Module: kamailio
Branch: master
Commit: 2b27aba7f4f396e4ebd894255abfa8ce20950313
URL:
https://github.com/kamailio/kamailio/commit/2b27aba7f4f396e4ebd894255abfa8c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-11-28T13:22:35+01:00
topos: use defined values for internal contact mode
---
Modified: src/modules/topos/topos_mod.c
Modified: src/modules/topos/tps_msg.c
Modified: src/modules/topos/tps_storage.c
Modified: src/modules/topos/tps_storage.h
---
Diff:
https://github.com/kamailio/kamailio/commit/2b27aba7f4f396e4ebd894255abfa8c…
Patch:
https://github.com/kamailio/kamailio/commit/2b27aba7f4f396e4ebd894255abfa8c…
---
diff --git a/src/modules/topos/topos_mod.c b/src/modules/topos/topos_mod.c
index 8ea8bb39c7e..7bcb2fea3c9 100644
--- a/src/modules/topos/topos_mod.c
+++ b/src/modules/topos/topos_mod.c
@@ -123,7 +123,7 @@ static int _tps_eventrt_receiving = -1;
static str _tps_eventrt_receiving_name = str_init("topos:msg-receiving");
str _tps_contact_host = str_init("");
-int _tps_contact_mode = 0;
+int _tps_contact_mode = TPS_CONTACT_MODE_SKEYUSER;
str _tps_cparam_name = str_init("tps");
str _tps_xavu_cfg = STR_NULL;
@@ -310,7 +310,7 @@ static int mod_init(void)
if(sruid_init(&_tps_sruid, '-', "tpsh", SRUID_INC) < 0)
return -1;
- if(_tps_contact_mode == 2
+ if(_tps_contact_mode == TPS_CONTACT_MODE_XAVPUSER
&& (_tps_xavu_cfg.len <= 0 || _tps_xavu_field_acontact.len <= 0
|| _tps_xavu_field_bcontact.len <= 0)) {
LM_ERR("contact_mode parameter is 2,"
diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index 4d680e53f45..e0e1c211923 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -324,7 +324,8 @@ int tps_dlg_message_update(sip_msg_t *msg, tps_data_t *ptsd, int
ctmode)
return -1;
}
- if(ctmode == 1 || ctmode == 2) {
+ if(ctmode == TPS_CONTACT_MODE_RURIUSER
+ || ctmode == TPS_CONTACT_MODE_XAVPUSER) {
if(msg->parsed_uri.sip_params.len < TPS_TUUID_MIN_LEN) {
LM_DBG("not an expected param format\n");
return 1;
@@ -962,7 +963,9 @@ int tps_request_received(sip_msg_t *msg, int dialog)
LM_DBG("use branch for routing information, request from direction "
"%d\n",
direction);
- if(tps_reappend_route(msg, &stsd, &stsd.s_rr, (direction == TPS_DIR_UPSTREAM) ?
0 : 1) < 0) {
+ if(tps_reappend_route(msg, &stsd, &stsd.s_rr,
+ (direction == TPS_DIR_UPSTREAM) ? 0 : 1)
+ < 0) {
LM_ERR("failed to reappend s-route\n");
return -1;
}
diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index 63951386622..fc0c2835a33 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -244,7 +244,8 @@ int tps_storage_fill_contact(
if(_tps_contact_host.len)
contact_len = sv.len - puri.host.len + _tps_contact_host.len;
- if(ctmode == 1 || ctmode == 2) {
+ if(ctmode == TPS_CONTACT_MODE_RURIUSER
+ || ctmode == TPS_CONTACT_MODE_XAVPUSER) {
cparam_len = _tps_cparam_name.len;
} else {
cparam_len = 0;
@@ -285,9 +286,10 @@ int tps_storage_fill_contact(
if(sv.s[i] == ':')
break;
}
- if(ctmode == 1 || ctmode == 2) {
+ if(ctmode == TPS_CONTACT_MODE_RURIUSER
+ || ctmode == TPS_CONTACT_MODE_XAVPUSER) {
/* create new URI parameter for Contact header */
- if(ctmode == 1) {
+ if(ctmode == TPS_CONTACT_MODE_RURIUSER) {
if(dir == TPS_DIR_DOWNSTREAM) {
/* extract the contact address */
if(parse_headers(msg, HDR_CONTACT_F, 0) < 0
@@ -332,7 +334,7 @@ int tps_storage_fill_contact(
msg->parsed_uri.user.len);
td->cp += msg->parsed_uri.user.len;
}
- } else if(ctmode == 2) {
+ } else if(ctmode == TPS_CONTACT_MODE_XAVPUSER) {
if(dir == TPS_DIR_DOWNSTREAM) {
/* extract the a contact */
vavu = xavu_get_child_with_sval(
@@ -356,8 +358,8 @@ int tps_storage_fill_contact(
}
}
- if(!((ctmode == 1) && (dir == TPS_DIR_DOWNSTREAM)
- && (curi.user.len <= 0))) {
+ if(!((ctmode == TPS_CONTACT_MODE_RURIUSER)
+ && (dir == TPS_DIR_DOWNSTREAM) && (curi.user.len <= 0))) {
*td->cp = '@';
td->cp++;
}
diff --git a/src/modules/topos/tps_storage.h b/src/modules/topos/tps_storage.h
index 4c2585a1ff6..245a1595652 100644
--- a/src/modules/topos/tps_storage.h
+++ b/src/modules/topos/tps_storage.h
@@ -37,6 +37,10 @@
#define TPS_IFLAG_INIT 1
#define TPS_IFLAG_DLGON 2
+#define TPS_CONTACT_MODE_SKEYUSER 0
+#define TPS_CONTACT_MODE_RURIUSER 1
+#define TPS_CONTACT_MODE_XAVPUSER 2
+
#define TPS_DBU_CONTACT (1 << 0)
#define TPS_DBU_RPLATTRS (1 << 1)
#define TPS_DBU_ARR (1 << 2)