[sr-dev] git:master:564940f5: pv: new transformation {uri.duri}

Daniel-Constantin Mierla miconda at gmail.com
Sat Aug 29 20:05:46 CEST 2020


Module: kamailio
Branch: master
Commit: 564940f5ef923df7935a7b737a70e25c0d5f6a7b
URL: https://github.com/kamailio/kamailio/commit/564940f5ef923df7935a7b737a70e25c0d5f6a7b

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-08-29T19:45:20+02:00

pv: new transformation {uri.duri}

- return uri needed for destination address (e.g., sip:host:port;transport=tcp)

---

Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h

---

Diff:  https://github.com/kamailio/kamailio/commit/564940f5ef923df7935a7b737a70e25c0d5f6a7b.diff
Patch: https://github.com/kamailio/kamailio/commit/564940f5ef923df7935a7b737a70e25c0d5f6a7b.patch

---

diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index b9eb291b99..91e9bca516 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -1408,6 +1408,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 		case TR_URI_PASSWD:
 			val->rs = (_tr_parsed_uri.passwd.s)?_tr_parsed_uri.passwd:_tr_empty;
 			break;
+		case TR_URI_DURI:
 		case TR_URI_SURI:
 			if(_tr_uri.len >= TR_BUFFER_SIZE) {
 				LM_WARN("uri too long [%.*s] (%d)\n",
@@ -1435,7 +1436,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
 			memcpy(_tr_buffer, sv.s, sv.len);
 			sv.s = _tr_buffer;
 			sv.len++;
-			if(_tr_parsed_uri.user.len > 0) {
+			if(subtype == TR_URI_SURI && _tr_parsed_uri.user.len > 0) {
 				memcpy(sv.s + sv.len, _tr_parsed_uri.user.s,
 						_tr_parsed_uri.user.len);
 				sv.len += _tr_parsed_uri.user.len;
@@ -2847,6 +2848,9 @@ char* tr_parse_uri(str* in, trans_t *t)
 	} else if(name.len==4 && strncasecmp(name.s, "suri", 4)==0) {
 		t->subtype = TR_URI_SURI;
 		goto done;
+	} else if(name.len==4 && strncasecmp(name.s, "duri", 4)==0) {
+		t->subtype = TR_URI_DURI;
+		goto done;
 	} else if(name.len==6 && strncasecmp(name.s, "params", 6)==0) {
 		t->subtype = TR_URI_PARAMS;
 		goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index bf4c922243..d15df89057 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -50,7 +50,7 @@ enum _tr_uri_subtype {
 	TR_URI_NONE=0, TR_URI_USER, TR_URI_HOST, TR_URI_PASSWD, TR_URI_PORT,
 	TR_URI_PARAMS, TR_URI_PARAM, TR_URI_HEADERS, TR_URI_TRANSPORT, TR_URI_TTL,
 	TR_URI_UPARAM, TR_URI_MADDR, TR_URI_METHOD, TR_URI_LR,
-	TR_URI_R2, TR_URI_SCHEME, TR_URI_TOSOCKET, TR_URI_SURI
+	TR_URI_R2, TR_URI_SCHEME, TR_URI_TOSOCKET, TR_URI_DURI, TR_URI_SURI
 };
 enum _tr_param_subtype {
 	TR_PL_NONE=0, TR_PL_VALUE, TR_PL_VALUEAT, TR_PL_NAME, TR_PL_COUNT




More information about the sr-dev mailing list