[pjsip] Parsing expires from REGISTER reply

Alan J. Bond alan.bond at wintology.com
Sat May 3 21:38:03 EDT 2008

Hi again,

Have done the debugging.  Here is the fix but remember I'm very new to this code so please scrutinise carefully.   Comments for clarity only, please amend per your normal standards.

The value of expires= on the end of a Contact: header is indeed parsed correctly and placed in the  pjsip_contact_hdr structure.  The problem is in sip_reg.c toward the end of this function where it is discarded and not passed to the callback handler.   This change assumes that any SIP servers that exhibit this behaviour are only going to do so when returning a single Contact: header.  You may know different.

static void tsx_callback(void *token, pjsip_event *event)


      /* Increment busy flag temporarily to prevent regc from
       * being destroyed.

      /* Call callback. */

      /* Change to cope with old SER implementations that append */
      /* expires= to Contact: and do not create Expires: header  */
      /* 20080504 BEGIN -----------------------------------------*/

      /* if (expiration == NOEXP) expiration = -1;               */

      if (expiration == NOEXP)
        expiration = -1;
      else if (expiration == 0 && contact_cnt == 1 && contact[0]->expires > 0)
        expiration = contact[0]->expires;

      /* 20080504 END -------------------------------------------*/

      call_callback(regc, PJ_SUCCESS, tsx->status_code,
                    (rdata ? &rdata->msg_info.msg->line.status.reason
                           : pjsip_get_status_text(tsx->status_code)),
                    rdata, expiration,
                    contact_cnt, contact);

      /* Decrement busy flag */

    /* Delete the record if user destroy regc during the callback. */
    if (regc->_delete_flag && regc->busy==0) {

Please let me know if you think this will screw up other implementations.

Best Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080504/d8a462dd/attachment.html>

More information about the pjsip mailing list