소스 검색

local cancel

Bogdan-Andrei Iancu 23 년 전
부모
커밋
b908cdebb9
12개의 변경된 파일120개의 추가작업 그리고 116개의 파일을 삭제
  1. 2 2
      Makefile.defs
  2. 13 11
      forward.c
  3. 8 10
      modules/tm/t_funcs.c
  4. 2 2
      modules/tm/t_funcs.h
  5. 19 17
      modules/tm/t_lookup.c
  6. 52 42
      modules/tm/t_reply.c
  7. 3 0
      modules/tm/timer.c
  8. 3 5
      msg_parser.c
  9. 3 5
      parse_hname2.c
  10. 7 10
      receive.c
  11. 0 1
      timer.c
  12. 8 11
      udp_server.c

+ 2 - 2
Makefile.defs

@@ -80,8 +80,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
 	 -DF_MALLOC  -DUSE_SYNONIM\
 	 -DF_MALLOC  -DUSE_SYNONIM\
-	 -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL\
-	 -DNO_DEBUG 
+	 -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL -DBOGDAN_TRIFLE \
+	 #-DNO_DEBUG \
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
 	 #-DNOSMP \
 	 #-DNOSMP \
 	 #-DEXTRA_DEBUG 
 	 #-DEXTRA_DEBUG 

+ 13 - 11
forward.c

@@ -153,6 +153,14 @@ int forward_reply(struct sip_msg* msg)
 		}
 		}
 	}
 	}
 	
 	
+	/* we have to forward the reply stateless, so we need second via -bogdan*/
+	if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK))
+	{
+		/* no second via => error */
+		LOG(L_ERR, "ERROR: forward_msg: no 2nd via found in reply\n");
+		goto error;
+	}
+
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
 	if (to==0){
 	if (to==0){
 		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
 		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
@@ -165,15 +173,6 @@ int forward_reply(struct sip_msg* msg)
 		goto error;
 		goto error;
 	}
 	}
 
 
-	 /* send it! */
-	/* moved to udp_send; -jiri
-
-	DBG("Sending: to %s:%d, \n%s.\n",
-			msg->via2->host.s,
-			(unsigned short)msg->via2->port,
-			new_buf);
-	*/
-
 	if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
 	if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
 
 
 	if (udp_send(new_buf,new_len, (struct sockaddr*) to,
 	if (udp_send(new_buf,new_len, (struct sockaddr*) to,
@@ -181,13 +180,16 @@ int forward_reply(struct sip_msg* msg)
 	{
 	{
 		STATS_TX_DROPS;
 		STATS_TX_DROPS;
 		goto error;
 		goto error;
-	}
-	else {
+	} else {
 #ifdef STATS
 #ifdef STATS
 		int j = msg->first_line.u.reply.statuscode/100;
 		int j = msg->first_line.u.reply.statuscode/100;
 		STATS_TX_RESPONSE(  j );
 		STATS_TX_RESPONSE(  j );
 #endif
 #endif
 	}
 	}
+
+	DBG(" reply forwarded to %s:%d\n",msg->via2->host.s,
+		(unsigned short) msg->via2->port);
+
 	free(new_buf);
 	free(new_buf);
 	free(to);
 	free(to);
 skip:
 skip:

+ 8 - 10
modules/tm/t_funcs.c

@@ -76,7 +76,6 @@ static inline void reset_retr_timers( struct s_table *h_table,
 	int ijk;
 	int ijk;
 	struct retrans_buff *rb;
 	struct retrans_buff *rb;
 
 
-	DBG("DEBUG:stop_RETR_and_FR_timers : start \n");
 	/* lock the first timer list of the FR group -- all other
 	/* lock the first timer list of the FR group -- all other
 	   lists share the same lock*/
 	   lists share the same lock*/
 	lock(hash_table->timers[RT_T1_TO_1].mutex);
 	lock(hash_table->timers[RT_T1_TO_1].mutex);
@@ -96,7 +95,7 @@ static inline void reset_retr_timers( struct s_table *h_table,
 			}
 			}
 		}
 		}
 	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
 	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
-	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
+	DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
 }
 }
 
 
 int tm_startup()
 int tm_startup()
@@ -376,7 +375,7 @@ int t_put_on_wait(  struct cell  *Trans  )
 	for( i=0 ; i<Trans->nr_of_outgoings ; i++ )
 	for( i=0 ; i<Trans->nr_of_outgoings ; i++ )
 		if ( Trans->inbound_response[i] && 
 		if ( Trans->inbound_response[i] && 
 		REPLY_CLASS(Trans->inbound_response[i])==1)
 		REPLY_CLASS(Trans->inbound_response[i])==1)
-		t_cancel_branch(i);
+			t_cancel_branch(i);
 
 
 
 
 	/* we don't need outbound requests anymore -- let's save
 	/* we don't need outbound requests anymore -- let's save
@@ -662,6 +661,7 @@ int t_build_and_send_CANCEL(struct cell *Trans,unsigned int branch)
 		sizeof (struct sockaddr_in));
 		sizeof (struct sockaddr_in));
 	srb->tolen = sizeof (struct sockaddr_in);
 	srb->tolen = sizeof (struct sockaddr_in);
 	srb->my_T = Trans;
 	srb->my_T = Trans;
+	srb->fr_timer.payload = srb->retr_timer.payload = srb;
 	srb->branch = branch;
 	srb->branch = branch;
 	srb->status = STATUS_LOCAL_CANCEL;
 	srb->status = STATUS_LOCAL_CANCEL;
 	srb->retr_buffer = (char *) srb + sizeof( struct retrans_buff );
 	srb->retr_buffer = (char *) srb + sizeof( struct retrans_buff );
@@ -837,7 +837,7 @@ void retransmission_handler( void *attr)
 {
 {
 	struct retrans_buff* r_buf ;
 	struct retrans_buff* r_buf ;
 	enum lists id;
 	enum lists id;
-
+	DBG("DEBUG: entering retransmisson with attr = %x\n",attr);
 	r_buf = (struct retrans_buff*)attr;
 	r_buf = (struct retrans_buff*)attr;
 #ifdef EXTRA_DEBUG
 #ifdef EXTRA_DEBUG
 	if (r_buf->my_T->damocles) {
 	if (r_buf->my_T->damocles) {
@@ -886,18 +886,16 @@ void final_response_handler( void *attr)
 	/* the transaction is already removed from FR_LIST by the timer */
 	/* the transaction is already removed from FR_LIST by the timer */
 	if (r_buf->status==STATUS_LOCAL_CANCEL)
 	if (r_buf->status==STATUS_LOCAL_CANCEL)
 	{
 	{
-		DBG("DEBUG: final_response_handler: stop retransmission for"
-			"Local Cancel\n");
+		DBG("DEBUG: FR_handler: stop retransmission for Local Cancel\n");
 		reset_timer( hash_table , &(r_buf->retr_timer) );
 		reset_timer( hash_table , &(r_buf->retr_timer) );
 		return;
 		return;
 	}
 	}
 	/* send a 408 */
 	/* send a 408 */
 	if ( r_buf->my_T->status<200)
 	if ( r_buf->my_T->status<200)
 	{
 	{
-		DBG("DEBUG: final_response_handler:stop retransmission and"
-			" send 408 (t=%p)\n", r_buf->my_T);
+		DBG("DEBUG: FR_handler:stop retr. and send CANCEL (%p)\n",r_buf->my_T);
 		reset_timer( hash_table, &(r_buf->retr_timer) );
 		reset_timer( hash_table, &(r_buf->retr_timer) );
-		//t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
+		t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
 		/* dirty hack:t_send_reply would increase ref_count which would indeed
 		/* dirty hack:t_send_reply would increase ref_count which would indeed
 		result in refcount++ which would not -- until timer processe's
 		result in refcount++ which would not -- until timer processe's
 		T changes again; currently only on next call to t_send_reply from
 		T changes again; currently only on next call to t_send_reply from
@@ -905,7 +903,7 @@ void final_response_handler( void *attr)
 		and refcount++ JKU */
 		and refcount++ JKU */
 		T=r_buf->my_T;
 		T=r_buf->my_T;
 		global_msg_id=T->inbound_request->id;
 		global_msg_id=T->inbound_request->id;
-
+		DBG("DEBUG: FR_handler: send 408 (%p)\n", r_buf->my_T);
 		t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
 		t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
 	}else{
 	}else{
 		/* put it on WT_LIST - transaction is over */
 		/* put it on WT_LIST - transaction is over */

+ 2 - 2
modules/tm/t_funcs.h

@@ -106,8 +106,8 @@ extern struct s_table*  hash_table;
 	( { \
 	( { \
 		DBG_REF("ref", (_T_cell));	 \
 		DBG_REF("ref", (_T_cell));	 \
 		if (T_IS_REFED_BYSELF(_T_cell)) { \
 		if (T_IS_REFED_BYSELF(_T_cell)) { \
-			DBG("ERROR: refering already refered transaction %p from %s , %s : %d\n", \
-				(_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
+			DBG("ERROR: refering already refered transaction %p from %s,%s :"\
+				" %d\n",(_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
 			abort(); \
 			abort(); \
 		} \
 		} \
 		(_T_cell)->ref_bitmap |= process_bit; \
 		(_T_cell)->ref_bitmap |= process_bit; \

+ 19 - 17
modules/tm/t_lookup.c

@@ -169,8 +169,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 found:
 found:
 	T=p_cell;
 	T=p_cell;
 	T_REF( T );
 	T_REF( T );
-	DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_lookup_request: "
-		"transaction found ( T=%p , ref=%x)\n",T,T->ref_bitmap);
+	DBG("DEBUG: t_lookup_request: transaction found (T=%p , ref=%x)\n",
+		T,T->ref_bitmap);
 	unlock(&(hash_table->entrys[p_msg->hash_index].mutex));
 	unlock(&(hash_table->entrys[p_msg->hash_index].mutex));
 	return 1;
 	return 1;
 }
 }
@@ -326,7 +326,7 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
 		&& ((get_cseq(p_msg)->method.s[0] ==
 		&& ((get_cseq(p_msg)->method.s[0] ==
 		get_cseq(p_cell->inbound_request)->method.s[0] && (*local_cancel=0)==0)
 		get_cseq(p_cell->inbound_request)->method.s[0] && (*local_cancel=0)==0)
 		|| (get_cseq(p_cell->inbound_request)->method.s[0]=='I' &&
 		|| (get_cseq(p_cell->inbound_request)->method.s[0]=='I' &&
-		get_cseq(p_msg)->method.s[0]=='C' 
+		get_cseq(p_msg)->method.s[0]=='C'
 		&& p_cell->outbound_cancel[branch_id]!=NO_CANCEL
 		&& p_cell->outbound_cancel[branch_id]!=NO_CANCEL
 		&& p_cell->outbound_cancel[branch_id]!=EXTERNAL_CANCEL
 		&& p_cell->outbound_cancel[branch_id]!=EXTERNAL_CANCEL
 		&& (*local_cancel=1)==1))
 		&& (*local_cancel=1)==1))
@@ -345,8 +345,8 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
 				*p_branch = branch_id;
 				*p_branch = branch_id;
 				T_REF( T );
 				T_REF( T );
 				unlock(&(hash_table->entrys[hash_index].mutex));
 				unlock(&(hash_table->entrys[hash_index].mutex));
-				DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_reply_matching:"
-					" reply matched (T=%p,ref=%x)!\n",T,T->ref_bitmap);
+				DBG("DEBUG: t_reply_matching: reply matched (T=%p,ref=%x)!\n",
+					T,T->ref_bitmap);
 				return 1;
 				return 1;
 			}
 			}
 		/* next cell */
 		/* next cell */
@@ -378,7 +378,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
 	int local_cancel;
 	int local_cancel;
 
 
 	/* is T still up-to-date ? */
 	/* is T still up-to-date ? */
-	DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on entrance=%p\n", 
+	DBG("DEBUG: t_check: msg id=%d global id=%d T start=%p\n", 
 		p_msg->id,global_msg_id,T);
 		p_msg->id,global_msg_id,T);
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
 	{
 	{
@@ -391,8 +391,8 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
 				return -1;
 				return -1;
 			t_lookup_request( p_msg , 0 /* unlock before returning */ );
 			t_lookup_request( p_msg , 0 /* unlock before returning */ );
 		} else {
 		} else {
-			if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1
-			|| !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq )
+			if ( parse_headers(p_msg, HDR_VIA1|HDR_TO|HDR_CSEQ )==-1
+			|| !p_msg->via1 || !p_msg->to || !p_msg->cseq )
 				return -1;
 				return -1;
 			t_reply_matching( p_msg ,
 			t_reply_matching( p_msg ,
 				((param_branch!=0)?(param_branch):(&local_branch)),
 				((param_branch!=0)?(param_branch):(&local_branch)),
@@ -406,7 +406,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
 			abort();
 			abort();
 		}
 		}
 #endif
 #endif
-		DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on finish=%p\n",
+		DBG("DEBUG: t_check: msg id=%d global id=%d T end=%p\n",
 			p_msg->id,global_msg_id,T);
 			p_msg->id,global_msg_id,T);
 	} else {
 	} else {
 		if (T)
 		if (T)
@@ -452,6 +452,9 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
 
 
 }
 }
 
 
+
+
+
 /* atomic "add_if_new" construct; it returns:
 /* atomic "add_if_new" construct; it returns:
 	AIN_ERROR	if a fatal error (e.g, parsing) occured
 	AIN_ERROR	if a fatal error (e.g, parsing) occured
 	AIN_RETR	it's a retransmission
 	AIN_RETR	it's a retransmission
@@ -466,8 +469,8 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
 	struct cell *new_cell;
 	struct cell *new_cell;
 
 
 	/* is T still up-to-date ? */
 	/* is T still up-to-date ? */
-	DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d , T on entrance=%p\n", 
-		p_msg->id,global_msg_id,T);
+	DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d ,"
+		" T on entrance=%p\n",p_msg->id,global_msg_id,T);
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
 	{
 	{
 		global_msg_id = p_msg->id;
 		global_msg_id = p_msg->id;
@@ -484,12 +487,12 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
 				ret=AIN_NEWACK;
 				ret=AIN_NEWACK;
 			} else {
 			} else {
 				/* add new transaction */
 				/* add new transaction */
- 				new_cell = build_cell( p_msg ) ;
-   				if  ( !new_cell ){
-       					LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
+				new_cell = build_cell( p_msg ) ;
+				if  ( !new_cell ){
+					LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
 					ret = AIN_ERROR;
 					ret = AIN_ERROR;
-    				} else {
- 					insert_into_hash_table_unsafe( hash_table , new_cell );
+				} else {
+					insert_into_hash_table_unsafe( hash_table , new_cell );
 					ret = AIN_NEW;
 					ret = AIN_NEW;
 					T=new_cell;
 					T=new_cell;
 					T_REF(T);
 					T_REF(T);
@@ -510,7 +513,6 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
 			"processing this message, T not found!\n");
 			"processing this message, T not found!\n");
 		return AIN_ERROR;
 		return AIN_ERROR;
 	}
 	}
-
 }
 }
 
 
 
 

+ 52 - 42
modules/tm/t_reply.c

@@ -173,7 +173,7 @@ int t_retransmit_reply( /* struct sip_msg* p_msg    */ )
 
 
 
 
 /* Force a new response into inbound response buffer.
 /* Force a new response into inbound response buffer.
-  * returns 1 if everything was OK or -1 for erro
+  * returns 1 if everything was OK or -1 for error
   */
   */
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 {
 {
@@ -181,7 +181,8 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
 	char * buf, *shbuf;
 	char * buf, *shbuf;
 	struct retrans_buff *rb;
 	struct retrans_buff *rb;
 
 
-	buf = build_res_buf_from_sip_req(code,text,0,0,T->inbound_request,&len);
+	buf = build_res_buf_from_sip_req(code,text,T->tag->s,T->tag->len,
+		T->inbound_request,&len);
 	DBG("DEBUG: t_send_reply: buffer computed\n");
 	DBG("DEBUG: t_send_reply: buffer computed\n");
 	if (!buf)
 	if (!buf)
 	{
 	{
@@ -422,7 +423,7 @@ int t_on_reply( struct sip_msg  *p_msg )
 	unsigned int local_cancel;
 	unsigned int local_cancel;
 	struct sip_msg *clone, *backup;
 	struct sip_msg *clone, *backup;
 	int relay;
 	int relay;
-	int start_fr;
+	int start_fr = 0;
 	int is_invite;
 	int is_invite;
 	/* retransmission structure of outbound reply and request */
 	/* retransmission structure of outbound reply and request */
 	struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
 	struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
@@ -434,7 +435,8 @@ int t_on_reply( struct sip_msg  *p_msg )
 
 
 
 
 	/* make sure we know the assosociated tranaction ... */
 	/* make sure we know the assosociated tranaction ... */
-	if (t_check( p_msg  , &branch , &local_cancel)==-1) return 1;
+	if (t_check( p_msg  , &branch , &local_cancel)==-1)
+		return 1;
 	/* ... if there is no such, tell the core router to forward statelessly */
 	/* ... if there is no such, tell the core router to forward statelessly */
 	if ( T<=0 ) return 1;
 	if ( T<=0 ) return 1;
 
 
@@ -443,23 +445,30 @@ int t_on_reply( struct sip_msg  *p_msg )
 
 
 	backup = 0;
 	backup = 0;
 
 
-	DBG("DEBUG: t_on_reply_received: Original status=%d (%d,%d)\n",
+	DBG("DEBUG: t_on_reply: Original status=%d (%d,%d)\n",
 		T->status,branch,local_cancel);
 		T->status,branch,local_cancel);
 
 
 	/* special cases (local cancel reply and another 100 reply!)*/
 	/* special cases (local cancel reply and another 100 reply!)*/
 	if (p_msg->REPLY_STATUS==100 && T->status==100)
 	if (p_msg->REPLY_STATUS==100 && T->status==100)
-		return 0;
+		goto error;
 	if (local_cancel==1)
 	if (local_cancel==1)
 	{
 	{
 		reset_timer( hash_table, &(T->outbound_cancel[branch]->retr_timer));
 		reset_timer( hash_table, &(T->outbound_cancel[branch]->retr_timer));
 		if ( p_msg->REPLY_STATUS>=200 )
 		if ( p_msg->REPLY_STATUS>=200 )
 			reset_timer( hash_table, &(T->outbound_cancel[branch]->fr_timer));
 			reset_timer( hash_table, &(T->outbound_cancel[branch]->fr_timer));
-		return 0;
+		goto error;
 	}
 	}
 
 
-	/* it can take quite long -- better do it now than later 
-	   inside a reply_lock */
-													/* CLONE alloc'ed */
+	/* do we have via2 ? - maybe we'll need it for forwarding -bogdan*/
+	if ((p_msg->via2==0) || (p_msg->via2->error!=VIA_PARSE_OK)){
+		/* no second via => error */
+		LOG(L_ERR, "ERROR: t_on_reply: no 2nd via found in reply\n");
+		goto error2;
+	}
+
+	/* it can take quite long - better do it now than later
+	inside a reply_lock */
+	/* CLONE alloc'ed */
 	if (!(clone=sip_msg_cloner( p_msg ))) {
 	if (!(clone=sip_msg_cloner( p_msg ))) {
 		goto error;
 		goto error;
 	}
 	}
@@ -472,10 +481,10 @@ int t_on_reply( struct sip_msg  *p_msg )
 	sometimes it will result in useless CPU cycles
 	sometimes it will result in useless CPU cycles
 	but mostly the assumption holds and allows the
 	but mostly the assumption holds and allows the
 	work to be done out of criticial lock region */
 	work to be done out of criticial lock region */
-	if (msg_status==100) buf=0;
+	if (msg_status==100)
+		buf=0;
 	else {
 	else {
-												/* buf maybe allo'ed*/
-
+		/* buf maybe allo'ed*/
 		buf = build_res_buf_from_sip_res ( p_msg, &orp_len);
 		buf = build_res_buf_from_sip_res ( p_msg, &orp_len);
 		if (!buf) {
 		if (!buf) {
 			LOG(L_ERR, "ERROR: t_on_reply_received: "
 			LOG(L_ERR, "ERROR: t_on_reply_received: "
@@ -487,15 +496,13 @@ int t_on_reply( struct sip_msg  *p_msg )
 	/* *** stop timers *** */
 	/* *** stop timers *** */
 	orq_rb=T->outbound_request[branch];
 	orq_rb=T->outbound_request[branch];
 	/* stop retransmission */
 	/* stop retransmission */
-												/* timers reset */
-
 	reset_timer( hash_table, &(orq_rb->retr_timer));
 	reset_timer( hash_table, &(orq_rb->retr_timer));
 	/* stop final response timer only if I got a final response */
 	/* stop final response timer only if I got a final response */
 	if ( msg_class>1 )
 	if ( msg_class>1 )
 		reset_timer( hash_table, &(orq_rb->fr_timer));
 		reset_timer( hash_table, &(orq_rb->fr_timer));
 
 
 	LOCK_REPLIES( T );
 	LOCK_REPLIES( T );
-   	/* if a got the first prov. response for an INVITE ->
+	/* if a got the first prov. response for an INVITE ->
 	   change FR_TIME_OUT to INV_FR_TIME_UT */
 	   change FR_TIME_OUT to INV_FR_TIME_UT */
 	start_fr = !T->inbound_response[branch] && msg_class==1 && is_invite;
 	start_fr = !T->inbound_response[branch] && msg_class==1 && is_invite;
 
 
@@ -508,14 +515,14 @@ int t_on_reply( struct sip_msg  *p_msg )
 		if ( ! orp_rb->retr_buffer ) {
 		if ( ! orp_rb->retr_buffer ) {
 			/*init retrans buffer*/
 			/*init retrans buffer*/
 			memset( orp_rb , 0 , sizeof (struct retrans_buff) );
 			memset( orp_rb , 0 , sizeof (struct retrans_buff) );
-			if (update_sock_struct_from_via(  &(orp_rb->to), p_msg->via2 )==-1) {
-					UNLOCK_REPLIES( T );
-					start_fr = 1;
-					LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
-						"cannot lookup reply dst: %s\n",
-						p_msg->via2->host.s );
-					save_clone = 0;
-					goto error2;
+			if (update_sock_struct_from_via( &(orp_rb->to),p_msg->via2 )==-1) {
+				UNLOCK_REPLIES( T );
+				start_fr = 1;
+				LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
+					"cannot lookup reply dst: %s\n",
+				p_msg->via2->host.s );
+				save_clone = 0;
+				goto error2;
 			}
 			}
 			orp_rb->retr_timer.tg=TG_RT;
 			orp_rb->retr_timer.tg=TG_RT;
 			orp_rb->fr_timer.tg=TG_FR;
 			orp_rb->fr_timer.tg=TG_FR;
@@ -530,9 +537,10 @@ int t_on_reply( struct sip_msg  *p_msg )
 			alloc_len = orp_len + REPLY_OVERBUFFER_LEN ;
 			alloc_len = orp_len + REPLY_OVERBUFFER_LEN ;
 		} else {
 		} else {
 			alloc_len = orp_len;
 			alloc_len = orp_len;
-		};
+		}
 
 
-		if (! (orp_rb->retr_buffer = (char *) shm_resize( orp_rb->retr_buffer, alloc_len ))) {
+		if (! (orp_rb->retr_buffer = (char *)
+		shm_resize( orp_rb->retr_buffer, alloc_len ))) {
 			UNLOCK_REPLIES( T );
 			UNLOCK_REPLIES( T );
 			start_fr = 1;
 			start_fr = 1;
 			save_clone = 0;
 			save_clone = 0;
@@ -570,29 +578,30 @@ cleanup:
 	}
 	}
 
 
 	/* *** ACK handling *** */
 	/* *** ACK handling *** */
-	if ( is_invite )
-	{
+	if ( is_invite ) {
 		if ( T->outbound_ack[branch] )
 		if ( T->outbound_ack[branch] )
 		{   /*retransmit*/
 		{   /*retransmit*/
 			/* I don't need any additional syncing here -- after ack
 			/* I don't need any additional syncing here -- after ack
 			   is introduced it's never changed */
 			   is introduced it's never changed */
 			SEND_BUFFER( T->outbound_ack[branch] );
 			SEND_BUFFER( T->outbound_ack[branch] );
-		} else if (msg_class>2 ) {   /*on a non-200 reply to INVITE*/
-           		DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE: send ACK\n");
-				ack_rb = build_ack( p_msg, T, branch );
-				if (ack_rb) {
-					SEND_BUFFER( ack_rb );
-					/* append to transaction structure */
-					attach_ack( T, branch, ack_rb );
-				} else {
-					/* restart FR */
-					start_fr=1;
-					DBG("ERROR: t_on_reply: build_ack failed\n");
-				}
+		} else if (msg_class>2 ) {
+			/*on a non-200 reply to INVITE*/
+			DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE:"
+				"send ACK\n");
+			ack_rb = build_ack( p_msg, T, branch );
+			if (ack_rb) {
+				SEND_BUFFER( ack_rb );
+				/* append to transaction structure */
+				attach_ack( T, branch, ack_rb );
+			} else {
+				/* restart FR */
+				start_fr=1;
+				DBG("ERROR: t_on_reply: build_ack failed\n");
+			}
 		}
 		}
 	} /* is_invite */
 	} /* is_invite */
 
 
-   	/* restart retransmission if a provisional response came for 
+	/* restart retransmission if a provisional response came for 
 	   a non_INVITE -> retrasmit at RT_T2*/
 	   a non_INVITE -> retrasmit at RT_T2*/
 	if ( msg_class==1 && !is_invite )
 	if ( msg_class==1 && !is_invite )
 	{
 	{
@@ -601,7 +610,8 @@ cleanup:
 	}
 	}
 	if (backup) sip_msg_free( backup );
 	if (backup) sip_msg_free( backup );
 error2:
 error2:
-	if (start_fr) set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
+	if (start_fr) 
+		set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
 	if (buf) free( buf );
 	if (buf) free( buf );
 error1:
 error1:
 	if (!save_clone) sip_msg_free( clone );
 	if (!save_clone) sip_msg_free( clone );

+ 3 - 0
modules/tm/timer.c

@@ -160,6 +160,9 @@ void timer_routine(unsigned int ticks , void * attr)
 	struct timer_link  *tl, *tmp_tl;
 	struct timer_link  *tl, *tmp_tl;
 	int                           id;
 	int                           id;
 
 
+#ifdef BOGDAN_TRIFLE
+	DBG(" %d \n",ticks);
+#endif
 
 
 	for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
 	for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
 	{
 	{

+ 3 - 5
msg_parser.c

@@ -263,8 +263,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			}
 			}
 			hdr->parsed=to_b;
 			hdr->parsed=to_b;
 			hdr->body.len=tmp-hdr->body.s;
 			hdr->body.len=tmp-hdr->body.s;
-			DBG("get_hdr_field: to <%s>: <%s>=[%d] <%c> [%d]\n",
-				hdr->name.s, to_b->body.s,to_b->body.len,*tmp,hdr->body.len);
+			DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
+				hdr->name.s, hdr->body.len, to_b->body.s,to_b->body.len);
 			break;
 			break;
 		case HDR_FROM:
 		case HDR_FROM:
 		case HDR_CALLID:
 		case HDR_CALLID:
@@ -353,7 +353,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
 	m_end=eat_token_end(m, end);
 	m_end=eat_token_end(m, end);
 	*t=0; /*null terminate it*/
 	*t=0; /*null terminate it*/
 	cb->number.len=t-cb->number.s;
 	cb->number.len=t-cb->number.s;
-	DBG("parse_cseq: found number %s\n", cb->number.s);
 
 
 	if (m_end>=end) goto error;
 	if (m_end>=end) goto error;
 	if (m_end==m){
 	if (m_end==m){
@@ -366,7 +365,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
 	c=*t;
 	c=*t;
 	*t=0; /*null terminate it*/
 	*t=0; /*null terminate it*/
 	cb->method.len=t-cb->method.s;
 	cb->method.len=t-cb->method.s;
-	DBG("parse_cseq: found method %s\n", cb->method.s);
 	t++;
 	t++;
 	/*check if the header ends here*/
 	/*check if the header ends here*/
 	if (c=='\n') goto check_continue;
 	if (c=='\n') goto check_continue;
@@ -714,7 +712,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
 			DBG(" version: <%s>\n",fl->u.reply.version.s);
 			DBG(" version: <%s>\n",fl->u.reply.version.s);
 			DBG(" status:  <%s>\n",fl->u.reply.status.s);
 			DBG(" status:  <%s>\n",fl->u.reply.status.s);
 			DBG(" reason:  <%s>\n",fl->u.reply.reason.s);
 			DBG(" reason:  <%s>\n",fl->u.reply.reason.s);
-			flags=HDR_VIA|HDR_VIA2;
+			flags=HDR_VIA | HDR_VIA2;
 			break;
 			break;
 		default:
 		default:
 			DBG("unknown type %d\n",fl->type);
 			DBG("unknown type %d\n",fl->type);

+ 3 - 5
parse_hname2.c

@@ -340,8 +340,6 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	register char* p;
 	register char* p;
 	register int val;
 	register int val;
 
 
-	DBG("DEBUG: parse_hname2 entered\n");
-
 	p = begin;
 	p = begin;
 	val = READ(p);
 	val = READ(p);
 	hdr->name.s = begin;
 	hdr->name.s = begin;
@@ -355,10 +353,10 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
 	case Via1: Via1_CASE;
 	case Via1: Via1_CASE;
 	case From: From_CASE;
 	case From: From_CASE;
 	case To12: To12_CASE;
 	case To12: To12_CASE;
-	case CSeq: CSeq_CASE;                                                             
+	case CSeq: CSeq_CASE;
 	case Call: Call_CASE;
 	case Call: Call_CASE;
-        case Cont: Cont_CASE;
-	case Rout: Rout_CASE;                                                             
+	case Cont: Cont_CASE;
+	case Rout: Rout_CASE;
 	case Max_: Max_CASE;
 	case Max_: Max_CASE;
 	case Reco: Reco_CASE;
 	case Reco: Reco_CASE;
         case Via2: Via2_CASE;
         case Via2: Via2_CASE;

+ 7 - 10
receive.c

@@ -57,7 +57,6 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 	}
 	}
 	DBG("After parse_msg...\n");
 	DBG("After parse_msg...\n");
 	if (msg->first_line.type==SIP_REQUEST){
 	if (msg->first_line.type==SIP_REQUEST){
-		DBG("msg= request\n");
 		/* sanity checks */
 		/* sanity checks */
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
 			/* no via, send back error ? */
 			/* no via, send back error ? */
@@ -68,7 +67,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 
 
 		/* loop checks */
 		/* loop checks */
 		if (loop_checks) {
 		if (loop_checks) {
-			DBG("WARNING: receive_msg: Placeholder for loop check. NOT implemented yet.\n");
+			DBG("WARNING: receive_msg: Placeholder for loop check."
+				" NOT implemented yet.\n");
 		}
 		}
 		
 		
 		/* exec routing script */
 		/* exec routing script */
@@ -90,18 +90,18 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 		STATS_RX_REQUEST( msg->first_line.u.request.method_value );
 		STATS_RX_REQUEST( msg->first_line.u.request.method_value );
 #endif
 #endif
 	}else if (msg->first_line.type==SIP_REPLY){
 	}else if (msg->first_line.type==SIP_REPLY){
-		DBG("msg= reply\n");
 		/* sanity checks */
 		/* sanity checks */
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
 			/* no via, send back error ? */
 			/* no via, send back error ? */
 			LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
 			LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
 			goto error;
 			goto error;
 		}
 		}
+		/*
 		if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
 		if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
-			/* no second via => error? */
+			/* no second via => error? /
 			LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
 			LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
 			goto error;
 			goto error;
-		}
+		}*/
 		/* check if via1 == us */
 		/* check if via1 == us */
 
 
 #ifdef STATS
 #ifdef STATS
@@ -110,11 +110,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
 #endif
 #endif
 		
 		
 		/* send the msg */
 		/* send the msg */
-		if (forward_reply(msg)==0){
-			DBG(" reply forwarded to %s:%d\n", 
-						msg->via2->host.s,
-						(unsigned short) msg->via2->port);
-		}
+		forward_reply(msg);
+
 #ifdef STATS
 #ifdef STATS
 		gettimeofday( & tve, &tz );
 		gettimeofday( & tve, &tz );
 		diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec);
 		diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec);

+ 0 - 1
timer.c

@@ -109,6 +109,5 @@ unsigned int get_ticks()
 			", returning 0 (probably wrong)");
 			", returning 0 (probably wrong)");
 	return 0;
 	return 0;
 #endif
 #endif
-	DBG("- get_ticks:returning %d\n", *jiffies);
 	return *jiffies;
 	return *jiffies;
 }
 }

+ 8 - 11
udp_server.c

@@ -223,30 +223,27 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
 	c=inet_ntoa(a->sin_addr);
 	c=inet_ntoa(a->sin_addr);
 	strncpy( ip_txt, c, MAX_IP_LENGTH - 1 );
 	strncpy( ip_txt, c, MAX_IP_LENGTH - 1 );
 	p=ntohs(a->sin_port);
 	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");
+		DBG("DEBUG: udp_send: 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");
+		DBG("DEBUG: udp_send: to not INET\n");
 	if (a->sin_port == 0)
 	if (a->sin_port == 0)
-		DBG("DEBUG: no port\n");
+		DBG("DEBUG: udp_send: no port\n");
 
 
 #ifdef EXTRA_DEBUG
 #ifdef EXTRA_DEBUG
-	if ( tolen < sizeof(struct sockaddr_in) || a->sin_family && a->sin_family != AF_INET
-		|| a->sin_port == 0 )
+	if ( tolen < sizeof(struct sockaddr_in) ||
+	a->sin_family && a->sin_family != AF_INET || a->sin_port == 0 )
 		abort();
 		abort();
 	/* every message must be terminated by CRLF */
 	/* every message must be terminated by CRLF */
 	if (memcmp(buf+len-CRLF_LEN, CRLF, CRLF_LEN)!=0) {
 	if (memcmp(buf+len-CRLF_LEN, CRLF, CRLF_LEN)!=0) {
-		LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet not terminated by CRLF\n");
+		LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet"
+			" not terminated by CRLF\n");
 		abort();
 		abort();
 	}
 	}
 #endif
 #endif
 
 
-	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(" packet: {%.*s...}\n", 24, buf ); */
-	/* DBG("%.*s\n", len, buf ); */
+	DBG("DEBUG: udp_send destination: IP=%s, port=%u;\n", ip_txt, p);
 #endif
 #endif
 /*
 /*
 	memset(&a2, 0, sizeof(struct sockaddr_in));
 	memset(&a2, 0, sizeof(struct sockaddr_in));