[sr-dev] git:master:4c6abaf9: topos: fix missing xavu_field_contact_host evaluation for contact_mode 0

Henning Westerholt hw at skalatan.de
Thu Jul 8 17:00:36 CEST 2021


Module: kamailio
Branch: master
Commit: 4c6abaf9066aebbd304391dd6730cad7ee592611
URL: https://github.com/kamailio/kamailio/commit/4c6abaf9066aebbd304391dd6730cad7ee592611

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2021-07-08T14:57:27Z

topos: fix missing xavu_field_contact_host evaluation for contact_mode 0

- fix missing xavu_field_contact_host evaluation for contact_mode 0
- it works currently only for contact_mode 1 and 2, but not for default mode

---

Modified: src/modules/topos/tps_storage.c

---

Diff:  https://github.com/kamailio/kamailio/commit/4c6abaf9066aebbd304391dd6730cad7ee592611.diff
Patch: https://github.com/kamailio/kamailio/commit/4c6abaf9066aebbd304391dd6730cad7ee592611.patch

---

diff --git a/src/modules/topos/tps_storage.c b/src/modules/topos/tps_storage.c
index 6e88b35af3..b94a960340 100644
--- a/src/modules/topos/tps_storage.c
+++ b/src/modules/topos/tps_storage.c
@@ -411,13 +411,23 @@ int tps_storage_fill_contact(sip_msg_t *msg, tps_data_t *td, str *uuid, int dir,
 		*td->cp = '@';
 		td->cp++;
 
-		if (_tps_contact_host.len) {
-			/* using configured hostname in the contact header */
-			memcpy(td->cp, _tps_contact_host.s, _tps_contact_host.len);
-			td->cp += _tps_contact_host.len;
+		/* contact_host xavu takes preference */
+		if (_tps_xavu_cfg.len>0 && _tps_xavu_field_contact_host.len>0) {
+			vavu = xavu_get_child_with_sval(&_tps_xavu_cfg,
+					&_tps_xavu_field_contact_host);
+		}
+		if(vavu!=NULL && vavu->val.v.s.len>0) {
+			memcpy(td->cp, vavu->val.v.s.s, vavu->val.v.s.len);
+			td->cp += vavu->val.v.s.len;
 		} else {
-			memcpy(td->cp, puri.host.s, puri.host.len);
-			td->cp += puri.host.len;
+			if (_tps_contact_host.len) {
+				/* using configured hostname in the contact header */
+				memcpy(td->cp, _tps_contact_host.s, _tps_contact_host.len);
+				td->cp += _tps_contact_host.len;
+			} else {
+				memcpy(td->cp, puri.host.s, puri.host.len);
+				td->cp += puri.host.len;
+			}
 		}
 		if(puri.port.len>0) {
 			*td->cp = ':';




More information about the sr-dev mailing list