[sr-dev] Improving "get_body_part" (parse_body)

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 27 19:17:49 CEST 2011


Hello,

my suggestion is to make new functions for what you need and not alter 
the existing ones that may break existing code. Then send us the patch, 
ideally taken with 'git diff' if you used sources from git repository, 
if not use diff with -u option.

Then upload the patch along with description of what it does to our tracker:

http://sip-router.org/tracker/

There is a place where any of the developers can review and comment, 
then commit if all is fine.

Thanks,
Daniel

On 10/27/11 2:51 PM, Luis Martin Gil wrote:
> Hello,
>
> I'm developing a module for Kamailio. I had to use some features that
> weren't developed so I implemented them by myself. I made a new function
> that can replace the existing get_body_part() of the
> "parser/parse_body.c" module.
>
> char *get_body_part(struct sip_msg *msg, unsigned short type, unsigned
> short subtype, int *len)
>
> This function allows you to pick the first multipart part of the SIP
> message which matches TYPE/SUBTYPE. It will return a pointer to the
> multipart structure as well as its length. The code it is not
> easy-readable but this function is working great. The point is, what if
> I would like to search a multipart part within a SIP message that
> matches TYPE/SUBTYPE but also the Content-ID header or the
> Content-Length header?
>
> I made this function:
> char *get_body_part_strict(struct sip_msg *msg, unsigned short
> content_type, unsigned short content_subtype, char *content_id, char
> *content_length, int *len)
>
> It returns the first multipart part of the SIP message which matches
> "TYPE/SUBTYPE" and/or the "Content-ID" and/or the "Content-Length", and
> its length. If you want to be less restrictive, you can unflag the
> parameter by:
> - setting 0/0 in case of the TYPE/SUBTYPE.
> - setting NULL in case of the Content-ID and the Content-Length.
>
> So setting Content-Length == NULL will make the function to skip the
> Content-Length from its filter and will give you back the first part
> which matches the TYPE/SUBTYPE and Content-ID, and its length.
>
> I think this could be very useful for someone who wants to retrieve
> specific parts of the multipart, this was my case. I would really like
> to contribute back to Kamailio platform back and I would appreciate if
> anyone can point me the correct contact information to check the
> viability of this adding.
>
>
> Thanks,
> Luis Martin Gil
>
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
Kamailio Advanced Training, Dec 5-8, Berlin: http://asipto.com/u/kat
http://linkedin.com/in/miconda -- http://twitter.com/miconda




More information about the sr-dev mailing list