aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-10-09 16:21:31 +0200
committerMax <msuraev@sysmocom.de>2017-10-09 16:21:31 +0200
commit86e04df8629f275af04982eb1b8d6c6701db5b1c (patch)
treec3776a3d1c29f624435f12c4bb0b2ff70c6c53f5 /src/gprs
parent6e59122ef94088d936fa5bbedef6bbdd6ca12f23 (diff)
Move P-TMSI alloc/update into separate function
Remove code duplication by allocating and assigning P-TMSI in a static function. Change-Id: Ie5466326a851867d55da389bf18b240acd3f0fc5
Diffstat (limited to 'src/gprs')
-rw-r--r--src/gprs/gprs_gmm.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 7e109b4f5..dff84a9e8 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -1235,6 +1235,19 @@ static int gsm48_rx_gmm_id_resp(struct sgsn_mm_ctx *ctx, struct msgb *msg)
return gsm48_gmm_authorize(ctx);
}
+/* Allocate a new P-TMSI and change context state */
+static inline void ptmsi_update(struct sgsn_mm_ctx *ctx)
+{
+ uint32_t ptmsi;
+ /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */
+ if (ctx->gmm_state != GMM_COMMON_PROC_INIT) {
+ ptmsi = sgsn_alloc_ptmsi();
+ ctx->p_tmsi_old = ctx->p_tmsi;
+ ctx->p_tmsi = ptmsi;
+ }
+ ctx->gmm_state = GMM_COMMON_PROC_INIT;
+}
+
/* Section 9.4.1 Attach request */
static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
struct gprs_llc_llme *llme)
@@ -1391,12 +1404,7 @@ static int gsm48_rx_gmm_att_req(struct sgsn_mm_ctx *ctx, struct msgb *msg,
}
#ifdef PTMSI_ALLOC
/* Allocate a new P-TMSI (+ P-TMSI signature) and update TLLI */
- /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */
- if (ctx->gmm_state != GMM_COMMON_PROC_INIT) {
- ctx->p_tmsi_old = ctx->p_tmsi;
- ctx->p_tmsi = sgsn_alloc_ptmsi();
- }
- ctx->gmm_state = GMM_COMMON_PROC_INIT;
+ ptmsi_update(ctx);
#endif
if (ctx->ran_type == MM_CTX_T_GERAN_Gb) {
@@ -1711,16 +1719,11 @@ static int gsm48_rx_gmm_ra_upd_req(struct sgsn_mm_ctx *mmctx, struct msgb *msg,
rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_RA_UPDATE]);
#ifdef PTMSI_ALLOC
- /* Don't change the P-TMSI if a P-TMSI re-assignment is under way */
- if (mmctx->gmm_state != GMM_COMMON_PROC_INIT) {
- mmctx->p_tmsi_old = mmctx->p_tmsi;
- mmctx->p_tmsi = sgsn_alloc_ptmsi();
- }
+ ptmsi_update(mmctx);
+
/* Start T3350 and re-transmit up to 5 times until ATTACH COMPLETE */
mmctx->t3350_mode = GMM_T3350_MODE_RAU;
mmctx_timer_start(mmctx, 3350, sgsn->cfg.timers.T3350);
-
- mmctx->gmm_state = GMM_COMMON_PROC_INIT;
#else
/* Make sure we are NORMAL (i.e. not SUSPENDED anymore) */
mmctx->gmm_state = GMM_REGISTERED_NORMAL;