Browse code

undoing CANCEL!!

Bogdan-Andrei Iancu authored on 25/01/2002 16:55:49
Showing 4 changed files
... ...
@@ -163,8 +163,7 @@ struct cell*  build_cell( struct sip_msg* p_msg )
163 163
    /* all pointers from outbound_response array are NULL */
164 164
    /*init the links with the canceled / canceler transaction */
165 165
    new_cell->relaied_reply_branch   = -1;
166
-   new_cell->T_canceled  = T_UNDEFINED;
167
-   new_cell->T_canceler  = T_UNDEFINED;
166
+   new_cell->T_canceled = T_UNDEFINED;
168 167
 
169 168
    /* init_cell_lock(  new_cell ); */
170 169
 
... ...
@@ -218,12 +217,6 @@ void remove_from_hash_table( struct s_table *hash_table,  struct cell * p_cell )
218 217
 {
219 218
    struct entry*  p_entry  = &(hash_table->entrys[p_cell->hash_index]);
220 219
 
221
-   /*update the canceler and canceled links*/
222
-   if ( p_cell->T_canceled!=T_NULL && p_cell->T_canceled!=T_UNDEFINED)
223
-      p_cell->T_canceled->T_canceler = T_NULL;
224
-   if ( p_cell->T_canceler!=T_NULL && p_cell->T_canceler!=T_UNDEFINED)
225
-      p_cell->T_canceler->T_canceled = T_NULL;
226
-
227 220
    /* unlink the cell from entry list */
228 221
    lock( p_entry->mutex );
229 222
 
... ...
@@ -73,7 +73,6 @@ typedef struct cell
73 73
 
74 74
 	/*the transaction that is canceled (usefull only for CANCEL req)*/
75 75
 	struct cell *T_canceled;
76
-	struct cell *T_canceler;
77 76
 
78 77
 	/* useful data */
79 78
 	/* UA Server */
... ...
@@ -188,13 +188,13 @@ int t_add_transaction( struct sip_msg* p_msg, char* foo, char* bar )
188 188
  */
189 189
 int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int dest_port_param )
190 190
 {
191
-	unsigned int dest_ip     = dest_ip_param;
192
-	unsigned int dest_port  = dest_port_param;
193
-	int	      branch;
194
-	unsigned int len;
195
-	char              *buf, *shbuf;
196
-	struct retrans_buff *rb;
197
-               struct cell         *T_source;
191
+	unsigned int  dest_ip     = dest_ip_param;
192
+	unsigned int  dest_port  = dest_port_param;
193
+	int	       branch;
194
+	unsigned int  len;
195
+	char                          *buf, *shbuf;
196
+	struct retrans_buff  *rb;
197
+	struct cell                *T_tmp;
198 198
 
199 199
 	buf=NULL;
200 200
 	shbuf = NULL;
... ...
@@ -217,7 +217,6 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
217 217
 		return 1;
218 218
 	}
219 219
 
220
-               T_source = T;
221 220
 	/* if it's forwarded for the first time ; else the request is retransmited
222 221
 	 * from the transaction buffer
223 222
 	 * when forwarding an ACK, this condition will be all the time false because
... ...
@@ -231,14 +230,12 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
231 230
 			DBG("DEBUG: t_forward: it's CANCEL\n");
232 231
 			/* find original cancelled transaction; if found, use its
233 232
 			   next-hops; otherwise use those passed by script */
234
-			if ( T->T_canceled==T_UNDEFINED )
235
-				T->T_canceled = t_lookupOriginalT( hash_table , p_msg );
233
+			T->T_canceled = t_lookupOriginalT( hash_table , p_msg );
236 234
 			/* if found */
237 235
 			if ( T->T_canceled!=T_NULL )
238 236
 			{
239
-				T->T_canceled->T_canceler = T;
240 237
 				/* if in 1xx status, send to the same destination */
241
-				if ( (T->T_canceled->status/100)==1 )
238
+				if ( (T_tmp->status/100)==1 )
242 239
 				{
243 240
 					DBG("DEBUG: t_forward: it's CANCEL and I will send "
244 241
 						"to the same place where INVITE went\n");
... ...
@@ -246,7 +243,6 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
246 243
 						to.sin_addr.s_addr;
247 244
 					dest_port = T->T_canceled->outbound_request[branch]->
248 245
 						to.sin_port;
249
-					T_source = T->T_canceled;
250 246
 				} else { /* transaction exists, but nothing to cancel */
251 247
 					DBG("DEBUG: t_forward: it's CANCEL but "
252 248
 						"I have nothing to cancel here\n");
... ...
@@ -258,9 +254,9 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
258 254
 			}
259 255
 		}/* end special case CANCEL*/
260 256
 
261
-		if ( add_branch_label( T_source, T->inbound_request , branch )==-1)
257
+		if ( add_branch_label( T, T->inbound_request , branch )==-1)
262 258
 			goto error;
263
-		if ( add_branch_label( T_source, p_msg , branch )==-1)
259
+		if ( add_branch_label( T, p_msg , branch )==-1)
264 260
 			goto error;
265 261
 		if ( !(buf = build_req_buf_from_sip_req  ( p_msg, &len)))
266 262
 			goto error;
... ...
@@ -319,7 +315,7 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
319 315
 	{
320 316
 		DBG("DEBUG: t_forward: forwarding CANCEL \n");
321 317
 		/* if no transaction to CANCEL
322
-		  or if the canceled transaction has a final status -> drop the CANCEL*/
318
+		    or if the canceled transaction has a final status -> drop the CANCEL*/
323 319
 		if ( T->T_canceled!=T_NULL && T->T_canceled->status>=200)
324 320
 		{
325 321
 			reset_timer( hash_table, &(rb->fr_timer ));
... ...
@@ -844,20 +840,18 @@ int t_update_timers_after_sending_reply( struct retrans_buff *rb )
844 840
 		rb->retr_list = RT_T1_TO_1;
845 841
 		set_timer( hash_table, &(rb->retr_timer), RT_T1_TO_1 );
846 842
 		set_timer( hash_table, &(rb->fr_timer), FR_TIMER_LIST );
847
-   	} else if ( Trans->inbound_request->REQ_METHOD==METHOD_CANCEL ) {
843
+	} else if ( Trans->inbound_request->REQ_METHOD==METHOD_CANCEL ) {
848 844
 		if ( Trans->T_canceled==T_UNDEFINED )
849 845
 			Trans->T_canceled = t_lookupOriginalT( hash_table ,
850 846
 				Trans->inbound_request );
851
-      		if ( Trans->T_canceled==T_NULL )
852
-            		return 1;
853
-      		Trans->T_canceled->T_canceler = Trans;
854
-     		/* put CANCEL transaction on wait only if canceled transaction already
855
-        	   is in final status and there is nothing to cancel;
856
-     		*/
857
-     		if ( Trans->T_canceled->status>=200)
858
-            		t_put_on_wait( Trans );
859
-   	} else if (Trans->status>=200)
860
-            t_put_on_wait( Trans );
847
+		if ( Trans->T_canceled==T_NULL )
848
+			return 1;
849
+		/* put CANCEL transaction on wait only if canceled transaction already
850
+		    is in final status and there is nothing to cancel; */
851
+		if ( Trans->T_canceled->status>=200)
852
+			t_put_on_wait( Trans );
853
+	} else if (Trans->status>=200)
854
+		t_put_on_wait( Trans );
861 855
    return 1;
862 856
 }
863 857
 
... ...
@@ -240,7 +240,6 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_
240 240
 int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
241 241
 {
242 242
    struct cell*  p_cell;
243
-   struct cell* tmp_cell;
244 243
    unsigned int hash_index = 0;
245 244
    unsigned int entry_label  = 0;
246 245
    unsigned int branch_id    = 0;
... ...
@@ -312,7 +311,6 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
312 311
 
313 312
    /*all the cells from the entry are scan to detect an entry_label matching */
314 313
    p_cell     = hash_table->entrys[hash_index].first_cell;
315
-   tmp_cell = 0;
316 314
    while( p_cell )
317 315
    {
318 316
       /* is it the cell with the wanted entry_label? */
... ...
@@ -321,9 +319,6 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
321 319
          if ( p_cell->nr_of_outgoings>branch_id && p_cell->outbound_request[branch_id] )
322 320
          {/* WE FOUND THE GOLDEN EGG !!!! */
323 321
              T = p_cell;
324
-             if ( *(get_cseq(p_msg)->method.s)=='C' && p_cell->T_canceler &&
325
-                p_cell->inbound_request->first_line.u.request.method_value!=METHOD_CANCEL)
326
-                T = T->T_canceler ;
327 322
              *p_branch = branch_id;
328 323
              T_REF( T );
329 324
              unlock( hash_table->entrys[hash_index].mutex );
... ...
@@ -331,7 +326,6 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch )
331 326
             return 1;
332 327
          }
333 328
       /* next cell */
334
-      tmp_cell = p_cell;
335 329
       p_cell = p_cell->next_cell;
336 330
    } /* while p_cell */
337 331