<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    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.<br>
    <br>
    If you can give it a try and all works fine, it can be backported to
    3.2.<br>
    <br>
    Thanks,<br>
    Daniel<br>
    <br>
    On 10/25/11 2:09 PM, Jason Penton wrote:
    <blockquote
cite="mid:CALoGXNX0pLXi4TQRtSXEbmEK=ui8igWA1z8WPt9OqNC=Dvirrg@mail.gmail.com"
      type="cite">Hi All,<br>
      <br>
      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?):<br>
      <br>
      p.s. If there are no objections/responses I will commit to master
      branch.<br>
      <br>
      Cheers<br>
      Jason<br>
      <br>
      <span style="font-family: courier new,monospace;">int
        extract_mediaip(str *body, str *mediaip, int *pf, char *line)</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">{</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; char
        *cp, *cp1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int len;</span><br
        style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cp1 =
        NULL;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (cp
        = body-&gt;s; (len = body-&gt;s + body-&gt;len - cp) &gt; 0;) {</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        cp1 = (char*)ser_memmem(cp, line, len, 2);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        if (cp1 == NULL || cp1[-1] == '\n' || cp1[-1] == '\r')</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        break;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        cp = cp1 + 2;</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cp1
        == NULL)</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        mediaip-&gt;s = cp1 + 2;</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        mediaip-&gt;len = eat_line(mediaip-&gt;s, body-&gt;s +
        body-&gt;len - mediaip-&gt;s) - mediaip-&gt;s;</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        trim_len(mediaip-&gt;len, mediaip-&gt;s, *mediaip);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
        (mediaip-&gt;len == 0) {</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_ERR("no [%s] line in SDP\n",line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*
        search reverse for IP[4|6] in c=/o= line */</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cp =
        (char*)ser_memrmem(mediaip-&gt;s, " IP", mediaip-&gt;len, 3);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (cp
        == NULL) {</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_ERR("no `IP[4|6]' in `%s' field\n",line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <div style="text-align: left; font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <span style="background-color: rgb(255, 255, 51);">switch
          (cp[3]) {</span><br style="background-color: rgb(255, 255,
          51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          case '4':</span><br style="background-color: rgb(255, 255,
          51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          *pf = AF_INET;</span><br style="background-color: rgb(255,
          255, 51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          break;</span><br style="background-color: rgb(255, 255, 51);">
        <br style="background-color: rgb(255, 255, 51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          case '6':</span><br style="background-color: rgb(255, 255,
          51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          *pf = AF_INET6;</span><br style="background-color: rgb(255,
          255, 51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          break;</span><br style="background-color: rgb(255, 255, 51);">
        <span style="background-color: rgb(255, 255, 51);">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br>
      </div>
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*
        safety checks:</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * - for
        lenght, at least 6: ' IP[4|6] x...'</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * -
        white space after</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(cp +
        6 &gt; mediaip-&gt;s + mediaip-&gt;len &amp;&amp; cp[4]!=' ') {</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_ERR("invalid content for `%s' line\n",line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        if(cp[3]!='4' &amp;&amp; cp[3]!='6') {</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_ERR("invalid addrtype IPx for `%s' line\n",line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cp += 5;</span><br
        style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* next
        token is the IP address */</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cp =
        eat_space_end(cp, mediaip-&gt;s + mediaip-&gt;len);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; len =
        eat_token_end(cp, mediaip-&gt;s + mediaip-&gt;len) - cp;</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        mediaip-&gt;s = cp;</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        mediaip-&gt;len = len;</span><br style="font-family: courier
        new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if
        (mediaip-&gt;len == 0) {</span><br style="font-family: courier
        new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_ERR("no `IP[4|6]' address in `%s' field\n",line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        return -1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><br
        style="font-family: courier new,monospace;">
      <br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        LM_DBG("located IP address [%.*s] in `%s' field\n",</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        mediaip-&gt;len, mediaip-&gt;s, line);</span><br
        style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return
        1;</span><br style="font-family: courier new,monospace;">
      <span style="font-family: courier new,monospace;">}</span><br>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
sr-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
Kamailio Advanced Training, Dec 5-8, Berlin: <a class="moz-txt-link-freetext" href="http://asipto.com/u/kat">http://asipto.com/u/kat</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a></pre>
  </body>
</html>