aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-09-02 16:45:27 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-09-03 15:22:12 +0200
commit31c4657c971e40407163034526aafeb9b5a83460 (patch)
tree3f034b28108531fdbc6c1911b12c4572690b96a2 /include
parent2e91fee1ad5c69f9336716b57979eb7557251778 (diff)
Implement GMM State using osmocom FSM
State machine inspired in the one from TS 24.008 4.1.3.3.1. Some state transitions are inroduced in the code but are still commented out since we lack some functionalitites or improvements in the code to handle different scenarios. Most of the logic is still outside of the FSM, but at least now the states are handled in a sane way triggered by events. Change-Id: Idecb43c10d66224d4f9ba9320825040ce6cf9a07
Diffstat (limited to 'include')
-rw-r--r--include/osmocom/sgsn/Makefile.am1
-rw-r--r--include/osmocom/sgsn/gprs_gmm_fsm.h34
-rw-r--r--include/osmocom/sgsn/gprs_sgsn.h11
3 files changed, 36 insertions, 10 deletions
diff --git a/include/osmocom/sgsn/Makefile.am b/include/osmocom/sgsn/Makefile.am
index 0ab00fe4..9ddc2bc9 100644
--- a/include/osmocom/sgsn/Makefile.am
+++ b/include/osmocom/sgsn/Makefile.am
@@ -6,6 +6,7 @@ noinst_HEADERS = \
gprs_gb.h \
gprs_gb_parse.h \
gprs_gmm.h \
+ gprs_gmm_fsm.h \
gprs_gmm_attach.h \
gprs_mm_state_gb_fsm.h \
gprs_mm_state_iu_fsm.h \
diff --git a/include/osmocom/sgsn/gprs_gmm_fsm.h b/include/osmocom/sgsn/gprs_gmm_fsm.h
new file mode 100644
index 00000000..fd5b4bff
--- /dev/null
+++ b/include/osmocom/sgsn/gprs_gmm_fsm.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <osmocom/core/fsm.h>
+
+/* 3GPP TS 24.008 § 4.1.3.3 GMM mobility management states on the network side */
+enum gmm_fsm_states {
+ ST_GMM_DEREGISTERED, /* 4.1.3.3.1.1 */
+ ST_GMM_COMMON_PROC_INIT, /* 4.1.3.3.1.2 */
+ ST_GMM_REGISTERED_NORMAL, /* 4.1.3.3.2.1 */
+ ST_GMM_REGISTERED_SUSPENDED, /* 4.1.3.3.2.2 */
+ ST_GMM_DEREGISTERED_INIT, /* 4.1.3.3.1.4 */
+};
+
+enum gmm_fsm_events {
+ E_GMM_COMMON_PROC_INIT_REQ,
+ /* E_GMM_COMMON_PROC_FAILED, NOT USED */
+ /* E_GMM_LOWER_LAYER_FAILED, NOT USED */
+ E_GMM_COMMON_PROC_SUCCESS,
+ E_GMM_ATTACH_SUCCESS,
+ /* E_GMM_NET_INIT_DETACH_REQ, NOT USED */
+ /* E_GMM_MS_INIT_DETACH_REQ, NOT USED */
+ /* E_GMM_DETACH_ACCEPTED, */
+ E_GMM_SUSPEND,
+ E_GMM_RESUME,
+ E_GMM_CLEANUP,
+};
+
+static inline bool gmm_fsm_is_registered(struct osmo_fsm_inst *fi)
+{
+ return fi->state == ST_GMM_REGISTERED_NORMAL ||
+ fi->state == ST_GMM_REGISTERED_SUSPENDED;
+}
+
+extern struct osmo_fsm gmm_fsm;
diff --git a/include/osmocom/sgsn/gprs_sgsn.h b/include/osmocom/sgsn/gprs_sgsn.h
index 20e0e06a..0a52a7df 100644
--- a/include/osmocom/sgsn/gprs_sgsn.h
+++ b/include/osmocom/sgsn/gprs_sgsn.h
@@ -23,15 +23,6 @@ struct gprs_subscr;
enum gsm48_gsm_cause;
-/* 3GPP TS 24.008 § 4.1.3.3 GMM mobility management states on the network side */
-enum gprs_gmm_state {
- GMM_DEREGISTERED, /* 4.1.3.3.1.1 */
- GMM_COMMON_PROC_INIT, /* 4.1.3.3.1.2 */
- GMM_REGISTERED_NORMAL, /* 4.1.3.3.2.1 */
- GMM_REGISTERED_SUSPENDED, /* 4.1.3.3.2.2 */
- GMM_DEREGISTERED_INIT, /* 4.1.3.3.1.4 */
-};
-
enum gprs_mm_ctr {
GMM_CTR_PKTS_SIG_IN,
GMM_CTR_PKTS_SIG_OUT,
@@ -128,7 +119,7 @@ struct sgsn_mm_ctx {
enum sgsn_ran_type ran_type;
char imsi[GSM23003_IMSI_MAX_DIGITS+1];
- enum gprs_gmm_state gmm_state;
+ struct osmo_fsm_inst *gmm_fsm;
uint32_t p_tmsi;
uint32_t p_tmsi_old; /* old P-TMSI before new is confirmed */
uint32_t p_tmsi_sig;