akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | feae557 | 2017-01-13 12:06:26 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Nick Gordon | f8b5bcd | 2016-08-11 15:06:50 -0500 | [diff] [blame] | 4 | * Regents of the University of California |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 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/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 19 | **/ |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 20 | #include "routing-table.hpp" |
| 21 | #include "nlsr.hpp" |
| 22 | #include "map.hpp" |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 23 | #include "conf-parameter.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 24 | #include "routing-table-calculator.hpp" |
| 25 | #include "routing-table-entry.hpp" |
akmhoque | c8a10f7 | 2014-04-25 18:42:55 -0500 | [diff] [blame] | 26 | #include "name-prefix-table.hpp" |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 27 | #include "logger.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 28 | |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 29 | #include <iostream> |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 30 | #include <list> |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 31 | #include <string> |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 32 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 33 | namespace nlsr { |
| 34 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 35 | INIT_LOGGER("RoutingTable"); |
| 36 | |
Nick Gordon | b7b5839 | 2017-08-17 16:29:21 -0500 | [diff] [blame] | 37 | RoutingTable::RoutingTable(ndn::Scheduler& scheduler) |
Nick Gordon | d40a588 | 2017-09-05 15:34:58 -0500 | [diff] [blame^] | 38 | : afterRoutingChange{ndn::make_unique<AfterRoutingChange>()} |
Nick Gordon | b7b5839 | 2017-08-17 16:29:21 -0500 | [diff] [blame] | 39 | , m_scheduler(scheduler) |
| 40 | , m_NO_NEXT_HOP{-12345} |
| 41 | , m_routingCalcInterval{static_cast<uint32_t>(ROUTING_CALC_INTERVAL_DEFAULT)} |
| 42 | { |
| 43 | } |
| 44 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 45 | void |
| 46 | RoutingTable::calculate(Nlsr& pnlsr) |
| 47 | { |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 48 | pnlsr.getLsdb().writeCorLsdbLog(); |
| 49 | pnlsr.getLsdb().writeNameLsdbLog(); |
| 50 | pnlsr.getLsdb().writeAdjLsdbLog(); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 51 | pnlsr.getNamePrefixTable().writeLog(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 52 | if (pnlsr.getIsRoutingTableCalculating() == false) { |
| 53 | //setting routing table calculation |
| 54 | pnlsr.setIsRoutingTableCalculating(true); |
Nick Gordon | e8e03ac | 2016-07-07 14:24:38 -0500 | [diff] [blame] | 55 | |
| 56 | bool isHrEnabled = pnlsr.getConfParameter().getHyperbolicState() != HYPERBOLIC_STATE_OFF; |
| 57 | |
| 58 | if ((!isHrEnabled |
| 59 | && |
| 60 | pnlsr.getLsdb() |
| 61 | .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri() |
| 62 | + "/" + "adjacency", std::string("adjacency"))) |
| 63 | || |
| 64 | (isHrEnabled |
| 65 | && |
| 66 | pnlsr.getLsdb() |
| 67 | .doesLsaExist(pnlsr.getConfParameter().getRouterPrefix().toUri() |
| 68 | + "/" + "coordinate", std::string("coordinate")))) { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 69 | if (pnlsr.getIsBuildAdjLsaSheduled() != 1) { |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 70 | _LOG_TRACE("Clearing old routing table"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 71 | clearRoutingTable(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 72 | // for dry run options |
| 73 | clearDryRoutingTable(); |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 74 | |
| 75 | _LOG_DEBUG("Calculating routing table"); |
| 76 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 77 | // calculate Link State routing |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 78 | if ((pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_OFF) |
| 79 | || (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 80 | calculateLsRoutingTable(pnlsr); |
| 81 | } |
| 82 | //calculate hyperbolic routing |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 83 | if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 84 | calculateHypRoutingTable(pnlsr); |
| 85 | } |
| 86 | //calculate dry hyperbolic routing |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 87 | if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 88 | calculateHypDryRoutingTable(pnlsr); |
| 89 | } |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 90 | // Inform the NPT that updates have been made |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 91 | _LOG_DEBUG("Calling Update NPT With new Route"); |
Nick Gordon | b7b5839 | 2017-08-17 16:29:21 -0500 | [diff] [blame] | 92 | (*afterRoutingChange)(m_rTable); |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 93 | writeLog(pnlsr.getConfParameter().getHyperbolicState()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 94 | pnlsr.getNamePrefixTable().writeLog(); |
| 95 | pnlsr.getFib().writeLog(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 96 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 97 | else { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 98 | _LOG_DEBUG("Adjacency building is scheduled, so" |
| 99 | " routing table can not be calculated :("); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 100 | } |
| 101 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 102 | else { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 103 | _LOG_DEBUG("No Adj LSA of router itself," |
| 104 | " so Routing table can not be calculated :("); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 105 | clearRoutingTable(); |
| 106 | clearDryRoutingTable(); // for dry run options |
| 107 | // need to update NPT here |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 108 | _LOG_DEBUG("Calling Update NPT With new Route"); |
Nick Gordon | b7b5839 | 2017-08-17 16:29:21 -0500 | [diff] [blame] | 109 | (*afterRoutingChange)(m_rTable); |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 110 | writeLog(pnlsr.getConfParameter().getHyperbolicState()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 111 | pnlsr.getNamePrefixTable().writeLog(); |
| 112 | pnlsr.getFib().writeLog(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 113 | //debugging purpose end |
| 114 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 115 | pnlsr.setIsRouteCalculationScheduled(false); //clear scheduled flag |
| 116 | pnlsr.setIsRoutingTableCalculating(false); //unsetting routing table calculation |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 117 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 118 | else { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 119 | scheduleRoutingTableCalculation(pnlsr); |
| 120 | } |
| 121 | } |
| 122 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 123 | void |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 124 | RoutingTable::calculateLsRoutingTable(Nlsr& nlsr) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 125 | { |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 126 | _LOG_DEBUG("RoutingTable::calculateLsRoutingTable Called"); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 127 | |
| 128 | Map map; |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 129 | map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end()); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 130 | map.writeLog(); |
| 131 | |
| 132 | size_t nRouters = map.getMapSize(); |
| 133 | |
| 134 | LinkStateRoutingTableCalculator calculator(nRouters); |
| 135 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 136 | calculator.calculatePath(map, std::ref(*this), nlsr); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | void |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 140 | RoutingTable::calculateHypRoutingTable(Nlsr& nlsr) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 141 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 142 | Map map; |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 143 | map.createFromCoordinateLsdb(nlsr.getLsdb().getCoordinateLsdb().begin(), |
| 144 | nlsr.getLsdb().getCoordinateLsdb().end()); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 145 | map.writeLog(); |
| 146 | |
| 147 | size_t nRouters = map.getMapSize(); |
| 148 | |
| 149 | HyperbolicRoutingCalculator calculator(nRouters, false, |
| 150 | nlsr.getConfParameter().getRouterPrefix()); |
| 151 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 152 | calculator.calculatePaths(map, std::ref(*this), |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 153 | nlsr.getLsdb(), nlsr.getAdjacencyList()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | void |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 157 | RoutingTable::calculateHypDryRoutingTable(Nlsr& nlsr) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 158 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 159 | Map map; |
Nick Gordon | 22b5c95 | 2017-08-10 17:48:15 -0500 | [diff] [blame] | 160 | map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end()); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 161 | map.writeLog(); |
| 162 | |
| 163 | size_t nRouters = map.getMapSize(); |
| 164 | |
| 165 | HyperbolicRoutingCalculator calculator(nRouters, true, |
| 166 | nlsr.getConfParameter().getRouterPrefix()); |
| 167 | |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 168 | calculator.calculatePaths(map, std::ref(*this), |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 169 | nlsr.getLsdb(), nlsr.getAdjacencyList()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | void |
| 173 | RoutingTable::scheduleRoutingTableCalculation(Nlsr& pnlsr) |
| 174 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 175 | if (pnlsr.getIsRouteCalculationScheduled() != true) { |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 176 | _LOG_DEBUG("Scheduling routing table calculation in " << m_routingCalcInterval); |
| 177 | |
Vince Lehman | 7b61658 | 2014-10-17 16:25:39 -0500 | [diff] [blame] | 178 | m_scheduler.scheduleEvent(m_routingCalcInterval, |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 179 | std::bind(&RoutingTable::calculate, this, std::ref(pnlsr))); |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 180 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 181 | pnlsr.setIsRouteCalculationScheduled(true); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
| 185 | static bool |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 186 | routingTableEntryCompare(RoutingTableEntry& rte, ndn::Name& destRouter) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 187 | { |
| 188 | return rte.getDestination() == destRouter; |
| 189 | } |
| 190 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 191 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 192 | RoutingTable::addNextHop(const ndn::Name& destRouter, NextHop& nh) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 193 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 194 | _LOG_DEBUG("Adding " << nh << " for destination: " << destRouter); |
| 195 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 196 | RoutingTableEntry* rteChk = findRoutingTableEntry(destRouter); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 197 | if (rteChk == 0) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 198 | RoutingTableEntry rte(destRouter); |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 199 | rte.getNexthopList().addNextHop(nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 200 | m_rTable.push_back(rte); |
| 201 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 202 | else { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 203 | rteChk->getNexthopList().addNextHop(nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 207 | RoutingTableEntry* |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 208 | RoutingTable::findRoutingTableEntry(const ndn::Name& destRouter) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 209 | { |
| 210 | std::list<RoutingTableEntry>::iterator it = std::find_if(m_rTable.begin(), |
| 211 | m_rTable.end(), |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 212 | std::bind(&routingTableEntryCompare, |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 213 | _1, destRouter)); |
| 214 | if (it != m_rTable.end()) { |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 215 | return &(*it); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 216 | } |
akmhoque | b6450b1 | 2014-04-24 00:01:03 -0500 | [diff] [blame] | 217 | return 0; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | void |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 221 | RoutingTable::writeLog(int hyperbolicState) |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 222 | { |
| 223 | _LOG_DEBUG("---------------Routing Table------------------"); |
| 224 | for (std::list<RoutingTableEntry>::iterator it = m_rTable.begin() ; |
| 225 | it != m_rTable.end(); ++it) { |
| 226 | _LOG_DEBUG("Destination: " << (*it).getDestination()); |
| 227 | _LOG_DEBUG("Nexthops: "); |
| 228 | (*it).getNexthopList().writeLog(); |
| 229 | } |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 230 | |
| 231 | if (hyperbolicState == HYPERBOLIC_STATE_DRY_RUN) { |
| 232 | _LOG_DEBUG("--------Hyperbolic Routing Table(Dry)---------"); |
| 233 | for (std::list<RoutingTableEntry>::iterator it = m_dryTable.begin() ; |
| 234 | it != m_dryTable.end(); ++it) { |
| 235 | _LOG_DEBUG("Destination: " << (*it).getDestination()); |
| 236 | _LOG_DEBUG("Nexthops: "); |
| 237 | (*it).getNexthopList().writeLog(); |
| 238 | } |
| 239 | } |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 240 | } |
| 241 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 242 | void |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 243 | RoutingTable::addNextHopToDryTable(const ndn::Name& destRouter, NextHop& nh) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 244 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 245 | _LOG_DEBUG("Adding " << nh << " to dry table for destination: " << destRouter); |
| 246 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 247 | std::list<RoutingTableEntry>::iterator it = std::find_if(m_dryTable.begin(), |
| 248 | m_dryTable.end(), |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 249 | std::bind(&routingTableEntryCompare, |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 250 | _1, destRouter)); |
| 251 | if (it == m_dryTable.end()) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 252 | RoutingTableEntry rte(destRouter); |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 253 | rte.getNexthopList().addNextHop(nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 254 | m_dryTable.push_back(rte); |
| 255 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 256 | else { |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 257 | (*it).getNexthopList().addNextHop(nh); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 258 | } |
| 259 | } |
| 260 | |
| 261 | void |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 262 | RoutingTable::clearRoutingTable() |
| 263 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 264 | if (m_rTable.size() > 0) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 265 | m_rTable.clear(); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | void |
| 270 | RoutingTable::clearDryRoutingTable() |
| 271 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 272 | if (m_dryTable.size() > 0) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 273 | m_dryTable.clear(); |
| 274 | } |
| 275 | } |
| 276 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 277 | } // namespace nlsr |