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