Module: kamailio
Branch: master
Commit: 15c139831f7135f141f7a32c34ecf24e37bfc3fc
URL:
https://github.com/kamailio/kamailio/commit/15c139831f7135f141f7a32c34ecf24…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-02-18T15:19:20+01:00
Merge pull request #503 from smititelu/SIPPROXY-195
Complete the list of checking routing blocks types with t_is_request_route() config
function
---
Modified: modules/tmx/doc/tmx_admin.xml
Modified: modules/tmx/tmx_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/15c139831f7135f141f7a32c34ecf24…
Patch:
https://github.com/kamailio/kamailio/commit/15c139831f7135f141f7a32c34ecf24…
---
diff --git a/modules/tmx/doc/tmx_admin.xml b/modules/tmx/doc/tmx_admin.xml
index 8c2dcfe..b3a756e 100644
--- a/modules/tmx/doc/tmx_admin.xml
+++ b/modules/tmx/doc/tmx_admin.xml
@@ -301,6 +301,31 @@ route[abc] {
</programlisting>
</example>
</section>
+ <section id="tmx.f.t_is_request_route">
+ <title>
+ <function moreinfo="none">t_is_request_route()</function>
+ </title>
+ <para>
+ Returns true if the top-executed route block is request_route.
+ </para>
+ <para>
+ This function can be used from ANY_ROUTE .
+ </para>
+ <example>
+ <title><function>t_is_request_route</function> usage</title>
+ <programlisting format="linespecific">
+...
+request_route[xyz] {
+ route(abc);
+}
+
+route[abc] {
+ if(t_is_request_route()) { ... }
+}
+...
+</programlisting>
+ </example>
+ </section>
<section id="tmx.f.t_suspend">
<title>
<function moreinfo="none">t_suspend()</function>
diff --git a/modules/tmx/tmx_mod.c b/modules/tmx/tmx_mod.c
index b6a9cce..41f9da2 100644
--- a/modules/tmx/tmx_mod.c
+++ b/modules/tmx/tmx_mod.c
@@ -70,6 +70,7 @@ 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* );
static int t_is_reply_route(struct sip_msg* msg, char*, char*);
+static int t_is_request_route(struct sip_msg* msg, char*, char*);
static int w_t_suspend(struct sip_msg* msg, char*, char*);
static int w_t_continue(struct sip_msg* msg, char *idx, char *lbl, char *rtn);
@@ -191,6 +192,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE },
{"t_is_reply_route", (cmd_function)t_is_reply_route, 0, 0,
0, ANY_ROUTE },
+ {"t_is_request_route", (cmd_function)t_is_request_route, 0, 0,
+ 0, ANY_ROUTE },
{"t_suspend", (cmd_function)w_t_suspend, 0, 0,
0, ANY_ROUTE },
{"t_continue", (cmd_function)w_t_continue, 3,
@@ -566,6 +569,16 @@ static int t_is_reply_route(struct sip_msg* msg, char *foo, char
*bar)
/**
*
*/
+static int t_is_request_route(struct sip_msg* msg, char *foo, char *bar)
+{
+ if(route_type == REQUEST_ROUTE)
+ return 1;
+ return -1;
+}
+
+/**
+ *
+ */
static int w_t_suspend(struct sip_msg* msg, char *p1, char *p2)
{
unsigned int tindex;