Module: kamailio Branch: master Commit: 247e9bf28ed900d980bf193708d2409cce3261d7 URL: https://github.com/kamailio/kamailio/commit/247e9bf28ed900d980bf193708d2409cce3261d7
Author: Vitaliy Aleksandrov <[email protected]> Committer: Vitaliy Aleksandrov <[email protected]> Date: 2017-10-23T19:15:44+03:00 usrloc: fix format of the ul.dump json reply - create "Domains" array instead of a single "Domain" object. --- Modified: src/modules/usrloc/ul_rpc.c --- Diff: https://github.com/kamailio/kamailio/commit/247e9bf28ed900d980bf193708d2409cce3261d7.diff Patch: https://github.com/kamailio/kamailio/commit/247e9bf28ed900d980bf193708d2409cce3261d7.patch --- diff --git a/src/modules/usrloc/ul_rpc.c b/src/modules/usrloc/ul_rpc.c index 36d2ed7d91..1231d4fc8a 100644 --- a/src/modules/usrloc/ul_rpc.c +++ b/src/modules/usrloc/ul_rpc.c @@ -217,6 +217,8 @@ static void ul_rpc_dump(rpc_t* rpc, void* ctx) int summary = 0; ucontact_t* c; void* th; + void* dah; + void* dh; void* ah; void* bh; void* ih; @@ -228,14 +230,27 @@ static void ul_rpc_dump(rpc_t* rpc, void* ctx) if(brief.len==5 && (strncmp(brief.s, "brief", 5)==0)) summary = 1; + if (rpc->add(ctx, "{", &th) < 0) + { + rpc->fault(ctx, 500, "Internal error creating top rpc"); + return; + } + if (rpc->struct_add(th, "[", "Domains", &dah) < 0) + { + rpc->fault(ctx, 500, "Internal error creating inner struct"); + return; + } + for( dl=root ; dl ; dl=dl->next ) { dom = dl->d; - if (rpc->add(ctx, "{", &th) < 0) + + if (rpc->struct_add(dah, "{", "Domain", &dh) < 0) { - rpc->fault(ctx, 500, "Internal error creating top rpc"); + rpc->fault(ctx, 500, "Internal error creating inner struct"); return; } - if(rpc->struct_add(th, "Sd[", + + if(rpc->struct_add(dh, "Sd[", "Domain", &dl->name, "Size", (int)dom->size, "AoRs", &ah)<0) @@ -289,7 +304,7 @@ static void ul_rpc_dump(rpc_t* rpc, void* ctx) } /* extra attributes node */ - if(rpc->struct_add(th, "{", "Stats", &sh)<0) + if(rpc->struct_add(dh, "{", "Stats", &sh)<0) { rpc->fault(ctx, 500, "Internal error creating stats struct"); return; _______________________________________________ Kamailio (SER) - Development Mailing List [email protected] https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
