Commit b9c4b40e authored by aligungr's avatar aligungr

gNB CLI improvements

parent ad4bbf64
......@@ -37,28 +37,30 @@ void GnbAppTask::onLoop()
m_statusInfo.isNgapUp = w->isNgapUp;
break;
}
delete w;
break;
}
case NtsMessageType::GNB_CLI_COMMAND: {
auto *w = dynamic_cast<NwGnbCliCommand *>(msg);
if (w->cmd == nullptr)
break;
switch (w->cmd->present)
{
case app::GnbCliCommand::STATUS: {
w->sendResult(m_statusInfo.toString());
delete w;
break;
}
case app::GnbCliCommand::INFO: {
w->sendResult(m_base->config->toString());
delete w;
break;
}
case app::GnbCliCommand::AMF_LIST: {
w->sendError("amf-list command not implemented yet");
case app::GnbCliCommand::AMF_LIST:
case app::GnbCliCommand::AMF_STATUS: {
m_base->ngapTask->push(w);
break;
}
case app::GnbCliCommand::AMF_STATUS: {
w->sendError("amf-status command not implemented yet");
default: {
delete w;
break;
}
}
......
......@@ -8,7 +8,7 @@
#include "task.hpp"
#include <gnb/app/task.hpp>
#include <sstream>
#include <utils/common.hpp>
namespace nr::gnb
......@@ -82,6 +82,34 @@ void NgapTask::onLoop()
}
break;
}
case NtsMessageType::GNB_CLI_COMMAND: {
auto *w = dynamic_cast<NwGnbCliCommand *>(msg);
switch (w->cmd->present)
{
case app::GnbCliCommand::AMF_LIST: {
std::stringstream ss{};
for (auto &amf : m_amfCtx)
ss << "* amf-id: " << amf.first << "\n";
utils::Trim(ss);
w->sendResult(ss.str());
break;
}
case app::GnbCliCommand::AMF_STATUS: {
if (m_amfCtx.count(w->cmd->amfId) == 0)
w->sendError("AMF not found with given ID");
else
{
auto amf = m_amfCtx[w->cmd->amfId];
w->sendResult("state: " + std::to_string((int)amf->state));
}
break;
}
default: {
break;
}
}
break;
}
default: {
m_logger->unhandledNts(msg);
break;
......
......@@ -309,3 +309,11 @@ void utils::Trim(std::string &s)
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) { return !std::isspace(ch); }));
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) { return !std::isspace(ch); }).base(), s.end());
}
void utils::Trim(std::stringstream &s)
{
std::string str{};
str = s.str();
Trim(str);
s.str(str);
}
......@@ -13,6 +13,7 @@
#include "octet_string.hpp"
#include "time_stamp.hpp"
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
......@@ -32,9 +33,10 @@ int ParseInt(const char *str);
uint64_t Random64();
void Sleep(int ms);
bool IsRoot();
bool IsNumeric(const std::string& str);
bool IsNumeric(const std::string &str);
void AssertNodeName(const std::string &str);
void Trim(std::string& str);
void Trim(std::string &str);
void Trim(std::stringstream &str);
template <typename T>
inline void ClearAndDelete(std::vector<T *> &vector)
......
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