summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-15 16:18:28 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2017-11-27 17:54:23 +0800
commit14598ac88d816168e037d701b6f43a2a4cf02f42 (patch)
treeedb5c23f7464dd739267a447d5b8b69bad24e723
parenteddf339871559f282fe615f9c618a1220bd97743 (diff)
mobile: Change started and shutdown state through function
Instead of changing the field all over the place, do the state change in a function. This will allow us to emit a notification when things change. It is similar to the lchan_state. Change-Id: I6a0591bb2785232681b23e41368323f16d3c960c
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/app_mobile.h5
-rw-r--r--src/host/layer23/src/mobile/app_mobile.c23
2 files changed, 21 insertions, 7 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
index 6162a38b..83c07d65 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
@@ -1,6 +1,8 @@
#ifndef APP_MOBILE_H
#define APP_MOBILE_H
+#include <stdbool.h>
+
extern char *config_dir;
int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
@@ -13,5 +15,8 @@ int mobile_init(struct osmocom_ms *ms);
int mobile_exit(struct osmocom_ms *ms, int force);
int mobile_work(struct osmocom_ms *ms);
+void mobile_set_started(struct osmocom_ms *ms, bool state);
+void mobile_set_shutdown(struct osmocom_ms *ms, int state);
+
#endif
diff --git a/src/host/layer23/src/mobile/app_mobile.c b/src/host/layer23/src/mobile/app_mobile.c
index d28af00e..c5c84e62 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -131,7 +131,7 @@ int mobile_signal_cb(unsigned int subsys, unsigned int signal,
gsm322_cs_sendmsg(ms, nmsg);
}
- ms->started = true;
+ mobile_set_started(ms, true);
}
return 0;
}
@@ -148,7 +148,7 @@ int mobile_exit(struct osmocom_ms *ms, int force)
if (!force && ms->started) {
struct msgb *nmsg;
- ms->shutdown = MS_SHUTDOWN_IMSI_DETACH;
+ mobile_set_shutdown(ms, MS_SHUTDOWN_IMSI_DETACH);
nmsg = gsm48_mmevent_msgb_alloc(GSM48_MM_EVENT_IMSI_DETACH);
if (!nmsg)
return -ENOMEM;
@@ -168,10 +168,10 @@ int mobile_exit(struct osmocom_ms *ms, int force)
lapdm_channel_exit(&ms->lapdm_channel);
if (ms->started) {
- ms->shutdown = MS_SHUTDOWN_WAIT_RESET; /* being down, wait for reset */
+ mobile_set_shutdown(ms, MS_SHUTDOWN_WAIT_RESET); /* being down, wait for reset */
l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
} else {
- ms->shutdown = MS_SHUTDOWN_COMPL; /* being down */
+ mobile_set_shutdown(ms, MS_SHUTDOWN_COMPL); /* being down */
}
vty_notify(ms, NULL);
vty_notify(ms, "Power off!\n");
@@ -230,8 +230,8 @@ int mobile_init(struct osmocom_ms *ms)
gsm_random_imei(&ms->settings);
- ms->shutdown = MS_SHUTDOWN_NONE;
- ms->started = false;
+ mobile_set_shutdown(ms, MS_SHUTDOWN_NONE);
+ mobile_set_started(ms, false);
if (!strcmp(ms->settings.imei, "000000000000000")) {
LOGP(DMOB, LOGL_NOTICE, "***\nWarning: Mobile '%s' has default IMEI: %s\n",
@@ -268,7 +268,7 @@ struct osmocom_ms *mobile_new(char *name)
gsm_support_init(ms);
gsm_settings_init(ms);
- ms->shutdown = MS_SHUTDOWN_COMPL;
+ mobile_set_shutdown(ms, MS_SHUTDOWN_COMPL);
if (mncc_recv_app) {
mncc_name = talloc_asprintf(ms, "/tmp/ms_mncc_%s", ms->name);
@@ -444,3 +444,12 @@ int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
return 0;
}
+void mobile_set_started(struct osmocom_ms *ms, bool state)
+{
+ ms->started = state;
+}
+
+void mobile_set_shutdown(struct osmocom_ms *ms, int state)
+{
+ ms->shutdown = state;
+}