[sr-dev] git:master:45d42958: lcr: fix rpc output of lcr.dump_gws

Ovidiu Sas osas at voipembedded.com
Thu Apr 11 16:58:17 CEST 2019


Module: kamailio
Branch: master
Commit: 45d4295829a436248419cfce3fd534b39efd0dcd
URL: https://github.com/kamailio/kamailio/commit/45d4295829a436248419cfce3fd534b39efd0dcd

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at 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/45d4295829a436248419cfce3fd534b39efd0dcd.diff
Patch: https://github.com/kamailio/kamailio/commit/45d4295829a436248419cfce3fd534b39efd0dcd.patch

---

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);




More information about the sr-dev mailing list