Module: kamailio
Branch: master
Commit: bf6b1feffeef81f43c9bffc75f7a1fbf5cd9caa7
URL:
https://github.com/kamailio/kamailio/commit/bf6b1feffeef81f43c9bffc75f7a1fb…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-04-05T10:29:57+02:00
dispatcher: turned ds_dns_mode values in bit flags
---
Modified: src/modules/dispatcher/dispatch.c
Modified: src/modules/dispatcher/dispatch.h
Modified: src/modules/dispatcher/dispatcher.c
---
Diff:
https://github.com/kamailio/kamailio/commit/bf6b1feffeef81f43c9bffc75f7a1fb…
Patch:
https://github.com/kamailio/kamailio/commit/bf6b1feffeef81f43c9bffc75f7a1fb…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index d59eebe23e..b770a02a40 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -111,7 +111,7 @@ extern float ds_latency_estimator_alpha;
extern int ds_attrs_none;
extern param_t *ds_db_extra_attrs_list;
extern int ds_load_mode;
-extern int ds_dns_mode;
+extern uint32_t ds_dns_mode;
static db_func_t ds_dbf;
static db1_con_t *ds_db_handle = NULL;
@@ -486,7 +486,7 @@ ds_dest_t *pack_dest(str iuri, int flags, int priority, str *attrs,
int dload)
/* Do a DNS-Lookup for the Host-Name, if not disabled via dst flags */
if(dp->flags & DS_NODNSARES_DST) {
dp->irmode |= DS_IRMODE_NOIPADDR;
- } else if (ds_dns_mode==DS_DNS_MODE_INIT || ds_dns_mode==DS_DNS_MODE_TIMER) {
+ } else if (ds_dns_mode & (DS_DNS_MODE_INIT|DS_DNS_MODE_TIMER)) {
he = resolvehost(hn);
if(he == 0) {
LM_ERR("could not resolve %.*s (missing no-probing flag?!?)\n",
diff --git a/src/modules/dispatcher/dispatch.h b/src/modules/dispatcher/dispatch.h
index 36e01e96ef..0d79386906 100644
--- a/src/modules/dispatcher/dispatch.h
+++ b/src/modules/dispatcher/dispatch.h
@@ -74,9 +74,9 @@
#define DS_IRMODE_NOIPADDR 1
-#define DS_DNS_MODE_INIT 0
-#define DS_DNS_MODE_ALWAYS 1
-#define DS_DNS_MODE_TIMER 2
+#define DS_DNS_MODE_INIT 1
+#define DS_DNS_MODE_ALWAYS (1<<1)
+#define DS_DNS_MODE_TIMER (1<<2)
/* clang-format on */
typedef struct ds_rctx {
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index 6317334fba..6a1b88c484 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -120,7 +120,8 @@ int ds_hash_check_interval = 30;
int ds_timer_mode = 0;
int ds_attrs_none = 0;
int ds_load_mode = 0;
-int ds_dns_mode = 0;
+uint32_t ds_dns_mode = DS_DNS_INIT;
+static int ds_dns_mode_param = 0;
str ds_outbound_proxy = STR_NULL;
@@ -297,7 +298,7 @@ static param_export_t params[]={
{"ds_db_extra_attrs", PARAM_STR, &ds_db_extra_attrs},
{"ds_load_mode", PARAM_INT, &ds_load_mode},
{"reload_delta", PARAM_INT, &ds_reload_delta },
- {"ds_dns_mode", PARAM_INT, &ds_dns_mode},
+ {"ds_dns_mode", PARAM_INT, &ds_dns_mode_param},
{0,0,0}
};
@@ -327,11 +328,7 @@ static int mod_init(void)
param_hooks_t phooks;
param_t *pit = NULL;
- if(ds_dns_mode!=DS_DNS_MODE_INIT && ds_dns_mode!=DS_DNS_MODE_ALWAYS
- && ds_dns_mode!=DS_DNS_MODE_TIMER) {
- LM_ERR("invalid dns mode %d\n", ds_dns_mode);
- return -1;
- }
+ ds_dns_mode = 1U<<(unsigned int)ds_dns_mode_param;
if(ds_ping_active_init() < 0) {
return -1;