blob: 1460dbb0bd6f74b1e794b9036e2605fc42d3aeba [file] [log] [blame]
akmhoque3d06e792014-05-27 16:23:20 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014 University of Memphis,
4 * Regents of the University of California
5 *
6 * This file is part of NLSR (Named-data Link State Routing).
7 * See AUTHORS.md for complete list of NLSR authors and contributors.
8 *
9 * NLSR is free software: you can redistribute it and/or modify it under the terms
10 * of the GNU General Public License as published by the Free Software Foundation,
11 * either version 3 of the License, or (at your option) any later version.
12 *
13 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
21 *
22 **/
akmhoque53353462014-04-22 08:43:45 -050023#include <list>
akmhoquefdbddb12014-05-02 18:35:19 -050024#include <cmath>
akmhoque157b0a42014-05-13 00:26:37 -050025#include <ndn-cxx/common.hpp>
akmhoquec8a10f72014-04-25 18:42:55 -050026
27#include "nlsr.hpp"
akmhoquec8a10f72014-04-25 18:42:55 -050028#include "nexthop-list.hpp"
akmhoque157b0a42014-05-13 00:26:37 -050029#include "face-map.hpp"
akmhoquefdbddb12014-05-02 18:35:19 -050030#include "fib.hpp"
akmhoque674b0b12014-05-20 14:33:28 -050031#include "logger.hpp"
akmhoquec8a10f72014-04-25 18:42:55 -050032
akmhoque53353462014-04-22 08:43:45 -050033
34
35namespace nlsr {
36
akmhoque674b0b12014-05-20 14:33:28 -050037INIT_LOGGER("Fib");
38
akmhoque53353462014-04-22 08:43:45 -050039using namespace std;
40using namespace ndn;
41
42static bool
akmhoque31d1d4b2014-05-05 22:08:14 -050043fibEntryNameCompare(const FibEntry& fibEntry, const ndn::Name& name)
akmhoque53353462014-04-22 08:43:45 -050044{
akmhoquefdbddb12014-05-02 18:35:19 -050045 return fibEntry.getName() == name ;
akmhoque53353462014-04-22 08:43:45 -050046}
47
48void
akmhoque31d1d4b2014-05-05 22:08:14 -050049Fib::cancelScheduledExpiringEvent(EventId eid)
akmhoque53353462014-04-22 08:43:45 -050050{
akmhoque31d1d4b2014-05-05 22:08:14 -050051 m_nlsr.getScheduler().cancelEvent(eid);
akmhoque53353462014-04-22 08:43:45 -050052}
53
54
55ndn::EventId
akmhoque31d1d4b2014-05-05 22:08:14 -050056Fib::scheduleEntryRefreshing(const ndn::Name& name, int32_t feSeqNum,
akmhoquec7a79b22014-05-26 08:06:19 -050057 const ndn::time::seconds& expTime)
akmhoque53353462014-04-22 08:43:45 -050058{
akmhoquefdbddb12014-05-02 18:35:19 -050059 std::cout << "Fib::scheduleEntryRefreshing Called" << std::endl;
60 std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
akmhoque674b0b12014-05-20 14:33:28 -050061 _LOG_DEBUG("Fib::scheduleEntryRefreshing Called");
62 _LOG_DEBUG("Name: " << name << " Seq Num: " << feSeqNum);
akmhoquec7a79b22014-05-26 08:06:19 -050063 return m_nlsr.getScheduler().scheduleEvent(expTime,
akmhoque31d1d4b2014-05-05 22:08:14 -050064 ndn::bind(&Fib::refreshEntry, this,
65 name, feSeqNum));
akmhoque53353462014-04-22 08:43:45 -050066}
67
68void
akmhoque31d1d4b2014-05-05 22:08:14 -050069Fib::refreshEntry(const ndn::Name& name, int32_t feSeqNum)
akmhoque53353462014-04-22 08:43:45 -050070{
akmhoquefdbddb12014-05-02 18:35:19 -050071 std::cout << "Fib::refreshEntry Called" << std::endl;
72 std::cout << "Name: " << name << " Seq Num: " << feSeqNum << std::endl;
73 std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
74 m_table.end(),
75 bind(&fibEntryNameCompare, _1, name));
akmhoque157b0a42014-05-13 00:26:37 -050076 if (it != m_table.end()) {
akmhoquefdbddb12014-05-02 18:35:19 -050077 std::cout << "Entry found with Seq Num: " << feSeqNum << std::endl;
akmhoque157b0a42014-05-13 00:26:37 -050078 if (it->getSeqNo() == feSeqNum) {
akmhoquefdbddb12014-05-02 18:35:19 -050079 std::cout << "Refreshing the FIB entry" << std::endl;
akmhoque674b0b12014-05-20 14:33:28 -050080 _LOG_DEBUG("Refreshing the FIB entry. Name: " << name);
akmhoquefdbddb12014-05-02 18:35:19 -050081 for (std::list<NextHop>::iterator nhit =
akmhoque31d1d4b2014-05-05 22:08:14 -050082 (*it).getNexthopList().getNextHops().begin();
akmhoque157b0a42014-05-13 00:26:37 -050083 nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
akmhoquefdbddb12014-05-02 18:35:19 -050084 // add entry to NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -050085 registerPrefix(it->getName(), nhit->getConnectingFaceUri(),
86 std::ceil(nhit->getRouteCost()), m_refreshTime);
akmhoquefdbddb12014-05-02 18:35:19 -050087 }
akmhoquefdbddb12014-05-02 18:35:19 -050088 // increase sequence number and schedule refresh again
89 it->setSeqNo(feSeqNum + 1);
akmhoque31d1d4b2014-05-05 22:08:14 -050090 it->setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
91 it->getSeqNo(),
akmhoquec7a79b22014-05-26 08:06:19 -050092 ndn::time::seconds(m_refreshTime)));
akmhoquefdbddb12014-05-02 18:35:19 -050093 }
94 }
akmhoque53353462014-04-22 08:43:45 -050095}
96
97void
akmhoque31d1d4b2014-05-05 22:08:14 -050098Fib::remove(const ndn::Name& name)
akmhoque53353462014-04-22 08:43:45 -050099{
akmhoque674b0b12014-05-20 14:33:28 -0500100 _LOG_DEBUG("Fib::remove called");
akmhoque53353462014-04-22 08:43:45 -0500101 std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
akmhoquefdbddb12014-05-02 18:35:19 -0500102 m_table.end(),
akmhoquec8a10f72014-04-25 18:42:55 -0500103 bind(&fibEntryNameCompare, _1, name));
akmhoque157b0a42014-05-13 00:26:37 -0500104 if (it != m_table.end()) {
akmhoque53353462014-04-22 08:43:45 -0500105 for (std::list<NextHop>::iterator nhit =
akmhoquefdbddb12014-05-02 18:35:19 -0500106 (*it).getNexthopList().getNextHops().begin();
akmhoque157b0a42014-05-13 00:26:37 -0500107 nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
akmhoque53353462014-04-22 08:43:45 -0500108 //remove entry from NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -0500109 if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName())) {
110 unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500111 }
112 else
113 {
akmhoque157b0a42014-05-13 00:26:37 -0500114 if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFaceUri() !=
115 nhit->getConnectingFaceUri()) {
116 unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500117 }
118 }
akmhoque53353462014-04-22 08:43:45 -0500119 }
akmhoquefdbddb12014-05-02 18:35:19 -0500120 std::cout << "Cancellling Scheduled event" << std::endl;
121 std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
akmhoque674b0b12014-05-20 14:33:28 -0500122 _LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
akmhoque31d1d4b2014-05-05 22:08:14 -0500123 cancelScheduledExpiringEvent((*it).getExpiringEventId());
akmhoque53353462014-04-22 08:43:45 -0500124 m_table.erase(it);
125 }
126}
127
128
129void
akmhoque31d1d4b2014-05-05 22:08:14 -0500130Fib::update(const ndn::Name& name, NexthopList& nextHopList)
akmhoque53353462014-04-22 08:43:45 -0500131{
132 std::cout << "Fib::updateFib Called" << std::endl;
akmhoque674b0b12014-05-20 14:33:28 -0500133 _LOG_DEBUG("Fib::updateFib Called");
akmhoque53353462014-04-22 08:43:45 -0500134 int startFace = 0;
135 int endFace = getNumberOfFacesForName(nextHopList,
akmhoque31d1d4b2014-05-05 22:08:14 -0500136 m_nlsr.getConfParameter().getMaxFacesPerPrefix());
akmhoque53353462014-04-22 08:43:45 -0500137 std::list<FibEntry>::iterator it = std::find_if(m_table.begin(),
138 m_table.end(),
139 bind(&fibEntryNameCompare, _1, name));
akmhoque157b0a42014-05-13 00:26:37 -0500140 if (it == m_table.end()) {
141 if (nextHopList.getSize() > 0) {
akmhoque53353462014-04-22 08:43:45 -0500142 nextHopList.sort();
143 FibEntry newEntry(name);
akmhoquefdbddb12014-05-02 18:35:19 -0500144 std::list<NextHop> nhl = nextHopList.getNextHops();
akmhoque53353462014-04-22 08:43:45 -0500145 std::list<NextHop>::iterator nhit = nhl.begin();
akmhoque157b0a42014-05-13 00:26:37 -0500146 for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++) {
akmhoquefdbddb12014-05-02 18:35:19 -0500147 newEntry.getNexthopList().addNextHop((*nhit));
akmhoque53353462014-04-22 08:43:45 -0500148 //Add entry to NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -0500149 registerPrefix(name, nhit->getConnectingFaceUri(),
150 std::ceil(nhit->getRouteCost()), m_refreshTime);
akmhoque53353462014-04-22 08:43:45 -0500151 }
akmhoquefdbddb12014-05-02 18:35:19 -0500152 newEntry.getNexthopList().sort();
akmhoquec7a79b22014-05-26 08:06:19 -0500153 ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
154 expirationTimePoint = expirationTimePoint + ndn::time::seconds(m_refreshTime);
155 newEntry.setExpirationTimePoint(expirationTimePoint);
akmhoque53353462014-04-22 08:43:45 -0500156 newEntry.setSeqNo(1);
akmhoquec7a79b22014-05-26 08:06:19 -0500157 newEntry.setExpiringEventId(scheduleEntryRefreshing(name , 1,
158 ndn::time::seconds(m_refreshTime)));
akmhoque53353462014-04-22 08:43:45 -0500159 m_table.push_back(newEntry);
160 }
161 }
akmhoque157b0a42014-05-13 00:26:37 -0500162 else {
akmhoque53353462014-04-22 08:43:45 -0500163 std::cout << "Old FIB Entry" << std::endl;
akmhoque157b0a42014-05-13 00:26:37 -0500164 if (nextHopList.getSize() > 0) {
akmhoque53353462014-04-22 08:43:45 -0500165 nextHopList.sort();
akmhoque157b0a42014-05-13 00:26:37 -0500166 if (!it->isEqualNextHops(nextHopList)) {
akmhoquefdbddb12014-05-02 18:35:19 -0500167 std::list<NextHop> nhl = nextHopList.getNextHops();
akmhoque53353462014-04-22 08:43:45 -0500168 std::list<NextHop>::iterator nhit = nhl.begin();
169 // Add first Entry to NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -0500170 registerPrefix(name, nhit->getConnectingFaceUri(),
171 std::ceil(nhit->getRouteCost()), m_refreshTime);
172 removeHop(it->getNexthopList(), nhit->getConnectingFaceUri(), name);
akmhoquefdbddb12014-05-02 18:35:19 -0500173 it->getNexthopList().reset();
174 it->getNexthopList().addNextHop((*nhit));
akmhoque53353462014-04-22 08:43:45 -0500175 ++startFace;
176 ++nhit;
akmhoque157b0a42014-05-13 00:26:37 -0500177 for (int i = startFace; i < endFace && nhit != nhl.end(); ++nhit, i++) {
akmhoquefdbddb12014-05-02 18:35:19 -0500178 it->getNexthopList().addNextHop((*nhit));
akmhoque53353462014-04-22 08:43:45 -0500179 //Add Entry to NDN_FIB
akmhoque157b0a42014-05-13 00:26:37 -0500180 registerPrefix(name, nhit->getConnectingFaceUri(),
181 std::ceil(nhit->getRouteCost()), m_refreshTime);
akmhoque53353462014-04-22 08:43:45 -0500182 }
183 }
akmhoquec7a79b22014-05-26 08:06:19 -0500184 ndn::time::system_clock::TimePoint expirationTimePoint = ndn::time::system_clock::now();
185 expirationTimePoint = expirationTimePoint + ndn::time::seconds(m_refreshTime);
186 it->setExpirationTimePoint(expirationTimePoint);
akmhoquefdbddb12014-05-02 18:35:19 -0500187 std::cout << "Cancellling Scheduled event" << std::endl;
188 std::cout << "Name: " << name << "Seq num: " << it->getSeqNo() << std::endl;
akmhoque674b0b12014-05-20 14:33:28 -0500189 _LOG_DEBUG("Cancelling Scheduled event. Name: " << name);
akmhoque31d1d4b2014-05-05 22:08:14 -0500190 cancelScheduledExpiringEvent(it->getExpiringEventId());
akmhoque53353462014-04-22 08:43:45 -0500191 it->setSeqNo(it->getSeqNo() + 1);
akmhoque31d1d4b2014-05-05 22:08:14 -0500192 (*it).setExpiringEventId(scheduleEntryRefreshing(it->getName() ,
akmhoquec7a79b22014-05-26 08:06:19 -0500193 it->getSeqNo(),
194 ndn::time::seconds(m_refreshTime)));
akmhoque53353462014-04-22 08:43:45 -0500195 }
akmhoque157b0a42014-05-13 00:26:37 -0500196 else {
akmhoque31d1d4b2014-05-05 22:08:14 -0500197 remove(name);
akmhoque53353462014-04-22 08:43:45 -0500198 }
199 }
200}
201
202
203
204void
akmhoque31d1d4b2014-05-05 22:08:14 -0500205Fib::clean()
akmhoque53353462014-04-22 08:43:45 -0500206{
akmhoque674b0b12014-05-20 14:33:28 -0500207 _LOG_DEBUG("Fib::clean called");
akmhoque53353462014-04-22 08:43:45 -0500208 for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
akmhoque157b0a42014-05-13 00:26:37 -0500209 ++it) {
akmhoquefdbddb12014-05-02 18:35:19 -0500210 std::cout << "Cancellling Scheduled event" << std::endl;
akmhoque31d1d4b2014-05-05 22:08:14 -0500211 std::cout << "Name: " << it->getName() << "Seq num: " << it->getSeqNo() <<
212 std::endl;
akmhoque674b0b12014-05-20 14:33:28 -0500213 _LOG_DEBUG("Cancelling Scheduled event. Name: " << it->getName());
akmhoque31d1d4b2014-05-05 22:08:14 -0500214 cancelScheduledExpiringEvent((*it).getExpiringEventId());
akmhoque53353462014-04-22 08:43:45 -0500215 for (std::list<NextHop>::iterator nhit =
akmhoquefdbddb12014-05-02 18:35:19 -0500216 (*it).getNexthopList().getNextHops().begin();
akmhoque157b0a42014-05-13 00:26:37 -0500217 nhit != (*it).getNexthopList().getNextHops().end(); nhit++) {
akmhoque53353462014-04-22 08:43:45 -0500218 //Remove entry from NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -0500219 if (!m_nlsr.getAdjacencyList().isNeighbor(it->getName())) {
220 unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500221 }
akmhoque157b0a42014-05-13 00:26:37 -0500222 else {
223 if (m_nlsr.getAdjacencyList().getAdjacent(it->getName()).getConnectingFaceUri() !=
224 nhit->getConnectingFaceUri()) {
225 unregisterPrefix(it->getName(), nhit->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500226 }
227 }
akmhoque53353462014-04-22 08:43:45 -0500228 }
229 }
akmhoque157b0a42014-05-13 00:26:37 -0500230 if (m_table.size() > 0) {
akmhoque53353462014-04-22 08:43:45 -0500231 m_table.clear();
232 }
233}
234
235int
akmhoque31d1d4b2014-05-05 22:08:14 -0500236Fib::getNumberOfFacesForName(NexthopList& nextHopList,
237 uint32_t maxFacesPerPrefix)
akmhoque53353462014-04-22 08:43:45 -0500238{
239 int endFace = 0;
akmhoque157b0a42014-05-13 00:26:37 -0500240 if ((maxFacesPerPrefix == 0) || (nextHopList.getSize() <= maxFacesPerPrefix)) {
akmhoque53353462014-04-22 08:43:45 -0500241 return nextHopList.getSize();
242 }
akmhoque157b0a42014-05-13 00:26:37 -0500243 else {
akmhoque53353462014-04-22 08:43:45 -0500244 return maxFacesPerPrefix;
245 }
246 return endFace;
247}
248
249void
akmhoque157b0a42014-05-13 00:26:37 -0500250Fib::removeHop(NexthopList& nl, const std::string& doNotRemoveHopFaceUri,
akmhoque31d1d4b2014-05-05 22:08:14 -0500251 const ndn::Name& name)
akmhoque53353462014-04-22 08:43:45 -0500252{
akmhoquefdbddb12014-05-02 18:35:19 -0500253 for (std::list<NextHop>::iterator it = nl.getNextHops().begin();
akmhoque157b0a42014-05-13 00:26:37 -0500254 it != nl.getNextHops().end(); ++it) {
255 if (it->getConnectingFaceUri() != doNotRemoveHopFaceUri) {
akmhoque53353462014-04-22 08:43:45 -0500256 //Remove FIB Entry from NDN-FIB
akmhoque157b0a42014-05-13 00:26:37 -0500257 if (!m_nlsr.getAdjacencyList().isNeighbor(name)) {
258 unregisterPrefix(name, it->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500259 }
akmhoque157b0a42014-05-13 00:26:37 -0500260 else {
261 if (m_nlsr.getAdjacencyList().getAdjacent(name).getConnectingFaceUri() !=
262 it->getConnectingFaceUri()) {
263 unregisterPrefix(name, it->getConnectingFaceUri());
akmhoquefdbddb12014-05-02 18:35:19 -0500264 }
265 }
akmhoque53353462014-04-22 08:43:45 -0500266 }
267 }
268}
269
270void
akmhoque157b0a42014-05-13 00:26:37 -0500271Fib::registerPrefix(const ndn::Name& namePrefix, const std::string& faceUri,
272 uint64_t faceCost, uint64_t timeout)
273{
274 ndn::nfd::ControlParameters faceParameters;
275 faceParameters
276 .setUri(faceUri);
277
278 m_controller.start<ndn::nfd::FaceCreateCommand>(faceParameters,
279 ndn::bind(&Fib::registerPrefixInNfd, this,_1,
280 namePrefix, faceCost, timeout),
281 ndn::bind(&Fib::onFailure, this, _1, _2,
282 "Failed in name registration"));
283
284}
285
286void
287Fib::registerPrefixInNfd(const ndn::nfd::ControlParameters& faceCreateResult,
288 const ndn::Name& namePrefix, uint64_t faceCost, uint64_t timeout)
akmhoquefdbddb12014-05-02 18:35:19 -0500289{
290 ndn::nfd::ControlParameters controlParameters;
291 controlParameters
akmhoque157b0a42014-05-13 00:26:37 -0500292 .setName(namePrefix)
293 .setFaceId(faceCreateResult.getFaceId())
294 .setCost(faceCost)
295 .setExpirationPeriod(ndn::time::milliseconds(timeout * 1000))
296 .setOrigin(128);
akmhoquefdbddb12014-05-02 18:35:19 -0500297 m_controller.start<ndn::nfd::RibRegisterCommand>(controlParameters,
akmhoque157b0a42014-05-13 00:26:37 -0500298 ndn::bind(&Fib::onRegistration, this, _1,
299 "Successful in name registration",
300 faceCreateResult.getUri()),
akmhoquefdbddb12014-05-02 18:35:19 -0500301 ndn::bind(&Fib::onFailure, this, _1, _2,
302 "Failed in name registration"));
303}
akmhoque31d1d4b2014-05-05 22:08:14 -0500304
akmhoquefdbddb12014-05-02 18:35:19 -0500305void
akmhoque157b0a42014-05-13 00:26:37 -0500306Fib::unregisterPrefix(const ndn::Name& namePrefix, const std::string& faceUri)
akmhoquefdbddb12014-05-02 18:35:19 -0500307{
akmhoque157b0a42014-05-13 00:26:37 -0500308 uint32_t faceId = m_faceMap.getFaceId(faceUri);
309 if (faceId > 0) {
310 ndn::nfd::ControlParameters controlParameters;
311 controlParameters
312 .setName(namePrefix)
313 .setFaceId(faceId)
314 .setOrigin(128);
315 m_controller.start<ndn::nfd::RibUnregisterCommand>(controlParameters,
akmhoquefdbddb12014-05-02 18:35:19 -0500316 ndn::bind(&Fib::onSuccess, this, _1,
317 "Successful in unregistering name"),
318 ndn::bind(&Fib::onFailure, this, _1, _2,
319 "Failed in unregistering name"));
akmhoque157b0a42014-05-13 00:26:37 -0500320 }
akmhoquefdbddb12014-05-02 18:35:19 -0500321}
322
323void
akmhoque157b0a42014-05-13 00:26:37 -0500324Fib::setStrategy(const ndn::Name& name, const std::string& strategy)
325{
326 ndn::nfd::ControlParameters parameters;
327 parameters
328 .setName(name)
329 .setStrategy(strategy);
330
331 m_controller.start<ndn::nfd::StrategyChoiceSetCommand>(parameters,
332 bind(&Fib::onSuccess, this, _1,
333 "Successfully set strategy choice"),
334 bind(&Fib::onFailure, this, _1, _2,
335 "Failed to set strategy choice"));
336}
337
338void
339Fib::onRegistration(const ndn::nfd::ControlParameters& commandSuccessResult,
340 const std::string& message, const std::string& faceUri)
341{
342 //std::cout << message << ": " << commandSuccessResult << std::endl;
343 m_faceMap.update(faceUri, commandSuccessResult.getFaceId());
344 m_faceMap.print();
345}
346
347
348void
akmhoque31d1d4b2014-05-05 22:08:14 -0500349Fib::onSuccess(const ndn::nfd::ControlParameters& commandSuccessResult,
350 const std::string& message)
akmhoquefdbddb12014-05-02 18:35:19 -0500351{
akmhoque157b0a42014-05-13 00:26:37 -0500352 //std::cout << message << ": " << commandSuccessResult << std::endl;
akmhoquefdbddb12014-05-02 18:35:19 -0500353}
354
355void
akmhoque31d1d4b2014-05-05 22:08:14 -0500356Fib::onFailure(uint32_t code, const std::string& error,
357 const std::string& message)
akmhoquefdbddb12014-05-02 18:35:19 -0500358{
359 std::cout << message << ": " << error << " (code: " << code << ")";
360}
361
akmhoque674b0b12014-05-20 14:33:28 -0500362void
363Fib::writeLog()
364{
365 _LOG_DEBUG("-------------------FIB-----------------------------");
366 for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
367 ++it) {
368 (*it).writeLog();
369 }
370}
akmhoquefdbddb12014-05-02 18:35:19 -0500371
372void
akmhoque53353462014-04-22 08:43:45 -0500373Fib::print()
374{
375 cout << "-------------------FIB-----------------------------" << endl;
376 for (std::list<FibEntry>::iterator it = m_table.begin(); it != m_table.end();
akmhoque157b0a42014-05-13 00:26:37 -0500377 ++it) {
akmhoque53353462014-04-22 08:43:45 -0500378 cout << (*it);
379 }
380}
381
382} //namespace nlsr