瀏覽代碼

- added callback for retransmitted request (TMCB_REQ_RETR_IN), acks to
negative replies (TMCB_NEG_ACK_IN) and replies for local transactions
(TMCB_LOCAL_RESPONSE_IN)

Andrei Pelinescu-Onciul 18 年之前
父節點
當前提交
1b8b28997c
共有 2 個文件被更改,包括 33 次插入8 次删除
  1. 23 7
      modules/tm/t_hooks.h
  2. 10 1
      modules/tm/t_lookup.c

+ 23 - 7
modules/tm/t_hooks.h

@@ -32,6 +32,8 @@
  *              multiple events per callback added; single list per
  *              transaction for all its callbacks (bogdan)
  * 2007-03-14   added *_SENT callbacks (andrei)
+ * 2007-03-17   added TMCB_NEG_ACK_IN, TMCB_REQ_RETR_IN & 
+ *               TMCB_LOCAL_RESPONSE_IN (andrei)
  */
 
 
@@ -62,12 +64,15 @@ struct cell;
 #define TMCB_RESPONSE_OUT_N     7
 #define TMCB_LOCAL_COMPLETED_N  8
 #define TMCB_LOCAL_RESPONSE_OUT_N 9
+#define TMCB_ACK_NEG_IN_N       10
+#define TMCB_REQ_RETR_IN_N      11
+#define TMCB_LOCAL_RESPONSE_IN_N 12
 #ifdef TMCB_ONSEND
-#define TMCB_REQUEST_SENT_N     10
-#define TMCB_RESPONSE_SENT_N    11
-#define TMCB_MAX_N              11
+#define TMCB_REQUEST_SENT_N     13
+#define TMCB_RESPONSE_SENT_N    14
+#define TMCB_MAX_N              14
 #else
-#define TMCB_MAX_N              9
+#define TMCB_MAX_N              12
 #endif
 
 #define TMCB_REQUEST_IN       (1<<TMCB_REQUEST_IN_N)
@@ -80,6 +85,9 @@ struct cell;
 #define TMCB_RESPONSE_OUT     (1<<TMCB_RESPONSE_OUT_N)
 #define TMCB_LOCAL_COMPLETED  (1<<TMCB_LOCAL_COMPLETED_N)
 #define TMCB_LOCAL_RESPONSE_OUT (1<<TMCB_LOCAL_RESPONSE_OUT_N)
+#define TMCB_ACK_NEG_IN       (1<<TMCB_ACK_NEG_IN_N)
+#define TMCB_REQ_RETR_IN      (1<<TMCB_REQ_RETR_IN_N)
+#define TMCB_LOCAL_RESPONSE_IN (1<<TMCB_LOCAL_RESPONSE_IN_N)
 #ifdef TMCB_ONSEND
 #define TMCB_REQUEST_SENT      (1<<TMCB_REQUEST_SENT_N)
 #define TMCB_RESPONSE_SENT     (1<<TMCB_RESPONSE_SENT_N)
@@ -219,7 +227,17 @@ struct cell;
  *  called multiple time quasi-simultaneously. No lock is held.
  *  It's unsafe to register other TMCB callbacks.
  *
- *  TMCB_ONSEND callbacks
+ *  TMCB_NEG_ACK_IN -- an ACK to a negative reply was received, thus ending
+ *  the transaction (this happens only when the final reply sent by tm is 
+ *  negative). The callback might be called simultaneously. No lock is held.
+ *
+ *  TMCB_REQ_RETR_IN -- a retransmitted request was received. This callback
+ *   might be called simultaneously. No lock is held.
+ *
+ * TMCB_LOCAL_RESPONSE_IN -- a brand-new reply was received which matches
+ * an existing local transaction (like TMCB_RESPONSE_IN but for local 
+ * transactions). It may or may not be a retransmission.
+ * No lock is held here (yet). It's unsafe to register other TMCB callbacks.
  *
  *  All of the following callbacks are called immediately after or before 
  *  sending a message. All of them are read-only (no change can be made to
@@ -325,8 +343,6 @@ void destroy_tmcb_lists();
 /* register a callback for several types of events */
 int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
 											transaction_cb f, void *param );
-//int register_tmcb( struct sip_msg* p_msg, int types, transaction_cb f,
-//																void *param );
 
 /* inserts a callback into the a callback list */
 int insert_tmcb(struct tmcb_head_list *cb_list, int types,

+ 10 - 1
modules/tm/t_lookup.c

@@ -87,7 +87,9 @@
  * 2006-11-10  a valid msg->hash_index is now marked by FL_HASH_INDEX in 
  *              msg_flags
  *             t_lookupOriginalT computes the hash_index by itself  if 
-*               needed (andrei)
+ *               needed (andrei)
+ * 2007-03-17  added callbacks for retransmitted request, ack to negative 
+ *              replies and replies to local transactions (andrei)
  */
 
 #include "defs.h"
@@ -897,6 +899,9 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 		if (!is_local(p_cell)) {
 			run_trans_callbacks( TMCB_RESPONSE_IN, T, T->uas.request, p_msg,
 				p_msg->REPLY_STATUS);
+		}else{
+			run_trans_callbacks( TMCB_LOCAL_RESPONSE_IN, T, T->uas.request, 
+					p_msg, p_msg->REPLY_STATUS);
 		}
 		return 1;
 	} /* for cycle */
@@ -1193,8 +1198,12 @@ int t_newtran( struct sip_msg* p_msg )
 	/* transaction found, it's a retransmission  */
 	if (lret>0) {
 		if (p_msg->REQ_METHOD==METHOD_ACK) {
+			run_trans_callbacks(TMCB_ACK_NEG_IN, T, p_msg, 0, 
+									p_msg->REQ_METHOD);
 			t_release_transaction(T);
 		} else {
+			run_trans_callbacks(TMCB_REQ_RETR_IN, T, p_msg, 0,
+									p_msg->REQ_METHOD);
 			t_retransmit_reply(T);
 		}
 		/* things are done -- return from script */