vty: make 'show calls summary' more userfriendly
Display a table with one row per call (instead of two lines per call), and display the phone numbers of the people making the calls instead of internal IDs. This should make the VTY command friendlier for end users, especially if they have bigger networks. There is still the 'show calls' command with all the verbose output. Example output: OsmoSIPcon> show calls summary No active calls. OsmoSIPcon> show calls summary ID From To State ----- -------------------------------- -------------------------------- ---------- 5001 101 100 PROCEEDING OsmoSIPcon> show calls summary ID From To State ----- -------------------------------- -------------------------------- ---------- 5001 101 100 CONNECTED Relates: OS#1680 Change-Id: I2092d58d80a34e6083f618593b92bb9e838aa906
This commit is contained in:
parent
baa5d7bdad
commit
f0c2b31df9
53
src/vty.c
53
src/vty.c
|
@ -256,39 +256,36 @@ DEFUN(show_calls_sum, show_calls_sum_cmd,
|
||||||
"show calls summary",
|
"show calls summary",
|
||||||
SHOW_STR "Current calls\nBrief overview\n")
|
SHOW_STR "Current calls\nBrief overview\n")
|
||||||
{
|
{
|
||||||
struct call *call;
|
/* don't print a table for zero active calls */
|
||||||
|
if(llist_empty(&g_call_list)) {
|
||||||
llist_for_each_entry(call, &g_call_list, entry) {
|
vty_out(vty, "No active calls.%s", VTY_NEWLINE);
|
||||||
char *initial_type, *initial_state;
|
return CMD_SUCCESS;
|
||||||
char *remote_type, *remote_state;
|
|
||||||
|
|
||||||
initial_type = initial_state = NULL;
|
|
||||||
remote_type = remote_state = NULL;
|
|
||||||
|
|
||||||
if (call->initial) {
|
|
||||||
initial_type = talloc_strdup(tall_mncc_ctx,
|
|
||||||
call_leg_type(call->initial));
|
|
||||||
initial_state = talloc_strdup(tall_mncc_ctx,
|
|
||||||
call_leg_state(call->initial));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (call->remote) {
|
/* table head */
|
||||||
remote_type = talloc_strdup(tall_mncc_ctx,
|
vty_out(vty, "ID From To State%s", VTY_NEWLINE);
|
||||||
call_leg_type(call->remote));
|
vty_out(vty, "----- -------------------------------- -------------------------------- ----------%s",
|
||||||
remote_state = talloc_strdup(tall_mncc_ctx,
|
|
||||||
call_leg_state(call->remote));
|
|
||||||
}
|
|
||||||
|
|
||||||
vty_out(vty, "Call(%u) initial(type=%s,state=%s) remote(type=%s,state=%s)%s",
|
|
||||||
call->id, initial_type, initial_state, remote_type, remote_state,
|
|
||||||
VTY_NEWLINE);
|
VTY_NEWLINE);
|
||||||
|
|
||||||
talloc_free(initial_type);
|
/* iterate over calls */
|
||||||
talloc_free(initial_state);
|
struct call *call;
|
||||||
talloc_free(remote_type);
|
llist_for_each_entry(call, &g_call_list, entry) {
|
||||||
talloc_free(remote_state);
|
/* only look at the initial=MNCC call */
|
||||||
}
|
if(call->initial->type == CALL_TYPE_MNCC) {
|
||||||
|
struct mncc_call_leg *leg = (struct mncc_call_leg *) call->initial;
|
||||||
|
|
||||||
|
/* table row */
|
||||||
|
char *called = talloc_strdup(tall_mncc_ctx, leg->called.number);
|
||||||
|
char *calling = talloc_strdup(tall_mncc_ctx, leg->calling.number);
|
||||||
|
char *state = talloc_strdup(tall_mncc_ctx, call_leg_state(call->initial));
|
||||||
|
vty_out(vty, "%5u %-32s %-32s %s%s", call->id, calling, called, state, VTY_NEWLINE);
|
||||||
|
|
||||||
|
/* clean up */
|
||||||
|
talloc_free(called);
|
||||||
|
talloc_free(calling);
|
||||||
|
talloc_free(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue