37 #include "ns3/node-list.h" 39 #include "ns3/simulator.h" 41 #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" 59 [&configSection] (
ConfigFile& config, bool isDryRun) {
60 config.parse(configSection, isDryRun,
"internal://nfd.conf");
65 template<
typename ConfigParseFunc>
67 : m_keyChain(keyChain)
69 , m_scheduler(m_face.getIoService())
70 , m_nfdController(m_face, m_keyChain)
71 , m_fibUpdater(m_rib, m_nfdController)
72 , m_dispatcher(m_face, m_keyChain)
73 , m_ribManager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
76 config.addSectionHandler(
CFG_SECTION, bind(&Service::processConfig,
this, _1, _2, _3));
77 configParse(config,
true);
78 configParse(config,
false);
91 auto node = ::ns3::NodeList::GetNode(::ns3::Simulator::GetContext());
97 Service::processConfig(
const ConfigSection& section,
bool isDryRun,
const std::string& filename)
100 checkConfig(section, filename);
103 applyConfig(section, filename);
108 Service::checkConfig(
const ConfigSection& section,
const std::string& filename)
110 for (
const auto& item : section) {
111 const std::string& key = item.first;
115 testValidator.load(value, filename);
124 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Unrecognized option " +
CFG_SECTION +
"." + key));
130 Service::applyConfig(
const ConfigSection& section,
const std::string& filename)
132 bool wantPrefixPropagate =
false;
133 bool wantReadvertiseNlsr =
false;
135 for (
const auto& item : section) {
136 const std::string& key = item.first;
145 wantPrefixPropagate =
true;
147 if (!m_readvertisePropagation) {
153 auto cost = item.second.get_optional<uint64_t>(
"cost");
155 parameters.setCost(*cost);
161 auto timeout = item.second.get_optional<uint64_t>(
"timeout");
163 options.
setTimeout(time::milliseconds(*timeout));
166 m_readvertisePropagation = make_unique<Readvertise>(
169 make_unique<HostToGatewayReadvertisePolicy>(m_keyChain, item.second),
170 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options, parameters));
177 BOOST_THROW_EXCEPTION(ConfigFile::Error(
"Unrecognized option " +
CFG_SECTION +
"." + key));
181 if (!wantPrefixPropagate && m_readvertisePropagation !=
nullptr) {
183 m_readvertisePropagation.reset();
186 if (wantReadvertiseNlsr && m_readvertiseNlsr ==
nullptr) {
189 m_readvertiseNlsr = make_unique<Readvertise>(
192 make_unique<ClientToNlsrReadvertisePolicy>(),
193 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options));
195 else if (!wantReadvertiseNlsr && m_readvertiseNlsr !=
nullptr) {
197 m_readvertiseNlsr.reset();
static const Name READVERTISE_NLSR_PREFIX
void applyLocalhostConfig(const ConfigSection §ion, const std::string &filename)
Apply localhost_security configuration.
static const std::string CFG_SECTION
static bool parseYesNo(const ConfigSection &node, const std::string &key, const std::string §ionName)
parse a config option that can be either "yes" or "no"
static const time::milliseconds PROPAGATE_DEFAULT_TIMEOUT
The interface of signing key management.
initializes and executes NFD-RIB service thread
Helper for validator that uses CommandInterest + Config policy and NetworkFetcher.
configuration file parsing utility
static const std::string CFG_LOCALHOST_SECURITY
void enableLocalhop(const ConfigSection §ion, const std::string &filename)
Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix.
static const std::string CFG_READVERTISE_NLSR
CommandOptions & setTimeout(const time::milliseconds &timeout)
sets command timeout
::nfd::rib::Service & getRibService()
static const uint64_t PROPAGATE_DEFAULT_COST
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
Provide a communication channel with local or remote NDN forwarder.
boost::property_tree::ptree ConfigSection
a config file section
Represents an absolute name.
Implementation network-layer of NDN stack.
static const std::string CFG_LOCALHOP_SECURITY
static Service & get()
Get a reference to the only instance of this class.
Service(const ConfigSection &configSection, ndn::Face &face, ndn::KeyChain &keyChain)
static void ignoreUnknownSection(const std::string &filename, const std::string §ionName, const ConfigSection §ion, bool isDryRun)
static const std::string CFG_PREFIX_PROPAGATE
#define NFD_LOG_INIT(name)
static const Name LOCALHOP_TOP_PREFIX
void enableLocalFields()
Enable NDNLP IncomingFaceId field in order to support self-registration commands.
CommandOptions & setPrefix(const Name &prefix)
sets command prefix
void registerWithNfd()
Start accepting commands and dataset requests.