pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmocom-bb/+/32440 )
(
4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: layer23: Move 'show {subscriber,support}' to common/' ......................................................................
layer23: Move 'show {subscriber,support}' to common/'
Those modules are aready in common/, so they can be added to the shared VTY interface to introspect MS objects.
Change-Id: Ie4d85bbb1d0af8894683589d8b936f9884f79be9 --- M src/host/layer23/include/osmocom/bb/common/vty.h M src/host/layer23/src/common/vty.c M src/host/layer23/src/mobile/vty_interface.c 3 files changed, 87 insertions(+), 73 deletions(-)
Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified
diff --git a/src/host/layer23/include/osmocom/bb/common/vty.h b/src/host/layer23/include/osmocom/bb/common/vty.h index 7f6e2d3..b2a52c0 100644 --- a/src/host/layer23/include/osmocom/bb/common/vty.h +++ b/src/host/layer23/include/osmocom/bb/common/vty.h @@ -23,7 +23,8 @@ void l23_vty_config_write_ms_node_contents(struct vty *vty, const struct osmocom_ms *ms, const char *prefix); void l23_vty_config_write_ms_node_contents_final(struct vty *vty, const struct osmocom_ms *ms, const char *prefix);
-extern void l23_vty_ms_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +void l23_vty_ms_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +void l23_vty_printf(void *priv, const char *fmt, ...);
extern bool l23_vty_reading; extern bool l23_vty_hide_default; diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c index 27d0330..462998d 100644 --- a/src/host/layer23/src/common/vty.c +++ b/src/host/layer23/src/common/vty.c @@ -130,6 +130,26 @@ } }
+void l23_vty_printf(void *priv, const char *fmt, ...) +{ + char buffer[1000]; + struct vty *vty = priv; + va_list args; + + va_start(args, fmt); + vsnprintf(buffer, sizeof(buffer) - 1, fmt, args); + buffer[sizeof(buffer) - 1] = '\0'; + va_end(args); + + if (buffer[0]) { + if (buffer[strlen(buffer) - 1] == '\n') { + buffer[strlen(buffer) - 1] = '\0'; + vty_out(vty, "%s%s", buffer, VTY_NEWLINE); + } else + vty_out(vty, "%s", buffer); + } +} + /* placeholder for layer23 shared MS info to be dumped */ void l23_ms_dump(struct osmocom_ms *ms, struct vty *vty) { @@ -188,6 +208,50 @@ return CMD_SUCCESS; }
+DEFUN(show_support, show_support_cmd, "show support [MS_NAME]", + SHOW_STR "Display information about MS support\n" + "Name of MS (see "show ms")") +{ + struct osmocom_ms *ms; + + if (argc) { + ms = l23_vty_get_ms(argv[0], vty); + if (!ms) + return CMD_WARNING; + gsm_support_dump(ms, l23_vty_printf, vty); + } else { + llist_for_each_entry(ms, &ms_list, entity) { + gsm_support_dump(ms, l23_vty_printf, vty); + vty_out(vty, "%s", VTY_NEWLINE); + } + } + + return CMD_SUCCESS; +} + +DEFUN(show_subscr, show_subscr_cmd, "show subscriber [MS_NAME]", + SHOW_STR "Display information about subscriber\n" + "Name of MS (see "show ms")") +{ + struct osmocom_ms *ms; + + if (argc) { + ms = l23_vty_get_ms(argv[0], vty); + if (!ms) + return CMD_WARNING; + gsm_subscr_dump(&ms->subscr, l23_vty_printf, vty); + } else { + llist_for_each_entry(ms, &ms_list, entity) { + if (ms->shutdown == MS_SHUTDOWN_NONE) { + gsm_subscr_dump(&ms->subscr, l23_vty_printf, vty); + vty_out(vty, "%s", VTY_NEWLINE); + } + } + } + + return CMD_SUCCESS; +} + /* "gsmtap" config */ gDEFUN(l23_cfg_gsmtap, l23_cfg_gsmtap_cmd, "gsmtap", "Configure GSMTAP\n") @@ -868,6 +932,9 @@ if (l23_app_info.opt_supported & L23_OPT_VTY) osmo_stats_vty_add_cmds();
+ install_element_ve(&show_subscr_cmd); + install_element_ve(&show_support_cmd); + install_element(CONFIG_NODE, &cfg_hide_default_cmd); install_element(CONFIG_NODE, &cfg_no_hide_default_cmd);
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c index 3938c3b..bdaf69b 100644 --- a/src/host/layer23/src/mobile/vty_interface.c +++ b/src/host/layer23/src/mobile/vty_interface.c @@ -54,26 +54,6 @@ 1 };
-static void print_vty(void *priv, const char *fmt, ...) -{ - char buffer[1000]; - struct vty *vty = priv; - va_list args; - - va_start(args, fmt); - vsnprintf(buffer, sizeof(buffer) - 1, fmt, args); - buffer[sizeof(buffer) - 1] = '\0'; - va_end(args); - - if (buffer[0]) { - if (buffer[strlen(buffer) - 1] == '\n') { - buffer[strlen(buffer) - 1] = '\0'; - vty_out(vty, "%s%s", buffer, VTY_NEWLINE); - } else - vty_out(vty, "%s", buffer); - } -} - int vty_check_number(struct vty *vty, const char *number) { int i; @@ -231,50 +211,6 @@ return CMD_SUCCESS; }
-DEFUN(show_support, show_support_cmd, "show support [MS_NAME]", - SHOW_STR "Display information about MS support\n" - "Name of MS (see "show ms")") -{ - struct osmocom_ms *ms; - - if (argc) { - ms = l23_vty_get_ms(argv[0], vty); - if (!ms) - return CMD_WARNING; - gsm_support_dump(ms, print_vty, vty); - } else { - llist_for_each_entry(ms, &ms_list, entity) { - gsm_support_dump(ms, print_vty, vty); - vty_out(vty, "%s", VTY_NEWLINE); - } - } - - return CMD_SUCCESS; -} - -DEFUN(show_subscr, show_subscr_cmd, "show subscriber [MS_NAME]", - SHOW_STR "Display information about subscriber\n" - "Name of MS (see "show ms")") -{ - struct osmocom_ms *ms; - - if (argc) { - ms = l23_vty_get_ms(argv[0], vty); - if (!ms) - return CMD_WARNING; - gsm_subscr_dump(&ms->subscr, print_vty, vty); - } else { - llist_for_each_entry(ms, &ms_list, entity) { - if (ms->shutdown == MS_SHUTDOWN_NONE) { - gsm_subscr_dump(&ms->subscr, print_vty, vty); - vty_out(vty, "%s", VTY_NEWLINE); - } - } - } - - return CMD_SUCCESS; -} - DEFUN(show_cell, show_cell_cmd, "show cell MS_NAME", SHOW_STR "Display information about received cells\n" "Name of MS (see "show ms")") @@ -285,7 +221,7 @@ if (!ms) return CMD_WARNING;
- gsm322_dump_cs_list(&ms->cellsel, GSM322_CS_FLAG_SUPPORT, print_vty, + gsm322_dump_cs_list(&ms->cellsel, GSM322_CS_FLAG_SUPPORT, l23_vty_printf, vty);
return CMD_SUCCESS; @@ -320,7 +256,7 @@ return CMD_SUCCESS; }
- gsm48_sysinfo_dump(s, arfcn, print_vty, vty, ms->settings.freq_map); + gsm48_sysinfo_dump(s, arfcn, l23_vty_printf, vty, ms->settings.freq_map);
return CMD_SUCCESS; } @@ -335,7 +271,7 @@ if (!ms) return CMD_WARNING;
- gsm322_dump_nb_list(&ms->cellsel, print_vty, vty); + gsm322_dump_nb_list(&ms->cellsel, l23_vty_printf, vty);
return CMD_SUCCESS; } @@ -365,7 +301,7 @@ } }
- gsm322_dump_ba_list(&ms->cellsel, mcc, mnc, print_vty, vty); + gsm322_dump_ba_list(&ms->cellsel, mcc, mnc, l23_vty_printf, vty);
return CMD_SUCCESS; } @@ -380,7 +316,7 @@ if (!ms) return CMD_WARNING;
- gsm_subscr_dump_forbidden_plmn(ms, print_vty, vty); + gsm_subscr_dump_forbidden_plmn(ms, l23_vty_printf, vty);
return CMD_SUCCESS; } @@ -395,7 +331,7 @@ if (!ms) return CMD_WARNING;
- gsm322_dump_forbidden_la(ms, print_vty, vty); + gsm322_dump_forbidden_la(ms, l23_vty_printf, vty);
return CMD_SUCCESS; } @@ -2713,8 +2649,6 @@ return rc;
install_element_ve(&show_ms_cmd); - install_element_ve(&show_subscr_cmd); - install_element_ve(&show_support_cmd); install_element_ve(&show_cell_cmd); install_element_ve(&show_cell_si_cmd); install_element_ve(&show_nbcells_cmd);