Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #include "face-manager.hpp" |
| 8 | |
| 9 | #include "core/face-uri.hpp" |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 10 | #include "core/network-interface.hpp" |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 11 | #include "fw/face-table.hpp" |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 12 | #include "face/tcp-factory.hpp" |
| 13 | #include "face/udp-factory.hpp" |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 14 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 15 | #include <ndn-cpp-dev/management/nfd-face-event-notification.hpp> |
| 16 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 17 | #ifdef HAVE_UNIX_SOCKETS |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 18 | #include "face/unix-stream-factory.hpp" |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 19 | #endif // HAVE_UNIX_SOCKETS |
| 20 | |
| 21 | #ifdef HAVE_PCAP |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 22 | #include "face/ethernet-factory.hpp" |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 23 | #endif // HAVE_PCAP |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 24 | |
| 25 | namespace nfd { |
| 26 | |
| 27 | NFD_LOG_INIT("FaceManager"); |
| 28 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 29 | const Name FaceManager::COMMAND_PREFIX("/localhost/nfd/faces"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 30 | |
| 31 | const size_t FaceManager::COMMAND_UNSIGNED_NCOMPS = |
| 32 | FaceManager::COMMAND_PREFIX.size() + |
| 33 | 1 + // verb |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 34 | 1; // verb parameters |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 35 | |
| 36 | const size_t FaceManager::COMMAND_SIGNED_NCOMPS = |
| 37 | FaceManager::COMMAND_UNSIGNED_NCOMPS + |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 38 | 4; // (timestamp, nonce, signed info tlv, signature tlv) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 39 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 40 | const FaceManager::SignedVerbAndProcessor FaceManager::SIGNED_COMMAND_VERBS[] = |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 41 | { |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 42 | SignedVerbAndProcessor( |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 43 | Name::Component("create"), |
| 44 | &FaceManager::createFace |
| 45 | ), |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 46 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 47 | SignedVerbAndProcessor( |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 48 | Name::Component("destroy"), |
| 49 | &FaceManager::destroyFace |
| 50 | ), |
| 51 | |
| 52 | SignedVerbAndProcessor( |
| 53 | Name::Component("enable-local-control"), |
| 54 | &FaceManager::enableLocalControl |
| 55 | ), |
| 56 | |
| 57 | SignedVerbAndProcessor( |
| 58 | Name::Component("disable-local-control"), |
| 59 | &FaceManager::disableLocalControl |
| 60 | ), |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 63 | const FaceManager::UnsignedVerbAndProcessor FaceManager::UNSIGNED_COMMAND_VERBS[] = |
| 64 | { |
| 65 | UnsignedVerbAndProcessor( |
| 66 | Name::Component("list"), |
| 67 | &FaceManager::listFaces |
| 68 | ), |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 69 | |
| 70 | UnsignedVerbAndProcessor( |
| 71 | Name::Component("events"), |
| 72 | &FaceManager::ignoreUnsignedVerb |
| 73 | ), |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | const Name FaceManager::LIST_COMMAND_PREFIX("/localhost/nfd/faces/list"); |
| 77 | const size_t FaceManager::LIST_COMMAND_NCOMPS = LIST_COMMAND_PREFIX.size(); |
| 78 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 79 | const Name FaceManager::EVENTS_COMMAND_PREFIX("/localhost/nfd/faces/events"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 80 | |
| 81 | FaceManager::FaceManager(FaceTable& faceTable, |
Steve DiBenedetto | 2c2b889 | 2014-02-27 11:46:48 -0700 | [diff] [blame] | 82 | shared_ptr<InternalFace> face) |
| 83 | : ManagerBase(face, FACE_MANAGER_PRIVILEGE) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 84 | , m_faceTable(faceTable) |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 85 | , m_statusPublisher(m_faceTable, m_face, LIST_COMMAND_PREFIX) |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 86 | , m_notificationStream(m_face, EVENTS_COMMAND_PREFIX) |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 87 | , m_signedVerbDispatch(SIGNED_COMMAND_VERBS, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 88 | SIGNED_COMMAND_VERBS + |
| 89 | (sizeof(SIGNED_COMMAND_VERBS) / sizeof(SignedVerbAndProcessor))) |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 90 | , m_unsignedVerbDispatch(UNSIGNED_COMMAND_VERBS, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 91 | UNSIGNED_COMMAND_VERBS + |
| 92 | (sizeof(UNSIGNED_COMMAND_VERBS) / sizeof(UnsignedVerbAndProcessor))) |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 93 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 94 | { |
| 95 | face->setInterestFilter("/localhost/nfd/faces", |
| 96 | bind(&FaceManager::onFaceRequest, this, _2)); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 97 | |
| 98 | m_faceTable.onAdd += bind(&FaceManager::onAddFace, this, _1); |
| 99 | m_faceTable.onRemove += bind(&FaceManager::onRemoveFace, this, _1); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 102 | FaceManager::~FaceManager() |
| 103 | { |
| 104 | |
| 105 | } |
| 106 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 107 | void |
| 108 | FaceManager::setConfigFile(ConfigFile& configFile) |
| 109 | { |
| 110 | configFile.addSectionHandler("face_system", |
Steve DiBenedetto | 1a3c673 | 2014-03-13 06:44:05 -0600 | [diff] [blame] | 111 | bind(&FaceManager::onConfig, this, _1, _2, _3)); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | |
| 115 | void |
Steve DiBenedetto | 1a3c673 | 2014-03-13 06:44:05 -0600 | [diff] [blame] | 116 | FaceManager::onConfig(const ConfigSection& configSection, |
| 117 | bool isDryRun, |
| 118 | const std::string& filename) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 119 | { |
| 120 | bool hasSeenUnix = false; |
| 121 | bool hasSeenTcp = false; |
| 122 | bool hasSeenUdp = false; |
| 123 | bool hasSeenEther = false; |
| 124 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 125 | const std::list<shared_ptr<NetworkInterfaceInfo> > nicList(listNetworkInterfaces()); |
| 126 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 127 | for (ConfigSection::const_iterator item = configSection.begin(); |
| 128 | item != configSection.end(); |
| 129 | ++item) |
| 130 | { |
| 131 | if (item->first == "unix") |
| 132 | { |
| 133 | if (hasSeenUnix) |
| 134 | throw Error("Duplicate \"unix\" section"); |
| 135 | hasSeenUnix = true; |
| 136 | |
| 137 | processSectionUnix(item->second, isDryRun); |
| 138 | } |
| 139 | else if (item->first == "tcp") |
| 140 | { |
| 141 | if (hasSeenTcp) |
| 142 | throw Error("Duplicate \"tcp\" section"); |
| 143 | hasSeenTcp = true; |
| 144 | |
| 145 | processSectionTcp(item->second, isDryRun); |
| 146 | } |
| 147 | else if (item->first == "udp") |
| 148 | { |
| 149 | if (hasSeenUdp) |
| 150 | throw Error("Duplicate \"udp\" section"); |
| 151 | hasSeenUdp = true; |
| 152 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 153 | processSectionUdp(item->second, isDryRun, nicList); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 154 | } |
| 155 | else if (item->first == "ether") |
| 156 | { |
| 157 | if (hasSeenEther) |
| 158 | throw Error("Duplicate \"ether\" section"); |
| 159 | hasSeenEther = true; |
| 160 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 161 | processSectionEther(item->second, isDryRun, nicList); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 162 | } |
| 163 | else |
| 164 | { |
| 165 | throw Error("Unrecognized option \"" + item->first + "\""); |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | void |
| 171 | FaceManager::processSectionUnix(const ConfigSection& configSection, bool isDryRun) |
| 172 | { |
| 173 | // ; the unix section contains settings of UNIX stream faces and channels |
| 174 | // unix |
| 175 | // { |
| 176 | // listen yes ; set to 'no' to disable UNIX stream listener, default 'yes' |
| 177 | // path /var/run/nfd.sock ; UNIX stream listener path |
| 178 | // } |
| 179 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 180 | #if defined(HAVE_UNIX_SOCKETS) |
| 181 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 182 | bool needToListen = true; |
| 183 | std::string path = "/var/run/nfd.sock"; |
| 184 | |
| 185 | for (ConfigSection::const_iterator i = configSection.begin(); |
| 186 | i != configSection.end(); |
| 187 | ++i) |
| 188 | { |
| 189 | if (i->first == "path") |
| 190 | { |
| 191 | path = i->second.get_value<std::string>(); |
| 192 | } |
| 193 | else if (i->first == "listen") |
| 194 | { |
| 195 | needToListen = parseYesNo(i, i->first, "unix"); |
| 196 | } |
| 197 | else |
| 198 | { |
| 199 | throw ConfigFile::Error("Unrecognized option \"" + i->first + "\" in \"unix\" section"); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (!isDryRun) |
| 204 | { |
| 205 | shared_ptr<UnixStreamFactory> factory = make_shared<UnixStreamFactory>(); |
| 206 | shared_ptr<UnixStreamChannel> unixChannel = factory->createChannel(path); |
| 207 | |
| 208 | if (needToListen) |
| 209 | { |
| 210 | // Should acceptFailed callback be used somehow? |
| 211 | unixChannel->listen(bind(&FaceTable::add, &m_faceTable, _1), |
| 212 | UnixStreamChannel::ConnectFailedCallback()); |
| 213 | } |
| 214 | |
| 215 | m_factories.insert(std::make_pair("unix", factory)); |
| 216 | } |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 217 | #else |
| 218 | throw ConfigFile::Error("NFD was compiled without UNIX sockets support, cannot process \"unix\" section"); |
| 219 | #endif // HAVE_UNIX_SOCKETS |
| 220 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | void |
| 224 | FaceManager::processSectionTcp(const ConfigSection& configSection, bool isDryRun) |
| 225 | { |
| 226 | // ; the tcp section contains settings of TCP faces and channels |
| 227 | // tcp |
| 228 | // { |
| 229 | // listen yes ; set to 'no' to disable TCP listener, default 'yes' |
| 230 | // port 6363 ; TCP listener port number |
| 231 | // } |
| 232 | |
| 233 | std::string port = "6363"; |
| 234 | bool needToListen = true; |
| 235 | |
| 236 | for (ConfigSection::const_iterator i = configSection.begin(); |
| 237 | i != configSection.end(); |
| 238 | ++i) |
| 239 | { |
| 240 | if (i->first == "port") |
| 241 | { |
| 242 | port = i->second.get_value<std::string>(); |
| 243 | } |
| 244 | else if (i->first == "listen") |
| 245 | { |
| 246 | needToListen = parseYesNo(i, i->first, "tcp"); |
| 247 | } |
| 248 | else |
| 249 | { |
| 250 | throw ConfigFile::Error("Unrecognized option \"" + i->first + "\" in \"tcp\" section"); |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | if (!isDryRun) |
| 255 | { |
| 256 | shared_ptr<TcpFactory> factory = make_shared<TcpFactory>(boost::cref(port)); |
| 257 | |
| 258 | using namespace boost::asio::ip; |
| 259 | |
| 260 | shared_ptr<TcpChannel> ipv4Channel = factory->createChannel("0.0.0.0", port); |
| 261 | shared_ptr<TcpChannel> ipv6Channel = factory->createChannel("::", port); |
| 262 | |
| 263 | if (needToListen) |
| 264 | { |
| 265 | // Should acceptFailed callback be used somehow? |
| 266 | |
| 267 | ipv4Channel->listen(bind(&FaceTable::add, &m_faceTable, _1), |
| 268 | TcpChannel::ConnectFailedCallback()); |
| 269 | ipv6Channel->listen(bind(&FaceTable::add, &m_faceTable, _1), |
| 270 | TcpChannel::ConnectFailedCallback()); |
| 271 | } |
| 272 | |
| 273 | m_factories.insert(std::make_pair("tcp", factory)); |
| 274 | m_factories.insert(std::make_pair("tcp4", factory)); |
| 275 | m_factories.insert(std::make_pair("tcp6", factory)); |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | void |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 280 | FaceManager::processSectionUdp(const ConfigSection& configSection, |
| 281 | bool isDryRun, |
| 282 | const std::list<shared_ptr<NetworkInterfaceInfo> >& nicList) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 283 | { |
| 284 | // ; the udp section contains settings of UDP faces and channels |
| 285 | // udp |
| 286 | // { |
| 287 | // port 6363 ; UDP unicast port number |
| 288 | // idle_timeout 30 ; idle time (seconds) before closing a UDP unicast face |
| 289 | // keep_alive_interval 25; interval (seconds) between keep-alive refreshes |
| 290 | |
| 291 | // ; NFD creates one UDP multicast face per NIC |
| 292 | // mcast yes ; set to 'no' to disable UDP multicast, default 'yes' |
| 293 | // mcast_port 56363 ; UDP multicast port number |
| 294 | // mcast_group 224.0.23.170 ; UDP multicast group (IPv4 only) |
| 295 | // } |
| 296 | |
| 297 | std::string port = "6363"; |
| 298 | size_t timeout = 30; |
| 299 | size_t keepAliveInterval = 25; |
| 300 | bool useMcast = true; |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 301 | std::string mcastGroup = "224.0.23.170"; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 302 | std::string mcastPort = "56363"; |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 303 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 304 | |
| 305 | for (ConfigSection::const_iterator i = configSection.begin(); |
| 306 | i != configSection.end(); |
| 307 | ++i) |
| 308 | { |
| 309 | if (i->first == "port") |
| 310 | { |
| 311 | port = i->second.get_value<std::string>(); |
| 312 | } |
| 313 | else if (i->first == "idle_timeout") |
| 314 | { |
| 315 | try |
| 316 | { |
| 317 | timeout = i->second.get_value<size_t>(); |
| 318 | } |
| 319 | catch (const std::exception& e) |
| 320 | { |
| 321 | throw ConfigFile::Error("Invalid value for option \"" + |
| 322 | i->first + "\" in \"udp\" section"); |
| 323 | } |
| 324 | } |
| 325 | else if (i->first == "keep_alive_interval") |
| 326 | { |
| 327 | try |
| 328 | { |
| 329 | keepAliveInterval = i->second.get_value<size_t>(); |
Alexander Afanasyev | efea8fe | 2014-03-23 00:00:35 -0700 | [diff] [blame] | 330 | |
| 331 | /// \todo Make use of keepAliveInterval |
| 332 | (void)(keepAliveInterval); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 333 | } |
| 334 | catch (const std::exception& e) |
| 335 | { |
| 336 | throw ConfigFile::Error("Invalid value for option \"" + |
| 337 | i->first + "\" in \"udp\" section"); |
| 338 | } |
| 339 | } |
| 340 | else if (i->first == "mcast") |
| 341 | { |
| 342 | useMcast = parseYesNo(i, i->first, "udp"); |
| 343 | } |
| 344 | else if (i->first == "mcast_port") |
| 345 | { |
| 346 | mcastPort = i->second.get_value<std::string>(); |
| 347 | } |
| 348 | else if (i->first == "mcast_group") |
| 349 | { |
| 350 | using namespace boost::asio::ip; |
| 351 | mcastGroup = i->second.get_value<std::string>(); |
| 352 | try |
| 353 | { |
| 354 | address mcastGroupTest = address::from_string(mcastGroup); |
| 355 | if (!mcastGroupTest.is_v4()) |
| 356 | { |
| 357 | throw ConfigFile::Error("Invalid value for option \"" + |
| 358 | i->first + "\" in \"udp\" section"); |
| 359 | } |
| 360 | } |
| 361 | catch(const std::runtime_error& e) |
| 362 | { |
| 363 | throw ConfigFile::Error("Invalid value for option \"" + |
| 364 | i->first + "\" in \"udp\" section"); |
| 365 | } |
| 366 | } |
| 367 | else |
| 368 | { |
| 369 | throw ConfigFile::Error("Unrecognized option \"" + i->first + "\" in \"udp\" section"); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | /// \todo what is keep alive interval used for? |
| 374 | |
| 375 | if (!isDryRun) |
| 376 | { |
| 377 | shared_ptr<UdpFactory> factory = make_shared<UdpFactory>(boost::cref(port)); |
| 378 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 379 | factory->createChannel("::", port, time::seconds(timeout)); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 380 | |
| 381 | m_factories.insert(std::make_pair("udp", factory)); |
| 382 | m_factories.insert(std::make_pair("udp4", factory)); |
| 383 | m_factories.insert(std::make_pair("udp6", factory)); |
| 384 | |
| 385 | if (useMcast) |
| 386 | { |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 387 | bool useEndpoint = false; |
| 388 | udp::Endpoint localEndpoint; |
| 389 | |
| 390 | try |
| 391 | { |
| 392 | localEndpoint.port(boost::lexical_cast<uint16_t>(port)); |
| 393 | useEndpoint = true; |
| 394 | } |
| 395 | catch (const boost::bad_lexical_cast& error) |
| 396 | { |
| 397 | NFD_LOG_DEBUG("Treating UDP port \"" << port << "\" as a service name"); |
| 398 | } |
| 399 | |
| 400 | for (std::list<shared_ptr<NetworkInterfaceInfo> >::const_iterator i = nicList.begin(); |
| 401 | i != nicList.end(); |
| 402 | ++i) |
| 403 | { |
| 404 | const shared_ptr<NetworkInterfaceInfo>& nic = *i; |
| 405 | if (nic->isUp() && nic->isMulticastCapable() && !nic->ipv4Addresses.empty()) |
| 406 | { |
| 407 | shared_ptr<MulticastUdpFace> newFace = |
| 408 | factory->createMulticastFace(nic->ipv4Addresses[0].to_string(), |
| 409 | mcastGroup, mcastPort); |
| 410 | |
Alexander Afanasyev | bbe3f0c | 2014-03-23 11:44:01 -0700 | [diff] [blame] | 411 | addCreatedFaceToForwarder(newFace); |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 412 | |
| 413 | if (useEndpoint) |
| 414 | { |
| 415 | for (std::vector<boost::asio::ip::address_v4>::const_iterator j = |
| 416 | nic->ipv4Addresses.begin(); |
| 417 | j != nic->ipv4Addresses.end(); |
| 418 | ++j) |
| 419 | { |
| 420 | localEndpoint.address(*j); |
| 421 | factory->createChannel(localEndpoint, time::seconds(timeout)); |
| 422 | } |
| 423 | } |
| 424 | else |
| 425 | { |
| 426 | for (std::vector<boost::asio::ip::address_v4>::const_iterator j = |
| 427 | nic->ipv4Addresses.begin(); |
| 428 | j != nic->ipv4Addresses.end(); |
| 429 | ++j) |
| 430 | { |
| 431 | factory->createChannel(j->to_string(), port, time::seconds(timeout)); |
| 432 | } |
| 433 | } |
| 434 | } |
| 435 | } |
| 436 | } |
| 437 | else |
| 438 | { |
| 439 | factory->createChannel("0.0.0.0", port, time::seconds(timeout)); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 440 | } |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 445 | FaceManager::processSectionEther(const ConfigSection& configSection, |
| 446 | bool isDryRun, |
| 447 | const std::list<shared_ptr<NetworkInterfaceInfo> >& nicList) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 448 | { |
| 449 | // ; the ether section contains settings of Ethernet faces and channels |
| 450 | // ether |
| 451 | // { |
| 452 | // ; NFD creates one Ethernet multicast face per NIC |
| 453 | // mcast yes ; set to 'no' to disable Ethernet multicast, default 'yes' |
| 454 | // mcast_group 01:00:5E:00:17:AA ; Ethernet multicast group |
| 455 | // } |
| 456 | |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 457 | #if defined(HAVE_PCAP) |
| 458 | |
| 459 | using ethernet::Address; |
| 460 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 461 | bool useMcast = true; |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 462 | Address mcastGroup(ethernet::getDefaultMulticastAddress()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 463 | |
| 464 | for (ConfigSection::const_iterator i = configSection.begin(); |
| 465 | i != configSection.end(); |
| 466 | ++i) |
| 467 | { |
| 468 | if (i->first == "mcast") |
| 469 | { |
| 470 | useMcast = parseYesNo(i, i->first, "ether"); |
| 471 | } |
| 472 | |
| 473 | else if (i->first == "mcast_group") |
| 474 | { |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 475 | mcastGroup = Address::fromString(i->second.get_value<std::string>()); |
| 476 | if (mcastGroup.isNull()) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 477 | { |
| 478 | throw ConfigFile::Error("Invalid value for option \"" + |
| 479 | i->first + "\" in \"ether\" section"); |
| 480 | } |
| 481 | } |
| 482 | else |
| 483 | { |
| 484 | throw ConfigFile::Error("Unrecognized option \"" + i->first + "\" in \"ether\" section"); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | if (!isDryRun) |
| 489 | { |
| 490 | shared_ptr<EthernetFactory> factory = make_shared<EthernetFactory>(); |
| 491 | m_factories.insert(std::make_pair("ether", factory)); |
| 492 | |
| 493 | if (useMcast) |
| 494 | { |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 495 | for (std::list<shared_ptr<NetworkInterfaceInfo> >::const_iterator i = nicList.begin(); |
| 496 | i != nicList.end(); |
| 497 | ++i) |
| 498 | { |
| 499 | const shared_ptr<NetworkInterfaceInfo>& nic = *i; |
| 500 | if (nic->isUp() && nic->isMulticastCapable()) |
| 501 | { |
| 502 | try |
| 503 | { |
| 504 | shared_ptr<EthernetFace> newFace = |
Davide Pesavento | b60cc12 | 2014-03-19 19:26:02 +0100 | [diff] [blame] | 505 | factory->createMulticastFace(nic, mcastGroup); |
Alexander Afanasyev | bbe3f0c | 2014-03-23 11:44:01 -0700 | [diff] [blame] | 506 | |
| 507 | addCreatedFaceToForwarder(newFace); |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 508 | } |
| 509 | catch (const EthernetFactory::Error& factoryError) |
| 510 | { |
| 511 | NFD_LOG_ERROR(factoryError.what() << ", continuing"); |
| 512 | } |
| 513 | catch (const EthernetFace::Error& faceError) |
| 514 | { |
| 515 | NFD_LOG_ERROR(faceError.what() << ", continuing"); |
| 516 | } |
| 517 | } |
| 518 | } |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 519 | } |
| 520 | } |
Steve DiBenedetto | 4aca99c | 2014-03-11 11:27:54 -0600 | [diff] [blame] | 521 | #else |
| 522 | throw ConfigFile::Error("NFD was compiled without libpcap, cannot process \"ether\" section"); |
| 523 | #endif // HAVE_PCAP |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | |
| 527 | void |
| 528 | FaceManager::onFaceRequest(const Interest& request) |
| 529 | { |
| 530 | const Name& command = request.getName(); |
| 531 | const size_t commandNComps = command.size(); |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 532 | const Name::Component& verb = command.get(COMMAND_PREFIX.size()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 533 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 534 | UnsignedVerbDispatchTable::const_iterator unsignedVerbProcessor = m_unsignedVerbDispatch.find(verb); |
| 535 | if (unsignedVerbProcessor != m_unsignedVerbDispatch.end()) |
| 536 | { |
| 537 | NFD_LOG_INFO("command result: processing verb: " << verb); |
| 538 | (unsignedVerbProcessor->second)(this, boost::cref(request)); |
| 539 | } |
| 540 | else if (COMMAND_UNSIGNED_NCOMPS <= commandNComps && |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 541 | commandNComps < COMMAND_SIGNED_NCOMPS) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 542 | { |
| 543 | NFD_LOG_INFO("command result: unsigned verb: " << command); |
| 544 | sendResponse(command, 401, "Signature required"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 545 | } |
| 546 | else if (commandNComps < COMMAND_SIGNED_NCOMPS || |
| 547 | !COMMAND_PREFIX.isPrefixOf(command)) |
| 548 | { |
| 549 | NFD_LOG_INFO("command result: malformed"); |
| 550 | sendResponse(command, 400, "Malformed command"); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 551 | } |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 552 | else |
| 553 | { |
| 554 | validate(request, |
| 555 | bind(&FaceManager::onValidatedFaceRequest, this, _1), |
| 556 | bind(&ManagerBase::onCommandValidationFailed, this, _1, _2)); |
| 557 | } |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | void |
| 561 | FaceManager::onValidatedFaceRequest(const shared_ptr<const Interest>& request) |
| 562 | { |
| 563 | const Name& command = request->getName(); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 564 | const Name::Component& verb = command[COMMAND_PREFIX.size()]; |
| 565 | const Name::Component& parameterComponent = command[COMMAND_PREFIX.size() + 1]; |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 566 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 567 | SignedVerbDispatchTable::const_iterator signedVerbProcessor = m_signedVerbDispatch.find(verb); |
| 568 | if (signedVerbProcessor != m_signedVerbDispatch.end()) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 569 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 570 | ControlParameters parameters; |
| 571 | if (!extractParameters(parameterComponent, parameters)) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 572 | { |
| 573 | sendResponse(command, 400, "Malformed command"); |
| 574 | return; |
| 575 | } |
| 576 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 577 | NFD_LOG_INFO("command result: processing verb: " << verb); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 578 | (signedVerbProcessor->second)(this, *request, parameters); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 579 | } |
| 580 | else |
| 581 | { |
| 582 | NFD_LOG_INFO("command result: unsupported verb: " << verb); |
| 583 | sendResponse(command, 501, "Unsupported command"); |
| 584 | } |
| 585 | |
| 586 | } |
| 587 | |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 588 | void |
Alexander Afanasyev | bbe3f0c | 2014-03-23 11:44:01 -0700 | [diff] [blame] | 589 | FaceManager::addCreatedFaceToForwarder(const shared_ptr<Face>& newFace) |
| 590 | { |
| 591 | m_faceTable.add(newFace); |
| 592 | |
| 593 | NFD_LOG_INFO("Created face " << newFace->getUri() << " ID " << newFace->getId()); |
| 594 | } |
| 595 | |
| 596 | void |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 597 | FaceManager::onCreated(const Name& requestName, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 598 | ControlParameters& parameters, |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 599 | const shared_ptr<Face>& newFace) |
| 600 | { |
Alexander Afanasyev | bbe3f0c | 2014-03-23 11:44:01 -0700 | [diff] [blame] | 601 | addCreatedFaceToForwarder(newFace); |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 602 | parameters.setFaceId(newFace->getId()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 603 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 604 | sendResponse(requestName, 200, "Success", parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | void |
| 608 | FaceManager::onConnectFailed(const Name& requestName, const std::string& reason) |
| 609 | { |
| 610 | NFD_LOG_INFO("Failed to create face: " << reason); |
| 611 | sendResponse(requestName, 400, "Failed to create face"); |
| 612 | } |
| 613 | |
| 614 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 615 | FaceManager::createFace(const Interest& request, |
| 616 | ControlParameters& parameters) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 617 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 618 | const Name& requestName = request.getName(); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 619 | FaceUri uri; |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 620 | if (!parameters.hasUri() || !uri.parse(parameters.getUri())) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 621 | { |
| 622 | sendResponse(requestName, 400, "Malformed command"); |
| 623 | return; |
| 624 | } |
| 625 | |
| 626 | FactoryMap::iterator factory = m_factories.find(uri.getScheme()); |
| 627 | if (factory == m_factories.end()) |
| 628 | { |
| 629 | sendResponse(requestName, 501, "Unsupported protocol"); |
| 630 | return; |
| 631 | } |
| 632 | |
| 633 | factory->second->createFace(uri, |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 634 | bind(&FaceManager::onCreated, this, requestName, parameters, _1), |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 635 | bind(&FaceManager::onConnectFailed, this, requestName, _1)); |
| 636 | } |
| 637 | |
| 638 | |
| 639 | void |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 640 | FaceManager::destroyFace(const Interest& request, |
| 641 | ControlParameters& parameters) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 642 | { |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 643 | const Name& requestName = request.getName(); |
| 644 | if (!parameters.hasFaceId()) |
| 645 | { |
| 646 | sendResponse(requestName, 400, "Malformed command"); |
| 647 | return; |
| 648 | } |
| 649 | |
| 650 | shared_ptr<Face> target = m_faceTable.get(parameters.getFaceId()); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 651 | if (static_cast<bool>(target)) |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 652 | { |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 653 | target->close(); |
| 654 | } |
Steve DiBenedetto | ba74905 | 2014-03-22 19:54:53 -0600 | [diff] [blame] | 655 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 656 | sendResponse(requestName, 200, "Success", parameters.wireEncode()); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 659 | void |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 660 | FaceManager::onAddFace(shared_ptr<Face> face) |
| 661 | { |
| 662 | ndn::nfd::FaceEventNotification faceCreated(ndn::nfd::FACE_EVENT_CREATED, |
| 663 | face->getId(), |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 664 | face->getUri().toString(), |
| 665 | (face->isLocal() ? ndn::nfd::FACE_IS_LOCAL : 0) | |
| 666 | (face->isOnDemand() ? ndn::nfd::FACE_IS_ON_DEMAND : 0)); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 667 | |
| 668 | m_notificationStream.postNotification(faceCreated); |
| 669 | } |
| 670 | |
| 671 | void |
| 672 | FaceManager::onRemoveFace(shared_ptr<Face> face) |
| 673 | { |
| 674 | ndn::nfd::FaceEventNotification faceDestroyed(ndn::nfd::FACE_EVENT_DESTROYED, |
| 675 | face->getId(), |
Alexander Afanasyev | 355c066 | 2014-03-20 18:08:17 -0700 | [diff] [blame] | 676 | face->getUri().toString(), |
| 677 | (face->isLocal() ? ndn::nfd::FACE_IS_LOCAL : 0) | |
| 678 | (face->isOnDemand() ? ndn::nfd::FACE_IS_ON_DEMAND : 0)); |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 679 | |
| 680 | m_notificationStream.postNotification(faceDestroyed); |
| 681 | } |
| 682 | |
| 683 | |
Steve DiBenedetto | 7564d97 | 2014-03-24 14:28:46 -0600 | [diff] [blame^] | 684 | bool |
| 685 | FaceManager::validateLocalControlParameters(const Interest& request, |
| 686 | ControlParameters& parameters, |
| 687 | shared_ptr<LocalFace>& outFace, |
| 688 | LocalControlFeature& outFeature) |
| 689 | { |
| 690 | if (!parameters.hasLocalControlFeature() || |
| 691 | (parameters.getLocalControlFeature() != LOCAL_CONTROL_FEATURE_INCOMING_FACE_ID && |
| 692 | parameters.getLocalControlFeature() != LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID)) |
| 693 | { |
| 694 | NFD_LOG_INFO("command result: malformed"); |
| 695 | sendResponse(request.getName(), 400, "Malformed command"); |
| 696 | return false; |
| 697 | } |
| 698 | |
| 699 | shared_ptr<Face> face = m_faceTable.get(request.getIncomingFaceId()); |
| 700 | |
| 701 | if (!static_cast<bool>(face)) |
| 702 | { |
| 703 | NFD_LOG_INFO("command result: faceid " << parameters.getFaceId() << " not found"); |
| 704 | sendResponse(request.getName(), 410, "Requested face not found"); |
| 705 | return false; |
| 706 | } |
| 707 | else if (!face->isLocal()) |
| 708 | { |
| 709 | NFD_LOG_INFO("command result: cannot enable local control on non-local faceid " << parameters.getFaceId()); |
| 710 | sendResponse(request.getName(), 412, "Requested face is non-local"); |
| 711 | return false; |
| 712 | } |
| 713 | |
| 714 | outFace = dynamic_pointer_cast<LocalFace>(face); |
| 715 | outFeature = static_cast<LocalControlFeature>(parameters.getLocalControlFeature()); |
| 716 | |
| 717 | return true; |
| 718 | } |
| 719 | |
| 720 | void |
| 721 | FaceManager::enableLocalControl(const Interest& request, |
| 722 | ControlParameters& parameters) |
| 723 | { |
| 724 | shared_ptr<LocalFace> face; |
| 725 | LocalControlFeature feature; |
| 726 | |
| 727 | if (validateLocalControlParameters(request, parameters, face, feature)) |
| 728 | { |
| 729 | face->setLocalControlHeaderFeature(feature, true); |
| 730 | sendResponse(request.getName(), 200, "Success", parameters.wireEncode()); |
| 731 | } |
| 732 | } |
| 733 | |
| 734 | void |
| 735 | FaceManager::disableLocalControl(const Interest& request, |
| 736 | ControlParameters& parameters) |
| 737 | { |
| 738 | shared_ptr<LocalFace> face; |
| 739 | LocalControlFeature feature; |
| 740 | |
| 741 | if (validateLocalControlParameters(request, parameters, face, feature)) |
| 742 | { |
| 743 | face->setLocalControlHeaderFeature(feature, false); |
| 744 | sendResponse(request.getName(), 200, "Success", parameters.wireEncode()); |
| 745 | } |
| 746 | } |
| 747 | |
Steve DiBenedetto | fbb40a8 | 2014-03-11 19:40:15 -0600 | [diff] [blame] | 748 | void |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 749 | FaceManager::listFaces(const Interest& request) |
| 750 | { |
| 751 | const Name& command = request.getName(); |
| 752 | const size_t commandNComps = command.size(); |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 753 | |
Steve DiBenedetto | 9f6c364 | 2014-03-10 17:02:27 -0600 | [diff] [blame] | 754 | if (commandNComps < LIST_COMMAND_NCOMPS || |
| 755 | !LIST_COMMAND_PREFIX.isPrefixOf(command)) |
| 756 | { |
| 757 | NFD_LOG_INFO("command result: malformed"); |
| 758 | sendResponse(command, 400, "Malformed command"); |
| 759 | return; |
| 760 | } |
| 761 | |
| 762 | m_statusPublisher.publish(); |
| 763 | } |
Steve DiBenedetto | abe9e97 | 2014-02-20 15:37:04 -0700 | [diff] [blame] | 764 | |
| 765 | } // namespace nfd |