blob: 1d9873ba421395a2b098f173bfc8acc154de32bd [file] [log] [blame]
Alexander Afanasyev3ecec502014-04-16 13:42:44 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi75306352018-02-01 21:59:44 +00002/*
3 * Copyright (c) 2014-2018, Regents of the University of California,
Junxiao Shi1e46be32015-01-08 20:18:05 -07004 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070010 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
Vince12e49462014-06-09 13:29:32 -050024 */
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070025
26#include "rib-manager.hpp"
Nick Gordon9fcf1232017-03-10 22:30:20 +000027
Junxiao Shi75306352018-02-01 21:59:44 +000028#include "core/fib-max-depth.hpp"
Alexander Afanasyev89cf5e02014-04-17 12:08:57 -070029#include "core/logger.hpp"
Alexander Afanasyev63108c42014-07-07 19:10:47 -070030#include "core/scheduler.hpp"
Nick Gordon9fcf1232017-03-10 22:30:20 +000031
Junxiao Shicbc8e942016-09-06 03:17:45 +000032#include <ndn-cxx/lp/tags.hpp>
Nick Gordon9fcf1232017-03-10 22:30:20 +000033#include <ndn-cxx/mgmt/nfd/control-command.hpp>
Nick Gordon9fcf1232017-03-10 22:30:20 +000034#include <ndn-cxx/mgmt/nfd/control-parameters.hpp>
Junxiao Shi3f21e582017-05-29 15:26:32 +000035#include <ndn-cxx/mgmt/nfd/control-response.hpp>
Junxiao Shi25c6ce42016-09-09 13:49:59 +000036#include <ndn-cxx/mgmt/nfd/face-status.hpp>
37#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070038
39namespace nfd {
40namespace rib {
41
Davide Pesaventoa3148082018-04-12 18:21:54 -040042NFD_LOG_INIT(RibManager);
Alexander Afanasyev89cf5e02014-04-17 12:08:57 -070043
Junxiao Shif4cfed12018-08-22 23:26:29 +000044static const std::string MGMT_MODULE_NAME = "rib";
45static const Name LOCALHOST_TOP_PREFIX = "/localhost/nfd";
46static const Name LOCALHOP_TOP_PREFIX = "/localhop/nfd";
47static const time::seconds ACTIVE_FACE_FETCH_INTERVAL = time::seconds(300);
Vince Lehman26b215c2014-08-17 15:00:41 -050048
Junxiao Shif4cfed12018-08-22 23:26:29 +000049RibManager::RibManager(Rib& rib, ndn::Face& face, ndn::nfd::Controller& nfdController, Dispatcher& dispatcher)
Junxiao Shifde3f542016-07-10 19:54:53 +000050 : ManagerBase(dispatcher, MGMT_MODULE_NAME)
Davide Pesavento9f8b10e2018-08-22 08:45:37 +000051 , m_rib(rib)
Junxiao Shif4cfed12018-08-22 23:26:29 +000052 , m_nfdController(nfdController)
53 , m_dispatcher(dispatcher)
Davide Pesavento9f8b10e2018-08-22 08:45:37 +000054 , m_faceMonitor(face)
55 , m_localhostValidator(face)
56 , m_localhopValidator(face)
Junxiao Shif4cfed12018-08-22 23:26:29 +000057 , m_isLocalhopEnabled(false)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070058{
Yanbiao Licf0db022016-01-29 00:54:25 -080059 registerCommandHandler<ndn::nfd::RibRegisterCommand>("register",
60 bind(&RibManager::registerEntry, this, _2, _3, _4, _5));
61 registerCommandHandler<ndn::nfd::RibUnregisterCommand>("unregister",
62 bind(&RibManager::unregisterEntry, this, _2, _3, _4, _5));
63
64 registerStatusDatasetHandler("list", bind(&RibManager::listEntries, this, _1, _2, _3));
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070065}
66
Junxiao Shif4cfed12018-08-22 23:26:29 +000067void
68RibManager::applyLocalhostConfig(const ConfigSection& section, const std::string& filename)
69{
70 m_localhostValidator.load(section, filename);
71}
72
73void
74RibManager::enableLocalhop(const ConfigSection& section, const std::string& filename)
75{
76 m_localhopValidator.load(section, filename);
77 m_isLocalhopEnabled = true;
78}
79
80void
81RibManager::disableLocalhop()
82{
83 m_isLocalhopEnabled = false;
84}
Vince Lehman26b215c2014-08-17 15:00:41 -050085
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070086void
87RibManager::registerWithNfd()
88{
Junxiao Shif4cfed12018-08-22 23:26:29 +000089 registerTopPrefix(LOCALHOST_TOP_PREFIX);
Alexander Afanasyevb3893c92014-05-15 01:49:54 -070090
Junxiao Shia3295742014-05-16 22:40:10 -070091 if (m_isLocalhopEnabled) {
Junxiao Shif4cfed12018-08-22 23:26:29 +000092 registerTopPrefix(LOCALHOP_TOP_PREFIX);
Junxiao Shia3295742014-05-16 22:40:10 -070093 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -070094
Alexander Afanasyev89cf5e02014-04-17 12:08:57 -070095 NFD_LOG_INFO("Start monitoring face create/destroy events");
Junxiao Shifbf78342015-01-23 14:46:41 -070096 m_faceMonitor.onNotification.connect(bind(&RibManager::onNotification, this, _1));
Junxiao Shi15b12e72014-08-09 19:56:24 -070097 m_faceMonitor.start();
Vince Lehmancd613c52014-07-30 14:34:49 -050098
Vince Lehman26b215c2014-08-17 15:00:41 -050099 scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700100}
101
102void
Eric Newberryecc45cb2016-11-08 19:57:12 +0000103RibManager::enableLocalFields()
Yanbiao Licf0db022016-01-29 00:54:25 -0800104{
Eric Newberryecc45cb2016-11-08 19:57:12 +0000105 m_nfdController.start<ndn::nfd::FaceUpdateCommand>(
Yanbiao Licf0db022016-01-29 00:54:25 -0800106 ControlParameters()
Eric Newberryecc45cb2016-11-08 19:57:12 +0000107 .setFlagBit(ndn::nfd::BIT_LOCAL_FIELDS_ENABLED, true),
108 bind(&RibManager::onEnableLocalFieldsSuccess, this),
109 bind(&RibManager::onEnableLocalFieldsError, this, _1));
Yanbiao Licf0db022016-01-29 00:54:25 -0800110}
111
112void
Yanbiao Licf0db022016-01-29 00:54:25 -0800113RibManager::onRibUpdateSuccess(const RibUpdate& update)
114{
115 NFD_LOG_DEBUG("RIB update succeeded for " << update);
116}
117
118void
119RibManager::onRibUpdateFailure(const RibUpdate& update, uint32_t code, const std::string& error)
120{
121 NFD_LOG_DEBUG("RIB update failed for " << update << " (code: " << code
122 << ", error: " << error << ")");
123
124 // Since the FIB rejected the update, clean up invalid routes
125 scheduleActiveFaceFetch(time::seconds(1));
126}
127
128void
Yanbiao Licf0db022016-01-29 00:54:25 -0800129RibManager::registerTopPrefix(const Name& topPrefix)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700130{
Yanbiao Licf0db022016-01-29 00:54:25 -0800131 // register entry to the FIB
132 m_nfdController.start<ndn::nfd::FibAddNextHopCommand>(
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400133 ControlParameters()
134 .setName(Name(topPrefix).append(MGMT_MODULE_NAME))
135 .setFaceId(0),
136 [=] (const auto& res) { this->onCommandPrefixAddNextHopSuccess(topPrefix, res); },
137 [=] (const auto& res) { this->onCommandPrefixAddNextHopError(topPrefix, res); });
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700138
Yanbiao Licf0db022016-01-29 00:54:25 -0800139 // add top prefix to the dispatcher
Junxiao Shif4cfed12018-08-22 23:26:29 +0000140 m_dispatcher.addTopPrefix(topPrefix, false);
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700141}
142
143void
Yanbiao Licf0db022016-01-29 00:54:25 -0800144RibManager::registerEntry(const Name& topPrefix, const Interest& interest,
145 ControlParameters parameters,
146 const ndn::mgmt::CommandContinuation& done)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700147{
Junxiao Shi75306352018-02-01 21:59:44 +0000148 if (parameters.getName().size() > FIB_MAX_DEPTH) {
149 done(ControlResponse(414, "Route prefix cannot exceed " + ndn::to_string(FIB_MAX_DEPTH) +
150 " components"));
151 return;
152 }
153
Yanbiao Licf0db022016-01-29 00:54:25 -0800154 setFaceForSelfRegistration(interest, parameters);
Vince Lehman76c751c2014-11-18 17:36:38 -0600155
156 // Respond since command is valid and authorized
Yanbiao Licf0db022016-01-29 00:54:25 -0800157 done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
Alexander Afanasyevfb1c8082014-07-17 15:16:15 -0700158
Vince Lehman218be0a2015-01-15 17:25:20 -0600159 Route route;
160 route.faceId = parameters.getFaceId();
161 route.origin = parameters.getOrigin();
162 route.cost = parameters.getCost();
163 route.flags = parameters.getFlags();
Syed Obaid3313a372014-07-01 01:31:33 -0500164
Alexander Afanasyevf67cf082014-07-18 16:47:29 -0700165 if (parameters.hasExpirationPeriod() &&
Nick Gordon9fcf1232017-03-10 22:30:20 +0000166 parameters.getExpirationPeriod() != time::milliseconds::max()) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600167 route.expires = time::steady_clock::now() + parameters.getExpirationPeriod();
Syed Obaid3313a372014-07-01 01:31:33 -0500168
Vince Lehman76c751c2014-11-18 17:36:38 -0600169 // Schedule a new event, the old one will be cancelled during rib insertion.
170 scheduler::EventId eventId = scheduler::schedule(parameters.getExpirationPeriod(),
Yanbiao Licf0db022016-01-29 00:54:25 -0800171 bind(&Rib::onRouteExpiration, &m_rib, parameters.getName(), route));
Syed Obaid3313a372014-07-01 01:31:33 -0500172
Junxiao Shi3f21e582017-05-29 15:26:32 +0000173 NFD_LOG_TRACE("Scheduled unregistration at: " << *route.expires <<
Vince Lehman76c751c2014-11-18 17:36:38 -0600174 " with EventId: " << eventId);
175
176 // Set the NewEventId of this entry
177 route.setExpirationEvent(eventId);
178 }
179 else {
Davide Pesavento87fc0f82018-04-11 23:43:51 -0400180 route.expires = nullopt;
Vince Lehman76c751c2014-11-18 17:36:38 -0600181 }
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700182
Vince Lehmanff8b3972015-02-20 16:51:21 -0600183 NFD_LOG_INFO("Adding route " << parameters.getName() << " nexthop=" << route.faceId
184 << " origin=" << route.origin
185 << " cost=" << route.cost);
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700186
Vince Lehman76c751c2014-11-18 17:36:38 -0600187 RibUpdate update;
188 update.setAction(RibUpdate::REGISTER)
189 .setName(parameters.getName())
190 .setRoute(route);
191
Yanbiao Licf0db022016-01-29 00:54:25 -0800192 m_rib.beginApplyUpdate(update,
Junxiao Shib2600172016-07-11 08:53:53 +0000193 bind(&RibManager::onRibUpdateSuccess, this, update),
194 bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
Vince Lehman76c751c2014-11-18 17:36:38 -0600195
Vince Lehman218be0a2015-01-15 17:25:20 -0600196 m_registeredFaces.insert(route.faceId);
Vince Lehman281ded72014-08-21 12:17:08 -0500197}
198
199void
Yanbiao Licf0db022016-01-29 00:54:25 -0800200RibManager::unregisterEntry(const Name& topPrefix, const Interest& interest,
201 ControlParameters parameters,
202 const ndn::mgmt::CommandContinuation& done)
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700203{
Yanbiao Licf0db022016-01-29 00:54:25 -0800204 setFaceForSelfRegistration(interest, parameters);
Vince Lehman76c751c2014-11-18 17:36:38 -0600205
206 // Respond since command is valid and authorized
Yanbiao Licf0db022016-01-29 00:54:25 -0800207 done(ControlResponse(200, "Success").setBody(parameters.wireEncode()));
Alexander Afanasyevfb1c8082014-07-17 15:16:15 -0700208
Vince Lehman218be0a2015-01-15 17:25:20 -0600209 Route route;
210 route.faceId = parameters.getFaceId();
211 route.origin = parameters.getOrigin();
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700212
Vince Lehmanff8b3972015-02-20 16:51:21 -0600213 NFD_LOG_INFO("Removing route " << parameters.getName() << " nexthop=" << route.faceId
214 << " origin=" << route.origin);
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700215
Vince Lehman76c751c2014-11-18 17:36:38 -0600216 RibUpdate update;
217 update.setAction(RibUpdate::UNREGISTER)
218 .setName(parameters.getName())
219 .setRoute(route);
Vince Lehman4387e782014-06-19 16:57:45 -0500220
Yanbiao Licf0db022016-01-29 00:54:25 -0800221 m_rib.beginApplyUpdate(update,
Junxiao Shib2600172016-07-11 08:53:53 +0000222 bind(&RibManager::onRibUpdateSuccess, this, update),
223 bind(&RibManager::onRibUpdateFailure, this, update, _1, _2));
Alexander Afanasyev20d31442014-04-19 17:00:53 -0700224}
225
226void
Yanbiao Licf0db022016-01-29 00:54:25 -0800227RibManager::listEntries(const Name& topPrefix, const Interest& interest,
228 ndn::mgmt::StatusDatasetContext& context)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700229{
Junxiao Shi3f21e582017-05-29 15:26:32 +0000230 auto now = time::steady_clock::now();
231 for (const auto& kv : m_rib) {
232 const RibEntry& entry = *kv.second;
233 ndn::nfd::RibEntry item;
234 item.setName(entry.getName());
235 for (const Route& route : entry.getRoutes()) {
236 ndn::nfd::Route r;
237 r.setFaceId(route.faceId);
238 r.setOrigin(route.origin);
239 r.setCost(route.cost);
240 r.setFlags(route.flags);
241 if (route.expires) {
242 r.setExpirationPeriod(time::duration_cast<time::milliseconds>(*route.expires - now));
243 }
244 item.addRoute(r);
245 }
246 context.append(item.wireEncode());
Vince Lehman76c751c2014-11-18 17:36:38 -0600247 }
Yanbiao Licf0db022016-01-29 00:54:25 -0800248 context.end();
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700249}
250
251void
Yanbiao Licf0db022016-01-29 00:54:25 -0800252RibManager::setFaceForSelfRegistration(const Interest& request, ControlParameters& parameters)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700253{
Yanbiao Licf0db022016-01-29 00:54:25 -0800254 bool isSelfRegistration = (parameters.getFaceId() == 0);
255 if (isSelfRegistration) {
256 shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = request.getTag<lp::IncomingFaceIdTag>();
257 // NDNLPv2 says "application MUST be prepared to receive a packet without IncomingFaceId field",
258 // but it's fine to assert IncomingFaceId is available, because InternalFace lives inside NFD
259 // and is initialized synchronously with IncomingFaceId field enabled.
260 BOOST_ASSERT(incomingFaceIdTag != nullptr);
261 parameters.setFaceId(*incomingFaceIdTag);
Vince Lehman76c751c2014-11-18 17:36:38 -0600262 }
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700263}
264
Junxiao Shi21738402016-08-19 19:48:00 +0000265ndn::mgmt::Authorization
266RibManager::makeAuthorization(const std::string& verb)
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700267{
Junxiao Shi21738402016-08-19 19:48:00 +0000268 return [this] (const Name& prefix, const Interest& interest,
269 const ndn::mgmt::ControlParameters* params,
270 const ndn::mgmt::AcceptContinuation& accept,
271 const ndn::mgmt::RejectContinuation& reject) {
272 BOOST_ASSERT(params != nullptr);
273 BOOST_ASSERT(typeid(*params) == typeid(ndn::nfd::ControlParameters));
Junxiao Shif4cfed12018-08-22 23:26:29 +0000274 BOOST_ASSERT(prefix == LOCALHOST_TOP_PREFIX || prefix == LOCALHOP_TOP_PREFIX);
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700275
Junxiao Shif4cfed12018-08-22 23:26:29 +0000276 ndn::ValidatorConfig& validator = prefix == LOCALHOST_TOP_PREFIX ?
Junxiao Shi21738402016-08-19 19:48:00 +0000277 m_localhostValidator : m_localhopValidator;
278 validator.validate(interest,
279 bind([&interest, this, accept] { extractRequester(interest, accept); }),
280 bind([reject] { reject(ndn::mgmt::RejectReply::STATUS403); }));
281 };
Vince Lehman26b215c2014-08-17 15:00:41 -0500282}
283
284void
Vince Lehmancd613c52014-07-30 14:34:49 -0500285RibManager::fetchActiveFaces()
286{
287 NFD_LOG_DEBUG("Fetching active faces");
288
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700289 m_nfdController.fetch<ndn::nfd::FaceDataset>(
290 bind(&RibManager::removeInvalidFaces, this, _1),
291 bind(&RibManager::onFetchActiveFacesFailure, this, _1, _2),
292 ndn::nfd::CommandOptions());
Vince Lehmancd613c52014-07-30 14:34:49 -0500293}
294
295void
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700296RibManager::onFetchActiveFacesFailure(uint32_t code, const std::string& reason)
Vince Lehmancd613c52014-07-30 14:34:49 -0500297{
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700298 NFD_LOG_DEBUG("Face Status Dataset request failure " << code << " " << reason);
Yanbiao Licf0db022016-01-29 00:54:25 -0800299 scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
300}
301
302void
303RibManager::onFaceDestroyedEvent(uint64_t faceId)
304{
305 m_rib.beginRemoveFace(faceId);
306 m_registeredFaces.erase(faceId);
307}
308
309void
310RibManager::scheduleActiveFaceFetch(const time::seconds& timeToWait)
311{
Davide Pesaventod396b612017-02-20 22:11:50 -0500312 m_activeFaceFetchEvent = scheduler::schedule(timeToWait, [this] { this->fetchActiveFaces(); });
Yanbiao Licf0db022016-01-29 00:54:25 -0800313}
314
315void
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700316RibManager::removeInvalidFaces(const std::vector<ndn::nfd::FaceStatus>& activeFaces)
Vince Lehmancd613c52014-07-30 14:34:49 -0500317{
Vince Lehman26b215c2014-08-17 15:00:41 -0500318 NFD_LOG_DEBUG("Checking for invalid face registrations");
Vince Lehmancd613c52014-07-30 14:34:49 -0500319
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700320 FaceIdSet activeFaceIds;
Davide Pesaventod396b612017-02-20 22:11:50 -0500321 for (const auto& faceStatus : activeFaces) {
322 activeFaceIds.insert(faceStatus.getFaceId());
Junxiao Shi78926c92015-02-28 22:56:06 -0700323 }
324
Vince Lehman26b215c2014-08-17 15:00:41 -0500325 // Look for face IDs that were registered but not active to find missed
326 // face destroyed events
Davide Pesaventod396b612017-02-20 22:11:50 -0500327 for (auto faceId : m_registeredFaces) {
Weiwei Liu6e21cdb2016-09-29 15:16:23 -0700328 if (activeFaceIds.count(faceId) == 0) {
Vince Lehman76c751c2014-11-18 17:36:38 -0600329 NFD_LOG_DEBUG("Removing invalid face ID: " << faceId);
Davide Pesaventod396b612017-02-20 22:11:50 -0500330 scheduler::schedule(time::seconds(0), [this, faceId] { this->onFaceDestroyedEvent(faceId); });
Vince Lehman26b215c2014-08-17 15:00:41 -0500331 }
Vince Lehman76c751c2014-11-18 17:36:38 -0600332 }
Vince Lehman26b215c2014-08-17 15:00:41 -0500333
334 // Reschedule the check for future clean up
335 scheduleActiveFaceFetch(ACTIVE_FACE_FETCH_INTERVAL);
Vince Lehmancd613c52014-07-30 14:34:49 -0500336}
337
338void
Davide Pesaventod396b612017-02-20 22:11:50 -0500339RibManager::onNotification(const ndn::nfd::FaceEventNotification& notification)
Vince Lehmancd613c52014-07-30 14:34:49 -0500340{
Yanbiao Licf0db022016-01-29 00:54:25 -0800341 NFD_LOG_TRACE("onNotification: " << notification);
342
343 if (notification.getKind() == ndn::nfd::FACE_EVENT_DESTROYED) {
344 NFD_LOG_DEBUG("Received notification for destroyed faceId: " << notification.getFaceId());
345
346 scheduler::schedule(time::seconds(0),
347 bind(&RibManager::onFaceDestroyedEvent, this, notification.getFaceId()));
348 }
349}
350
351void
Junxiao Shib2600172016-07-11 08:53:53 +0000352RibManager::onCommandPrefixAddNextHopSuccess(const Name& prefix,
353 const ndn::nfd::ControlParameters& result)
Yanbiao Licf0db022016-01-29 00:54:25 -0800354{
355 NFD_LOG_DEBUG("Successfully registered " + prefix.toUri() + " with NFD");
356
357 // Routes must be inserted into the RIB so route flags can be applied
358 Route route;
359 route.faceId = result.getFaceId();
360 route.origin = ndn::nfd::ROUTE_ORIGIN_APP;
Davide Pesavento87fc0f82018-04-11 23:43:51 -0400361 route.expires = nullopt;
Yanbiao Licf0db022016-01-29 00:54:25 -0800362 route.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
363
364 m_rib.insert(prefix, route);
365
366 m_registeredFaces.insert(route.faceId);
367}
368
369void
Junxiao Shi29b41282016-08-22 03:47:02 +0000370RibManager::onCommandPrefixAddNextHopError(const Name& name,
371 const ndn::nfd::ControlResponse& response)
Yanbiao Licf0db022016-01-29 00:54:25 -0800372{
Junxiao Shi29b41282016-08-22 03:47:02 +0000373 BOOST_THROW_EXCEPTION(Error("Error in setting interest filter (" + name.toUri() +
374 "): " + response.getText()));
Yanbiao Licf0db022016-01-29 00:54:25 -0800375}
376
377void
Eric Newberryecc45cb2016-11-08 19:57:12 +0000378RibManager::onEnableLocalFieldsSuccess()
Yanbiao Licf0db022016-01-29 00:54:25 -0800379{
Eric Newberryecc45cb2016-11-08 19:57:12 +0000380 NFD_LOG_DEBUG("Local fields enabled");
Yanbiao Licf0db022016-01-29 00:54:25 -0800381}
382
383void
Eric Newberryecc45cb2016-11-08 19:57:12 +0000384RibManager::onEnableLocalFieldsError(const ndn::nfd::ControlResponse& response)
Yanbiao Licf0db022016-01-29 00:54:25 -0800385{
Eric Newberryecc45cb2016-11-08 19:57:12 +0000386 BOOST_THROW_EXCEPTION(Error("Couldn't enable local fields (code: " +
Davide Pesaventoe4b22382018-06-10 14:37:24 -0400387 to_string(response.getCode()) + ", info: " + response.getText() + ")"));
Vince Lehmancd613c52014-07-30 14:34:49 -0500388}
389
Alexander Afanasyev3ecec502014-04-16 13:42:44 -0700390} // namespace rib
391} // namespace nfd