Browse code

sip: b/f: check method (ACK or PRACK) before deleting transaction

In case PRACK is received after 200, the transaction would be removed without checking the method.

Raphael Coeffic authored on 15/04/2014 12:49:49 • Stefan Sayer committed on 15/04/2014 20:20:22
Showing 1 changed files
... ...
@@ -2179,22 +2179,31 @@ int _trans_layer::update_uas_reply(trans_bucket* bucket, sip_trans* t, int reply
2179 2179
 int _trans_layer::update_uas_request(trans_bucket* bucket, sip_trans* t, sip_msg* msg)
2180 2180
 {
2181 2181
     DBG("update_uas_request(t=%p)\n", t);
2182
+    int method = msg->u.request->method;
2183
+
2184
+    if(method != sip_request::ACK &&
2185
+       method != sip_request::PRACK) {
2182 2186
 
2183
-    if(msg->u.request->method != sip_request::ACK &&
2184
-            msg->u.request->method != sip_request::PRACK){
2185 2187
 	ERROR("Bug? Recvd non PR-/ACK request for existing UAS transact.!?\n");
2186 2188
 	return -1;
2187 2189
     }
2188
-	
2190
+
2189 2191
     switch(t->state){
2190 2192
 
2193
+    case TS_PROCEEDING:
2194
+	// ACK or PRACK after non-reliable 1xx???
2195
+	return -1;
2196
+
2191 2197
     case TS_PROCEEDING_REL:
2192
-        // stop retransmissions
2193
-	t->clear_timer(STIMER_G);
2194
-	t->clear_timer(STIMER_H);
2198
+	if(method == sip_request::PRACK) {
2199
+	    // stop retransmissions
2200
+	    t->clear_timer(STIMER_G);
2201
+	    t->clear_timer(STIMER_H);
2202
+	}
2195 2203
         return t->state;
2196 2204
 	    
2197 2205
     case TS_COMPLETED: // non-2xx-ACK
2206
+	if(method != sip_request::ACK) return -1;
2198 2207
 	t->state = TS_CONFIRMED;
2199 2208
 
2200 2209
 	t->clear_timer(STIMER_G);
... ...
@@ -2212,12 +2221,14 @@ int _trans_layer::update_uas_request(trans_bucket* bucket, sip_trans* t, sip_msg
2212 2221
 	return t->state;
2213 2222
 	    
2214 2223
     case TS_TERMINATED_200: // 2xx-ACK
2224
+	if(method != sip_request::ACK) return -1;
2215 2225
 	// remove transaction
2216 2226
 	bucket->remove(t);
2217 2227
 	return TS_REMOVED;
2218 2228
 	    
2219 2229
     default:
2220 2230
 	DBG("Bug? Unknown state at this point: %i\n",t->state);
2231
+	break;
2221 2232
     }
2222 2233
 
2223 2234
     return -1;