Commit 9be407e9 authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 509824ae
......@@ -32,6 +32,11 @@ IE5gsTrackingAreaIdentity::IE5gsTrackingAreaIdentity(int mcc, int mnc, bool isLo
{
}
IE5gsTrackingAreaIdentity::IE5gsTrackingAreaIdentity(const Tai &tai)
: mcc(tai.plmn.mcc), mnc(tai.plmn.mnc), isLongMnc(tai.plmn.isLongMnc), trackingAreaCode(tai.tac)
{
}
IE5gsTrackingAreaIdentity IE5gsTrackingAreaIdentity::Decode(const OctetView &stream)
{
auto plmn = VPlmn::Decode(stream);
......
......@@ -34,6 +34,7 @@ struct IE5gsTrackingAreaIdentity : InformationElement3
IE5gsTrackingAreaIdentity() = default;
IE5gsTrackingAreaIdentity(int mcc, int mnc, bool isLongMnc, const octet3 &trackingAreaCode);
explicit IE5gsTrackingAreaIdentity(const Tai &tai);
static IE5gsTrackingAreaIdentity Decode(const OctetView &stream);
static void Encode(const IE5gsTrackingAreaIdentity &ie, OctetString &stream);
......
......@@ -207,6 +207,11 @@ class NasSlot
return m_value;
}
void clear()
{
set(T{});
}
void set(const T &value)
{
autoClearIfNecessary();
......
......@@ -52,12 +52,12 @@ bool NasMm::isInNonAllowedArea()
if (!plmn.hasValue())
return false;
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->m_serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
return true;
int tac = m_base->shCtx.currentCell.get<int>([](auto &value) { return value.tac; });
if (nas::utils::ServiceAreaListForbidsTai(m_storage->m_serviceAreaList->get(),
if (nas::utils::ServiceAreaListForbidsTai(m_storage->serviceAreaList->get(),
nas::VTrackingAreaIdentity{nas::utils::PlmnFrom(plmn), octet3{tac}}))
return true;
......
......@@ -433,7 +433,7 @@ void NasMm::receiveAuthenticationReject(const nas::AuthenticationReject &msg)
// Delete the stored 5G-GUTI, TAI list, last visited registered TAI and ngKSI. The USIM shall be considered invalid
// until switching off the UE or the UICC containing the USIM is removed
m_usim->m_storedGuti = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_taiList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......
......@@ -59,7 +59,7 @@ void NasMm::receiveConfigurationUpdate(const nas::ConfigurationUpdateCommand &ms
if (msg.serviceAreaList.has_value())
{
hasNewConfig = true;
m_storage->m_serviceAreaList->set(*msg.serviceAreaList);
m_storage->serviceAreaList->set(*msg.serviceAreaList);
}
// "If the UE receives new NITZ information in the CONFIGURATION UPDATE COMMAND message, the UE considers the new
......
......@@ -197,7 +197,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
// TS 23.122 [5]; otherwise the UE shall enter the state 5GMM-DEREGISTERED.ATTEMPTING-REGISTRATION."
m_usim->m_storedGuti = {};
m_usim->m_taiList = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -219,7 +219,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
{
switchUState(E5UState::U3_ROAMING_NOT_ALLOWED);
m_usim->m_storedGuti = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_taiList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -250,7 +250,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
{
Tai tai = m_base->shCtx.getCurrentTai();
if (tai.hasValue())
m_storage->m_forbiddenTaiListRoaming->add(tai);
m_storage->forbiddenTaiListRoaming->add(tai);
}
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED)
......
......@@ -89,7 +89,7 @@ bool NasMm::switchToECallInactivityIfNeeded()
// Perform item c) in 5.5.3
m_usim->m_storedGuti = {};
m_usim->m_taiList = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......
......@@ -87,7 +87,7 @@ void NasMm::performPlmnSelection()
continue; // If it's the HPLMN, it's already added above
if (nas::utils::PlmnListContains(m_usim->m_forbiddenPlmnList, plmn))
continue;
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->m_serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
continue;
if (nas::utils::PlmnListContains(m_usim->m_equivalentPlmnList, plmn))
candidates.push_back(plmn);
......@@ -175,6 +175,8 @@ void NasMm::handleActiveCellChange(const Tai &lastTai)
if (!nas::utils::TaiListContains(m_usim->m_taiList, nas::VTrackingAreaIdentity{currentTai}))
sendMobilityRegistration(ERegUpdateCause::ENTER_UNLISTED_TRACKING_AREA);
else
m_storage->lastVisitedRegisteredTai->set(currentTai);
}
}
else if (m_mmState == EMmState::MM_DEREGISTERED)
......@@ -195,6 +197,9 @@ void NasMm::handleActiveCellChange(const Tai &lastTai)
switchMmState(EMmSubState::MM_DEREGISTERED_LIMITED_SERVICE);
else
switchMmState(EMmSubState::MM_DEREGISTERED_PS);
if (nas::utils::TaiListContains(m_usim->m_taiList, nas::VTrackingAreaIdentity{currentTai}))
m_storage->lastVisitedRegisteredTai->set(currentTai);
}
}
else if (m_mmState == EMmState::MM_REGISTERED_INITIATED || m_mmState == EMmState::MM_DEREGISTERED_INITIATED ||
......
......@@ -80,7 +80,9 @@ void NasMm::sendInitialRegistration(EInitialRegCause regCause)
// Assign other fields
request->mobileIdentity = getOrGeneratePreferredId();
request->lastVisitedRegisteredTai = m_usim->m_lastVisitedRegisteredTai;
if (m_storage->lastVisitedRegisteredTai->get().hasValue())
request->lastVisitedRegisteredTai =
nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
if (!requestedNssai.slices.empty())
request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai);
request->ueSecurityCapability = createSecurityCapabilityIe();
......@@ -173,7 +175,9 @@ void NasMm::sendMobilityRegistration(ERegUpdateCause updateCause)
}
// Assign other fields
request->lastVisitedRegisteredTai = m_usim->m_lastVisitedRegisteredTai;
if (m_storage->lastVisitedRegisteredTai->get().hasValue())
request->lastVisitedRegisteredTai =
nas::IE5gsTrackingAreaIdentity{m_storage->lastVisitedRegisteredTai->get()};
request->mobileIdentity = getOrGeneratePreferredId();
if (!requestedNssai.slices.empty())
request->requestedNSSAI = nas::utils::NssaiFrom(requestedNssai);
......@@ -232,7 +236,7 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
// Store the TAI list as a registration area
m_usim->m_taiList = msg.taiList.value_or(nas::IE5gsTrackingAreaIdentityList{});
// Store the service area list
m_storage->m_serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
// Store the E-PLMN list and ..
m_usim->m_equivalentPlmnList = msg.equivalentPLMNs.value_or(nas::IEPlmnList{});
......@@ -355,7 +359,7 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg
nas::utils::AddToPlmnList(m_usim->m_equivalentPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
// Store the service area list
m_storage->m_serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
m_storage->serviceAreaList->set(msg.serviceAreaList.value_or(nas::IEServiceAreaList{}));
// "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."
......@@ -513,7 +517,7 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA || cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
m_usim->m_storedGuti = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_taiList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -565,7 +569,7 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
{
Tai tai = m_base->shCtx.getCurrentTai();
if (tai.hasValue())
m_storage->m_forbiddenTaiListRoaming->add(tai);
m_storage->forbiddenTaiListRoaming->add(tai);
}
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
......@@ -662,7 +666,7 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
cause == nas::EMmCause::UE_IDENTITY_CANNOT_BE_DERIVED_FROM_NETWORK)
{
m_usim->m_storedGuti = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_taiList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -726,7 +730,7 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
{
Tai tai = m_base->shCtx.getCurrentTai();
if (tai.hasValue())
m_storage->m_forbiddenTaiListRoaming->add(tai);
m_storage->forbiddenTaiListRoaming->add(tai);
}
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
......@@ -803,7 +807,7 @@ void NasMm::handleAbnormalInitialRegFailure(nas::ERegistrationType regType)
// The UE shall delete 5G-GUTI, TAI list, last visited TAI, list of equivalent PLMNs and ngKSI, ..
m_usim->m_storedGuti = {};
m_usim->m_taiList = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_equivalentPlmnList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......
......@@ -287,7 +287,7 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
m_usim->m_storedGuti = {};
m_usim->m_lastVisitedRegisteredTai = {};
m_storage->lastVisitedRegisteredTai->clear();
m_usim->m_taiList = {};
m_usim->m_currentNsCtx = {};
m_usim->m_nonCurrentNsCtx = {};
......@@ -312,7 +312,7 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
{
Tai tai = m_base->shCtx.getCurrentTai();
if (tai.hasValue())
m_storage->m_forbiddenTaiListRps->add(tai);
m_storage->forbiddenTaiListRps->add(tai);
}
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
......@@ -320,7 +320,7 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
Tai tai = m_base->shCtx.getCurrentTai();
if (tai.hasValue())
{
m_storage->m_forbiddenTaiListRoaming->add(tai);
m_storage->forbiddenTaiListRoaming->add(tai);
nas::utils::RemoveFromTaiList(m_usim->m_taiList, nas::VTrackingAreaIdentity{tai});
}
}
......
......@@ -25,17 +25,19 @@ namespace nr::ue
MmStorage::MmStorage(TaskBase *base) : m_base{base}
{
m_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) {
BackupTaiListInSharedCtx(buffer, count, m_base->shCtx.forbiddenTaiRoaming);
});
m_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) {
BackupTaiListInSharedCtx(buffer, count, m_base->shCtx.forbiddenTaiRps);
});
m_serviceAreaList = std::make_unique<nas::NasSlot<nas::IEServiceAreaList>>(0, std::nullopt);
serviceAreaList = std::make_unique<nas::NasSlot<nas::IEServiceAreaList>>(0, std::nullopt);
lastVisitedRegisteredTai = std::make_unique<nas::NasSlot<Tai>>(0, std::nullopt);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -19,9 +19,10 @@ class MmStorage
TaskBase *m_base;
public:
std::unique_ptr<nas::NasList<Tai>> m_forbiddenTaiListRoaming;
std::unique_ptr<nas::NasList<Tai>> m_forbiddenTaiListRps;
std::unique_ptr<nas::NasSlot<nas::IEServiceAreaList>> m_serviceAreaList;
std::unique_ptr<nas::NasList<Tai>> forbiddenTaiListRoaming;
std::unique_ptr<nas::NasList<Tai>> forbiddenTaiListRps;
std::unique_ptr<nas::NasSlot<nas::IEServiceAreaList>> serviceAreaList;
std::unique_ptr<nas::NasSlot<Tai>> lastVisitedRegisteredTai;
public:
explicit MmStorage(TaskBase *base);
......
......@@ -35,7 +35,6 @@ class Usim
nas::IE5gsMobileIdentity m_storedGuti{};
// Plmn related
std::optional<nas::IE5gsTrackingAreaIdentity> m_lastVisitedRegisteredTai{};
nas::IE5gsTrackingAreaIdentityList m_taiList{};
nas::IEPlmnList m_equivalentPlmnList{};
nas::IEPlmnList m_forbiddenPlmnList{};
......
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