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 | f8b5bcd | 2016-08-11 15:06:50 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2016, The University of Memphis, |
| 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/>. |
| 19 | * |
| 20 | * \author A K M Mahmudul Hoque <ahoque1@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 23 | #include "nlsr.hpp" |
| 24 | #include "lsdb.hpp" |
| 25 | #include "hello-protocol.hpp" |
| 26 | #include "utility/name-helper.hpp" |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 27 | #include "logger.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 28 | |
| 29 | namespace nlsr { |
| 30 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 31 | INIT_LOGGER("HelloProtocol"); |
| 32 | |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 33 | const std::string HelloProtocol::INFO_COMPONENT = "INFO"; |
| 34 | const std::string HelloProtocol::NLSR_COMPONENT = "NLSR"; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 35 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 36 | void |
| 37 | HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds) |
| 38 | { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 39 | _LOG_DEBUG("Expressing Interest :" << interestName); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 40 | ndn::Interest i(interestName); |
| 41 | i.setInterestLifetime(ndn::time::seconds(seconds)); |
| 42 | i.setMustBeFresh(true); |
| 43 | m_nlsr.getNlsrFace().expressInterest(i, |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 44 | ndn::bind(&HelloProtocol::onContent, |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 45 | this, |
| 46 | _1, _2), |
| 47 | ndn::bind(&HelloProtocol::processInterestTimedOut, |
| 48 | this, _1)); |
| 49 | } |
| 50 | |
| 51 | void |
| 52 | HelloProtocol::sendScheduledInterest(uint32_t seconds) |
| 53 | { |
| 54 | std::list<Adjacent> adjList = m_nlsr.getAdjacencyList().getAdjList(); |
| 55 | for (std::list<Adjacent>::iterator it = adjList.begin(); it != adjList.end(); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 56 | ++it) { |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 57 | if((*it).getFaceId() != 0) { |
| 58 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 59 | ndn::Name interestName = (*it).getName() ; |
| 60 | interestName.append(NLSR_COMPONENT); |
| 61 | interestName.append(INFO_COMPONENT); |
| 62 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 63 | expressInterest(interestName, |
| 64 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 65 | } |
| 66 | else { |
| 67 | registerPrefixes((*it).getName(), (*it).getConnectingFaceUri(), |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 68 | (*it).getLinkCost(), ndn::time::milliseconds::max()); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 69 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 70 | } |
| 71 | scheduleInterest(m_nlsr.getConfParameter().getInfoInterestInterval()); |
| 72 | } |
| 73 | |
| 74 | void |
| 75 | HelloProtocol::scheduleInterest(uint32_t seconds) |
| 76 | { |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 77 | _LOG_DEBUG("Scheduling HELLO Interests in " << ndn::time::seconds(seconds)); |
| 78 | |
Vince Lehman | 7c60329 | 2014-09-11 17:48:16 -0500 | [diff] [blame] | 79 | m_scheduler.scheduleEvent(ndn::time::seconds(seconds), |
| 80 | ndn::bind(&HelloProtocol::sendScheduledInterest, this, seconds)); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | void |
| 84 | HelloProtocol::processInterest(const ndn::Name& name, |
| 85 | const ndn::Interest& interest) |
| 86 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 87 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 88 | const ndn::Name interestName = interest.getName(); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 89 | _LOG_DEBUG("Interest Received for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 90 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 91 | return; |
| 92 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 93 | ndn::Name neighbor; |
| 94 | neighbor.wireDecode(interestName.get(-1).blockFromValue()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 95 | _LOG_DEBUG("Neighbor: " << neighbor); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 96 | if (m_nlsr.getAdjacencyList().isNeighbor(neighbor)) { |
akmhoque | 69c9aa9 | 2014-07-23 15:15:05 -0500 | [diff] [blame] | 97 | ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>(); |
| 98 | data->setName(ndn::Name(interest.getName()).appendVersion()); |
| 99 | data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec |
| 100 | data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()), |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 101 | INFO_COMPONENT.size()); |
akmhoque | 69c9aa9 | 2014-07-23 15:15:05 -0500 | [diff] [blame] | 102 | m_nlsr.getKeyChain().sign(*data, m_nlsr.getDefaultCertName()); |
| 103 | _LOG_DEBUG("Sending out data for name: " << interest.getName()); |
| 104 | m_nlsr.getNlsrFace().put(*data); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 105 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 106 | if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) { |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 107 | if(adjacent->getFaceId() != 0){ |
| 108 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 109 | ndn::Name interestName(neighbor); |
| 110 | interestName.append(NLSR_COMPONENT); |
| 111 | interestName.append(INFO_COMPONENT); |
| 112 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 113 | expressInterest(interestName, |
| 114 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 115 | } |
| 116 | else { |
| 117 | registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(), |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 118 | adjacent->getLinkCost(), ndn::time::milliseconds::max()); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 119 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | void |
| 125 | HelloProtocol::processInterestTimedOut(const ndn::Interest& interest) |
| 126 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 127 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 128 | const ndn::Name interestName(interest.getName()); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 129 | _LOG_DEBUG("Interest timed out for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 130 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 131 | return; |
| 132 | } |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 133 | ndn::Name neighbor = interestName.getPrefix(-3); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 134 | _LOG_DEBUG("Neighbor: " << neighbor); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 135 | m_nlsr.getAdjacencyList().incrementTimedOutInterestCount(neighbor); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 136 | |
| 137 | Adjacent::Status status = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
| 138 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 139 | uint32_t infoIntTimedOutCount = |
| 140 | m_nlsr.getAdjacencyList().getTimedOutInterestCount(neighbor); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 141 | _LOG_DEBUG("Status: " << status); |
| 142 | _LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 143 | if ((infoIntTimedOutCount < m_nlsr.getConfParameter().getInterestRetryNumber())) { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 144 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 145 | ndn::Name interestName(neighbor); |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 146 | interestName.append(NLSR_COMPONENT); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 147 | interestName.append(INFO_COMPONENT); |
| 148 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 149 | expressInterest(interestName, |
| 150 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 151 | } |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 152 | else if ((status == Adjacent::STATUS_ACTIVE) && |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 153 | (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber())) { |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 154 | m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE); |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 155 | |
| 156 | m_nlsr.getLsdb().scheduleAdjLsaBuild(); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 157 | } |
| 158 | } |
| 159 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 160 | void |
| 161 | HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data) |
| 162 | { |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 163 | _LOG_DEBUG("Received data for INFO(name): " << data.getName()); |
| 164 | if (data.getSignature().hasKeyLocator()) { |
| 165 | if (data.getSignature().getKeyLocator().getType() == ndn::KeyLocator::KeyLocator_Name) { |
| 166 | _LOG_DEBUG("Data signed with: " << data.getSignature().getKeyLocator().getName()); |
| 167 | } |
| 168 | } |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 169 | m_nlsr.getValidator().validate(data, |
| 170 | ndn::bind(&HelloProtocol::onContentValidated, this, _1), |
| 171 | ndn::bind(&HelloProtocol::onContentValidationFailed, |
| 172 | this, _1, _2)); |
| 173 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 174 | |
| 175 | void |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 176 | HelloProtocol::onContentValidated(const ndn::shared_ptr<const ndn::Data>& data) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 177 | { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 178 | /* data name: /<neighbor>/NLSR/INFO/<router>/<version> */ |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 179 | ndn::Name dataName = data->getName(); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 180 | _LOG_DEBUG("Data validation successful for INFO(name): " << dataName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 181 | if (dataName.get(-3).toUri() == INFO_COMPONENT) { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 182 | ndn::Name neighbor = dataName.getPrefix(-4); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 183 | |
| 184 | Adjacent::Status oldStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
| 185 | m_nlsr.getAdjacencyList().setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 186 | m_nlsr.getAdjacencyList().setTimedOutInterestCount(neighbor, 0); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 187 | Adjacent::Status newStatus = m_nlsr.getAdjacencyList().getStatusOfNeighbor(neighbor); |
| 188 | |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 189 | _LOG_DEBUG("Neighbor : " << neighbor); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 190 | _LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 191 | // change in Adjacency list |
| 192 | if ((oldStatus - newStatus) != 0) { |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 193 | m_nlsr.getLsdb().scheduleAdjLsaBuild(); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 198 | void |
| 199 | HelloProtocol::onContentValidationFailed(const ndn::shared_ptr<const ndn::Data>& data, |
| 200 | const std::string& msg) |
| 201 | { |
| 202 | _LOG_DEBUG("Validation Error: " << msg); |
| 203 | } |
| 204 | |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 205 | void |
akmhoque | 8e0252b | 2014-07-07 16:04:44 -0500 | [diff] [blame] | 206 | HelloProtocol::registerPrefixes(const ndn::Name& adjName, const std::string& faceUri, |
akmhoque | bf11c5f | 2014-07-21 14:49:47 -0500 | [diff] [blame] | 207 | double linkCost, const ndn::time::milliseconds& timeout) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 208 | { |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 209 | m_nlsr.getFib().registerPrefix(adjName, faceUri, linkCost, timeout, |
| 210 | ndn::nfd::ROUTE_FLAG_CAPTURE, 0, |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 211 | ndn::bind(&HelloProtocol::onRegistrationSuccess, |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 212 | this, _1, adjName,timeout), |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 213 | ndn::bind(&HelloProtocol::onRegistrationFailure, |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 214 | this, _1, _2, adjName)); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | void |
| 218 | HelloProtocol::onRegistrationSuccess(const ndn::nfd::ControlParameters& commandSuccessResult, |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 219 | const ndn::Name& neighbor,const ndn::time::milliseconds& timeout) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 220 | { |
| 221 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(neighbor); |
| 222 | if (adjacent != 0) { |
| 223 | adjacent->setFaceId(commandSuccessResult.getFaceId()); |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 224 | ndn::Name broadcastKeyPrefix = DEFAULT_BROADCAST_PREFIX; |
| 225 | broadcastKeyPrefix.append("KEYS"); |
| 226 | std::string faceUri = adjacent->getConnectingFaceUri(); |
| 227 | double linkCost = adjacent->getLinkCost(); |
| 228 | m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getChronosyncPrefix(), |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 229 | faceUri, linkCost, timeout, |
| 230 | ndn::nfd::ROUTE_FLAG_CAPTURE, 0); |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 231 | m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getLsaPrefix(), |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 232 | faceUri, linkCost, timeout, |
| 233 | ndn::nfd::ROUTE_FLAG_CAPTURE, 0); |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 234 | m_nlsr.getFib().registerPrefix(broadcastKeyPrefix, |
akmhoque | 060d302 | 2014-08-12 13:35:06 -0500 | [diff] [blame] | 235 | faceUri, linkCost, timeout, |
| 236 | ndn::nfd::ROUTE_FLAG_CAPTURE, 0); |
akmhoque | 102aea4 | 2014-08-04 10:22:12 -0500 | [diff] [blame] | 237 | m_nlsr.setStrategies(); |
| 238 | |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 239 | /* interest name: /<neighbor>/NLSR/INFO/<router> */ |
| 240 | ndn::Name interestName(neighbor); |
| 241 | interestName.append(NLSR_COMPONENT); |
| 242 | interestName.append(INFO_COMPONENT); |
| 243 | interestName.append(m_nlsr.getConfParameter().getRouterPrefix().wireEncode()); |
| 244 | expressInterest(interestName, |
| 245 | m_nlsr.getConfParameter().getInterestResendTime()); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | void |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 250 | HelloProtocol::onRegistrationFailure(uint32_t code, const std::string& error, |
| 251 | const ndn::Name& name) |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 252 | { |
| 253 | _LOG_DEBUG(error << " (code: " << code << ")"); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 254 | /* |
| 255 | * If NLSR can not create face for given faceUri then it will treat this |
| 256 | * failure as one INFO interest timed out. So that NLSR can move on with |
| 257 | * building Adj Lsa and calculate routing table. NLSR does not build Adj |
| 258 | * Lsa unless all the neighbors are ACTIVE or DEAD. For considering the |
| 259 | * missconfigured(link) neighbour dead this is required. |
| 260 | */ |
| 261 | Adjacent *adjacent = m_nlsr.getAdjacencyList().findAdjacent(name); |
| 262 | if (adjacent != 0) { |
| 263 | adjacent->setInterestTimedOutNo(adjacent->getInterestTimedOutNo() + 1); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 264 | Adjacent::Status status = adjacent->getStatus(); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 265 | uint32_t infoIntTimedOutCount = adjacent->getInterestTimedOutNo(); |
| 266 | |
| 267 | if (infoIntTimedOutCount == m_nlsr.getConfParameter().getInterestRetryNumber()) { |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 268 | if (status == Adjacent::STATUS_ACTIVE) { |
| 269 | adjacent->setStatus(Adjacent::STATUS_INACTIVE); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 270 | } |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 271 | |
| 272 | m_nlsr.getLsdb().scheduleAdjLsaBuild(); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 273 | } |
| 274 | } |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 275 | } |
| 276 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame^] | 277 | } // namespace nlsr |