]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fixes interoperability problems with session timer behavior in Asterisk.
authorDavid Vossel <dvossel@digium.com>
Wed, 8 Sep 2010 21:47:29 +0000 (21:47 +0000)
committerDavid Vossel <dvossel@digium.com>
Wed, 8 Sep 2010 21:47:29 +0000 (21:47 +0000)
CHANGES:
1. Never put "timer" in "Require" header.  This is not to our benefit
and RFC 4028 section 7.1 even warns against it.  It is possible for one
endpoint to perform session-timer refreshes while the other endpoint does
not support them.  If in this case the end point performing the refreshing
puts "timer" in the Require field during a refresh, the dialog will
likely get terminated by the other end.

2. Change the behavior of 'session-timer=accept' in sip.conf (which is
the default behavior of Asterisk with no session timer configuration
specified) to only run session-timers as result of an incoming INVITE
request if the INVITE contains an "Session-Expires" header... Asterisk is
currently treating having the "timer" option in the "Supported" header as
a request for session timers by the UAC.  I do not agree with this.  Session
timers should only be negotiated in "accept" mode when the incoming INVITE
supplies a "Session-Expires" header, otherwise RFC 4028 says we should
treat a request containing no "Session-Expires" header as a session with
no expiration.

Below I have outlined some situations and what Asterisk's behavior is.
The table reflects the behavior changes implemented by this patch.

SITUATIONS:
-Asterisk as UAS
1. Incoming INVITE: NO  "Session-Expires"
2. Incoming INVITE: HAS "Session-Expires"

-Asterisk as UAC
3. Outgoing INVITE: NO  "Session-Expires". 200 Ok Response HAS "Session-Expires" header
4. Outgoing INVITE: NO  "Session-Expires". 200 Ok Response NO  "Session-Expires" header
5. Outgoing INVITE: HAS "Session-Expires".

Active   - Asterisk will have an active refresh timer regardless if the other endpoint does.
Inactive - Asterisk does not have an active refresh timer regardless if the other endpoint does.
XXXXXXX  - Not possible for mode.
______________________________________
|SITUATIONS | 'session-timer' MODES  |
|___________|________________________|
|           | originate  |  accept   |
|-----------|------------|-----------|
|1.         |   Active   | Inactive  |
|2.         |   Active   |  Active   |
|3.         | XXXXXXXX   | Active    |
|4.         | XXXXXXXX   | Inactive  |
|5.         |   Active   | XXXXXXXX  |
--------------------------------------

(closes issue #17005)
Reported by: alexrecarey

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@285563 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c

index 673a8376e858c8bcc3b616a51e430f4d751f7fe1..f132a4f013ce8dfc5b5b610c791ab3e244338308 100644 (file)
@@ -9547,7 +9547,6 @@ static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg
                char se_hdr[256];
                snprintf(se_hdr, sizeof(se_hdr), "%d;refresher=%s", p->stimer->st_interval, 
                        strefresher2str(p->stimer->st_ref));
-               add_header(resp, "Require", "timer");
                add_header(resp, "Session-Expires", se_hdr);
        }
 
@@ -17889,7 +17888,7 @@ static void handle_response_invite(struct sip_pvt *p, int resp, char *rest, stru
                /* Check for Session-Timers related headers */
                if (st_get_mode(p) != SESSION_TIMER_MODE_REFUSE && p->outgoing_call == TRUE && !reinvite) {
                        p_hdrval = (char*)get_header(req, "Session-Expires");
-                       if (!ast_strlen_zero(p_hdrval)) {
+                       if (!ast_strlen_zero(p_hdrval)) {
                                /* UAS supports Session-Timers */
                                enum st_refresher tmp_st_ref = SESSION_TIMER_REFRESHER_AUTO;
                                int tmp_st_interval = 0;
@@ -20264,10 +20263,10 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
        }
 
        /* Session-Timers */
-       if (p->sipoptions & SIP_OPT_TIMER) {
+       if ((p->sipoptions & SIP_OPT_TIMER) && !ast_strlen_zero(get_header(req, "Session-Expires"))) {
                /* The UAC has requested session-timers for this session. Negotiate
                the session refresh interval and who will be the refresher */
-               ast_debug(2, "Incoming INVITE with 'timer' option enabled\n");
+               ast_debug(2, "Incoming INVITE with 'timer' option supported and \"Session-Expires\" header.\n");
 
                /* Allocate Session-Timers struct w/in the dialog */
                if (!p->stimer)
@@ -20275,17 +20274,15 @@ static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int
 
                /* Parse the Session-Expires header */
                p_uac_se_hdr = get_header(req, "Session-Expires");
-               if (!ast_strlen_zero(p_uac_se_hdr)) {
-                       rtn = parse_session_expires(p_uac_se_hdr, &uac_max_se, &st_ref);
-                       if (rtn != 0) {
-                               transmit_response_reliable(p, "400 Session-Expires Invalid Syntax", req);
-                               p->invitestate = INV_COMPLETED;
-                               if (!p->lastinvite) {
-                                       sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
-                               }
-                               res = -1;
-                               goto request_invite_cleanup;
+               rtn = parse_session_expires(p_uac_se_hdr, &uac_max_se, &st_ref);
+               if (rtn != 0) {
+                       transmit_response_reliable(p, "400 Session-Expires Invalid Syntax", req);
+                       p->invitestate = INV_COMPLETED;
+                       if (!p->lastinvite) {
+                               sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
                        }
+                       res = -1;
+                       goto request_invite_cleanup;
                }
 
                /* Parse the Min-SE header */