Change in osmo-mgw[master]: Add show mgcp active

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/.

keith gerrit-no-reply at lists.osmocom.org
Tue May 4 20:23:53 UTC 2021


keith has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/24131 )


Change subject: Add show mgcp active
......................................................................

Add show mgcp active

With just one E1 line, the 'show mgcp' command outputs
several hundred lines to the vty. Add a 'active' parameter to
only show endpoints that are active.

Change-Id: I23a26b4fdc03d8b2469d293dd6c06ed83ce739e9
---
M src/libosmo-mgcp/mgcp_vty.c
1 file changed, 32 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/31/24131/1

diff --git a/src/libosmo-mgcp/mgcp_vty.c b/src/libosmo-mgcp/mgcp_vty.c
index 521f86e..2329bdc 100644
--- a/src/libosmo-mgcp/mgcp_vty.c
+++ b/src/libosmo-mgcp/mgcp_vty.c
@@ -301,7 +301,7 @@
 }
 
 
-static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats)
+static void dump_trunk(struct vty *vty, struct mgcp_trunk *trunk, int show_stats, int active_only)
 {
 	int i;
 
@@ -316,29 +316,25 @@
 
 	for (i = 0; i < trunk->number_endpoints; ++i) {
 		struct mgcp_endpoint *endp = trunk->endpoints[i];
-		dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
-			      show_stats);
-		if (i < trunk->number_endpoints - 1)
-			vty_out(vty, "%s", VTY_NEWLINE);
+		if (!active_only || !llist_empty(&endp->conns)) {
+			dump_endpoint(vty, endp, trunk->trunk_nr, trunk->trunk_type,
+				      show_stats);
+			if (i < trunk->number_endpoints - 1)
+				vty_out(vty, "%s", VTY_NEWLINE);
+		}
 	}
 
 	if (show_stats)
 		dump_ratectr_trunk(vty, trunk);
 }
 
-#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
-
-DEFUN(show_mcgp, show_mgcp_cmd,
-      "show mgcp [stats]",
-      SHOW_STR
-      SHOW_MGCP_STR
-      "Include Statistics\n")
+static int mgcp_show(struct vty *vty, int argc, const char **argv,
+		     int show_stats, int active_only)
 {
 	struct mgcp_trunk *trunk;
-	int show_stats = argc >= 1;
 
 	llist_for_each_entry(trunk, &g_cfg->trunks, entry)
-		dump_trunk(vty, trunk, show_stats);
+		dump_trunk(vty, trunk, show_stats, active_only);
 
 	if (g_cfg->osmux)
 		vty_out(vty, "Osmux used CID: %d%s", osmux_cid_pool_count_used(),
@@ -350,6 +346,27 @@
 	return CMD_SUCCESS;
 }
 
+#define SHOW_MGCP_STR "Display information about the MGCP Media Gateway\n"
+
+DEFUN(show_mgcp, show_mgcp_cmd,
+      "show mgcp [stats]",
+      SHOW_STR
+      SHOW_MGCP_STR
+      "Include Statistics\n")
+{
+	int show_stats = argc >= 1;
+	return mgcp_show(vty, argc, argv, show_stats, 0);
+}
+
+DEFUN(show_mgcp_active, show_mgcp_active_cmd,
+      "show mgcp active",
+      SHOW_STR
+      SHOW_MGCP_STR
+      "Show only Endpoints with Active Connections\n")
+{
+	return mgcp_show(vty, argc, argv, 0, 1);
+}
+
 static void
 dump_mgcp_endpoint(struct vty *vty, struct mgcp_trunk *trunk, const char *epname)
 {
@@ -1606,6 +1623,7 @@
 int mgcp_vty_init(void)
 {
 	install_element_ve(&show_mgcp_cmd);
+	install_element_ve(&show_mgcp_active_cmd);
 	install_element_ve(&show_mgcp_endpoint_cmd);
 	install_element_ve(&show_mgcp_trunk_endpoint_cmd);
 	install_element(ENABLE_NODE, &loop_conn_cmd);

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-mgw/+/24131
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-mgw
Gerrit-Branch: master
Gerrit-Change-Id: I23a26b4fdc03d8b2469d293dd6c06ed83ce739e9
Gerrit-Change-Number: 24131
Gerrit-PatchSet: 1
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210504/f65ff923/attachment.htm>


More information about the gerrit-log mailing list