Przeglądaj źródła

- expreimental e2eack retransmission callback (called each time a retrans.
of an ACK to a 2xx is received, however like TMCB_E2EACK_IN it will work
only as long as the transaction still exists)

Andrei Pelinescu-Onciul 18 lat temu
rodzic
commit
89f03bcf44
3 zmienionych plików z 25 dodań i 11 usunięć
  1. 10 4
      modules/tm/t_hooks.h
  2. 11 5
      modules/tm/t_lookup.c
  3. 4 2
      modules/tm/t_reply.c

+ 10 - 4
modules/tm/t_hooks.h

@@ -37,6 +37,7 @@
  * 2007-03-23   added TMCB_LOCAL_REQUEST_IN (andrei)
  * 2007-05-16   added TMCB_DESTROY (andrei)
  * 2007-05-24   fixed has_tran_tmcbs() & added TMCB_E2ECANCEL_IN (andrei)
+ * 2007-11-12   added TMCB_E2EACK_RETR_IN (andrei)
  */
 
 
@@ -74,12 +75,13 @@ struct cell;
 #define TMCB_DLG_N              14
 #define TMCB_DESTROY_N          15  /* called on transaction destroy */
 #define TMCB_E2ECANCEL_IN_N     16
+#define TMCB_E2EACK_RETR_IN_N   17
 #ifdef TMCB_ONSEND
-#define TMCB_REQUEST_SENT_N     17
-#define TMCB_RESPONSE_SENT_N    18
-#define TMCB_MAX_N              18
+#define TMCB_REQUEST_SENT_N     18
+#define TMCB_RESPONSE_SENT_N    19
+#define TMCB_MAX_N              19
 #else
-#define TMCB_MAX_N              16
+#define TMCB_MAX_N              17
 #endif
 
 
@@ -100,6 +102,7 @@ struct cell;
 #define TMCB_DLG              (1<<TMCB_DLG_N)
 #define TMCB_DESTROY          (1<<TMCB_DESTROY_N)
 #define TMCB_E2ECANCEL_IN     (1<<TMCB_E2ECANCEL_IN_N)
+#define TMCB_E2EACK_RETR_IN   (1<<TMCB_E2EACK_RETR_IN_N)
 #ifdef TMCB_ONSEND
 #define TMCB_REQUEST_SENT      (1<<TMCB_REQUEST_SENT_N)
 #define TMCB_RESPONSE_SENT     (1<<TMCB_RESPONSE_SENT_N)
@@ -220,6 +223,9 @@ struct cell;
  *   quasi-simultaneously if multiple ACK copies arrive in parallel or if
  *   ACKs with different (never seen before) to-tags are received.
  *
+ *   TMCB_E2EACK_RETR_IN -- like TMCB_E2EACK_IN, but matches retransmissions
+ *   and it's called for every retransmission (but not for the "first" ACK).
+ *
  *  TMCB_E2ECANCEL_IN -- called when a CANCEL for the INVITE transaction
  *  for which the callback was registered arrives.
  *   The transaction parameter will point to the invite transaction (and 

+ 11 - 5
modules/tm/t_lookup.c

@@ -903,7 +903,8 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 		if (unlikely( is_invite(p_cell) && p_msg->REPLY_STATUS>=200 
 			&& p_msg->REPLY_STATUS<300 
 			&& ((!is_local(p_cell) &&
-				has_tran_tmcbs(p_cell, TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) )
+				has_tran_tmcbs(p_cell, 
+					TMCB_RESPONSE_OUT|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN) )
 			|| (is_local(p_cell)&&has_tran_tmcbs(p_cell, TMCB_LOCAL_COMPLETED))
 		)) ) {
 			if (parse_headers(p_msg, HDR_TO_F, 0)==-1) {
@@ -1269,7 +1270,8 @@ int t_newtran( struct sip_msg* p_msg )
 
 	if (lret==-2) { /* was it an e2e ACK ? if so, trigger a callback */
 		/* no callbacks? complete quickly */
-		if (likely( !has_tran_tmcbs(t_ack,TMCB_E2EACK_IN) )) {
+		if (likely( !has_tran_tmcbs(t_ack, 
+						TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN) )) {
 			UNLOCK_HASH(p_msg->hash_index);
 			return 1;
 		} 
@@ -1281,12 +1283,16 @@ int t_newtran( struct sip_msg* p_msg )
 		 * multiple ACK/200s received in parallel), that we do not
 		 * better waste time in locks  */
 		if (unmatched_totag(t_ack, p_msg)) {
-			run_trans_callbacks( TMCB_E2EACK_IN , t_ack, p_msg, 0,
-				-p_msg->REQ_METHOD );
+			if (likely (has_tran_tmcbs(t_ack, TMCB_E2EACK_IN)))
+				run_trans_callbacks( TMCB_E2EACK_IN , t_ack, p_msg, 0,
+										-p_msg->REQ_METHOD );
+		}else if (unlikely(has_tran_tmcbs(t_ack, TMCB_E2EACK_RETR_IN))){
+			run_trans_callbacks( TMCB_E2EACK_RETR_IN , t_ack, p_msg, 0,
+									-p_msg->REQ_METHOD );
 		}
 		UNREF(t_ack);
 		return 1;
-	} 
+	}
 
 
 	/* transaction not found, it's a new request (lret<0, lret!=-2);

+ 4 - 2
modules/tm/t_reply.c

@@ -1477,7 +1477,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 
 		if ( unlikely(is_invite(t) && relayed_msg!=FAKED_REPLY
 		&& relayed_code>=200 && relayed_code < 300
-		&& has_tran_tmcbs( t, TMCB_RESPONSE_OUT|TMCB_E2EACK_IN))) {
+		&& has_tran_tmcbs( t,
+				TMCB_RESPONSE_OUT|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN))) {
 			totag_retr=update_totag_set(t, relayed_msg);
 		}
 	}; /* if relay ... */
@@ -1581,7 +1582,8 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
 		update_reply_stats( winning_code );
 		if (unlikely(is_invite(t) && winning_msg!=FAKED_REPLY
 		&& winning_code>=200 && winning_code <300
-		&& has_tran_tmcbs(t,TMCB_RESPONSE_OUT|TMCB_E2EACK_IN) ))  {
+		&& has_tran_tmcbs(t,
+				TMCB_RESPONSE_OUT|TMCB_E2EACK_IN|TMCB_E2EACK_RETR_IN) ))  {
 			totag_retr=update_totag_set(t, winning_msg);
 		}
 	}