[pjsip] Problem for Pjsip to read "Expires" value from some 200/OK REGISTER Replies

Tanguy Floc'h electrocut at gmail.com
Thu Apr 17 04:26:33 EDT 2008


Hi !

I think there is a problem, when pjsip tries to get the Expire value, from
the 200 OK

Reply coming from a REGISTER Request.

The problem is for SIP messages like these, when "Expires" value had not its
own header field :

SIP/2.0 200 OK
Via: SIP/2.0/UDP 172.17.20.226:1265;rport;branch=z9hG4b...
To: <sip:101 at 172.17.20.226 <sip%3A101 at 172.17.20.226>>
From: <sip:101 at 172.17.20.226 <sip%3A101 at 172.17.20.226>>;tag=c8b125...
Call-ID: 99ed82...
CSeq: 22778 REGISTER
User-Agent: NCH Swift Sound Axon 1.30
Contact: <sip:101 at 172.17.20.226:1265>;expires=300;
Content-Length: 0

As you can see, expires value has not its own header field (like "Expires:
300"), but is put at the end of the "Contact" header field (.. ;
expires=300;)

That's what happen in this case :

When receiving the 200 OK Reply, from the REGISTER Request, the function
tsx_callback() in sig_reg.c tries to find the "Expires= ?" header field :

(line 718)
expires = (pjsip_expires_hdr*)pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES,
NULL);

but can't find this field in the SIP message.

If PJSIP_REGISTER_CLIENT_CHECK_CONTACT Param is set to 1, it is not a
problem if expire field can not be found in SIP 200/Ok Reply, because the
previous (and lower) value

(from the REGISTER Request) will be taken into account instead :

(line 760)
if (contact[i]->expires >= 0 && contact[i]->expires < expiration)
    expiration = contact[i]->expires;

But if PJSIP_REGISTER_CLIENT_CHECK_CONTACT Param is set to 0 (that's my
case), expiration value is set to -1, just before the callback is called,
line 810 in sig_reg.c

Consequently, when the callback function regc_cb in pjsua_acc.c test the
expiration value, it believes that it is a "succefful UNregistration",
instead of Registration (because expiration < 1)

A way to fix the problem could be :
- To read expires value in "pjsip_contact_hdr->expires", if
"pjsip_contact_hdr->ivalue" doesn't exist
or
- to compare the Expiration value, even if
PJSIP_REGISTER_CLIENT_CHECK_CONTACT is disable, so the previous value will
be taken into account instead.

Thanks !

Electrocut
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080417/5c07b05e/attachment.html>


More information about the pjsip mailing list