Bläddra i källkod

Update tm module to use and set the global route_type variable.

This patch removes the rmode variable from tm module and replaces it
with the global variable route_type defined in route.h. In addition to
that we replaced MODE_* constants with *_ROUTE (also defined in
route.h).

A variable that was once defined in the tm module is now better moved
to the core, because just the core itself without the tm module loaded
can execute two types of routes, the request route and the global
onreply route (if used).
Jan Janak 16 år sedan
förälder
incheckning
29e00cb942
9 ändrade filer med 52 tillägg och 51 borttagningar
  1. 9 7
      modules/tm/t_fwd.c
  2. 13 13
      modules/tm/t_lookup.c
  3. 11 13
      modules/tm/t_reply.c
  4. 0 3
      modules/tm/t_reply.h
  5. 14 14
      modules/tm/tm.c
  6. 0 1
      modules/tm/tm_load.c
  7. 1 0
      onsend.h
  8. 3 0
      receive.c
  9. 1 0
      route.c

+ 9 - 7
modules/tm/t_fwd.c

@@ -97,6 +97,7 @@
 #include "../../data_lump.h"
 #include "../../data_lump.h"
 #include "../../onsend.h"
 #include "../../onsend.h"
 #include "../../compiler_opt.h"
 #include "../../compiler_opt.h"
+#include "../../route.h"
 #include "t_funcs.h"
 #include "t_funcs.h"
 #include "t_hooks.h"
 #include "t_hooks.h"
 #include "t_msgbuilder.h"
 #include "t_msgbuilder.h"
@@ -126,8 +127,8 @@ void t_on_branch( unsigned int go_to )
 {
 {
 	struct cell *t = get_t();
 	struct cell *t = get_t();
 
 
-       /* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-        * in MODE_REQUEST T will be set only if the transaction was already
+       /* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+        * in REQUEST_ROUTE T will be set only if the transaction was already
         * created; if not -> use the static variable */
         * created; if not -> use the static variable */
 	if (!t || t==T_UNDEFINED ) {
 	if (!t || t==T_UNDEFINED ) {
 		goto_on_branch=go_to;
 		goto_on_branch=go_to;
@@ -191,6 +192,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
 	if (unlikely(branch_route)) {
 	if (unlikely(branch_route)) {
 		reset_static_buffer();
 		reset_static_buffer();
 		     /* run branch_route actions if provided */
 		     /* run branch_route actions if provided */
+		set_route_type(BRANCH_ROUTE);
 		init_run_actions_ctx(&ra_ctx);
 		init_run_actions_ctx(&ra_ctx);
 		if (run_actions(&ra_ctx, branch_rt.rlist[branch_route], i_req) < 0) {
 		if (run_actions(&ra_ctx, branch_rt.rlist[branch_route], i_req) < 0) {
 			LOG(L_ERR, "ERROR: print_uac_request: Error in run_actions\n");
 			LOG(L_ERR, "ERROR: print_uac_request: Error in run_actions\n");
@@ -812,7 +814,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 		 * is called (we are already holding the reply mutex for the cancel
 		 * is called (we are already holding the reply mutex for the cancel
 		 * transaction).
 		 * transaction).
 		 */
 		 */
-		if ((rmode==MODE_ONFAILURE) && (t_cancel==get_t()))
+		if ((is_route_type(FAILURE_ROUTE)) && (t_cancel==get_t()))
 			t_reply_unsafe( t_cancel, cancel_msg, 500, "cancel error");
 			t_reply_unsafe( t_cancel, cancel_msg, 500, "cancel error");
 		else
 		else
 			t_reply( t_cancel, cancel_msg, 500, "cancel error");
 			t_reply( t_cancel, cancel_msg, 500, "cancel error");
@@ -825,7 +827,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 		 * is called (we are already hold the reply mutex for the cancel
 		 * is called (we are already hold the reply mutex for the cancel
 		 * transaction).
 		 * transaction).
 		 */
 		 */
-		if ((rmode==MODE_ONFAILURE) && (t_cancel==get_t()))
+		if ((is_route_type(FAILURE_ROUTE)) && (t_cancel==get_t()))
 			t_reply_unsafe( t_cancel, cancel_msg, 200, CANCELING );
 			t_reply_unsafe( t_cancel, cancel_msg, 200, CANCELING );
 		else
 		else
 			t_reply( t_cancel, cancel_msg, 200, CANCELING );
 			t_reply( t_cancel, cancel_msg, 200, CANCELING );
@@ -838,7 +840,7 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 		 * is called (we are already hold the reply mutex for the cancel
 		 * is called (we are already hold the reply mutex for the cancel
 		 * transaction).
 		 * transaction).
 		 */
 		 */
-		if ((rmode==MODE_ONFAILURE) && (t_cancel==get_t()))
+		if ((is_route_type(FAILURE_ROUTE)) && (t_cancel==get_t()))
 			t_reply_unsafe( t_cancel, cancel_msg, 200, CANCEL_DONE );
 			t_reply_unsafe( t_cancel, cancel_msg, 200, CANCEL_DONE );
 		else
 		else
 			t_reply( t_cancel, cancel_msg, 200, CANCEL_DONE );
 			t_reply( t_cancel, cancel_msg, 200, CANCEL_DONE );
@@ -1046,7 +1048,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 	if (first_branch==0) {
 	if (first_branch==0) {
 #ifdef POSTPONE_MSG_CLONING
 #ifdef POSTPONE_MSG_CLONING
 		/* update the shmem-ized msg with the lumps */
 		/* update the shmem-ized msg with the lumps */
-		if ((rmode == MODE_REQUEST) &&
+		if ((is_route_type(REQUEST_ROUTE)) &&
 			save_msg_lumps(t->uas.request, p_msg)) {
 			save_msg_lumps(t->uas.request, p_msg)) {
 				LOG(L_ERR, "ERROR: t_forward_nonack: "
 				LOG(L_ERR, "ERROR: t_forward_nonack: "
 					"failed to save the message lumps\n");
 					"failed to save the message lumps\n");
@@ -1102,7 +1104,7 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 	ser_error=0; /* clear branch adding errors */
 	ser_error=0; /* clear branch adding errors */
 	/* send them out now */
 	/* send them out now */
 	success_branch=0;
 	success_branch=0;
-	lock_replies= ! ((rmode==MODE_ONFAILURE) && (t==get_t()));
+	lock_replies= ! ((is_route_type(FAILURE_ROUTE)) && (t==get_t()));
 	for (i=first_branch; i<t->nr_of_outgoings; i++) {
 	for (i=first_branch; i<t->nr_of_outgoings; i++) {
 		if (added_branches & (1<<i)) {
 		if (added_branches & (1<<i)) {
 			
 			

+ 13 - 13
modules/tm/t_lookup.c

@@ -1454,7 +1454,7 @@ int t_unref( struct sip_msg* p_msg  )
 		kr=get_kr();
 		kr=get_kr();
 		if (unlikely(kr == REQ_ERR_DELAYED)){
 		if (unlikely(kr == REQ_ERR_DELAYED)){
 			DBG("t_unref: delayed error reply generation(%d)\n", tm_error);
 			DBG("t_unref: delayed error reply generation(%d)\n", tm_error);
-			if (unlikely(rmode==MODE_ONFAILURE)){
+			if (unlikely(is_route_type(FAILURE_ROUTE))){
 				BUG("tm: t_unref: called w/ kr=REQ_ERR_DELAYED in failure"
 				BUG("tm: t_unref: called w/ kr=REQ_ERR_DELAYED in failure"
 						" route for %p\n", T);
 						" route for %p\n", T);
 			}else if (unlikely( kill_transaction(T, tm_error)<=0 )){
 			}else if (unlikely( kill_transaction(T, tm_error)<=0 )){
@@ -1675,8 +1675,8 @@ int t_set_fr(struct sip_msg* msg, unsigned int fr_inv_to, unsigned int fr_to)
 	}
 	}
 	
 	
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		set_msgid_val(user_fr_inv_timeout, msg->id, int, (int)fr_inv);
 		set_msgid_val(user_fr_inv_timeout, msg->id, int, (int)fr_inv);
@@ -1693,8 +1693,8 @@ int t_reset_fr()
 	struct cell *t;
 	struct cell *t;
 
 
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		memset(&user_fr_inv_timeout, 0, sizeof(user_fr_inv_timeout));
 		memset(&user_fr_inv_timeout, 0, sizeof(user_fr_inv_timeout));
@@ -1739,8 +1739,8 @@ int t_set_retr(struct sip_msg* msg, unsigned int t1_to, unsigned int t2_to)
 	} 
 	} 
 	
 	
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		set_msgid_val(user_rt_t1_timeout, msg->id, int, (int)retr_t1);
 		set_msgid_val(user_rt_t1_timeout, msg->id, int, (int)retr_t1);
@@ -1757,8 +1757,8 @@ int t_reset_retr()
 	struct cell *t;
 	struct cell *t;
 
 
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		memset(&user_rt_t1_timeout, 0, sizeof(user_rt_t1_timeout));
 		memset(&user_rt_t1_timeout, 0, sizeof(user_rt_t1_timeout));
@@ -1799,8 +1799,8 @@ int t_set_max_lifetime(struct sip_msg* msg,
 	}
 	}
 	
 	
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		set_msgid_val(user_noninv_max_lifetime, msg->id, int,
 		set_msgid_val(user_noninv_max_lifetime, msg->id, int,
@@ -1820,8 +1820,8 @@ int t_reset_max_lifetime()
 	struct cell *t;
 	struct cell *t;
 
 
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		memset(&user_inv_max_lifetime, 0, sizeof(user_inv_max_lifetime));
 		memset(&user_inv_max_lifetime, 0, sizeof(user_inv_max_lifetime));

+ 11 - 13
modules/tm/t_reply.c

@@ -108,6 +108,7 @@
 #include "../../action.h"
 #include "../../action.h"
 #include "../../dset.h"
 #include "../../dset.h"
 #include "../../tags.h"
 #include "../../tags.h"
+#include "../../route.h"
 #include "../../data_lump.h"
 #include "../../data_lump.h"
 #include "../../data_lump_rpl.h"
 #include "../../data_lump_rpl.h"
 #include "../../usr_avp.h"
 #include "../../usr_avp.h"
@@ -137,9 +138,6 @@
 #include "uac.h"
 #include "uac.h"
 
 
 
 
-/* are we processing original or shmemed request ? */
-enum route_mode rmode=MODE_REQUEST;
-
 /* private place where we create to-tags for replies */
 /* private place where we create to-tags for replies */
 /* janakj: made public, I need to access this value to store it in dialogs */
 /* janakj: made public, I need to access this value to store it in dialogs */
 char tm_tags[TOTAG_VALUE_LEN];
 char tm_tags[TOTAG_VALUE_LEN];
@@ -187,8 +185,8 @@ void t_on_negative( unsigned int go_to )
 {
 {
 	struct cell *t = get_t();
 	struct cell *t = get_t();
 
 
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variable */
 	 * created; if not -> use the static variable */
 	if (!t || t==T_UNDEFINED )
 	if (!t || t==T_UNDEFINED )
 		goto_on_negative=go_to;
 		goto_on_negative=go_to;
@@ -201,8 +199,8 @@ void t_on_reply( unsigned int go_to )
 {
 {
 	struct cell *t = get_t();
 	struct cell *t = get_t();
 
 
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variable */
 	 * created; if not -> use the static variable */
 	if (!t || t==T_UNDEFINED )
 	if (!t || t==T_UNDEFINED )
 		goto_on_reply=go_to;
 		goto_on_reply=go_to;
@@ -659,7 +657,7 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg,
  * the env. will be restore to original */
  * the env. will be restore to original */
 void faked_env( struct cell *t,struct sip_msg *msg)
 void faked_env( struct cell *t,struct sip_msg *msg)
 {
 {
-	static enum route_mode backup_mode;
+	static int backup_route_type;
 	static struct cell *backup_t;
 	static struct cell *backup_t;
 	static unsigned int backup_msgid;
 	static unsigned int backup_msgid;
 	static avp_list_t* backup_user_from, *backup_user_to;
 	static avp_list_t* backup_user_from, *backup_user_to;
@@ -669,11 +667,11 @@ void faked_env( struct cell *t,struct sip_msg *msg)
 
 
 	if (msg) {
 	if (msg) {
 		/* remember we are back in request processing, but process
 		/* remember we are back in request processing, but process
-		 * a shmem-ed replica of the request; advertise it in rmode;
+		 * a shmem-ed replica of the request; advertise it in route type;
 		 * for example t_reply needs to know that
 		 * for example t_reply needs to know that
 		 */
 		 */
-		backup_mode=rmode;
-		rmode=MODE_ONFAILURE;
+		backup_route_type=route_type;
+		set_route_type(FAILURE_ROUTE);
 		/* also, tm actions look in beginning whether transaction is
 		/* also, tm actions look in beginning whether transaction is
 		 * set -- whether we are called from a reply-processing
 		 * set -- whether we are called from a reply-processing
 		 * or a timer process, we need to set current transaction;
 		 * or a timer process, we need to set current transaction;
@@ -701,7 +699,7 @@ void faked_env( struct cell *t,struct sip_msg *msg)
 		/* restore original environment */
 		/* restore original environment */
 		set_t(backup_t);
 		set_t(backup_t);
 		global_msg_id=backup_msgid;
 		global_msg_id=backup_msgid;
-		rmode=backup_mode;
+		set_route_type(backup_route_type);
 		/* restore original avp list */
 		/* restore original avp list */
 		set_avp_list(AVP_TRACK_FROM | AVP_CLASS_USER, backup_user_from );
 		set_avp_list(AVP_TRACK_FROM | AVP_CLASS_USER, backup_user_from );
 		set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, backup_user_to );
 		set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, backup_user_to );
@@ -1932,7 +1930,7 @@ int reply_received( struct sip_msg  *p_msg )
 	}
 	}
 	/* processing of on_reply block */
 	/* processing of on_reply block */
 	if (t->on_reply) {
 	if (t->on_reply) {
-		rmode=MODE_ONREPLY;
+		set_route_type(ONREPLY_ROUTE);
 		/* transfer transaction flag to message context */
 		/* transfer transaction flag to message context */
 		if (t->uas.request) p_msg->flags=t->uas.request->flags;
 		if (t->uas.request) p_msg->flags=t->uas.request->flags;
 		/* set the as avp_list the one from transaction */
 		/* set the as avp_list the one from transaction */

+ 0 - 3
modules/tm/t_reply.h

@@ -58,9 +58,6 @@ extern char *tm_tag_suffix;
 
 
 extern int goto_on_sl_reply;
 extern int goto_on_sl_reply;
 
 
-enum route_mode { MODE_REQUEST=1, MODE_ONREPLY, MODE_ONFAILURE };
-extern enum route_mode rmode;
-
 /* has this to-tag been never seen in previous 200/INVs? */
 /* has this to-tag been never seen in previous 200/INVs? */
 int unmatched_totag(struct cell *t, struct sip_msg *ack);
 int unmatched_totag(struct cell *t, struct sip_msg *ack);
 
 

+ 14 - 14
modules/tm/tm.c

@@ -642,7 +642,7 @@ static int script_init( struct sip_msg *foo, void *bar)
 	reset_kr(0);
 	reset_kr(0);
 	/* set request mode so that multiple-mode actions know
 	/* set request mode so that multiple-mode actions know
 	 * how to behave */
 	 * how to behave */
-	rmode=MODE_REQUEST;
+	set_route_type(REQUEST_ROUTE);
 
 
 #ifdef POSTPONE_MSG_CLONING
 #ifdef POSTPONE_MSG_CLONING
 	lumps_are_cloned = 0;
 	lumps_are_cloned = 0;
@@ -835,20 +835,20 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 		break;
 		break;
 	}
 	}
 	
 	
-	switch(rmode) {
-	case MODE_REQUEST:
+	switch(route_type) {
+	case REQUEST_ROUTE:
 		/* use the status of the last sent reply */
 		/* use the status of the last sent reply */
 		status = int2str( t->uas.status, 0);
 		status = int2str( t->uas.status, 0);
 		break;
 		break;
 		
 		
-	case MODE_ONREPLY:
+	case ONREPLY_ROUTE:
 		/* use the status of the current reply */
 		/* use the status of the current reply */
 		status = msg->first_line.u.reply.status.s;
 		status = msg->first_line.u.reply.status.s;
 		backup = status[msg->first_line.u.reply.status.len];
 		backup = status[msg->first_line.u.reply.status.len];
 		status[msg->first_line.u.reply.status.len] = 0;
 		status[msg->first_line.u.reply.status.len] = 0;
 		break;
 		break;
 
 
-	case MODE_ONFAILURE:
+	case FAILURE_ROUTE:
 		/* use the status of the winning reply */
 		/* use the status of the winning reply */
 		ret = t_pick_branch( -1, 0, t, &lowest_status);
 		ret = t_pick_branch( -1, 0, t, &lowest_status);
 		if (ret == -1) {
 		if (ret == -1) {
@@ -861,14 +861,14 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 		}
 		}
 		if (ret < 0) {
 		if (ret < 0) {
 			LOG(L_CRIT,"BUG:t_check_status: t_pick_branch failed to get "
 			LOG(L_CRIT,"BUG:t_check_status: t_pick_branch failed to get "
-				" a final response in MODE_ONFAILURE\n");
+				" a final response in FAILURE_ROUTE\n");
 			goto error;
 			goto error;
 		}
 		}
 		status = int2str( lowest_status , 0);
 		status = int2str( lowest_status , 0);
 		break;
 		break;
 
 
 	default:
 	default:
-		LOG(L_ERR,"ERROR:t_check_status: unsupported mode %d\n",rmode);
+		LOG(L_ERR,"ERROR:t_check_status: unsupported route type %d\n",route_type);
 		goto error;
 		goto error;
 	}
 	}
 
 
@@ -1143,10 +1143,10 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
 	 * the safe version would lead to a deadlock
 	 * the safe version would lead to a deadlock
 	 */
 	 */
 	 
 	 
-	if (rmode==MODE_ONFAILURE) {
+	if (is_route_type(FAILURE_ROUTE)) {
 		DBG("DEBUG: t_reply_unsafe called from w_t_reply\n");
 		DBG("DEBUG: t_reply_unsafe called from w_t_reply\n");
 		ret = t_reply_unsafe(t, msg, code, r);
 		ret = t_reply_unsafe(t, msg, code, r);
-	} else if (rmode==MODE_REQUEST) {
+	} else if (is_route_type(REQUEST_ROUTE)) {
 		ret = t_reply( t, msg, code, r);
 		ret = t_reply( t, msg, code, r);
 	} else {
 	} else {
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
@@ -1233,7 +1233,7 @@ inline static int _w_t_relay_to(struct sip_msg  *p_msg ,
 {
 {
 	struct cell *t;
 	struct cell *t;
 
 
-	if (rmode==MODE_ONFAILURE) {
+	if (is_route_type(FAILURE_ROUTE)) {
 		t=get_t();
 		t=get_t();
 		if (!t || t==T_UNDEFINED) {
 		if (!t || t==T_UNDEFINED) {
 			LOG(L_CRIT, "BUG: w_t_relay_to: undefined T\n");
 			LOG(L_CRIT, "BUG: w_t_relay_to: undefined T\n");
@@ -1248,10 +1248,10 @@ inline static int _w_t_relay_to(struct sip_msg  *p_msg ,
 		}
 		}
 		return 1;
 		return 1;
 	}
 	}
-	if (rmode==MODE_REQUEST)
+	if (is_route_type(REQUEST_ROUTE))
 		return t_relay_to( p_msg, proxy, force_proto,
 		return t_relay_to( p_msg, proxy, force_proto,
 			0 /* no replication */ );
 			0 /* no replication */ );
-	LOG(L_CRIT, "ERROR: w_t_relay_to: unsupported mode: %d\n", rmode);
+	LOG(L_CRIT, "ERROR: w_t_relay_to: unsupported route type: %d\n", route_type);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1517,8 +1517,8 @@ static int t_set_auto_inv_100(struct sip_msg* msg, char* p1, char* p2)
 	
 	
 	if (get_int_fparam(&state, msg, (fparam_t*)p1) < 0) return -1;
 	if (get_int_fparam(&state, msg, (fparam_t*)p1) < 0) return -1;
 	t=get_t();
 	t=get_t();
-	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
-	 * in MODE_REQUEST T will be set only if the transaction was already
+	/* in REPLY_ROUTE and FAILURE_ROUTE T will be set to current transaction;
+	 * in REQUEST_ROUTE T will be set only if the transaction was already
 	 * created; if not -> use the static variables */
 	 * created; if not -> use the static variables */
 	if (!t || t==T_UNDEFINED ){
 	if (!t || t==T_UNDEFINED ){
 		if (state)
 		if (state)

+ 0 - 1
modules/tm/tm_load.c

@@ -199,7 +199,6 @@ int load_tm( struct tm_binds *tmb)
 	tmb->prepare_request_within = prepare_req_within;
 	tmb->prepare_request_within = prepare_req_within;
 	tmb->send_prepared_request = send_prepared_request;
 	tmb->send_prepared_request = send_prepared_request;
 	
 	
-	tmb->route_mode = &rmode;
 #ifdef DIALOG_CALLBACKS
 #ifdef DIALOG_CALLBACKS
 	tmb->register_new_dlg_cb=register_new_dlg_cb;
 	tmb->register_new_dlg_cb=register_new_dlg_cb;
 	tmb->register_dlg_tmcb=register_dlg_tmcb;
 	tmb->register_dlg_tmcb=register_dlg_tmcb;

+ 1 - 0
onsend.h

@@ -68,6 +68,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
 		onsnd_info.buf=buf;
 		onsnd_info.buf=buf;
 		onsnd_info.len=len;
 		onsnd_info.len=len;
 		p_onsend=&onsnd_info;
 		p_onsend=&onsnd_info;
+		set_route_type(ONSEND_ROUTE);
 		init_run_actions_ctx(&ra_ctx);
 		init_run_actions_ctx(&ra_ctx);
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
 		p_onsend=0; /* reset it */
 		p_onsend=0; /* reset it */

+ 3 - 0
receive.c

@@ -169,6 +169,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		if (exec_pre_req_cb(msg)==0 )
 		if (exec_pre_req_cb(msg)==0 )
 			goto end; /* drop the request */
 			goto end; /* drop the request */
 
 
+		set_route_type(REQUEST_ROUTE);
 		/* exec the routing script */
 		/* exec the routing script */
 		init_run_actions_ctx(&ra_ctx);
 		init_run_actions_ctx(&ra_ctx);
 		if (run_actions(&ra_ctx, main_rt.rlist[DEFAULT_RT], msg)<0){
 		if (run_actions(&ra_ctx, main_rt.rlist[DEFAULT_RT], msg)<0){
@@ -210,8 +211,10 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		*/
 		*/
 		if (exec_pre_rpl_cb(msg)==0 )
 		if (exec_pre_rpl_cb(msg)==0 )
 			goto end; /* drop the request */
 			goto end; /* drop the request */
+
 		/* exec the onreply routing script */
 		/* exec the onreply routing script */
 		if (onreply_rt.rlist[DEFAULT_RT]){
 		if (onreply_rt.rlist[DEFAULT_RT]){
+			set_route_type(ONREPLY_ROUTE);
 			init_run_actions_ctx(&ra_ctx);
 			init_run_actions_ctx(&ra_ctx);
 			ret=run_actions(&ra_ctx, onreply_rt.rlist[DEFAULT_RT], msg);
 			ret=run_actions(&ra_ctx, onreply_rt.rlist[DEFAULT_RT], msg);
 			if (ret<0){
 			if (ret<0){

+ 1 - 0
route.c

@@ -93,6 +93,7 @@ struct route_list failure_rt;
 struct route_list branch_rt;
 struct route_list branch_rt;
 struct route_list onsend_rt;
 struct route_list onsend_rt;
 
 
+int route_type = REQUEST_ROUTE;
 
 
 /** script optimization level, useful for debugging.
 /** script optimization level, useful for debugging.
  *  0 - no optimization
  *  0 - no optimization