Browse code

local cancel

Bogdan-Andrei Iancu authored on 27/02/2002 21:30:43
Showing 12 changed files
... ...
@@ -80,8 +80,8 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
80 80
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
81 81
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
82 82
 	 -DF_MALLOC  -DUSE_SYNONIM\
83
-	 -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL\
84
-	 -DNO_DEBUG 
83
+	 -DWAIT -DNEW_HNAME -DNOISY_REPLIES -DSRL -DBOGDAN_TRIFLE \
84
+	 #-DNO_DEBUG \
85 85
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
86 86
 	 #-DNOSMP \
87 87
 	 #-DEXTRA_DEBUG 
... ...
@@ -153,6 +153,14 @@ int forward_reply(struct sip_msg* msg)
153 153
 		}
154 154
 	}
155 155
 	
156
+	/* we have to forward the reply stateless, so we need second via -bogdan*/
157
+	if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK))
158
+	{
159
+		/* no second via => error */
160
+		LOG(L_ERR, "ERROR: forward_msg: no 2nd via found in reply\n");
161
+		goto error;
162
+	}
163
+
156 164
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr_in));
157 165
 	if (to==0){
158 166
 		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
... ...
@@ -165,15 +173,6 @@ int forward_reply(struct sip_msg* msg)
165 173
 		goto error;
166 174
 	}
167 175
 
168
-	 /* send it! */
169
-	/* moved to udp_send; -jiri
170
-
171
-	DBG("Sending: to %s:%d, \n%s.\n",
172
-			msg->via2->host.s,
173
-			(unsigned short)msg->via2->port,
174
-			new_buf);
175
-	*/
176
-
177 176
 	if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
178 177
 
179 178
 	if (udp_send(new_buf,new_len, (struct sockaddr*) to,
... ...
@@ -181,13 +180,16 @@ int forward_reply(struct sip_msg* msg)
181 180
 	{
182 181
 		STATS_TX_DROPS;
183 182
 		goto error;
184
-	}
185
-	else {
183
+	} else {
186 184
 #ifdef STATS
187 185
 		int j = msg->first_line.u.reply.statuscode/100;
188 186
 		STATS_TX_RESPONSE(  j );
189 187
 #endif
190 188
 	}
189
+
190
+	DBG(" reply forwarded to %s:%d\n",msg->via2->host.s,
191
+		(unsigned short) msg->via2->port);
192
+
191 193
 	free(new_buf);
192 194
 	free(to);
193 195
 skip:
... ...
@@ -76,7 +76,6 @@ static inline void reset_retr_timers( struct s_table *h_table,
76 76
 	int ijk;
77 77
 	struct retrans_buff *rb;
78 78
 
79
-	DBG("DEBUG:stop_RETR_and_FR_timers : start \n");
80 79
 	/* lock the first timer list of the FR group -- all other
81 80
 	   lists share the same lock*/
82 81
 	lock(hash_table->timers[RT_T1_TO_1].mutex);
... ...
@@ -96,7 +95,7 @@ static inline void reset_retr_timers( struct s_table *h_table,
96 95
 			}
97 96
 		}
98 97
 	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
99
-	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
98
+	DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
100 99
 }
101 100
 
102 101
 int tm_startup()
... ...
@@ -376,7 +375,7 @@ int t_put_on_wait(  struct cell  *Trans  )
376 375
 	for( i=0 ; i<Trans->nr_of_outgoings ; i++ )
377 376
 		if ( Trans->inbound_response[i] && 
378 377
 		REPLY_CLASS(Trans->inbound_response[i])==1)
379
-		t_cancel_branch(i);
378
+			t_cancel_branch(i);
380 379
 
381 380
 
382 381
 	/* 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)
662 661
 		sizeof (struct sockaddr_in));
663 662
 	srb->tolen = sizeof (struct sockaddr_in);
664 663
 	srb->my_T = Trans;
664
+	srb->fr_timer.payload = srb->retr_timer.payload = srb;
665 665
 	srb->branch = branch;
666 666
 	srb->status = STATUS_LOCAL_CANCEL;
667 667
 	srb->retr_buffer = (char *) srb + sizeof( struct retrans_buff );
... ...
@@ -837,7 +837,7 @@ void retransmission_handler( void *attr)
837 837
 {
838 838
 	struct retrans_buff* r_buf ;
839 839
 	enum lists id;
840
-
840
+	DBG("DEBUG: entering retransmisson with attr = %x\n",attr);
841 841
 	r_buf = (struct retrans_buff*)attr;
842 842
 #ifdef EXTRA_DEBUG
843 843
 	if (r_buf->my_T->damocles) {
... ...
@@ -886,18 +886,16 @@ void final_response_handler( void *attr)
886 886
 	/* the transaction is already removed from FR_LIST by the timer */
887 887
 	if (r_buf->status==STATUS_LOCAL_CANCEL)
888 888
 	{
889
-		DBG("DEBUG: final_response_handler: stop retransmission for"
890
-			"Local Cancel\n");
889
+		DBG("DEBUG: FR_handler: stop retransmission for Local Cancel\n");
891 890
 		reset_timer( hash_table , &(r_buf->retr_timer) );
892 891
 		return;
893 892
 	}
894 893
 	/* send a 408 */
895 894
 	if ( r_buf->my_T->status<200)
896 895
 	{
897
-		DBG("DEBUG: final_response_handler:stop retransmission and"
898
-			" send 408 (t=%p)\n", r_buf->my_T);
896
+		DBG("DEBUG: FR_handler:stop retr. and send CANCEL (%p)\n",r_buf->my_T);
899 897
 		reset_timer( hash_table, &(r_buf->retr_timer) );
900
-		//t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
898
+		t_build_and_send_CANCEL( r_buf->my_T ,r_buf->branch);
901 899
 		/* dirty hack:t_send_reply would increase ref_count which would indeed
902 900
 		result in refcount++ which would not -- until timer processe's
903 901
 		T changes again; currently only on next call to t_send_reply from
... ...
@@ -905,7 +903,7 @@ void final_response_handler( void *attr)
905 903
 		and refcount++ JKU */
906 904
 		T=r_buf->my_T;
907 905
 		global_msg_id=T->inbound_request->id;
908
-
906
+		DBG("DEBUG: FR_handler: send 408 (%p)\n", r_buf->my_T);
909 907
 		t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
910 908
 	}else{
911 909
 		/* put it on WT_LIST - transaction is over */
... ...
@@ -106,8 +106,8 @@ extern struct s_table*  hash_table;
106 106
 	( { \
107 107
 		DBG_REF("ref", (_T_cell));	 \
108 108
 		if (T_IS_REFED_BYSELF(_T_cell)) { \
109
-			DBG("ERROR: refering already refered transaction %p from %s , %s : %d\n", \
110
-				(_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
109
+			DBG("ERROR: refering already refered transaction %p from %s,%s :"\
110
+				" %d\n",(_T_cell), __FUNCTION__, __FILE__, __LINE__ ); \
111 111
 			abort(); \
112 112
 		} \
113 113
 		(_T_cell)->ref_bitmap |= process_bit; \
... ...
@@ -169,8 +169,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
169 169
 found:
170 170
 	T=p_cell;
171 171
 	T_REF( T );
172
-	DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_lookup_request: "
173
-		"transaction found ( T=%p , ref=%x)\n",T,T->ref_bitmap);
172
+	DBG("DEBUG: t_lookup_request: transaction found (T=%p , ref=%x)\n",
173
+		T,T->ref_bitmap);
174 174
 	unlock(&(hash_table->entrys[p_msg->hash_index].mutex));
175 175
 	return 1;
176 176
 }
... ...
@@ -326,7 +326,7 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
326 326
 		&& ((get_cseq(p_msg)->method.s[0] ==
327 327
 		get_cseq(p_cell->inbound_request)->method.s[0] && (*local_cancel=0)==0)
328 328
 		|| (get_cseq(p_cell->inbound_request)->method.s[0]=='I' &&
329
-		get_cseq(p_msg)->method.s[0]=='C' 
329
+		get_cseq(p_msg)->method.s[0]=='C'
330 330
 		&& p_cell->outbound_cancel[branch_id]!=NO_CANCEL
331 331
 		&& p_cell->outbound_cancel[branch_id]!=EXTERNAL_CANCEL
332 332
 		&& (*local_cancel=1)==1))
... ...
@@ -345,8 +345,8 @@ int t_reply_matching( struct sip_msg *p_msg , unsigned int *p_branch ,
345 345
 				*p_branch = branch_id;
346 346
 				T_REF( T );
347 347
 				unlock(&(hash_table->entrys[hash_index].mutex));
348
-				DBG("DEBUG:XXXXXXXXXXXXXXXXXXXXX t_reply_matching:"
349
-					" reply matched (T=%p,ref=%x)!\n",T,T->ref_bitmap);
348
+				DBG("DEBUG: t_reply_matching: reply matched (T=%p,ref=%x)!\n",
349
+					T,T->ref_bitmap);
350 350
 				return 1;
351 351
 			}
352 352
 		/* next cell */
... ...
@@ -378,7 +378,7 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
378 378
 	int local_cancel;
379 379
 
380 380
 	/* is T still up-to-date ? */
381
-	DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on entrance=%p\n", 
381
+	DBG("DEBUG: t_check: msg id=%d global id=%d T start=%p\n", 
382 382
 		p_msg->id,global_msg_id,T);
383 383
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
384 384
 	{
... ...
@@ -391,8 +391,8 @@ int t_check( struct sip_msg* p_msg , int *param_branch, int *param_cancel)
391 391
 				return -1;
392 392
 			t_lookup_request( p_msg , 0 /* unlock before returning */ );
393 393
 		} else {
394
-			if ( parse_headers(p_msg, HDR_VIA1|HDR_VIA2|HDR_TO|HDR_CSEQ )==-1
395
-			|| !p_msg->via1 || !p_msg->via2 || !p_msg->to || !p_msg->cseq )
394
+			if ( parse_headers(p_msg, HDR_VIA1|HDR_TO|HDR_CSEQ )==-1
395
+			|| !p_msg->via1 || !p_msg->to || !p_msg->cseq )
396 396
 				return -1;
397 397
 			t_reply_matching( p_msg ,
398 398
 				((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)
406 406
 			abort();
407 407
 		}
408 408
 #endif
409
-		DBG("DEBUG: t_check : msg id=%d , global msg id=%d , T on finish=%p\n",
409
+		DBG("DEBUG: t_check: msg id=%d global id=%d T end=%p\n",
410 410
 			p_msg->id,global_msg_id,T);
411 411
 	} else {
412 412
 		if (T)
... ...
@@ -452,6 +452,9 @@ int add_branch_label( struct cell *trans, struct sip_msg *p_msg, int branch )
452 452
 
453 453
 }
454 454
 
455
+
456
+
457
+
455 458
 /* atomic "add_if_new" construct; it returns:
456 459
 	AIN_ERROR	if a fatal error (e.g, parsing) occured
457 460
 	AIN_RETR	it's a retransmission
... ...
@@ -466,8 +469,8 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
466 469
 	struct cell *new_cell;
467 470
 
468 471
 	/* is T still up-to-date ? */
469
-	DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d , T on entrance=%p\n", 
470
-		p_msg->id,global_msg_id,T);
472
+	DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d ,"
473
+		" T on entrance=%p\n",p_msg->id,global_msg_id,T);
471 474
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
472 475
 	{
473 476
 		global_msg_id = p_msg->id;
... ...
@@ -484,12 +487,12 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
484 487
 				ret=AIN_NEWACK;
485 488
 			} else {
486 489
 				/* add new transaction */
487
- 				new_cell = build_cell( p_msg ) ;
488
-   				if  ( !new_cell ){
489
-       					LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
490
+				new_cell = build_cell( p_msg ) ;
491
+				if  ( !new_cell ){
492
+					LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
490 493
 					ret = AIN_ERROR;
491
-    				} else {
492
- 					insert_into_hash_table_unsafe( hash_table , new_cell );
494
+				} else {
495
+					insert_into_hash_table_unsafe( hash_table , new_cell );
493 496
 					ret = AIN_NEW;
494 497
 					T=new_cell;
495 498
 					T_REF(T);
... ...
@@ -510,7 +513,6 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
510 513
 			"processing this message, T not found!\n");
511 514
 		return AIN_ERROR;
512 515
 	}
513
-
514 516
 }
515 517
 
516 518
 
... ...
@@ -173,7 +173,7 @@ int t_retransmit_reply( /* struct sip_msg* p_msg    */ )
173 173
 
174 174
 
175 175
 /* Force a new response into inbound response buffer.
176
-  * returns 1 if everything was OK or -1 for erro
176
+  * returns 1 if everything was OK or -1 for error
177 177
   */
178 178
 int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
179 179
 {
... ...
@@ -181,7 +181,8 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
181 181
 	char * buf, *shbuf;
182 182
 	struct retrans_buff *rb;
183 183
 
184
-	buf = build_res_buf_from_sip_req(code,text,0,0,T->inbound_request,&len);
184
+	buf = build_res_buf_from_sip_req(code,text,T->tag->s,T->tag->len,
185
+		T->inbound_request,&len);
185 186
 	DBG("DEBUG: t_send_reply: buffer computed\n");
186 187
 	if (!buf)
187 188
 	{
... ...
@@ -422,7 +423,7 @@ int t_on_reply( struct sip_msg  *p_msg )
422 423
 	unsigned int local_cancel;
423 424
 	struct sip_msg *clone, *backup;
424 425
 	int relay;
425
-	int start_fr;
426
+	int start_fr = 0;
426 427
 	int is_invite;
427 428
 	/* retransmission structure of outbound reply and request */
428 429
 	struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
... ...
@@ -434,7 +435,8 @@ int t_on_reply( struct sip_msg  *p_msg )
434 435
 
435 436
 
436 437
 	/* make sure we know the assosociated tranaction ... */
437
-	if (t_check( p_msg  , &branch , &local_cancel)==-1) return 1;
438
+	if (t_check( p_msg  , &branch , &local_cancel)==-1)
439
+		return 1;
438 440
 	/* ... if there is no such, tell the core router to forward statelessly */
439 441
 	if ( T<=0 ) return 1;
440 442
 
... ...
@@ -443,23 +445,30 @@ int t_on_reply( struct sip_msg  *p_msg )
443 445
 
444 446
 	backup = 0;
445 447
 
446
-	DBG("DEBUG: t_on_reply_received: Original status=%d (%d,%d)\n",
448
+	DBG("DEBUG: t_on_reply: Original status=%d (%d,%d)\n",
447 449
 		T->status,branch,local_cancel);
448 450
 
449 451
 	/* special cases (local cancel reply and another 100 reply!)*/
450 452
 	if (p_msg->REPLY_STATUS==100 && T->status==100)
451
-		return 0;
453
+		goto error;
452 454
 	if (local_cancel==1)
453 455
 	{
454 456
 		reset_timer( hash_table, &(T->outbound_cancel[branch]->retr_timer));
455 457
 		if ( p_msg->REPLY_STATUS>=200 )
456 458
 			reset_timer( hash_table, &(T->outbound_cancel[branch]->fr_timer));
457
-		return 0;
459
+		goto error;
458 460
 	}
459 461
 
460
-	/* it can take quite long -- better do it now than later 
461
-	   inside a reply_lock */
462
-													/* CLONE alloc'ed */
462
+	/* do we have via2 ? - maybe we'll need it for forwarding -bogdan*/
463
+	if ((p_msg->via2==0) || (p_msg->via2->error!=VIA_PARSE_OK)){
464
+		/* no second via => error */
465
+		LOG(L_ERR, "ERROR: t_on_reply: no 2nd via found in reply\n");
466
+		goto error2;
467
+	}
468
+
469
+	/* it can take quite long - better do it now than later
470
+	inside a reply_lock */
471
+	/* CLONE alloc'ed */
463 472
 	if (!(clone=sip_msg_cloner( p_msg ))) {
464 473
 		goto error;
465 474
 	}
... ...
@@ -472,10 +481,10 @@ int t_on_reply( struct sip_msg  *p_msg )
472 481
 	sometimes it will result in useless CPU cycles
473 482
 	but mostly the assumption holds and allows the
474 483
 	work to be done out of criticial lock region */
475
-	if (msg_status==100) buf=0;
484
+	if (msg_status==100)
485
+		buf=0;
476 486
 	else {
477
-												/* buf maybe allo'ed*/
478
-
487
+		/* buf maybe allo'ed*/
479 488
 		buf = build_res_buf_from_sip_res ( p_msg, &orp_len);
480 489
 		if (!buf) {
481 490
 			LOG(L_ERR, "ERROR: t_on_reply_received: "
... ...
@@ -487,15 +496,13 @@ int t_on_reply( struct sip_msg  *p_msg )
487 496
 	/* *** stop timers *** */
488 497
 	orq_rb=T->outbound_request[branch];
489 498
 	/* stop retransmission */
490
-												/* timers reset */
491
-
492 499
 	reset_timer( hash_table, &(orq_rb->retr_timer));
493 500
 	/* stop final response timer only if I got a final response */
494 501
 	if ( msg_class>1 )
495 502
 		reset_timer( hash_table, &(orq_rb->fr_timer));
496 503
 
497 504
 	LOCK_REPLIES( T );
498
-   	/* if a got the first prov. response for an INVITE ->
505
+	/* if a got the first prov. response for an INVITE ->
499 506
 	   change FR_TIME_OUT to INV_FR_TIME_UT */
500 507
 	start_fr = !T->inbound_response[branch] && msg_class==1 && is_invite;
501 508
 
... ...
@@ -508,14 +515,14 @@ int t_on_reply( struct sip_msg  *p_msg )
508 515
 		if ( ! orp_rb->retr_buffer ) {
509 516
 			/*init retrans buffer*/
510 517
 			memset( orp_rb , 0 , sizeof (struct retrans_buff) );
511
-			if (update_sock_struct_from_via(  &(orp_rb->to), p_msg->via2 )==-1) {
512
-					UNLOCK_REPLIES( T );
513
-					start_fr = 1;
514
-					LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
515
-						"cannot lookup reply dst: %s\n",
516
-						p_msg->via2->host.s );
517
-					save_clone = 0;
518
-					goto error2;
518
+			if (update_sock_struct_from_via( &(orp_rb->to),p_msg->via2 )==-1) {
519
+				UNLOCK_REPLIES( T );
520
+				start_fr = 1;
521
+				LOG(L_ERR, "ERROR: push_reply_from_uac_to_uas: "
522
+					"cannot lookup reply dst: %s\n",
523
+				p_msg->via2->host.s );
524
+				save_clone = 0;
525
+				goto error2;
519 526
 			}
520 527
 			orp_rb->retr_timer.tg=TG_RT;
521 528
 			orp_rb->fr_timer.tg=TG_FR;
... ...
@@ -530,9 +537,10 @@ int t_on_reply( struct sip_msg  *p_msg )
530 537
 			alloc_len = orp_len + REPLY_OVERBUFFER_LEN ;
531 538
 		} else {
532 539
 			alloc_len = orp_len;
533
-		};
540
+		}
534 541
 
535
-		if (! (orp_rb->retr_buffer = (char *) shm_resize( orp_rb->retr_buffer, alloc_len ))) {
542
+		if (! (orp_rb->retr_buffer = (char *)
543
+		shm_resize( orp_rb->retr_buffer, alloc_len ))) {
536 544
 			UNLOCK_REPLIES( T );
537 545
 			start_fr = 1;
538 546
 			save_clone = 0;
... ...
@@ -570,29 +578,30 @@ cleanup:
570 578
 	}
571 579
 
572 580
 	/* *** ACK handling *** */
573
-	if ( is_invite )
574
-	{
581
+	if ( is_invite ) {
575 582
 		if ( T->outbound_ack[branch] )
576 583
 		{   /*retransmit*/
577 584
 			/* I don't need any additional syncing here -- after ack
578 585
 			   is introduced it's never changed */
579 586
 			SEND_BUFFER( T->outbound_ack[branch] );
580
-		} else if (msg_class>2 ) {   /*on a non-200 reply to INVITE*/
581
-           		DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE: send ACK\n");
582
-				ack_rb = build_ack( p_msg, T, branch );
583
-				if (ack_rb) {
584
-					SEND_BUFFER( ack_rb );
585
-					/* append to transaction structure */
586
-					attach_ack( T, branch, ack_rb );
587
-				} else {
588
-					/* restart FR */
589
-					start_fr=1;
590
-					DBG("ERROR: t_on_reply: build_ack failed\n");
591
-				}
587
+		} else if (msg_class>2 ) {
588
+			/*on a non-200 reply to INVITE*/
589
+			DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE:"
590
+				"send ACK\n");
591
+			ack_rb = build_ack( p_msg, T, branch );
592
+			if (ack_rb) {
593
+				SEND_BUFFER( ack_rb );
594
+				/* append to transaction structure */
595
+				attach_ack( T, branch, ack_rb );
596
+			} else {
597
+				/* restart FR */
598
+				start_fr=1;
599
+				DBG("ERROR: t_on_reply: build_ack failed\n");
600
+			}
592 601
 		}
593 602
 	} /* is_invite */
594 603
 
595
-   	/* restart retransmission if a provisional response came for 
604
+	/* restart retransmission if a provisional response came for 
596 605
 	   a non_INVITE -> retrasmit at RT_T2*/
597 606
 	if ( msg_class==1 && !is_invite )
598 607
 	{
... ...
@@ -601,7 +610,8 @@ cleanup:
601 610
 	}
602 611
 	if (backup) sip_msg_free( backup );
603 612
 error2:
604
-	if (start_fr) set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
613
+	if (start_fr) 
614
+		set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
605 615
 	if (buf) free( buf );
606 616
 error1:
607 617
 	if (!save_clone) sip_msg_free( clone );
... ...
@@ -160,6 +160,9 @@ void timer_routine(unsigned int ticks , void * attr)
160 160
 	struct timer_link  *tl, *tmp_tl;
161 161
 	int                           id;
162 162
 
163
+#ifdef BOGDAN_TRIFLE
164
+	DBG(" %d \n",ticks);
165
+#endif
163 166
 
164 167
 	for( id=0 ; id<NR_OF_TIMER_LISTS ; id++ )
165 168
 	{
... ...
@@ -263,8 +263,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
263 263
 			}
264 264
 			hdr->parsed=to_b;
265 265
 			hdr->body.len=tmp-hdr->body.s;
266
-			DBG("get_hdr_field: to <%s>: <%s>=[%d] <%c> [%d]\n",
267
-				hdr->name.s, to_b->body.s,to_b->body.len,*tmp,hdr->body.len);
266
+			DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
267
+				hdr->name.s, hdr->body.len, to_b->body.s,to_b->body.len);
268 268
 			break;
269 269
 		case HDR_FROM:
270 270
 		case HDR_CALLID:
... ...
@@ -353,7 +353,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
353 353
 	m_end=eat_token_end(m, end);
354 354
 	*t=0; /*null terminate it*/
355 355
 	cb->number.len=t-cb->number.s;
356
-	DBG("parse_cseq: found number %s\n", cb->number.s);
357 356
 
358 357
 	if (m_end>=end) goto error;
359 358
 	if (m_end==m){
... ...
@@ -366,7 +365,6 @@ char * parse_cseq(char *buf, char* end, struct cseq_body* cb)
366 365
 	c=*t;
367 366
 	*t=0; /*null terminate it*/
368 367
 	cb->method.len=t-cb->method.s;
369
-	DBG("parse_cseq: found method %s\n", cb->method.s);
370 368
 	t++;
371 369
 	/*check if the header ends here*/
372 370
 	if (c=='\n') goto check_continue;
... ...
@@ -714,7 +712,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
714 712
 			DBG(" version: <%s>\n",fl->u.reply.version.s);
715 713
 			DBG(" status:  <%s>\n",fl->u.reply.status.s);
716 714
 			DBG(" reason:  <%s>\n",fl->u.reply.reason.s);
717
-			flags=HDR_VIA|HDR_VIA2;
715
+			flags=HDR_VIA | HDR_VIA2;
718 716
 			break;
719 717
 		default:
720 718
 			DBG("unknown type %d\n",fl->type);
... ...
@@ -340,8 +340,6 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
340 340
 	register char* p;
341 341
 	register int val;
342 342
 
343
-	DBG("DEBUG: parse_hname2 entered\n");
344
-
345 343
 	p = begin;
346 344
 	val = READ(p);
347 345
 	hdr->name.s = begin;
... ...
@@ -355,10 +353,10 @@ char* parse_hname2(char* begin, char* end, struct hdr_field* hdr)
355 353
 	case Via1: Via1_CASE;
356 354
 	case From: From_CASE;
357 355
 	case To12: To12_CASE;
358
-	case CSeq: CSeq_CASE;                                                             
356
+	case CSeq: CSeq_CASE;
359 357
 	case Call: Call_CASE;
360
-        case Cont: Cont_CASE;
361
-	case Rout: Rout_CASE;                                                             
358
+	case Cont: Cont_CASE;
359
+	case Rout: Rout_CASE;
362 360
 	case Max_: Max_CASE;
363 361
 	case Reco: Reco_CASE;
364 362
         case Via2: Via2_CASE;
... ...
@@ -57,7 +57,6 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
57 57
 	}
58 58
 	DBG("After parse_msg...\n");
59 59
 	if (msg->first_line.type==SIP_REQUEST){
60
-		DBG("msg= request\n");
61 60
 		/* sanity checks */
62 61
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
63 62
 			/* no via, send back error ? */
... ...
@@ -68,7 +67,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
68 67
 
69 68
 		/* loop checks */
70 69
 		if (loop_checks) {
71
-			DBG("WARNING: receive_msg: Placeholder for loop check. NOT implemented yet.\n");
70
+			DBG("WARNING: receive_msg: Placeholder for loop check."
71
+				" NOT implemented yet.\n");
72 72
 		}
73 73
 		
74 74
 		/* exec routing script */
... ...
@@ -90,18 +90,18 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
90 90
 		STATS_RX_REQUEST( msg->first_line.u.request.method_value );
91 91
 #endif
92 92
 	}else if (msg->first_line.type==SIP_REPLY){
93
-		DBG("msg= reply\n");
94 93
 		/* sanity checks */
95 94
 		if ((msg->via1==0) || (msg->via1->error!=VIA_PARSE_OK)){
96 95
 			/* no via, send back error ? */
97 96
 			LOG(L_ERR, "ERROR: receive_msg: no via found in reply\n");
98 97
 			goto error;
99 98
 		}
99
+		/*
100 100
 		if ((msg->via2==0) || (msg->via2->error!=VIA_PARSE_OK)){
101
-			/* no second via => error? */
101
+			/* no second via => error? /
102 102
 			LOG(L_ERR, "ERROR: receive_msg: no 2nd via found in reply\n");
103 103
 			goto error;
104
-		}
104
+		}*/
105 105
 		/* check if via1 == us */
106 106
 
107 107
 #ifdef STATS
... ...
@@ -110,11 +110,8 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
110 110
 #endif
111 111
 		
112 112
 		/* send the msg */
113
-		if (forward_reply(msg)==0){
114
-			DBG(" reply forwarded to %s:%d\n", 
115
-						msg->via2->host.s,
116
-						(unsigned short) msg->via2->port);
117
-		}
113
+		forward_reply(msg);
114
+
118 115
 #ifdef STATS
119 116
 		gettimeofday( & tve, &tz );
120 117
 		diff = (tve.tv_sec-tvb.tv_sec)*1000000+(tve.tv_usec-tvb.tv_usec);
... ...
@@ -109,6 +109,5 @@ unsigned int get_ticks()
109 109
 			", returning 0 (probably wrong)");
110 110
 	return 0;
111 111
 #endif
112
-	DBG("- get_ticks:returning %d\n", *jiffies);
113 112
 	return *jiffies;
114 113
 }
... ...
@@ -223,30 +223,27 @@ int udp_send(char *buf, unsigned len, struct sockaddr*  to, unsigned tolen)
223 223
 	c=inet_ntoa(a->sin_addr);
224 224
 	strncpy( ip_txt, c, MAX_IP_LENGTH - 1 );
225 225
 	p=ntohs(a->sin_port);
226
-	DBG("DEBUG: udp_send: ");
227 226
 
228 227
 	if (tolen < sizeof(struct sockaddr_in))
229
-		DBG("DEBUG: tolen small\n");
228
+		DBG("DEBUG: udp_send: tolen small\n");
230 229
 	if (a->sin_family && a->sin_family != AF_INET)
231
-		DBG("DEBUG: to not INET\n");
230
+		DBG("DEBUG: udp_send: to not INET\n");
232 231
 	if (a->sin_port == 0)
233
-		DBG("DEBUG: no port\n");
232
+		DBG("DEBUG: udp_send: no port\n");
234 233
 
235 234
 #ifdef EXTRA_DEBUG
236
-	if ( tolen < sizeof(struct sockaddr_in) || a->sin_family && a->sin_family != AF_INET
237
-		|| a->sin_port == 0 )
235
+	if ( tolen < sizeof(struct sockaddr_in) ||
236
+	a->sin_family && a->sin_family != AF_INET || a->sin_port == 0 )
238 237
 		abort();
239 238
 	/* every message must be terminated by CRLF */
240 239
 	if (memcmp(buf+len-CRLF_LEN, CRLF, CRLF_LEN)!=0) {
241
-		LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet not terminated by CRLF\n");
240
+		LOG(L_CRIT, "ERROR: this is ugly -- we are sending a packet"
241
+			" not terminated by CRLF\n");
242 242
 		abort();
243 243
 	}
244 244
 #endif
245 245
 
246
-	DBG(" destination: IP=%s, port=%u; packet:\n", ip_txt, p);
247
-	DBG(" destination (hex): IP=%x, port=%x;\n", a->sin_addr.s_addr, a->sin_port );
248
-	/* DBG(" packet: {%.*s...}\n", 24, buf ); */
249
-	/* DBG("%.*s\n", len, buf ); */
246
+	DBG("DEBUG: udp_send destination: IP=%s, port=%u;\n", ip_txt, p);
250 247
 #endif
251 248
 /*
252 249
 	memset(&a2, 0, sizeof(struct sockaddr_in));