aboutsummaryrefslogtreecommitdiffstats
path: root/src/sgsn/gprs_mm_state_iu_fsm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sgsn/gprs_mm_state_iu_fsm.c')
-rw-r--r--src/sgsn/gprs_mm_state_iu_fsm.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/src/sgsn/gprs_mm_state_iu_fsm.c b/src/sgsn/gprs_mm_state_iu_fsm.c
index 1ed5f56f1..c2e9c4498 100644
--- a/src/sgsn/gprs_mm_state_iu_fsm.c
+++ b/src/sgsn/gprs_mm_state_iu_fsm.c
@@ -1,3 +1,25 @@
+/* TS 23.060 ยง 6.1.2 Mobility Management States (Iu mode) */
+/*
+ * (C) 2019 by sysmocom - s.f.m.c. GmbH <info@sysmocom.de>
+ * All Rights Reserved
+ *
+ * SPDX-License-Identifier: AGPL-3.0+
+ *
+ * Author: Pau Espin Pedrol <pespin@sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#include <arpa/inet.h>
#include <osmocom/core/tdef.h>
@@ -6,6 +28,10 @@
#include <osmocom/sgsn/debug.h>
#include <osmocom/sgsn/sgsn.h>
+#include <osmocom/sgsn/gprs_ranap.h>
+#include <osmocom/sgsn/gtp.h>
+#include <osmocom/sgsn/pdpctx.h>
+#include <osmocom/sgsn/mmctx.h>
#define X(s) (1 << (s))
@@ -38,18 +64,22 @@ static void st_pmm_detached(struct osmo_fsm_inst *fi, uint32_t event, void *data
case E_PMM_PS_ATTACH:
mm_state_iu_fsm_state_chg(fi, ST_PMM_CONNECTED);
break;
- case E_PMM_IMPLICIT_DETACH:
+ case E_PMM_PS_DETACH:
break;
}
}
static void st_pmm_connected(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
+ struct sgsn_mm_ctx *ctx = fi->priv;
+
switch(event) {
case E_PMM_PS_CONN_RELEASE:
+ sgsn_ranap_iu_free(ctx);
mm_state_iu_fsm_state_chg(fi, ST_PMM_IDLE);
break;
- case E_PMM_IMPLICIT_DETACH:
+ case E_PMM_PS_DETACH:
+ sgsn_ranap_iu_release_free(ctx, NULL);
mm_state_iu_fsm_state_chg(fi, ST_PMM_DETACHED);
break;
case E_PMM_RA_UPDATE:
@@ -67,10 +97,11 @@ static void st_pmm_idle_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
static void st_pmm_idle(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
switch(event) {
+ case E_PMM_PS_ATTACH:
case E_PMM_PS_CONN_ESTABLISH:
mm_state_iu_fsm_state_chg(fi, ST_PMM_CONNECTED);
break;
- case E_PMM_IMPLICIT_DETACH:
+ case E_PMM_PS_DETACH:
mm_state_iu_fsm_state_chg(fi, ST_PMM_DETACHED);
break;
}
@@ -78,19 +109,25 @@ static void st_pmm_idle(struct osmo_fsm_inst *fi, uint32_t event, void *data)
static struct osmo_fsm_state mm_state_iu_fsm_states[] = {
[ST_PMM_DETACHED] = {
- .in_event_mask = X(E_PMM_PS_ATTACH) | X(E_PMM_IMPLICIT_DETACH),
+ .in_event_mask = X(E_PMM_PS_ATTACH) | X(E_PMM_PS_DETACH),
.out_state_mask = X(ST_PMM_CONNECTED),
.name = "Detached",
.action = st_pmm_detached,
},
[ST_PMM_CONNECTED] = {
- .in_event_mask = X(E_PMM_PS_CONN_RELEASE) | X(E_PMM_RA_UPDATE) | X(E_PMM_IMPLICIT_DETACH),
+ .in_event_mask =
+ X(E_PMM_PS_CONN_RELEASE) |
+ X(E_PMM_RA_UPDATE) |
+ X(E_PMM_PS_DETACH),
.out_state_mask = X(ST_PMM_DETACHED) | X(ST_PMM_IDLE),
.name = "Connected",
.action = st_pmm_connected,
},
[ST_PMM_IDLE] = {
- .in_event_mask = X(E_PMM_IMPLICIT_DETACH) | X(E_PMM_PS_CONN_ESTABLISH),
+ .in_event_mask =
+ X(E_PMM_PS_DETACH) |
+ X(E_PMM_PS_CONN_ESTABLISH) |
+ X(E_PMM_PS_ATTACH),
.out_state_mask = X(ST_PMM_DETACHED) | X(ST_PMM_CONNECTED),
.name = "Idle",
.onenter = st_pmm_idle_on_enter,
@@ -102,7 +139,7 @@ const struct value_string mm_state_iu_fsm_event_names[] = {
OSMO_VALUE_STRING(E_PMM_PS_ATTACH),
OSMO_VALUE_STRING(E_PMM_PS_CONN_RELEASE),
OSMO_VALUE_STRING(E_PMM_PS_CONN_ESTABLISH),
- OSMO_VALUE_STRING(E_PMM_IMPLICIT_DETACH),
+ OSMO_VALUE_STRING(E_PMM_PS_DETACH),
OSMO_VALUE_STRING(E_PMM_RA_UPDATE),
{ 0, NULL }
};
@@ -117,5 +154,5 @@ struct osmo_fsm mm_state_iu_fsm = {
static __attribute__((constructor)) void mm_state_iu_fsm_init(void)
{
- osmo_fsm_register(&mm_state_iu_fsm);
+ OSMO_ASSERT(osmo_fsm_register(&mm_state_iu_fsm) == 0);
}