Commit b44eeafd authored by aligungr's avatar aligungr

UE SRA dev.

parent 505bc9cf
//
// 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"
#include <utils/common.hpp>
namespace nr::gnb
{
void GnbSraTask::updateUeInfo(const InetAddress &addr, uint64_t sti)
{
if (m_stiToUeId.count(sti))
{
int ueId = m_stiToUeId[sti];
auto &ctx = m_ueCtx[ueId];
ctx->addr = addr;
}
else
{
int ueId = utils::NextId();
m_stiToUeId[sti] = ueId;
auto ctx = std::make_unique<SraUeContext>(ueId);
ctx->sti = sti;
ctx->addr = addr;
m_ueCtx[ueId] = std::move(ctx);
m_logger->debug("New UE signal detected, UE[%d]", ueId);
}
}
} // namespace nr::gnb
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
namespace nr::gnb namespace nr::gnb
{ {
GnbSraTask::GnbSraTask(TaskBase *base) : m_base{base}, m_udpTask{} GnbSraTask::GnbSraTask(TaskBase *base) : m_base{base}, m_udpTask{}, m_ueCtx{}, m_stiToUeId{}
{ {
m_logger = m_base->logBase->makeUniqueLogger("sra"); m_logger = m_base->logBase->makeUniqueLogger("sra");
m_sti = utils::Random64(); m_sti = utils::Random64();
......
...@@ -31,6 +31,8 @@ class GnbSraTask : public NtsTask ...@@ -31,6 +31,8 @@ class GnbSraTask : public NtsTask
udp::UdpServerTask *m_udpTask; udp::UdpServerTask *m_udpTask;
uint64_t m_sti; uint64_t m_sti;
std::unordered_map<int, std::unique_ptr<SraUeContext>> m_ueCtx;
std::unordered_map<uint64_t, int> m_stiToUeId;
friend class GnbCmdHandler; friend class GnbCmdHandler;
...@@ -49,6 +51,9 @@ class GnbSraTask : public NtsTask ...@@ -49,6 +51,9 @@ class GnbSraTask : public NtsTask
private: /* Handler */ private: /* Handler */
void handleCellInfoRequest(const InetAddress &addr, const sra::SraCellInfoRequest &msg); void handleCellInfoRequest(const InetAddress &addr, const sra::SraCellInfoRequest &msg);
private: /* UE Management */
void updateUeInfo(const InetAddress &addr, uint64_t sti);
}; };
} // namespace nr::gnb } // namespace nr::gnb
\ No newline at end of file
...@@ -13,6 +13,8 @@ namespace nr::gnb ...@@ -13,6 +13,8 @@ namespace nr::gnb
void GnbSraTask::receiveSraMessage(const InetAddress &addr, const sra::SraMessage &msg) void GnbSraTask::receiveSraMessage(const InetAddress &addr, const sra::SraMessage &msg)
{ {
updateUeInfo(addr, msg.sti);
switch (msg.msgType) switch (msg.msgType)
{ {
case sra::EMessageType::CELL_INFO_REQUEST: case sra::EMessageType::CELL_INFO_REQUEST:
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include <string> #include <string>
#include <utils/common_types.hpp> #include <utils/common_types.hpp>
#include <utils/logger.hpp> #include <utils/logger.hpp>
#include <utils/network.hpp>
#include <utils/nts.hpp> #include <utils/nts.hpp>
#include <utils/octet_string.hpp> #include <utils/octet_string.hpp>
...@@ -104,6 +105,17 @@ struct NgapAmfContext ...@@ -104,6 +105,17 @@ struct NgapAmfContext
std::vector<PlmnSupport *> plmnSupportList{}; std::vector<PlmnSupport *> plmnSupportList{};
}; };
struct SraUeContext
{
const int ueId;
uint64_t sti{};
InetAddress addr{};
explicit SraUeContext(int ueId) : ueId(ueId)
{
}
};
struct AggregateMaximumBitRate struct AggregateMaximumBitRate
{ {
uint64_t dlAmbr{}; uint64_t dlAmbr{};
......
...@@ -26,7 +26,7 @@ static_assert(sizeof(float) == sizeof(uint32_t)); ...@@ -26,7 +26,7 @@ static_assert(sizeof(float) == sizeof(uint32_t));
static_assert(sizeof(double) == sizeof(uint64_t)); static_assert(sizeof(double) == sizeof(uint64_t));
static_assert(sizeof(long long) == sizeof(uint64_t)); static_assert(sizeof(long long) == sizeof(uint64_t));
static std::atomic<int> IdCounter = 1; static std::atomic<int> g_idCounter = 1;
static bool IPv6FromString(const char *szAddress, uint8_t *address) static bool IPv6FromString(const char *szAddress, uint8_t *address)
{ {
...@@ -135,7 +135,7 @@ std::vector<uint8_t> utils::HexStringToVector(const std::string &hex) ...@@ -135,7 +135,7 @@ std::vector<uint8_t> utils::HexStringToVector(const std::string &hex)
int utils::NextId() int utils::NextId()
{ {
int res = ++IdCounter; int res = ++g_idCounter;
if (res == 0) if (res == 0)
{ {
// ID counter overflows. // ID counter overflows.
......
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