summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/src/mobile/app_mobile.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/app_mobile.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/app_mobile.c')
-rw-r--r--src/host/layer23/src/mobile/app_mobile.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index c5c84e62..b2900ad5 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -181,7 +181,7 @@ int mobile_exit(struct osmocom_ms *ms, int force)
}
/* power-on ms instance */
-int mobile_init(struct osmocom_ms *ms)
+static int mobile_init(struct osmocom_ms *ms)
{
int rc;
@@ -245,6 +245,51 @@ int mobile_init(struct osmocom_ms *ms)
return 0;
}
+int mobile_start(struct osmocom_ms *ms, char **other_name)
+{
+ struct osmocom_ms *tmp;
+ int rc;
+
+ if (ms->shutdown != MS_SHUTDOWN_COMPL)
+ return 0;
+
+ 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)) {
+ LOGP(DMOB, LOGL_ERROR, "Cannot start MS '%s', because MS '%s' "
+ "use the same layer2-socket.\nPlease shutdown "
+ "MS '%s' first.\n", ms->name, tmp->name, tmp->name);
+ *other_name = tmp->name;
+ return -1;
+ }
+ if (!strcmp(ms->settings.sap_socket_path,
+ tmp->settings.sap_socket_path)) {
+ LOGP(DMOB, LOGL_ERROR, "Cannot start MS '%s', because MS '%s' "
+ "use the same sap-socket.\nPlease shutdown "
+ "MS '%s' first.\n", ms->name, tmp->name, tmp->name);
+ *other_name = tmp->name;
+ return -2;
+ }
+ }
+
+ rc = mobile_init(ms);
+ if (rc < 0)
+ return -3;
+ return 0;
+}
+
+int mobile_stop(struct osmocom_ms *ms, int force)
+{
+ if (force && ms->shutdown <= MS_SHUTDOWN_IMSI_DETACH)
+ return mobile_exit(ms, 1);
+ if (!force && ms->shutdown == MS_SHUTDOWN_NONE)
+ return mobile_exit(ms, 0);
+ return 0;
+}
+
+
/* create ms instance */
struct osmocom_ms *mobile_new(char *name)
{