Browse code

ACK retransmission

Bogdan-Andrei Iancu authored on 23/01/2002 13:23:21
Showing 3 changed files
... ...
@@ -53,7 +53,7 @@ ARCH = $(shell uname -s)
53 53
 
54 54
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
55 55
 	 -DDNS_IP_HACK  -DPKG_MALLOC -DSHM_MEM  -DSHM_MMAP \
56
-	-DBRUT_HACK -DVQ_MALLOC 
56
+	 -DVQ_MALLOC 
57 57
 	#-DEXTRA_DEBUG -DBRUT_HACK \
58 58
 	#-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
59 59
 	  #-DDBG_QM_MALLOC #-DVQ_MALLOC #-DNO_DEBUG
... ...
@@ -174,8 +174,8 @@ struct sip_msg* sip_msg_cloner_1( struct sip_msg *org_msg )
174 174
 	    case HDR_CONTACT :
175 175
 		new_msg->contact = new_hdr;
176 176
 		break;
177
-	    case HDR_MAXFORWARD :
178
-		new_msg->maxforward = new_hdr;
177
+	    case HDR_MAXFORWARDS :
178
+		new_msg->maxforwards = new_hdr;
179 179
 		break;
180 180
 	    case HDR_ROUTE :
181 181
 		new_msg->route = new_hdr;
... ...
@@ -399,14 +399,13 @@ int t_on_reply_received( struct sip_msg  *p_msg )
399 399
 
400 400
 	/* we were not able to process the response due to memory
401 401
 	   shortage; simply drop it; hopefuly, we will have more
402
-           memory on the next try
403
-	*/
402
+	memory on the next try */
404 403
 	msg_status=p_msg->REPLY_STATUS;
405 404
 	msg_class=REPLY_CLASS(p_msg);
406 405
 	relay = t_should_relay_response( T , msg_status );
406
+
407 407
 	if (relay && !(clone=sip_msg_cloner( p_msg ))) {
408 408
 		T_UNREF( T );
409
-		/* t_unref( p_msg, NULL, NULL ); */
410 409
 		return 0;
411 410
 	}
412 411
 
... ...
@@ -418,7 +417,7 @@ int t_on_reply_received( struct sip_msg  *p_msg )
418 417
 	/* stop final response timer only if I got a final response */
419 418
 	if ( msg_class>1 )
420 419
 		reset_timer( hash_table, &(rb->fr_timer));
421
-   	/* if a got the first prov. response for an INVITE ->
420
+	/* if a got the first prov. response for an INVITE ->
422 421
 	   change FR_TIME_OUT to INV_FR_TIME_UT */
423 422
 	if (!T->inbound_response[branch] && msg_class==1
424 423
 	 && T->inbound_request->REQ_METHOD==METHOD_INVITE )
... ...
@@ -428,20 +427,20 @@ int t_on_reply_received( struct sip_msg  *p_msg )
428 427
 	if ( T->inbound_request->REQ_METHOD==METHOD_INVITE )
429 428
 	{
430 429
 		if ( T->outbound_request_isACKed[branch] )
431
-		{   /*retransmit*/
430
+		{	/*retransmit the last ACK*/
431
+			DBG("DEBUG: t_on_reply_received: retransmitting ACK!!!!!!!!!!!!!!!!!!+!+!+!!\n");
432 432
 			SEND_BUFFER( T->outbound_request[branch] );
433 433
 		} else if (msg_class>2 ) {   /*on a non-200 reply to INVITE*/
434
-           		DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE: send ACK\n");
435
-           		if ( t_build_and_send_ACK( T , branch , p_msg )==-1)
436
-           		{
437
-               			LOG( L_ERR , "ERROR: t_on_reply_received: unable to send ACK\n" );
438
-						if (clone ) sip_msg_free( clone );
439
-						/* t_unref( p_msg, NULL, NULL ); */
440
-						T_UNREF( T );
441
-               			return 0;
442
-           		}
443
-       		}
444
-   	}
434
+			DBG("DEBUG: t_on_reply_received: >=3xx reply to INVITE: send ACK\n");
435
+			if ( t_build_and_send_ACK( T , branch , p_msg )==-1)
436
+			{
437
+				LOG( L_ERR , "ERROR: t_on_reply_received: unable to send ACK\n" );
438
+				if (clone ) sip_msg_free( clone );
439
+				T_UNREF( T );
440
+				return 0;
441
+			}
442
+		}
443
+	}
445 444
 
446 445
 #	ifdef FORKING
447 446
    	/* skipped for the moment*/
... ...
@@ -449,7 +448,6 @@ int t_on_reply_received( struct sip_msg  *p_msg )
449 448
 
450 449
 	/* if the incoming response code is not reliable->drop it*/
451 450
 	if (!relay) {
452
-		/* t_unref( p_msg, NULL, NULL ); */
453 451
 		T_UNREF( T );
454 452
 		return 0;
455 453
 	}
... ...
@@ -647,12 +645,6 @@ int t_send_reply(  struct sip_msg* p_msg , unsigned int code , char * text )
647 645
 		return -1;
648 646
 	}
649 647
 
650
-	/* if the incoming response code is not reliable->drop it*/
651
-	/*
652
-	if ( !t_should_relay_response( T , code ) )
653
-		return 1;
654
-	*/
655
-
656 648
 	rb = & T->outbound_response;
657 649
 	if (!rb->retr_buffer) {
658 650
 		/* initialize retransmission structure */
... ...
@@ -900,37 +892,6 @@ int t_should_relay_response( struct cell *Trans , int new_code )
900 892
 	}
901 893
 	DBG("DBG: t_should_relay: not to be relayed\n");
902 894
 	return 0;
903
-
904
-
905
-/*
906
-   // have we already sent something?
907
-   if ( !Trans->outbound_response.retr_buffer )
908
-   {
909
-      DBG("DEBUG: t_should_relay_response: %d response relayed (no previous response sent)\n",new_code);
910
-      return 1;
911
-   }
912
-
913
-   // have we sent a final response?
914
-   if ( (T_code/100)>1 )
915
-   {  //final response was sent
916
-      if ( new_code==200 && Trans->inbound_request->REQ_METHOD==METHOD_INVITE )
917
-      {
918
-         DBG("DEBUG: t_should_relay_response: %d response relayed (final satus, but 200 to an INVITE)\n",new_code);
919
-         return 0;
920
-      }
921
-   }
922
-   else
923
-   { // provisional response was sent
924
-      if ( new_code>T_code )
925
-      {
926
-         DBG("DEBUG: t_should_relay_response: %d response relayed (higher provisional response)\n",new_code);
927
-         return 1;
928
-      }
929
-   }
930
-
931
-   DBG("DEBUG: t_should_relay_response: %d response not relayed\n",new_code);
932
-   return 0;
933
-*/
934 895
 }
935 896
 
936 897
 
... ...
@@ -1084,7 +1045,20 @@ int t_build_and_send_ACK( struct cell *Trans, unsigned int branch, struct sip_ms
1084 1045
     p += CRLF_LEN;
1085 1046
 
1086 1047
    /* sends the ACK message to the same destination as the INVITE */
1087
-   udp_send( ack_buf, p-ack_buf, (struct sockaddr*)&(T->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
1048
+   udp_send( ack_buf, p-ack_buf, (struct sockaddr*)&(Trans->outbound_request[branch]->to) , sizeof(struct sockaddr_in) );
1049
+
1050
+   /* registering the ACK as received, processed and send */
1051
+   Trans->outbound_request_isACKed[branch] = 1;
1052
+   if ( (Trans->outbound_request[branch]->retr_buffer =
1053
+      (char*)shm_resize( Trans->outbound_request[branch]->retr_buffer, p-ack_buf) ))
1054
+   {
1055
+       memcpy ( Trans->outbound_request[branch]->retr_buffer , ack_buf , p-ack_buf);
1056
+       Trans->outbound_request[branch]->bufflen = p-ack_buf;
1057
+   }
1058
+   else
1059
+       Trans->outbound_request[branch]->bufflen = 0;
1060
+
1061
+
1088 1062
    DBG("DEBUG: t_build_and_send_ACK: ACK sent\n");
1089 1063
 
1090 1064
    /* free mem*/