Change in libosmo-sccp[master]: cs7 vty: add 'show cs7 config'

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

neels gerrit-no-reply at lists.osmocom.org
Thu Mar 19 18:01:49 UTC 2020


neels has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/17501 )

Change subject: cs7 vty: add 'show cs7 config'
......................................................................

cs7 vty: add 'show cs7 config'

When 'cs7' was added, it was generally possible to get the full automatic
configuration spelled out by using 'show running-config'. Later, the vty was
modified so that automatically configured parts were omitted.

Since figuring out the 'cs7' configuration is far from trivial, it is very
convenient to get the program's current configuration spelled out in detail,
whether it is automatic or not. For this purpose, add a new 'show' command
which simply calls the ss7 VTY's write function with a new switch to disable
all omissions.

Change-Id: I84707561a6f54851c5599c39ea9bf1d971a2a1d7
---
M src/osmo_ss7_vty.c
M tests/vty/ss7_asp_test.vty
2 files changed, 31 insertions(+), 11 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmo_ss7_vty.c b/src/osmo_ss7_vty.c
index 2931fb9..9a2f8bb 100644
--- a/src/osmo_ss7_vty.c
+++ b/src/osmo_ss7_vty.c
@@ -202,18 +202,23 @@
 	return CMD_SUCCESS;
 }
 
-static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst);
+static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst, bool show_dyn_config);
 
-static int config_write_cs7(struct vty *vty)
+static int write_all_cs7(struct vty *vty, bool show_dyn_config)
 {
 	struct osmo_ss7_instance *inst;
 
 	llist_for_each_entry(inst, &osmo_ss7_instances, list)
-		write_one_cs7(vty, inst);
+		write_one_cs7(vty, inst, show_dyn_config);
 
 	return 0;
 }
 
+static int config_write_cs7(struct vty *vty)
+{
+	return write_all_cs7(vty, false);
+}
+
 DEFUN(show_cs7_user, show_cs7_user_cmd,
 	"show cs7 instance <0-15> users",
 	SHOW_STR CS7_STR INST_STR INST_STR "User Table\n")
@@ -543,6 +548,14 @@
 	return CMD_SUCCESS;
 }
 
+DEFUN(show_cs7_config, show_cs7_config_cmd,
+      "show cs7 config",
+      SHOW_STR CS7_STR "Currently running cs7 configuration")
+{
+	write_all_cs7(vty, true);
+	return CMD_SUCCESS;
+}
+
 
 /***********************************************************************
  * Application Server Process
@@ -728,11 +741,12 @@
 	return CMD_SUCCESS;
 }
 
-static void write_one_asp(struct vty *vty, struct osmo_ss7_asp *asp)
+static void write_one_asp(struct vty *vty, struct osmo_ss7_asp *asp, bool show_dyn_config)
 {
 	int i;
 	/* skip any dynamically created ASPs (e.g. auto-created at connect time) */
-	if (asp->dyn_allocated || asp->simple_client_allocated)
+	if ((asp->dyn_allocated || asp->simple_client_allocated)
+	    && !show_dyn_config)
 		return;
 
 	vty_out(vty, " asp %s %u %u %s%s",
@@ -1025,13 +1039,14 @@
 	return CMD_SUCCESS;
 }
 
-static void write_one_as(struct vty *vty, struct osmo_ss7_as *as)
+static void write_one_as(struct vty *vty, struct osmo_ss7_as *as, bool show_dyn_config)
 {
 	struct osmo_ss7_routing_key *rkey;
 	unsigned int i;
 
 	/* skip any dynamically allocated AS definitions */
-	if (as->rkm_dyn_allocated || as->simple_client_allocated)
+	if ((as->rkm_dyn_allocated || as->simple_client_allocated)
+	    && !show_dyn_config)
 		return;
 
 	vty_out(vty, " as %s %s%s", as->cfg.name,
@@ -1043,7 +1058,8 @@
 		if (!asp)
 			continue;
 		/* skip any dynamically created ASPs (e.g. auto-created at connect time) */
-		if (asp->dyn_allocated || asp->simple_client_allocated)
+		if ((asp->dyn_allocated || asp->simple_client_allocated)
+		    && !show_dyn_config)
 			continue;
 		vty_out(vty, "  asp %s%s", asp->cfg.name, VTY_NEWLINE);
 	}
@@ -1700,7 +1716,7 @@
  * Common
  ***********************************************************************/
 
-static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst)
+static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst, bool show_dyn_config)
 {
 	struct osmo_ss7_asp *asp;
 	struct osmo_ss7_as *as;
@@ -1741,11 +1757,11 @@
 
 	/* first dump ASPs, as ASs reference them */
 	llist_for_each_entry(asp, &inst->asp_list, list)
-		write_one_asp(vty, asp);
+		write_one_asp(vty, asp, show_dyn_config);
 
 	/* then dump ASPs, as routes reference them */
 	llist_for_each_entry(as, &inst->as_list, list)
-		write_one_as(vty, as);
+		write_one_as(vty, as, show_dyn_config);
 
 	/* now dump everything that is relevent for the SG role */
 	if (cs7_role == CS7_ROLE_SG) {
@@ -1880,6 +1896,7 @@
 
 	install_element_ve(&show_cs7_user_cmd);
 	install_element_ve(&show_cs7_xua_cmd);
+	install_element_ve(&show_cs7_config_cmd);
 
 	/* the mother of all VTY config nodes */
 	install_element(CONFIG_NODE, &cs7_instance_cmd);
diff --git a/tests/vty/ss7_asp_test.vty b/tests/vty/ss7_asp_test.vty
index a7fe492..9bafb02 100644
--- a/tests/vty/ss7_asp_test.vty
+++ b/tests/vty/ss7_asp_test.vty
@@ -2,6 +2,7 @@
 ... !show cs7
   show cs7 instance <0-15> users
   show cs7 (sua|m3ua|ipa) [<0-65534>]
+  show cs7 config
   show cs7 instance <0-15> asp
   show cs7 instance <0-15> as (active|all|m3ua|sua)
   show cs7 instance <0-15> sccp addressbook
@@ -16,6 +17,7 @@
 ... !show cs7
   show cs7 instance <0-15> users
   show cs7 (sua|m3ua|ipa) [<0-65534>]
+  show cs7 config
   show cs7 instance <0-15> asp
   show cs7 instance <0-15> as (active|all|m3ua|sua)
   show cs7 instance <0-15> sccp addressbook
@@ -35,6 +37,7 @@
   sua       SCCP User Adaptation
   m3ua      MTP3 User Adaptation
   ipa       IPA Multiplex (SCCP Lite)
+  config    Currently running cs7 configuration
 
 ss7_asp_vty_test# show cs7 m3ua ?
   [<0-65534>]  Port Number

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/17501
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I84707561a6f54851c5599c39ea9bf1d971a2a1d7
Gerrit-Change-Number: 17501
Gerrit-PatchSet: 3
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200319/be1d4eba/attachment.htm>


More information about the gerrit-log mailing list