Module: kamailio
Branch: 5.0
Commit: a62698612bccaaa2defd640feb3552f6d916b279
URL:
https://github.com/kamailio/kamailio/commit/a62698612bccaaa2defd640feb3552f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-09-29T09:31:44+02:00
domain: proper output format for rpc dump command
- arrays have to be used to list domains and attributes
(cherry picked from commit 6d4367e4ab1e7e2d38b94b942f2383e3878a1e7a)
---
Modified: src/modules/domain/domain_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/a62698612bccaaa2defd640feb3552f…
Patch:
https://github.com/kamailio/kamailio/commit/a62698612bccaaa2defd640feb3552f…
---
diff --git a/src/modules/domain/domain_mod.c b/src/modules/domain/domain_mod.c
index 179d847a45..3c16fe00c3 100644
--- a/src/modules/domain/domain_mod.c
+++ b/src/modules/domain/domain_mod.c
@@ -290,30 +290,46 @@ static void domain_rpc_dump(rpc_t *rpc, void *ctx)
struct domain_list *np;
struct attr_list *ap;
struct domain_list **ht;
+ void *rt;
+ void *at;
void *st;
if(hash_table == 0 || *hash_table == 0) {
rpc->fault(ctx, 404, "Server Domain Cache Empty");
return;
}
+ if(rpc->add(ctx, "{", &rt) < 0) {
+ rpc->fault(ctx, 500, "Failed to create root struct");
+ return;
+ }
+ if(rpc->struct_add(rt, "[", "domains", &at) < 0) {
+ rpc->fault(ctx, 500, "Failed to create domains struct");
+ return;
+ }
+
ht = *hash_table;
for(i = 0; i < DOM_HASH_SIZE; i++) {
np = ht[i];
while(np) {
- if(rpc->add(ctx, "{", &st) < 0)
+ if(rpc->array_add(at, "{", &st) < 0)
return;
rpc->struct_add(st, "SS", "domain", &np->domain,
"did", &np->did);
np = np->next;
}
}
+ if(rpc->struct_add(rt, "[", "attributes", &at) < 0) {
+ rpc->fault(ctx, 500, "Failed to create attributes struct");
+ return;
+ }
np = ht[DOM_HASH_SIZE];
while(np) {
- if(rpc->add(ctx, "{", &st) < 0)
+ if(rpc->array_add(at, "{", &st) < 0)
return;
rpc->struct_add(st, "S", "did", &np->did);
+ rpc->struct_add(st, "[", "attrs", &st);
ap = np->attrs;
while(ap) {
- rpc->struct_add(st, "S", "attr", &ap->name);
+ rpc->array_add(st, "S", &ap->name);
ap = ap->next;
}
np = np->next;
@@ -325,7 +341,9 @@ static void domain_rpc_dump(rpc_t *rpc, void *ctx)
rpc_export_t domain_rpc_list[] = {
{"domain.reload", domain_rpc_reload, domain_rpc_reload_doc, 0},
- {"domain.dump", domain_rpc_dump, domain_rpc_dump_doc, 0}, {0, 0, 0, 0}};
+ {"domain.dump", domain_rpc_dump, domain_rpc_dump_doc, 0},
+ {0, 0, 0, 0}
+};
static int domain_init_rpc(void)
{
@@ -334,4 +352,4 @@ static int domain_init_rpc(void)
return -1;
}
return 0;
-}
\ No newline at end of file
+}