Commit f6d45224 authored by aligungr's avatar aligungr

5G SM Status handling

parent 3a883188
......@@ -177,7 +177,7 @@ void NasSm::receiveEstablishmentRoutingFailure(const nas::PduSessionEstablishmen
if (!checkPtiAndPsi(msg))
return;
abortEstablishmentRequest(msg.pti);
abortProcedureByPti(msg.pti);
}
void NasSm::receiveEstablishmentReject(const nas::PduSessionEstablishmentReject &msg)
......@@ -205,14 +205,4 @@ void NasSm::receiveEstablishmentReject(const nas::PduSessionEstablishmentReject
}
}
void NasSm::abortEstablishmentRequest(int pti)
{
int psi = m_procedureTransactions[pti].psi;
m_logger->debug("PDU Session Establishment Procedure aborted for PTI[%d], PSI[%d]", pti, psi);
freeProcedureTransactionId(pti);
freePduSessionId(psi);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -8,6 +8,7 @@
#include "sm.hpp"
#include <nas/utils.hpp>
#include <set>
#include <ue/app/task.hpp>
#include <ue/mm/mm.hpp>
......@@ -34,4 +35,40 @@ bool NasSm::checkPtiAndPsi(const nas::SmMessage &msg)
return true;
}
void NasSm::abortProcedureByPti(int pti)
{
auto &pt = m_procedureTransactions[pti];
if (pt.state != EPtState::PENDING)
return;
int psi = m_procedureTransactions[pti].psi;
auto &ps = m_pduSessions[psi];
m_logger->debug("Aborting SM procedure for PTI[%d], PSI[%d]", pti, psi);
freeProcedureTransactionId(pti);
if (ps->psState == EPsState::ACTIVE_PENDING)
freePduSessionId(psi);
if (ps->psState == EPsState::INACTIVE_PENDING || ps->psState == EPsState::MODIFICATION_PENDING)
ps->psState = EPsState::ACTIVE;
}
void NasSm::abortProcedureByPtiOrPsi(int pti, int psi)
{
std::set<int> ptiToAbort{};
int i = 0;
for (auto &pt : m_procedureTransactions)
{
if (pt.state == EPtState::PENDING && pt.psi == psi)
ptiToAbort.insert(i);
i++;
}
ptiToAbort.insert(pti);
for (int id : ptiToAbort)
abortProcedureByPti(id);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -54,7 +54,6 @@ class NasSm
/* Transport */
void sendSmMessage(int psi, const nas::SmMessage &msg);
void receiveSmStatus(const nas::FiveGSmStatus &msg);
void receiveSmCause(const nas::IE5gSmCause &msg);
void sendSmCause(const nas::ESmCause &cause, int pti, int psi);
/* Allocation */
......@@ -68,15 +67,16 @@ class NasSm
void receiveEstablishmentAccept(const nas::PduSessionEstablishmentAccept &msg);
void receiveEstablishmentReject(const nas::PduSessionEstablishmentReject &msg);
void receiveEstablishmentRoutingFailure(const nas::PduSessionEstablishmentRequest &msg);
void abortEstablishmentRequest(int pti);
/* Timer */
std::unique_ptr<nas::NasTimer> newTransactionTimer(int code);
void onTimerExpire(nas::NasTimer &timer);
void onTransactionTimerExpire(int pti);
/* Utils */
/* Procedure */
bool checkPtiAndPsi(const nas::SmMessage &msg);
void abortProcedureByPti(int pti);
void abortProcedureByPtiOrPsi(int pti, int psi);
public:
/* Interface */
......
......@@ -63,7 +63,7 @@ void NasSm::onTransactionTimerExpire(int pti)
else
{
m_logger->err("PDU Session Establishment Procedure failure, no response from the network after 5 attempts");
abortEstablishmentRequest(pti);
abortProcedureByPti(pti);
}
break;
}
......
......@@ -64,12 +64,19 @@ void NasSm::receiveSmMessage(const nas::SmMessage &msg)
void NasSm::receiveSmStatus(const nas::FiveGSmStatus &msg)
{
receiveSmCause(msg.smCause);
}
m_logger->err("SM Status received: %s", nas::utils::EnumToString(msg.smCause.value));
void NasSm::receiveSmCause(const nas::IE5gSmCause &msg)
{
m_logger->err("SM cause received: %s", nas::utils::EnumToString(msg.value));
if (msg.smCause.value == nas::ESmCause::INVALID_PTI_VALUE)
{
// "The UE shall abort any ongoing 5GSM procedure related to the received PTI value and stop any related timer."
abortProcedureByPti(msg.pti);
}
else if (msg.smCause.value == nas::ESmCause::MESSAGE_TYPE_NON_EXISTENT_OR_NOT_IMPLEMENTED)
{
// "The UE shall abort any ongoing 5GSM procedure related to the PTI or PDU session Id and stop any related
// timer."
abortProcedureByPtiOrPsi(msg.pti, msg.pduSessionId);
}
}
void NasSm::sendSmCause(const nas::ESmCause &cause, int pti, int psi)
......
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