pespin submitted this change.

View Change

Approvals: Jenkins Builder: Verified osmith: Looks good to me, approved
layer23: Initial VTY framework to share VTY code between apps

A small layer23 framework is added which allows apps to easily share/reuse
VTY commands while giving some flexiblity to add new per-app
specific configs/cmds, since not all commands may be relevant for all
apps.

Some of the mobile app code is moved to common, and sample infra is
added to modem app.
Future commits will most probably keep moving more stuff mobile->common
and then reusing those in modem app, as found needed.

Change-Id: Iabfb3129199488d790b89884bc1e424f2aca696f
---
M src/host/layer23/include/osmocom/bb/common/Makefile.am
A src/host/layer23/include/osmocom/bb/common/vty.h
M src/host/layer23/include/osmocom/bb/mobile/vty.h
M src/host/layer23/include/osmocom/bb/modem/Makefile.am
A src/host/layer23/include/osmocom/bb/modem/vty.h
M src/host/layer23/src/common/Makefile.am
A src/host/layer23/src/common/vty.c
M src/host/layer23/src/mobile/app_mobile.c
M src/host/layer23/src/mobile/vty_interface.c
M src/host/layer23/src/modem/Makefile.am
M src/host/layer23/src/modem/app_modem.c
A src/host/layer23/src/modem/vty.c
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 8663d9c..c756b8e 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 @@
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 0000000..dd5e7f2
--- /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 d066804..6bd1b37 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 d99240d..309a514 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 0000000..14ec624
--- /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 f6578ec..7d27eb1 100644
--- a/src/host/layer23/src/common/Makefile.am
+++ b/src/host/layer23/src/common/Makefile.am
@@ -26,4 +26,5 @@
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 0000000..34d39b0
--- /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 b2133f7..b4466de 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -446,7 +446,6 @@
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 6fc7f5b..39a64fd 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 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
{
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 @@
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
{
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@

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 @@
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 @@
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 3fa1ceb..3f4c261 100644
--- a/src/host/layer23/src/modem/Makefile.am
+++ b/src/host/layer23/src/modem/Makefile.am
@@ -16,6 +16,7 @@
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 61266f5..a1bb27a 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 @@
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 @@
.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 0000000..2320efc
--- /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;
+}

To view, visit change 30961. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: Iabfb3129199488d790b89884bc1e424f2aca696f
Gerrit-Change-Number: 30961
Gerrit-PatchSet: 11
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>
Gerrit-CC: msuraev <msuraev@sysmocom.de>
Gerrit-CC: neels <nhofmeyr@sysmocom.de>
Gerrit-MessageType: merged