From 8a0baed43094531eee6487c8e12f40c8d021e900 Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Thu, 8 May 2025 15:31:42 +0200 Subject: [PATCH] Handle both 5G-S-TMSI and GUAMI in the NGAP Initial UE Message procedures * use bitmask to select presence of either 5G-S-TMSI or GUAMI * select the AMF based on (1) absence of UE Identity (2) Presence of GUAMI (3) Presence of 5G-S-TMSI Related to #801 --- openair2/COMMON/ngap_messages_types.h | 1 - openair2/RRC/NR/rrc_gNB_NGAP.c | 15 +++++----- openair3/NGAP/ngap_gNB_nas_procedures.c | 38 ++++++++++++++----------- 3 files changed, 28 insertions(+), 26 deletions(-) diff --git a/openair2/COMMON/ngap_messages_types.h b/openair2/COMMON/ngap_messages_types.h index f833fbdbf0..e54bc46d09 100644 --- a/openair2/COMMON/ngap_messages_types.h +++ b/openair2/COMMON/ngap_messages_types.h @@ -217,7 +217,6 @@ typedef struct ngap_ue_paging_identity_s { } ngap_ue_paging_identity_t; typedef enum ngap_ue_identities_presenceMask_e { - NGAP_UE_IDENTITIES_NONE = 0, NGAP_UE_IDENTITIES_FiveG_s_tmsi = 1 << 1, NGAP_UE_IDENTITIES_guami = 1 << 2, } ngap_ue_identities_presenceMask_t; diff --git a/openair2/RRC/NR/rrc_gNB_NGAP.c b/openair2/RRC/NR/rrc_gNB_NGAP.c index 0749fc12aa..879141144e 100644 --- a/openair2/RRC/NR/rrc_gNB_NGAP.c +++ b/openair2/RRC/NR/rrc_gNB_NGAP.c @@ -189,19 +189,20 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC /* 5G-S-TMSI */ if (UE->Initialue_identity_5g_s_TMSI.presence) { - // 5G-S-TMSI - req->ue_identity.presenceMask = NGAP_UE_IDENTITIES_FiveG_s_tmsi; + req->ue_identity.presenceMask |= NGAP_UE_IDENTITIES_FiveG_s_tmsi; req->ue_identity.s_tmsi.amf_set_id = UE->Initialue_identity_5g_s_TMSI.amf_set_id; req->ue_identity.s_tmsi.amf_pointer = UE->Initialue_identity_5g_s_TMSI.amf_pointer; req->ue_identity.s_tmsi.m_tmsi = UE->Initialue_identity_5g_s_TMSI.fiveg_tmsi; - } else if (rrcSetupComplete->registeredAMF != NULL) { - /** - * Fetch the AMF-Identifier from the registeredAMF IE + } + + /* Process Registered AMF IE */ + if (rrcSetupComplete->registeredAMF != NULL) { + /* Fetch the AMF-Identifier from the registeredAMF IE * The IE AMF-Identifier (AMFI) comprises of an AMF Region ID (8b), * an AMF Set ID (10b) and an AMF Pointer (6b) * as specified in TS 23.003 [21], clause 2.10.1. */ NR_RegisteredAMF_t *r_amf = rrcSetupComplete->registeredAMF; - req->ue_identity.presenceMask = NGAP_UE_IDENTITIES_guami; + req->ue_identity.presenceMask |= NGAP_UE_IDENTITIES_guami; uint32_t amf_Id = BIT_STRING_to_uint32(&r_amf->amf_Identifier); UE->ue_guami = req->ue_identity.guami = get_guami(amf_Id); LOG_I(NGAP, @@ -210,8 +211,6 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC req->ue_identity.guami.amf_set_id, req->ue_identity.guami.amf_region_id, req->ue_identity.guami.amf_pointer); - } else { - req->ue_identity.presenceMask = NGAP_UE_IDENTITIES_NONE; } itti_send_msg_to_task(TASK_NGAP, rrc->module_id, message_p); diff --git a/openair3/NGAP/ngap_gNB_nas_procedures.c b/openair3/NGAP/ngap_gNB_nas_procedures.c index 5fe80db46e..36e9934384 100644 --- a/openair3/NGAP/ngap_gNB_nas_procedures.c +++ b/openair3/NGAP/ngap_gNB_nas_procedures.c @@ -79,9 +79,15 @@ static ngap_gNB_amf_data_t *select_amf(ngap_gNB_instance_t *instance_p, const ng { ngap_gNB_amf_data_t *amf = NULL; - /* Select the AMF corresponding to the provided GUAMI. */ + // Select the AMF corresponding to the GUAMI from the RegisteredAMF IE if (msg->ue_identity.presenceMask & NGAP_UE_IDENTITIES_guami) { const nr_guami_t *guami = &msg->ue_identity.guami; + NGAP_DEBUG("GUAMI is present: MCC=%03d MNC=%03d RegionID=%d SetID=%d Pointer=%d\n", + guami->mcc, + guami->mnc, + guami->amf_region_id, + guami->amf_set_id, + guami->amf_pointer); amf = ngap_gNB_nnsf_select_amf_by_guami(instance_p, msg->establishment_cause, *guami); if (amf) { NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through GUAMI MCC %d MNC %d AMFRI %d AMFSI %d AMFPT %d\n", @@ -93,12 +99,12 @@ static ngap_gNB_amf_data_t *select_amf(ngap_gNB_instance_t *instance_p, const ng guami->amf_region_id, guami->amf_set_id, guami->amf_pointer); + return amf; } } + // Select the AMF corresponding to the provided 5G-S-TMSI if (amf == NULL) { - /* Select the AMF corresponding to the provided s-TMSI. */ - //TODO have not be test. it's should be test if (msg->ue_identity.presenceMask & NGAP_UE_IDENTITIES_FiveG_s_tmsi) { const fiveg_s_tmsi_t *fgs_tmsi = &msg->ue_identity.s_tmsi; amf = ngap_gNB_nnsf_select_amf_by_amf_setid(instance_p, msg->establishment_cause, msg->selected_plmn_identity, fgs_tmsi->amf_set_id); @@ -111,13 +117,14 @@ static ngap_gNB_amf_data_t *select_amf(ngap_gNB_instance_t *instance_p, const ng msg->selected_plmn_identity, instance_p->plmn[msg->selected_plmn_identity].plmn.mcc, instance_p->plmn[msg->selected_plmn_identity].plmn.mnc); + return amf; } } } - if (amf == NULL) { - /* Select AMF based on the selected PLMN identity, received through RRC - * Connection Setup Complete */ + // No UE identity (5G-S-TMSI or GUAMI) is present + if (msg->ue_identity.presenceMask == 0) { + // Select the AMF based on the selected PLMN identity received through RRCSetupComplete amf = ngap_gNB_nnsf_select_amf_by_plmn_id(instance_p, msg->establishment_cause, msg->selected_plmn_identity); if (amf) { NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through selected PLMN Identity index %d MCC %d MNC %d\n", @@ -127,17 +134,14 @@ static ngap_gNB_amf_data_t *select_amf(ngap_gNB_instance_t *instance_p, const ng msg->selected_plmn_identity, instance_p->plmn[msg->selected_plmn_identity].plmn.mcc, instance_p->plmn[msg->selected_plmn_identity].plmn.mnc); - } - } - - if (amf == NULL) { - /* - * If no AMF corresponds to the GUAMI, the s-TMSI, or the selected PLMN - * identity, selects the AMF with the highest capacity. - */ - amf = ngap_gNB_nnsf_select_amf(instance_p, msg->establishment_cause); - if (amf) { - NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through highest relative capacity\n", msg->gNB_ue_ngap_id, amf->amf_name, amf->assoc_id); + return amf; + } else { + // Select the AMF with the highest capacity + amf = ngap_gNB_nnsf_select_amf(instance_p, msg->establishment_cause); + if (amf) { + NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through highest relative capacity\n", msg->gNB_ue_ngap_id, amf->amf_name, amf->assoc_id); + return amf; + } } }