Skip to content

Commit

Permalink
pv: new transformation {uri.duri}
Browse files Browse the repository at this point in the history
- return uri needed for destination address (e.g., sip:host:port;transport=tcp)
  • Loading branch information
miconda committed Aug 29, 2020
1 parent 4a3ad2b commit 564940f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/modules/pv/pv_trans.c
Expand Up @@ -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",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/pv/pv_trans.h
Expand Up @@ -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
Expand Down

0 comments on commit 564940f

Please sign in to comment.