m_desc.add_options()
("help,h", "Display this help message")
("uuid,u", boost::program_options::value<std::string>(),
- "TA UUID to set port for")
+ "TA UUID to set / clear port for")
("port,p", boost::program_options::value<int32_t>(),
- "Port number");
+ "Set debug port number")
+ ("clear,c", "Clear debug port number");
}
void DebugPortHandler::readOptions(int argc, char *argv[]) {
void DebugPortHandler::checkExactlyOneMainFlag()
{
- std::vector<std::string> mainOptions = { "port" };
+ std::vector<std::string> mainOptions = { "port", "clear" };
auto optionCount = [this](std::string &s) { return m_opts.count(s) > 0; };
bool mainOptionCount = std::count_if(mainOptions.begin(),
mainOptions.end(),
return false;
}
- if (m_opts.count("port")) {
+ if (m_opts.count("clear")) {
+ cmd.clear = true;
+ cmd.port = 0;
+ } else if (m_opts.count("port")) {
+ cmd.clear = false;
cmd.port = m_opts["port"].as<int32_t>();
if (cmd.port < 0)
throw boost::program_options::error(
}
std::memcpy(&cmd, data.data(), sizeof(cmd));
- (*UUIDConfig)[cmd.uuid]->setDebugPort(cmd.port);
-
+ if (cmd.clear)
+ (*UUIDConfig)[cmd.uuid]->clearDebugPort();
+ else
+ (*UUIDConfig)[cmd.uuid]->setDebugPort(cmd.port);
+ LOGI(SIM_DAEMON, "%s debug port of UUID %s",
+ cmd.clear ? "Cleared" : "Set",
+ UUIDToString(cmd.uuid).c_str());
reply.status = CTL_REPLY_SUCCESS;
m_writer->write(CTL_SET_PORT_REPLY, (char *) &reply, sizeof(reply));
}