From 1a0bb5108c5c84cb3dfdca0b848e2fa4c7b03f05 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Mon, 25 Apr 2016 14:55:35 +0200 Subject: 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 --- src/hnbgw_hnbap.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) (limited to 'src/hnbgw_hnbap.c') 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 @@ static int hnbgw_tx_ue_register_acc(struct ue_context *ue) 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 @@ static int hnbgw_rx_ue_register_req(struct hnb_context *ctx, ANY_t *in) 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", -- cgit v1.2.3