From ed2d50d4e92a8d512d6a15773beeca310fa4e534 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 17 Mar 2020 22:24:55 +0100 Subject: 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 --- src/osmo_ss7_vty.c | 39 ++++++++++++++++++++++++++++----------- tests/vty/ss7_asp_test.vty | 3 +++ 2 files changed, 31 insertions(+), 11 deletions(-) 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 @@ DEFUN(cs7_permit_dyn_rkm, cs7_permit_dyn_rkm_cmd, 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 @@ DEFUN(show_cs7_xua, show_cs7_xua_cmd, 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 @@ DEFUN(show_cs7_asp, show_cs7_asp_cmd, 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 @@ DEFUN(as_pc_patch_sccp, as_pc_patch_sccp_cmd, 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 @@ static void write_one_as(struct vty *vty, struct osmo_ss7_as *as) 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 @@ DEFUN(cs7_sccpaddr_gt_digits, cs7_sccpaddr_gt_digits_cmd, * 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 @@ static void write_one_cs7(struct vty *vty, struct osmo_ss7_instance *inst) /* 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 @@ static void vty_init_shared(void *ctx) 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 @@ ss7_asp_vty_test> list ... !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 @@ ss7_asp_vty_test# list ... !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 @@ ss7_asp_vty_test# show cs7 ? 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 -- cgit v1.2.3