Browse code

core: added local_rport global parameter

- similar to add_local_rport() but set globally

Daniel-Constantin Mierla authored on 11/11/2020 08:29:08
Showing 4 changed files
... ...
@@ -154,6 +154,7 @@ ROUTE_SEND onsend_route
154 154
 ROUTE_EVENT event_route
155 155
 EXEC	exec
156 156
 FORCE_RPORT		"force_rport"|"add_rport"
157
+LOCAL_RPORT		"local_rport"
157 158
 ADD_LOCAL_RPORT		"add_local_rport"
158 159
 FORCE_TCP_ALIAS		"force_tcp_alias"|"add_tcp_alias"
159 160
 UDP_MTU		"udp_mtu"
... ...
@@ -638,6 +639,8 @@ IMPORTFILE      "import_file"
638 639
 <INITIAL>{SET_USERPHONE}	{ count(); yylval.strval=yytext;
639 640
 								return SET_USERPHONE; }
640 641
 <INITIAL>{FORCE_RPORT}	{ count(); yylval.strval=yytext; return FORCE_RPORT; }
642
+<INITIAL>{LOCAL_RPORT}	{ count(); yylval.strval=yytext;
643
+								return LOCAL_RPORT; }
641 644
 <INITIAL>{ADD_LOCAL_RPORT}	{ count(); yylval.strval=yytext;
642 645
 								return ADD_LOCAL_RPORT; }
643 646
 <INITIAL>{FORCE_TCP_ALIAS}	{ count(); yylval.strval=yytext;
... ...
@@ -253,6 +253,7 @@ extern char *default_routename;
253 253
 %token REVERT_URI
254 254
 %token FORCE_RPORT
255 255
 %token ADD_LOCAL_RPORT
256
+%token LOCAL_RPORT
256 257
 %token FORCE_TCP_ALIAS
257 258
 %token UDP_MTU
258 259
 %token UDP_MTU_TRY_PROTO
... ...
@@ -1757,6 +1758,8 @@ assign_stm:
1757 1758
 	| FORCE_RPORT EQUAL NUMBER
1758 1759
 		{ default_core_cfg.force_rport=$3; fix_global_req_flags(0, 0); }
1759 1760
 	| FORCE_RPORT EQUAL error { yyerror("boolean value expected"); }
1761
+	| LOCAL_RPORT EQUAL NUMBER { ksr_local_rport=$3; }
1762
+	| LOCAL_RPORT EQUAL error { yyerror("boolean value expected"); }
1760 1763
 	| UDP_MTU_TRY_PROTO EQUAL proto
1761 1764
 		{ default_core_cfg.udp_mtu_try_proto=$3; fix_global_req_flags(0, 0); }
1762 1765
 	| UDP_MTU_TRY_PROTO EQUAL error
... ...
@@ -222,6 +222,7 @@ extern unsigned char *_ksr_hname_extra_chars;
222 222
 
223 223
 extern char *ksr_stats_namesep;
224 224
 extern str ksr_ipv6_hex_style;
225
+extern int ksr_local_rport;
225 226
 
226 227
 #ifdef USE_DNS_CACHE
227 228
 extern int dns_cache_init; /* if 0, the DNS cache is not initialized at startup */
... ...
@@ -114,6 +114,7 @@ extern int version_len;
114 114
 
115 115
 str _ksr_xavp_via_params = STR_NULL;
116 116
 str _ksr_xavp_via_fields = STR_NULL;
117
+int ksr_local_rport = 0;
117 118
 
118 119
 /** per process fixup function for global_req_flags.
119 120
   * It should be called from the configuration framework.
... ...
@@ -2975,7 +2976,7 @@ char* create_via_hf(unsigned int *len,
2975 2976
 #endif /* USE_TCP || USE_SCTP */
2976 2977
 
2977 2978
 	/* test and add rport parameter to local via - rfc3581 */
2978
-	if(msg && msg->msg_flags&FL_ADD_LOCAL_RPORT) {
2979
+	if((ksr_local_rport) || (msg && (msg->msg_flags&FL_ADD_LOCAL_RPORT))) {
2979 2980
 		/* params so far + ';rport' + '\0' */
2980 2981
 		via = (char*)pkg_malloc(extra_params.len+RPORT_LEN);
2981 2982
 		if(via==0) {