From 238d249b08be899f7db695a358a8a4e6b9031902 Mon Sep 17 00:00:00 2001 From: aligungr Date: Sat, 27 Feb 2021 23:36:23 +0300 Subject: [PATCH 1/2] Generic UE configuration update procedure improvement --- src/ue/mm/config.cpp | 145 +++++++++++++++++++++++++++++++++++++++-- src/ue/nas/storage.hpp | 7 ++ 2 files changed, 145 insertions(+), 7 deletions(-) diff --git a/src/ue/mm/config.cpp b/src/ue/mm/config.cpp index 92a08c35f..1640b0948 100644 --- a/src/ue/mm/config.cpp +++ b/src/ue/mm/config.cpp @@ -8,37 +8,168 @@ #include "mm.hpp" +#include + namespace nr::ue { void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &msg) { + // Indicates there exists at least one configuration to be updated + bool hasNewConfig = false; + + // "Upon receiving the CONFIGURATION UPDATE COMMAND message, the UE shall stop timer T3346 if running" m_timers->t3346.stop(); + // "If the UE receives a new 5G-GUTI in the CONFIGURATION UPDATE COMMAND message, the UE shall consider the new + // 5G-GUTI as valid, the old 5G-GUTI as invalid, stop timer T3519 if running, and delete any stored SUCI;" if (msg.guti.has_value() && msg.guti->type == nas::EIdentityType::GUTI) { + hasNewConfig = true; m_storage.m_storedSuci = {}; m_storage.m_storedGuti = *msg.guti; m_timers->t3519.stop(); } + // "If the UE receives a new TAI list in the CONFIGURATION UPDATE COMMAND message, the UE shall consider the new TAI + // list as valid and the old TAI list as invalid; otherwise, the UE shall consider the old TAI list as valid." if (msg.taiList.has_value()) - m_storage.m_taiList = msg.taiList.value(); + { + hasNewConfig = true; + m_storage.m_taiList = *msg.taiList; + } + + // "If the UE receives a new service area list in the CONFIGURATION UPDATE COMMAND message, the UE shall consider + // the + // new service area list as valid and the old service area list as invalid; otherwise, the UE shall consider the + // old service area list, if any, as valid." + if (msg.serviceAreaList.has_value()) + { + hasNewConfig = true; + m_storage.m_serviceAreaList = *msg.serviceAreaList; + } + + // "If the UE receives new NITZ information in the CONFIGURATION UPDATE COMMAND message, the UE considers the new + // NITZ information as valid and the old NITZ information as invalid; otherwise, the UE shall consider the old NITZ + // information as valid." + if (msg.networkFullName.has_value()) + { + hasNewConfig = true; + m_storage.networkFullName = nas::utils::DeepCopyIe(*msg.networkFullName); + } + if (msg.networkShortName.has_value()) + { + hasNewConfig = true; + m_storage.networkShortName = nas::utils::DeepCopyIe(*msg.networkShortName); + } + if (msg.localTimeZone.has_value()) + { + hasNewConfig = true; + m_storage.localTimeZone = *msg.localTimeZone; + } + if (msg.universalTimeAndLocalTimeZone.has_value()) + { + hasNewConfig = true; + m_storage.universalTimeAndLocalTimeZone = *msg.universalTimeAndLocalTimeZone; + } + if (msg.networkDaylightSavingTime.has_value()) + { + hasNewConfig = true; + m_storage.networkDaylightSavingTime = *msg.networkDaylightSavingTime; + } + + // "If the UE receives a new allowed NSSAI for the associated access type in the CONFIGURATION UPDATE COMMAND + // message, the UE shall consider the new allowed NSSAI as valid for the associated access type, store the allowed + // NSSAI for the associated access type as specified in subclause 4.6.2.2 and consider the old allowed NSSAI for + // the associated access type as invalid; otherwise, the UE shall consider the old Allowed NSSAI as valid for the + // associated access type." + if (msg.allowedNssai.has_value()) + { + hasNewConfig = true; + m_storage.m_allowedNssai = nas::utils::NssaiTo(*msg.allowedNssai); + } + + // "If the UE receives a new configured NSSAI in the CONFIGURATION UPDATE COMMAND message, the UE shall consider the + // new configured NSSAI for the registered PLMN as valid and the old configured NSSAI for the registered PLMN as + // invalid; otherwise, the UE shall consider the old configured NSSAI for the registered PLMN as valid The UE shall + // store the new configured NSSAI as specified in subclause 4.6.2.2." + if (msg.configuredNssai.has_value()) + { + hasNewConfig = true; + m_storage.m_configuredNssai = nas::utils::NssaiTo(*msg.configuredNssai); + } + + // "If the UE receives the Network slicing indication IE in the CONFIGURATION UPDATE COMMAND message with the + // Network slicing subscription change indication set to "Network slicing subscription changed", the UE shall + // delete the network slicing information for each and every PLMN except for the current PLMN as specified in + // subclause 4.6.2.2." + if (msg.networkSlicingIndication.has_value() && + msg.networkSlicingIndication->nssci == nas::ENetworkSlicingSubscriptionChangeIndication::CHANGED) + { + hasNewConfig = true; + handleNetworkSlicingSubscriptionChange(); + } + + // "The UE receiving the rejected NSSAI in the CONFIGURATION UPDATE COMMAND message takes the following actions + // based on the rejection cause in the rejected NSSAI: .." + if (msg.rejectedNssai.has_value()) + { + hasNewConfig = true; + for (auto &rejectedSlice : msg.rejectedNssai->list) + { + SingleSlice slice{}; + slice.sst = rejectedSlice.sst; + slice.sd = rejectedSlice.sd; - if (msg.configurationUpdateIndication.has_value()) + auto &list = rejectedSlice.cause == nas::ERejectedSNssaiCause::NA_IN_PLMN ? m_storage.m_rejectedNssaiInPlmn + : m_storage.m_rejectedNssaiInTa; + list.addIfNotExists(slice); + } + } + + // "If the CONFIGURATION UPDATE COMMAND message indicates "registration requested" in the Configuration update + // indication IE and:" + if (msg.configurationUpdateIndication.has_value() && + msg.configurationUpdateIndication->red == nas::ERegistrationRequested::REQUESTED) { - if (msg.configurationUpdateIndication.has_value()) + // "contains no other parameters or contains at least one of the following parameters: a new allowed NSSAI, + // a new configured NSSAI or the Network slicing subscription change indication, and:" + if (!hasNewConfig || (msg.allowedNssai.has_value() || msg.configuredNssai.has_value() || + msg.networkSlicingIndication.has_value())) { - if (msg.configurationUpdateIndication->red == nas::ERegistrationRequested::REQUESTED) + if (hasEmergency()) // "an emergency PDU session exists," { + // "the UE shall, after the completion of the generic UE configuration + // update procedure and after the emergency PDU session is released, release the existing N1 NAS + // signalling connection, and start a registration procedure for mobility and periodic registration + // update as specified in subclause 5.5.1.3;" // TODO } - if (msg.configurationUpdateIndication->ack == nas::EAcknowledgement::REQUESTED) + else // "no emergency PDU Session exists," { - nas::ConfigurationUpdateComplete resp; - sendNasMessage(resp); + // "the UE shall, after the completion of the generic UE configuration + // update procedure, and the release of the existing N1 NAS signalling connection, start a registration + // procedure for mobility and periodic registration update as specified in subclause 5.5.1.3;" + // TODO } } + + if (msg.micoIndication.has_value() && !msg.allowedNssai.has_value() && !msg.configuredNssai.has_value()) + { + // "an MICO indication is included without a new allowed NSSAI or a new configured NSSAI, the UE shall, + // after the completion of the generic UE configuration update procedure, start a registration procedure + // for mobility and registration update as specified in subclause 5.5.1.3 to re-negotiate MICO mode with + // the network." + // TODO + } + } + + // "If acknowledgement requested is indicated in the Configuration update indication IE in the CONFIGURATION UPDATE + // COMMAND message, the UE shall send a CONFIGURATION UPDATE COMPLETE message." + if (msg.configurationUpdateIndication.has_value() && + msg.configurationUpdateIndication->ack == nas::EAcknowledgement::REQUESTED) + { + sendNasMessage(nas::ConfigurationUpdateComplete{}); } } diff --git a/src/ue/nas/storage.hpp b/src/ue/nas/storage.hpp index 09d7a4e6b..13884ef7d 100644 --- a/src/ue/nas/storage.hpp +++ b/src/ue/nas/storage.hpp @@ -48,6 +48,13 @@ class MobileStorage NetworkSlice m_rejectedNssaiInPlmn{}; NetworkSlice m_rejectedNssaiInTa{}; + // NITZ related + std::optional networkFullName{}; + std::optional networkShortName{}; + std::optional localTimeZone{}; + std::optional universalTimeAndLocalTimeZone{}; + std::optional networkDaylightSavingTime{}; + public: void initialize(bool hasSupi, const UeConfig::Initials &initials) { From 159e260afc7bb2ade73356ea6852ac372bb97439 Mon Sep 17 00:00:00 2001 From: aligungr Date: Sun, 28 Feb 2021 00:36:32 +0300 Subject: [PATCH 2/2] milenage.cpp compilation fix --- src/crypt/milenage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crypt/milenage.cpp b/src/crypt/milenage.cpp index 108374bba..82eb351c5 100644 --- a/src/crypt/milenage.cpp +++ b/src/crypt/milenage.cpp @@ -8,6 +8,7 @@ #include "milenage.hpp" #include +#include namespace crypto::milenage {