37 #include "ns3/node-list.h"
39 #include "ns3/simulator.h"
41 #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp"
60 [&configSection] (
ConfigFile& config, bool isDryRun) {
61 config.parse(configSection, isDryRun,
"internal://nfd.conf");
66 template<
typename ConfigParseFunc>
68 : m_keyChain(keyChain)
70 , m_scheduler(m_face.getIoService())
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)
77 config.addSectionHandler(
CFG_SECTION, bind(&Service::processConfig,
this, _1, _2, _3));
78 configParse(config,
true);
79 configParse(config,
false);
92 auto node = ::ns3::NodeList::GetNode(::ns3::Simulator::GetContext());
98 Service::processConfig(
const ConfigSection& section,
bool isDryRun,
const std::string& filename)
101 checkConfig(section, filename);
104 applyConfig(section, filename);
109 Service::checkConfig(
const ConfigSection& section,
const std::string& filename)
111 bool hasLocalhop =
false;
112 bool hasPropagate =
false;
114 for (
const auto& item : section) {
115 const std::string& key = item.first;
120 testValidator.load(value, filename);
134 if (hasLocalhop && hasPropagate) {
136 " cannot be enabled at the same time"));
141 Service::applyConfig(
const ConfigSection& section,
const std::string& filename)
143 bool wantPrefixPropagate =
false;
144 bool wantReadvertiseNlsr =
false;
146 for (
const auto& item : section) {
147 const std::string& key = item.first;
159 wantPrefixPropagate =
true;
161 if (!m_readvertisePropagation) {
164 auto cost = item.second.get_optional<uint64_t>(
"cost");
169 auto timeout = item.second.get_optional<uint64_t>(
"timeout");
174 m_readvertisePropagation = make_unique<Readvertise>(
176 make_unique<HostToGatewayReadvertisePolicy>(m_keyChain, item.second),
177 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options, parameters));
188 if (!wantPrefixPropagate && m_readvertisePropagation !=
nullptr) {
190 m_readvertisePropagation.reset();
193 if (wantReadvertiseNlsr && m_readvertiseNlsr ==
nullptr) {
196 m_readvertiseNlsr = make_unique<Readvertise>(
198 make_unique<ClientToNlsrReadvertisePolicy>(),
199 make_unique<NfdRibReadvertiseDestination>(m_nfdController, m_rib, options));
201 else if (!wantReadvertiseNlsr && m_readvertiseNlsr !=
nullptr) {
203 m_readvertiseNlsr.reset();