浏览代码

*** empty log message ***

Bogdan-Andrei Iancu 24 年之前
父节点
当前提交
0468a81a89
共有 5 个文件被更改,包括 89 次插入74 次删除
  1. 71 55
      modules/tm/t_funcs.c
  2. 1 1
      modules/tm/timer.c
  3. 11 12
      msg_translator.c
  4. 1 1
      t_debug.cfg
  5. 5 5
      udp_server.c

+ 71 - 55
modules/tm/t_funcs.c

@@ -3,6 +3,21 @@
 #include "../../config.h"
 #include "../../parser_f.h"
 
+
+#define stop_RETR_and_FR_timers(h_table,p_cell)    \
+           { int ijk; \
+           if ( p_cell->outbound_response )  {  \
+               remove_from_timer_list( h_table , &(p_cell->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST ); \
+               remove_from_timer_list( h_table , &(p_cell->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST ); } \
+           for( ijk=0 ; ijk<p_cell->nr_of_outgoings ; ijk++ )  { \
+               remove_from_timer_list( h_table , &(p_cell->outbound_request[ijk]->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST ); \
+               remove_from_timer_list( h_table , &(p_cell->outbound_request[ijk]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST ); } \
+           }
+
+
+
+
+
 struct cell         *T;
 unsigned int     global_msg_id;
 struct s_table*  hash_table;
@@ -256,6 +271,12 @@ int t_forward( struct sip_msg* p_msg , unsigned int dest_ip_param , unsigned int
                return 1;
             }
          }
+         else
+         {
+            /* transaction doesnot exists  */
+            DBG("DEBUG: t_forward: canceled request not found! nothing to CANCEL\n");
+            return 1;
+         }
       }/* end special case CANCEL*/
 
       /* allocates a new retrans_buff for the outbound request */
@@ -480,18 +501,7 @@ int t_put_on_wait(  struct sip_msg  *p_msg  )
 
    /* make double-sure we have finished everything */
    /* remove from  retranssmision  and  final response   list */
-   DBG("DEBUG: t_put_on_wait: remove inboud stuff from lists\n");
-   if ( T->outbound_response )
-   {
-      remove_from_timer_list( hash_table , &(T->outbound_response->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
-      remove_from_timer_list( hash_table , &(T->outbound_response->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
-   }
-   for( i=0 ; i<T->nr_of_outgoings ; i++ )
-   {
-      DBG("DEBUG: t_put_on_wait: remove outboud stuff[%d] from lists\n",i);
-      remove_from_timer_list( hash_table , &(T->outbound_request[i]->tl[RETRASMISSIONS_LIST]) , RETRASMISSIONS_LIST );
-      remove_from_timer_list( hash_table , &(T->outbound_request[i]->tl[FR_TIMER_LIST]) , FR_TIMER_LIST );
-   }
+   stop_RETR_and_FR_timers(hash_table,T) ;
    /* adds to Wait list*/
    add_to_tail_of_timer_list( hash_table, &(T->wait_tl), WT_TIMER_LIST, WT_TIME_OUT );
    return 1;
@@ -531,46 +541,50 @@ int t_retransmit_reply( struct sip_msg* p_msg, char* foo, char* bar  )
   */
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 {
-      	unsigned int len;
-      	char * buf = NULL;
-        struct hostent  *nhost;
-        unsigned int      ip, port;
-        char foo;
-	int err;
-        struct retrans_buff* rb = NULL;
-
-   	DBG("DEBUG: t_send_reply: entered\n");
-   	t_check( hash_table, p_msg );
-
-   	if (!T) {
-		LOG(L_ERR, "ERROR: cannot send a t_reply to a message for which no T-state has been established\n");
-		return -1;
-   	} ;
+   unsigned int len;
+   char * buf = NULL;
+   struct hostent  *nhost;
+   unsigned int      ip, port;
+   char foo;
+   int err;
+   struct retrans_buff* rb = NULL;
 
-      	buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
-        DBG("DEBUG: t_send_reply: after build\n");
-      	if (!buf)
-      	{
-         	DBG("DEBUG: t_send_reply: response building failed\n");
-		goto error;
-      	}
+   DBG("DEBUG: t_send_reply: entered\n");
+   t_check( hash_table, p_msg );
 
-     	if ( T->outbound_response) {
-		if (  T->outbound_response->retr_buffer )
-      		{
-			sh_free( T->outbound_response->retr_buffer );
-			T->outbound_response->retr_buffer = NULL;
-	 	}
-	} else {
-		rb = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );
-		if (!rb) {
-			LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem\n");
-			goto error;
-		} 
-		T->outbound_response = rb;
-		memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
-	}
+   if (!T)
+   {
+      LOG(L_ERR, "ERROR: cannot send a t_reply to a message for which no T-state has been established\n");
+     return -1;
+   }
+
+   buf = build_res_buf_from_sip_req( code , text , T->inbound_request , &len );
+   DBG("DEBUG: t_send_reply: after build\n");
+   if (!buf)
+   {
+      DBG("DEBUG: t_send_reply: response building failed\n");
+     goto error;
+   }
 
+   if ( T->outbound_response)
+   {
+      if (  T->outbound_response->retr_buffer )
+       {
+          sh_free( T->outbound_response->retr_buffer );
+          T->outbound_response->retr_buffer = NULL;
+       }
+   }
+   else
+   {
+      rb = (struct retrans_buff*)sh_malloc( sizeof(struct retrans_buff) );
+     if (!rb)
+      {
+        LOG(L_ERR, "ERROR: t_send_reply: cannot allocate shmem\n");
+       goto error;
+      }
+      T->outbound_response = rb;
+      memset( T->outbound_response , 0 , sizeof (struct retrans_buff) );
+   }
 
 	/* initialize retransmission structure */
 	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_
    /* it's a CANCEL request for sure */
 
    /* start searching into the table */
-   hash_index = hash( p_msg->callid , get_cseq(p_msg)->number  ) ;
+   hash_index = hash( p_msg->callid->body , get_cseq(p_msg)->number  ) ;
+   DBG("DEBUG: t_lookupOriginalT: searching on hash entry %d\n",hash_index );
 
    /* all the transactions from the entry are compared */
    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_
                                    //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 )) )
                                       if ( /*callid*/ !memcmp( p_cell->inbound_request->callid->body.s , p_msg->callid->body.s , p_msg->callid->body.len ) )
                                           if ( /*cseq_nr*/ !memcmp( get_cseq(p_cell->inbound_request)->number.s , get_cseq(p_msg)->number.s , get_cseq(p_msg)->number.len ) )
-                                             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 ) )
+                                             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 ) )
                                              { /* WE FOUND THE GOLDEN EGG !!!! */
                                                 unref_cell( p_cell );
                                                 return p_cell;
@@ -892,8 +907,8 @@ int relay_lowest_reply_upstream( struct cell *Trans , struct sip_msg *p_msg )
    int                 lowest_v = 999;
 
    for(  ; i<T->nr_of_outgoings ; i++ )
-      if ( T->inbound_response[i] && 
-	   T->inbound_response[i]->first_line.u.reply.statuscode>=200 && 
+      if ( T->inbound_response[i] &&
+	   T->inbound_response[i]->first_line.u.reply.statuscode>=200 &&
 	   T->inbound_response[i]->first_line.u.reply.statuscode<lowest_v )
       {
          lowest_i =i;
@@ -1164,8 +1179,9 @@ void wait_handler( void *attr)
 
    /* the transaction is already removed from WT_LIST by the timer */
    /* the cell is removed from the hash table */
-   DBG("DEBUG: wait_handler : removing from table\n");
-    remove_from_hash_table( hash_table, p_cell );
+   DBG("DEBUG: wait_handler : removing from table ans stopping all timers\n");
+   remove_from_hash_table( hash_table, p_cell );
+   stop_RETR_and_FR_timers(hash_table,p_cell) ;
    /* put it on DEL_LIST - sch for del */
     add_to_tail_of_timer_list( hash_table, &(p_cell->dele_tl), DELETE_LIST, DEL_TIME_OUT );
 }

+ 1 - 1
modules/tm/timer.c

@@ -89,7 +89,7 @@ void remove_from_timer_list( struct s_table* hash_table , struct timer_link* tl
    struct timer* timers=&(hash_table->timers[ list_id ]);
    DBG("DEBUG: remove_from_timer[%d]: %d, %p \n",list_id,tl->time_out,tl);
 
-   if (tl->next_tl || tl->prev_tl || (!tl->next_tl && !tl->prev_tl && tl==timers->first_tl)   )
+   if ( is_in_timer_list(tl,list_id)  )
    {
       lock( timers->mutex );
       if ( tl->prev_tl )

+ 11 - 12
msg_translator.c

@@ -156,7 +156,6 @@ char * build_req_buf_from_sip_req(	struct sip_msg* msg,
 	/* jku: if we compute branches using MD5 it will take 32 bytes */
 	branch_len= (loop_checks ? MY_BRANCH_LEN : MY_BRANCH_LEN -1 + MD5_LEN)+
 					msg->add_to_branch_len;
-	DBG("DEBUG: XXX via building entered; ( branch len %d)\n", msg->add_to_branch_len );
 
 	if ((via_len+port_no_str_len+branch_len+CRLF_LEN)<MAX_VIA_LINE_SIZE){
 		memcpy(line_buf, MY_VIA, MY_VIA_LEN);
@@ -175,28 +174,28 @@ char * build_req_buf_from_sip_req(	struct sip_msg* msg,
 			if (check_transaction_quadruple( msg )) {
 				str src[5];
 				int r;
-			
+
 				src[0]= msg->from->body;
-				src[1]= msg->to->body; 
-				src[2]= msg->callid->body; 
-				src[3]= msg->first_line.u.request.uri; 
+				src[1]= msg->to->body;
+				src[2]= msg->callid->body;
+				src[3]= msg->first_line.u.request.uri;
 				src[4]= get_cseq( msg )->number;
 
 				MDStringArray ( line_buf+via_len-1, src, 5 );
-				DBG("DEBUG: build_req_buf_from_sip_req: branch loop "
-						"detection: %s, %s, %s, %s, %s -> %s32\n",
-					msg->from->body.s, msg->to->body.s, msg->callid->body.s, 
+				//DBG("DEBUG: build_req_buf_from_sip_req: branch loop "
+				//		"detection: %s, %s, %s, %s, %s -> %s32\n",
+					msg->from->body.s, msg->to->body.s, msg->callid->body.s,
 					msg->first_line.u.request.uri.s,
 					((struct cseq_body *)(msg->cseq->parsed))->number.s,
 					line_buf+via_len-1 );
-				DBG("WARNING: build_req_buf_from_sip_req: branch computation "
-						"NOT over canonical values\n");
+				//DBG("WARNING: build_req_buf_from_sip_req: branch computation "
+				//		"NOT over canonical values\n");
 				via_len+=MD5_LEN - 1;
-				
+
 			} else DBG("DEBUG: build_req_buf_from_sip_req: required HFs for "
 					"loop checking missing\n");
 		}
-		DBG("DEBUG: XXX will add branch now: %s (%d)\n", msg->add_to_branch_s, msg->add_to_branch_len );
+		//DBG("DEBUG: XXX will add branch now: %s (%d)\n", msg->add_to_branch_s, msg->add_to_branch_len );
 		/* someone wants me to add something to branch here ? */
 		memcpy(line_buf+via_len, msg->add_to_branch_s,
 				msg->add_to_branch_len );

+ 1 - 1
t_debug.cfg

@@ -10,8 +10,8 @@ loop_checks=1
 # for more info: sip_router -h
 
 #modules
-loadmodule "modules/tm/tm.so"
 loadmodule "modules/print/print.so"
+loadmodule "modules/tm/tm.so"
 
 route{
 	log("trying forward to uri");

+ 5 - 5
udp_server.c

@@ -203,7 +203,7 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
 	int n;
 
 /*	struct sockaddr_in a2;*/
-
+/*
 #ifndef NO_DEBUG
 #define MAX_IP_LENGTH 18
 	char ip_txt[MAX_IP_LENGTH];
@@ -218,17 +218,17 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
 	p=ntohs(a->sin_port);
 	DBG("DEBUG: udp_send: ");
 
-	if (tolen < sizeof(struct sockaddr_in)) 
+	if (tolen < sizeof(struct sockaddr_in))
 		DBG("DEBUG: tolen small\n");
-	if (a->sin_family && a->sin_family != AF_INET) 
+	if (a->sin_family && a->sin_family != AF_INET)
 		DBG("DEBUG: to not INET\n");
-	if (a->sin_port == 0) 
+	if (a->sin_port == 0)
 		DBG("DEBUG: no port\n");
 
 	DBG(" destination: IP=%s, port=%u; packet:\n", ip_txt, p);
 	DBG(" destination (hex): IP=%x, port=%x;\n", a->sin_addr.s_addr, a->sin_port );
 	DBG("%*s\n", len, buf );
-#endif
+#endif*/
 /*
 	memset(&a2, 0, sizeof(struct sockaddr_in));
 	a2.sin_family = a->sin_family;