[sr-dev] git:master:20a4f7e0: permissions: fixed rpc array

Kelvin Chua kelchy at gmail.com
Mon Aug 22 09:37:18 CEST 2016


Module: kamailio
Branch: master
Commit: 20a4f7e029262a94c5c4bcdc68a90e404b506c98
URL: https://github.com/kamailio/kamailio/commit/20a4f7e029262a94c5c4bcdc68a90e404b506c98

Author: Kelvin Chua <kelchy at gmail.com>
Committer: Kelvin Chua <kelchy at gmail.com>
Date: 2016-08-20T15:03:09Z

permissions: fixed rpc array

- added array structure when returning multiple address and subnets

---

Modified: modules/permissions/hash.c
Modified: modules/permissions/permissions.c

---

Diff:  https://github.com/kamailio/kamailio/commit/20a4f7e029262a94c5c4bcdc68a90e404b506c98.diff
Patch: https://github.com/kamailio/kamailio/commit/20a4f7e029262a94c5c4bcdc68a90e404b506c98.patch

---

diff --git a/modules/permissions/hash.c b/modules/permissions/hash.c
index 9f90bac..e8824f2 100644
--- a/modules/permissions/hash.c
+++ b/modules/permissions/hash.c
@@ -612,15 +612,15 @@ int addr_hash_table_rpc_print(struct addr_list** table, rpc_t* rpc, void* c)
 	struct addr_list *np;
 
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
-		rpc->fault(c, 500, "Internal error creating rpc");
-		return -1;
-	}
-
 	for (i = 0; i < PERM_HASH_SIZE; i++) {
 		np = table[i];
 		while (np) {
+			if (rpc->add(c, "{", &th) < 0)
+			{
+				rpc->fault(c, 500, "Internal error creating rpc");
+				return -1;
+			}
+
 			if(rpc->struct_add(th, "dd{",
 						"table", i,
 						"group", np->grp,
@@ -847,13 +847,13 @@ int subnet_table_rpc_print(struct subnet* table, rpc_t* rpc, void* c)
 
 	count = table[PERM_MAX_SUBNETS].grp;
 
-	if (rpc->add(c, "{", &th) < 0)
-	{
-		rpc->fault(c, 500, "Internal error creating rpc");
-		return -1;
-	}
-
 	for (i = 0; i < count; i++) {
+		if (rpc->add(c, "{", &th) < 0)
+		{
+			rpc->fault(c, 500, "Internal error creating rpc");
+			return -1;
+		}
+
 		if(rpc->struct_add(th, "dd{",
 					"id", i,
 					"group", table[i].grp,
diff --git a/modules/permissions/permissions.c b/modules/permissions/permissions.c
index b935e37..0445fbb 100644
--- a/modules/permissions/permissions.c
+++ b/modules/permissions/permissions.c
@@ -1016,8 +1016,8 @@ rpc_export_t permissions_rpc[] = {
 	{"permissions.trustedReload", rpc_trusted_reload, rpc_trusted_reload_doc, 0},
 	{"permissions.addressReload", rpc_address_reload, rpc_address_reload_doc, 0},
 	{"permissions.trustedDump", rpc_trusted_dump, rpc_trusted_dump_doc, 0},
-	{"permissions.addressDump", rpc_address_dump, rpc_address_dump_doc, 0},
-	{"permissions.subnetDump", rpc_subnet_dump, rpc_subnet_dump_doc, 0},
+	{"permissions.addressDump", rpc_address_dump, rpc_address_dump_doc, RET_ARRAY},
+	{"permissions.subnetDump", rpc_subnet_dump, rpc_subnet_dump_doc, RET_ARRAY},
 	{"permissions.domainDump", rpc_domain_name_dump, rpc_domain_name_dump_doc, 0},
 	{"permissions.testUri", rpc_test_uri, rpc_test_uri_doc, 0},
 	{0, 0, 0, 0}




More information about the sr-dev mailing list