Commit 96407574 authored by aligungr's avatar aligungr

L3 RRC/NAS developments

parent 07ed4cbf
......@@ -47,10 +47,11 @@ bool NasMm::isInNonAllowedArea()
{
if (!m_usim->isValid())
return false;
if (!m_usim->m_currentPlmn.has_value())
return false;
auto &plmn = *m_usim->m_currentPlmn;
auto plmn = m_base->shCtx.getCurrentPlmn();
if (!plmn.hasValue())
return false;
if (nas::utils::ServiceAreaListForbidsPlmn(m_storage->m_serviceAreaList->get(), nas::utils::PlmnFrom(plmn)))
return true;
......
......@@ -16,7 +16,7 @@ namespace nr::ue
void NasMm::receiveAuthenticationRequest(const nas::AuthenticationRequest &msg)
{
m_logger->debug("Authentication Request received.");
m_logger->debug("Authentication Request received");
if (!m_usim->isValid())
{
......@@ -111,7 +111,7 @@ void NasMm::receiveAuthenticationRequestEap(const nas::AuthenticationRequest &ms
return;
}
auto snn = keys::ConstructServingNetworkName(*m_usim->m_currentPlmn);
auto snn = keys::ConstructServingNetworkName(m_base->shCtx.getCurrentPlmn());
if (receivedEap.attributes.getKdfInput() != OctetString::FromAscii(snn))
{
......@@ -196,7 +196,7 @@ void NasMm::receiveAuthenticationRequestEap(const nas::AuthenticationRequest &ms
m_usim->m_nonCurrentNsCtx->keys.kAusf = keys::CalculateKAusfFor5gAka(milenage.ck, milenage.ik, snn, sqnXorAk);
m_usim->m_nonCurrentNsCtx->keys.abba = msg.abba.rawData.copy();
keys::DeriveKeysSeafAmf(*m_base->config, *m_usim->m_currentPlmn, *m_usim->m_nonCurrentNsCtx);
keys::DeriveKeysSeafAmf(*m_base->config, m_base->shCtx.getCurrentPlmn(), *m_usim->m_nonCurrentNsCtx);
// Send response
m_nwConsecutiveAuthFailure = 0;
......@@ -346,7 +346,7 @@ void NasMm::receiveAuthenticationRequest5gAka(const nas::AuthenticationRequest &
auto milenage = calculateMilenage(m_usim->m_sqnMng->getSqn(), rand, false);
auto ckIk = OctetString::Concat(milenage.ck, milenage.ik);
auto sqnXorAk = OctetString::Xor(m_usim->m_sqnMng->getSqn(), milenage.ak);
auto snn = keys::ConstructServingNetworkName(*m_usim->m_currentPlmn);
auto snn = keys::ConstructServingNetworkName(m_base->shCtx.getCurrentPlmn());
// Store the relevant parameters
m_usim->m_rand = rand.copy();
......@@ -359,7 +359,7 @@ void NasMm::receiveAuthenticationRequest5gAka(const nas::AuthenticationRequest &
m_usim->m_nonCurrentNsCtx->keys.kAusf = keys::CalculateKAusfFor5gAka(milenage.ck, milenage.ik, snn, sqnXorAk);
m_usim->m_nonCurrentNsCtx->keys.abba = msg.abba.rawData.copy();
keys::DeriveKeysSeafAmf(*m_base->config, *m_usim->m_currentPlmn, *m_usim->m_nonCurrentNsCtx);
keys::DeriveKeysSeafAmf(*m_base->config, m_base->shCtx.getCurrentPlmn(), *m_usim->m_nonCurrentNsCtx);
// Send response
m_nwConsecutiveAuthFailure = 0;
......@@ -413,7 +413,7 @@ void NasMm::receiveAuthenticationResult(const nas::AuthenticationResult &msg)
void NasMm::receiveAuthenticationReject(const nas::AuthenticationReject &msg)
{
m_logger->err("Authentication Reject received.");
m_logger->err("Authentication Reject received");
// The RAND and RES* values stored in the ME shall be deleted and timer T3516, if running, shall be stopped
m_usim->m_rand = {};
......@@ -524,10 +524,10 @@ bool NasMm::networkFailingTheAuthCheck(bool hasChance)
m_logger->err("Network failing the authentication check");
if (m_cmState == ECmState::CM_CONNECTED)
{
localReleaseConnection();
// TODO: treat the active cell as barred
}
{
localReleaseConnection();
// TODO: treat the active cell as barred
}
m_timers->t3520.stop();
return true;
......
......@@ -241,7 +241,8 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED)
{
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(*m_usim->m_currentPlmn));
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList,
nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
}
if (cause == nas::EMmCause::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA ||
......
......@@ -175,7 +175,6 @@ void NasMm::handleServingCellChange(const UeCellInfo &servingCell)
resetRegAttemptCounter();
m_usim->m_servingCell = servingCell;
m_usim->m_currentPlmn = servingCell.cellId.plmn;
m_usim->m_currentTai =
nas::VTrackingAreaIdentity{nas::utils::PlmnFrom(servingCell.cellId.plmn), octet3{servingCell.tac}};
}
......@@ -198,7 +197,6 @@ void NasMm::handleRadioLinkFailure()
}
m_usim->m_servingCell = std::nullopt;
m_usim->m_currentPlmn = std::nullopt;
m_usim->m_currentTai = std::nullopt;
handleRrcConnectionRelease();
......
......@@ -246,7 +246,7 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
});
}
// .. 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_usim->m_currentPlmn));
nas::utils::AddToPlmnList(m_usim->m_equivalentPlmnList, nas::utils::PlmnFrom(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.
......@@ -352,7 +352,7 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg
});
}
// .. 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_usim->m_currentPlmn));
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{}));
......@@ -574,7 +574,7 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(*m_usim->m_currentPlmn));
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
}
if (cause == nas::EMmCause::CONGESTION)
......@@ -738,7 +738,7 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(*m_usim->m_currentPlmn));
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
}
if (cause == nas::EMmCause::CONGESTION)
......
......@@ -305,7 +305,7 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(*m_usim->m_currentPlmn));
nas::utils::AddToPlmnList(m_usim->m_forbiddenPlmnList, nas::utils::PlmnFrom(m_base->shCtx.getCurrentPlmn()));
}
if (cause == nas::EMmCause::TA_NOT_ALLOWED)
......
......@@ -36,7 +36,6 @@ class Usim
// Plmn related
std::optional<UeCellInfo> m_servingCell{};
std::optional<Plmn> m_currentPlmn{};
std::optional<nas::VTrackingAreaIdentity> m_currentTai{};
std::optional<nas::IE5gsTrackingAreaIdentity> m_lastVisitedRegisteredTai{};
nas::IE5gsTrackingAreaIdentityList m_taiList{};
......
......@@ -294,4 +294,9 @@ bool CurrentCellInfo::hasValue() const
return cellId != 0;
}
Plmn UeSharedContext::getCurrentPlmn()
{
return currentCell.get<Plmn>([](auto &value) { return value.plmn; });
}
} // namespace nr::ue
......@@ -11,8 +11,8 @@
#include <array>
#include <atomic>
#include <memory>
#include <unordered_set>
#include <set>
#include <unordered_set>
#include <lib/app/monitor.hpp>
#include <lib/app/ue_ctl.hpp>
......@@ -165,6 +165,8 @@ struct UeSharedContext
Locked<CurrentCellInfo> currentCell;
Locked<std::vector<Tai>> forbiddenTaiRoaming;
Locked<std::vector<Tai>> forbiddenTaiRps;
Plmn getCurrentPlmn();
};
struct TaskBase
......
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