22#ifndef NDN_CXX_MGMT_NFD_CONTROL_COMMAND_HPP
23#define NDN_CXX_MGMT_NFD_CONTROL_COMMAND_HPP
40 using std::invalid_argument::invalid_argument;
64 m_required.set(field);
74 m_optional.set(field);
89 static shared_ptr<ControlParameters>
100 std::bitset<CONTROL_PARAMETER_UBOUND> m_required;
101 std::bitset<CONTROL_PARAMETER_UBOUND> m_optional;
128 static shared_ptr<ParametersType>
131 auto params = make_shared<ParametersType>();
157template<
typename Derived,
158 typename RequestFormatType = ControlParametersCommandFormat,
159 typename ResponseFormatType = ControlParametersCommandFormat>
192 Derived::s_requestFormat.encode(request, params);
199 static shared_ptr<mgmt::ControlParametersBase>
203 return Derived::s_requestFormat.decode(interest, prefixLen + 2);
213 Derived::s_requestFormat.validate(params);
214 Derived::validateRequestImpl(params);
223 Derived::applyDefaultsToRequestImpl(params);
233 Derived::s_responseFormat.validate(params);
234 Derived::validateResponseImpl(params);
243 Derived::applyDefaultsToResponseImpl(params);
268#define NDN_CXX_CONTROL_COMMAND(module_, verb_) \
270 static inline const ::ndn::name::Component module{std::string_view(module_)}; \
271 static inline const ::ndn::name::Component verb{std::string_view(verb_)}; \
273 static const RequestFormat s_requestFormat; \
274 static const ResponseFormat s_responseFormat; \
Represents a TLV element of the NDN packet format.
Represents an Interest packet.
Block getApplicationParameters() const
Get the ApplicationParameters element.
Interest & setApplicationParameters(const Block &block)
Set ApplicationParameters from a Block.
Represents an absolute name.
Name & append(const Component &component)
Append a name component.
A prefix announcement object that represents an application's intent of registering a prefix toward i...
Base class for a struct that contains the parameters for a ControlCommand.
Represents an error in the parameters of the control command request or response.
Base class for all NFD control commands.
static shared_ptr< mgmt::ControlParametersBase > parseRequest(const Interest &interest, size_t prefixLen)
Extract parameters from request Interest.
static Interest createRequest(Name commandPrefix, const RequestParameters ¶ms)
Construct request Interest.
static void validateRequest(const RequestParameters ¶ms)
Validate request parameters.
static void applyDefaultsToRequest(RequestParameters ¶ms)
Apply default values to missing fields in request.
static void applyDefaultsToResponse(ResponseParameters ¶ms)
Apply default values to missing fields in response.
typename ResponseFormat::ParametersType ResponseParameters
ResponseFormatType ResponseFormat
static PartialName getName()
Return the command name (module + verb).
typename RequestFormat::ParametersType RequestParameters
static void validateResponse(const ResponseParameters ¶ms)
Validate response parameters.
RequestFormatType RequestFormat
Represents parameters in a ControlCommand request or response.
Represents a cs/config command.
Represents a cs/erase command.
Represents a faces/create command.
Represents a faces/destroy command.
Represents a faces/update command.
Represents a fib/add-nexthop command.
Represents a fib/remove-nexthop command.
Represents a rib/announce command.
Request parameters for rib/announce command.
const PrefixAnnouncement & getPrefixAnnouncement() const
Block wireEncode() const final
void wireDecode(const Block &wire) final
RibAnnounceParameters & setPrefixAnnouncement(const PrefixAnnouncement &pa)
Represents a rib/register command.
Represents a rib/unregister command.
Represents a strategy-choice/set command.
Represents a strategy-choice/unset command.
Represents an error in TLV encoding or decoding.
Error(const char *expectedType, uint32_t actualType)
#define NDN_CXX_CONTROL_COMMAND(module_, verb_)
Contains classes and functions related to the NFD Management protocol.
Name PartialName
Represents an arbitrary sequence of name components.