sgsn: Split gsm0408_gprs_force_reattach into 2 functions
This patch replaces gsm0408_gprs_force_reattach(msg, mmctx) by two
functions
- gsm0408_gprs_force_reattach(mmctx)
- gsm0408_gprs_force_reattach_oldmsg(msg)
The old function basically consists of the code of the two new
functions, where the code path selected depends on mmctx == NULL,
which is harder to maintain, less obvious to use, and not consistent
with many other SGSN functions.
Sponsored-by: On-Waves ehf
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index 389123d..7119816 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -1689,16 +1689,21 @@
return rc;
}
-int gsm0408_gprs_force_reattach(struct msgb *msg, struct sgsn_mm_ctx *mmctx)
+int gsm0408_gprs_force_reattach_oldmsg(struct msgb *msg)
{
+ int rc;
gprs_llgmm_reset_oldmsg(msg, GPRS_SAPI_GMM);
- if (!mmctx)
- return gsm48_tx_gmm_detach_req_oldmsg(
- msg, GPRS_DET_T_MT_REATT_REQ, GMM_CAUSE_IMPL_DETACHED);
+ rc = gsm48_tx_gmm_detach_req_oldmsg(
+ msg, GPRS_DET_T_MT_REATT_REQ, GMM_CAUSE_IMPL_DETACHED);
- /* Mark MM state as deregistered initiated */
- mmctx->mm_state = GMM_DEREGISTERED_INIT;
+ return rc;
+}
+
+int gsm0408_gprs_force_reattach(struct sgsn_mm_ctx *mmctx)
+{
+ int rc;
+ gprs_llgmm_reset(mmctx->llme);
/* Delete all existing PDP contexts for this MS */
delete_pdp_contexts(mmctx, "forced reattach");
diff --git a/openbsc/src/gprs/gprs_sgsn.c b/openbsc/src/gprs/gprs_sgsn.c
index 15f4753..c4ff3c2 100644
--- a/openbsc/src/gprs/gprs_sgsn.c
+++ b/openbsc/src/gprs/gprs_sgsn.c
@@ -448,6 +448,6 @@
int sgsn_force_reattach_oldmsg(struct msgb *oldmsg)
{
- return gsm0408_gprs_force_reattach(oldmsg, NULL);
+ return gsm0408_gprs_force_reattach_oldmsg(oldmsg);
}