Module: kamailio
Branch: master
Commit: ef7f784e70087abd8dec22a899eb7c544e9d981d
URL:
https://github.com/kamailio/kamailio/commit/ef7f784e70087abd8dec22a899eb7c5…
Author: Stefan Mititelu <stefan-cristian.mititelu(a)1and1.ro>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-04-07T19:20:35+02:00
p_usrloc: make UTC param runtime configurable
---
Modified: src/modules/p_usrloc/config.c
Modified: src/modules/p_usrloc/config.h
Modified: src/modules/p_usrloc/p_usrloc_mod.c
Modified: src/modules/p_usrloc/p_usrloc_mod.h
---
Diff:
https://github.com/kamailio/kamailio/commit/ef7f784e70087abd8dec22a899eb7c5…
Patch:
https://github.com/kamailio/kamailio/commit/ef7f784e70087abd8dec22a899eb7c5…
---
diff --git a/src/modules/p_usrloc/config.c b/src/modules/p_usrloc/config.c
index bf24a97229..c95be9ec70 100644
--- a/src/modules/p_usrloc/config.c
+++ b/src/modules/p_usrloc/config.c
@@ -35,7 +35,8 @@ struct cfg_group_p_usrloc default_p_usrloc_cfg = {
DEFAULT_FAILOVER_LEVEL, /* failover_level */
0, /* db_ops_ruid */
1, /* db_update_as_insert */
- CONTACT_ONLY /* matching_mode */
+ CONTACT_ONLY, /* matching_mode */
+ 0, /* utc_timestamps */
};
void *p_usrloc_cfg = &default_p_usrloc_cfg;
@@ -53,5 +54,7 @@ cfg_def_t p_usrloc_cfg_def[] = {
"Set this parameter if you want to do INSERT DB operations instead of UPDATE DB
operations. "},
{"matching_mode", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
"Specified which contact maching algorithm to be used (0 - Contact only / 1 -
Contact and Call-ID / 2 - Contact and Path)"},
+ {"utc_timestamps", CFG_VAR_INT | CFG_ATOMIC, 0, 0, 0, 0,
+ "Expires and last_modified timestamps in UTC time format"},
{0, 0, 0, 0, 0, 0}
};
diff --git a/src/modules/p_usrloc/config.h b/src/modules/p_usrloc/config.h
index 42e16cb6b4..396bcded49 100644
--- a/src/modules/p_usrloc/config.h
+++ b/src/modules/p_usrloc/config.h
@@ -33,6 +33,7 @@ struct cfg_group_p_usrloc {
unsigned int db_ops_ruid;
unsigned int db_update_as_insert;
unsigned int matching_mode;
+ unsigned int utc_timestamps;
};
extern struct cfg_group_p_usrloc default_p_usrloc_cfg;
diff --git a/src/modules/p_usrloc/p_usrloc_mod.c b/src/modules/p_usrloc/p_usrloc_mod.c
index b29f4e7e18..89d053d278 100644
--- a/src/modules/p_usrloc/p_usrloc_mod.c
+++ b/src/modules/p_usrloc/p_usrloc_mod.c
@@ -148,7 +148,6 @@ str uniq_col = str_init(UNIQ_COL); /*!< Name of column
containing the un
int db_mode = 3; /*!< Database sync scheme: 1-write through, 2-write back,
3-only db */
int use_domain = 0; /*!< Whether usrloc should use domain part of aor */
int desc_time_order = 0; /*!< By default do not enable timestamp ordering */
-int ul_UTC_timestamps = 0; /*!< If set to 1 use UTC instead of local time for
expires and last_modified */
int ul_fetch_rows = 2000; /*!< number of rows to fetch from result */
int ul_hash_size = 9;
@@ -241,7 +240,7 @@ static param_export_t params[] = {
{"error_column", PARAM_STR, &error_col },
{"risk_group_column", PARAM_STR, &risk_group_col },
{"expire_time", INT_PARAM, &default_p_usrloc_cfg.expire_time},
- {"UTC_timestamps", INT_PARAM, &ul_UTC_timestamps},
+ {"UTC_timestamps", INT_PARAM,
&default_p_usrloc_cfg.utc_timestamps},
{"db_err_threshold", INT_PARAM,
&default_p_usrloc_cfg.db_err_threshold},
{"failover_level", INT_PARAM,
&default_p_usrloc_cfg.failover_level},
{"db_retry_interval", INT_PARAM, &retry_interval },
@@ -484,7 +483,7 @@ struct mi_root* mi_loc_nr_refresh(struct mi_root* cmd_tree, void*
param) {
#endif
time_t ul_db_datetime_set(time_t v) {
- if (ul_UTC_timestamps == 1) {
+ if (cfg_get(p_usrloc, p_usrloc_cfg, utc_timestamps) == 1) {
return local2utc(v);
} else {
return v;
@@ -492,7 +491,7 @@ time_t ul_db_datetime_set(time_t v) {
}
time_t ul_db_datetime_get(time_t v) {
- if (ul_UTC_timestamps == 1) {
+ if (cfg_get(p_usrloc, p_usrloc_cfg, utc_timestamps) == 1) {
return utc2local(v);
} else {
return v;
diff --git a/src/modules/p_usrloc/p_usrloc_mod.h b/src/modules/p_usrloc/p_usrloc_mod.h
index eb87b7a608..bfdcc2f45c 100644
--- a/src/modules/p_usrloc/p_usrloc_mod.h
+++ b/src/modules/p_usrloc/p_usrloc_mod.h
@@ -92,7 +92,6 @@ extern int desc_time_order;
extern int cseq_delay;
extern int ul_fetch_rows;
extern int ul_hash_size;
-extern int ul_UTC_timestamps;
extern str default_db_url;