Skip to content

Commit

Permalink
Merge pull request #1749 from jchavanton/issue_1745
Browse files Browse the repository at this point in the history
acc_json: support for leg_info fields
  • Loading branch information
jchavanton committed Dec 3, 2018
2 parents 1894b37 + 60c8d90 commit 6f2e120
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/modules/acc_json/acc_json_mod.c
Expand Up @@ -160,6 +160,7 @@ static void destroy(void)

int acc_json_init(acc_init_info_t *inf)
{
LM_DBG(" init ...\n");
return 0;
}

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 6f2e120

Please sign in to comment.