31 const std::string& module)
32 : m_dispatcher(dispatcher)
40 return ndn::PartialName(m_module).append(verb);
46 const std::string& module)
48 , m_namePrefixList(namePrefixList)
55 const ndn::Interest& interest,
56 const ndn::mgmt::ControlParameters& parameters,
57 const ndn::mgmt::CommandContinuation& done)
59 const ndn::nfd::ControlParameters& castParams =
60 static_cast<const ndn::nfd::ControlParameters&
>(parameters);
64 NLSR_LOG_INFO(
"Advertising name: " << castParams.getName() <<
"\n");
66 if (castParams.hasFlags() && castParams.getFlags() ==
PREFIX_FLAG) {
69 return done(ndn::nfd::ControlResponse(205,
"OK").setBody(parameters.wireEncode()));
72 return done(ndn::nfd::ControlResponse(406,
"Failed to open configuration file.")
73 .setBody(parameters.wireEncode()));
76 return done(ndn::nfd::ControlResponse(200,
"OK").setBody(parameters.wireEncode()));
79 if (castParams.hasFlags() && castParams.getFlags() ==
PREFIX_FLAG) {
81 NLSR_LOG_INFO(
"Saving an already advertised name: " << castParams.getName() <<
"\n");
83 return done(ndn::nfd::ControlResponse(205,
"OK").setBody(parameters.wireEncode()));
86 return done(ndn::nfd::ControlResponse(406,
"Prefix is already Saved/Failed to open configuration file.")
87 .setBody(parameters.wireEncode()));
90 return done(ndn::nfd::ControlResponse(204,
"Prefix is already advertised/inserted.")
91 .setBody(parameters.wireEncode()));
97 const ndn::Interest& interest,
98 const ndn::mgmt::ControlParameters& parameters,
99 const ndn::mgmt::CommandContinuation& done)
101 const ndn::nfd::ControlParameters& castParams =
102 static_cast<const ndn::nfd::ControlParameters&
>(parameters);
106 NLSR_LOG_INFO(
"Withdrawing/Removing name: " << castParams.getName() <<
"\n");
108 if (castParams.hasFlags() && castParams.getFlags() ==
PREFIX_FLAG) {
110 return done(ndn::nfd::ControlResponse(205,
"OK").setBody(parameters.wireEncode()));
113 return done(ndn::nfd::ControlResponse(406,
"Failed to open configuration file.")
114 .setBody(parameters.wireEncode()));
117 return done(ndn::nfd::ControlResponse(200,
"OK").setBody(parameters.wireEncode()));
120 if (castParams.hasFlags() && castParams.getFlags() ==
PREFIX_FLAG) {
122 NLSR_LOG_INFO(
"Deleting an already withdrawn name: " << castParams.getName() <<
"\n");
124 return done(ndn::nfd::ControlResponse(205,
"OK").setBody(parameters.wireEncode()));
127 return done(ndn::nfd::ControlResponse(406,
"Prefix is already deleted/Failed to open configuration file.")
128 .setBody(parameters.wireEncode()));
131 return done(ndn::nfd::ControlResponse(204,
"Prefix is already withdrawn/removed.")
132 .setBody(parameters.wireEncode()));
void buildAndInstallOwnNameLsa()
Builds a name LSA for this router and then installs it into the LSDB.
bool erase(const ndn::Name &name, const std::string &source="")
Deletes name and source combination.
bool insert(const ndn::Name &name, const std::string &source="")
Inserts name and source combination.
virtual std::optional< bool > afterWithdraw(const ndn::Name &prefix)
save an advertised prefix to the nlsr configuration file returns bool from the overridden function wh...
NamePrefixList & m_namePrefixList
void withdrawAndRemovePrefix(const ndn::Name &prefix, const ndn::Interest &interest, const ndn::mgmt::ControlParameters ¶meters, const ndn::mgmt::CommandContinuation &done)
remove desired name prefix from the advertised name prefix list or remove a prefix from the FIB if pa...
virtual std::optional< bool > afterAdvertise(const ndn::Name &prefix)
save an advertised prefix to the nlsr configuration file returns bool from the overridden function wh...
CommandManagerBase(ndn::mgmt::Dispatcher &m_dispatcher, NamePrefixList &m_namePrefixList, Lsdb &lsdb, const std::string &module)
void advertiseAndInsertPrefix(const ndn::Name &prefix, const ndn::Interest &interest, const ndn::mgmt::ControlParameters ¶meters, const ndn::mgmt::CommandContinuation &done)
add desired name prefix to the advertised name prefix list or insert a prefix into the FIB if paramet...
ManagerBase(ndn::mgmt::Dispatcher &m_dispatcher, const std::string &module)
ndn::PartialName makeRelPrefix(const std::string &verb) const
generate the relative prefix for a handler by appending the verb name to the module name
Copyright (c) 2014-2018, The University of Memphis, Regents of the University of California.
#define INIT_LOGGER(name)
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.