Browse code

SST fixes: timer option tag; Min-SE==Interval

Stefan Sayer authored on 04/03/2011 16:33:29
Showing 2 changed files
... ...
@@ -152,17 +152,15 @@ bool SessionTimer::onSendRequest(const string& method,
152 152
 					 hdrs);
153 153
   }
154 154
 
155
-  string m_hdrs = SIP_HDR_COLSP(SIP_HDR_SUPPORTED)  "timer"  CRLF;
155
+  addOptionTag(hdrs, SIP_HDR_SUPPORTED, TIMER_OPTION_TAG);
156 156
   if  ((method != SIP_METH_INVITE) && (method != SIP_METH_UPDATE))
157
-    goto end;
157
+    return false; // session-expires / min-se only in INV/UPD
158 158
 
159 159
   removeHeader(hdrs, SIP_HDR_SESSION_EXPIRES);
160 160
   removeHeader(hdrs, SIP_HDR_MIN_SE);
161
-  m_hdrs += SIP_HDR_COLSP(SIP_HDR_SESSION_EXPIRES) + int2str(session_interval) +CRLF
161
+  hdrs += SIP_HDR_COLSP(SIP_HDR_SESSION_EXPIRES) + int2str(session_interval) + CRLF
162 162
     + SIP_HDR_COLSP(SIP_HDR_MIN_SE) + int2str(min_se) + CRLF;
163 163
 
164
- end:
165
-  hdrs += m_hdrs;
166 164
   return false;
167 165
 }
168 166
 
... ...
@@ -173,22 +171,26 @@ bool SessionTimer::onSendReply(const AmSipRequest& req,
173 173
 			       string& hdrs,
174 174
 			       int flags)
175 175
 {
176
+  // only in 2xx responses to INV/UPD
176 177
   if  (((req.method != SIP_METH_INVITE) && (req.method != SIP_METH_UPDATE)) ||
177 178
        (code < 200) || (code >= 300))
178 179
     return false;
179
-    
180
-  string m_hdrs = SIP_HDR_COLSP(SIP_HDR_SUPPORTED)  "timer"  CRLF;
181 180
 
182
-  // only in 2xx responses to INV/UPD
183
-  m_hdrs  += SIP_HDR_COLSP(SIP_HDR_SESSION_EXPIRES) +
181
+  addOptionTag(hdrs, SIP_HDR_SUPPORTED, TIMER_OPTION_TAG);
182
+
183
+  if (((session_refresher_role==UAC) && (session_refresher==refresh_remote))
184
+      || ((session_refresher_role==UAS) && remote_timer_aware)) {
185
+    addOptionTag(hdrs, SIP_HDR_REQUIRE, TIMER_OPTION_TAG);
186
+  } else {
187
+    removeOptionTag(hdrs, SIP_HDR_REQUIRE, TIMER_OPTION_TAG);
188
+  }
189
+
190
+  // remove (possibly existing) Session-Expires header
191
+  removeHeader(hdrs, SIP_HDR_SESSION_EXPIRES);
192
+
193
+  hdrs += SIP_HDR_COLSP(SIP_HDR_SESSION_EXPIRES) +
184 194
     int2str(session_interval) + ";refresher="+
185 195
     (session_refresher_role==UAC ? "uac":"uas")+CRLF;
186
-    
187
-  if (((session_refresher_role==UAC) && (session_refresher==refresh_remote)) 
188
-      || ((session_refresher_role==UAS) && remote_timer_aware))
189
-    m_hdrs += SIP_HDR_COLSP(SIP_HDR_REQUIRE)  "timer"  CRLF;
190
-    
191
-  hdrs += m_hdrs;
192 196
 
193 197
   return false;
194 198
 }
... ...
@@ -266,7 +268,7 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
266 266
   if((req.method == SIP_METH_INVITE)||(req.method == SIP_METH_UPDATE)){
267 267
     
268 268
     remote_timer_aware = 
269
-      key_in_list(getHeader(req.hdrs, SIP_HDR_SUPPORTED),"timer", true);
269
+      key_in_list(getHeader(req.hdrs, SIP_HDR_SUPPORTED), TIMER_OPTION_TAG, true);
270 270
     
271 271
     // determine session interval
272 272
     string sess_expires_hdr = getHeader(req.hdrs, SIP_HDR_SESSION_EXPIRES,
... ...
@@ -295,17 +297,20 @@ void SessionTimer::updateTimer(AmSession* s, const AmSipRequest& req) {
295 295
       }
296 296
     }
297 297
 
298
-    // calculate actual se
299
-    session_interval = session_timer_conf.getSessionExpires();
300
-
298
+    // minimum limit of both
301 299
     if (i_minse > min_se)
302 300
       min_se = i_minse;
303 301
 
304
-    if (rem_has_sess_expires && (rem_sess_expires < min_se)) {
305
-      session_interval = min_se;
306
-    } else {
307
-      if (rem_has_sess_expires && (rem_sess_expires < session_interval))
308
-	session_interval = rem_sess_expires;
302
+    // calculate actual se
303
+    session_interval = session_timer_conf.getSessionExpires();
304
+
305
+    if (rem_has_sess_expires) {
306
+      if (rem_sess_expires <= min_se) {
307
+	session_interval = min_se;
308
+      } else {
309
+	if (rem_sess_expires < session_interval)
310
+	  session_interval = rem_sess_expires;
311
+      }
309 312
     }
310 313
      
311 314
     DBG("using actual session interval %u\n", session_interval);
... ...
@@ -33,6 +33,8 @@
33 33
 
34 34
 #define MOD_NAME "session_timer"
35 35
 
36
+#define TIMER_OPTION_TAG  "timer"
37
+
36 38
 /* Session Timer: -ssa */
37 39
 class AmTimeoutEvent;
38 40
 // these are the timer IDs for session timer