Hi, Cindy!

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.

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.

The reason why the message is not sent over UDP has a different cause. Are you trying to somehow modify the message body?

Best regards,

Razvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com

On 03/25/2013 10:06 PM, Cindy Leung wrote:
Hi Razvan,

This is a part of the config that's supposed to catch parse errors:

error_route{
xlog ("Entering error route");

# SIP message parse error
if ( $(err.class)==1 ) {
        xlog ("Parse error from $si:$sp");
        xlog ("$mb");
        sl_send_reply("$err.rcode", "$err.rreason");
        exit;
}

else {
xlog ("Error class=$(err.class) level=$(err.level) info=$(err.info <http://err.info>)");
}
}

route{
if ( !sipmsg_validate() ) {
        xlog ("Bad request from $si:$sp");
        xlog ("$mb");
        sl_send_reply("400", "Bad Request");
        exit;
}
...

I'm sure it didn't go through error route for TCP because none of the xlog messages showed up in syslog. I've also tried "s", "sh", and nothing as flags for sipmsg_validate. Same error every time.

Thanks.


Cindy


On Mar 25, 2013, at 1:26 PM, Răzvan Crainea wrote:

Hi Cindy!

for TCP: the error seems to occur while reading the message. Are you sure the error route is not called for this type? for UDP: Are you passing any flags to the sipmsg_validate() function? Have you tried using the 's' flag [1]?

[1] http://www.opensips.org/html/docs/modules/1.9.x/sipmsgops.html#id293070

Best regards,
Razvan Crainea
OpenSIPS Core Developer
http://www.opensips-solutions.com
On 03/22/2013 02:30 AM, Cindy Leung wrote:
Hi all,

So we encountered a malformed SIP message one day that looks like this...

INVITE sip:[email protected]:5060 SIP/2.0
Via: SIP/2.0/UDP 127.0.1.1:5060;branch=z9hG4bK-15598-12-0
From: sipp <sip:[email protected]>;tag=12
To: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 1 INVITE
Contact: "1234" <sip:[email protected]:5060;transport=udp>
User-Agent: SIPp
Max-Forwards: 70
Content-Type: application/sdp
Content-Lenght: 0

Typo in Content-Length.

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.

TCP:
/usr/local/sbin/opensips[18814]: ERROR:core:tcp_read_req: bad request, state=4, error=4 buf: <SIP message here>

UDP:
/usr/local/sbin/opensips[18804]: ERROR:core:clen_builder: no message body found (missing crlf?) /usr/local/sbin/opensips[18804]: ERROR:core:build_req_buf_from_sip_req: failed to adjust Content-Length /usr/local/sbin/opensips[18804]: ERROR:tm:print_uac_request: no more shm_mem /usr/local/sbin/opensips[18804]: ERROR:tm:t_forward_nonack: failure to add branches

Can you let me know if I have missed anything please?  Thanks!


Cindy


_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected] <mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users



_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to