[sr-dev] Why was IP type parsing removed from sdp in parser?
Daniel-Constantin Mierla
miconda at gmail.com
Tue Oct 25 17:40:52 CEST 2011
Hello,
extract_mediaip() was pretty much completely refactored since there was
a bug reported by Juha, resulting in missing the setting of IP address
type. Reverting would have been wrong -- I just committed a patch to set
the address, but slightly different, to set it after the other checks
for it are done.
If you can give it a try and all works fine, it can be backported to 3.2.
Thanks,
Daniel
On 10/25/11 2:09 PM, Jason Penton wrote:
> Hi All,
>
> Just curious as to why the parsing of IP type was removed from
> extract_mediaip in parser/sdp/sdp_helper_funcs.c. The latest code
> looks like below (could I suggest adding the highlighted part?):
>
> p.s. If there are no objections/responses I will commit to master branch.
>
> Cheers
> Jason
>
> int extract_mediaip(str *body, str *mediaip, int *pf, char *line)
> {
> char *cp, *cp1;
> int len;
>
> cp1 = NULL;
> for (cp = body->s; (len = body->s + body->len - cp) > 0;) {
> cp1 = (char*)ser_memmem(cp, line, len, 2);
> if (cp1 == NULL || cp1[-1] == '\n' || cp1[-1] == '\r')
> break;
> cp = cp1 + 2;
> }
> if (cp1 == NULL)
> return -1;
>
> mediaip->s = cp1 + 2;
> mediaip->len = eat_line(mediaip->s, body->s + body->len -
> mediaip->s) - mediaip->s;
> trim_len(mediaip->len, mediaip->s, *mediaip);
> if (mediaip->len == 0) {
> LM_ERR("no [%s] line in SDP\n",line);
> return -1;
> }
>
> /* search reverse for IP[4|6] in c=/o= line */
> cp = (char*)ser_memrmem(mediaip->s, " IP", mediaip->len, 3);
> if (cp == NULL) {
> LM_ERR("no `IP[4|6]' in `%s' field\n",line);
> return -1;
> }
>
> switch (cp[3]) {
> case '4':
> *pf = AF_INET;
> break;
>
> case '6':
> *pf = AF_INET6;
> break;
> }
>
> /* safety checks:
> * - for lenght, at least 6: ' IP[4|6] x...'
> * - white space after
> */
> if(cp + 6 > mediaip->s + mediaip->len && cp[4]!=' ') {
> LM_ERR("invalid content for `%s' line\n",line);
> return -1;
> }
> if(cp[3]!='4' && cp[3]!='6') {
> LM_ERR("invalid addrtype IPx for `%s' line\n",line);
> return -1;
> }
> cp += 5;
>
> /* next token is the IP address */
> cp = eat_space_end(cp, mediaip->s + mediaip->len);
> len = eat_token_end(cp, mediaip->s + mediaip->len) - cp;
> mediaip->s = cp;
> mediaip->len = len;
>
> if (mediaip->len == 0) {
> LM_ERR("no `IP[4|6]' address in `%s' field\n",line);
> return -1;
> }
>
> LM_DBG("located IP address [%.*s] in `%s' field\n",
> mediaip->len, mediaip->s, line);
> return 1;
> }
>
>
>
> _______________________________________________
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-dev/attachments/20111025/a1baa6ec/attachment-0001.htm>
More information about the sr-dev
mailing list