Explorar el Código

- added TMCB_E2E_CANCEL_IN callback, called each a CANCEL mathcing an exisitng invite transaction arrives
- fixed has_tran_tmcb typo(?)

Andrei Pelinescu-Onciul hace 18 años
padre
commit
32b645a4d4
Se han modificado 2 ficheros con 25 adiciones y 10 borrados
  1. 11 5
      modules/tm/t_fwd.c
  2. 14 5
      modules/tm/t_hooks.h

+ 11 - 5
modules/tm/t_fwd.c

@@ -63,8 +63,9 @@
  *              stop retr. timers fix on cancel for non-invites     (andrei)
  *  2006-11-20  new_uri is no longer saved/restore across add_uac calls, since
  *              print_uac_request is now uri safe (andrei)
- * 2007-03-15  TMCB_ONSEND hooks added (andrei)
- * 2007-05-02  added t_forward_cancel(unmatched_cancel) (andrei)
+ *  2007-03-15  TMCB_ONSEND hooks added (andrei)
+ *  2007-05-02  added t_forward_cancel(unmatched_cancel) (andrei)
+ *  2007-05-24  added TMCB_E2ECANCEL_IN hook support (andrei)
  */
 
 #include "defs.h"
@@ -82,6 +83,7 @@
 #include "../../action.h"
 #include "../../data_lump.h"
 #include "../../onsend.h"
+#include "../../compiler_opt.h"
 #include "t_funcs.h"
 #include "t_hooks.h"
 #include "t_msgbuilder.h"
@@ -475,6 +477,9 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	cancel_bm=0;
 	lowest_error=0;
 
+	if (unlikely(has_tran_tmcbs(t_invite, TMCB_E2ECANCEL_IN)))
+		run_trans_callbacks( TMCB_E2ECANCEL_IN, t_invite, cancel_msg, 0,
+								cancel_msg->REQ_METHOD);
 	/* first check if there are any branches */
 	if (t_invite->nr_of_outgoings==0){
 		t_invite->flags|=T_CANCELED;
@@ -512,9 +517,10 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 				}
 #ifdef TMCB_ONSEND
 				else{
-					run_onsend_callbacks(TMCB_REQUEST_SENT, 
-											&t_cancel->uac[i].request,
-											TMCB_LOCAL_F);
+					if (unlikely(has_tran_tmcbs(t_cancel, TMCB_REQUEST_SENT)))
+						run_onsend_callbacks(TMCB_REQUEST_SENT, 
+												&t_cancel->uac[i].request,
+												TMCB_LOCAL_F);
 				}
 #endif
 				if (start_retr( &t_cancel->uac[i].request )!=0)

+ 14 - 5
modules/tm/t_hooks.h

@@ -36,6 +36,7 @@
  *               TMCB_LOCAL_RESPONSE_IN (andrei)
  * 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)
  */
 
 
@@ -72,12 +73,13 @@ struct cell;
 #define TMCB_LOCAL_REQUEST_IN_N  13
 #define TMCB_DLG_N              14
 #define TMCB_DESTROY_N          15  /* called on transaction destroy */
+#define TMCB_E2ECANCEL_IN_N     16
 #ifdef TMCB_ONSEND
-#define TMCB_REQUEST_SENT_N     16
-#define TMCB_RESPONSE_SENT_N    17
-#define TMCB_MAX_N              17
+#define TMCB_REQUEST_SENT_N     17
+#define TMCB_RESPONSE_SENT_N    18
+#define TMCB_MAX_N              18
 #else
-#define TMCB_MAX_N              15
+#define TMCB_MAX_N              16
 #endif
 
 
@@ -97,6 +99,7 @@ struct cell;
 #define TMCB_LOCAL_REQUEST_IN (1<<TMCB_LOCAL_REQUEST_IN_N)
 #define TMCB_DLG              (1<<TMCB_DLG_N)
 #define TMCB_DESTROY          (1<<TMCB_DESTROY_N)
+#define TMCB_E2ECANCEL_IN     (1<<TMCB_E2EACK_IN_N)
 #ifdef TMCB_ONSEND
 #define TMCB_REQUEST_SENT      (1<<TMCB_REQUEST_SENT_N)
 #define TMCB_RESPONSE_SENT     (1<<TMCB_RESPONSE_SENT_N)
@@ -216,6 +219,12 @@ struct cell;
  *   quasi-simultaneously if multiple ACK copies arrive in parallel or if
  *   ACKs with different (never seen before) to-tags are received.
  *
+ *  TMCB_E2ECANCEL_IN -- called when a CANCEL belonging to a proxied
+ *  INVITE arrived. Note that if the CANCEL arrives before the INVITE
+ *  (out of order) this callback won't be called.
+ *   The transaction parameter will point to the invite transaction (and 
+ *   not the cancel) and the request parameter to the CANCEL sip msg.
+ *
  *  TMCB_REQUEST_FWDED -- request is being forwarded out. It is
  *  called before a message is forwarded, when the corresponding branch
  *   is created (it's called for each branch) and it is your last
@@ -367,7 +376,7 @@ extern struct tmcb_head_list*  local_req_in_tmcb_hl;
 
 
 #define has_tran_tmcbs(_T_, _types_) \
-	( ((_T_)->tmcb_hl.reg_types)|(_types_) )
+	( ((_T_)->tmcb_hl.reg_types)&(_types_) )
 #define has_reqin_tmcbs() \
 	( req_in_tmcb_hl->first!=0 )
 #define has_local_reqin_tmcbs() \