Module: kamailio
Branch: master
Commit: 32bf022ad48ff1d7ac02ce2201373e8b684d4f6f
URL:
https://github.com/kamailio/kamailio/commit/32bf022ad48ff1d7ac02ce2201373e8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-10-14T11:31:52+02:00
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
---
Modified: src/modules/registrar/registrar.c
Modified: src/modules/registrar/registrar.h
Modified: src/modules/registrar/save.c
---
Diff:
https://github.com/kamailio/kamailio/commit/32bf022ad48ff1d7ac02ce2201373e8…
Patch:
https://github.com/kamailio/kamailio/commit/32bf022ad48ff1d7ac02ce2201373e8…
---
diff --git a/src/modules/registrar/registrar.c b/src/modules/registrar/registrar.c
index 7dae9b6ccb..923fde39d9 100644
--- a/src/modules/registrar/registrar.c
+++ b/src/modules/registrar/registrar.c
@@ -132,7 +132,7 @@ int reg_use_domain = 0;
int sock_flag = -1;
str sock_hdr_name = {0,0};
-int sock_advertise_enabled = 0;
+int reg_sock_mode = 0;
/* where to go for event route ("usrloc:contact-expired") */
int reg_expire_event_rt = -1; /* default disabled */
@@ -232,6 +232,7 @@ static param_export_t params[] = {
{"received_avp", PARAM_STRING, &rcv_avp_param },
{"max_contacts", INT_PARAM,
&default_registrar_cfg.max_contacts },
{"retry_after", INT_PARAM, &default_registrar_cfg.retry_after },
+ {"sock_mode", PARAM_INT, ®_sock_mode },
{"sock_flag", INT_PARAM, &sock_flag },
{"sock_hdr_name", PARAM_STR, &sock_hdr_name },
{"method_filtering", INT_PARAM, &method_filtering },
@@ -251,7 +252,6 @@ static param_export_t params[] = {
{"lookup_filter_mode", INT_PARAM, ®_lookup_filter_mode },
{"min_expires_mode", PARAM_INT, ®_min_expires_mode },
{"use_expired_contacts", INT_PARAM,
&default_registrar_cfg.use_expired_contacts },
- {"use_advertised_address", PARAM_INT, &sock_advertise_enabled },
{0, 0, 0}
};
diff --git a/src/modules/registrar/registrar.h b/src/modules/registrar/registrar.h
index 0fbdbd5bd4..fcf565a6fd 100644
--- a/src/modules/registrar/registrar.h
+++ b/src/modules/registrar/registrar.h
@@ -99,7 +99,7 @@ extern int reg_flow_timer;
extern str sock_hdr_name;
extern int sock_flag;
-extern int sock_advertise_enabled;
+extern int reg_sock_mode;
extern str reg_xavp_cfg;
extern str reg_xavp_rcd;
diff --git a/src/modules/registrar/save.c b/src/modules/registrar/save.c
index 702499cfdd..4302127814 100644
--- a/src/modules/registrar/save.c
+++ b/src/modules/registrar/save.c
@@ -62,6 +62,8 @@
#include "save.h"
#include "config.h"
+#define REG_SOCK_USE_ADVERTISED 1 /* 1<<0 */
+
static int mem_only = 0;
extern sruid_t _reg_sruid;
@@ -255,14 +257,17 @@ static inline ucontact_info_t* pack_ci( struct sip_msg* _m,
contact_t* _c,
/* set received socket */
if (_m->flags&sock_flag) {
ci.sock = get_sock_val(_m);
- if (ci.sock==0)
+ }
+ if (ci.sock==NULL) {
+ if ((reg_sock_mode & REG_SOCK_USE_ADVERTISED)
+ && _m->rcv.bind_address != NULL
+ && _m->rcv.bind_address->useinfo.sock_str.len > 0) {
+ memset(&si, 0, sizeof(struct socket_info));
+ si.sock_str = _m->rcv.bind_address->useinfo.sock_str;
+ ci.sock = &si;
+ } else {
ci.sock = _m->rcv.bind_address;
- } else if (sock_advertise_enabled && _m->rcv.bind_address &&
_m->rcv.bind_address->useinfo.sock_str.len > 0) {
- memset(&si, 0, sizeof(struct socket_info));
- si.sock_str = _m->rcv.bind_address->useinfo.sock_str;
- ci.sock = &si;
- } else {
- ci.sock = _m->rcv.bind_address;
+ }
}
/* set tcp connection id */