Browse code

registrar: renamed parameter to use advertise addr for socket

- becomes sock_mode, when set to 0 (default) use bind address,
if set to 1, then use advertised address if specified

Daniel-Constantin Mierla authored on 14/10/2020 09:29:50
Showing 3 changed files
... ...
@@ -132,7 +132,7 @@ int reg_use_domain = 0;
132 132
 int sock_flag = -1;
133 133
 str sock_hdr_name = {0,0};
134 134
 
135
-int sock_advertise_enabled = 0;
135
+int reg_sock_mode = 0;
136 136
 
137 137
 /* where to go for event route ("usrloc:contact-expired") */
138 138
 int reg_expire_event_rt = -1; /* default disabled */
... ...
@@ -232,6 +232,7 @@ static param_export_t params[] = {
232 232
 	{"received_avp",       PARAM_STRING, &rcv_avp_param       					},
233 233
 	{"max_contacts",       INT_PARAM, &default_registrar_cfg.max_contacts			},
234 234
 	{"retry_after",        INT_PARAM, &default_registrar_cfg.retry_after			},
235
+	{"sock_mode",          PARAM_INT, &reg_sock_mode						},
235 236
 	{"sock_flag",          INT_PARAM, &sock_flag           					},
236 237
 	{"sock_hdr_name",      PARAM_STR, &sock_hdr_name     					},
237 238
 	{"method_filtering",   INT_PARAM, &method_filtering    					},
... ...
@@ -251,7 +252,6 @@ static param_export_t params[] = {
251 252
 	{"lookup_filter_mode", INT_PARAM, &reg_lookup_filter_mode			},
252 253
 	{"min_expires_mode",   PARAM_INT, &reg_min_expires_mode				},
253 254
 	{"use_expired_contacts",  INT_PARAM, &default_registrar_cfg.use_expired_contacts	 },
254
-	{"use_advertised_address", PARAM_INT, &sock_advertise_enabled		},
255 255
 	{0, 0, 0}
256 256
 };
257 257
 
... ...
@@ -99,7 +99,7 @@ extern int reg_flow_timer;
99 99
 
100 100
 extern str sock_hdr_name;
101 101
 extern int sock_flag;
102
-extern int sock_advertise_enabled;
102
+extern int reg_sock_mode;
103 103
 
104 104
 extern str reg_xavp_cfg;
105 105
 extern str reg_xavp_rcd;
... ...
@@ -62,6 +62,8 @@
62 62
 #include "save.h"
63 63
 #include "config.h"
64 64
 
65
+#define REG_SOCK_USE_ADVERTISED 1 /* 1<<0 */
66
+
65 67
 static int mem_only = 0;
66 68
 
67 69
 extern sruid_t _reg_sruid;
... ...
@@ -255,14 +257,17 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m, contact_t* _c,
255 257
 		/* set received socket */
256 258
 		if (_m->flags&sock_flag) {
257 259
 			ci.sock = get_sock_val(_m);
258
-			if (ci.sock==0)
260
+		}
261
+		if (ci.sock==NULL) {
262
+			if ((reg_sock_mode & REG_SOCK_USE_ADVERTISED)
263
+					&& _m->rcv.bind_address != NULL
264
+					&& _m->rcv.bind_address->useinfo.sock_str.len > 0) {
265
+				memset(&si, 0, sizeof(struct socket_info));
266
+				si.sock_str = _m->rcv.bind_address->useinfo.sock_str;
267
+				ci.sock = &si;
268
+			} else {
259 269
 				ci.sock = _m->rcv.bind_address;
260
-		} else if (sock_advertise_enabled && _m->rcv.bind_address && _m->rcv.bind_address->useinfo.sock_str.len > 0) {
261
-		    memset(&si, 0, sizeof(struct socket_info));
262
-		    si.sock_str = _m->rcv.bind_address->useinfo.sock_str;
263
-		    ci.sock = &si;
264
-		} else {
265
-			ci.sock = _m->rcv.bind_address;
270
+			}
266 271
 		}
267 272
 
268 273
 		/* set tcp connection id */