[asterisk-dev] Asterisks CSeq parsing not RFC 3261 compliant

Tobias Engel t-asterisk-dev at tobias.org
Wed Jun 11 04:55:41 CDT 2008


Hi,

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++;


The problem is present at least in the current 1.4 and 1.6 versions of 
Asterisk.

(Is this even the right place to report such an issue?)


-Tobias



More information about the asterisk-dev mailing list