Fix handling of selected PLMN in NGAP
selectedPLMN-Identity IE in RRCSetupComplete is an Index (long) of the PLMN selected by the UE from the plmn-IdentityInfoList (SIB1) (see 3GPP TS 38.331) while Selected PLMN Identity in NGAP INITIAL UE MESSAGE Indicates the selected PLMN id for the non-3GPP access (PLMN Identity ID carrying MNC, MCC and MNC size, 9.2.5.1 3GPP TS 38.413) The legacy code was setting Selected PLMN Identity in the latter to an ID value as the former, however in NGAP the IE to be encoded is PLMN Identity 9.3.3.5 therefore: * set plmn type plmn_id_t in ngap_nas_first_req_t * check whether received selectedPLMN-Identity is within bounds * select PLMN from gNB_RrcConfigurationReq by selectedPLMN-Identity ID note: this commit is assuming that the plmn-IdentityInfoList in SIB1 is matching the PLMN list in gNB_RrcConfigurationReq * in NGAP: store the PLMN in the NGAP UE context, no need to fetch the PLMN in the NGAP instance since the UE context already tells what PLMN was selected Closes #801
This commit is contained in:
@@ -490,22 +490,16 @@ typedef struct ngap_deregistered_gnb_ind_s {
|
||||
* will be the unique identifier used between RRC and NGAP.
|
||||
*/
|
||||
typedef struct ngap_nas_first_req_s {
|
||||
/* UE id for initial connection to NGAP */
|
||||
// RAN UE NGAP ID (mandatory)
|
||||
uint32_t gNB_ue_ngap_id;
|
||||
|
||||
/* the chosen PLMN identity as index, see TS 36.331 6.2.2 RRC Connection
|
||||
* Setup Complete. This index here is zero-based, unlike the standard! */
|
||||
int selected_plmn_identity;
|
||||
|
||||
/* Establishment cause as sent by UE */
|
||||
/* PLMN: Selected PLMN Identity (optional)
|
||||
* User Location Information (mandatory) */
|
||||
plmn_id_t plmn;
|
||||
// RRC Establishment Cause (mandatory)
|
||||
ngap_rrc_establishment_cause_t establishment_cause;
|
||||
|
||||
/* NAS PDU */
|
||||
// NAS-PDU (mandatory)
|
||||
byte_array_t nas_pdu;
|
||||
|
||||
/* If this flag is set NGAP layer is expecting the GUAMI. If = 0,
|
||||
* the temporary s-tmsi is used.
|
||||
*/
|
||||
// UE identity: 5G-S-TMSI, GUAMI
|
||||
ngap_ue_identity_t ue_identity;
|
||||
} ngap_nas_first_req_t;
|
||||
|
||||
|
||||
@@ -149,12 +149,15 @@ void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering)
|
||||
}
|
||||
|
||||
/** @brief Process AMF Identifier and fill GUAMI struct members */
|
||||
static nr_guami_t get_guami(const uint32_t amf_Id)
|
||||
static nr_guami_t get_guami(const uint32_t amf_Id, const plmn_id_t plmn)
|
||||
{
|
||||
nr_guami_t guami = {0};
|
||||
guami.amf_region_id = (amf_Id >> 16) & 0xff;
|
||||
guami.amf_set_id = (amf_Id >> 6) & 0x3ff;
|
||||
guami.amf_pointer = amf_Id & 0x3f;
|
||||
guami.mcc = plmn.mcc;
|
||||
guami.mnc = plmn.mnc;
|
||||
guami.mnc_len = plmn.mnc_digit_length;
|
||||
return guami;
|
||||
}
|
||||
|
||||
@@ -179,13 +182,19 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC
|
||||
// NAS-PDU
|
||||
req->nas_pdu = create_byte_array(rrcSetupComplete->dedicatedNAS_Message.size, rrcSetupComplete->dedicatedNAS_Message.buf);
|
||||
|
||||
// Selected PLMN Identity: indicates the selected PLMN id for the non-3GPP access
|
||||
/* selected_plmn_identity: IE is 1-based, convert to 0-based (C array) */
|
||||
int selected_plmn_identity = rrcSetupComplete->selectedPLMN_Identity - 1;
|
||||
if (selected_plmn_identity != 0)
|
||||
LOG_E(NGAP, "UE %u: sent selected PLMN identity %ld, but only one PLMN supported\n", req->gNB_ue_ngap_id, rrcSetupComplete->selectedPLMN_Identity);
|
||||
|
||||
req->selected_plmn_identity = 0; /* always zero because we only support one */
|
||||
/* Selected PLMN Identity (Optional)
|
||||
* selectedPLMN-Identity in RRCSetupComplete: Index of the PLMN selected by the UE from the plmn-IdentityInfoList (SIB1)
|
||||
* Selected PLMN Identity in INITIAL UE MESSAGE: Indicates the selected PLMN id for the non-3GPP access.*/
|
||||
if (rrcSetupComplete->selectedPLMN_Identity > rrc->configuration.num_plmn) {
|
||||
LOG_E(NGAP,
|
||||
"Failed to send Initial UE Message: selected PLMN (%ld) identity is out of bounds (%d)\n",
|
||||
rrcSetupComplete->selectedPLMN_Identity,
|
||||
rrc->configuration.num_plmn);
|
||||
return;
|
||||
}
|
||||
int selected_plmn_identity = rrcSetupComplete->selectedPLMN_Identity - 1; // Convert 1-based PLMN Identity IE to 0-based index
|
||||
req->plmn = rrc->configuration.plmn[selected_plmn_identity]; // Select from the stored list
|
||||
LOG_I(NGAP, "Selected PLMN in the NG Initial UE Message: MCC %u, MNC %u\n", req->plmn.mcc, req->plmn.mnc);
|
||||
|
||||
/* 5G-S-TMSI */
|
||||
if (UE->Initialue_identity_5g_s_TMSI.presence) {
|
||||
@@ -204,7 +213,7 @@ void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRC
|
||||
NR_RegisteredAMF_t *r_amf = rrcSetupComplete->registeredAMF;
|
||||
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);
|
||||
UE->ue_guami = req->ue_identity.guami = get_guami(amf_Id, req->plmn);
|
||||
LOG_I(NGAP,
|
||||
"GUAMI in NGAP_NAS_FIRST_REQ (UE %04x): AMF Set ID %u, Region ID %u, Pointer %u\n",
|
||||
UE->rnti,
|
||||
|
||||
Reference in New Issue
Block a user