Module: sip-router Branch: master Commit: 744a8d317b894a1360e3441a9e69ac9190a1745b URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=744a8d31...
Author: Juha Heinanen jh@tutpro.com Committer: Juha Heinanen jh@tutpro.com Date: Thu Apr 25 14:12:21 2013 +0300
modules/outbound: added force_no_outbound flag
---
modules/outbound/README | 29 +++++++++++++++++++++++------ modules/outbound/doc/outbound_admin.xml | 19 +++++++++++++++++++ modules/outbound/ob_mod.c | 17 ++++++++++++++++- 3 files changed, 58 insertions(+), 7 deletions(-)
diff --git a/modules/outbound/README b/modules/outbound/README index 057fefa..2f23ab1 100644 --- a/modules/outbound/README +++ b/modules/outbound/README @@ -4,7 +4,7 @@ Peter Dunkley
Crocodile RCS Ltd
- Copyright © 2012-2013 Crocodile RCS Ltd + Copyright (c) 2012-2013 Crocodile RCS Ltd __________________________________________________________________
Table of Contents @@ -24,6 +24,7 @@ Peter Dunkley 3. Parameters
3.1. force_outbound_flag (integer) + 3.2. force_no_outbound_flag (integer)
4. Functions 5. MI Commands @@ -33,6 +34,7 @@ Peter Dunkley 1.1. Edge Proxy Configuration 1.2. Registrar Configuration 1.3. Set force_outbound_flag parameter + 1.4. Set force_no_outbound_flag parameter
Chapter 1. Admin Guide
@@ -51,6 +53,7 @@ Chapter 1. Admin Guide 3. Parameters
3.1. force_outbound_flag (integer) + 3.2. force_no_outbound_flag (integer)
4. Functions 5. MI Commands @@ -69,7 +72,7 @@ Chapter 1. Admin Guide 1.1. Edge Proxy Keep-Alives (STUN)
Outbound Edge Proxies MUST support STUN NAT keep-alives on their SIP - UDP ports. Kamailio supports this though the “stun” module. + UDP ports. Kamailio supports this though the "stun" module.
1.2. Flow Timer
@@ -78,9 +81,9 @@ Chapter 1. Admin Guide responses to REGISTERs.
When using TCP or TLS as the SIP transport care should be taken to set - the “tcp_connection_lifetime” on the Edge Proxy to a value slightly + the "tcp_connection_lifetime" on the Edge Proxy to a value slightly larger than the interval the Registrar is using for flow timer. Setting - “tcp_connection_lifetime” to less than the interval could cause + "tcp_connection_lifetime" to less than the interval could cause connections to be lost, and setting it to a value much larger than the interval will keep connections open far longer than is required (which is wasteful). @@ -88,9 +91,9 @@ Chapter 1. Admin Guide Application-layer keep-alives are optional when the underlying transport already has a keep-alive mechanism. The WebSocket transport has a transport-layer keep-alive. When using the WebSocket transport - the “keepalive_timeout” should be set to a value a little greater than + the "keepalive_timeout" should be set to a value a little greater than the Registrar flow timer interval and a little less than the - “tcp_connection_lifetime”. + "tcp_connection_lifetime".
Example 1.1. Edge Proxy Configuration #!KAMAILIO @@ -489,6 +492,7 @@ event_route[tm:branch-failure:FAIL-BRANCH] { 3. Parameters
3.1. force_outbound_flag (integer) + 3.2. force_no_outbound_flag (integer)
3.1. force_outbound_flag (integer)
@@ -503,6 +507,19 @@ event_route[tm:branch-failure:FAIL-BRANCH] { modparam("outbound", "force_outbound_flag", 1) ...
+3.2. force_no_outbound_flag (integer) + + A flag which, if set for a request, will force path and rr not to add + flow tokens to Path: and Record-Route: headers regardless of the + request contents. + + Default value is -1. + + Example 1.4. Set force_no_outbound_flag parameter +... +modparam("outbound", "force_no_outbound_flag", 2) +... + 4. Functions
None diff --git a/modules/outbound/doc/outbound_admin.xml b/modules/outbound/doc/outbound_admin.xml index dca8448..4cd8f0d 100644 --- a/modules/outbound/doc/outbound_admin.xml +++ b/modules/outbound/doc/outbound_admin.xml @@ -481,6 +481,25 @@ modparam("outbound", "force_outbound_flag", 1) </programlisting> </example> </section> + + <section> + <title><varname>force_no_outbound_flag</varname> (integer)</title> + <para>A flag which, if set for a request, will force + <emphasis>path</emphasis> and <emphasis>rr</emphasis> not + to add flow tokens to Path: and Record-Route: headers + regardless of the request contents.</para> + <para><emphasis>Default value is -1.</emphasis></para> + <example> + <title>Set <varname>force_no_outbound_flag</varname> parameter + </title> + <programlisting format="linespecific"> +... +modparam("outbound", "force_no_outbound_flag", 2) +... +</programlisting> + </example> + </section> + </section>
<section> diff --git a/modules/outbound/ob_mod.c b/modules/outbound/ob_mod.c index 69ac1e0..a2b6d12 100644 --- a/modules/outbound/ob_mod.c +++ b/modules/outbound/ob_mod.c @@ -48,6 +48,7 @@ static int mod_init(void); static void destroy(void);
static unsigned int ob_force_flag = (unsigned int) -1; +static unsigned int ob_force_no_flag = (unsigned int) -1; static str ob_key = {0, 0};
static cmd_export_t cmds[]= @@ -61,6 +62,7 @@ static cmd_export_t cmds[]= static param_export_t params[]= { { "force_outbound_flag", INT_PARAM, &ob_force_flag }, + { "force_no_outbound_flag", INT_PARAM, &ob_force_no_flag }, { 0, 0, 0 } };
@@ -88,6 +90,12 @@ static int mod_init(void) return -1; }
+ if (ob_force_no_flag != -1 && !flag_in_range(ob_force_no_flag)) + { + LM_ERR("bad no_outbound_flag value (%d)\n", ob_force_no_flag); + return -1; + } + if ((ob_key.s = shm_malloc(OB_KEY_LEN)) == NULL) { LM_ERR("Failed to allocate memory for flow-token key\n"); @@ -451,10 +459,17 @@ int use_outbound(struct sip_msg *msg) /* If Outbound is forced return success without any further checks */ if (ob_force_flag != -1 && isflagset(msg, ob_force_flag) > 0) { - LM_DBG("outbound forced\n"); + LM_DBG("outbound used by force\n"); return 1; }
+ /* If Outbound is turned off, return failure without any further checks */ + if (ob_force_no_flag != -1 && isflagset(msg, ob_force_no_flag) > 0) + { + LM_DBG("outbound not used by force\n"); + return 0; + } + LM_DBG("Analysing %.*s for outbound markers\n", msg->first_line.u.request.method.len, msg->first_line.u.request.method.s);