summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/vty_interface.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-29 14:35:40 +0800
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-12-03 12:58:52 +0000
commit04754e88899c58051ef1a0b0602261f033609dce (patch)
tree256875c1eb48681010194f3c744b0f1adafc1914 /src/host/layer23/src/mobile/vty_interface.c
parentd2cdf93b53ce3eb4714c3c97a5467e3dc455112b (diff)
mobile: Move starting/stopping a MS into a separate function
Move the check if within the mobile app there is no other active MS using the same L1 socket. This way we can call this function from the primitive code as well. Change-Id: Ib4aa5ff212fa6bead8f620abaecc6a0b51a99fec
Diffstat (limited to 'src/host/layer23/src/mobile/vty_interface.c')
-rw-r--r--src/host/layer23/src/mobile/vty_interface.c53
1 files changed, 19 insertions, 34 deletions
diff --git a/src/host/layer23/src/mobile/vty_interface.c b/src/host/layer23/src/mobile/vty_interface.c
index eafed6ea..81c20fe9 100644
--- a/src/host/layer23/src/mobile/vty_interface.c
+++ b/src/host/layer23/src/mobile/vty_interface.c
@@ -2696,35 +2696,25 @@ DEFUN(cfg_test_hplmn, cfg_test_hplmn_cmd, "hplmn-search (everywhere|foreign-coun
DEFUN(cfg_no_shutdown, cfg_ms_no_shutdown_cmd, "no shutdown",
NO_STR "Activate and run MS")
{
- struct osmocom_ms *ms = vty->index, *tmp;
+ struct osmocom_ms *ms = vty->index;
+ char *other_name = NULL;
int rc;
- if (ms->shutdown != MS_SHUTDOWN_COMPL)
- return CMD_SUCCESS;
-
- llist_for_each_entry(tmp, &ms_list, entity) {
- if (tmp->shutdown == MS_SHUTDOWN_COMPL)
- continue;
- if (!strcmp(ms->settings.layer2_socket_path,
- tmp->settings.layer2_socket_path)) {
- vty_out(vty, "Cannot start MS '%s', because MS '%s' "
- "use the same layer2-socket.%sPlease shutdown "
- "MS '%s' first.%s", ms->name, tmp->name,
- VTY_NEWLINE, tmp->name, VTY_NEWLINE);
- return CMD_WARNING;
- }
- if (!strcmp(ms->settings.sap_socket_path,
- tmp->settings.sap_socket_path)) {
- vty_out(vty, "Cannot start MS '%s', because MS '%s' "
- "use the same sap-socket.%sPlease shutdown "
- "MS '%s' first.%s", ms->name, tmp->name,
- VTY_NEWLINE, tmp->name, VTY_NEWLINE);
- return CMD_WARNING;
- }
- }
-
- rc = mobile_init(ms);
- if (rc < 0) {
+ rc = mobile_start(ms, &other_name);
+ switch (rc) {
+ case -1:
+ vty_out(vty, "Cannot start MS '%s', because MS '%s' "
+ "use the same layer2-socket.%sPlease shutdown "
+ "MS '%s' first.%s", ms->name, other_name,
+ VTY_NEWLINE, other_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ case -2:
+ vty_out(vty, "Cannot start MS '%s', because MS '%s' "
+ "use the same sap-socket.%sPlease shutdown "
+ "MS '%s' first.%s", ms->name, other_name,
+ VTY_NEWLINE, other_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ case -3:
vty_out(vty, "Connection to layer 1 failed!%s",
VTY_NEWLINE);
return CMD_WARNING;
@@ -2737,10 +2727,7 @@ DEFUN(cfg_shutdown, cfg_ms_shutdown_cmd, "shutdown",
"Shut down and deactivate MS")
{
struct osmocom_ms *ms = vty->index;
-
- if (ms->shutdown == MS_SHUTDOWN_NONE)
- mobile_exit(ms, 0);
-
+ mobile_stop(ms, 0);
return CMD_SUCCESS;
}
@@ -2749,9 +2736,7 @@ DEFUN(cfg_shutdown_force, cfg_ms_shutdown_force_cmd, "shutdown force",
{
struct osmocom_ms *ms = vty->index;
- if (ms->shutdown <= MS_SHUTDOWN_IMSI_DETACH)
- mobile_exit(ms, 1);
-
+ mobile_stop(ms, 1);
return CMD_SUCCESS;
}