Commit b1aa51a8 authored by aligungr's avatar aligungr

Registration reject improvement

parent afbb2569
...@@ -45,6 +45,8 @@ class NasMm ...@@ -45,6 +45,8 @@ class NasMm
bool m_lastDeregDueToDisable5g{}; bool m_lastDeregDueToDisable5g{};
// Last time PLMN search is triggered // Last time PLMN search is triggered
long m_lastPlmnSearchTrigger{}; long m_lastPlmnSearchTrigger{};
// Registration attempt counter
int m_regCounter{};
friend class UeCmdHandler; friend class UeCmdHandler;
...@@ -95,6 +97,7 @@ class NasMm ...@@ -95,6 +97,7 @@ class NasMm
void sendRegistration(nas::ERegistrationType registrationType, nas::EFollowOnRequest followOn); void sendRegistration(nas::ERegistrationType registrationType, nas::EFollowOnRequest followOn);
void receiveRegistrationAccept(const nas::RegistrationAccept &msg); void receiveRegistrationAccept(const nas::RegistrationAccept &msg);
void receiveRegistrationReject(const nas::RegistrationReject &msg); void receiveRegistrationReject(const nas::RegistrationReject &msg);
void incrementRegistrationAttempt();
/* Authentication */ /* Authentication */
void receiveAuthenticationRequest(const nas::AuthenticationRequest &msg); void receiveAuthenticationRequest(const nas::AuthenticationRequest &msg);
......
...@@ -124,12 +124,11 @@ void NasMm::receiveRegistrationReject(const nas::RegistrationReject &msg) ...@@ -124,12 +124,11 @@ void NasMm::receiveRegistrationReject(const nas::RegistrationReject &msg)
nas::utils::EnumToString(msg.eapMessage->eap->code)); nas::utils::EnumToString(msg.eapMessage->eap->code));
} }
auto unhandledRejectCase = [cause, this]() { switchRmState(ERmState::RM_DEREGISTERED);
m_storage.discardUsim();
m_logger->err("Registration rejected with unhandled MMCause: %s", nas::utils::EnumToString(cause)); auto handleAbnormalCase = [cause, this]() {
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA); m_logger->debug("Handling Registration Reject abnormal case");
switchRmState(ERmState::RM_DEREGISTERED); // todo
}; };
if (regType == nas::ERegistrationType::INITIAL_REGISTRATION) if (regType == nas::ERegistrationType::INITIAL_REGISTRATION)
...@@ -137,24 +136,86 @@ void NasMm::receiveRegistrationReject(const nas::RegistrationReject &msg) ...@@ -137,24 +136,86 @@ void NasMm::receiveRegistrationReject(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::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::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || 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::NO_SUITIBLE_CELLS_IN_TA || cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{ {
switchUState(E5UState::U3_ROAMING_NOT_ALLOWED); switchUState(E5UState::U3_ROAMING_NOT_ALLOWED);
m_storage.invalidateSim(); }
if (cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
switchUState(E5UState::U2_NOT_UPDATED);
}
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::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA ||
cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA || cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
m_storage.m_storedGuti = {};
m_storage.m_lastVisitedRegisteredTai = {};
m_storage.m_taiList = {};
m_storage.m_currentNsCtx = {};
m_storage.m_nonCurrentNsCtx = {};
}
// TODO Normally UE switches to PLMN SEARCH, but this leads to endless registration attempt again and again. if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
// due to RLS. cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED)
// switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_PLMN_SEARCH); {
m_storage.invalidateSim__();
}
if (cause == nas::EMmCause::ILLEGAL_UE || cause == nas::EMmCause::ILLEGAL_ME ||
cause == nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA); switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
}
if (cause == nas::EMmCause::TA_NOT_ALLOWED || cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA ||
cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_LIMITED_SERVICE);
}
if (cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
switchMmState(EMmState::MM_NULL, EMmSubState::MM_NULL_NA);
// TODO: disable n1 mode capability (See 4.9)
}
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_PLMN_SEARCH);
}
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::N1_MODE_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
m_regCounter = 0;
}
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_storage.m_equivalentPlmnList = {};
}
switchRmState(ERmState::RM_DEREGISTERED); if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA || cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{
// TODO add to forbidden tai
} }
else if (cause == nas::EMmCause::CONGESTION)
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
// todo add to forbidden plmn
}
if (cause == nas::EMmCause::CONGESTION)
{ {
if (msg.t3346value.has_value() && nas::utils::HasValue(*msg.t3346value)) if (msg.t3346value.has_value() && nas::utils::HasValue(*msg.t3346value))
{ {
switchUState(E5UState::U2_NOT_UPDATED);
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_ATTEMPTING_REGISTRATION); switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_ATTEMPTING_REGISTRATION);
switchRmState(ERmState::RM_DEREGISTERED);
m_timers->t3346.stop(); m_timers->t3346.stop();
if (msg.sht != nas::ESecurityHeaderType::NOT_PROTECTED) if (msg.sht != nas::ESecurityHeaderType::NOT_PROTECTED)
...@@ -164,41 +225,32 @@ void NasMm::receiveRegistrationReject(const nas::RegistrationReject &msg) ...@@ -164,41 +225,32 @@ void NasMm::receiveRegistrationReject(const nas::RegistrationReject &msg)
} }
else else
{ {
// TODO abnormal case see 5.5.1.2.7. handleAbnormalCase();
unhandledRejectCase();
} }
} }
else if (cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
m_storage.discardUsim();
switchMmState(EMmState::MM_NULL, EMmSubState::MM_NULL_NA); if (cause != nas::EMmCause::ILLEGAL_UE && cause != nas::EMmCause::ILLEGAL_ME &&
switchRmState(ERmState::RM_DEREGISTERED); cause != nas::EMmCause::FIVEG_SERVICES_NOT_ALLOWED && cause != nas::EMmCause::PLMN_NOT_ALLOWED &&
} cause != nas::EMmCause::TA_NOT_ALLOWED && cause != nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA &&
else cause != nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA && cause != nas::EMmCause::CONGESTION &&
cause != nas::EMmCause::N1_MODE_NOT_ALLOWED && cause != nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{ {
// TODO handleAbnormalCase();
unhandledRejectCase();
} }
} }
else if (regType == nas::ERegistrationType::EMERGENCY_REGISTRATION) else if (regType == nas::ERegistrationType::EMERGENCY_REGISTRATION)
{ {
if (cause == nas::EMmCause::PEI_NOT_ACCEPTED) // TODO
{
// TODO
unhandledRejectCase();
}
else
{
// TODO: abnormal case
unhandledRejectCase();
}
} }
else else
{ {
// TODO // TODO
unhandledRejectCase();
} }
} }
void NasMm::incrementRegistrationAttempt()
{
m_regCounter++;
}
} // namespace nr::ue } // namespace nr::ue
\ No newline at end of file
...@@ -29,7 +29,10 @@ class MobileStorage ...@@ -29,7 +29,10 @@ class MobileStorage
nas::IE5gsMobileIdentity m_storedSuci{}; nas::IE5gsMobileIdentity m_storedSuci{};
// Plmn related // Plmn related
std::optional<nas::IE5gsTrackingAreaIdentityList> m_taiList{}; nas::IE5gsTrackingAreaIdentityList m_taiList{};
nas::IE5gsTrackingAreaIdentityList m_forbiddenTaiList{};
nas::IEPlmnList m_equivalentPlmnList{};
nas::IEPlmnList m_forbiddenPlmnList{};
// Security related // Security related
std::optional<NasSecurityContext> m_currentNsCtx{}; std::optional<NasSecurityContext> m_currentNsCtx{};
...@@ -72,10 +75,9 @@ class MobileStorage ...@@ -72,10 +75,9 @@ class MobileStorage
discardSecurity(); discardSecurity();
} }
void invalidateSim() void invalidateSim__()
{ {
// TODO: log // TODO: log
discardUsim();
m_simIsValid = false; m_simIsValid = false;
} }
......
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