- allow use in KEMI scripting by pre-registering container result id via
modparam
... | ... |
@@ -47,6 +47,8 @@ static int w_phonenum_match_cn(struct sip_msg *msg, char *str1, char *str2, |
47 | 47 |
char *str3); |
48 | 48 |
static int phonenum_match(sip_msg_t *msg, str *tomatch, str *pvclass); |
49 | 49 |
|
50 |
+static int phonenum_resid_param(modparam_t type, void* val); |
|
51 |
+ |
|
50 | 52 |
/* clang-format off */ |
51 | 53 |
static pv_export_t mod_pvs[] = { |
52 | 54 |
{ {"phn", sizeof("phn")-1}, PVT_OTHER, pv_get_phonenum, 0, |
... | ... |
@@ -64,6 +66,7 @@ static cmd_export_t cmds[]={ |
64 | 66 |
|
65 | 67 |
static param_export_t params[]={ |
66 | 68 |
{"smode", PARAM_INT, &phonenum_smode}, |
69 |
+ {"resid", PARAM_STR|PARAM_USE_FUNC, &phonenum_resid_param}, |
|
67 | 70 |
{0, 0, 0} |
68 | 71 |
}; |
69 | 72 |
|
... | ... |
@@ -102,6 +105,22 @@ static void mod_destroy(void) |
102 | 105 |
phonenum_destroy_pv(); |
103 | 106 |
} |
104 | 107 |
|
108 |
+/** |
|
109 |
+ * |
|
110 |
+ */ |
|
111 |
+static int phonenum_resid_param(modparam_t type, void* val) |
|
112 |
+{ |
|
113 |
+ str rname; |
|
114 |
+ |
|
115 |
+ rname.s = (char*)val; |
|
116 |
+ rname.len = strlen(rname.s); |
|
117 |
+ if(sr_phonenum_add_resid(&rname) < 0) { |
|
118 |
+ LM_ERR("failed to register result container with id: %.*s\n", |
|
119 |
+ rname.len, rname.s); |
|
120 |
+ return -1; |
|
121 |
+ } |
|
122 |
+ return 0; |
|
123 |
+} |
|
105 | 124 |
|
106 | 125 |
static int phonenum_match(sip_msg_t *msg, str *tomatch, str *pvclass) |
107 | 126 |
{ |
... | ... |
@@ -111,6 +111,13 @@ sr_phonenum_item_t *sr_phonenum_add_item(str *name) |
111 | 111 |
return it; |
112 | 112 |
} |
113 | 113 |
|
114 |
+int sr_phonenum_add_resid(str *rname) |
|
115 |
+{ |
|
116 |
+ if(sr_phonenum_add_item(rname)==NULL) { |
|
117 |
+ return -1; |
|
118 |
+ } |
|
119 |
+ return 0; |
|
120 |
+} |
|
114 | 121 |
|
115 | 122 |
int pv_parse_phonenum_name(pv_spec_p sp, str *in) |
116 | 123 |
{ |