Commit f460d829 authored by aligungr's avatar aligungr

NAS MM refactor

parent 74452fe7
......@@ -138,6 +138,21 @@ void NasMm::performMmCycle()
void NasMm::switchMmState(EMmState state, EMmSubState subState)
{
ERmState oldRmState = m_rmState;
if (state == EMmState::MM_DEREGISTERED || state == EMmState::MM_REGISTERED_INITIATED)
m_rmState = ERmState::RM_DEREGISTERED;
else if (state == EMmState::MM_REGISTERED || state == EMmState::MM_SERVICE_REQUEST_INITIATED ||
state == EMmState::MM_DEREGISTERED_INITIATED)
m_rmState = ERmState::RM_REGISTERED;
onSwitchRmState(oldRmState, m_rmState);
if (m_base->nodeListener)
{
m_base->nodeListener->onSwitch(app::NodeType::UE, m_base->config->getNodeName(), app::StateType::RM,
ToJson(oldRmState).str(), ToJson(m_rmState).str());
}
EMmState oldState = m_mmState;
EMmSubState oldSubState = m_mmSubState;
......@@ -160,25 +175,6 @@ void NasMm::switchMmState(EMmState state, EMmSubState subState)
triggerMmCycle();
}
void NasMm::switchRmState(ERmState state)
{
ERmState oldState = m_rmState;
m_rmState = state;
onSwitchRmState(oldState, m_rmState);
if (m_base->nodeListener)
{
m_base->nodeListener->onSwitch(app::NodeType::UE, m_base->config->getNodeName(), app::StateType::RM,
ToJson(oldState).str(), ToJson(m_rmState).str());
}
// No need to log it
// m_logger->info("UE switches to state [%s]", RmStateName(state));
triggerMmCycle();
}
void NasMm::switchCmState(ECmState state)
{
ECmState oldState = m_cmState;
......@@ -258,7 +254,6 @@ void NasMm::onSwitchCmState(ECmState oldState, ECmState newState)
if (regType == nas::ERegistrationType::INITIAL_REGISTRATION ||
regType == nas::ERegistrationType::EMERGENCY_REGISTRATION)
{
switchRmState(ERmState::RM_DEREGISTERED);
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
switchUState(E5UState::U2_NOT_UPDATED);
......@@ -282,8 +277,6 @@ void NasMm::onSwitchCmState(ECmState oldState, ECmState newState)
else if (m_lastDeregistrationRequest->deRegistrationType.switchOff ==
nas::ESwitchOff::NORMAL_DE_REGISTRATION)
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
switchRmState(ERmState::RM_DEREGISTERED);
}
}
}
......
......@@ -77,7 +77,6 @@ void NasMm::sendDeregistration(EDeregCause deregCause)
switchMmState(EMmState::MM_DEREGISTERED_INITIATED, EMmSubState::MM_DEREGISTERED_INITIATED_NA);
else
{
switchRmState(ERmState::RM_DEREGISTERED);
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
}
}
......@@ -100,8 +99,6 @@ void NasMm::receiveDeregistrationAccept(const nas::DeRegistrationAcceptUeOrigina
m_sm->localReleaseAllSessions();
switchRmState(ERmState::RM_DEREGISTERED);
if (m_lastDeregCause == EDeregCause::DISABLE_5G)
switchMmState(EMmState::MM_NULL, EMmSubState::MM_NULL_NA);
else
......@@ -181,7 +178,6 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
}
sendNasMessage(nas::DeRegistrationAcceptUeTerminated{});
switchRmState(ERmState::RM_DEREGISTERED);
// "Upon sending a DEREGISTRATION ACCEPT message, the UE shall delete the rejected NSSAI as specified in
// subclause 4.6.2.2."
......
......@@ -72,7 +72,6 @@ class NasMm
void triggerMmCycle();
void performMmCycle();
void switchMmState(EMmState state, EMmSubState subState);
void switchRmState(ERmState state);
void switchCmState(ECmState state);
void switchUState(E5UState state);
void onSwitchMmState(EMmState oldState, EMmState newState, EMmSubState oldSubState, EMmSubState newSubSate);
......
......@@ -245,7 +245,6 @@ void NasMm::receiveInitialRegistrationAccept(const nas::RegistrationAccept &msg)
// 5GMM-REGISTERED and set the 5GS update status to 5U1 UPDATED.
resetRegAttemptCounter();
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NORMAL_SERVICE);
switchRmState(ERmState::RM_REGISTERED);
switchUState(E5UState::U1_UPDATED);
// If the REGISTRATION ACCEPT message included a T3512 value IE, the UE shall use the value in the T3512 value IE as
......@@ -356,7 +355,6 @@ void NasMm::receiveMobilityRegistrationAccept(const nas::RegistrationAccept &msg
resetRegAttemptCounter();
m_serCounter = 0;
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NORMAL_SERVICE);
switchRmState(ERmState::RM_REGISTERED);
switchUState(E5UState::U1_UPDATED);
// "If the ACCEPT message included a T3512 value IE, the UE shall use the value in T3512 value IE as
......@@ -467,8 +465,6 @@ void NasMm::receiveInitialRegistrationReject(const nas::RegistrationReject &msg)
nas::utils::EnumToString(msg.eapMessage->eap->code));
}
switchRmState(ERmState::RM_DEREGISTERED);
auto handleAbnormalCase = [this, regType, cause]() {
m_logger->debug("Handling Registration Reject abnormal case");
......@@ -618,8 +614,6 @@ void NasMm::receiveMobilityRegistrationReject(const nas::RegistrationReject &msg
nas::utils::EnumToString(msg.eapMessage->eap->code));
}
switchRmState(ERmState::RM_DEREGISTERED);
auto handleAbnormalCase = [this, regType, cause]() {
m_logger->debug("Handling Registration Reject abnormal case");
......
......@@ -222,7 +222,6 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
m_logger->debug("Handling Service Reject abnormal case");
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NA);
switchRmState(ERmState::RM_REGISTERED);
m_timers->t3517.stop();
};
......@@ -307,43 +306,36 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
cause == nas::EMmCause::UE_IDENTITY_CANNOT_BE_DERIVED_FROM_NETWORK)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
switchRmState(ERmState::RM_DEREGISTERED);
}
if (cause == nas::EMmCause::IMPLICITY_DEREGISTERED)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NORMAL_SERVICE);
switchRmState(ERmState::RM_DEREGISTERED);
}
if (cause == nas::EMmCause::PLMN_NOT_ALLOWED || cause == nas::EMmCause::SERVING_NETWORK_NOT_AUTHORIZED)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_PLMN_SEARCH);
switchRmState(ERmState::RM_DEREGISTERED);
}
if (cause == nas::EMmCause::TA_NOT_ALLOWED)
{
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_LIMITED_SERVICE);
switchRmState(ERmState::RM_DEREGISTERED);
}
if (cause == nas::EMmCause::ROAMING_NOT_ALLOWED_IN_TA)
{
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_PLMN_SEARCH);
switchRmState(ERmState::RM_REGISTERED);
}
if (cause == nas::EMmCause::NO_SUITIBLE_CELLS_IN_TA)
{
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_LIMITED_SERVICE);
switchRmState(ERmState::RM_REGISTERED);
}
if (cause == nas::EMmCause::N1_MODE_NOT_ALLOWED)
{
switchMmState(EMmState::MM_NULL, EMmSubState::MM_NULL_NA);
switchRmState(ERmState::RM_DEREGISTERED);
setN1Capability(false);
}
......@@ -372,7 +364,6 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (!hasEmergency())
{
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NA);
switchRmState(ERmState::RM_REGISTERED);
m_timers->t3517.stop();
}
......@@ -393,7 +384,6 @@ void NasMm::receiveServiceReject(const nas::ServiceReject &msg)
if (cause == nas::EMmCause::RESTRICTED_SERVICE_AREA)
{
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NON_ALLOWED_SERVICE);
switchRmState(ERmState::RM_REGISTERED);
if (m_lastServiceRequest->serviceType.serviceType != nas::EServiceType::ELEVATED_SIGNALLING)
sendMobilityRegistration(ERegUpdateCause::RESTRICTED_SERVICE_AREA);
......
......@@ -54,7 +54,6 @@ void NasMm::onTimerExpire(nas::NasTimer &timer)
// The UE shall abort the registration procedure for initial registration and the NAS signalling
// connection, if any, shall be released locally if the initial registration request is not for
// emergency services..
switchRmState(ERmState::RM_DEREGISTERED);
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
switchUState(E5UState::U2_NOT_UPDATED);
......@@ -93,7 +92,6 @@ void NasMm::onTimerExpire(nas::NasTimer &timer)
logExpired();
switchMmState(EMmState::MM_REGISTERED, EMmSubState::MM_REGISTERED_NA);
switchRmState(ERmState::RM_REGISTERED);
if (m_cmState == ECmState::CM_IDLE && m_lastServiceReqCause != EServiceReqCause::EMERGENCY_FALLBACK)
{
......@@ -126,8 +124,6 @@ void NasMm::onTimerExpire(nas::NasTimer &timer)
else if (m_lastDeregistrationRequest->deRegistrationType.switchOff ==
nas::ESwitchOff::NORMAL_DE_REGISTRATION)
switchMmState(EMmState::MM_DEREGISTERED, EMmSubState::MM_DEREGISTERED_NA);
switchRmState(ERmState::RM_DEREGISTERED);
}
}
else
......
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