[sr-dev] git:master:34293750: Merge pull request #1442 from hdikme/control_command_tos

GitHub noreply at github.com
Tue Feb 20 18:21:41 CET 2018


Module: kamailio
Branch: master
Commit: 34293750753280229a6e546a12a8a59871d758b0
URL: https://github.com/kamailio/kamailio/commit/34293750753280229a6e546a12a8a59871d758b0

Author: Richard Fuchs <rfuchs at sipwise.com>
Committer: GitHub <noreply at github.com>
Date: 2018-02-20T12:21:35-05:00

Merge pull request #1442 from hdikme/control_command_tos

rtpengine: setting tos value for the control commands

---

Modified: src/modules/rtpengine/doc/rtpengine_admin.xml
Modified: src/modules/rtpengine/rtpengine.c

---

Diff:  https://github.com/kamailio/kamailio/commit/34293750753280229a6e546a12a8a59871d758b0.diff
Patch: https://github.com/kamailio/kamailio/commit/34293750753280229a6e546a12a8a59871d758b0.patch

---

diff --git a/src/modules/rtpengine/doc/rtpengine_admin.xml b/src/modules/rtpengine/doc/rtpengine_admin.xml
index bc31168f63..af0c147d50 100644
--- a/src/modules/rtpengine/doc/rtpengine_admin.xml
+++ b/src/modules/rtpengine/doc/rtpengine_admin.xml
@@ -1965,6 +1965,27 @@ modparam("rtpengine", "mos_average_samples_B_pv", "$avp(mos_average_samples_B)")
 		</example>
 	</section>
 
+	<section id="rtpengine.p.control_cmd_tos">
+		<title><varname>control_cmd_tos</varname> (integer)</title>
+		<para>
+			The parameter is used to set the value of <quote>type of service (tos)</quote> for the control commands (such as rtpengine_offer(), rtpengine_answer() etc).
+		</para>
+		<para>
+			There is no default value. By default this feature is not used.
+		</para>
+		<para>
+			The values not falling into the range <quote>0-255</quote> will be simply ignored.
+		</para>
+		<example>
+		<title>Set <varname>control_cmd_tos</varname> parameter</title>
+<programlisting format="linespecific">
+...
+modparam("rtpengine", "control_cmd_tos", "144")
+...
+</programlisting>
+		</example>
+	</section>
+
 	</section>
 
 
diff --git a/src/modules/rtpengine/rtpengine.c b/src/modules/rtpengine/rtpengine.c
index 3b41789bbf..9fd827b987 100644
--- a/src/modules/rtpengine/rtpengine.c
+++ b/src/modules/rtpengine/rtpengine.c
@@ -209,6 +209,7 @@ static int pv_parse_var(str *inp, pv_elem_t **outp, int *got_any);
 static int mos_label_stats_parse(struct minmax_mos_label_stats *mmls);
 static void parse_call_stats(bencode_item_t *, struct sip_msg *);
 
+static int control_cmd_tos = -1; 
 static int rtpengine_allow_op = 0;
 static struct rtpp_node **queried_nodes_ptr = NULL;
 static pid_t mypid;
@@ -341,6 +342,7 @@ static param_export_t params[] = {
 	{"queried_nodes_limit",   INT_PARAM, &default_rtpengine_cfg.queried_nodes_limit    },
 	{"rtpengine_tout_ms",     INT_PARAM, &default_rtpengine_cfg.rtpengine_tout_ms      },
 	{"rtpengine_allow_op",    INT_PARAM, &rtpengine_allow_op     },
+	{"control_cmd_tos",       INT_PARAM, &control_cmd_tos        }, 
 	{"db_url",                PARAM_STR, &rtpp_db_url            },
 	{"table_name",            PARAM_STR, &rtpp_table_name        },
 	{"setid_col",             PARAM_STR, &rtpp_setid_col         },
@@ -1675,6 +1677,20 @@ static int build_rtpp_socks() {
 				LM_WARN("Failed enable set MTU discovery socket option\n");
 #endif
 
+			if((0 <= control_cmd_tos) && (control_cmd_tos < 256)) {
+				unsigned char tos = control_cmd_tos;
+				if (pnode->rn_umode == 6) {
+					setsockopt(rtpp_socks[pnode->idx], IPPROTO_IPV6,
+							IPV6_TCLASS, &control_cmd_tos,
+							sizeof(control_cmd_tos));
+
+				} else {
+					setsockopt(rtpp_socks[pnode->idx], IPPROTO_IP,
+							IP_TOS, &tos,
+							sizeof(tos));
+				}
+			}
+
 			if (bind_force_send_ip(pnode->idx) == -1) {
 				LM_ERR("can't bind socket\n");
 				close(rtpp_socks[pnode->idx]);




More information about the sr-dev mailing list