From 91ce3c4bf51a884f7534551669e38d6b44a2da55 Mon Sep 17 00:00:00 2001 From: Liong Sauw Ming Date: Fri, 5 Dec 2014 04:03:06 +0000 Subject: Fixed #1805: Make UAS as refresher in session timer when UAC doesn't support it (thanks to Glenn Walbran for the patch) git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4967 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsip-ua/sip_timer.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'pjsip') diff --git a/pjsip/src/pjsip-ua/sip_timer.c b/pjsip/src/pjsip-ua/sip_timer.c index c1831587..9417325f 100644 --- a/pjsip/src/pjsip-ua/sip_timer.c +++ b/pjsip/src/pjsip-ua/sip_timer.c @@ -1088,10 +1088,29 @@ PJ_DEF(pj_status_t) pjsip_timer_process_req(pjsip_inv_session *inv, /* Update refresher role */ inv->timer->refresher = as_refresher? TR_UAS : TR_UAC; } else { - /* If UAC support timer (currently check the existance of - * Session-Expires header in the request), set UAC as refresher. + /* If UAC supports timer and Session-Expires header is present + * in the request, set UAC as refresher. + * If UAC doesn't support timer and a proxy inserts a + * Session-Expires header, then UAS has to be the + * refresher (according to RFC 4028 Section 9). */ - inv->timer->refresher = se_hdr? TR_UAC : TR_UAS; + pj_bool_t uac_supports_timer = PJ_FALSE; + pjsip_supported_hdr *sup_hdr; + + sup_hdr = (pjsip_supported_hdr*) + pjsip_msg_find_hdr(msg, PJSIP_H_SUPPORTED, NULL); + if (sup_hdr) { + unsigned i; + + for (i = 0; i < sup_hdr->count; i++) { + if (pj_stricmp(&sup_hdr->values[i], &STR_TIMER) == 0) { + uac_supports_timer = PJ_TRUE; + break; + } + } + } + inv->timer->refresher = (uac_supports_timer && se_hdr)? TR_UAC: + TR_UAS; } } -- cgit v1.2.3