[Home]

Summary:ASTERISK-17409: [patch] Session timer refresher incorrect
Reporter:nohara (nohara)Labels:
Date Opened:2011-02-15 05:55:40.000-0600Date Closed:2011-07-26 14:37:41
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/Interoperability
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_sip_sample.c
Description:Asterisk appears to request a refresher role swap relative to the original refresher roles established in the initial INVITE that set up the session/dialog, but does not actually perform the refreshes.  


GW -(1)-> Asterisk --> UA

(1)
In the 200 OK that establishes the dialog (the response to the initial INVITE),
Asterisk sends the SST headers:

   Supported: timer
   Session-Expires: 180;refresher=uac

This establishes the UAC (the GW) as the refresher for this session.
Asterisk sends a reinvite to the GW by canreinvite with the following headers:

   Require: timer
   Session-Expires: 180;refresher=uac

This establishes the UAC (Asterisk ) as the refresher for this session.
Asterisk does not, however, actually send any reinvites.

It looks like issue 18127.
https://issues.asterisk.org/view.php?id=18127


****** ADDITIONAL INFORMATION ******

I sends chan_sip_sample.c for bug FIX.
Please check the chan_sip_sample.c.

<inline patch removed by lmadsen>
Comments:By: Leif Madsen (lmadsen) 2011-02-16 15:39:24.000-0600

I have removed your inline patch as that is not permitted. Please sign the agreement by clicking the appropriate link at the top of the page, and upon confirmation of your agreement then attach your patch as a unified diff to this issue.

By: Leif Madsen (lmadsen) 2011-02-16 15:40:29.000-0600

Updated to requiring a license.

By: nohara (nohara) 2011-02-17 09:55:19.000-0600

I'm sorry.
I signed the license.
Please check the chan_sip_sample.c.


$ diff -u chan_sip.c chan_sip_sample.c
--- chan_sip.c 2011-02-18 00:47:12.282779200 +0900
+++ chan_sip_sample.c 2011-02-18 00:49:35.178252800 +0900
@@ -1515,6 +1515,7 @@
int st_active_peer_ua;                  /*!< Session-Timers on/off in peer UA */
int st_cached_min_se;                   /*!< Session-Timers cached Min-SE */
int st_cached_max_se;                   /*!< Session-Timers cached Session-Expires */
+ int st_refresher_self;                  /*!< Session-Timers session refresher is self */
enum st_mode st_cached_mode;            /*!< Session-Timers cached M.O. */
enum st_refresher st_cached_ref;        /*!< Session-Timers cached refresher */
unsigned char quit_flag:1;              /*!< Stop trying to lock; just quit */
@@ -9731,6 +9732,11 @@
*/
if (p->stimer && p->stimer->st_active == TRUE && p->stimer->st_active_peer_ua == TRUE
   && sipmethod == SIP_INVITE) {
+ if (p->stimer->st_refresher_self == TRUE) {
+ p->stimer->st_ref = SESSION_TIMER_REFRESHER_UAC;
+ } else {
+ p->stimer->st_ref = SESSION_TIMER_REFRESHER_UAS;
+ }
char se_hdr[256];
snprintf(se_hdr, sizeof(se_hdr), "%d;refresher=%s", p->stimer->st_interval,
strefresher2str(p->stimer->st_ref));
@@ -17964,7 +17970,7 @@
}

/* Check for Session-Timers related headers */
- if (st_get_mode(p) != SESSION_TIMER_MODE_REFUSE && p->outgoing_call == TRUE && !reinvite) {
+ if (st_get_mode(p) != SESSION_TIMER_MODE_REFUSE) {
p_hdrval = (char*)get_header(req, "Session-Expires");
if (!ast_strlen_zero(p_hdrval)) {
/* UAS supports Session-Timers */
@@ -17977,19 +17983,28 @@
if (tmp_st_ref == SESSION_TIMER_REFRESHER_UAC ||
tmp_st_ref == SESSION_TIMER_REFRESHER_UAS) {
p->stimer->st_ref = tmp_st_ref;
+ if (tmp_st_ref == SESSION_TIMER_REFRESHER_UAC) {
+ p->stimer->st_refresher_self = TRUE;
+ } else {
+ p->stimer->st_refresher_self = FALSE;
+ }
}
if (tmp_st_interval) {
p->stimer->st_interval = tmp_st_interval;
}
p->stimer->st_active = TRUE;
p->stimer->st_active_peer_ua = TRUE;
- start_session_timer(p);
+ if (!reinvite) {
+ start_session_timer(p);
+ }
} else {
/* UAS doesn't support Session-Timers */
if (st_get_mode(p) == SESSION_TIMER_MODE_ORIGINATE) {
p->stimer->st_ref = SESSION_TIMER_REFRESHER_UAC;
p->stimer->st_active_peer_ua = FALSE;
- start_session_timer(p);
+ if (!reinvite) {
+ start_session_timer(p);
+ }
}
}
}
@@ -20487,6 +20502,12 @@
}
}

+ if (st_ref == SESSION_TIMER_REFRESHER_UAS) {
+ p->stimer->st_refresher_self = TRUE;
+ } else {
+ p->stimer->st_refresher_self = FALSE;
+ }
+
if (!req->ignore && p)
p->lastinvite = seqno;

@@ -22884,29 +22905,24 @@
goto return_unref;
}

- switch (p->stimer->st_ref) {
- case SESSION_TIMER_REFRESHER_UAC:
- if (p->outgoing_call == TRUE) {
-   sendreinv = TRUE;
- }
- break;
- case SESSION_TIMER_REFRESHER_UAS:
- if (p->outgoing_call != TRUE) {
-   sendreinv = TRUE;
- }
- break;
- default:
- ast_log(LOG_ERROR, "Unknown session refresher %d\n", p->stimer->st_ref);
- goto return_unref;
+ if (p->stimer->st_ref != SESSION_TIMER_REFRESHER_UAC &&
+ p->stimer->st_ref != SESSION_TIMER_REFRESHER_UAS) {
+ ast_log(LOG_ERROR, "Unknown session refresher %d\n", p->stimer->st_ref);
+ goto return_unref;
+ }
+
+ if (p->stimer->st_refresher_self == TRUE) {
+ sendreinv = TRUE;
}
-
+
+ res = 1;
if (sendreinv == TRUE) {
- res = 1;
transmit_reinvite_with_sdp(p, FALSE, TRUE);
} else {
p->stimer->st_expirys++;
if (p->stimer->st_expirys >= 2) {
if (p->stimer->quit_flag) {
+ res = 0;
goto return_unref;
}
ast_log(LOG_WARNING, "Session-Timer expired - %s\n", p->callid);
@@ -22915,6 +22931,7 @@
sip_pvt_unlock(p);
usleep(1);
if (p->stimer && p->stimer->quit_flag) {
+ res = 0;
goto return_unref;
}
sip_pvt_lock(p);

By: Russell Bryant (russell) 2011-07-26 14:37:36.075-0500

Per the Asterisk maintenance timeline page at http://www.asterisk.org/asterisk-versions maintenance (bug) support for the 1.4 and 1.6.x branches has ended. For continued maintenance support please move to the 1.8 branch which is a long term support (LTS) branch. For more information about branch support, please see https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions

If this is still an issue, please open a new issue so it can be re-triaged appropriately. Thanks!