Commit 97f76db4 authored by aligungr's avatar aligungr

PS local release implementation

parent e121c5c7
......@@ -95,7 +95,7 @@ void UeCmdHandler::handleCmdImpl(NwUeCliCommand &msg)
case app::UeCliCommand::STATUS: {
std::vector<Json> pduSessions{};
int index = 0;
for (auto &pduSession : m_base->appTask->m_statusInfo.pduSessions)
for (auto &pduSession : m_base->appTask->m_pduSessions)
{
if (pduSession.has_value())
{
......
......@@ -20,7 +20,7 @@ static constexpr const int SWITCH_OFF_DELAY = 500;
namespace nr::ue
{
UeAppTask::UeAppTask(TaskBase *base) : m_base{base}, m_statusInfo{}, m_tunTasks{}
UeAppTask::UeAppTask(TaskBase *base) : m_base{base}
{
m_logger = m_base->logBase->makeUniqueLogger(m_base->config->getLoggerPrefix() + "app");
}
......@@ -129,12 +129,12 @@ void UeAppTask::receiveStatusUpdate(NwUeStatusUpdate &msg)
{
auto *session = msg.pduSession;
UeStatusInfo::UePduSessionInfo sessionInfo{};
UePduSessionInfo sessionInfo{};
sessionInfo.type = nas::utils::EnumToString(session->sessionType);
if (session->pduAddress.has_value())
sessionInfo.address = utils::OctetStringToIp(session->pduAddress->pduAddressInformation);
m_statusInfo.pduSessions[session->id] = std::move(sessionInfo);
m_pduSessions[session->id] = std::move(sessionInfo);
setupTunInterface(session);
return;
......@@ -142,8 +142,18 @@ void UeAppTask::receiveStatusUpdate(NwUeStatusUpdate &msg)
if (msg.what == NwUeStatusUpdate::SESSION_RELEASE)
{
// TODO
m_logger->err("todo: release");
if (m_tunTasks[msg.psi] != nullptr)
{
m_tunTasks[msg.psi]->quit();
delete m_tunTasks[msg.psi];
m_tunTasks[msg.psi] = nullptr;
}
if (m_pduSessions[msg.psi].has_value())
{
m_logger->info("PDU session[%d] released", msg.psi);
m_pduSessions[msg.psi] = {};
}
}
}
......
......@@ -27,8 +27,8 @@ class UeAppTask : public NtsTask
TaskBase *m_base;
std::unique_ptr<Logger> m_logger;
UeStatusInfo m_statusInfo;
TunTask *m_tunTasks[16];
std::array<std::optional<UePduSessionInfo>, 16> m_pduSessions{};
std::array<TunTask *, 16> m_tunTasks{};
friend class UeCmdHandler;
......
......@@ -56,8 +56,7 @@ void NasMm::sendDeregistration(nas::ESwitchOff switchOff, bool dueToDisable5g)
switchMmState(EMmState::MM_DEREGISTERED_INITIATED, EMmSubState::MM_DEREGISTERED_INITIATED_NA);
// Release all PDU sessions
m_sm->localReleaseSession(0);
m_sm->localReleaseAllSessions();
if (switchOff == nas::ESwitchOff::SWITCH_OFF)
m_base->appTask->push(new NwUeNasToApp(NwUeNasToApp::PERFORM_SWITCH_OFF));
......@@ -138,8 +137,7 @@ void NasMm::receiveDeregistrationRequest(const nas::DeRegistrationRequestUeTermi
msg.deRegistrationType.reRegistrationRequired == nas::EReRegistrationRequired::REQUIRED &&
!forceIgnoreReregistration;
// Release all PDU sessions
m_sm->localReleaseSession(0);
m_sm->localReleaseAllSessions();
if (reRegistrationRequired)
{
......
......@@ -247,7 +247,7 @@ struct NwUeStatusUpdate : NtsMessage
PduSession *pduSession{};
// SESSION_RELEASE
int psi{}; // psi=0 means release all of the sessions
int psi{};
explicit NwUeStatusUpdate(const int what) : NtsMessage(NtsMessageType::UE_STATUS_UPDATE), what(what)
{
......
......@@ -76,28 +76,12 @@ int NasSm::allocateProcedureTransactionId()
void NasSm::freeProcedureTransactionId(int pti)
{
if (pti == 0)
{
for (auto &transaction : m_procedureTransactions)
transaction = {};
}
else
{
m_procedureTransactions[pti].id = 0;
}
m_procedureTransactions[pti] = {};
}
void NasSm::freePduSessionId(int psi)
{
if (psi == 0)
{
for (auto &session : m_pduSessions)
session = {};
}
else
{
m_pduSessions[psi] = {};
}
m_pduSessions[psi] = {};
}
} // namespace nr::ue
\ No newline at end of file
......@@ -18,11 +18,23 @@ void NasSm::localReleaseSession(int psi)
{
m_logger->debug("Performing local release of PDU session[%d]", psi);
bool isEstablished = m_pduSessions[psi].isEstablished;
freePduSessionId(psi);
auto *statusUpdate = new NwUeStatusUpdate(NwUeStatusUpdate::SESSION_RELEASE);
statusUpdate->psi = psi;
m_base->appTask->push(statusUpdate);
if (isEstablished)
{
auto *statusUpdate = new NwUeStatusUpdate(NwUeStatusUpdate::SESSION_RELEASE);
statusUpdate->psi = psi;
m_base->appTask->push(statusUpdate);
}
}
void NasSm::localReleaseAllSessions()
{
for (auto &session : m_pduSessions)
if (session.id != 0)
localReleaseSession(session.id);
}
} // namespace nr::ue
\ No newline at end of file
......@@ -47,6 +47,7 @@ class NasSm
/* Resource */
void localReleaseSession(int psi);
void localReleaseAllSessions();
private:
/* Transport */
......
......@@ -10,6 +10,7 @@
#include <app/monitor.hpp>
#include <app/ue_ctl.hpp>
#include <array>
#include <nas/nas.hpp>
#include <nas/timer.hpp>
#include <utils/common_types.hpp>
......@@ -353,15 +354,10 @@ enum class EAutnValidationRes
SYNCHRONISATION_FAILURE,
};
struct UeStatusInfo
struct UePduSessionInfo
{
struct UePduSessionInfo
{
std::string type{};
std::string address{};
};
std::optional<UePduSessionInfo> pduSessions[16]{};
std::string type{};
std::string address{};
};
Json ToJson(const ECmState &state);
......
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