aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-08-29 19:59:07 +0200
committerpespin <pespin@sysmocom.de>2019-09-02 09:42:21 +0000
commit0b72240799c1cc961645a714a78b8c0209fdd7ab (patch)
tree4ce7b28ebaf54d0b3173f7261771e2d3a3720700 /src
parent8333ef10c9e2a3806e04dd9512dbb141d6cb13cc (diff)
Split enum gprs_pmm_state into Iu and Gb counterparts
Those two state sets are not part of the same state machine, and are used in different scenarios, so let's split them and handle them in Gb and Iu specific parts of struct sgsn_mm_ctx. This is required in order to improve related code (for instance, use osmocom fsm). Change-Id: I6100d607da316da0595886c6968704dd9ccfbde9
Diffstat (limited to 'src')
-rw-r--r--src/gprs/gprs_gb.c2
-rw-r--r--src/gprs/gprs_gmm.c45
-rw-r--r--src/gprs/gprs_ranap.c2
-rw-r--r--src/gprs/gprs_sgsn.c4
4 files changed, 27 insertions, 26 deletions
diff --git a/src/gprs/gprs_gb.c b/src/gprs/gprs_gb.c
index 29bfc53e..43af4347 100644
--- a/src/gprs/gprs_gb.c
+++ b/src/gprs/gprs_gb.c
@@ -35,7 +35,7 @@
/* Update the MM context state */
static void gsm0408_gprs_notify_pdu_gb(struct sgsn_mm_ctx *mmctx)
{
- switch (mmctx->pmm_state) {
+ switch (mmctx->gb.mm_state) {
case MM_STANDBY:
mmctx_set_mm_state(mmctx, MM_READY);
break;
diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 33ade4d8..badb881c 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -102,16 +102,20 @@ static const struct tlv_definition gsm48_sm_att_tlvdef = {
},
};
-static const struct value_string gprs_pmm_state_names[] = {
- OSMO_VALUE_STRING(PMM_DETACHED),
- OSMO_VALUE_STRING(PMM_CONNECTED),
- OSMO_VALUE_STRING(PMM_IDLE),
+static const struct value_string gprs_mm_state_gb_names[] = {
OSMO_VALUE_STRING(MM_IDLE),
OSMO_VALUE_STRING(MM_READY),
OSMO_VALUE_STRING(MM_STANDBY),
{ 0, NULL }
};
+static const struct value_string gprs_mm_state_iu_names[] = {
+ OSMO_VALUE_STRING(PMM_DETACHED),
+ OSMO_VALUE_STRING(PMM_CONNECTED),
+ OSMO_VALUE_STRING(PMM_IDLE),
+ { 0, NULL }
+};
+
static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
{
struct sgsn_pdp_ctx *pdp;
@@ -130,14 +134,14 @@ static void mmctx_state_timer_cb(void *_mm)
switch (mm->gb.state_T) {
case 3314:
- switch (mm->pmm_state) {
+ switch (mm->gb.mm_state) {
case MM_READY:
LOGMMCTXP(LOGL_INFO, mm, "T3314 expired\n");
mmctx_set_mm_state(mm, MM_STANDBY);
break;
default:
LOGMMCTXP(LOGL_ERROR, mm, "T3314 expired in state %s != MM_READY\n",
- get_value_string(gprs_pmm_state_names, mm->pmm_state));
+ get_value_string(gprs_mm_state_gb_names, mm->gb.mm_state));
break;
}
break;
@@ -174,16 +178,16 @@ static void mmctx_state_timer_stop(struct sgsn_mm_ctx *mm, unsigned int T)
mm->gb.state_T = 0;
}
-void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
+void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_iu state)
{
OSMO_ASSERT(ctx->ran_type == MM_CTX_T_UTRAN_Iu);
- if (ctx->pmm_state == state)
+ if (ctx->iu.mm_state == state)
return;
LOGMMCTXP(LOGL_INFO, ctx, "Changing PMM state from %s to %s\n",
- get_value_string(gprs_pmm_state_names, ctx->pmm_state),
- get_value_string(gprs_pmm_state_names, state));
+ get_value_string(gprs_mm_state_iu_names, ctx->iu.mm_state),
+ get_value_string(gprs_mm_state_iu_names, state));
switch (state) {
case PMM_IDLE:
@@ -192,23 +196,23 @@ void mmctx_set_pmm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
break;
case PMM_CONNECTED:
break;
- default:
+ case PMM_DETACHED:
break;
}
- ctx->pmm_state = state;
+ ctx->iu.mm_state = state;
}
-void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
+void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_mm_state_gb state)
{
OSMO_ASSERT(ctx->ran_type == MM_CTX_T_GERAN_Gb);
- if (ctx->pmm_state == state)
+ if (ctx->gb.mm_state == state)
return;
LOGMMCTXP(LOGL_INFO, ctx, "Changing MM state from %s to %s\n",
- get_value_string(gprs_pmm_state_names, ctx->pmm_state),
- get_value_string(gprs_pmm_state_names, state));
+ get_value_string(gprs_mm_state_gb_names, ctx->gb.mm_state),
+ get_value_string(gprs_mm_state_gb_names, state));
switch (state) {
case MM_READY:
@@ -216,19 +220,16 @@ void mmctx_set_mm_state(struct sgsn_mm_ctx *ctx, enum gprs_pmm_state state)
mmctx_state_timer_start(ctx, 3314);
break;
case MM_IDLE:
- if (ctx->pmm_state == MM_READY)
+ if (ctx->gb.mm_state == MM_READY)
mmctx_state_timer_stop(ctx, 3314);
break;
case MM_STANDBY:
- if (ctx->pmm_state == MM_READY)
+ if (ctx->gb.mm_state == MM_READY)
mmctx_state_timer_stop(ctx, 3314);
break;
- default:
- /* when changing to state != MM_READY */
- break;
}
- ctx->pmm_state = state;
+ ctx->gb.mm_state = state;
}
/* Our implementation, should be kept in SGSN */
diff --git a/src/gprs/gprs_ranap.c b/src/gprs/gprs_ranap.c
index e0470f60..836937b6 100644
--- a/src/gprs/gprs_ranap.c
+++ b/src/gprs/gprs_ranap.c
@@ -138,7 +138,7 @@ int sgsn_ranap_iu_event(struct ranap_ue_conn_ctx *ctx, enum ranap_iu_event_type
LOGMMCTXP(LOGL_INFO, mm, "IU release for imsi %s\n", mm->imsi);
else
LOGIUP(ctx, LOGL_INFO, "IU release\n");
- if (mm && mm->pmm_state == PMM_CONNECTED)
+ if (mm && mm->iu.mm_state == PMM_CONNECTED)
mmctx_set_pmm_state(mm, PMM_IDLE);
rc = 0;
break;
diff --git a/src/gprs/gprs_sgsn.c b/src/gprs/gprs_sgsn.c
index ee1902c2..2116590d 100644
--- a/src/gprs/gprs_sgsn.c
+++ b/src/gprs/gprs_sgsn.c
@@ -228,7 +228,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_gb(uint32_t tlli,
ctx->ran_type = MM_CTX_T_GERAN_Gb;
ctx->gb.tlli = tlli;
ctx->gmm_state = GMM_DEREGISTERED;
- ctx->pmm_state = MM_IDLE;
+ ctx->gb.mm_state = MM_IDLE;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ciph_algo = sgsn->cfg.cipher;
LOGMMCTXP(LOGL_DEBUG, ctx, "Allocated with %s cipher.\n",
@@ -263,7 +263,7 @@ struct sgsn_mm_ctx *sgsn_mm_ctx_alloc_iu(void *uectx)
ctx->iu.ue_ctx->rab_assign_addr_enc = sgsn->cfg.iu.rab_assign_addr_enc;
ctx->iu.new_key = 1;
ctx->gmm_state = GMM_DEREGISTERED;
- ctx->pmm_state = PMM_DETACHED;
+ ctx->iu.mm_state = PMM_DETACHED;
ctx->auth_triplet.key_seq = GSM_KEY_SEQ_INVAL;
ctx->ctrg = rate_ctr_group_alloc(ctx, &mmctx_ctrg_desc, ue_ctx->conn_id);
if (!ctx->ctrg) {