Commit a40bb41e authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 9d841446
......@@ -501,4 +501,13 @@ bool ServiceAreaListAllowsTai(const VPartialServiceAreaList &list, const VTracki
return false;
}
Plmn PlmnFrom(const VPlmn &plmn)
{
Plmn res;
res.mcc = plmn.mcc;
res.mnc = plmn.mnc;
res.isLongMnc = plmn.isLongMnc;
return res;
}
} // namespace nas::utils
......@@ -17,6 +17,7 @@ IESNssai SNssaiFrom(const SingleSlice &v);
IENssai NssaiFrom(const NetworkSlice &v);
IEDnn DnnFromApn(const std::string &apn);
VPlmn PlmnFrom(const Plmn &plmn);
Plmn PlmnFrom(const VPlmn &plmn);
NetworkSlice NssaiTo(const IENssai &v);
SingleSlice SNssaiTo(const IESNssai &v);
......
......@@ -198,7 +198,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
m_storage->storedGuti->clear();
m_storage->taiList->clear();
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
switchUState(E5UState::U2_NOT_UPDATED);
......@@ -232,7 +232,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED || cause == nas::EMmCause::PLMN_NOT_ALLOWED ||
cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA)
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::TA_NOT_ALLOWED ||
cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA ||
......
......@@ -93,7 +93,7 @@ bool NasMm::switchToECallInactivityIfNeeded()
m_storage->storedGuti->clear();
m_storage->taiList->clear();
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......
......@@ -89,7 +89,7 @@ void NasMm::performPlmnSelection()
continue;
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
continue;
if (nas::utils::PlmnListContains(m_usim->m_equivalentPlmnList, plmn))
if (m_storage->equivalentPlmnList->contains(plmn))
candidates.push_back(plmn);
}
......
......@@ -250,18 +250,19 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
updateForbiddenTaiListsForAllowedIndications();
// Store the E-PLMN list and ..
m_usim->m_equivalentPlmnList = msg.equivalentPLMNs.value_or(nas::IEPlmnList{});
m_storage->equivalentPlmnList->clear();
if (msg.equivalentPLMNs.has_value())
for (auto &item : msg.equivalentPLMNs->plmns)
m_storage->equivalentPlmnList->add(nas::utils::PlmnFrom(item));
// .. if the initial registration procedure is not for emergency services, the UE shall remove from the list any
// PLMN code that is already in the list of "forbidden PLMNs". ..
if (!hasEmergency())
{
utils::EraseWhere(m_usim->m_equivalentPlmnList.plmns, [this](auto &plmn) {
return std::any_of(m_usim->m_forbiddenPlmnList.plmns.begin(), m_usim->m_forbiddenPlmnList.plmns.end(),
[&plmn](auto &forbidden) { return nas::utils::DeepEqualsV(plmn, forbidden); });
});
for (auto &forbiddenPlmn : m_usim->m_forbiddenPlmnList.plmns)
m_storage->equivalentPlmnList->remove(nas::utils::PlmnFrom(forbiddenPlmn));
}
// .. in addition, the UE shall add to the stored list the PLMN code of the registered PLMN that sent the list
nas::utils::AddToPlmnList(m_usim->m_equivalentPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
m_storage->equivalentPlmnList->add(m_base->shCtx.getCurrentPlmn());
// Upon receipt of the REGISTRATION ACCEPT message, the UE shall reset the registration attempt counter, enter state
// 5GMM-REGISTERED and set the 5GS update status to 5U1 UPDATED.
......@@ -370,18 +371,19 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg
}
// Store the E-PLMN list and ..
m_usim->m_equivalentPlmnList = msg.equivalentPLMNs.value_or(nas::IEPlmnList{});
m_storage->equivalentPlmnList->clear();
if (msg.equivalentPLMNs.has_value())
for (auto &item : msg.equivalentPLMNs->plmns)
m_storage->equivalentPlmnList->add(nas::utils::PlmnFrom(item));
// .. if the initial registration procedure is not for emergency services, the UE shall remove from the list any
// PLMN code that is already in the list of "forbidden PLMNs". ..
if (!hasEmergency())
{
utils::EraseWhere(m_usim->m_equivalentPlmnList.plmns, [this](auto &plmn) {
return std::any_of(m_usim->m_forbiddenPlmnList.plmns.begin(), m_usim->m_forbiddenPlmnList.plmns.end(),
[&plmn](auto &forbidden) { return nas::utils::DeepEqualsV(plmn, forbidden); });
});
for (auto &forbiddenPlmn : m_usim->m_forbiddenPlmnList.plmns)
m_storage->equivalentPlmnList->remove(nas::utils::PlmnFrom(forbiddenPlmn));
}
// .. in addition, the UE shall add to the stored list the PLMN code of the registered PLMN that sent the list
nas::utils::AddToPlmnList(m_usim->m_equivalentPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
m_storage->equivalentPlmnList->add(m_base->shCtx.getCurrentPlmn());
// Store the service area list
m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
......@@ -589,7 +591,7 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA)
{
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
}
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
......@@ -750,7 +752,7 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA)
{
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
}
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
......@@ -835,7 +837,7 @@ void NasMm::handleAbnormalInitialRegFailure(nas::ERegistrationType regType)
m_storage->storedGuti->clear();
m_storage->taiList->clear();
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -897,7 +899,7 @@ void NasMm::handleAbnormalMobilityRegFailure(nas::ERegistrationType regType)
// "The UE shall delete the list of equivalent PLMNs and shall change to state
// 5GMM-REGISTERED.ATTEMPTING-REGISTRATION-UPDATE UPDATE"
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
switchMmState(EMmSubState::MM_REGISTERED_ATTEMPTING_REGISTRATION_UPDATE);
}
}
......
......@@ -301,7 +301,7 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED)
{
m_usim->m_equivalentPlmnList = {};
m_storage->equivalentPlmnList->clear();
}
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
......
......@@ -8,9 +8,6 @@
#include "storage.hpp"
static constexpr const size_t FORBIDDEN_TAI_LIST_SIZE = 40;
static constexpr const int64_t FORBIDDEN_TAI_CLEAR_PERIOD = 1000ll * 60ll * 60ll * 12ll;
static void BackupTaiListInSharedCtx(const std::vector<Tai> &buffer, size_t count, Locked<std::vector<Tai>> &target)
{
target.mutate([count, &buffer](auto &value) {
......@@ -32,18 +29,20 @@ MmStorage::MmStorage(TaskBase *base) : m_base{base}
lastVisitedRegisteredTai = std::make_unique<nas::NasSlot<Tai>>(0, std::nullopt);
forbiddenTaiListRoaming = std::make_unique<nas::NasList<Tai>>(
FORBIDDEN_TAI_LIST_SIZE, FORBIDDEN_TAI_CLEAR_PERIOD, [this](const std::vector<Tai> &buffer, size_t count) {
40, (1000ll * 60ll * 60ll * 12ll), [this](const std::vector<Tai> &buffer, size_t count) {
BackupTaiListInSharedCtx(buffer, count, m_base->shCtx.forbiddenTaiRoaming);
});
forbiddenTaiListRps = std::make_unique<nas::NasList<Tai>>(
FORBIDDEN_TAI_LIST_SIZE, FORBIDDEN_TAI_CLEAR_PERIOD, [this](const std::vector<Tai> &buffer, size_t count) {
40, (1000ll * 60ll * 60ll * 12ll), [this](const std::vector<Tai> &buffer, size_t count) {
BackupTaiListInSharedCtx(buffer, count, m_base->shCtx.forbiddenTaiRps);
});
serviceAreaList = std::make_unique<nas::NasSlot<nas::IEServiceAreaList>>(0, std::nullopt);
taiList = std::make_unique<nas::NasSlot<nas::IE5gsTrackingAreaIdentityList>>(0, std::nullopt);
equivalentPlmnList = std::make_unique<nas::NasList<Plmn>>(16, 0, std::nullopt);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -22,6 +22,8 @@ class MmStorage
std::unique_ptr<nas::NasSlot<nas::IE5gsMobileIdentity>> storedSuci;
std::unique_ptr<nas::NasSlot<nas::IE5gsMobileIdentity>> storedGuti;
std::unique_ptr<nas::NasList<Plmn>> equivalentPlmnList;
std::unique_ptr<nas::NasSlot<nas::IE5gsTrackingAreaIdentityList>> taiList;
std::unique_ptr<nas::NasSlot<Tai>> lastVisitedRegisteredTai;
std::unique_ptr<nas::NasList<Tai>> forbiddenTaiListRoaming;
......
......@@ -31,7 +31,6 @@ class Usim
E5UState m_uState{};
// Plmn related
nas::IEPlmnList m_equivalentPlmnList{};
nas::IEPlmnList m_forbiddenPlmnList{};
// Security related
......
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