aboutsummaryrefslogtreecommitdiffstats
path: root/src/hnbgw_hnbap.c
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2016-04-25 14:55:35 +0200
committerHarald Welte <laforge@gnumonks.org>2016-09-09 06:34:24 +0000
commit1a0bb5108c5c84cb3dfdca0b848e2fa4c7b03f05 (patch)
treed4a9a6990bb82b02f9466a3c2820644aec0ed93d /src/hnbgw_hnbap.c
parentf6673b725758c1942835cb7241a3510bfec12c6a (diff)
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
Diffstat (limited to 'src/hnbgw_hnbap.c')
-rw-r--r--src/hnbgw_hnbap.c66
1 files changed, 65 insertions, 1 deletions
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",