Commit f7279026 authored by aligungr's avatar aligungr

gNB CLI improvements

parent 8e2eae84
......@@ -15,6 +15,7 @@
#include <gnb/rrc/task.hpp>
#include <gnb/sctp/task.hpp>
#include <utils/common.hpp>
#include <utils/printer.hpp>
#define PAUSE_CONFIRM_TIMEOUT 3000
#define PAUSE_POLLING 10
......@@ -101,7 +102,7 @@ void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg)
case app::GnbCliCommand::AMF_LIST: {
std::stringstream ss{};
for (auto &amf : base.ngapTask->m_amfCtx)
ss << "* amf-id: " << amf.first << "\n";
ss << "- ID[" << amf.first << "] Address[" << amf.second->address << ":" << amf.second->port << "]\n";
utils::Trim(ss);
msg.sendResult(ss.str());
break;
......@@ -112,7 +113,15 @@ void GnbCmdHandler::HandleCmdImpl(TaskBase &base, NwGnbCliCommand &msg)
else
{
auto amf = base.ngapTask->m_amfCtx[msg.cmd->amfId];
msg.sendResult("state: " + std::to_string((int)amf->state));
Printer printer{};
printer.appendKeyValue("address", amf->address);
printer.appendKeyValue("port", amf->port);
printer.appendKeyValue("name", amf->amfName);
printer.appendKeyValue("relative-capacity", amf->relativeCapacity);
printer.appendKeyValue("state", EnumToString(amf->state));
printer.trim();
msg.sendResult(printer.makeString());
}
break;
}
......
//
// 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 "printer.hpp"
#include <utils/common.hpp>
void Printer::appendKeyValue(const std::string &key, const std::string &value)
{
appendIndentation();
m_ss << key << ": " << value << "\n";
}
std::string Printer::makeString() const
{
return m_ss.str();
}
void Printer::appendIndentation()
{
m_ss << std::string(m_indent, ' ');
}
void Printer::trim()
{
utils::Trim(m_ss);
}
void Printer::appendKeyValue(const std::string &key, int16_t value)
{
appendKeyValue(key, std::to_string(value));
}
void Printer::appendKeyValue(const std::string &key, uint16_t value)
{
appendKeyValue(key, std::to_string(value));
}
void Printer::appendKeyValue(const std::string &key, int32_t value)
{
appendKeyValue(key, std::to_string(value));
}
void Printer::appendKeyValue(const std::string &key, uint32_t value)
{
appendKeyValue(key, std::to_string(value));
}
void Printer::appendKeyValue(const std::string &key, int64_t value)
{
appendKeyValue(key, std::to_string(value));
}
void Printer::appendKeyValue(const std::string &key, uint64_t value)
{
appendKeyValue(key, std::to_string(value));
}
//
// 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.
//
#pragma once
#include <sstream>
#include <string>
class Printer
{
std::stringstream m_ss{};
int m_indent{};
private:
void appendIndentation();
public:
void appendKeyValue(const std::string &key, const std::string &value);
void appendKeyValue(const std::string &key, int16_t value);
void appendKeyValue(const std::string &key, uint16_t value);
void appendKeyValue(const std::string &key, int32_t value);
void appendKeyValue(const std::string &key, uint32_t value);
void appendKeyValue(const std::string &key, int64_t value);
void appendKeyValue(const std::string &key, uint64_t value);
std::string makeString() const;
void trim();
};
\ 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