37 #include "ns3/node-list.h" 39 #include "ns3/simulator.h" 41 #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" 61 config.parse(configSection, isDryRun,
"internal://nfd.conf");
66 template<
typename ConfigParseFunc>
68 : m_keyChain(keyChain)
71 , m_nfdController(m_face, m_keyChain)
72 , m_fibUpdater(m_rib, m_nfdController)
73 , m_dispatcher(m_face, m_keyChain)
74 , m_ribManager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher)
78 processConfig(std::forward<decltype(args)>(args)...);
80 configParse(config,
true);
81 configParse(config,
false);
94 auto node = ::ns3::NodeList::GetNode(::ns3::Simulator::GetContext());
100 Service::processConfig(
const ConfigSection& section,
bool isDryRun,
const std::string& filename)
103 checkConfig(section, filename);
106 applyConfig(section, filename);
111 Service::checkConfig(
const ConfigSection& section,
const std::string& filename)
113 bool hasLocalhop =
false;
114 bool hasPropagate =
false;
116 for (
const auto& item : section) {
117 const std::string& key = item.first;
119 if (key == CFG_LOCALHOST_SECURITY || key == CFG_PA_VALIDATION) {
121 testValidator.
load(value, filename);
123 else if (key == CFG_LOCALHOP_SECURITY) {
126 testValidator.
load(value, filename);
128 else if (key == CFG_PREFIX_PROPAGATE) {
132 else if (key == CFG_READVERTISE_NLSR) {
140 if (hasLocalhop && hasPropagate) {
142 " cannot be enabled at the same time"));
147 Service::applyConfig(
const ConfigSection& section,
const std::string& filename)
149 bool wantPrefixPropagate =
false;
150 bool wantReadvertiseNlsr =
false;
152 for (
const auto& item : section) {
153 const std::string& key = item.first;
155 if (key == CFG_LOCALHOST_SECURITY) {
158 else if (key == CFG_LOCALHOP_SECURITY) {
161 else if (key == CFG_PA_VALIDATION) {
164 else if (key == CFG_PREFIX_PROPAGATE) {
165 wantPrefixPropagate =
true;
167 if (!m_readvertisePropagation) {
170 auto cost = item.second.get_optional<uint64_t>(
"cost");
172 .setCost(cost.value_or(PROPAGATE_DEFAULT_COST))
175 auto timeout = item.second.get_optional<uint64_t>(
"timeout");
180 m_readvertisePropagation = make_unique<Readvertise>(
182 make_unique<HostToGatewayReadvertisePolicy>(m_keyChain, item.second),
183 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options, parameters));
186 else if (key == CFG_READVERTISE_NLSR) {
194 if (!wantPrefixPropagate && m_readvertisePropagation !=
nullptr) {
196 m_readvertisePropagation.reset();
199 if (wantReadvertiseNlsr && m_readvertiseNlsr ==
nullptr) {
202 m_readvertiseNlsr = make_unique<Readvertise>(
204 make_unique<ClientToNlsrReadvertisePolicy>(),
205 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options));
207 else if (!wantReadvertiseNlsr && m_readvertiseNlsr !=
nullptr) {
209 m_readvertiseNlsr.reset();
const Name READVERTISE_NLSR_PREFIX
const std::string CFG_PA_VALIDATION
void load(const std::string &filename)
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"
const time::milliseconds PROPAGATE_DEFAULT_TIMEOUT
#define NFD_LOG_INIT(name)
void enableLocalFields()
Enable NDNLP IncomingFaceId field in order to support self-registration commands. ...
initializes and executes NFD-RIB service thread
Helper for validator that uses SignedInterest + CommandInterest + Config policy and NetworkFetcher...
configuration file parsing utility
const std::string CFG_LOCALHOST_SECURITY
DummyIoService & getIoService()
const std::string CFG_READVERTISE_NLSR
const std::string CFG_RIB
CommandOptions & setTimeout(const time::milliseconds &timeout)
sets command timeout
::nfd::rib::Service & getRibService()
const uint64_t PROPAGATE_DEFAULT_COST
void enableLocalhop(const ConfigSection §ion, const std::string &filename)
Apply localhop_security configuration and allow accepting commands on /localhop/nfd/rib prefix...
contains options for ControlCommand execution
Copyright (c) 2011-2015 Regents of the University of California.
void addSectionHandler(const std::string §ionName, ConfigSectionHandler subscriber)
setup notification of configuration file sections
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.
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)
const std::string CFG_PREFIX_PROPAGATE
static const Name LOCALHOP_TOP_PREFIX
void applyPaConfig(const ConfigSection §ion, const std::string &filename)
Apply prefix_announcement_validation configuration.
void registerWithNfd()
Start accepting commands and dataset requests.
void applyLocalhostConfig(const ConfigSection §ion, const std::string &filename)
Apply localhost_security configuration.
CommandOptions & setPrefix(const Name &prefix)
sets command prefix
boost::chrono::milliseconds milliseconds