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