瀏覽代碼

modules_k/tmx: add t_is_reply_route()

Function to determine if the top executed route block is a reply.
In line with t_is_failure_route() and t_is_branch_route().
Alex Hermann 14 年之前
父節點
當前提交
d2bdfd3256
共有 3 個文件被更改,包括 71 次插入12 次删除
  1. 33 12
      modules_k/tmx/README
  2. 25 0
      modules_k/tmx/doc/tmx_admin.xml
  3. 13 0
      modules_k/tmx/tmx_mod.c

+ 33 - 12
modules_k/tmx/README

@@ -32,8 +32,9 @@ Daniel-Constantin Mierla
               3.4. t_flush_flags()
               3.5. t_is_failure_route()
               3.6. t_is_branch_route()
-              3.7. t_suspend()
-              3.8. t_continue(tindex, tlabel, rtname)
+              3.7. t_is_reply_route()
+              3.8. t_suspend()
+              3.9. t_continue(tindex, tlabel, rtname)
 
         4. Exported pseudo-variables
         5. MI Commands
@@ -66,8 +67,9 @@ Daniel-Constantin Mierla
    1.4. t_flush_flags usage
    1.5. t_is_failure_route usage
    1.6. t_is_branch_route usage
-   1.7. t_suspend usage
-   1.8. t_continue usage
+   1.7. t_is_reply_route usage
+   1.8. t_suspend usage
+   1.9. t_continue usage
 
 Chapter 1. Admin Guide
 
@@ -87,8 +89,9 @@ Chapter 1. Admin Guide
         3.4. t_flush_flags()
         3.5. t_is_failure_route()
         3.6. t_is_branch_route()
-        3.7. t_suspend()
-        3.8. t_continue(tindex, tlabel, rtname)
+        3.7. t_is_reply_route()
+        3.8. t_suspend()
+        3.9. t_continue(tindex, tlabel, rtname)
 
    4. Exported pseudo-variables
    5. MI Commands
@@ -144,8 +147,9 @@ Chapter 1. Admin Guide
    3.4. t_flush_flags()
    3.5. t_is_failure_route()
    3.6. t_is_branch_route()
-   3.7. t_suspend()
-   3.8. t_continue(tindex, tlabel, rtname)
+   3.7. t_is_reply_route()
+   3.8. t_suspend()
+   3.9. t_continue(tindex, tlabel, rtname)
 
 3.1.  t_cancel_branches(which)
 
@@ -251,7 +255,24 @@ route[abc] {
 }
 ...
 
-3.7.  t_suspend()
+3.7.  t_is_reply_route()
+
+   Returns true if the top-executed route block is reply_route.
+
+   This function can be used from ANY_ROUTE .
+
+   Example 1.7. t_is_reply_route usage
+...
+reply_route[xyz] {
+    route(abc);
+}
+
+route[abc] {
+    if(t_is_reply_route()) { ... }
+}
+...
+
+3.8.  t_suspend()
 
    Suspend the execution of SIP request in a transaction. If transaction
    was not created yet, it is created by this function. Returns true in
@@ -260,7 +281,7 @@ route[abc] {
 
    This function can be used from ANY_ROUTE .
 
-   Example 1.7. t_suspend usage
+   Example 1.8. t_suspend usage
 ...
 if(t_suspend())
 {
@@ -269,7 +290,7 @@ if(t_suspend())
 }
 ...
 
-3.8.  t_continue(tindex, tlabel, rtname)
+3.9.  t_continue(tindex, tlabel, rtname)
 
    Continue the execution of the transaction identified by tindex and
    tlabel with the actions defined in route[rtname].
@@ -284,7 +305,7 @@ if(t_suspend())
 
    This function can be used in ANY_ROUTE.
 
-   Example 1.8. t_continue usage
+   Example 1.9. t_continue usage
 ...
 tcontinue('123', '456', 'MYROUTE');
 ...

+ 25 - 0
modules_k/tmx/doc/tmx_admin.xml

@@ -239,6 +239,31 @@ route[abc] {
     if(t_is_branch_route()) { ... }
 }
 ...
+</programlisting>
+		</example>
+	</section>
+	<section>
+		<title>
+		<function moreinfo="none">t_is_reply_route()</function>
+		</title>
+		<para>
+		Returns true if the top-executed route block is reply_route.
+		</para>
+		<para>
+		This function can be used from ANY_ROUTE .
+		</para>
+		<example>
+		<title><function>t_is_reply_route</function> usage</title>
+		<programlisting format="linespecific">
+...
+reply_route[xyz] {
+    route(abc);
+}
+
+route[abc] {
+    if(t_is_reply_route()) { ... }
+}
+...
 </programlisting>
 		</example>
 	</section>

+ 13 - 0
modules_k/tmx/tmx_mod.c

@@ -59,6 +59,7 @@ 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* );
+static int t_is_reply_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);
@@ -160,6 +161,8 @@ static cmd_export_t cmds[]={
 			0, ANY_ROUTE  },
 	{"t_is_branch_route",    (cmd_function)t_is_branch_route,    0, 0,
 			0, ANY_ROUTE  },
+	{"t_is_reply_route",    (cmd_function)t_is_reply_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,
@@ -466,6 +469,16 @@ static int t_is_branch_route(struct sip_msg* msg, char *foo, char *bar)
 	return -1;
 }
 
+/**
+ *
+ */
+static int t_is_reply_route(struct sip_msg* msg, char *foo, char *bar)
+{
+	if(route_type & ONREPLY_ROUTE)
+		return 1;
+	return -1;
+}
+
 /**
  *
  */