Module: kamailio
Branch: master
Commit: 7cee6518421ed16b715d32a8b2ff6d222eac038b
URL:
https://github.com/kamailio/kamailio/commit/7cee6518421ed16b715d32a8b2ff6d2…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2021-05-07T08:00:34+02:00
uac: added uac_reg_lookup_uri() - do lookup for user in the uri
---
Modified: src/modules/uac/uac.c
---
Diff:
https://github.com/kamailio/kamailio/commit/7cee6518421ed16b715d32a8b2ff6d2…
Patch:
https://github.com/kamailio/kamailio/commit/7cee6518421ed16b715d32a8b2ff6d2…
---
diff --git a/src/modules/uac/uac.c b/src/modules/uac/uac.c
index 5f0a3ad635..c7e181dc7c 100644
--- a/src/modules/uac/uac.c
+++ b/src/modules/uac/uac.c
@@ -102,6 +102,7 @@ static int w_restore_to(struct sip_msg* msg, char* p1, char* p2);
static int w_uac_auth(struct sip_msg* msg, char* str, char* str2);
static int w_uac_auth_mode(struct sip_msg* msg, char* pmode, char* str2);
static int w_uac_reg_lookup(struct sip_msg* msg, char* src, char* dst);
+static int w_uac_reg_lookup_uri(struct sip_msg* msg, char* src, char* dst);
static int w_uac_reg_status(struct sip_msg* msg, char* src, char* dst);
static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* mode_s);
static int w_uac_reg_enable(struct sip_msg* msg, char* pfilter, char* pval);
@@ -142,6 +143,8 @@ static cmd_export_t cmds[]={
{"uac_req_send", (cmd_function)w_uac_req_send, 0, 0, 0, ANY_ROUTE},
{"uac_reg_lookup", (cmd_function)w_uac_reg_lookup, 2, fixup_spve_pvar,
fixup_free_spve_pvar, ANY_ROUTE },
+ {"uac_reg_lookup_uri", (cmd_function)w_uac_reg_lookup_uri, 2,
fixup_spve_pvar,
+ fixup_free_spve_pvar, ANY_ROUTE },
{"uac_reg_status", (cmd_function)w_uac_reg_status, 1, fixup_spve_null, 0,
ANY_ROUTE },
{"uac_reg_request_to", (cmd_function)w_uac_reg_request_to, 2,
@@ -666,6 +669,32 @@ static int ki_uac_reg_lookup(sip_msg_t* msg, str* userid, str* sdst)
return uac_reg_lookup(msg, userid, dpv, 0);
}
+static int w_uac_reg_lookup_uri(struct sip_msg* msg, char* src, char* dst)
+{
+ pv_spec_t *dpv;
+ str sval;
+
+ if(fixup_get_svalue(msg, (gparam_t*)src, &sval)<0) {
+ LM_ERR("cannot get the uuid parameter\n");
+ return -1;
+ }
+
+ dpv = (pv_spec_t*)dst;
+
+ return uac_reg_lookup(msg, &sval, dpv, 1);
+}
+
+static int ki_uac_reg_lookup_uri(sip_msg_t* msg, str* userid, str* sdst)
+{
+ pv_spec_t *dpv = NULL;
+ dpv = pv_cache_get(sdst);
+ if(dpv==NULL) {
+ LM_ERR("cannot get pv spec for [%.*s]\n", sdst->len, sdst->s);
+ return -1;
+ }
+ return uac_reg_lookup(msg, userid, dpv, 1);
+}
+
static int w_uac_reg_status(struct sip_msg* msg, char* src, char* p2)
{
str sval;
@@ -827,6 +856,11 @@ static sr_kemi_t sr_kemi_uac_exports[] = {
{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
},
+ { str_init("uac"), str_init("uac_reg_lookup_uri"),
+ SR_KEMIP_INT, ki_uac_reg_lookup_uri,
+ { SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
+ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+ },
{ str_init("uac"), str_init("uac_reg_status"),
SR_KEMIP_INT, ki_uac_reg_status,
{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,