22 #ifndef NDN_MGMT_DISPATCHER_HPP 23 #define NDN_MGMT_DISPATCHER_HPP 33 #include <unordered_map> 74 typedef std::function<void(
const Name& prefix,
const Interest& interest,
76 const AcceptContinuation& accept,
104 typedef std::function<void(
const Name& prefix,
const Interest& interest,
117 typedef std::function<void(
const Name& prefix,
const Interest& interest,
141 size_t imsCapacity = 256);
166 addTopPrefix(
const Name& prefix,
bool wantRegister =
true,
178 removeTopPrefix(
const Name& prefix);
206 template<
typename CP>
209 Authorization authorize,
210 ValidateParameters validate,
211 ControlCommandHandler handle);
246 Authorization authorize,
247 StatusDatasetHandler handle);
270 addNotificationStream(
const PartialName& relPrefix);
273 typedef std::function<void(
const Name& prefix,
274 const Interest& interest)> InterestHandler;
276 typedef std::function<void(
const std::string& requester,
279 const shared_ptr<ControlParameters>&)> AuthorizationAcceptedCallback;
282 const Interest& interest)> AuthorizationRejectedCallback;
290 typedef std::function<shared_ptr<ControlParameters>(
const name::Component& comp)> ControlParametersParser;
293 isOverlappedWithOthers(
const PartialName& relPrefix)
const;
313 queryStorage(
const Name& prefix,
const Interest& interest,
const InterestHandler& missContinuation);
315 enum class SendDestination {
340 SendDestination destination, time::milliseconds imsFresh);
348 sendOnFace(
const Data& data);
362 processControlCommandInterest(
const Name& prefix,
363 const Name& relPrefix,
365 const ControlParametersParser& parser,
366 const Authorization& authorization,
367 const AuthorizationAcceptedCallback& accepted,
368 const AuthorizationRejectedCallback& rejected);
381 processAuthorizedControlCommandInterest(
const std::string& requester,
384 const shared_ptr<ControlParameters>& parameters,
385 const ValidateParameters& validate,
386 const ControlCommandHandler& handler);
401 processStatusDatasetInterest(
const Name& prefix,
403 const Authorization& authorization,
404 const AuthorizationAcceptedCallback& accepted,
405 const AuthorizationRejectedCallback& rejected);
416 processAuthorizedStatusDatasetInterest(
const std::string& requester,
419 const StatusDatasetHandler& handler);
430 sendStatusDatasetSegment(
const Name& dataName,
const Block& content,
431 time::milliseconds imsFresh,
bool isFinalBlock);
437 struct TopPrefixEntry
440 std::vector<ScopedInterestFilterHandle> interestFilters;
442 std::unordered_map<Name, TopPrefixEntry> m_topLevelPrefixes;
448 std::unordered_map<PartialName, InterestHandler> m_handlers;
451 std::unordered_map<Name, uint64_t> m_streams;
457 template<
typename CP>
460 Authorization authorize,
461 ValidateParameters validate,
462 ControlCommandHandler handle)
464 if (!m_topLevelPrefixes.empty()) {
465 NDN_THROW(std::domain_error(
"one or more top-level prefix has been added"));
468 if (isOverlappedWithOthers(relPrefix)) {
469 NDN_THROW(std::out_of_range(
"relPrefix overlaps with another relPrefix"));
472 auto parser = [] (
const name::Component& comp) -> shared_ptr<ControlParameters> {
473 return make_shared<CP>(comp.blockFromValue());
476 AuthorizationAcceptedCallback accepted =
477 bind(&Dispatcher::processAuthorizedControlCommandInterest,
this,
478 _1, _2, _3, _4, std::move(validate), std::move(handle));
480 AuthorizationRejectedCallback rejected =
481 bind(&Dispatcher::afterAuthorizationRejected,
this, _1, _2);
483 m_handlers[relPrefix] = bind(&Dispatcher::processControlCommandInterest,
this,
484 _1, relPrefix, _2, std::move(parser), std::move(authorize),
485 std::move(accepted), std::move(rejected));
491 #endif // NDN_MGMT_DISPATCHER_HPP
The interface of signing key management.
Provides in-memory storage employing First-In-First-Out (FIFO) replacement policy.
std::function< void(const Block ¬ification)> PostNotification
a function to post a notification
represents a dispatcher on server side of NFD Management protocol
RejectReply
indicate how to reply in case authorization is rejected
reply with a ControlResponse where StatusCode is 403
Represents a TLV element of the NDN packet format.
Represents an Interest packet.
std::function< void(const std::string &requester)> AcceptContinuation
a function to be called if authorization is successful
Authorization makeAcceptAllAuthorization()
return an Authorization that accepts all Interests, with empty string as requester ...
Signing parameters passed to KeyChain.
std::function< void(RejectReply reply)> RejectContinuation
a function to be called if authorization is rejected
Provide a communication channel with local or remote NDN forwarder.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
void addControlCommand(const PartialName &relPrefix, Authorization authorize, ValidateParameters validate, ControlCommandHandler handle)
register a ControlCommand
Represents an absolute name.
std::function< void(const ControlResponse &resp)> CommandContinuation
a function to be called after ControlCommandHandler completes
base class for a struct that contains ControlCommand parameters
Represents a name component.
std::function< void(const Name &prefix, const Interest &interest, const ControlParameters ¶ms, const CommandContinuation &done)> ControlCommandHandler
a function to handle an authorized ControlCommand
std::function< bool(const ControlParameters ¶ms)> ValidateParameters
a function to validate input ControlParameters
provides a context for generating response to a StatusDataset request
Represents a Data packet.
std::function< void(const Name &prefix, const Interest &interest, const ControlParameters *params, const AcceptContinuation &accept, const RejectContinuation &reject)> Authorization
a function that performs authorization
std::function< void(const Name &prefix, const Interest &interest, StatusDatasetContext &context)> StatusDatasetHandler
a function to handle a StatusDataset request