Module: kamailio Branch: master Commit: 45d4295829a436248419cfce3fd534b39efd0dcd URL: https://github.com/kamailio/kamailio/commit/45d4295829a436248419cfce3fd534b3...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: 2019-04-11T09:57:35-05:00
lcr: fix rpc output of lcr.dump_gws
---
Modified: src/modules/lcr/lcr_rpc.c
---
Diff: https://github.com/kamailio/kamailio/commit/45d4295829a436248419cfce3fd534b3... Patch: https://github.com/kamailio/kamailio/commit/45d4295829a436248419cfce3fd534b3...
---
diff --git a/src/modules/lcr/lcr_rpc.c b/src/modules/lcr/lcr_rpc.c index ef5b351e6c..8aeb80c98f 100644 --- a/src/modules/lcr/lcr_rpc.c +++ b/src/modules/lcr/lcr_rpc.c @@ -51,6 +51,8 @@ static const char *dump_gws_doc[2] = {"Dump the contents of lcr_gws table.", 0}; static void dump_gws(rpc_t *rpc, void *c) { void *st; + void *rec = NULL; + void *srec = NULL; unsigned int i, j; str scheme, gw_name, hostname, params, transport; str prefix, tag; @@ -63,7 +65,14 @@ static void dump_gws(rpc_t *rpc, void *c) gws = gw_pt[j];
for(i = 1; i <= gws[0].ip_addr.u.addr32[0]; i++) { - if(rpc->add(c, "{", &st) < 0) + if (srec==NULL) { + /* We create one array per lcr_id */ + if(rpc->add(c, "{", &rec) < 0) + return; + if(rpc->struct_add(rec, "[", "gw", &srec) < 0) + return; + } + if(rpc->array_add(srec, "{", &st) < 0) return; rpc->struct_add(st, "d", "lcr_id", j); rpc->struct_add(st, "d", "gw_id", gws[i].gw_id);