Change in ...osmo-sgsn[master]: gprs_gmm: Introduce macros to access msgb's associated IU UE ctx

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/.

pespin gerrit-no-reply at lists.osmocom.org
Mon Aug 12 14:07:33 UTC 2019


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/15158


Change subject: gprs_gmm: Introduce macros to access msgb's associated IU UE ctx
......................................................................

gprs_gmm: Introduce macros to access msgb's associated IU UE ctx

Change-Id: I4d1d47af332d4557e8a3a70c1055bcc172166016
---
M src/gprs/gprs_gmm.c
1 file changed, 20 insertions(+), 22 deletions(-)



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

diff --git a/src/gprs/gprs_gmm.c b/src/gprs/gprs_gmm.c
index 3465a52..c93ddf4 100644
--- a/src/gprs/gprs_gmm.c
+++ b/src/gprs/gprs_gmm.c
@@ -116,6 +116,12 @@
 	{ 0, NULL }
 };
 
+/* On RANAP, Returns pointer to he associated ranap_ue_conn_ctx in msg, filled
+ * in by osmo-iuh's iu_recv_cb().
+ * On Gb, returns NULL */
+#define MSG_IU_UE_CTX(msg) ((struct ranap_ue_conn_ctx *)(msg)->dst)
+#define MSG_IU_UE_CTX_SET(msg, val) (msg)->dst = (val)
+
 static int gsm48_gmm_authorize(struct sgsn_mm_ctx *ctx);
 
 static void mmctx_change_gtpu_endpoints_to_sgsn(struct sgsn_mm_ctx *mm_ctx)
@@ -271,10 +277,7 @@
 	}
 
 #ifdef BUILD_IU
-	/* In Iu mode, msg->dst contains the ranap_ue_conn_ctx pointer, in Gb mode
-	 * dst is empty. */
-	/* FIXME: have a more explicit indicator for Iu messages */
-	if (msg->dst)
+	if (MSG_IU_UE_CTX(msg))
 		return ranap_iu_tx(msg, GPRS_SAPI_GMM);
 #endif
 
@@ -289,7 +292,7 @@
 	msgb_tlli(msg) = msgb_tlli(old);
 	msgb_bvci(msg) = msgb_bvci(old);
 	msgb_nsei(msg) = msgb_nsei(old);
-	msg->dst = old->dst;
+	MSG_IU_UE_CTX_SET(msg, MSG_IU_UE_CTX(old));
 }
 
 /* Store BVCI/NSEI in MM context */
@@ -298,7 +301,7 @@
 	mm->gb.bvci = msgb_bvci(msg);
 	mm->gb.nsei = msgb_nsei(msg);
 	/* In case a Iu connection is reconnected we need to update the ue ctx */
-	mm->iu.ue_ctx = msg->dst;
+	mm->iu.ue_ctx = MSG_IU_UE_CTX(msg);
 	if (mm->ran_type == MM_CTX_T_UTRAN_Iu
 	    && mm->iu.ue_ctx) {
 #ifdef BUILD_IU
@@ -314,7 +317,7 @@
 	msgb_tlli(msg) = mm->gb.tlli;
 	msgb_bvci(msg) = mm->gb.bvci;
 	msgb_nsei(msg) = mm->gb.nsei;
-	msg->dst = mm->iu.ue_ctx;
+	MSG_IU_UE_CTX_SET(msg, mm->iu.ue_ctx);
 }
 
 static void mm_ctx_cleanup_free(struct sgsn_mm_ctx *ctx, const char *log_text)
@@ -1290,15 +1293,12 @@
 	 * with a foreign TLLI (P-TMSI that was allocated to the MS before),
 	 * or with random TLLI. */
 
-	/* In Iu mode, msg->dst contains the ranap_ue_conn_ctx pointer, in Gb mode
-	 * dst is empty. */
-	/* FIXME: have a more explicit indicator for Iu messages */
-	if (!msg->dst) {
+	if (!MSG_IU_UE_CTX(msg)) {
 		/* Gb mode */
 		cid = bssgp_parse_cell_id(&ra_id, msgb_bcid(msg));
 	} else {
 #ifdef BUILD_IU
-		ra_id = ((struct ranap_ue_conn_ctx*)msg->dst)->ra_id;
+		ra_id = MSG_IU_UE_CTX(msg)->ra_id;
 #else
 		LOGMMCTXP(LOGL_ERROR, ctx, "Cannot handle Iu Attach Request, built without Iu support\n");
 		return -ENOTSUP;
@@ -1354,8 +1354,8 @@
 		if (!ctx)
 			ctx = sgsn_mm_ctx_by_imsi(mi_string);
 		if (!ctx) {
-			if (msg->dst)
-				ctx = sgsn_mm_ctx_alloc_iu(msg->dst);
+			if (MSG_IU_UE_CTX(msg))
+				ctx = sgsn_mm_ctx_alloc_iu(MSG_IU_UE_CTX(msg));
 			else
 				ctx = sgsn_mm_ctx_alloc_gb(0, &ra_id);
 			if (!ctx) {
@@ -1379,8 +1379,8 @@
 		if (!ctx) {
 			/* Allocate a context as most of our code expects one.
 			 * Context will not have an IMSI ultil ID RESP is received */
-			if (msg->dst)
-				ctx = sgsn_mm_ctx_alloc_iu(msg->dst);
+			if (MSG_IU_UE_CTX(msg))
+				ctx = sgsn_mm_ctx_alloc_iu(MSG_IU_UE_CTX(msg));
 			else
 				ctx = sgsn_mm_ctx_alloc_gb(msgb_tlli(msg), &ra_id);
 			if (!ctx) {
@@ -1697,10 +1697,8 @@
 		 * is an optimization to avoid the RA reject (impl detached)
 		 * below, which will cause a new attach cycle. */
 		/* Look-up the MM context based on old RA-ID and TLLI */
-		/* In Iu mode, msg->dst contains the ranap_ue_conn_ctx pointer, in Gb
-		 * mode dst is empty. */
-		/* FIXME: have a more explicit indicator for Iu messages */
-		if (!msg->dst) {
+		if (!MSG_IU_UE_CTX(msg)) {
+			/* Gb */
 			mmctx = sgsn_mm_ctx_by_tlli_and_ptmsi(msgb_tlli(msg), &old_ra_id);
 		} else if (TLVP_PRESENT(&tp, GSM48_IE_GMM_ALLOC_PTMSI)) {
 #ifdef BUILD_IU
@@ -1847,7 +1845,7 @@
 	LOGMMCTXP(LOGL_INFO, ctx, "-> GMM SERVICE REQUEST ");
 
 	/* This message is only valid in Iu mode */
-	if (!msg->dst) {
+	if (!MSG_IU_UE_CTX(msg)) {
 		LOGPC(DMM, LOGL_INFO, "Invalid if not in Iu mode\n");
 		return -1;
 	}
@@ -2904,7 +2902,7 @@
 	struct sgsn_mm_ctx *mmctx;
 	int rc = -EINVAL;
 
-	mmctx = sgsn_mm_ctx_by_ue_ctx(msg->dst);
+	mmctx = sgsn_mm_ctx_by_ue_ctx(MSG_IU_UE_CTX(msg));
 	if (mmctx) {
 		rate_ctr_inc(&mmctx->ctrg->ctr[GMM_CTR_PKTS_SIG_IN]);
 		if (ra_id)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-sgsn/+/15158
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I4d1d47af332d4557e8a3a70c1055bcc172166016
Gerrit-Change-Number: 15158
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190812/f5d19eb3/attachment.htm>


More information about the gerrit-log mailing list