[PATCH] osmocom-bb[master]: mobile: Change started and shutdown state through function

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Holger Freyther gerrit-no-reply at lists.osmocom.org
Sun Nov 19 15:23:50 UTC 2017


Review at  https://gerrit.osmocom.org/4930

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
---
M src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
M src/host/layer23/src/mobile/app_mobile.c
2 files changed, 21 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/30/4930/1

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 6162a38..83c07d6 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_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 d28af00..c5c84e6 100644
--- a/src/host/layer23/src/mobile/app_mobile.c
+++ b/src/host/layer23/src/mobile/app_mobile.c
@@ -131,7 +131,7 @@
 			gsm322_cs_sendmsg(ms, nmsg);
 		}
 
-		ms->started = true;
+		mobile_set_started(ms, true);
 	}
 	return 0;
 }
@@ -148,7 +148,7 @@
 	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 @@
 	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 @@
 
 	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 @@
 	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 @@
 	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;
+}

-- 
To view, visit https://gerrit.osmocom.org/4930
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a0591bb2785232681b23e41368323f16d3c960c
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Holger Freyther <holger at freyther.de>



More information about the gerrit-log mailing list