Module: kamailio Branch: master Commit: 67412b4b2b377cca179de2ebe109bd56fb8a63b9 URL: https://github.com/kamailio/kamailio/commit/67412b4b2b377cca179de2ebe109bd56...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2019-09-02T13:41:03+02:00
phonenum: new param resid to register result container ids
- allow use in KEMI scripting by pre-registering container result id via modparam
---
Modified: src/modules/phonenum/phonenum_mod.c Modified: src/modules/phonenum/phonenum_pv.c Modified: src/modules/phonenum/phonenum_pv.h
---
Diff: https://github.com/kamailio/kamailio/commit/67412b4b2b377cca179de2ebe109bd56... Patch: https://github.com/kamailio/kamailio/commit/67412b4b2b377cca179de2ebe109bd56...
---
diff --git a/src/modules/phonenum/phonenum_mod.c b/src/modules/phonenum/phonenum_mod.c index eaaa43c1aa..6c9e0b1d1b 100644 --- a/src/modules/phonenum/phonenum_mod.c +++ b/src/modules/phonenum/phonenum_mod.c @@ -47,6 +47,8 @@ static int w_phonenum_match_cn(struct sip_msg *msg, char *str1, char *str2, char *str3); static int phonenum_match(sip_msg_t *msg, str *tomatch, str *pvclass);
+static int phonenum_resid_param(modparam_t type, void* val); + /* clang-format off */ static pv_export_t mod_pvs[] = { { {"phn", sizeof("phn")-1}, PVT_OTHER, pv_get_phonenum, 0, @@ -64,6 +66,7 @@ static cmd_export_t cmds[]={
static param_export_t params[]={ {"smode", PARAM_INT, &phonenum_smode}, + {"resid", PARAM_STR|PARAM_USE_FUNC, &phonenum_resid_param}, {0, 0, 0} };
@@ -102,6 +105,22 @@ static void mod_destroy(void) phonenum_destroy_pv(); }
+/** + * + */ +static int phonenum_resid_param(modparam_t type, void* val) +{ + str rname; + + rname.s = (char*)val; + rname.len = strlen(rname.s); + if(sr_phonenum_add_resid(&rname) < 0) { + LM_ERR("failed to register result container with id: %.*s\n", + rname.len, rname.s); + return -1; + } + return 0; +}
static int phonenum_match(sip_msg_t *msg, str *tomatch, str *pvclass) { diff --git a/src/modules/phonenum/phonenum_pv.c b/src/modules/phonenum/phonenum_pv.c index a34382239a..6115d9daad 100644 --- a/src/modules/phonenum/phonenum_pv.c +++ b/src/modules/phonenum/phonenum_pv.c @@ -111,6 +111,13 @@ sr_phonenum_item_t *sr_phonenum_add_item(str *name) return it; }
+int sr_phonenum_add_resid(str *rname) +{ + if(sr_phonenum_add_item(rname)==NULL) { + return -1; + } + return 0; +}
int pv_parse_phonenum_name(pv_spec_p sp, str *in) { diff --git a/src/modules/phonenum/phonenum_pv.h b/src/modules/phonenum/phonenum_pv.h index b56d6f47dd..938bbac297 100644 --- a/src/modules/phonenum/phonenum_pv.h +++ b/src/modules/phonenum/phonenum_pv.h @@ -34,6 +34,7 @@ int phonenum_init_pv(int smode); void phonenum_destroy_pv(void); void phonenum_pv_reset(str *pvclass); int phonenum_update_pv(str *tomatch, str *cncode, str *pvclass); +int sr_phonenum_add_resid(str *rname);
#endif