Commit 0cf24f02 authored by aligungr's avatar aligungr

PDU session establishment reject improvements

parent 8cceeae6
...@@ -129,38 +129,25 @@ void NasSm::receivePduSessionEstablishmentAccept(const nas::PduSessionEstablishm ...@@ -129,38 +129,25 @@ void NasSm::receivePduSessionEstablishmentAccept(const nas::PduSessionEstablishm
{ {
m_logger->debug("PDU Session Establishment Accept received"); m_logger->debug("PDU Session Establishment Accept received");
if (msg.smCause.has_value()) if (!checkPtiAndPsi(msg))
{
m_logger->warn("SM cause received in PduSessionEstablishmentAccept [%s]",
nas::utils::EnumToString(msg.smCause->value));
}
if (msg.pti < ProcedureTransaction::MIN_ID || msg.pti > ProcedureTransaction::MAX_ID)
{
// PTI is required for PDU session establishment request
m_logger->err("Received PTI [%d] value is invalid", msg.pti);
sendSmCause(nas::ESmCause::INVALID_PTI_VALUE, msg.pduSessionId);
return; return;
}
if (m_procedureTransactions[msg.pti].psi != msg.pduSessionId)
{
m_logger->err("Received PSI value [%d] is invalid, expected was [%d]", msg.pduSessionId,
m_procedureTransactions[msg.pti].psi);
sendSmCause(nas::ESmCause::INVALID_PTI_VALUE, msg.pduSessionId);
return;
}
freeProcedureTransactionId(msg.pti); freeProcedureTransactionId(msg.pti);
auto& pduSession = m_pduSessions[msg.pduSessionId]; auto &pduSession = m_pduSessions[msg.pduSessionId];
if (pduSession->psState != EPsState::ACTIVE_PENDING) if (pduSession->psState != EPsState::ACTIVE_PENDING)
{ {
m_logger->err("PS establishment accept received without requested"); m_logger->err("PS establishment accept received without being requested");
sendSmCause(nas::ESmCause::MESSAGE_TYPE_NOT_COMPATIBLE_WITH_THE_PROTOCOL_STATE, pduSession->psi); sendSmCause(nas::ESmCause::MESSAGE_TYPE_NOT_COMPATIBLE_WITH_THE_PROTOCOL_STATE, pduSession->psi);
return; return;
} }
if (msg.smCause.has_value())
{
m_logger->warn("SM cause received in PduSessionEstablishmentAccept [%s]",
nas::utils::EnumToString(msg.smCause->value));
}
pduSession->psState = EPsState::ACTIVE; pduSession->psState = EPsState::ACTIVE;
pduSession->authorizedQoSRules = nas::utils::DeepCopyIe(msg.authorizedQoSRules); pduSession->authorizedQoSRules = nas::utils::DeepCopyIe(msg.authorizedQoSRules);
pduSession->sessionAmbr = nas::utils::DeepCopyIe(msg.sessionAmbr); pduSession->sessionAmbr = nas::utils::DeepCopyIe(msg.sessionAmbr);
...@@ -183,12 +170,6 @@ void NasSm::receivePduSessionEstablishmentAccept(const nas::PduSessionEstablishm ...@@ -183,12 +170,6 @@ void NasSm::receivePduSessionEstablishmentAccept(const nas::PduSessionEstablishm
m_logger->info("PDU Session establishment is successful PSI[%d]", pduSession->psi); m_logger->info("PDU Session establishment is successful PSI[%d]", pduSession->psi);
} }
void NasSm::receivePduSessionEstablishmentReject(const nas::PduSessionEstablishmentReject &msg)
{
m_logger->err("PDU Session Establishment Reject received [%s]", nas::utils::EnumToString(msg.smCause.value));
// TODO
}
void NasSm::abortEstablishmentRequest(int pti) void NasSm::abortEstablishmentRequest(int pti)
{ {
int psi = m_procedureTransactions[pti].psi; int psi = m_procedureTransactions[pti].psi;
...@@ -199,4 +180,29 @@ void NasSm::abortEstablishmentRequest(int pti) ...@@ -199,4 +180,29 @@ void NasSm::abortEstablishmentRequest(int pti)
freePduSessionId(psi); freePduSessionId(psi);
} }
void NasSm::receivePduSessionEstablishmentReject(const nas::PduSessionEstablishmentReject &msg)
{
m_logger->err("PDU Session Establishment Reject received [%s]", nas::utils::EnumToString(msg.smCause.value));
if (!checkPtiAndPsi(msg))
return;
freeProcedureTransactionId(msg.pti);
auto &pduSession = m_pduSessions[msg.pduSessionId];
if (pduSession->psState != EPsState::ACTIVE_PENDING)
{
m_logger->err("PS establishment reject received without being requested");
sendSmCause(nas::ESmCause::MESSAGE_TYPE_NOT_COMPATIBLE_WITH_THE_PROTOCOL_STATE, pduSession->psi);
return;
}
pduSession->psState = EPsState::INACTIVE;
if (pduSession->isEmergency)
{
// This not much important and no need for now
// TODO: inform the upper layers of the failure of the procedure
}
}
} // namespace nr::ue } // namespace nr::ue
\ No newline at end of file
...@@ -74,6 +74,9 @@ class NasSm ...@@ -74,6 +74,9 @@ class NasSm
void onTimerExpire(nas::NasTimer &timer); void onTimerExpire(nas::NasTimer &timer);
void onTransactionTimerExpire(int pti); void onTransactionTimerExpire(int pti);
/* Utils */
bool checkPtiAndPsi(const nas::SmMessage& msg);
public: public:
/* Interface */ /* Interface */
void handleNasEvent(const NwUeNasToNas &msg); // used by NAS void handleNasEvent(const NwUeNasToNas &msg); // used by NAS
......
//
// This file is a part of UERANSIM open source project.
// Copyright (c) 2021 ALİ GÜNGÖR.
//
// The software and all associated files are licensed under GPL-3.0
// and subject to the terms and conditions defined in LICENSE file.
//
#include "sm.hpp"
#include <nas/utils.hpp>
#include <ue/app/task.hpp>
#include <ue/mm/mm.hpp>
namespace nr::ue
{
bool NasSm::checkPtiAndPsi(const nas::SmMessage &msg)
{
if (msg.pti < ProcedureTransaction::MIN_ID || msg.pti > ProcedureTransaction::MAX_ID)
{
m_logger->err("Received PTI [%d] value is invalid", msg.pti);
sendSmCause(nas::ESmCause::INVALID_PTI_VALUE, msg.pduSessionId);
return false;
}
if (m_procedureTransactions[msg.pti].psi != msg.pduSessionId)
{
m_logger->err("Received PSI value [%d] is invalid, expected was [%d]", msg.pduSessionId,
m_procedureTransactions[msg.pti].psi);
sendSmCause(nas::ESmCause::INVALID_PTI_VALUE, msg.pduSessionId);
return false;
}
return true;
}
} // namespace nr::ue
\ No newline at end of file
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