Module: kamailio Branch: master Commit: 974038f5f81382fe6fa6565f0ab9ea0f2cf9896f URL: https://github.com/kamailio/kamailio/commit/974038f5f81382fe6fa6565f0ab9ea0f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2020-06-05T09:39:50+02:00
pv: vars to get the length for o-uri/r-uri/f-uri/t-uri username
- $oUl, $rUl, $fUl. $tUl - the length is already available in the str value, optimizing a bit by no longer having to use {s.len}
---
Modified: src/modules/pv/pv.c Modified: src/modules/pv/pv_core.c
---
Diff: https://github.com/kamailio/kamailio/commit/974038f5f81382fe6fa6565f0ab9ea0f... Patch: https://github.com/kamailio/kamailio/commit/974038f5f81382fe6fa6565f0ab9ea0f...
---
diff --git a/src/modules/pv/pv.c b/src/modules/pv/pv.c index 0308514e70..4d3d8b343c 100644 --- a/src/modules/pv/pv.c +++ b/src/modules/pv/pv.c @@ -272,6 +272,9 @@ static pv_export_t mod_pvs[] = { {{"from.user", (sizeof("from.user")-1)}, /* */ PVT_OTHER, pv_get_from_attr, pv_set_from_username, 0, 0, pv_init_iname, 2}, + {{"fUl", (sizeof("fUl")-1)}, /* */ + PVT_OTHER, pv_get_from_attr, 0, + 0, 0, pv_init_iname, 6}, {{"mb", (sizeof("mb")-1)}, /* */ PVT_OTHER, pv_get_msg_buf, 0, 0, 0, 0, 0}, @@ -314,6 +317,9 @@ static pv_export_t mod_pvs[] = { {{"oU", (sizeof("oU")-1)}, /* */ PVT_OTHER, pv_get_ouri_attr, 0, 0, 0, pv_init_iname, 1}, + {{"oUl", (sizeof("oUl")-1)}, /* */ + PVT_OTHER, pv_get_ouri_attr, 0, + 0, 0, pv_init_iname, 6}, {{"pd", (sizeof("pd")-1)}, /* */ PVT_OTHER, pv_get_ppi_attr, 0, 0, pv_parse_index, pv_init_iname, 3}, @@ -383,6 +389,9 @@ static pv_export_t mod_pvs[] = { {{"ruri.user", (sizeof("ruri.user")-1)}, /* */ PVT_RURI_USERNAME, pv_get_ruri_attr, pv_set_ruri_user, 0, 0, pv_init_iname, 1}, + {{"rUl", (sizeof("rUl")-1)}, /* */ + PVT_RURI_USERNAME, pv_get_ruri_attr, 0, + 0, 0, pv_init_iname, 6}, {{"rv", (sizeof("rv")-1)}, /* */ PVT_OTHER, pv_get_version, 0, 0, 0, 0, 0}, @@ -470,6 +479,9 @@ static pv_export_t mod_pvs[] = { {{"to.user", (sizeof("to.user")-1)}, /* */ PVT_OTHER, pv_get_to_attr, pv_set_to_username, 0, 0, pv_init_iname, 2}, + {{"tUl", (sizeof("tUl")-1)}, /* */ + PVT_OTHER, pv_get_to_attr, pv_set_to_username, + 0, 0, pv_init_iname, 6}, {{"true", (sizeof("true")-1)}, /* */ PVT_OTHER, pv_get_true, 0, 0, 0, 0, 0}, diff --git a/src/modules/pv/pv_core.c b/src/modules/pv/pv_core.c index ae91aa9d82..7b28fb966e 100644 --- a/src/modules/pv/pv_core.c +++ b/src/modules/pv/pv_core.c @@ -323,6 +323,10 @@ int pv_get_xuri_attr(struct sip_msg *msg, struct sip_uri *parsed_uri, } else if(param->pvn.u.isname.name.n==5) /* uri scheme */ { return pv_get_strintval(msg, param, res, &pv_uri_scheme[parsed_uri->type], (int)parsed_uri->type); + } else if(param->pvn.u.isname.name.n==6) /* username length */ { + if(parsed_uri->user.s==NULL || parsed_uri->user.len<=0) + return pv_get_sintval(msg, param, res, 0); + return pv_get_sintval(msg, param, res, parsed_uri->user.len); } LM_ERR("unknown specifier\n"); return pv_get_null(msg, param, res); @@ -452,6 +456,11 @@ int pv_get_xto_attr(struct sip_msg *msg, pv_param_t *param, return pv_get_null(msg, param, res); } return pv_get_strval(msg, param, res, &uri->host); + } else if(param->pvn.u.isname.name.n==6) /* username length */ { + if(uri->user.s==NULL || uri->user.len<=0) { + return pv_get_sintval(msg, param, res, 0); + } + return pv_get_sintval(msg, param, res, uri->user.len); }
LM_ERR("unknown specifier\n");