<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix"><tt>Hi, Cindy!<br>
        <br>
        The problem with the TCP is that the message doesn't even get to
        OpenSIPS script, because the message is dropped from the network
        level. Not having a Content-Length, the TCP mechanism does not
        know how many bytes it has to read, therefore it fails, and the
        error_route is never called.<br>
        <br>
        For the UDP, the sipmsg_validate() function does not fail
        because there is nothing wrong with the SIP message. For
        non-stream protocols (like UDP), the 'Content-Length' header is
        not mandatory, and it considers 'Content-Lenght' a custom
        header, therefore it skips it.<br>
        <br>
        The reason why the message is not sent over UDP has a different
        cause. Are you trying to somehow modify the message body?<br>
        <br>
        Best regards,<br>
      </tt>
      <pre class="moz-signature" cols="72">Razvan Crainea
OpenSIPS Core Developer
<a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a>
</pre>
      On 03/25/2013 10:06 PM, Cindy Leung wrote:<br>
    </div>
    <blockquote
      cite="mid:8D236C4D-325E-4E4F-A4E5-F03B8811749C@gmail.com"
      type="cite">
      <div>Hi Razvan,</div>
      <div><br>
      </div>
      <div>This is a part of the config that's supposed to catch parse
        errors:</div>
      <div><br>
      </div>
      <div>
        <div><font class="Apple-style-span" face="'Courier New'">error_route{</font></div>
        <div><font class="Apple-style-span" face="'Courier New'"><span
              class="Apple-tab-span" style="white-space:pre"> xlog
              ("Entering error route");</span></font></div>
        <div><font class="Apple-style-span" face="'Courier New'"><br>
          </font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            # SIP message parse error        </font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            if ( $(err.class)==1 ) {</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    xlog ("Parse error from $si:$sp");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    xlog ("$mb");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    sl_send_reply("$err.rcode", "$err.rreason");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    exit;</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            }</font></div>
        <div><font class="Apple-style-span" face="'Courier New'"><br>
          </font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            else {</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    xlog ("Error class=$(err.class) level=$(err.level)
            info=$(<a moz-do-not-send="true" href="http://err.info">err.info</a>)");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            }</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">}</font></div>
        <div><font class="Apple-style-span" face="'Courier New'"><br>
          </font></div>
        <div><font class="Apple-style-span" face="'Courier New'">route{</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            if ( !sipmsg_validate() ) {</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    xlog ("Bad request from $si:$sp");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    xlog ("$mb");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    sl_send_reply("400", "Bad Request");</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
                    exit;</font></div>
        <div><font class="Apple-style-span" face="'Courier New'">       
            }</font></div>
      </div>
      <div><font class="Apple-style-span" face="'Courier New'">...</font></div>
      <div><br>
      </div>
      <div>I'm sure it didn't go through error route for TCP because
        none of the xlog messages showed up in syslog.</div>
      <div>I've also tried "s", "sh", and nothing as flags for
        sipmsg_validate.  Same error every time.</div>
      <div><br>
      </div>
      <div>Thanks.</div>
      <div><br>
      </div>
      <div><br>
      </div>
      <div>Cindy</div>
      <div><br>
      </div>
      <br>
      <div>
        <div>On Mar 25, 2013, at 1:26 PM, Răzvan Crainea wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">
          <meta content="text/html; charset=UTF-8"
            http-equiv="Content-Type">
          <div text="#000000" bgcolor="#FFFFFF">
            <div class="moz-cite-prefix"><tt>Hi Cindy!<br>
                <br>
                for TCP: the error seems to occur while reading the
                message. Are you sure the error route is not called for
                this type?<br>
                for UDP: Are you passing any flags to the
                sipmsg_validate() function? Have you tried using the 's'
                flag [1]?<br>
                <br>
                [1] </tt><a moz-do-not-send="true"
href="http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id293070">http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id293070</a><br>
              <br>
              Best regards,<br>
              <pre class="moz-signature" cols="72">Razvan Crainea
OpenSIPS Core Developer
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.opensips-solutions.com/">http://www.opensips-solutions.com</a>
</pre>
              On 03/22/2013 02:30 AM, Cindy Leung wrote:<br>
            </div>
            <blockquote
              cite="mid:D3BEFA1C-81E3-419A-9248-B0BFA42CE4E5@gmail.com"
              type="cite">Hi all,
              <div><br>
              </div>
              <div>So we encountered a malformed SIP message one day
                that looks like this...</div>
              <div><br>
              </div>
              <div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">INVITE
                    <a moz-do-not-send="true"
                      href="sip:2345@my.opensips.server.IP:5060">sip:2345@my.opensips.server.IP:5060</a>
                    SIP/2.0</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Via:
                    SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK-15598-12-0</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">From:
                    sipp &lt;<a moz-do-not-send="true"
                      href="sip:1234@127.0.1.1">sip:1234@127.0.1.1</a>&gt;;tag=12</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">To:
                    &lt;<a moz-do-not-send="true" href="sip:2345@">sip:2345@</a></font><span
                    class="Apple-style-span" style="font-family:
                    'Courier New'; ">my.opensips.server.IP</span><font
                    class="Apple-style-span" face="'Courier New'">:5060&gt;</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Call-ID:
                    <a moz-do-not-send="true"
                      class="moz-txt-link-abbreviated"
                      href="mailto:12-15598@127.0.1.1">12-15598@127.0.1.1</a></font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">CSeq:
                    1 INVITE</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Contact:
                    "1234" &lt;<a moz-do-not-send="true"
                      href="sip:1234@127.0.1.1:5060;transport=udp">sip:1234@127.0.1.1:5060;transport=udp</a>&gt;</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">User-Agent:
                    SIPp</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Max-Forwards:
                    70</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Content-Type:
                    application/sdp</font></div>
                <div style="margin-top: 0px; margin-right: 0px;
                  margin-bottom: 0px; margin-left: 0px; font: normal
                  normal normal 12px/normal Helvetica; "><font
                    class="Apple-style-span" face="'Courier New'">Content-Lenght:
                    0</font></div>
              </div>
              <div><br>
              </div>
              <div>Typo in Content-Length.</div>
              <div><br>
              </div>
              <div>This message successfully passed through error_route
                and sipmsg_validate() and continue through the rest of
                the config.  Interesting enough, I get different errors
                when I send it over different protocol.</div>
              <div><br>
              </div>
              <div>TCP:</div>
              <div>/usr/local/sbin/opensips[18814]:
                ERROR:core:tcp_read_req: bad request, state=4, error=4
                buf: &lt;SIP message here&gt;</div>
              <div><br>
              </div>
              <div>UDP:</div>
              <div>
                <div>/usr/local/sbin/opensips[18804]:
                  ERROR:core:clen_builder: no message body found
                  (missing crlf?)</div>
                <div>/usr/local/sbin/opensips[18804]:
                  ERROR:core:build_req_buf_from_sip_req: failed to
                  adjust Content-Length</div>
                <div>/usr/local/sbin/opensips[18804]:
                  ERROR:tm:print_uac_request: no more shm_mem</div>
                <div>/usr/local/sbin/opensips[18804]:
                  ERROR:tm:t_forward_nonack: failure to add branches</div>
              </div>
              <div><br>
              </div>
              <div>Can you let me know if I have missed anything please?
                 Thanks!</div>
              <div><br>
              </div>
              <div><br>
              </div>
              <div>Cindy</div>
              <br>
              <fieldset class="mimeAttachmentHeader"></fieldset>
              <br>
              <pre wrap="">_______________________________________________
Users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
            </blockquote>
            <br>
          </div>
          _______________________________________________<br>
          Users mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a><br>
          <a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
        </blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>