Commit 267c5c46 authored by aligungr's avatar aligungr

UE CLI improvements

parent 8ad0767a
......@@ -82,6 +82,18 @@ static std::map<std::string, bool> g_gnbCmdToHelpIfEmpty = {
{"info", false},
};
static std::map<std::string, std::string> g_ueCmdToDescription = {
{"info", "Show some information about the UE"},
};
static std::map<std::string, std::string> g_ueCmdToUsage = {
{"info", "[option...]"},
};
static std::map<std::string, bool> g_ueCmdToHelpIfEmpty = {
{"info", false},
};
std::unique_ptr<GnbCliCommand> ParseGnbCliCommand(std::vector<std::string> &&tokens, std::string &error,
std::string &output)
{
......@@ -149,4 +161,46 @@ std::unique_ptr<GnbCliCommand> ParseGnbCliCommand(std::vector<std::string> &&tok
return nullptr;
}
std::unique_ptr<UeCliCommand> ParseUeCliCommand(std::vector<std::string> &&tokens, std::string &error,
std::string &output)
{
if (tokens.empty())
{
error = "Empty command";
return nullptr;
}
std::string &subCmd = tokens[0];
if (subCmd == "commands")
{
output = DumpCommands(g_ueCmdToDescription);
return nullptr;
}
if (g_ueCmdToDescription.count(subCmd) == 0 || g_ueCmdToUsage.count(subCmd) == 0 ||
g_ueCmdToHelpIfEmpty.count(subCmd) == 0)
{
error = "Command not recognized: " + subCmd;
return nullptr;
}
opt::OptionsDescription desc =
Desc(subCmd, g_ueCmdToDescription[subCmd], g_ueCmdToUsage[subCmd], g_ueCmdToHelpIfEmpty[subCmd]);
OptionsHandler handler{};
opt::OptionsResult options{tokens, desc, &handler};
error = handler.m_err.str();
output = handler.m_output.str();
utils::Trim(error);
utils::Trim(output);
if (!error.empty() || !output.empty())
return nullptr;
return nullptr;
}
} // namespace app
......@@ -33,7 +33,21 @@ struct GnbCliCommand
}
};
struct UeCliCommand
{
enum PR
{
} present;
explicit UeCliCommand(PR present) : present(present)
{
}
};
std::unique_ptr<GnbCliCommand> ParseGnbCliCommand(std::vector<std::string> &&tokens, std::string &error,
std::string &output);
std::unique_ptr<UeCliCommand> ParseUeCliCommand(std::vector<std::string> &&tokens, std::string &error,
std::string &output);
} // namespace app
\ No newline at end of file
......@@ -24,7 +24,7 @@
static app::CliServer *g_cliServer = nullptr;
static nr::gnb::GnbConfig *g_refConfig = nullptr;
static std::unordered_map<std::string, nr::gnb::GNodeB *> g_gnbMap{};
static app::CliResponseTask *g_cliRespTask;
static app::CliResponseTask *g_cliRespTask = nullptr;
static struct Options
{
......@@ -78,7 +78,7 @@ static nr::gnb::GnbConfig *ReadConfigYaml()
static void ReadOptions(int argc, char **argv)
{
opt::OptionsDescription desc{cons::Project, cons::Tag, "5G-SA gNB implementation",
cons::Owner, "nr-cli", {"-c <config-file> [option...]"},
cons::Owner, "nr-gnb", {"-c <config-file> [option...]"},
true};
opt::OptionItem itemConfigFile = {'c', "config", "Use specified configuration file for gNB", "config-file"};
......
This diff is collapsed.
......@@ -9,6 +9,8 @@
#pragma once
#include "types.hpp"
#include "ue.hpp"
#include <app/cli_base.hpp>
#include <nas/timer.hpp>
#include <rrc/rrc.hpp>
#include <urs/rls/rls.hpp>
......@@ -253,4 +255,26 @@ struct NwUeStatusUpdate : NtsMessage
}
};
struct NwUeCliCommand : NtsMessage
{
std::unique_ptr<app::UeCliCommand> cmd;
InetAddress address;
NtsTask *callbackTask;
NwUeCliCommand(std::unique_ptr<app::UeCliCommand> cmd, InetAddress address, NtsTask *callbackTask)
: NtsMessage(NtsMessageType::UE_CLI_COMMAND), cmd(std::move(cmd)), address(address), callbackTask(callbackTask)
{
}
void sendResult(const std::string &output) const
{
callbackTask->push(new app::NwCliSendResponse(address, output, false));
}
void sendError(const std::string &output) const
{
callbackTask->push(new app::NwCliSendResponse(address, output, true));
}
};
} // namespace nr::ue
\ No newline at end of file
......@@ -56,4 +56,10 @@ void UserEquipment::start()
taskBase->appTask->start();
}
void UserEquipment::pushCommand(std::unique_ptr<app::UeCliCommand> cmd, const InetAddress &address,
NtsTask *callbackTask)
{
taskBase->appTask->push(new NwUeCliCommand(std::move(cmd), address, callbackTask));
}
} // namespace nr::ue
......@@ -9,6 +9,10 @@
#pragma once
#include "types.hpp"
#include <app/cli_cmd.hpp>
#include <memory>
#include <utils/network.hpp>
#include <utils/nts.hpp>
namespace nr::ue
{
......@@ -24,6 +28,7 @@ class UserEquipment
public:
void start();
void pushCommand(std::unique_ptr<app::UeCliCommand> cmd, const InetAddress &address, NtsTask *callbackTask);
};
} // namespace nr::ue
\ 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