[Home]

Summary:ASTERISK-01206: Invalid Protocol Implementation - Very easy fix
Reporter:ivelin (ivelin)Labels:
Date Opened:2004-03-13 01:32:58.000-0600Date Closed:2008-01-15 14:47:10.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) sipcl.diff
Description:The SIP REGISTER message sends incorrectly spelled "Content-length"  header.
Reads with small "l" in "length". Should read "Content-Lendgth" with capital "L". As a result Asterisk cannot register with some SIP servers. More specifically Lucent Excel_CSP.

****** ADDITIONAL INFORMATION ******

When attempting to register, the SIP server times out because it does not recognize "Content-length" correctly and expects further input. Following is the message that Asterisk sends, which causes the connection to the SIP server to time out.

-----------------
REGISTER sip:xchange.terracall.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.11:5060;branch=z9hG4bK0b60a35e
From: <sip:5314227537@xchange.terracall.com>;tag=as5ce63620
To: <sip:5314227537@xchange.terracall.com>
Call-ID: 3d29f45005dc7aff318513496e7b77fb@192.168.0.11
CSeq: 103 REGISTER
User-Agent: Asterisk PBX
Expires: 120
Contact: <sip:7002@192.168.0.11>
Event: registration
Content-length: 0
-----------------------------

However the same message with only one character changed ("l" to "L" in "length") is processed better:

-------------------------------
REGISTER sip:xchange.terracall.com SIP/2.0
Via: SIP/2.0/UDP 192.168.0.11:5060;branch=z9hG4bK0b60a35e
From: <sip:5314227537@xchange.terracall.com>;tag=as5ce63620
To: <sip:5314227537@xchange.terracall.com>
Call-ID: 3d29f45005dc7aff318513496e7b77fb@192.168.0.11
CSeq: 103 REGISTER
User-Agent: Asterisk PBX
Expires: 120
Contact: <sip:7002@192.168.0.11>
Event: registration
Content-Length: 0

SIP/2.0 100 Trying
To: <sip:5314227537@xchange.terracall.com>;tag=109272620
From: <sip:5314227537@xchange.terracall.com>;tag=as5ce63620
Call-ID: 3d29f45005dc7aff318513496e7b77fb@192.168.0.11
CSeq: 103 REGISTER
Via: SIP/2.0/UDP 192.168.0.11:5060;branch=z9hG4bK0b60a35e;received=66.136.199.22
1
User-Agent: Excel_CSP/82.20.84
Content-Length: 0

SIP/2.0 200 OK
To: <sip:5314227537@xchange.terracall.com>;tag=109272620
From: <sip:5314227537@xchange.terracall.com>;tag=as5ce63620
Call-ID: 3d29f45005dc7aff318513496e7b77fb@192.168.0.11
CSeq: 103 REGISTER
Contact: 7002<sip:7002@192.168.0.11>
Via: SIP/2.0/UDP 192.168.0.11:5060;branch=z9hG4bK0b60a35e;received=66.136.199.22
1
User-Agent: Excel_CSP/82.20.84
Content-Length: 0

------------------------------
Comments:By: Brian West (bkw918) 2004-03-13 16:03:59.000-0600

What does the RFC say about this?

By: ivelin (ivelin) 2004-03-13 16:39:28.000-0600

The RFC calls for capital "L": Content-Length
http://www.faqs.org/rfcs/rfc2543.html
http://www.zvon.org/tmRFC/RFC3665/Output/chapter2.html
The RFC does not explicitly say whether the letters should as given in the RFC doc.

I tried several SIP agents - XTEN, ATA-186, SER. They all use capital "L".

Would you be able to fix it? I would like to but I need to get my hands around the Asterisk CVS first. If you point me to the source code that prints the "Content-Length" header, I'll submit the patch.

Cheers,

Ivelin

By: zoa (zoa) 2004-03-13 17:01:04.000-0600

julius:/usr/src/asterisk # grep -ri "Content-Length" *
channels/chan_sip.c:    { "Content-Length", "l" },
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");
channels/chan_sip.c:    add_header(req, "Content-Length", clen);
channels/chan_sip.c:    add_header(req, "Content-Length", clen);
channels/chan_sip.c:    add_header(resp, "Content-Length", costr);
channels/chan_sip.c:            add_header(&req, "Content-Length", "0");
channels/chan_sip.c:    add_header(&req, "Content-Length", clen);
channels/chan_sip.c:    add_header(&req, "Content-Length", clen);
channels/chan_sip.c:    add_header(&req, "Content-length", "0");
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");
channels/chan_sip.c:    add_header(&resp, "Content-Length", "0");

By: ivelin (ivelin) 2004-03-13 22:53:57.000-0600

Thanks for the output. Seems like the bug is in channels/chan_sip.c: add_header(&req, "Content-length", "0"); ?
Can you confirm?

Ivelin

By: Olle Johansson (oej) 2004-03-14 04:17:32.000-0600

Patch uploaded. Didn't change it according to 'Should read "Content-Lendgth"  thought, since I thought it would add another problem ;-)

By: zoa (zoa) 2004-03-14 04:59:20.000-0600

can this be added to cvs ? don't think this can break something as the source is already filled with LLLLLLength's

By: Olle Johansson (oej) 2004-03-14 05:03:50.000-0600

Just kidding, zoa, this is ready for CVS without breaking anything. Just thought the initial miss-spelling in the bug report (see above) was rather funny.

By: zoa (zoa) 2004-03-14 05:30:29.000-0600

yeah i know, i got that one :)
(i just don't have cvs commit privs)

By: ivelin (ivelin) 2004-03-14 09:02:57.000-0600

Thanks guys. So what's wrong with an extra "d" in there ;)

If I build from CVS now, would I have the patch there?

Ivelin

By: Malcolm Davenport (mdavenport) 2004-03-14 21:13:38.000-0600

Fixed in CVS.  Thank you. :)

By: Digium Subversion (svnbot) 2008-01-15 14:47:09.000-0600

Repository: asterisk
Revision: 2429

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r2429 | malcolmd | 2008-01-15 14:47:09 -0600 (Tue, 15 Jan 2008) | 2 lines

Bug ASTERISK-1206.  Fix for improperly specified Content-Length header

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=2429

By: Digium Subversion (svnbot) 2008-01-15 14:47:10.000-0600

Repository: asterisk
Revision: 2430

U   branches/v1-0_stable/channels/chan_sip.c

------------------------------------------------------------------------
r2430 | malcolmd | 2008-01-15 14:47:10 -0600 (Tue, 15 Jan 2008) | 2 lines

Bug ASTERISK-1206: Fix for improperly specified Content-Length header

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=2430