[sr-dev] git:master:5fef3a6d: rtpengine: setting tos value for the control commands

Huseyin Dikme hueseyin.dikme at 1und1.de
Tue Feb 20 18:21:40 CET 2018


Module: kamailio
Branch: master
Commit: 5fef3a6dc02543dcdced6f935da4b23f7702a050
URL: https://github.com/kamailio/kamailio/commit/5fef3a6dc02543dcdced6f935da4b23f7702a050

Author: Huseyin Dikme <hueseyin.dikme at 1und1.de>
Committer: Huseyin Dikme <hueseyin.dikme at 1und1.de>
Date: 2018-02-20T13:25:07+01:00

rtpengine: setting tos value for the control commands
- A parameter "control_cmd_tos" has been created in order to set
  the type of service for the control channel.

---

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

---

Diff:  https://github.com/kamailio/kamailio/commit/5fef3a6dc02543dcdced6f935da4b23f7702a050.diff
Patch: https://github.com/kamailio/kamailio/commit/5fef3a6dc02543dcdced6f935da4b23f7702a050.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