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 165
 		goto error;
166 166
 	}
167 167
 
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 168
 	if (update_sock_struct_from_via( to, msg->via2 )==-1) goto error;
178 169
 
179 170
 	if (udp_send(new_buf,new_len, (struct sockaddr*) to,
... ...
@@ -181,13 +180,16 @@ int forward_reply(struct sip_msg* msg)
181 181
 	{
182 182
 		STATS_TX_DROPS;
183 183
 		goto error;
184
-	}
185
-	else {
184
+	} else {
186 185
 #ifdef STATS
187 186
 		int j = msg->first_line.u.reply.statuscode/100;
188 187
 		STATS_TX_RESPONSE(  j );
189 188
 #endif
190 189
 	}
190
+
191
+	DBG(" reply forwarded to %s:%d\n",msg->via2->host.s,
192
+		(unsigned short) msg->via2->port);
193
+
191 194
 	free(new_buf);
192 195
 	free(to);
193 196
 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 96
 			}
97 97
 		}
98 98
 	unlock(hash_table->timers[FR_TIMER_LIST].mutex);
99
-	DBG("DEBUG:stop_RETR_and_FR_timers : stop\n");
99
+	DBG("DEBUG:stop_RETR_and_FR_timers : timers stopped\n");
100 100
 }
101 101
 
102 102
 int tm_startup()
... ...
@@ -376,7 +375,7 @@ int t_put_on_wait(  struct cell  *Trans  )
376 376
 	for( i=0 ; i<Trans->nr_of_outgoings ; i++ )
377 377
 		if ( Trans->inbound_response[i] && 
378 378
 		REPLY_CLASS(Trans->inbound_response[i])==1)
379
-		t_cancel_branch(i);
379
+			t_cancel_branch(i);
380 380
 
381 381
 
382 382
 	/* 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 662
 		sizeof (struct sockaddr_in));
663 663
 	srb->tolen = sizeof (struct sockaddr_in);
664 664
 	srb->my_T = Trans;
665
+	srb->fr_timer.payload = srb->retr_timer.payload = srb;
665 666
 	srb->branch = branch;
666 667
 	srb->status = STATUS_LOCAL_CANCEL;
667 668
 	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 905
 		and refcount++ JKU */
906 906
 		T=r_buf->my_T;
907 907
 		global_msg_id=T->inbound_request->id;
908
-
908
+		DBG("DEBUG: FR_handler: send 408 (%p)\n", r_buf->my_T);
909 909
 		t_send_reply( r_buf->my_T->inbound_request,408,"Request Timeout" );
910 910
 	}else{
911 911
 		/* 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 466
 	struct cell *new_cell;
467 467
 
468 468
 	/* 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);
469
+	DBG("DEBUG: t_check_new_request: msg id=%d , global msg id=%d ,"
470
+		" T on entrance=%p\n",p_msg->id,global_msg_id,T);
471 471
 	if ( p_msg->id != global_msg_id || T==T_UNDEFINED )
472 472
 	{
473 473
 		global_msg_id = p_msg->id;
... ...
@@ -484,12 +487,12 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
484 484
 				ret=AIN_NEWACK;
485 485
 			} else {
486 486
 				/* 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");
487
+				new_cell = build_cell( p_msg ) ;
488
+				if  ( !new_cell ){
489
+					LOG(L_ERR, "ERROR: t_addifnew: out of mem:\n");
490 490
 					ret = AIN_ERROR;
491
-    				} else {
492
- 					insert_into_hash_table_unsafe( hash_table , new_cell );
491
+				} else {
492
+					insert_into_hash_table_unsafe( hash_table , new_cell );
493 493
 					ret = AIN_NEW;
494 494
 					T=new_cell;
495 495
 					T_REF(T);
... ...
@@ -510,7 +513,6 @@ enum addifnew_status t_addifnew( struct sip_msg* p_msg )
510 510
 			"processing this message, T not found!\n");
511 511
 		return AIN_ERROR;
512 512
 	}
513
-
514 513
 }
515 514
 
516 515
 
... ...
@@ -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 422
 	unsigned int local_cancel;
423 423
 	struct sip_msg *clone, *backup;
424 424
 	int relay;
425
-	int start_fr;
425
+	int start_fr = 0;
426 426
 	int is_invite;
427 427
 	/* retransmission structure of outbound reply and request */
428 428
 	struct retrans_buff *orq_rb, *orp_rb, *ack_rb;
... ...
@@ -434,7 +435,8 @@ int t_on_reply( struct sip_msg  *p_msg )
434 434
 
435 435
 
436 436
 	/* make sure we know the assosociated tranaction ... */
437
-	if (t_check( p_msg  , &branch , &local_cancel)==-1) return 1;
437
+	if (t_check( p_msg  , &branch , &local_cancel)==-1)
438
+		return 1;
438 439
 	/* ... if there is no such, tell the core router to forward statelessly */
439 440
 	if ( T<=0 ) return 1;
440 441
 
... ...
@@ -443,23 +445,30 @@ int t_on_reply( struct sip_msg  *p_msg )
443 443
 
444 444
 	backup = 0;
445 445
 
446
-	DBG("DEBUG: t_on_reply_received: Original status=%d (%d,%d)\n",
446
+	DBG("DEBUG: t_on_reply: Original status=%d (%d,%d)\n",
447 447
 		T->status,branch,local_cancel);
448 448
 
449 449
 	/* special cases (local cancel reply and another 100 reply!)*/
450 450
 	if (p_msg->REPLY_STATUS==100 && T->status==100)
451
-		return 0;
451
+		goto error;
452 452
 	if (local_cancel==1)
453 453
 	{
454 454
 		reset_timer( hash_table, &(T->outbound_cancel[branch]->retr_timer));
455 455
 		if ( p_msg->REPLY_STATUS>=200 )
456 456
 			reset_timer( hash_table, &(T->outbound_cancel[branch]->fr_timer));
457
-		return 0;
457
+		goto error;
458 458
 	}
459 459
 
460
-	/* it can take quite long -- better do it now than later 
461
-	   inside a reply_lock */
462
-													/* CLONE alloc'ed */
460
+	/* do we have via2 ? - maybe we'll need it for forwarding -bogdan*/
461
+	if ((p_msg->via2==0) || (p_msg->via2->error!=VIA_PARSE_OK)){
462
+		/* no second via => error */
463
+		LOG(L_ERR, "ERROR: t_on_reply: no 2nd via found in reply\n");
464
+		goto error2;
465
+	}
466
+
467
+	/* it can take quite long - better do it now than later
468
+	inside a reply_lock */
469
+	/* CLONE alloc'ed */
463 470
 	if (!(clone=sip_msg_cloner( p_msg ))) {
464 471
 		goto error;
465 472
 	}
... ...
@@ -472,10 +481,10 @@ int t_on_reply( struct sip_msg  *p_msg )
472 472
 	sometimes it will result in useless CPU cycles
473 473
 	but mostly the assumption holds and allows the
474 474
 	work to be done out of criticial lock region */
475
-	if (msg_status==100) buf=0;
475
+	if (msg_status==100)
476
+		buf=0;
476 477
 	else {
477
-												/* buf maybe allo'ed*/
478
-
478
+		/* buf maybe allo'ed*/
479 479
 		buf = build_res_buf_from_sip_res ( p_msg, &orp_len);
480 480
 		if (!buf) {
481 481
 			LOG(L_ERR, "ERROR: t_on_reply_received: "
... ...
@@ -487,15 +496,13 @@ int t_on_reply( struct sip_msg  *p_msg )
487 487
 	/* *** stop timers *** */
488 488
 	orq_rb=T->outbound_request[branch];
489 489
 	/* stop retransmission */
490
-												/* timers reset */
491
-
492 490
 	reset_timer( hash_table, &(orq_rb->retr_timer));
493 491
 	/* stop final response timer only if I got a final response */
494 492
 	if ( msg_class>1 )
495 493
 		reset_timer( hash_table, &(orq_rb->fr_timer));
496 494
 
497 495
 	LOCK_REPLIES( T );
498
-   	/* if a got the first prov. response for an INVITE ->
496
+	/* if a got the first prov. response for an INVITE ->
499 497
 	   change FR_TIME_OUT to INV_FR_TIME_UT */
500 498
 	start_fr = !T->inbound_response[branch] && msg_class==1 && is_invite;
501 499
 
... ...
@@ -508,14 +515,14 @@ int t_on_reply( struct sip_msg  *p_msg )
508 508
 		if ( ! orp_rb->retr_buffer ) {
509 509
 			/*init retrans buffer*/
510 510
 			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;
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;
519 519
 			}
520 520
 			orp_rb->retr_timer.tg=TG_RT;
521 521
 			orp_rb->fr_timer.tg=TG_FR;
... ...
@@ -530,9 +537,10 @@ int t_on_reply( struct sip_msg  *p_msg )
530 530
 			alloc_len = orp_len + REPLY_OVERBUFFER_LEN ;
531 531
 		} else {
532 532
 			alloc_len = orp_len;
533
-		};
533
+		}
534 534
 
535
-		if (! (orp_rb->retr_buffer = (char *) shm_resize( orp_rb->retr_buffer, alloc_len ))) {
535
+		if (! (orp_rb->retr_buffer = (char *)
536
+		shm_resize( orp_rb->retr_buffer, alloc_len ))) {
536 537
 			UNLOCK_REPLIES( T );
537 538
 			start_fr = 1;
538 539
 			save_clone = 0;
... ...
@@ -570,29 +578,30 @@ cleanup:
570 570
 	}
571 571
 
572 572
 	/* *** ACK handling *** */
573
-	if ( is_invite )
574
-	{
573
+	if ( is_invite ) {
575 574
 		if ( T->outbound_ack[branch] )
576 575
 		{   /*retransmit*/
577 576
 			/* I don't need any additional syncing here -- after ack
578 577
 			   is introduced it's never changed */
579 578
 			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
-				}
579
+		} else if (msg_class>2 ) {
580
+			/*on a non-200 reply to INVITE*/
581
+			DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE:"
582
+				"send ACK\n");
583
+			ack_rb = build_ack( p_msg, T, branch );
584
+			if (ack_rb) {
585
+				SEND_BUFFER( ack_rb );
586
+				/* append to transaction structure */
587
+				attach_ack( T, branch, ack_rb );
588
+			} else {
589
+				/* restart FR */
590
+				start_fr=1;
591
+				DBG("ERROR: t_on_reply: build_ack failed\n");
592
+			}
592 593
 		}
593 594
 	} /* is_invite */
594 595
 
595
-   	/* restart retransmission if a provisional response came for 
596
+	/* restart retransmission if a provisional response came for 
596 597
 	   a non_INVITE -> retrasmit at RT_T2*/
597 598
 	if ( msg_class==1 && !is_invite )
598 599
 	{
... ...
@@ -601,7 +610,8 @@ cleanup:
601 601
 	}
602 602
 	if (backup) sip_msg_free( backup );
603 603
 error2:
604
-	if (start_fr) set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
604
+	if (start_fr) 
605
+		set_timer( hash_table, &(orq_rb->fr_timer), FR_INV_TIMER_LIST );
605 606
 	if (buf) free( buf );
606 607
 error1:
607 608
 	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 366
 	c=*t;
367 367
 	*t=0; /*null terminate it*/
368 368
 	cb->method.len=t-cb->method.s;
369
-	DBG("parse_cseq: found method %s\n", cb->method.s);
370 369
 	t++;
371 370
 	/*check if the header ends here*/
372 371
 	if (c=='\n') goto check_continue;
... ...
@@ -714,7 +712,7 @@ int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
714 714
 			DBG(" version: <%s>\n",fl->u.reply.version.s);
715 715
 			DBG(" status:  <%s>\n",fl->u.reply.status.s);
716 716
 			DBG(" reason:  <%s>\n",fl->u.reply.reason.s);
717
-			flags=HDR_VIA|HDR_VIA2;
717
+			flags=HDR_VIA | HDR_VIA2;
718 718
 			break;
719 719
 		default:
720 720
 			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 355
 	case Via1: Via1_CASE;
356 356
 	case From: From_CASE;
357 357
 	case To12: To12_CASE;
358
-	case CSeq: CSeq_CASE;                                                             
358
+	case CSeq: CSeq_CASE;
359 359
 	case Call: Call_CASE;
360
-        case Cont: Cont_CASE;
361
-	case Rout: Rout_CASE;                                                             
360
+	case Cont: Cont_CASE;
361
+	case Rout: Rout_CASE;
362 362
 	case Max_: Max_CASE;
363 363
 	case Reco: Reco_CASE;
364 364
         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 68
 
69 69
 		/* loop checks */
70 70
 		if (loop_checks) {
71
-			DBG("WARNING: receive_msg: Placeholder for loop check. NOT implemented yet.\n");
71
+			DBG("WARNING: receive_msg: Placeholder for loop check."
72
+				" NOT implemented yet.\n");
72 73
 		}
73 74
 		
74 75
 		/* 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));