Bläddra i källkod

tmx: two helper functions to detect route block type

- t_is_failure_route() - return true if it is a failure_route execution
- t_is_branch_route() - return true if it is a branch_route execution
- useful to check in sub-routes executed from different points of config
Daniel-Constantin Mierla 14 år sedan
förälder
incheckning
0160d59ce4
1 ändrade filer med 27 tillägg och 0 borttagningar
  1. 27 0
      modules_k/tmx/tmx_mod.c

+ 27 - 0
modules_k/tmx/tmx_mod.c

@@ -27,6 +27,7 @@
 #include "../../sr_module.h"
 #include "../../dprint.h"
 #include "../../mod_fix.h"
+#include "../../route.h"
 #include "../../modules/tm/tm_load.h"
 #include "../../lib/kcore/kstats_wrapper.h"
 
@@ -54,6 +55,8 @@ static int t_reply_callid(struct sip_msg* msg, char *cid, char *cseq,
 static int fixup_reply_callid(void** param, int param_no);
 
 static int t_flush_flags(struct sip_msg* msg, char*, char* );
+static int t_is_failure_route(struct sip_msg* msg, char*, char* );
+static int t_is_branch_route(struct sip_msg* msg, char*, char* );
 
 /* statistic variables */
 stat_var *tm_rcv_rpls;
@@ -139,6 +142,10 @@ static cmd_export_t cmds[]={
 		fixup_reply_callid, 0, ANY_ROUTE },
 	{"t_flush_flags",   (cmd_function)t_flush_flags,    0, 0,
 			0, ANY_ROUTE  },
+	{"t_is_failure_route",   (cmd_function)t_is_failure_route,   0, 0,
+			0, ANY_ROUTE  },
+	{"t_is_branch_route",    (cmd_function)t_is_branch_route,    0, 0,
+			0, ANY_ROUTE  },
 	{0,0,0,0,0,0}
 };
 
@@ -419,6 +426,26 @@ static int t_flush_flags(struct sip_msg* msg, char *foo, char *bar)
 	return 1;
 }
 
+/**
+ *
+ */
+static int t_is_failure_route(struct sip_msg* msg, char *foo, char *bar)
+{
+	if(route_type==FAILURE_ROUTE)
+		return 1;
+	return -1;
+}
+
+/**
+ *
+ */
+static int t_is_branch_route(struct sip_msg* msg, char *foo, char *bar)
+{
+	if(route_type==BRANCH_ROUTE)
+		return 1;
+	return -1;
+}
+
 #ifdef STATISTICS
 
 /*** tm stats ***/