SGSN: move TLLI unassignment into separate function
Change-Id: Ia4df145ab03ebcaad70a13601cff60c488a5de54
Related: OS#1582
diff --git a/openbsc/include/openbsc/gprs_llc.h b/openbsc/include/openbsc/gprs_llc.h
index d54b72e..8cd0c26 100644
--- a/openbsc/include/openbsc/gprs_llc.h
+++ b/openbsc/include/openbsc/gprs_llc.h
@@ -218,6 +218,7 @@
int gprs_llgmm_assign(struct gprs_llc_llme *llme,
uint32_t old_tlli, uint32_t new_tlli,
enum gprs_ciph_algo alg, const uint8_t *kc);
+int gprs_llgmm_unassign(struct gprs_llc_llme *llme);
int gprs_llc_init(const char *cipher_plugin_path);
int gprs_llc_vty_init(void);
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index 5848a63..5db69dd 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -982,8 +982,7 @@
if (ctx)
mm_ctx_cleanup_free(ctx, "GPRS ATTACH REJ");
else
- /* TLLI unassignment */
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(llme);
return rc;
@@ -1286,11 +1285,8 @@
if (mmctx)
mm_ctx_cleanup_free(mmctx, "GPRS RA UPDATE REJ");
else {
- if (llme) {
- /* TLLI unassignment */
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff,
- GPRS_ALGO_GEA0, NULL);
- }
+ if (llme)
+ gprs_llgmm_unassign(llme);
}
return rc;
@@ -1323,17 +1319,13 @@
/* 4.7.10 */
if (gh->msg_type == GSM48_MT_GMM_STATUS) {
/* TLLI unassignment */
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff,
- GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(llme);
return 0;
}
/* Don't reply or establish a LLME on DETACH_ACK */
- if (gh->msg_type == GSM48_MT_GMM_DETACH_ACK) {
- /* TLLI unassignment */
- return gprs_llgmm_assign(llme, llme->tlli, 0xffffffff,
- GPRS_ALGO_GEA0, NULL);
- }
+ if (gh->msg_type == GSM48_MT_GMM_DETACH_ACK)
+ return gprs_llgmm_unassign(llme);
gprs_llgmm_reset(llme);
@@ -1343,8 +1335,7 @@
rc = gsm48_rx_gmm_det_req(NULL, msg);
/* TLLI unassignment */
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff,
- GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(llme);
return rc;
}
@@ -1352,8 +1343,7 @@
rc = sgsn_force_reattach_oldmsg(msg);
/* TLLI unassignment */
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff,
- GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(llme);
return rc;
}
diff --git a/openbsc/src/gprs/gprs_llc.c b/openbsc/src/gprs/gprs_llc.c
index 71178c9..64d22b3 100644
--- a/openbsc/src/gprs/gprs_llc.c
+++ b/openbsc/src/gprs/gprs_llc.c
@@ -745,6 +745,13 @@
return 0;
}
+/* TLLI unassignment */
+int gprs_llgmm_unassign(struct gprs_llc_llme *llme)
+{
+ return gprs_llgmm_assign(llme, llme->tlli, 0xffffffff, GPRS_ALGO_GEA0,
+ NULL);
+}
+
/* Chapter 7.2.1.2 LLGMM-RESET.req */
int gprs_llgmm_reset(struct gprs_llc_llme *llme)
{
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 8f9f453..98439de 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -770,7 +770,7 @@
/* No MM context found */
LOGP(DGPRS, LOGL_INFO, "Deleting orphaned LLME, TLLI 0x%08x\n",
llme->tlli);
- gprs_llgmm_assign(llme, llme->tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(llme);
}
static void sgsn_llme_check_cb(void *data_)
diff --git a/openbsc/tests/sgsn/sgsn_test.c b/openbsc/tests/sgsn/sgsn_test.c
index f425c33..d568807 100644
--- a/openbsc/tests/sgsn/sgsn_test.c
+++ b/openbsc/tests/sgsn/sgsn_test.c
@@ -222,7 +222,7 @@
OSMO_ASSERT(count(gprs_llme_list()) == 1);
/* unassign which should delete it*/
- gprs_llgmm_assign(lle->llme, lle->llme->tlli, 0xffffffff, GPRS_ALGO_GEA0, NULL);
+ gprs_llgmm_unassign(lle->llme);
/* Check that everything was cleaned up */
OSMO_ASSERT(count(gprs_llme_list()) == 0);