Module: kamailio Branch: master Commit: f5628c8cb2d0d0603d56487ce47350914869ec1e URL: https://github.com/kamailio/kamailio/commit/f5628c8cb2d0d0603d56487ce4735091...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-07-06T10:21:27+02:00
uac: exported cfg function uac_reg_refresh(luuid)
---
Modified: src/modules/uac/uac.c Modified: src/modules/uac/uac_reg.c Modified: src/modules/uac/uac_reg.h
---
Diff: https://github.com/kamailio/kamailio/commit/f5628c8cb2d0d0603d56487ce4735091... Patch: https://github.com/kamailio/kamailio/commit/f5628c8cb2d0d0603d56487ce4735091...
---
diff --git a/src/modules/uac/uac.c b/src/modules/uac/uac.c index 812602e7ef..3b3e22c0a5 100644 --- a/src/modules/uac/uac.c +++ b/src/modules/uac/uac.c @@ -101,6 +101,7 @@ 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); static int w_uac_reg_disable(struct sip_msg* msg, char* pfilter, char* pval); +static int w_uac_reg_refresh(struct sip_msg* msg, char* pluuid, char* p2); static int mod_init(void); static void mod_destroy(void); static int child_init(int rank); @@ -136,10 +137,12 @@ static cmd_export_t cmds[]={ {"uac_reg_request_to", (cmd_function)w_uac_reg_request_to, 2, fixup_spve_igp, fixup_free_spve_igp, REQUEST_ROUTE | FAILURE_ROUTE | BRANCH_ROUTE }, - {"uac_reg_enable", (cmd_function)w_uac_reg_enable, 1, fixup_spve_spve, + {"uac_reg_enable", (cmd_function)w_uac_reg_enable, 2, fixup_spve_spve, fixup_free_spve_spve, ANY_ROUTE }, - {"uac_reg_disable", (cmd_function)w_uac_reg_disable, 1, fixup_spve_spve, + {"uac_reg_disable", (cmd_function)w_uac_reg_disable, 2, fixup_spve_spve, fixup_free_spve_spve, ANY_ROUTE }, + {"uac_reg_refresh", (cmd_function)w_uac_reg_refresh, 1, fixup_spve_null, + fixup_free_spve_null, ANY_ROUTE }, {"bind_uac", (cmd_function)bind_uac, 1, 0, 0, 0}, {0,0,0,0,0,0} }; @@ -659,6 +662,17 @@ static int w_uac_reg_disable(struct sip_msg* msg, char* pfilter, char* pval) return uac_reg_disable(msg, &sfilter, &sval); }
+static int w_uac_reg_refresh(struct sip_msg* msg, char* pluuid, char* p2) +{ + str sluuid; + + if(fixup_get_svalue(msg, (gparam_t*)pluuid, &sluuid)<0) { + LM_ERR("cannot get the local uuid parameter\n"); + return -1; + } + return uac_reg_refresh(msg, &sluuid); +} + static int w_uac_reg_request_to(struct sip_msg* msg, char* src, char* pmode) { str sval; @@ -775,6 +789,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_refresh"), + SR_KEMIP_INT, uac_reg_refresh, + { SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE, + SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE } + },
{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } } }; diff --git a/src/modules/uac/uac_reg.c b/src/modules/uac/uac_reg.c index 456d725cf4..559e6bd74a 100644 --- a/src/modules/uac/uac_reg.c +++ b/src/modules/uac/uac_reg.c @@ -1483,6 +1483,31 @@ int uac_reg_db_refresh(str *pl_uuid) return -1; }
+/** + * + */ +int uac_reg_refresh(sip_msg_t *msg, str *l_uuid) +{ + int ret; + + if(l_uuid==NULL || l_uuid->s==NULL || l_uuid->len<=0) { + LM_ERR("invalid parameters\n"); + return -1; + } + + ret = uac_reg_db_refresh(l_uuid); + if(ret==0) { + LM_WARN("record not found: %.*s\n", l_uuid->len, l_uuid->s); + return -1; + } else if(ret<0) { + LM_WARN("failed to refresh record: %.*s - check log messages\n", + l_uuid->len, l_uuid->s); + return -1; + } + + return 1; +} + /** * */ diff --git a/src/modules/uac/uac_reg.h b/src/modules/uac/uac_reg.h index f8d40b7e14..769966009b 100644 --- a/src/modules/uac/uac_reg.h +++ b/src/modules/uac/uac_reg.h @@ -57,5 +57,6 @@ int uac_reg_request_to(struct sip_msg *msg, str *src, unsigned int mode);
int uac_reg_enable(sip_msg_t *msg, str *attr, str *val); int uac_reg_disable(sip_msg_t *msg, str *attr, str *val); +int uac_reg_refresh(sip_msg_t *msg, str *l_uuid);
#endif