From 3585f802b3beada38b24e1daa72dc527c1d86535 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Fri, 1 Nov 2019 10:23:35 +0100 Subject: [PATCH] dialog: added dlg.briefing rpc command - list fewer details for the dialog records in memory --- src/modules/dialog/dialog.c | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/modules/dialog/dialog.c b/src/modules/dialog/dialog.c index a5f0e56b39e..dd41ddf7562 100644 --- a/src/modules/dialog/dialog.c +++ b/src/modules/dialog/dialog.c @@ -2837,7 +2837,46 @@ static void rpc_dlg_list_match_ctx(rpc_t *rpc, void *c) rpc_dlg_list_match_ex(rpc, c, 1); } +static const char *rpc_dlg_briefing_doc[2] = { + "List the summary of dialog records in memory", 0 +}; + +/*! + * \brief List summary of active calls + */ +static void rpc_dlg_briefing(rpc_t *rpc, void *c) +{ + dlg_cell_t *dlg; + unsigned int i; + void *h; + + for( i=0 ; isize ; i++ ) { + dlg_lock( d_table, &(d_table->entries[i]) ); + for( dlg=d_table->entries[i].first ; dlg ; dlg=dlg->next ) { + if (rpc->add(c, "{", &h) < 0) { + rpc->fault(c, 500, "Failed to create the structure"); + return; + } + if(rpc->struct_add(h, "ddSSSSSd", + "h_entry", dlg->h_entry, + "h_id", dlg->h_id, + "from_uri", &dlg->from_uri, + "to_uri", &dlg->to_uri, + "call-id", &dlg->callid, + "from_tag", &dlg->tag[DLG_CALLER_LEG], + "to_tag", &dlg->tag[DLG_CALLER_LEG], + "state", dlg->state) < 0) { + rpc->fault(c, 500, "Failed to add fields"); + return; + + } + } + dlg_unlock( d_table, &(d_table->entries[i]) ); + } +} + static rpc_export_t rpc_methods[] = { + {"dlg.briefing", rpc_dlg_briefing, rpc_dlg_briefing_doc, RET_ARRAY}, {"dlg.list", rpc_print_dlgs, rpc_print_dlgs_doc, RET_ARRAY}, {"dlg.list_ctx", rpc_print_dlgs_ctx, rpc_print_dlgs_ctx_doc, RET_ARRAY}, {"dlg.list_match", rpc_dlg_list_match, rpc_dlg_list_match_doc, RET_ARRAY},