Commit 9d841446 authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 6818bd98
...@@ -454,4 +454,51 @@ int TaiListSize(const VPartialTrackingAreaIdentityList &list) ...@@ -454,4 +454,51 @@ int TaiListSize(const VPartialTrackingAreaIdentityList &list)
return static_cast<int>(size); return static_cast<int>(size);
} }
bool ServiceAreaListAllowsPlmn(const IEServiceAreaList &list, const VPlmn &plmn)
{
return std::any_of(list.list.begin(), list.list.end(),
[&plmn](auto &item) { return ServiceAreaListAllowsPlmn(item, plmn); });
}
bool ServiceAreaListAllowsTai(const IEServiceAreaList &list, const VTrackingAreaIdentity &tai)
{
return std::any_of(list.list.begin(), list.list.end(),
[&tai](auto &item) { return ServiceAreaListAllowsTai(item, tai); });
}
bool ServiceAreaListAllowsPlmn(const VPartialServiceAreaList &list, const VPlmn &plmn)
{
if (list.present == 3)
{
if (list.list11->allowedType == EAllowedType::IN_THE_ALLOWED_AREA && DeepEqualsV(list.list11->plmn, plmn))
return true;
}
return false;
}
bool ServiceAreaListAllowsTai(const VPartialServiceAreaList &list, const VTrackingAreaIdentity &tai)
{
if (list.present == 0)
{
if (list.list00->allowedType == EAllowedType::IN_THE_ALLOWED_AREA && DeepEqualsV(list.list00->plmn, tai.plmn) &&
std::any_of(list.list00->tacs.begin(), list.list00->tacs.end(),
[&tai](auto &i) { return (int)i == (int)tai.tac; }))
return true;
}
else if (list.present == 1)
{
if (list.list01->allowedType == EAllowedType::IN_THE_ALLOWED_AREA && DeepEqualsV(list.list01->plmn, tai.plmn) &&
(int)list.list01->tac == (int)tai.tac)
return true;
}
else if (list.present == 2)
{
if (list.list10->allowedType == EAllowedType::IN_THE_ALLOWED_AREA &&
std::any_of(list.list10->tais.begin(), list.list10->tais.end(),
[tai](auto &i) { return DeepEqualsV(i, tai); }))
return true;
}
return false;
}
} // namespace nas::utils } // namespace nas::utils
...@@ -37,6 +37,10 @@ bool ServiceAreaListForbidsPlmn(const nas::IEServiceAreaList &list, const VPlmn ...@@ -37,6 +37,10 @@ bool ServiceAreaListForbidsPlmn(const nas::IEServiceAreaList &list, const VPlmn
bool ServiceAreaListForbidsTai(const nas::IEServiceAreaList &list, const VTrackingAreaIdentity &tai); bool ServiceAreaListForbidsTai(const nas::IEServiceAreaList &list, const VTrackingAreaIdentity &tai);
bool ServiceAreaListForbidsPlmn(const nas::VPartialServiceAreaList &list, const VPlmn &plmn); bool ServiceAreaListForbidsPlmn(const nas::VPartialServiceAreaList &list, const VPlmn &plmn);
bool ServiceAreaListForbidsTai(const nas::VPartialServiceAreaList &list, const VTrackingAreaIdentity &tai); bool ServiceAreaListForbidsTai(const nas::VPartialServiceAreaList &list, const VTrackingAreaIdentity &tai);
bool ServiceAreaListAllowsPlmn(const nas::IEServiceAreaList &list, const VPlmn &plmn);
bool ServiceAreaListAllowsTai(const nas::IEServiceAreaList &list, const VTrackingAreaIdentity &tai);
bool ServiceAreaListAllowsPlmn(const nas::VPartialServiceAreaList &list, const VPlmn &plmn);
bool ServiceAreaListAllowsTai(const nas::VPartialServiceAreaList &list, const VTrackingAreaIdentity &tai);
const char *EnumToString(ERegistrationType v); const char *EnumToString(ERegistrationType v);
const char *EnumToString(EMmCause v); const char *EnumToString(EMmCause v);
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include "mm.hpp" #include "mm.hpp"
#include <unordered_set>
#include <lib/nas/utils.hpp> #include <lib/nas/utils.hpp>
#include <ue/nas/sm/sm.hpp> #include <ue/nas/sm/sm.hpp>
...@@ -16,6 +18,8 @@ namespace nr::ue ...@@ -16,6 +18,8 @@ namespace nr::ue
void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &msg) void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &msg)
{ {
m_logger->debug("Configuration Update Command received");
// Abnormal case: 5.4.4.5, c) Generic UE configuration update and de-registration procedure collision // Abnormal case: 5.4.4.5, c) Generic UE configuration update and de-registration procedure collision
if (m_mmState == EMmState::MM_DEREGISTERED_INITIATED) if (m_mmState == EMmState::MM_DEREGISTERED_INITIATED)
{ {
...@@ -58,6 +62,7 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms ...@@ -58,6 +62,7 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms
hasNewConfig = true; hasNewConfig = true;
m_storage->taiList->set(*msg.taiList); m_storage->taiList->set(*msg.taiList);
updateForbiddenTaiListsForAllowedIndications();
Tai currentTai = m_base->shCtx.getCurrentTai(); Tai currentTai = m_base->shCtx.getCurrentTai();
if (currentTai.hasValue() && if (currentTai.hasValue() &&
...@@ -73,6 +78,7 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms ...@@ -73,6 +78,7 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms
{ {
hasNewConfig = true; hasNewConfig = true;
m_storage->serviceAreaList->set(*msg.serviceAreaList); m_storage->serviceAreaList->set(*msg.serviceAreaList);
updateForbiddenTaiListsForAllowedIndications();
} }
// "If the UE receives new NITZ information in the CONFIGURATION UPDATE COMMAND message, the UE considers the new // "If the UE receives new NITZ information in the CONFIGURATION UPDATE COMMAND message, the UE considers the new
...@@ -199,4 +205,36 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms ...@@ -199,4 +205,36 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms
} }
} }
void NasMm::updateForbiddenTaiListsForAllowedIndications()
{
// "A tracking area shall be removed from the list of "5GS forbidden tracking areas for roaming", as well as the
// list of "5GS forbidden tracking areas for regional provision of service", if the UE receives the tracking area in
// the TAI list or the Service area list of "allowed tracking areas" in REGISTRATION ACCEPT message or a
// CONFIGURATION UPDATE COMMAND message. The UE shall not remove the tracking area from "5GS forbidden tracking
// areas for roaming" or "5GS forbidden tracking areas for regional provision of service" if the UE is registered
// for emergency services"
std::unordered_set<Tai> taiSet;
m_storage->forbiddenTaiListRoaming->forEach([&taiSet, this](auto &value) {
if (nas::utils::TaiListContains(m_storage->taiList->get(), nas::VTrackingAreaIdentity{value}))
taiSet.insert(value);
if (nas::utils::ServiceAreaListAllowsTai(m_storage->serviceAreaList->get(), nas::VTrackingAreaIdentity{value}))
taiSet.insert(value);
});
m_storage->forbiddenTaiListRps->forEach([&taiSet, this](auto &value) {
if (nas::utils::TaiListContains(m_storage->taiList->get(), nas::VTrackingAreaIdentity{value}))
taiSet.insert(value);
if (nas::utils::ServiceAreaListAllowsTai(m_storage->serviceAreaList->get(), nas::VTrackingAreaIdentity{value}))
taiSet.insert(value);
});
for (auto &tai : taiSet)
{
m_storage->forbiddenTaiListRoaming->remove(tai);
m_storage->forbiddenTaiListRps->remove(tai);
}
}
} // namespace nr::ue } // namespace nr::ue
...@@ -142,6 +142,7 @@ class NasMm ...@@ -142,6 +142,7 @@ class NasMm
private: /* Configuration */ private: /* Configuration */
void receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &msg); void receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &msg);
void updateForbiddenTaiListsForAllowedIndications();
private: /* Identity */ private: /* Identity */
void receiveIdentityRequest(const nas::IdentityRequest &msg); void receiveIdentityRequest(const nas::IdentityRequest &msg);
......
...@@ -247,6 +247,8 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg) ...@@ -247,6 +247,8 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
// Store the service area list // Store the service area list
m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{})); m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
updateForbiddenTaiListsForAllowedIndications();
// Store the E-PLMN list and .. // Store the E-PLMN list and ..
m_usim->m_equivalentPlmnList = msg.equivalentPLMNs.value_or(nas::IEPlmnList{}); m_usim->m_equivalentPlmnList = msg.equivalentPLMNs.value_or(nas::IEPlmnList{});
// .. if the initial registration procedure is not for emergency services, the UE shall remove from the list any // .. if the initial registration procedure is not for emergency services, the UE shall remove from the list any
...@@ -383,6 +385,7 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg ...@@ -383,6 +385,7 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg
// Store the service area list // Store the service area list
m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{})); m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
updateForbiddenTaiListsForAllowedIndications();
// "Upon receipt of the REGISTRATION ACCEPT message, the UE shall reset the registration attempt counter and service // "Upon receipt of the REGISTRATION ACCEPT message, the UE shall reset the registration attempt counter and service
// request attempt counter, enter state 5GMM-REGISTERED and set the 5GS update status to 5U1 UPDATED." // request attempt counter, enter state 5GMM-REGISTERED and set the 5GS update status to 5U1 UPDATED."
......
...@@ -166,6 +166,14 @@ std::size_t std::hash<GlobalNci>::operator()(const GlobalNci &v) const noexcept ...@@ -166,6 +166,14 @@ std::size_t std::hash<GlobalNci>::operator()(const GlobalNci &v) const noexcept
return h; return h;
} }
std::size_t std::hash<Tai>::operator()(const Tai &v) const noexcept
{
std::size_t h = 0;
utils::HashCombine(h, v.plmn);
utils::HashCombine(h, v.tac);
return h;
}
bool Plmn::hasValue() const bool Plmn::hasValue() const
{ {
return this->mcc != 0; return this->mcc != 0;
......
...@@ -217,6 +217,12 @@ struct hash<Plmn> ...@@ -217,6 +217,12 @@ struct hash<Plmn>
std::size_t operator()(const Plmn &v) const noexcept; std::size_t operator()(const Plmn &v) const noexcept;
}; };
template <>
struct hash<Tai>
{
std::size_t operator()(const Tai &v) const noexcept;
};
template <> template <>
struct hash<GlobalNci> struct hash<GlobalNci>
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment