[PATCH] osmo-sgsn[master]: Move P-TMSI alloc/update into separate function

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Mon Oct 9 14:28:17 UTC 2017


Review at  https://gerrit.osmocom.org/4167

Move P-TMSI alloc/update into separate function

Remove code duplication by allocating and assigning P-TMSI in a static
function.

Change-Id: Ie5466326a851867d55da389bf18b240acd3f0fc5
---
M src/gprs/gprs_gmm.c
1 file changed, 16 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/67/4167/1

diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 7e109b4..dff84a9 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -1235,6 +1235,19 @@
 	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 @@
 	}
 #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 @@
 	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;

-- 
To view, visit https://gerrit.osmocom.org/4167
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5466326a851867d55da389bf18b240acd3f0fc5
Gerrit-PatchSet: 1
Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list