[sr-dev] git:master:8a12e15b: Merge pull request #1534 from armenb/armenb/relay_100

GitHub noreply at github.com
Fri Jun 22 10:34:51 CEST 2018


Module: kamailio
Branch: master
Commit: 8a12e15b7a7c597f39a69f5bfdb265e42d5a778d
URL: https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: GitHub <noreply at github.com>
Date: 2018-06-22T10:34:45+02:00

Merge pull request #1534 from armenb/armenb/relay_100

tm: add relay_100 config parameter to support stateless operation

---

Modified: src/modules/tm/config.c
Modified: src/modules/tm/config.h
Modified: src/modules/tm/doc/params.xml
Modified: src/modules/tm/t_reply.c
Modified: src/modules/tm/tm.c

---

Diff:  https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d.diff
Patch: https://github.com/kamailio/kamailio/commit/8a12e15b7a7c597f39a69f5bfdb265e42d5a778d.patch

---

diff --git a/src/modules/tm/config.c b/src/modules/tm/config.c
index 00f86b12b1..b5494fea50 100644
--- a/src/modules/tm/config.c
+++ b/src/modules/tm/config.c
@@ -93,8 +93,9 @@ struct cfg_group_tm	default_tm_cfg = {
 	0,  /* local_ack_mode, default 0 (rfc3261 conformant) */
 	1, /* local_cancel_reason -- add Reason header to locally generated
 		  CANCELs; on by default */
-	1  /* e2e_cancel_reason -- copy the Reason headers from incoming CANCELs
+	1,  /* e2e_cancel_reason -- copy the Reason headers from incoming CANCELs
 		  into the corresp. hop-by-hop CANCELs, on by default */
+	0   /* relay_100 -- by default, assume stateful proxy and do not relay SIP 100 */
 };
 
 void	*tm_cfg = &default_tm_cfg;
@@ -204,5 +205,7 @@ cfg_def_t	tm_cfg_def[] = {
 	{"e2e_cancel_reason",	CFG_VAR_INT | CFG_ATOMIC,	0, 1, 0, 0,
 		"if set to 1, Reason headers from received CANCELs are copied into"
 		" the corresponding generated hop-by-hop CANCELs"},
+	{"relay_100",		CFG_VAR_INT | CFG_ATOMIC,	0, 1, 0, 0,
+		"if set to 1, relay SIP 100 messages as a stateless proxy"},
 	{0, 0, 0, 0, 0, 0}
 };
diff --git a/src/modules/tm/config.h b/src/modules/tm/config.h
index 963fea6ea0..d46f71f9f6 100644
--- a/src/modules/tm/config.h
+++ b/src/modules/tm/config.h
@@ -135,6 +135,7 @@ struct cfg_group_tm {
 	int local_ack_mode;
 	int local_cancel_reason;
 	int e2e_cancel_reason;
+	unsigned int relay_100;
 };
 
 extern struct cfg_group_tm	default_tm_cfg;
diff --git a/src/modules/tm/doc/params.xml b/src/modules/tm/doc/params.xml
index d787447c40..3692dab0d4 100644
--- a/src/modules/tm/doc/params.xml
+++ b/src/modules/tm/doc/params.xml
@@ -1454,6 +1454,33 @@ function ksr_tm_event(evname)
 	return 1;
 end
 ...
+</programlisting>
+		</example>
+	</section>
+
+	<section id="tm.p.relay_100">
+		<title><varname>relay_100</varname> (str)</title>
+		<para>
+			This parameter controls whether or not a SIP 100 response is proxied.
+			Note that this is not valid behavior when operating in stateful mode
+			per RFC 3261 Section 21.1.1, and therefore is useful only when
+			operating as a stateless proxy.
+			When using this feature, it is possible to control which 100 responses
+			are proxied and which are not by detecting whether they are part of
+			an existing transaction and setting up the appropriate logic in
+			onreply_route.
+		</para>
+		<para>
+		<emphasis>
+			Default value is 0 (disabled).
+		</emphasis>
+		</para>
+		<example>
+		<title>Set <varname>relay_100</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("tm", "relay_100", 1)
+...
 </programlisting>
 		</example>
 	</section>
diff --git a/src/modules/tm/t_reply.c b/src/modules/tm/t_reply.c
index 8b94cec624..474851aa7c 100644
--- a/src/modules/tm/t_reply.c
+++ b/src/modules/tm/t_reply.c
@@ -1494,9 +1494,10 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 #else
 		*should_store=0;
 #endif
-		/* 1xx and 2xx except 100 will be relayed */
+		/* By default, 1xx and 2xx (except 100) will be relayed. 100 relaying can be
+		 * controlled via relay_100 parameter */
 		Trans->uac[branch].last_received=new_code;
-		*should_relay= new_code==100? -1 : branch;
+		*should_relay= (new_code==100 && !cfg_get(tm, tm_cfg, relay_100)) ? -1 : branch;
 		if (new_code>=200 ) {
 			prepare_to_cancel( Trans, &cancel_data->cancel_bitmap, 0);
 #ifdef CANCEL_REASON_SUPPORT
diff --git a/src/modules/tm/tm.c b/src/modules/tm/tm.c
index 426898f314..68df52b5c1 100644
--- a/src/modules/tm/tm.c
+++ b/src/modules/tm/tm.c
@@ -474,6 +474,7 @@ static param_export_t params[]={
 #endif /* CANCEL_REASON_SUPPORT */
 	{"xavp_contact",        PARAM_STR, &ulattrs_xavp_name                    },
 	{"event_callback",      PARAM_STR, &tm_event_callback                    },
+	{"relay_100",           PARAM_INT, &default_tm_cfg.relay_100             },
 	{0,0,0}
 };
 




More information about the sr-dev mailing list