NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
command-validator.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #ifndef NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
26 #define NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
27 
28 #include "common.hpp"
29 #include "config-file.hpp"
30 #include <ndn-cxx/util/command-interest-validator.hpp>
31 
32 namespace nfd {
33 
35 {
36 public:
37 
38  class Error : public std::runtime_error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : std::runtime_error(what)
44  {
45 
46  }
47  };
48 
50 
52 
53  void
54  setConfigFile(ConfigFile& configFile);
55 
62  void
63  onConfig(const ConfigSection& section, bool isDryRun, const std::string& filename);
64 
69  void
70  addSupportedPrivilege(const std::string& privilege);
71 
72  void
73  addInterestRule(const std::string& regex,
74  const ndn::IdentityCertificate& certificate);
75 
76  void
77  addInterestRule(const std::string& regex,
78  const Name& keyName,
79  const ndn::PublicKey& publicKey);
80 
81  void
82  validate(const Interest& interest,
83  const ndn::OnInterestValidated& onValidated,
84  const ndn::OnInterestValidationFailed& onValidationFailed);
85 
86 private:
88  std::set<std::string> m_supportedPrivileges;
89 };
90 
91 inline void
92 CommandValidator::addInterestRule(const std::string& regex,
93  const ndn::IdentityCertificate& certificate)
94 {
95  m_validator.addInterestRule(regex, certificate);
96 }
97 
98 inline void
99 CommandValidator::addInterestRule(const std::string& regex,
100  const Name& keyName,
101  const ndn::PublicKey& publicKey)
102 {
103  m_validator.addInterestRule(regex, keyName, publicKey);
104 }
105 
106 inline void
108  const ndn::OnInterestValidated& onValidated,
109  const ndn::OnInterestValidationFailed& onValidationFailed)
110 {
111  m_validator.validate(interest, onValidated, onValidationFailed);
112 }
113 
114 } // namespace nfd
115 
116 #endif // NFD_DAEMON_MGMT_COMMAND_VALIDATOR_HPP
void addInterestRule(const std::string &regex, const ndn::IdentityCertificate &certificate)
void setConfigFile(ConfigFile &configFile)
Helper class to validate CommandInterests.
STL namespace.
represents an Interest packet
Definition: interest.hpp:45
void onConfig(const ConfigSection &section, bool isDryRun, const std::string &filename)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:38
Error(const std::string &what)
boost::property_tree::ptree ConfigSection
Name abstraction to represent an absolute name.
Definition: name.hpp:46
function< void(const shared_ptr< const Interest > &, const std::string &)> OnInterestValidationFailed
Callback to report a failed Interest validation.
void validate(const Interest &interest, const ndn::OnInterestValidated &onValidated, const ndn::OnInterestValidationFailed &onValidationFailed)
void addSupportedPrivilege(const std::string &privilege)
function< void(const shared_ptr< const Interest > &)> OnInterestValidated
Callback to report a successful Interest validation.