Commit ed946b11 authored by aligungr's avatar aligungr

NNSF refactor

parent b797eb78
......@@ -40,13 +40,12 @@ void NgapTask::createUeContext(int ueId)
m_ueCtx[ctx->ctxId] = ctx;
// Select an AMF for the UE (if any)
for (auto &amf : m_amfCtx)
{
// todo: an arbitrary AMF is selected for now
ctx->associatedAmfId = amf.second->ctxId;
break;
}
// Perform AMF selection
auto *amf = selectAmf(ueId);
if (amf == nullptr)
m_logger->err("AMF selection for UE[%d] failed. Could not find a suitable AMF.", ueId);
else
ctx->associatedAmfId = amf->ctxId;
}
NgapUeContext *NgapTask::findUeContext(int ctxId)
......@@ -134,12 +133,6 @@ NgapUeContext *NgapTask::findUeByNgapIdPair(int amfCtxId, const NgapIdPair &idPa
return ue;
}
NgapAmfContext *NgapTask::selectNewAmfForReAllocation(int initiatedAmfId, int amfSetId)
{
// TODO an arbitrary AMF is selected for now
return findAmfContext(initiatedAmfId);
}
void NgapTask::deleteUeContext(int ueId)
{
auto *ue = m_ueCtx[ueId];
......
......@@ -174,7 +174,7 @@ void NgapTask::receiveRerouteNasRequest(int amfId, ASN_NGAP_RerouteNASRequest *m
}
}
auto *newAmf = selectNewAmfForReAllocation(amfId, asn::GetBitStringInt<10>(ieAmfSetId->AMFSetID));
auto *newAmf = selectNewAmfForReAllocation(ue->ctxId, amfId, asn::GetBitStringInt<10>(ieAmfSetId->AMFSetID));
if (newAmf == nullptr)
{
m_logger->err("AMF selection for re-allocation failed. Could not find a suitable AMF.");
......
//
// 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 "task.hpp"
namespace nr::gnb
{
NgapAmfContext *NgapTask::selectAmf(int ueId)
{
// todo:
for (auto &amf : m_amfCtx)
return amf.second; // return the first one
return nullptr;
}
NgapAmfContext *NgapTask::selectNewAmfForReAllocation(int ueId, int initiatedAmfId, int amfSetId)
{
// TODO an arbitrary AMF is selected for now
return findAmfContext(initiatedAmfId);
}
} // namespace nr::gnb
......@@ -69,7 +69,6 @@ class NgapTask : public NtsTask
NgapUeContext *findUeByRanId(long ranUeNgapId);
NgapUeContext *findUeByAmfId(long amfUeNgapId);
NgapUeContext *findUeByNgapIdPair(int amfCtxId, const NgapIdPair &idPair);
NgapAmfContext *selectNewAmfForReAllocation(int initiatedAmfId, int amfSetId);
void deleteUeContext(int ueId);
void deleteAmfContext(int amfId);
......@@ -105,6 +104,10 @@ class NgapTask : public NtsTask
void receiveInitialContextSetup(int amfId, ASN_NGAP_InitialContextSetupRequest *msg);
void receiveContextRelease(int amfId, ASN_NGAP_UEContextReleaseCommand *msg);
void receiveContextModification(int amfId, ASN_NGAP_UEContextModificationRequest *msg);
/* NAS Node Selection */
NgapAmfContext *selectAmf(int ueId);
NgapAmfContext *selectNewAmfForReAllocation(int ueId, int initiatedAmfId, int amfSetId);
};
} // namespace nr::gnb
\ 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