Change in osmo-sip-connector[master]: vty: make 'show calls summary' more userfriendly

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

osmith gerrit-no-reply at lists.osmocom.org
Fri Oct 5 09:59:38 UTC 2018


osmith has uploaded this change for review. ( https://gerrit.osmocom.org/11238


Change subject: vty: make 'show calls summary' more userfriendly
......................................................................

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
5003 | 101 | 100 | PROCEEDING
OsmoSIPcon> show calls summary
ID | From | To | State
5003 | 101 | 100 | CONNECTED

Change-Id: I2092d58d80a34e6083f618593b92bb9e838aa906
---
M src/vty.c
1 file changed, 26 insertions(+), 31 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sip-connector refs/changes/38/11238/1

diff --git a/src/vty.c b/src/vty.c
index 540e2de..eb236b4 100644
--- a/src/vty.c
+++ b/src/vty.c
@@ -256,39 +256,34 @@
 	"show calls summary",
 	SHOW_STR "Current calls\nBrief overview\n")
 {
-	struct call *call;
-
-	llist_for_each_entry(call, &g_call_list, entry) {
-		char *initial_type, *initial_state;
-		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) {
-			remote_type = talloc_strdup(tall_mncc_ctx,
-						call_leg_type(call->remote));
-			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);
-
-		talloc_free(initial_type);
-		talloc_free(initial_state);
-		talloc_free(remote_type);
-		talloc_free(remote_state);
+	/* don't print a table for zero active calls */
+	if(llist_empty(&g_call_list)) {
+		vty_out(vty, "No active calls.%s", VTY_NEWLINE);
+		return CMD_SUCCESS;
 	}
 
+	/* table head */
+	vty_out(vty, "ID | From | To | State%s", VTY_NEWLINE);
+
+	/* iterate over calls */
+	struct call *call;
+	llist_for_each_entry(call, &g_call_list, entry) {
+		/* 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, "%u | %s | %s | %s%s", call->id, calling, called, state, VTY_NEWLINE);
+
+			/* clean up */
+			talloc_free(called);
+			talloc_free(calling);
+			talloc_free(state);
+		}
+	}
 	return CMD_SUCCESS;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/11238
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sip-connector
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2092d58d80a34e6083f618593b92bb9e838aa906
Gerrit-Change-Number: 11238
Gerrit-PatchSet: 1
Gerrit-Owner: osmith <osmith at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181005/b5f04536/attachment.htm>


More information about the gerrit-log mailing list