[PATCH] osmo-iuh[master]: UE Register with TMSI: reply with a Register Reject

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Sat Aug 20 15:09:40 UTC 2016


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

UE Register with TMSI: reply with a Register Reject

When receiving a UE Register Request with TMSI and no IMSI, compose a
Register Reject with the same UE Identity and send.

The accepting function expects a ue_context argument and composes the
message from the IMSI found there. This new rejection message cannot rely
on a ue_context struct and hence uses the asn1 uE_Identity directly.

Change-Id: Ia47e398e50e316842cd260dc0d9a4e2d8a1c627c
---
M src/hnbgw_hnbap.c
1 file changed, 65 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/osmo-iuh refs/changes/23/723/1

diff --git a/src/hnbgw_hnbap.c b/src/hnbgw_hnbap.c
index 8a0bc9b..5246b81 100644
--- a/src/hnbgw_hnbap.c
+++ b/src/hnbgw_hnbap.c
@@ -114,6 +114,69 @@
 	return hnbgw_hnbap_tx(ue->hnb, msg);
 }
 
+static int hnbgw_tx_ue_register_rej_tmsi(struct hnb_context *hnb, UE_Identity_t *ue_id)
+{
+	UERegisterReject_t reject_out;
+	UERegisterRejectIEs_t reject;
+	struct msgb *msg;
+	int rc;
+
+	memset(&reject, 0, sizeof(reject));
+	reject.uE_Identity.present = ue_id->present;
+
+	if (ue_id->present != UE_Identity_PR_tMSILAI) {
+		LOGP(DHNBAP, LOGL_ERROR, "Trying to reject UE Register without IMSI: only rejects of UE_Identity_PR_tMSILAI supported so far.\n");
+		return -1;
+	}
+
+	LOGP(DHNBAP, LOGL_DEBUG, "REJ UE_Id tMSI %d %s\n",
+	     ue_id->choice.tMSILAI.tMSI.size,
+	     osmo_hexdump(ue_id->choice.tMSILAI.tMSI.buf,
+			  ue_id->choice.tMSILAI.tMSI.size));
+
+	LOGP(DHNBAP, LOGL_DEBUG, "REJ UE_Id pLMNID %d %s\n",
+	     ue_id->choice.tMSILAI.lAI.pLMNID.size,
+	     osmo_hexdump(ue_id->choice.tMSILAI.lAI.pLMNID.buf,
+			  ue_id->choice.tMSILAI.lAI.pLMNID.size));
+
+	LOGP(DHNBAP, LOGL_DEBUG, "REJ UE_Id lAC %d %s\n",
+	     ue_id->choice.tMSILAI.lAI.lAC.size,
+	     osmo_hexdump(ue_id->choice.tMSILAI.lAI.lAC.buf,
+			  ue_id->choice.tMSILAI.lAI.lAC.size));
+
+	BIT_STRING_fromBuf(&reject.uE_Identity.choice.tMSILAI.tMSI,
+			   ue_id->choice.tMSILAI.tMSI.buf,
+			   ue_id->choice.tMSILAI.tMSI.size * 8
+			   - ue_id->choice.tMSILAI.tMSI.bits_unused);
+	OCTET_STRING_fromBuf(&reject.uE_Identity.choice.tMSILAI.lAI.pLMNID,
+			     ue_id->choice.tMSILAI.lAI.pLMNID.buf,
+			     ue_id->choice.tMSILAI.lAI.pLMNID.size);
+	OCTET_STRING_fromBuf(&reject.uE_Identity.choice.tMSILAI.lAI.lAC,
+			     ue_id->choice.tMSILAI.lAI.lAC.buf,
+			     ue_id->choice.tMSILAI.lAI.lAC.size);
+
+	reject.cause.present = Cause_PR_radioNetwork;
+	reject.cause.choice.radioNetwork = CauseRadioNetwork_invalid_UE_identity;
+
+	memset(&reject_out, 0, sizeof(reject_out));
+	rc = hnbap_encode_ueregisterrejecties(&reject_out, &reject);
+	if (rc < 0) {
+		return rc;
+	}
+
+	msg = hnbap_generate_unsuccessful_outcome(ProcedureCode_id_UERegister,
+						  Criticality_reject,
+						  &asn_DEF_UERegisterReject,
+						  &reject_out);
+
+	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_BIT_STRING, &reject.uE_Identity.choice.tMSILAI.tMSI);
+	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_OCTET_STRING, &reject.uE_Identity.choice.tMSILAI.lAI.pLMNID);
+	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_OCTET_STRING, &reject.uE_Identity.choice.tMSILAI.lAI.lAC);
+	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_UERegisterReject, &reject_out);
+
+	return hnbgw_hnbap_tx(hnb, msg);
+}
+
 static int hnbgw_rx_hnb_deregister(struct hnb_context *ctx, ANY_t *in)
 {
 	HNBDe_RegisterIEs_t ies;
@@ -187,8 +250,9 @@
 		LOGP(DHNBAP, LOGL_NOTICE, "UE-REGISTER-REQ without IMSI\n");
 		/* TODO: this is probably a TMSI registration. Store TMSIs
 		 * and look them up to accept UE Registration. */
+		rc = hnbgw_tx_ue_register_rej_tmsi(ctx, &ies.uE_Identity);
 		hnbap_free_ueregisterrequesties(&ies);
-		return -1;
+		return rc;
 	}
 
 	DEBUGP(DHNBAP, "UE-REGISTER-REQ ID_type=%d imsi=%s cause=%ld\n",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia47e398e50e316842cd260dc0d9a4e2d8a1c627c
Gerrit-PatchSet: 1
Gerrit-Project: osmo-iuh
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list