summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/host/layer23/include/osmocom/bb/common/Makefile.am1
-rw-r--r--src/host/layer23/include/osmocom/bb/common/vty.h25
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/vty.h6
-rw-r--r--src/host/layer23/include/osmocom/bb/modem/Makefile.am5
-rw-r--r--src/host/layer23/include/osmocom/bb/modem/vty.h3
-rw-r--r--src/host/layer23/src/common/Makefile.am1
-rw-r--r--src/host/layer23/src/common/vty.c182
-rw-r--r--src/host/layer23/src/mobile/app_mobile.c1
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c119
-rw-r--r--src/host/layer23/src/modem/Makefile.am1
-rw-r--r--src/host/layer23/src/modem/app_modem.c9
-rw-r--r--src/host/layer23/src/modem/vty.c49
12 files changed, 311 insertions, 91 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/Makefile.am b/src/host/layer23/include/osmocom/bb/common/Makefile.am
index 8663d9cd..c756b8e4 100644
--- a/src/host/layer23/include/osmocom/bb/common/Makefile.am
+++ b/src/host/layer23/include/osmocom/bb/common/Makefile.am
@@ -13,4 +13,5 @@ noinst_HEADERS = \
sap_fsm.h \
sap_interface.h \
sim.h \
+ vty.h \
$(NULL)
diff --git a/src/host/layer23/include/osmocom/bb/common/vty.h b/src/host/layer23/include/osmocom/bb/common/vty.h
new file mode 100644
index 00000000..dd5e7f2f
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/common/vty.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/buffer.h>
+#include <osmocom/vty/command.h>
+
+struct osmocom_ms;
+
+enum l23_vty_node {
+ MS_NODE = _LAST_OSMOVTY_NODE + 1,
+ _LAST_L23VTY_NODE,
+};
+
+int l23_vty_init(int (*config_write_ms_node_cb)(struct vty *));
+
+struct osmocom_ms *l23_vty_get_ms(const char *name, struct vty *vty);
+void l23_ms_dump(struct osmocom_ms *ms, struct vty *vty);
+void l23_vty_config_write_ms_node(struct vty *vty, const struct osmocom_ms *ms, const char *prefix);
+void l23_vty_config_write_ms_node_contents(struct vty *vty, const struct osmocom_ms *ms, const char *prefix);
+
+extern struct llist_head ms_list;
+
+extern struct cmd_element l23_show_ms_cmd;
+extern struct cmd_element l23_cfg_ms_cmd;
diff --git a/src/host/layer23/include/osmocom/bb/mobile/vty.h b/src/host/layer23/include/osmocom/bb/mobile/vty.h
index d0668041..6bd1b37c 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/vty.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/vty.h
@@ -6,14 +6,14 @@
#include <osmocom/vty/buffer.h>
#include <osmocom/vty/command.h>
+#include <osmocom/bb/common/vty.h>
+
enum ms_vty_node {
- MS_NODE = _LAST_OSMOVTY_NODE + 1,
- TESTSIM_NODE,
+ TESTSIM_NODE = _LAST_L23VTY_NODE + 1,
SUPPORT_NODE,
AUDIO_NODE,
};
-int ms_vty_go_parent(struct vty *vty);
int ms_vty_init(void);
extern void vty_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
diff --git a/src/host/layer23/include/osmocom/bb/modem/Makefile.am b/src/host/layer23/include/osmocom/bb/modem/Makefile.am
index d99240db..309a5141 100644
--- a/src/host/layer23/include/osmocom/bb/modem/Makefile.am
+++ b/src/host/layer23/include/osmocom/bb/modem/Makefile.am
@@ -1 +1,4 @@
-noinst_HEADERS = modem.h
+noinst_HEADERS = \
+ modem.h \
+ vty.h \
+ $(NULL)
diff --git a/src/host/layer23/include/osmocom/bb/modem/vty.h b/src/host/layer23/include/osmocom/bb/modem/vty.h
new file mode 100644
index 00000000..14ec6241
--- /dev/null
+++ b/src/host/layer23/include/osmocom/bb/modem/vty.h
@@ -0,0 +1,3 @@
+#pragma once
+
+int modem_vty_init(void);
diff --git a/src/host/layer23/src/common/Makefile.am b/src/host/layer23/src/common/Makefile.am
index f6578ece..7d27eb12 100644
--- a/src/host/layer23/src/common/Makefile.am
+++ b/src/host/layer23/src/common/Makefile.am
@@ -26,4 +26,5 @@ liblayer23_a_SOURCES = \
sim.c \
sysinfo.c \
utils.c \
+ vty.c \
$(NULL)
diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c
new file mode 100644
index 00000000..34d39b0d
--- /dev/null
+++ b/src/host/layer23/src/common/vty.c
@@ -0,0 +1,182 @@
+/*
+ * (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ * (C) 2023 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/gsm48.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/crypt/auth.h>
+
+#include <osmocom/bb/common/vty.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/ms.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/mobile/mncc.h>
+#include <osmocom/bb/mobile/mncc_ms.h>
+#include <osmocom/bb/mobile/transaction.h>
+#include <osmocom/bb/mobile/vty.h>
+#include <osmocom/bb/mobile/app_mobile.h>
+#include <osmocom/bb/mobile/gsm480_ss.h>
+#include <osmocom/bb/mobile/gsm411_sms.h>
+#include <osmocom/vty/telnet_interface.h>
+#include <osmocom/vty/misc.h>
+
+static struct cmd_node ms_node = {
+ MS_NODE,
+ "%s(ms)# ",
+ 1
+};
+
+struct osmocom_ms *l23_vty_get_ms(const char *name, struct vty *vty)
+{
+ struct osmocom_ms *ms;
+
+ llist_for_each_entry(ms, &ms_list, entity) {
+ if (!strcmp(ms->name, name)) {
+ if (ms->shutdown != MS_SHUTDOWN_NONE) {
+ vty_out(vty, "MS '%s' is admin down.%s", name,
+ VTY_NEWLINE);
+ return NULL;
+ }
+ return ms;
+ }
+ }
+ vty_out(vty, "MS name '%s' does not exist.%s", name, VTY_NEWLINE);
+
+ return NULL;
+}
+
+/* placeholder for layer23 shared MS info to be dumped */
+void l23_ms_dump(struct osmocom_ms *ms, struct vty *vty)
+{
+ char *service = "";
+
+ if (!ms->started)
+ service = ", radio is not started";
+ else if (ms->mmlayer.state == GSM48_MM_ST_MM_IDLE) {
+ /* current MM idle state */
+ switch (ms->mmlayer.substate) {
+ case GSM48_MM_SST_NORMAL_SERVICE:
+ case GSM48_MM_SST_PLMN_SEARCH_NORMAL:
+ service = ", service is normal";
+ break;
+ case GSM48_MM_SST_LOC_UPD_NEEDED:
+ case GSM48_MM_SST_ATTEMPT_UPDATE:
+ service = ", service is limited (pending)";
+ break;
+ case GSM48_MM_SST_NO_CELL_AVAIL:
+ service = ", service is unavailable";
+ break;
+ default:
+ if (ms->subscr.sim_valid)
+ service = ", service is limited";
+ else
+ service = ", service is limited "
+ "(IMSI detached)";
+ break;
+ }
+ } else
+ service = ", MM connection active";
+
+ vty_out(vty, "MS '%s' is %s%s%s%s", ms->name,
+ (ms->shutdown != MS_SHUTDOWN_NONE) ? "administratively " : "",
+ (ms->shutdown != MS_SHUTDOWN_NONE || !ms->started) ? "down" : "up",
+ (ms->shutdown == MS_SHUTDOWN_NONE) ? service : "",
+ VTY_NEWLINE);
+}
+
+
+gDEFUN(l23_show_ms, l23_show_ms_cmd, "show ms [MS_NAME]",
+ SHOW_STR "Display available MS entities\n")
+{
+ struct osmocom_ms *ms;
+
+ if (argc) {
+ llist_for_each_entry(ms, &ms_list, entity) {
+ if (!strcmp(ms->name, argv[0])) {
+ l23_ms_dump(ms, vty);
+ return CMD_SUCCESS;
+ }
+ }
+ vty_out(vty, "MS name '%s' does not exist.%s", argv[0],
+ VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ llist_for_each_entry(ms, &ms_list, entity) {
+ l23_ms_dump(ms, vty);
+ vty_out(vty, "%s", VTY_NEWLINE);
+ }
+
+ return CMD_SUCCESS;
+}
+
+/* per MS config */
+gDEFUN(l23_cfg_ms, l23_cfg_ms_cmd, "ms MS_NAME",
+ "Select a mobile station to configure\nName of MS (see \"show ms\")")
+{
+ struct osmocom_ms *ms;
+
+ llist_for_each_entry(ms, &ms_list, entity) {
+ if (!strcmp(ms->name, argv[0])) {
+ vty->index = ms;
+ vty->node = MS_NODE;
+ return CMD_SUCCESS;
+ }
+ }
+
+ vty_out(vty, "MS name '%s' does not exits%s", argv[0],
+ VTY_NEWLINE);
+ return CMD_WARNING;
+}
+
+void l23_vty_config_write_ms_node(struct vty *vty, const struct osmocom_ms *ms, const char *prefix)
+{
+ size_t prefix_len = strlen(prefix);
+ char *prefix_content = alloca(prefix_len + 1 + 1);
+
+ memcpy(prefix_content, prefix, prefix_len);
+ prefix_content[prefix_len] = ' ';
+ prefix_content[prefix_len + 1] = '\0';
+
+ vty_out(vty, "%sms %s%s", prefix, ms->name, VTY_NEWLINE);
+ l23_vty_config_write_ms_node_contents(vty, ms, prefix_content);
+}
+
+void l23_vty_config_write_ms_node_contents(struct vty *vty, const struct osmocom_ms *ms, const char *prefix)
+{
+ /* placeholder for shared VTY commands */
+}
+
+int l23_vty_init(int (*config_write_ms_node_cb)(struct vty *))
+{
+ install_node(&ms_node, config_write_ms_node_cb);
+
+ /* Register the talloc context introspection command */
+ osmo_talloc_vty_add_cmds();
+
+ return 0;
+}
+
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index b2133f7f..b4466dea 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -446,7 +446,6 @@ int l23_app_exit(void)
static struct vty_app_info vty_info = {
.name = "OsmocomBB",
.version = PACKAGE_VERSION,
- .go_parent_cb = ms_vty_go_parent,
};
/* global init */
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index 6fc7f5b9..39a64fdc 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -41,15 +41,8 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
-extern struct llist_head ms_list;
extern struct llist_head active_connections;
-struct cmd_node ms_node = {
- MS_NODE,
- "%s(ms)# ",
- 1
-};
-
struct cmd_node testsim_node = {
TESTSIM_NODE,
"%s(test-sim)# ",
@@ -133,25 +126,6 @@ static void vty_restart_if_started(struct vty *vty, struct osmocom_ms *ms)
vty_restart(vty, ms);
}
-static struct osmocom_ms *get_ms(const char *name, struct vty *vty)
-{
- struct osmocom_ms *ms;
-
- llist_for_each_entry(ms, &ms_list, entity) {
- if (!strcmp(ms->name, name)) {
- if (ms->shutdown != MS_SHUTDOWN_NONE) {
- vty_out(vty, "MS '%s' is admin down.%s", name,
- VTY_NEWLINE);
- return NULL;
- }
- return ms;
- }
- }
- vty_out(vty, "MS name '%s' does not exist.%s", name, VTY_NEWLINE);
-
- return NULL;
-}
-
static void gsm_ms_dump(struct osmocom_ms *ms, struct vty *vty)
{
struct gsm_settings *set = &ms->settings;
@@ -274,7 +248,7 @@ DEFUN(show_support, show_support_cmd, "show support [MS_NAME]",
struct osmocom_ms *ms;
if (argc) {
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
gsm_support_dump(ms, print_vty, vty);
@@ -295,7 +269,7 @@ DEFUN(show_subscr, show_subscr_cmd, "show subscriber [MS_NAME]",
struct osmocom_ms *ms;
if (argc) {
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
gsm_subscr_dump(&ms->subscr, print_vty, vty);
@@ -317,7 +291,7 @@ DEFUN(show_cell, show_cell_cmd, "show cell MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -336,7 +310,7 @@ DEFUN(show_cell_si, show_cell_si_cmd, "show cell MS_NAME <0-1023> [pcs]",
struct gsm48_sysinfo *s;
uint16_t arfcn = atoi(argv[1]);
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -367,7 +341,7 @@ DEFUN(show_nbcells, show_nbcells_cmd, "show neighbour-cells MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -384,7 +358,7 @@ DEFUN(show_ba, show_ba_cmd, "show ba MS_NAME [MCC] [MNC]",
struct osmocom_ms *ms;
uint16_t mcc = 0, mnc = 0;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -412,7 +386,7 @@ DEFUN(show_forb_plmn, show_forb_plmn_cmd, "show forbidden plmn MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -427,7 +401,7 @@ DEFUN(show_forb_la, show_forb_la_cmd, "show forbidden location-area MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -441,7 +415,7 @@ DEFUN(monitor_network, monitor_network_cmd, "monitor network MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -456,7 +430,7 @@ DEFUN(no_monitor_network, no_monitor_network_cmd, "no monitor network MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -475,7 +449,7 @@ static int _sim_test_cmd(struct vty *vty, int argc, const char *argv[],
uint16_t mcc = 0x001, mnc = 0x01f, lac = 0x0000;
uint32_t tmsi = 0xffffffff;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -552,7 +526,7 @@ DEFUN(sim_sap, sim_sap_cmd, "sim sap MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -574,7 +548,7 @@ DEFUN(sim_reader, sim_reader_cmd, "sim reader MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -594,7 +568,7 @@ DEFUN(sim_remove, sim_remove_cmd, "sim remove MS_NAME",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -617,7 +591,7 @@ DEFUN(sim_pin, sim_pin_cmd, "sim pin MS_NAME PIN",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -642,7 +616,7 @@ DEFUN(sim_disable_pin, sim_disable_pin_cmd, "sim disable-pin MS_NAME PIN",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -662,7 +636,7 @@ DEFUN(sim_enable_pin, sim_enable_pin_cmd, "sim enable-pin MS_NAME PIN",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -682,7 +656,7 @@ DEFUN(sim_change_pin, sim_change_pin_cmd, "sim change-pin MS_NAME OLD NEW",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -706,7 +680,7 @@ DEFUN(sim_unblock_pin, sim_unblock_pin_cmd, "sim unblock-pin MS_NAME PUC NEW",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -734,7 +708,7 @@ DEFUN(sim_lai, sim_lai_cmd, "sim lai MS_NAME MCC MNC LAC",
mnc = gsm_input_mnc((char *)argv[2]),
lac = strtoul(argv[3], NULL, 16);
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -772,7 +746,7 @@ DEFUN(network_select, network_select_cmd,
mnc = gsm_input_mnc((char *)argv[2]);
int found = 0;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
plmn = &ms->plmn;
@@ -826,7 +800,7 @@ DEFUN(call, call_cmd, "call MS_NAME (NUMBER|emergency|answer|hangup|hold)",
struct gsm_settings_abbrev *abbrev;
char *number;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
set = &ms->settings;
@@ -869,7 +843,7 @@ DEFUN(call_retr, call_retr_cmd, "call MS_NAME retrieve [NUMBER]",
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -885,7 +859,7 @@ DEFUN(call_dtmf, call_dtmf_cmd, "call MS_NAME dtmf DIGITS",
struct osmocom_ms *ms;
struct gsm_settings *set;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
set = &ms->settings;
@@ -911,7 +885,7 @@ DEFUN(sms, sms_cmd, "sms MS_NAME NUMBER .LINE",
struct gsm_settings_abbrev *abbrev;
char *number, *sms_sca = NULL;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
set = &ms->settings;
@@ -970,7 +944,7 @@ DEFUN(service, service_cmd, "service MS_NAME (*#06#|*#21#|*#67#|*#61#|*#62#"
{
struct osmocom_ms *ms;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -989,7 +963,7 @@ DEFUN(test_reselection, test_reselection_cmd, "test re-selection NAME",
struct gsm_settings *set;
struct msgb *nmsg;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
set = &ms->settings;
@@ -1018,7 +992,7 @@ DEFUN(delete_forbidden_plmn, delete_forbidden_plmn_cmd,
uint16_t mcc = gsm_input_mcc((char *)argv[1]),
mnc = gsm_input_mnc((char *)argv[2]);
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -1045,7 +1019,7 @@ DEFUN(network_show, network_show_cmd, "network show MS_NAME",
struct gsm322_plmn *plmn;
struct gsm322_plmn_list *temp;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
set = &ms->settings;
@@ -1072,7 +1046,7 @@ DEFUN(network_search, network_search_cmd, "network search MS_NAME",
struct osmocom_ms *ms;
struct msgb *nmsg;
- ms = get_ms(argv[0], vty);
+ ms = l23_vty_get_ms(argv[0], vty);
if (!ms)
return CMD_WARNING;
@@ -1323,6 +1297,9 @@ static void config_write_ms(struct vty *vty, struct osmocom_ms *ms)
struct gsm_settings_abbrev *abbrev;
vty_out(vty, "ms %s%s", ms->name, VTY_NEWLINE);
+
+ l23_vty_config_write_ms_node_contents(vty, ms, " ");
+
vty_out(vty, " layer2-socket %s%s", set->layer2_socket_path,
VTY_NEWLINE);
vty_out(vty, " sap-socket %s%s", set->sap_socket_path, VTY_NEWLINE);
@@ -2996,25 +2973,6 @@ DEFUN(cfg_ms_no_script_load_run, cfg_ms_no_script_load_run_cmd, "no lua-script",
return CMD_SUCCESS;
}
-int ms_vty_go_parent(struct vty *vty)
-{
- switch (vty->node) {
- case MS_NODE:
- vty->node = CONFIG_NODE;
- vty->index = NULL;
- break;
- case TESTSIM_NODE:
- case SUPPORT_NODE:
- case AUDIO_NODE:
- vty->node = MS_NODE;
- break;
- default:
- vty->node = CONFIG_NODE;
- }
-
- return vty->node;
-}
-
DEFUN(off, off_cmd, "off",
"Turn mobiles off (shutdown) and exit")
{
@@ -3028,6 +2986,11 @@ DEFUN(off, off_cmd, "off",
int ms_vty_init(void)
{
+ int rc;
+
+ if ((rc = l23_vty_init(config_write)) < 0)
+ return rc;
+
install_element_ve(&show_ms_cmd);
install_element_ve(&show_subscr_cmd);
install_element_ve(&show_support_cmd);
@@ -3078,7 +3041,8 @@ int ms_vty_init(void)
install_element(CONFIG_NODE, &cfg_ms_create_cmd);
install_element(CONFIG_NODE, &cfg_ms_rename_cmd);
install_element(CONFIG_NODE, &cfg_no_ms_cmd);
- install_node(&ms_node, config_write);
+
+ /* MS_NODE is installed by l23_vty_init(). App specific commands below: */
install_element(MS_NODE, &cfg_ms_show_this_cmd);
install_element(MS_NODE, &cfg_ms_layer2_cmd);
install_element(MS_NODE, &cfg_ms_sap_cmd);
@@ -3205,9 +3169,6 @@ int ms_vty_init(void)
install_element(AUDIO_NODE, &cfg_ms_audio_alsa_out_dev_cmd);
install_element(AUDIO_NODE, &cfg_ms_audio_alsa_in_dev_cmd);
- /* Register the talloc context introspection command */
- osmo_talloc_vty_add_cmds();
-
return 0;
}
diff --git a/src/host/layer23/src/modem/Makefile.am b/src/host/layer23/src/modem/Makefile.am
index 3fa1cebc..3f4c2613 100644
--- a/src/host/layer23/src/modem/Makefile.am
+++ b/src/host/layer23/src/modem/Makefile.am
@@ -16,6 +16,7 @@ bin_PROGRAMS = modem
modem_SOURCES = \
$(top_srcdir)/src/common/main.c \
app_modem.c \
+ vty.c \
$(NULL)
modem_LDADD = \
$(top_builddir)/src/common/liblayer23.a \
diff --git a/src/host/layer23/src/modem/app_modem.c b/src/host/layer23/src/modem/app_modem.c
index 61266f51..a1bb27ab 100644
--- a/src/host/layer23/src/modem/app_modem.c
+++ b/src/host/layer23/src/modem/app_modem.c
@@ -41,6 +41,7 @@
#include <osmocom/bb/common/l1ctl.h>
#include <osmocom/bb/common/l23_app.h>
#include <osmocom/bb/common/sysinfo.h>
+#include <osmocom/bb/modem/vty.h>
#include <l1ctl_proto.h>
@@ -490,12 +491,6 @@ static int l23_cfg_supported(void)
return L23_OPT_ARFCN | L23_OPT_TAP | L23_OPT_VTY | L23_OPT_DBG;
}
-static int l23_vty_init(void)
-{
- /* TODO: add sample specific vty nodes/cmds */
- return 0;
-}
-
static struct vty_app_info _modem_vty_info = {
.name = "modem",
.version = PACKAGE_VERSION,
@@ -505,7 +500,7 @@ static struct l23_app_info info = {
.copyright = "Copyright (C) 2022 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>\n",
.cfg_supported = &l23_cfg_supported,
.vty_info = &_modem_vty_info,
- .vty_init = l23_vty_init,
+ .vty_init = modem_vty_init,
};
struct l23_app_info *l23_app_info(void)
diff --git a/src/host/layer23/src/modem/vty.c b/src/host/layer23/src/modem/vty.c
new file mode 100644
index 00000000..2320efc7
--- /dev/null
+++ b/src/host/layer23/src/modem/vty.c
@@ -0,0 +1,49 @@
+/*
+ * (C) 2023 by sysmocom - s.m.f.c. GmbH <info@sysmocom.de>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#include <osmocom/vty/vty.h>
+#include <osmocom/vty/command.h>
+
+#include <osmocom/bb/common/vty.h>
+#include <osmocom/bb/common/ms.h>
+
+
+static int config_write(struct vty *vty)
+{
+ struct osmocom_ms *ms;
+ llist_for_each_entry(ms, &ms_list, entity)
+ l23_vty_config_write_ms_node(vty, ms, "");
+ return CMD_SUCCESS;
+}
+
+int modem_vty_init(void)
+{
+ int rc;
+
+ if ((rc = l23_vty_init(config_write)) < 0)
+ return rc;
+ install_element_ve(&l23_show_ms_cmd);
+ install_element(CONFIG_NODE, &l23_cfg_ms_cmd);
+
+ return 0;
+}