Summary: | ASTERISK-12173: Asterisk can not register as SIP client to Cisco BTS due to faulty CSeq header parsing | ||
Reporter: | Tobias Engel (tobias_e) | Labels: | |
Date Opened: | 2008-06-11 07:53:25 | Date Closed: | 2008-06-17 13:03:41 |
Priority: | Major | Regression? | No |
Status: | Closed/Complete | Components: | Channels/chan_sip/Interoperability |
Versions: | Frequency of Occurrence | ||
Related Issues: | |||
Environment: | Attachments: | ( 0) 12834.patch | |
Description: | I came across a problem yesterday when I wanted to use Asterisk as a SIP client for a Cisco BTS. The registration failed, and after some tcpdumping I found out that Asterisk sends the following CSeq header: CSeq: 4 REGISTER and the CSeq header in the response by the BTS looks like this: CSeq: 4 REGISTER Asterisk fails to match that response to its request. At first I thought that this was a problem of the BTS behaving badly, since RFC 3261 states in 8.2.6.2: "The CSeq header field of the response MUST equal the CSeq field of the request." But in 20.16 it says: "Two CSeq header fields are considered equal if the sequence number and the request method are identical." So the fields *are* identical according to RFC 3261. The problem lies in chan_sip.c in the method "handle_response": const char *c = get_header(req, "Cseq"); const char *msg = strchr(c, ' '); if (!msg) msg = ""; else msg++; sipmethod = find_sip_method(msg); The strchr(c, ' ') would have to be replaced by something else since not only spaces but also tabs are allowed. Also, the "else" part of the if would have too look something like this: else while(*msg == ' ' || *msg == '\t') msg++; ****** ADDITIONAL INFORMATION ****** The problem is present at least in the current 1.4 and 1.6 versions of Asterisk. | ||
Comments: | By: Tobias Engel (tobias_e) 2008-06-11 07:57:10 Ok, this is not visible here due to the HTML output, but in the response from the Cisco BTS there are several spaces between the Sequence number and the method. By: Mark Michelson (mmichelson) 2008-06-12 14:34:29 Please test the attached patch to be sure it will work with the Cisco. I have checked to be sure that it still works with UAs which place a single space between the Cseq and request method. By: Tobias Engel (tobias_e) 2008-06-17 01:39:35 The patch seems to be working - I can now register and make calls via the Cisco BTS. By: Digium Subversion (svnbot) 2008-06-17 13:02:28 Repository: asterisk Revision: 123333 U branches/1.4/channels/chan_sip.c ------------------------------------------------------------------------ r123333 | mmichelson | 2008-06-17 13:02:25 -0500 (Tue, 17 Jun 2008) | 11 lines Cisco BTS sends SIP responses with a tab between the Cseq number and SIP request method in the Cseq: header. Asterisk did not handle this properly, but with this patch, all is well. (closes issue ASTERISK-12173) Reported by: tobias_e Patches: 12834.patch uploaded by putnopvut (license 60) Tested by: tobias_e ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=123333 By: Digium Subversion (svnbot) 2008-06-17 13:02:56 Repository: asterisk Revision: 123334 _U trunk/ U trunk/channels/chan_sip.c ------------------------------------------------------------------------ r123334 | mmichelson | 2008-06-17 13:02:55 -0500 (Tue, 17 Jun 2008) | 19 lines Merged revisions 123333 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r123333 | mmichelson | 2008-06-17 13:09:16 -0500 (Tue, 17 Jun 2008) | 11 lines Cisco BTS sends SIP responses with a tab between the Cseq number and SIP request method in the Cseq: header. Asterisk did not handle this properly, but with this patch, all is well. (closes issue ASTERISK-12173) Reported by: tobias_e Patches: 12834.patch uploaded by putnopvut (license 60) Tested by: tobias_e ........ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=123334 By: Digium Subversion (svnbot) 2008-06-17 13:03:41 Repository: asterisk Revision: 123335 _U branches/1.6.0/ U branches/1.6.0/channels/chan_sip.c ------------------------------------------------------------------------ r123335 | mmichelson | 2008-06-17 13:03:40 -0500 (Tue, 17 Jun 2008) | 27 lines Merged revisions 123334 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r123334 | mmichelson | 2008-06-17 13:09:54 -0500 (Tue, 17 Jun 2008) | 19 lines Merged revisions 123333 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r123333 | mmichelson | 2008-06-17 13:09:16 -0500 (Tue, 17 Jun 2008) | 11 lines Cisco BTS sends SIP responses with a tab between the Cseq number and SIP request method in the Cseq: header. Asterisk did not handle this properly, but with this patch, all is well. (closes issue ASTERISK-12173) Reported by: tobias_e Patches: 12834.patch uploaded by putnopvut (license 60) Tested by: tobias_e ........ ................ ------------------------------------------------------------------------ http://svn.digium.com/view/asterisk?view=rev&revision=123335 |