Browse code

*** empty log message ***

Bogdan-Andrei Iancu authored on 03/12/2001 16:58:23
Showing 5 changed files
... ...
@@ -3,6 +3,21 @@
3 3
 #include "../../config.h"
4 4
 #include "../../parser_f.h"
5 5
 
6
+
7
+#define stop_RETR_and_FR_timers(h_table,p_cell)    \
8
+           { int ijk; \
9
+           if ( p_cell->outbound_response )  {  \
10
+               remove_from_timer_list( h_table , &(p_cell->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST ); \
11
+               remove_from_timer_list( h_table , &(p_cell->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST ); } \
12
+           for( ijk=0 ; ijk<p_cell->nr_of_outgoings ; ijk++ )  { \
13
+               remove_from_timer_list( h_table , &(p_cell->outbound_request[ijk]->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST ); \
14
+               remove_from_timer_list( h_table , &(p_cell->outbound_request[ijk]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST ); } \
15
+           }
16
+
17
+
18
+
19
+
20
+
6 21
 struct cell         *T;
7 22
 unsigned int     global_msg_id;
8 23
 struct s_table*  hash_table;
... ...
@@ -256,6 +271,12 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
256 271
                return 1;
257 272
             }
258 273
          }
274
+         else
275
+         {
276
+            /* transaction doesnot exists  */
277
+            DBG("DEBUG: t_forward: canceled request not found! nothing to CANCEL\n");
278
+            return 1;
279
+         }
259 280
       }/* end special case CANCEL*/
260 281
 
261 282
       /* allocates a new retrans_buff for the outbound request */
... ...
@@ -480,18 +501,7 @@ int t_put_on_wait(  struct sip_msg  *p_msg  )
480 501
 
481 502
    /* make double-sure we have finished everything */
482 503
    /* remove from  retranssmision  and  final response   list */
483
-   DBG("DEBUG: t_put_on_wait: remove inboud stuff from lists\n");
484
-   if ( T->outbound_response )
485
-   {
486
-      remove_from_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
487
-      remove_from_timer_list( hash_table , &(T->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
488
-   }
489
-   for( i=0 ; i<T->nr_of_outgoings ; i++ )
490
-   {
491
-      DBG("DEBUG: t_put_on_wait: remove outboud stuff[%d] from lists\n",i);
492
-      remove_from_timer_list( hash_table , &(T->outbound_request[i]->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
493
-      remove_from_timer_list( hash_table , &(T->outbound_request[i]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
494
-   }
504
+   stop_RETR_and_FR_timers(hash_table,T) ;
495 505
    /* adds to Wait list*/
496 506
    add_to_tail_of_timer_list( hash_table, &(T->wait_tl), WT_TIMER_LIST, WT_TIME_OUT );
497 507
    return 1;
... ...
@@ -531,46 +541,50 @@ int t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar  )
531 541
   */
532 542
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
533 543
 {
534
-      	unsigned int len;
535
-      	char * buf = NULL;
536
-        struct hostent  *nhost;
537
-        unsigned int      ip, port;
538
-        char foo;
539
-	int err;
540
-        struct retrans_buff* rb = NULL;
541
-
542
-   	DBG("DEBUG: t_send_reply: entered\n");
543
-   	t_check( hash_table, p_msg );
544
-
545
-   	if (!T) {
546
-		LOG(L_ERR, "ERROR: cannot send a t_reply to a message for which no T-state has been established\n");
547
-		return -1;
548
-   	} ;
544
+   unsigned int len;
545
+   char * buf = NULL;
546
+   struct hostent  *nhost;
547
+   unsigned int      ip, port;
548
+   char foo;
549
+   int err;
550
+   struct retrans_buff* rb = NULL;
549 551
 
550
-      	buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
551
-        DBG("DEBUG: t_send_reply: after build\n");
552
-      	if (!buf)
553
-      	{
554
-         	DBG("DEBUG: t_send_reply: response building failed\n");
555
-		goto error;
556
-      	}
552
+   DBG("DEBUG: t_send_reply: entered\n");
553
+   t_check( hash_table, p_msg );
557 554
 
558
-     	if ( T->outbound_response) {
559
-		if (  T->outbound_response->retr_buffer )
560
-      		{
561
-			sh_free( T->outbound_response->retr_buffer );
562
-			T->outbound_response->retr_buffer = NULL;
563
-	 	}
564
-	} else {
565
-		rb = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );
566
-		if (!rb) {
567
-			LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem\n");
568
-			goto error;
569
-		} 
570
-		T->outbound_response = rb;
571
-		memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
572
-	}
555
+   if (!T)
556
+   {
557
+      LOG(L_ERR, "ERROR: cannot send a t_reply to a message for which no T-state has been established\n");
558
+     return -1;
559
+   }
560
+
561
+   buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
562
+   DBG("DEBUG: t_send_reply: after build\n");
563
+   if (!buf)
564
+   {
565
+      DBG("DEBUG: t_send_reply: response building failed\n");
566
+     goto error;
567
+   }
573 568
 
569
+   if ( T->outbound_response)
570
+   {
571
+      if (  T->outbound_response->retr_buffer )
572
+       {
573
+          sh_free( T->outbound_response->retr_buffer );
574
+          T->outbound_response->retr_buffer = NULL;
575
+       }
576
+   }
577
+   else
578
+   {
579
+      rb = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );
580
+     if (!rb)
581
+      {
582
+        LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem\n");
583
+       goto error;
584
+      }
585
+      T->outbound_response = rb;
586
+      memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
587
+   }
574 588
 
575 589
 	/* initialize retransmission structure */
576 590
 	if (update_sock_struct_from_via(  &(T->outbound_response->to),  p_msg->via1 )==-1) {
... ...
@@ -638,7 +652,8 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_
638 652
    /* it's a CANCEL request for sure */
639 653
 
640 654
    /* start searching into the table */
641
-   hash_index = hash( p_msg->callid , get_cseq(p_msg)->number  ) ;
655
+   hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number  ) ;
656
+   DBG("DEBUG: t_lookupOriginalT: searching on hash entry %d\n",hash_index );
642 657
 
643 658
    /* all the transactions from the entry are compared */
644 659
    p_cell     = hash_table->entrys[hash_index].first_cell;
... ...
@@ -663,7 +678,7 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table , struct sip_msg* p_
663 678
                                    //if ( /*tag*/ (!p_cell->inbound_request->tag && !p_msg->tag) || (p_cell->inbound_request->tag && p_msg->tag && !memcmp( p_cell->inbound_request->tag->body.s , p_msg->tag->body.s , p_msg->tag->body.len )) )
664 679
                                       if ( /*callid*/ !memcmp( p_cell->inbound_request->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) )
665 680
                                           if ( /*cseq_nr*/ !memcmp( get_cseq(p_cell->inbound_request)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) )
666
-                                             if ( /*req_uri*/ memcmp( p_cell->inbound_request->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.len ) )
681
+                                             if ( /*req_uri*/ !memcmp( p_cell->inbound_request->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.s , p_msg->first_line.u.request.uri.len ) )
667 682
                                              { /* WE FOUND THE GOLDEN EGG !!!! */
668 683
                                                 unref_cell( p_cell );
669 684
                                                 return p_cell;
... ...
@@ -892,8 +907,8 @@ int relay_lowest_reply_upstream( struct cell *Trans , struct sip_msg *p_msg )
892 907
    int                 lowest_v = 999;
893 908
 
894 909
    for(  ; i<T->nr_of_outgoings ; i++ )
895
-      if ( T->inbound_response[i] && 
896
-	   T->inbound_response[i]->first_line.u.reply.statuscode>=200 && 
910
+      if ( T->inbound_response[i] &&
911
+	   T->inbound_response[i]->first_line.u.reply.statuscode>=200 &&
897 912
 	   T->inbound_response[i]->first_line.u.reply.statuscode<lowest_v )
898 913
       {
899 914
          lowest_i =i;
... ...
@@ -1164,8 +1179,9 @@ void wait_handler( void *attr)
1164 1179
 
1165 1180
    /* the transaction is already removed from WT_LIST by the timer */
1166 1181
    /* the cell is removed from the hash table */
1167
-   DBG("DEBUG: wait_handler : removing from table\n");
1168
-    remove_from_hash_table( hash_table, p_cell );
1182
+   DBG("DEBUG: wait_handler : removing from table ans stopping all timers\n");
1183
+   remove_from_hash_table( hash_table, p_cell );
1184
+   stop_RETR_and_FR_timers(hash_table,p_cell) ;
1169 1185
    /* put it on DEL_LIST - sch for del */
1170 1186
     add_to_tail_of_timer_list( hash_table, &(p_cell->dele_tl), DELETE_LIST, DEL_TIME_OUT );
1171 1187
 }
... ...
@@ -89,7 +89,7 @@ void remove_from_timer_list( struct s_table* hash_table , struct timer_link* tl
89 89
    struct timer* timers=&(hash_table->timers[ list_id ]);
90 90
    DBG("DEBUG: remove_from_timer[%d]: %d, %p \n",list_id,tl->time_out,tl);
91 91
 
92
-   if (tl->next_tl || tl->prev_tl || (!tl->next_tl && !tl->prev_tl && tl==timers->first_tl)   )
92
+   if ( is_in_timer_list(tl,list_id)  )
93 93
    {
94 94
       lock( timers->mutex );
95 95
       if ( tl->prev_tl )
... ...
@@ -156,7 +156,6 @@ char * build_req_buf_from_sip_req(	struct sip_msg* msg,
156 156
 	/* jku: if we compute branches using MD5 it will take 32 bytes */
157 157
 	branch_len= (loop_checks ? MY_BRANCH_LEN : MY_BRANCH_LEN -1 + MD5_LEN)+
158 158
 					msg->add_to_branch_len;
159
-	DBG("DEBUG: XXX via building entered; ( branch len %d)\n", msg->add_to_branch_len );
160 159
 
161 160
 	if ((via_len+port_no_str_len+branch_len+CRLF_LEN)<MAX_VIA_LINE_SIZE){
162 161
 		memcpy(line_buf, MY_VIA, MY_VIA_LEN);
... ...
@@ -175,28 +174,28 @@ char * build_req_buf_from_sip_req(	struct sip_msg* msg,
175 174
 			if (check_transaction_quadruple( msg )) {
176 175
 				str src[5];
177 176
 				int r;
178
-			
177
+
179 178
 				src[0]= msg->from->body;
180
-				src[1]= msg->to->body; 
181
-				src[2]= msg->callid->body; 
182
-				src[3]= msg->first_line.u.request.uri; 
179
+				src[1]= msg->to->body;
180
+				src[2]= msg->callid->body;
181
+				src[3]= msg->first_line.u.request.uri;
183 182
 				src[4]= get_cseq( msg )->number;
184 183
 
185 184
 				MDStringArray ( line_buf+via_len-1, src, 5 );
186
-				DBG("DEBUG: build_req_buf_from_sip_req: branch loop "
187
-						"detection: %s, %s, %s, %s, %s -> %s32\n",
188
-					msg->from->body.s, msg->to->body.s, msg->callid->body.s, 
185
+				//DBG("DEBUG: build_req_buf_from_sip_req: branch loop "
186
+				//		"detection: %s, %s, %s, %s, %s -> %s32\n",
187
+					msg->from->body.s, msg->to->body.s, msg->callid->body.s,
189 188
 					msg->first_line.u.request.uri.s,
190 189
 					((struct cseq_body *)(msg->cseq->parsed))->number.s,
191 190
 					line_buf+via_len-1 );
192
-				DBG("WARNING: build_req_buf_from_sip_req: branch computation "
193
-						"NOT over canonical values\n");
191
+				//DBG("WARNING: build_req_buf_from_sip_req: branch computation "
192
+				//		"NOT over canonical values\n");
194 193
 				via_len+=MD5_LEN - 1;
195
-				
194
+
196 195
 			} else DBG("DEBUG: build_req_buf_from_sip_req: required HFs for "
197 196
 					"loop checking missing\n");
198 197
 		}
199
-		DBG("DEBUG: XXX will add branch now: %s (%d)\n", msg->add_to_branch_s, msg->add_to_branch_len );
198
+		//DBG("DEBUG: XXX will add branch now: %s (%d)\n", msg->add_to_branch_s, msg->add_to_branch_len );
200 199
 		/* someone wants me to add something to branch here ? */
201 200
 		memcpy(line_buf+via_len, msg->add_to_branch_s,
202 201
 				msg->add_to_branch_len );
... ...
@@ -10,8 +10,8 @@ loop_checks=1
10 10
 # for more info: sip_router -h
11 11
 
12 12
 #modules
13
-loadmodule "modules/tm/tm.so"
14 13
 loadmodule "modules/print/print.so"
14
+loadmodule "modules/tm/tm.so"
15 15
 
16 16
 route{
17 17
 	log("trying forward to uri");
... ...
@@ -203,7 +203,7 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
203 203
 	int n;
204 204
 
205 205
 /*	struct sockaddr_in a2;*/
206
-
206
+/*
207 207
 #ifndef NO_DEBUG
208 208
 #define MAX_IP_LENGTH 18
209 209
 	char ip_txt[MAX_IP_LENGTH];
... ...
@@ -218,17 +218,17 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
218 218
 	p=ntohs(a->sin_port);
219 219
 	DBG("DEBUG: udp_send: ");
220 220
 
221
-	if (tolen < sizeof(struct sockaddr_in)) 
221
+	if (tolen < sizeof(struct sockaddr_in))
222 222
 		DBG("DEBUG: tolen small\n");
223
-	if (a->sin_family && a->sin_family != AF_INET) 
223
+	if (a->sin_family && a->sin_family != AF_INET)
224 224
 		DBG("DEBUG: to not INET\n");
225
-	if (a->sin_port == 0) 
225
+	if (a->sin_port == 0)
226 226
 		DBG("DEBUG: no port\n");
227 227
 
228 228
 	DBG(" destination: IP=%s, port=%u; packet:\n", ip_txt, p);
229 229
 	DBG(" destination (hex): IP=%x, port=%x;\n", a->sin_addr.s_addr, a->sin_port );
230 230
 	DBG("%*s\n", len, buf );
231
-#endif
231
+#endif*/
232 232
 /*
233 233
 	memset(&a2, 0, sizeof(struct sockaddr_in));
234 234
 	a2.sin_family = a->sin_family;