Browse code

modules/outbound: added force_no_outbound flag

Juha Heinanen authored on 25/04/2013 11:12:21
Showing 3 changed files
... ...
@@ -4,7 +4,7 @@ Peter Dunkley
4 4
 
5 5
    Crocodile RCS Ltd
6 6
 
7
-   Copyright © 2012-2013 Crocodile RCS Ltd
7
+   Copyright (c) 2012-2013 Crocodile RCS Ltd
8 8
      __________________________________________________________________
9 9
 
10 10
    Table of Contents
... ...
@@ -24,6 +24,7 @@ Peter Dunkley
24 24
         3. Parameters
25 25
 
26 26
               3.1. force_outbound_flag (integer)
27
+              3.2. force_no_outbound_flag (integer)
27 28
 
28 29
         4. Functions
29 30
         5. MI Commands
... ...
@@ -33,6 +34,7 @@ Peter Dunkley
33 34
    1.1. Edge Proxy Configuration
34 35
    1.2. Registrar Configuration
35 36
    1.3. Set force_outbound_flag parameter
37
+   1.4. Set force_no_outbound_flag parameter
36 38
 
37 39
 Chapter 1. Admin Guide
38 40
 
... ...
@@ -51,6 +53,7 @@ Chapter 1. Admin Guide
51 53
    3. Parameters
52 54
 
53 55
         3.1. force_outbound_flag (integer)
56
+        3.2. force_no_outbound_flag (integer)
54 57
 
55 58
    4. Functions
56 59
    5. MI Commands
... ...
@@ -69,7 +72,7 @@ Chapter 1. Admin Guide
69 72
 1.1. Edge Proxy Keep-Alives (STUN)
70 73
 
71 74
    Outbound Edge Proxies MUST support STUN NAT keep-alives on their SIP
72
-   UDP ports. Kamailio supports this though the “stun” module.
75
+   UDP ports. Kamailio supports this though the "stun" module.
73 76
 
74 77
 1.2. Flow Timer
75 78
 
... ...
@@ -78,9 +81,9 @@ Chapter 1. Admin Guide
78 81
    responses to REGISTERs.
79 82
 
80 83
    When using TCP or TLS as the SIP transport care should be taken to set
81
-   the “tcp_connection_lifetime” on the Edge Proxy to a value slightly
84
+   the "tcp_connection_lifetime" on the Edge Proxy to a value slightly
82 85
    larger than the interval the Registrar is using for flow timer. Setting
83
-   “tcp_connection_lifetime” to less than the interval could cause
86
+   "tcp_connection_lifetime" to less than the interval could cause
84 87
    connections to be lost, and setting it to a value much larger than the
85 88
    interval will keep connections open far longer than is required (which
86 89
    is wasteful).
... ...
@@ -88,9 +91,9 @@ Chapter 1. Admin Guide
88 91
    Application-layer keep-alives are optional when the underlying
89 92
    transport already has a keep-alive mechanism. The WebSocket transport
90 93
    has a transport-layer keep-alive. When using the WebSocket transport
91
-   the “keepalive_timeout” should be set to a value a little greater than
94
+   the "keepalive_timeout" should be set to a value a little greater than
92 95
    the Registrar flow timer interval and a little less than the
93
-   “tcp_connection_lifetime”.
96
+   "tcp_connection_lifetime".
94 97
 
95 98
    Example 1.1. Edge Proxy Configuration
96 99
 #!KAMAILIO
... ...
@@ -489,6 +492,7 @@ event_route[tm:branch-failure:FAIL-BRANCH] {
489 492
 3. Parameters
490 493
 
491 494
    3.1. force_outbound_flag (integer)
495
+   3.2. force_no_outbound_flag (integer)
492 496
 
493 497
 3.1. force_outbound_flag (integer)
494 498
 
... ...
@@ -503,6 +507,19 @@ event_route[tm:branch-failure:FAIL-BRANCH] {
503 507
 modparam("outbound", "force_outbound_flag", 1)
504 508
 ...
505 509
 
510
+3.2. force_no_outbound_flag (integer)
511
+
512
+   A flag which, if set for a request, will force path and rr not to add
513
+   flow tokens to Path: and Record-Route: headers regardless of the
514
+   request contents.
515
+
516
+   Default value is -1.
517
+
518
+   Example 1.4. Set force_no_outbound_flag parameter
519
+...
520
+modparam("outbound", "force_no_outbound_flag", 2)
521
+...
522
+
506 523
 4. Functions
507 524
 
508 525
    None
... ...
@@ -481,6 +481,25 @@ modparam("outbound", "force_outbound_flag", 1)
481 481
 </programlisting>
482 482
 		</example>
483 483
 	</section>
484
+
485
+	<section>
486
+		<title><varname>force_no_outbound_flag</varname> (integer)</title>
487
+		<para>A flag which, if set for a request, will force
488
+		<emphasis>path</emphasis> and <emphasis>rr</emphasis> not
489
+		to add flow tokens to Path: and Record-Route: headers
490
+		regardless of the request contents.</para>
491
+		<para><emphasis>Default value is -1.</emphasis></para>
492
+		<example>
493
+		<title>Set <varname>force_no_outbound_flag</varname> parameter
494
+		</title>
495
+		<programlisting format="linespecific">
496
+...
497
+modparam("outbound", "force_no_outbound_flag", 2)
498
+...
499
+</programlisting>
500
+		</example>
501
+	</section>
502
+
484 503
 	</section>
485 504
 
486 505
 	<section>
... ...
@@ -48,6 +48,7 @@ static int mod_init(void);
48 48
 static void destroy(void);
49 49
 
50 50
 static unsigned int ob_force_flag = (unsigned int) -1;
51
+static unsigned int ob_force_no_flag = (unsigned int) -1;
51 52
 static str ob_key = {0, 0};
52 53
 
53 54
 static cmd_export_t cmds[]= 
... ...
@@ -61,6 +62,7 @@ static cmd_export_t cmds[]=
61 62
 static param_export_t params[]=
62 63
 {
63 64
 	{ "force_outbound_flag",	INT_PARAM, &ob_force_flag },
65
+	{ "force_no_outbound_flag",     INT_PARAM, &ob_force_no_flag },
64 66
 	{ 0, 0, 0 }
65 67
 };
66 68
 
... ...
@@ -88,6 +90,12 @@ static int mod_init(void)
88 90
 		return -1;
89 91
 	}
90 92
 
93
+	if (ob_force_no_flag != -1 && !flag_in_range(ob_force_no_flag))
94
+	{
95
+		LM_ERR("bad no_outbound_flag value (%d)\n", ob_force_no_flag);
96
+		return -1;
97
+	}
98
+
91 99
 	if ((ob_key.s = shm_malloc(OB_KEY_LEN)) == NULL)
92 100
 	{
93 101
 		LM_ERR("Failed to allocate memory for flow-token key\n");
... ...
@@ -451,10 +459,17 @@ int use_outbound(struct sip_msg *msg)
451 459
 	/* If Outbound is forced return success without any further checks */
452 460
 	if (ob_force_flag != -1 && isflagset(msg, ob_force_flag) > 0)
453 461
 	{
454
-		LM_DBG("outbound forced\n");
462
+		LM_DBG("outbound used by force\n");
455 463
 		return 1;
456 464
 	}
457 465
 
466
+	/* If Outbound is turned off, return failure without any further checks */
467
+	if (ob_force_no_flag != -1 && isflagset(msg, ob_force_no_flag) > 0)
468
+	{
469
+		LM_DBG("outbound not used by force\n");
470
+		return 0;
471
+	}
472
+
458 473
 	LM_DBG("Analysing %.*s for outbound markers\n",
459 474
 		msg->first_line.u.request.method.len,
460 475
 		msg->first_line.u.request.method.s);