pespin has submitted this change. (
https://gerrit.osmocom.org/c/osmocom-bb/+/30978 )
Change subject: layer23: Move layer2-socket VTY command to common/
......................................................................
layer23: Move layer2-socket VTY command to common/
This allows configuring layer2-socket for other apps than mobile, like
the "modem" one.
Change-Id: If7419f8fc54a54eed68a076968d93dba5ac977b7
---
M src/host/layer23/include/osmocom/bb/common/l1l2_interface.h
M src/host/layer23/include/osmocom/bb/common/settings.h
M src/host/layer23/include/osmocom/bb/common/vty.h
M src/host/layer23/src/common/main.c
M src/host/layer23/src/common/ms.c
M src/host/layer23/src/common/settings.c
M 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
9 files changed, 51 insertions(+), 25 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
osmith: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h
b/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h
index 4f46914..9cb993c 100644
--- a/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h
+++ b/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h
@@ -3,6 +3,8 @@
#include <osmocom/core/msgb.h>
+#define L2_DEFAULT_SOCKET_PATH "/tmp/osmocom_l2"
+
int layer2_open(struct osmocom_ms *ms, const char *socket_path);
int layer2_close(struct osmocom_ms *ms);
int osmo_send_l1(struct osmocom_ms *ms, struct msgb *msg);
diff --git a/src/host/layer23/include/osmocom/bb/common/settings.h
b/src/host/layer23/include/osmocom/bb/common/settings.h
index c9a3622..8ebf049 100644
--- a/src/host/layer23/include/osmocom/bb/common/settings.h
+++ b/src/host/layer23/include/osmocom/bb/common/settings.h
@@ -180,5 +180,7 @@
char *gsm_check_imei(const char *imei, const char *sv);
int gsm_random_imei(struct gsm_settings *set);
+extern char *layer2_socket_path;
+
#endif /* _settings_h */
diff --git a/src/host/layer23/include/osmocom/bb/common/vty.h
b/src/host/layer23/include/osmocom/bb/common/vty.h
index f345260..259725e 100644
--- a/src/host/layer23/include/osmocom/bb/common/vty.h
+++ b/src/host/layer23/include/osmocom/bb/common/vty.h
@@ -20,6 +20,9 @@
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);
void l23_vty_config_write_ms_node_contents_final(struct vty *vty, const struct osmocom_ms
*ms, const char *prefix);
+
+extern bool l23_vty_reading;
+
extern struct llist_head ms_list;
extern struct cmd_element l23_show_ms_cmd;
diff --git a/src/host/layer23/src/common/main.c b/src/host/layer23/src/common/main.c
index 8017898..c0064c5 100644
--- a/src/host/layer23/src/common/main.c
+++ b/src/host/layer23/src/common/main.c
@@ -25,6 +25,7 @@
#include <osmocom/bb/misc/layer3.h>
#include <osmocom/bb/common/logging.h>
#include <osmocom/bb/common/l23_app.h>
+#include <osmocom/bb/common/vty.h>
#include <osmocom/core/msgb.h>
#include <osmocom/core/talloc.h>
@@ -51,7 +52,6 @@
void *l23_ctx = NULL;
-static char *layer2_socket_path = "/tmp/osmocom_l2";
static char *sap_socket_path = "/tmp/osmocom_sap";
struct llist_head ms_list;
static struct osmocom_ms *ms = NULL;
@@ -163,7 +163,7 @@
exit(0);
break;
case 's':
- layer2_socket_path = talloc_strdup(l23_ctx, optarg);
+ layer2_socket_path = optarg;
break;
case 'S':
sap_socket_path = talloc_strdup(l23_ctx, optarg);
@@ -230,7 +230,9 @@
if (app->vty_init)
app->vty_init();
if (config_file) {
+ l23_vty_reading = true;
rc = vty_read_config_file(config_file, NULL);
+ l23_vty_reading = false;
if (rc < 0) {
LOGP(DLGLOBAL, LOGL_FATAL,
"Failed to parse the configuration file '%s'\n", config_file);
@@ -288,7 +290,7 @@
exit(1);
}
- rc = layer2_open(ms, layer2_socket_path);
+ rc = layer2_open(ms, ms->settings.layer2_socket_path);
if (rc < 0) {
fprintf(stderr, "Failed during layer2_open()\n");
exit(1);
diff --git a/src/host/layer23/src/common/ms.c b/src/host/layer23/src/common/ms.c
index 74dabc2..9851ebe 100644
--- a/src/host/layer23/src/common/ms.c
+++ b/src/host/layer23/src/common/ms.c
@@ -45,5 +45,8 @@
/* Register a new MS */
llist_add_tail(&ms->entity, &ms_list);
+ gsm_support_init(ms);
+ gsm_settings_init(ms);
+
return ms;
}
diff --git a/src/host/layer23/src/common/settings.c
b/src/host/layer23/src/common/settings.c
index d607aff..fd7177d 100644
--- a/src/host/layer23/src/common/settings.c
+++ b/src/host/layer23/src/common/settings.c
@@ -27,8 +27,11 @@
#include <osmocom/bb/common/osmocom_data.h>
#include <osmocom/bb/common/ms.h>
#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/l1l2_interface.h>
-static char *layer2_socket_path = "/tmp/osmocom_l2";
+/* Used to set default path globally through cmdline */
+char *layer2_socket_path = L2_DEFAULT_SOCKET_PATH;
+
static char *sap_socket_path = "/tmp/osmocom_sap";
static char *mncc_socket_path = "/tmp/ms_mncc";
static char *alsa_dev_default = "default";
diff --git a/src/host/layer23/src/common/vty.c b/src/host/layer23/src/common/vty.c
index a7b65b3..2e7dea8 100644
--- a/src/host/layer23/src/common/vty.c
+++ b/src/host/layer23/src/common/vty.c
@@ -33,6 +33,7 @@
#include <osmocom/bb/common/ms.h>
#include <osmocom/bb/common/networks.h>
#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/common/l1l2_interface.h>
#include <osmocom/bb/mobile/mncc.h>
#include <osmocom/bb/mobile/mncc_ms.h>
#include <osmocom/bb/mobile/transaction.h>
@@ -43,12 +44,24 @@
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/vty/misc.h>
+bool l23_vty_reading = false;
+
static struct cmd_node ms_node = {
MS_NODE,
"%s(ms)# ",
1
};
+static void l23_vty_restart_required_warn(struct vty *vty, struct osmocom_ms *ms)
+{
+ if (l23_vty_reading)
+ return;
+ if (ms->shutdown != MS_SHUTDOWN_NONE)
+ return;
+ vty_out(vty, "You must restart MS '%s' ('shutdown / no shutdown')
for "
+ "change to take effect!%s", ms->name, VTY_NEWLINE);
+}
+
struct osmocom_ms *l23_vty_get_ms(const char *name, struct vty *vty)
{
struct osmocom_ms *ms;
@@ -152,6 +165,19 @@
return CMD_WARNING;
}
+DEFUN(cfg_ms_layer2, cfg_ms_layer2_cmd, "layer2-socket PATH",
+ "Define socket path to connect between layer 2 and layer 1\n"
+ "Unix socket, default '" L2_DEFAULT_SOCKET_PATH "'")
+{
+ struct osmocom_ms *ms = vty->index;
+ struct gsm_settings *set = &ms->settings;
+
+ OSMO_STRLCPY_ARRAY(set->layer2_socket_path, argv[0]);
+
+ l23_vty_restart_required_warn(vty, ms);
+ return CMD_SUCCESS;
+}
+
DEFUN(cfg_ms_no_shutdown, cfg_ms_no_shutdown_cmd, "no shutdown",
NO_STR "Activate and run MS")
{
@@ -216,9 +242,13 @@
l23_vty_config_write_ms_node_contents_final(vty, ms, prefix_content);
}
+/* placeholder for shared VTY commands */
void l23_vty_config_write_ms_node_contents(struct vty *vty, const struct osmocom_ms *ms,
const char *prefix)
{
- /* placeholder for shared VTY commands */
+ const struct gsm_settings *set = &ms->settings;
+
+ vty_out(vty, "%slayer2-socket %s%s", prefix, set->layer2_socket_path,
+ VTY_NEWLINE);
}
/* placeholder for shared VTY commands. Must be put at the end of the node: */
@@ -234,6 +264,7 @@
{
int rc = 0;
install_node(&ms_node, config_write_ms_node_cb);
+ install_element(MS_NODE, &cfg_ms_layer2_cmd);
install_element(MS_NODE, &cfg_ms_shutdown_cmd);
install_element(MS_NODE, &cfg_ms_shutdown_force_cmd);
install_element(MS_NODE, &cfg_ms_no_shutdown_cmd);
diff --git a/src/host/layer23/src/mobile/app_mobile.c
b/src/host/layer23/src/mobile/app_mobile.c
index a161fc3..ae4845d 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -341,11 +341,7 @@
return NULL;
}
- gsm_support_init(ms);
- gsm_settings_init(ms);
-
mobile_set_shutdown(ms, MS_SHUTDOWN_COMPL);
-
return ms;
}
diff --git a/src/host/layer23/src/mobile/vty_interface.c
b/src/host/layer23/src/mobile/vty_interface.c
index ae0e95e..3ffdc54 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -1300,8 +1300,6 @@
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);
vty_out(vty, " mncc-socket %s%s", set->mncc_socket_path, VTY_NEWLINE);
switch (set->mncc_handler) {
@@ -1574,19 +1572,6 @@
return CMD_SUCCESS;
}
-DEFUN(cfg_ms_layer2, cfg_ms_layer2_cmd, "layer2-socket PATH",
- "Define socket path to connect between layer 2 and layer 1\n"
- "Unix socket, default '/tmp/osmocom_l2'")
-{
- struct osmocom_ms *ms = vty->index;
- struct gsm_settings *set = &ms->settings;
-
- OSMO_STRLCPY_ARRAY(set->layer2_socket_path, argv[0]);
-
- vty_restart(vty, ms);
- return CMD_SUCCESS;
-}
-
DEFUN(cfg_ms_sap, cfg_ms_sap_cmd, "sap-socket PATH",
"Define socket path to connect to SIM reader\n"
"Unix socket, default '/tmp/osmocom_sap'")
@@ -3039,7 +3024,6 @@
/* 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);
install_element(MS_NODE, &cfg_ms_mncc_sock_cmd);
install_element(MS_NODE, &cfg_ms_mncc_handler_cmd);
--
To view, visit
https://gerrit.osmocom.org/c/osmocom-bb/+/30978
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Change-Id: If7419f8fc54a54eed68a076968d93dba5ac977b7
Gerrit-Change-Number: 30978
Gerrit-PatchSet: 5
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>
Gerrit-CC: msuraev <msuraev(a)sysmocom.de>
Gerrit-CC: neels <nhofmeyr(a)sysmocom.de>
Gerrit-MessageType: merged