summaryrefslogtreecommitdiff
path: root/res/res_pjsip_registrar.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-02-21 19:28:09 +0000
committerJoshua Colp <jcolp@digium.com>2015-02-21 19:28:09 +0000
commit87b7060f3657f00e32d8da3673fa407157e5eebf (patch)
tree7d985b9341f4205c267ac562cea5560f7bffe621 /res/res_pjsip_registrar.c
parent283bb15c16c383f14b60a503e655b708f9ed791e (diff)
res_pjsip_registrar: Add Expires header to 200 OK if present in REGISTER.
Some implementations don't pay attention to the expires for individual contacts. In this case they may consider the lack of an Expires header in the 200 OK as unregistered. This change makes it so if an Expires header is present in the REGISTER we will add one in the 200 OK. ASTERISK-24785 #close Reported by: Ross Beer ........ Merged revisions 432136 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@432137 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_registrar.c')
-rw-r--r--res/res_pjsip_registrar.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/res/res_pjsip_registrar.c b/res/res_pjsip_registrar.c
index daeeec9b8..7fe2b77d9 100644
--- a/res/res_pjsip_registrar.c
+++ b/res/res_pjsip_registrar.c
@@ -57,7 +57,7 @@ static int registrar_get_expiration(const struct ast_sip_aor *aor, const pjsip_c
pjsip_expires_hdr *expires;
int expiration = aor->default_expiration;
- if (contact->expires != -1) {
+ if (contact && contact->expires != -1) {
/* Expiration was provided with the contact itself */
expiration = contact->expires;
} else if ((expires = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL))) {
@@ -424,6 +424,7 @@ static int rx_task(void *data)
struct ast_sip_contact *response_contact;
char *user_agent = NULL;
pjsip_user_agent_hdr *user_agent_hdr;
+ pjsip_expires_hdr *expires_hdr;
/* Retrieve the current contacts, we'll need to know whether to update or not */
contacts = ast_sip_location_retrieve_aor_contacts(task_data->aor);
@@ -597,6 +598,11 @@ static int rx_task(void *data)
ao2_callback(contacts, 0, registrar_add_contact, tdata);
+ if ((expires_hdr = pjsip_msg_find_hdr(task_data->rdata->msg_info.msg, PJSIP_H_EXPIRES, NULL))) {
+ expires_hdr = pjsip_expires_hdr_create(tdata->pool, registrar_get_expiration(task_data->aor, NULL, task_data->rdata));
+ pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr*)expires_hdr);
+ }
+
if (pjsip_get_response_addr(tdata->pool, task_data->rdata, &addr) == PJ_SUCCESS) {
ast_sip_send_response(&addr, tdata, task_data->endpoint);
} else {