Module: kamailio
Branch: master
Commit: 8aeaee0fda4013e1fe0477ce1dcb31738dc18aea
URL:
https://github.com/kamailio/kamailio/commit/8aeaee0fda4013e1fe0477ce1dcb317…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-08-31T09:37:45+02:00
pv: new transformation {uri.saor}
- return sip aor (sip:[user@]domain)
---
Modified: src/modules/pv/pv_trans.c
Modified: src/modules/pv/pv_trans.h
---
Diff:
https://github.com/kamailio/kamailio/commit/8aeaee0fda4013e1fe0477ce1dcb317…
Patch:
https://github.com/kamailio/kamailio/commit/8aeaee0fda4013e1fe0477ce1dcb317…
---
diff --git a/src/modules/pv/pv_trans.c b/src/modules/pv/pv_trans.c
index 91e9bca516..4de9849165 100644
--- a/src/modules/pv/pv_trans.c
+++ b/src/modules/pv/pv_trans.c
@@ -1409,6 +1409,7 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
val->rs = (_tr_parsed_uri.passwd.s)?_tr_parsed_uri.passwd:_tr_empty;
break;
case TR_URI_DURI:
+ case TR_URI_SAOR:
case TR_URI_SURI:
if(_tr_uri.len >= TR_BUFFER_SIZE) {
LM_WARN("uri too long [%.*s] (%d)\n",
@@ -1436,7 +1437,8 @@ 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(subtype == TR_URI_SURI && _tr_parsed_uri.user.len > 0) {
+ if((_tr_parsed_uri.user.len > 0)
+ && (subtype != TR_URI_DURI)) {
memcpy(sv.s + sv.len, _tr_parsed_uri.user.s,
_tr_parsed_uri.user.len);
sv.len += _tr_parsed_uri.user.len;
@@ -1448,19 +1450,21 @@ int tr_eval_uri(struct sip_msg *msg, tr_param_t *tp, int subtype,
_tr_parsed_uri.host.len);
sv.len += _tr_parsed_uri.host.len;
}
- if(_tr_parsed_uri.port.len > 0) {
- sv.s[sv.len] = ':';
- sv.len++;
- memcpy(sv.s + sv.len, _tr_parsed_uri.port.s,
- _tr_parsed_uri.port.len);
- sv.len += _tr_parsed_uri.port.len;
- }
- if(_tr_parsed_uri.transport_val.len > 0) {
- memcpy(sv.s + sv.len, ";transport=", 11);
- sv.len += 11;
- memcpy(sv.s + sv.len, _tr_parsed_uri.transport_val.s,
- _tr_parsed_uri.transport_val.len);
- sv.len += _tr_parsed_uri.transport_val.len;
+ if(subtype != TR_URI_SAOR) {
+ if(_tr_parsed_uri.port.len > 0) {
+ sv.s[sv.len] = ':';
+ sv.len++;
+ memcpy(sv.s + sv.len, _tr_parsed_uri.port.s,
+ _tr_parsed_uri.port.len);
+ sv.len += _tr_parsed_uri.port.len;
+ }
+ if(_tr_parsed_uri.transport_val.len > 0) {
+ memcpy(sv.s + sv.len, ";transport=", 11);
+ sv.len += 11;
+ memcpy(sv.s + sv.len, _tr_parsed_uri.transport_val.s,
+ _tr_parsed_uri.transport_val.len);
+ sv.len += _tr_parsed_uri.transport_val.len;
+ }
}
sv.s[sv.len] = '\0';
val->rs = sv;
@@ -2845,6 +2849,9 @@ char* tr_parse_uri(str* in, trans_t *t)
} else if(name.len==4 && strncasecmp(name.s, "port", 4)==0) {
t->subtype = TR_URI_PORT;
goto done;
+ } else if(name.len==4 && strncasecmp(name.s, "saor", 4)==0) {
+ t->subtype = TR_URI_SAOR;
+ goto done;
} else if(name.len==4 && strncasecmp(name.s, "suri", 4)==0) {
t->subtype = TR_URI_SURI;
goto done;
diff --git a/src/modules/pv/pv_trans.h b/src/modules/pv/pv_trans.h
index d15df89057..c587464bed 100644
--- a/src/modules/pv/pv_trans.h
+++ b/src/modules/pv/pv_trans.h
@@ -50,7 +50,8 @@ 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_DURI, TR_URI_SURI
+ TR_URI_R2, TR_URI_SCHEME, TR_URI_TOSOCKET, TR_URI_SAOR, 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