[Devel] [Fwd: Re: [Serdev] patch: nathelper content-length]

Klaus Darilion klaus.mailinglists at pernau.at
Mon Mar 12 12:02:13 CET 2007


Hi!

I wonder how openser handles the SIP PING by nathelper - does it contain 
a Content-Length header when sent via TCP/TLS?

regards
klaus

-------- Original Message --------
Subject: Re: [Serdev] patch: nathelper content-length
Date: Wed, 07 Mar 2007 12:15:43 +0100
From: Alfred E. Heggestad <aeh at db.org>
To: Maxim Sobolev <sobomax at sippysoft.com>
CC: serdev at iptel.org
References: <45EDF6A9.6080300 at db.org> <45EE135A.2080001 at sippysoft.com>

Hi Maxim

I think that Content-Length header should be present in all outgoing
SIP messages, even if body is empty and even for UDP. Some might
argue that it is not strictly necessary to add Content-Length for
UDP messages with empty body, and might increase processing.

But from a simplistic perspective I think that *always* adding
a Content-Length header will reduce number of bugs in the future
(like this one)..

Please see another patch (attached) which does the fix in the
TM module instead. I have tested it and it works for nathelper/options
but some SER expert should review it carefully..


/alfred

Maxim Sobolev wrote:
> I wonder if it should be fixed in the tm module instead. It should 
> include Content-Length into every request generated by the t_request. 
> Right now it only does it for requests that contain body.
> 
> What do people think?
> 
> -Maxim
> 
> Alfred E. Heggestad wrote:
>> hi
>>
>> ser v2.0.0-rc1:
>>
>> when nathelper ping is enabled with e.g. method OPTIONS, and keepalives
>> are sent using TCP transport, I found that the OPTIONS message was 
>> missing
>> the mandatory Content-Length header for TCP. This is required by RFC3261
>> to handle de-framing for incoming TCP packets.
>>
>> the attached patch adds "Content-Length: 0\r\n" for all outgoing natping
>> packets, it works but can probably be improved. please consider for CVS..
>>
>>
>> /alfred
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>> Index: modules/nathelper/natping.c
>> ===================================================================
>> RCS file: /cvsroot/ser/sip_router/modules/nathelper/natping.c,v
>> retrieving revision 1.8
>> diff -u -1 -r1.8 natping.c
>> --- modules/nathelper/natping.c    17 Jun 2006 00:21:27 -0000    1.8
>> +++ modules/nathelper/natping.c    6 Mar 2007 22:53:24 -0000
>> @@ -149,3 +149,3 @@
>>      struct hostent *he;
>> -    str p_method, p_from;
>> +    str p_method, p_from, p_hdr;
>>  
>> @@ -157,4 +157,6 @@
>>          p_from.len = strlen(p_from.s);
>> +        p_hdr.s = CONTENT_LENGTH "0" CRLF;
>> +        p_hdr.len = CONTENT_LENGTH_LEN + 1 + CRLF_LEN;
>>          if (tmb.t_request(&p_method, &contact, &contact, &p_from,
>> -            NULL, NULL, NULL, NULL, NULL) == -1) {
>> +            &p_hdr, NULL, NULL, NULL, NULL) == -1) {
>>              LOG(L_ERR, "ERROR: nathelper::natping(): t_request() 
>> failed\n");
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Serdev mailing list
>> Serdev at lists.iptel.org
>> http://lists.iptel.org/mailman/listinfo/serdev
> 





-- 
Klaus Darilion
nic.at

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ser-tm-cl.patch
Type: text/x-patch
Size: 1274 bytes
Desc: not available
Url : http://openser.org/pipermail/devel/attachments/20070312/84156e4c/ser-tm-cl.bin
-------------- next part --------------
_______________________________________________
Serdev mailing list
Serdev at lists.iptel.org
http://lists.iptel.org/mailman/listinfo/serdev



More information about the Devel mailing list