aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2014-10-28 16:23:46 +0100
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-11-14 09:12:10 +0100
commit0074a77424c95d2d7d0608dc0dfabc1948e62fe0 (patch)
tree13b91adf9c7e8620b94cdb1908f74b73dffe4f0d
parent93eae8ec78d145cf87b7858ebee60c72da7a2d20 (diff)
sgsn: Cleanup GMM state transitions
Currently the GMM state is set to GMM-REGISTERED when an Attach Accept or a RA Update Accept message is sent, even if a new P-TMSI is included. In this case 04.08 requires (see 4.7.3.1.3 and 4.7.5.1.3), that the state is set to GMM-COMMON-PROCEDURE-INITIATED when the Accept is sent. When the Complete is received, the SGSN shall set the state to GMM-REGISTERED. This patch modifies the state updates accordingly. Sponsored-by: On-Waves ehf
-rw-r--r--openbsc/src/gprs/gprs_gmm.c16
-rw-r--r--openbsc/tests/sgsn/sgsn_test.c6
2 files changed, 11 insertions, 11 deletions
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index e661b4875..9f34b4ded 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -629,13 +629,11 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
{
/* Request IMSI and IMEI from the MS if they are unknown */
if (!strlen(ctx->imei)) {
- ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->t3370_id_type = GSM_MI_TYPE_IMEI;
mmctx_timer_start(ctx, 3370, GSM0408_T3370_SECS);
return gsm48_tx_gmm_id_req(ctx, GSM_MI_TYPE_IMEI);
}
if (!strlen(ctx->imsi)) {
- ctx->mm_state = GMM_COMMON_PROC_INIT;
ctx->t3370_id_type = GSM_MI_TYPE_IMSI;
mmctx_timer_start(ctx, 3370, GSM0408_T3370_SECS);
return gsm48_tx_gmm_id_req(ctx, GSM_MI_TYPE_IMSI);
@@ -655,9 +653,10 @@ static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx)
/* Start T3350 and re-transmit up to 5 times until ATTACH COMPLETE */
mmctx_timer_start(ctx, 3350, GSM0408_T3350_SECS);
ctx->t3350_mode = GMM_T3350_MODE_ATT;
+#else
+ ctx->mm_state = GMM_REGISTERED_NORMAL;
#endif
- ctx->mm_state = GMM_REGISTERED_NORMAL;
return gsm48_tx_gmm_att_ack(ctx);
default:
LOGMMCTXP(LOGL_ERROR, ctx,
@@ -860,6 +859,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
/* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */
ctx->p_tmsi_old = ctx->p_tmsi;
ctx->p_tmsi = sgsn_alloc_ptmsi();
+ ctx->mm_state = GMM_COMMON_PROC_INIT;
#endif
/* Even if there is no P-TMSI allocated, the MS will switch from
* foreign TLLI to local TLLI */
@@ -1078,6 +1078,11 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
/* Start T3350 and re-transmit up to 5 times until ATTACH COMPLETE */
mmctx->t3350_mode = GMM_T3350_MODE_RAU;
mmctx_timer_start(mmctx, 3350, GSM0408_T3350_SECS);
+
+ mmctx->mm_state = GMM_COMMON_PROC_INIT;
+#else
+ /* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
+ mmctx->mm_state = GMM_REGISTERED_NORMAL;
#endif
/* Even if there is no P-TMSI allocated, the MS will switch from
* foreign TLLI to local TLLI */
@@ -1094,9 +1099,6 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
process_ms_ctx_status(mmctx, pdp_status);
}
- /* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
- mmctx->mm_state = GMM_REGISTERED_NORMAL;
-
/* Send RA UPDATE ACCEPT */
return gsm48_tx_gmm_ra_upd_ack(mmctx);
}
@@ -1189,6 +1191,7 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->tlli = mmctx->tlli_new;
gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new,
GPRS_ALGO_GEA0, NULL);
+ mmctx->mm_state = GMM_REGISTERED_NORMAL;
rc = 0;
break;
case GSM48_MT_GMM_RA_UPD_COMPL:
@@ -1202,6 +1205,7 @@ static int gsm0408_rcv_gmm(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
mmctx->tlli = mmctx->tlli_new;
gprs_llgmm_assign(mmctx->llme, 0xffffffff, mmctx->tlli_new,
GPRS_ALGO_GEA0, NULL);
+ mmctx->mm_state = GMM_REGISTERED_NORMAL;
rc = 0;
break;
case GSM48_MT_GMM_PTMSI_REALL_COMPL:
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index 814b45740..49ee2df20 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -376,11 +376,7 @@ static void test_gmm_attach(void)
* authorization */
OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));
- /* FIXME: If we were authorized, the state should be
- * GMM_COMMON_PROC_INIT until the Attach Complete is received, since a
- * P-TMSI is included, fix state handling in gprs_gmm.c */
-
- /* OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT); */
+ OSMO_ASSERT(ctx->mm_state == GMM_COMMON_PROC_INIT);
/* we expect an attach accept/reject */
OSMO_ASSERT(sgsn_tx_counter == 1);