Module: kamailio
Branch: master
Commit: 6f2e12039ef341b1dcb88c77272d2e9f0f53f252
URL:
https://github.com/kamailio/kamailio/commit/6f2e12039ef341b1dcb88c77272d2e9…
Author: Julien Chavanton <jchavanton(a)gmail.com>
Committer: GitHub <noreply(a)github.com>
Date: 2018-12-03T10:17:46-08:00
Merge pull request #1749 from jchavanton/issue_1745
acc_json: support for leg_info fields
---
Modified: src/modules/acc_json/acc_json_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/6f2e12039ef341b1dcb88c77272d2e9…
Patch:
https://github.com/kamailio/kamailio/commit/6f2e12039ef341b1dcb88c77272d2e9…
---
diff --git a/src/modules/acc_json/acc_json_mod.c b/src/modules/acc_json/acc_json_mod.c
index 908d7d0eb9..ee3f84bf6b 100644
--- a/src/modules/acc_json/acc_json_mod.c
+++ b/src/modules/acc_json/acc_json_mod.c
@@ -160,6 +160,7 @@ static void destroy(void)
int acc_json_init(acc_init_info_t *inf)
{
+ LM_DBG(" init ...\n");
return 0;
}
@@ -246,6 +247,27 @@ int acc_json_send_request(struct sip_msg *req, acc_info_t *inf)
extra = extra->next;
}
+ /* add leginfo fields */
+ if(inf->leg_info) {
+ o = accb.get_leg_attrs(inf->leg_info, req, inf->varr + attr_cnt,
+ inf->iarr + attr_cnt, inf->tarr + attr_cnt, 1);
+ attr_cnt += o;
+ m = attr_cnt;
+
+ struct acc_extra *leg_info = inf->leg_info;
+ for(; i < m; i++) {
+ LM_DBG("[%d][%s][%.*s]\n", i, leg_info->name.s, inf->varr[i].len,
+ inf->varr[i].s);
+ char *tmp = strndup(inf->varr[i].s, inf->varr[i].len);
+ json_t *value = json_string(tmp);
+ if(!value)
+ value = json_string("NON-UTF8");
+ json_object_set_new(object, leg_info->name.s, value);
+ free(tmp);
+ leg_info = leg_info->next;
+ }
+ }
+
if(object) {
if(json_object_size(object) == 0) {
LM_ERR("json object empty\n");