Browse code

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.

Huseyin Dikme authored on 15/02/2018 15:17:55
Showing 2 changed files
... ...
@@ -1965,6 +1965,27 @@ modparam("rtpengine", "mos_average_samples_B_pv", "$avp(mos_average_samples_B)")
1965 1965
 		</example>
1966 1966
 	</section>
1967 1967
 
1968
+	<section id="rtpengine.p.control_cmd_tos">
1969
+		<title><varname>control_cmd_tos</varname> (integer)</title>
1970
+		<para>
1971
+			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).
1972
+		</para>
1973
+		<para>
1974
+			There is no default value. By default this feature is not used.
1975
+		</para>
1976
+		<para>
1977
+			The values not falling into the range <quote>0-255</quote> will be simply ignored.
1978
+		</para>
1979
+		<example>
1980
+		<title>Set <varname>control_cmd_tos</varname> parameter</title>
1981
+<programlisting format="linespecific">
1982
+...
1983
+modparam("rtpengine", "control_cmd_tos", "144")
1984
+...
1985
+</programlisting>
1986
+		</example>
1987
+	</section>
1988
+
1968 1989
 	</section>
1969 1990
 
1970 1991
 
... ...
@@ -209,6 +209,7 @@ static int pv_parse_var(str *inp, pv_elem_t **outp, int *got_any);
209 209
 static int mos_label_stats_parse(struct minmax_mos_label_stats *mmls);
210 210
 static void parse_call_stats(bencode_item_t *, struct sip_msg *);
211 211
 
212
+static int control_cmd_tos = -1; 
212 213
 static int rtpengine_allow_op = 0;
213 214
 static struct rtpp_node **queried_nodes_ptr = NULL;
214 215
 static pid_t mypid;
... ...
@@ -341,6 +342,7 @@ static param_export_t params[] = {
341 342
 	{"queried_nodes_limit",   INT_PARAM, &default_rtpengine_cfg.queried_nodes_limit    },
342 343
 	{"rtpengine_tout_ms",     INT_PARAM, &default_rtpengine_cfg.rtpengine_tout_ms      },
343 344
 	{"rtpengine_allow_op",    INT_PARAM, &rtpengine_allow_op     },
345
+	{"control_cmd_tos",       INT_PARAM, &control_cmd_tos        }, 
344 346
 	{"db_url",                PARAM_STR, &rtpp_db_url            },
345 347
 	{"table_name",            PARAM_STR, &rtpp_table_name        },
346 348
 	{"setid_col",             PARAM_STR, &rtpp_setid_col         },
... ...
@@ -1675,6 +1677,20 @@ static int build_rtpp_socks() {
1675 1677
 				LM_WARN("Failed enable set MTU discovery socket option\n");
1676 1678
 #endif
1677 1679
 
1680
+			if((0 <= control_cmd_tos) && (control_cmd_tos < 256)) {
1681
+				unsigned char tos = control_cmd_tos;
1682
+				if (pnode->rn_umode == 6) {
1683
+					setsockopt(rtpp_socks[pnode->idx], IPPROTO_IPV6,
1684
+							IPV6_TCLASS, &control_cmd_tos,
1685
+							sizeof(control_cmd_tos));
1686
+
1687
+				} else {
1688
+					setsockopt(rtpp_socks[pnode->idx], IPPROTO_IP,
1689
+							IP_TOS, &tos,
1690
+							sizeof(tos));
1691
+				}
1692
+			}
1693
+
1678 1694
 			if (bind_force_send_ip(pnode->idx) == -1) {
1679 1695
 				LM_ERR("can't bind socket\n");
1680 1696
 				close(rtpp_socks[pnode->idx]);