2
0
Эх сурвалжийг харах

modules/outbound: added force_no_outbound flag

Juha Heinanen 12 жил өмнө
parent
commit
744a8d317b

+ 23 - 6
modules/outbound/README

@@ -4,7 +4,7 @@ Peter Dunkley
 
 
    Crocodile RCS Ltd
    Crocodile RCS Ltd
 
 
-   Copyright © 2012-2013 Crocodile RCS Ltd
+   Copyright (c) 2012-2013 Crocodile RCS Ltd
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -24,6 +24,7 @@ Peter Dunkley
         3. Parameters
         3. Parameters
 
 
               3.1. force_outbound_flag (integer)
               3.1. force_outbound_flag (integer)
+              3.2. force_no_outbound_flag (integer)
 
 
         4. Functions
         4. Functions
         5. MI Commands
         5. MI Commands
@@ -33,6 +34,7 @@ Peter Dunkley
    1.1. Edge Proxy Configuration
    1.1. Edge Proxy Configuration
    1.2. Registrar Configuration
    1.2. Registrar Configuration
    1.3. Set force_outbound_flag parameter
    1.3. Set force_outbound_flag parameter
+   1.4. Set force_no_outbound_flag parameter
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -51,6 +53,7 @@ Chapter 1. Admin Guide
    3. Parameters
    3. Parameters
 
 
         3.1. force_outbound_flag (integer)
         3.1. force_outbound_flag (integer)
+        3.2. force_no_outbound_flag (integer)
 
 
    4. Functions
    4. Functions
    5. MI Commands
    5. MI Commands
@@ -69,7 +72,7 @@ Chapter 1. Admin Guide
 1.1. Edge Proxy Keep-Alives (STUN)
 1.1. Edge Proxy Keep-Alives (STUN)
 
 
    Outbound Edge Proxies MUST support STUN NAT keep-alives on their SIP
    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
 1.2. Flow Timer
 
 
@@ -78,9 +81,9 @@ Chapter 1. Admin Guide
    responses to REGISTERs.
    responses to REGISTERs.
 
 
    When using TCP or TLS as the SIP transport care should be taken to set
    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
    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
    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
    interval will keep connections open far longer than is required (which
    is wasteful).
    is wasteful).
@@ -88,9 +91,9 @@ Chapter 1. Admin Guide
    Application-layer keep-alives are optional when the underlying
    Application-layer keep-alives are optional when the underlying
    transport already has a keep-alive mechanism. The WebSocket transport
    transport already has a keep-alive mechanism. The WebSocket transport
    has a transport-layer keep-alive. When using 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
    the Registrar flow timer interval and a little less than the
-   “tcp_connection_lifetime”.
+   "tcp_connection_lifetime".
 
 
    Example 1.1. Edge Proxy Configuration
    Example 1.1. Edge Proxy Configuration
 #!KAMAILIO
 #!KAMAILIO
@@ -489,6 +492,7 @@ event_route[tm:branch-failure:FAIL-BRANCH] {
 3. Parameters
 3. Parameters
 
 
    3.1. force_outbound_flag (integer)
    3.1. force_outbound_flag (integer)
+   3.2. force_no_outbound_flag (integer)
 
 
 3.1. force_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)
 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
 4. Functions
 
 
    None
    None

+ 19 - 0
modules/outbound/doc/outbound_admin.xml

@@ -481,6 +481,25 @@ modparam("outbound", "force_outbound_flag", 1)
 </programlisting>
 </programlisting>
 		</example>
 		</example>
 	</section>
 	</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>
 
 
 	<section>
 	<section>

+ 16 - 1
modules/outbound/ob_mod.c

@@ -48,6 +48,7 @@ static int mod_init(void);
 static void destroy(void);
 static void destroy(void);
 
 
 static unsigned int ob_force_flag = (unsigned int) -1;
 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 str ob_key = {0, 0};
 
 
 static cmd_export_t cmds[]= 
 static cmd_export_t cmds[]= 
@@ -61,6 +62,7 @@ static cmd_export_t cmds[]=
 static param_export_t params[]=
 static param_export_t params[]=
 {
 {
 	{ "force_outbound_flag",	INT_PARAM, &ob_force_flag },
 	{ "force_outbound_flag",	INT_PARAM, &ob_force_flag },
+	{ "force_no_outbound_flag",     INT_PARAM, &ob_force_no_flag },
 	{ 0, 0, 0 }
 	{ 0, 0, 0 }
 };
 };
 
 
@@ -88,6 +90,12 @@ static int mod_init(void)
 		return -1;
 		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)
 	if ((ob_key.s = shm_malloc(OB_KEY_LEN)) == NULL)
 	{
 	{
 		LM_ERR("Failed to allocate memory for flow-token key\n");
 		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 Outbound is forced return success without any further checks */
 	if (ob_force_flag != -1 && isflagset(msg, ob_force_flag) > 0)
 	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;
 		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",
 	LM_DBG("Analysing %.*s for outbound markers\n",
 		msg->first_line.u.request.method.len,
 		msg->first_line.u.request.method.len,
 		msg->first_line.u.request.method.s);
 		msg->first_line.u.request.method.s);