akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | af7a211 | 2019-03-19 14:55:20 -0400 | [diff] [blame] | 2 | /* |
Ashlesh Gawande | e63b7fa | 2021-04-06 21:43:17 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2021, 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/>. |
Alexander Afanasyev | 0ad01f3 | 2020-06-03 14:12:58 -0400 | [diff] [blame] | 19 | */ |
Junxiao Shi | 63bd034 | 2016-08-17 16:57:14 +0000 | [diff] [blame] | 20 | |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 21 | #include "hello-protocol.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 22 | #include "nlsr.hpp" |
| 23 | #include "lsdb.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 24 | #include "utility/name-helper.hpp" |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 25 | #include "logger.hpp" |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 26 | |
Ashlesh Gawande | 214032e | 2020-12-22 17:20:14 -0500 | [diff] [blame] | 27 | #include <ndn-cxx/encoding/nfd-constants.hpp> |
| 28 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 29 | namespace nlsr { |
| 30 | |
dmcoomes | cf8d0ed | 2017-02-21 11:39:01 -0600 | [diff] [blame] | 31 | INIT_LOGGER(HelloProtocol); |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 32 | |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 33 | const std::string HelloProtocol::INFO_COMPONENT = "INFO"; |
Ashlesh Gawande | cba0ae2 | 2018-03-27 17:57:56 -0500 | [diff] [blame] | 34 | const std::string HelloProtocol::NLSR_COMPONENT = "nlsr"; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 35 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 36 | HelloProtocol::HelloProtocol(ndn::Face& face, ndn::KeyChain& keyChain, |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 37 | ConfParameter& confParam, RoutingTable& routingTable, |
| 38 | Lsdb& lsdb) |
| 39 | : m_face(face) |
| 40 | , m_scheduler(m_face.getIoService()) |
| 41 | , m_keyChain(keyChain) |
Saurab Dulal | 427e012 | 2019-11-28 11:58:02 -0600 | [diff] [blame] | 42 | , m_signingInfo(confParam.getSigningInfo()) |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 43 | , m_confParam(confParam) |
| 44 | , m_routingTable(routingTable) |
| 45 | , m_lsdb(lsdb) |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 46 | , m_adjacencyList(m_confParam.getAdjacencyList()) |
Nick Gordon | e18296c | 2017-10-11 16:05:24 -0500 | [diff] [blame] | 47 | { |
Ashlesh Gawande | 214032e | 2020-12-22 17:20:14 -0500 | [diff] [blame] | 48 | ndn::Name name(m_confParam.getRouterPrefix()); |
| 49 | name.append(NLSR_COMPONENT); |
| 50 | name.append(INFO_COMPONENT); |
| 51 | |
| 52 | NLSR_LOG_DEBUG("Setting interest filter for Hello interest: " << name); |
| 53 | |
| 54 | m_face.setInterestFilter(ndn::InterestFilter(name).allowLoopback(false), |
| 55 | [this] (const auto& name, const auto& interest) { |
| 56 | processInterest(name, interest); |
| 57 | }, |
| 58 | [] (const auto& name) { |
| 59 | NLSR_LOG_DEBUG("Successfully registered prefix: " << name); |
| 60 | }, |
| 61 | [] (const auto& name, const auto& resp) { |
| 62 | NLSR_LOG_ERROR("Failed to register prefix " << name); |
| 63 | NDN_THROW(std::runtime_error("Failed to register hello prefix: " + resp)); |
| 64 | }, |
| 65 | m_signingInfo, ndn::nfd::ROUTE_FLAG_CAPTURE); |
Nick Gordon | e18296c | 2017-10-11 16:05:24 -0500 | [diff] [blame] | 66 | } |
| 67 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 68 | void |
| 69 | HelloProtocol::expressInterest(const ndn::Name& interestName, uint32_t seconds) |
| 70 | { |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 71 | NLSR_LOG_DEBUG("Expressing Interest: " << interestName); |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 72 | ndn::Interest interest(interestName); |
| 73 | interest.setInterestLifetime(ndn::time::seconds(seconds)); |
| 74 | interest.setMustBeFresh(true); |
| 75 | interest.setCanBePrefix(true); |
| 76 | m_face.expressInterest(interest, |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 77 | std::bind(&HelloProtocol::onContent, this, _1, _2), |
| 78 | [this, seconds] (const ndn::Interest& interest, const ndn::lp::Nack& nack) |
| 79 | { |
| 80 | NDN_LOG_TRACE("Received Nack with reason: " << nack.getReason()); |
| 81 | NDN_LOG_TRACE("Will treat as timeout in " << 2 * seconds << " seconds"); |
| 82 | m_scheduler.schedule(ndn::time::seconds(2 * seconds), |
| 83 | [this, interest] { processInterestTimedOut(interest); }); |
| 84 | }, |
| 85 | std::bind(&HelloProtocol::processInterestTimedOut, this, _1)); |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 86 | |
| 87 | // increment SENT_HELLO_INTEREST |
| 88 | hpIncrementSignal(Statistics::PacketType::SENT_HELLO_INTEREST); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | void |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 92 | HelloProtocol::sendHelloInterest(const ndn::Name& neighbor) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 93 | { |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 94 | auto adjacent = m_adjacencyList.findAdjacent(neighbor); |
| 95 | |
| 96 | if (adjacent == m_adjacencyList.end()) { |
| 97 | return; |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 98 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 99 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 100 | // If this adjacency has a Face, just proceed as usual. |
| 101 | if(adjacent->getFaceId() != 0) { |
| 102 | // interest name: /<neighbor>/NLSR/INFO/<router> |
| 103 | ndn::Name interestName = adjacent->getName() ; |
| 104 | interestName.append(NLSR_COMPONENT); |
| 105 | interestName.append(INFO_COMPONENT); |
| 106 | interestName.append(m_confParam.getRouterPrefix().wireEncode()); |
| 107 | expressInterest(interestName, m_confParam.getInterestResendTime()); |
| 108 | NLSR_LOG_DEBUG("Sending HELLO interest: " << interestName); |
| 109 | } |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 110 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 111 | m_scheduler.schedule(ndn::time::seconds(m_confParam.getInfoInterestInterval()), |
| 112 | [this, neighbor] { sendHelloInterest(neighbor); }); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | void |
| 116 | HelloProtocol::processInterest(const ndn::Name& name, |
| 117 | const ndn::Interest& interest) |
| 118 | { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 119 | // interest name: /<neighbor>/NLSR/INFO/<router> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 120 | const ndn::Name interestName = interest.getName(); |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 121 | |
| 122 | // increment RCV_HELLO_INTEREST |
| 123 | hpIncrementSignal(Statistics::PacketType::RCV_HELLO_INTEREST); |
| 124 | |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 125 | NLSR_LOG_DEBUG("Interest Received for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 126 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 127 | NLSR_LOG_DEBUG("INFO_COMPONENT not found or interestName: " << interestName |
dmcoomes | 9eaf3f4 | 2017-02-21 11:39:01 -0600 | [diff] [blame] | 128 | << " does not match expression"); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 129 | return; |
| 130 | } |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 131 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 132 | ndn::Name neighbor; |
| 133 | neighbor.wireDecode(interestName.get(-1).blockFromValue()); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 134 | NLSR_LOG_DEBUG("Neighbor: " << neighbor); |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 135 | if (m_adjacencyList.isNeighbor(neighbor)) { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 136 | std::shared_ptr<ndn::Data> data = std::make_shared<ndn::Data>(); |
akmhoque | 69c9aa9 | 2014-07-23 15:15:05 -0500 | [diff] [blame] | 137 | data->setName(ndn::Name(interest.getName()).appendVersion()); |
| 138 | data->setFreshnessPeriod(ndn::time::seconds(10)); // 10 sec |
| 139 | data->setContent(reinterpret_cast<const uint8_t*>(INFO_COMPONENT.c_str()), |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 140 | INFO_COMPONENT.size()); |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 141 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 142 | m_keyChain.sign(*data, m_signingInfo); |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 143 | |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 144 | NLSR_LOG_DEBUG("Sending out data for name: " << interest.getName()); |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 145 | |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 146 | m_face.put(*data); |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 147 | // increment SENT_HELLO_DATA |
| 148 | hpIncrementSignal(Statistics::PacketType::SENT_HELLO_DATA); |
Nick Gordon | c780a69 | 2017-04-27 18:03:02 -0500 | [diff] [blame] | 149 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 150 | auto adjacent = m_adjacencyList.findAdjacent(neighbor); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 151 | // If this neighbor was previously inactive, send our own hello interest, too |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 152 | if (adjacent->getStatus() == Adjacent::STATUS_INACTIVE) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 153 | // We can only do that if the neighbor currently has a face. |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 154 | if(adjacent->getFaceId() != 0){ |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 155 | // interest name: /<neighbor>/NLSR/INFO/<router> |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 156 | ndn::Name interestName(neighbor); |
| 157 | interestName.append(NLSR_COMPONENT); |
| 158 | interestName.append(INFO_COMPONENT); |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 159 | interestName.append(m_confParam.getRouterPrefix().wireEncode()); |
| 160 | expressInterest(interestName, m_confParam.getInterestResendTime()); |
akmhoque | c04e727 | 2014-07-02 11:00:14 -0500 | [diff] [blame] | 161 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | void |
| 167 | HelloProtocol::processInterestTimedOut(const ndn::Interest& interest) |
| 168 | { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 169 | // interest name: /<neighbor>/NLSR/INFO/<router> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 170 | const ndn::Name interestName(interest.getName()); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 171 | NLSR_LOG_DEBUG("Interest timed out for Name: " << interestName); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 172 | if (interestName.get(-2).toUri() != INFO_COMPONENT) { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 173 | return; |
| 174 | } |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 175 | ndn::Name neighbor = interestName.getPrefix(-3); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 176 | NLSR_LOG_DEBUG("Neighbor: " << neighbor); |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 177 | m_adjacencyList.incrementTimedOutInterestCount(neighbor); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 178 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 179 | Adjacent::Status status = m_adjacencyList.getStatusOfNeighbor(neighbor); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 180 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 181 | uint32_t infoIntTimedOutCount = m_adjacencyList.getTimedOutInterestCount(neighbor); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 182 | NLSR_LOG_DEBUG("Status: " << status); |
| 183 | NLSR_LOG_DEBUG("Info Interest Timed out: " << infoIntTimedOutCount); |
Ashlesh Gawande | 214032e | 2020-12-22 17:20:14 -0500 | [diff] [blame] | 184 | if (infoIntTimedOutCount < m_confParam.getInterestRetryNumber()) { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 185 | // interest name: /<neighbor>/NLSR/INFO/<router> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 186 | ndn::Name interestName(neighbor); |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 187 | interestName.append(NLSR_COMPONENT); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 188 | interestName.append(INFO_COMPONENT); |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 189 | interestName.append(m_confParam.getRouterPrefix().wireEncode()); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 190 | NLSR_LOG_DEBUG("Resending interest: " << interestName); |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 191 | expressInterest(interestName, m_confParam.getInterestResendTime()); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 192 | } |
Ashlesh Gawande | 214032e | 2020-12-22 17:20:14 -0500 | [diff] [blame] | 193 | else if (status == Adjacent::STATUS_ACTIVE) { |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 194 | m_adjacencyList.setStatusOfNeighbor(neighbor, Adjacent::STATUS_INACTIVE); |
Vince Lehman | 50df6b7 | 2015-03-03 12:06:40 -0600 | [diff] [blame] | 195 | |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 196 | NLSR_LOG_DEBUG("Neighbor: " << neighbor << " status changed to INACTIVE"); |
dmcoomes | 9eaf3f4 | 2017-02-21 11:39:01 -0600 | [diff] [blame] | 197 | |
Ashlesh Gawande | 214032e | 2020-12-22 17:20:14 -0500 | [diff] [blame] | 198 | if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) { |
| 199 | m_routingTable.scheduleRoutingTableCalculation(); |
| 200 | } |
| 201 | else { |
| 202 | m_lsdb.scheduleAdjLsaBuild(); |
| 203 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 204 | } |
| 205 | } |
| 206 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 207 | // This is the first function that incoming Hello data will |
| 208 | // see. This checks if the data appears to be signed, and passes it |
| 209 | // on to validate the content of the data. |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 210 | void |
| 211 | HelloProtocol::onContent(const ndn::Interest& interest, const ndn::Data& data) |
| 212 | { |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 213 | NLSR_LOG_DEBUG("Received data for INFO(name): " << data.getName()); |
Ashlesh Gawande | 7a231c0 | 2020-06-12 20:06:44 -0700 | [diff] [blame] | 214 | auto kl = data.getKeyLocator(); |
| 215 | if (kl && kl->getType() == ndn::tlv::Name) { |
| 216 | NLSR_LOG_DEBUG("Data signed with: " << kl->getName()); |
akmhoque | dfe615f | 2014-07-27 14:12:21 -0500 | [diff] [blame] | 217 | } |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 218 | m_confParam.getValidator().validate(data, |
| 219 | std::bind(&HelloProtocol::onContentValidated, this, _1), |
| 220 | std::bind(&HelloProtocol::onContentValidationFailed, |
| 221 | this, _1, _2)); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 222 | } |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 223 | |
| 224 | void |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 225 | HelloProtocol::onContentValidated(const ndn::Data& data) |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 226 | { |
dmcoomes | 9f93666 | 2017-03-02 10:33:09 -0600 | [diff] [blame] | 227 | // data name: /<neighbor>/NLSR/INFO/<router>/<version> |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 228 | ndn::Name dataName = data.getName(); |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 229 | NLSR_LOG_DEBUG("Data validation successful for INFO(name): " << dataName); |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 230 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 231 | if (dataName.get(-3).toUri() == INFO_COMPONENT) { |
akmhoque | 93f1a07 | 2014-06-19 16:24:28 -0500 | [diff] [blame] | 232 | ndn::Name neighbor = dataName.getPrefix(-4); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 233 | |
Ashlesh Gawande | 6b388fc | 2019-09-30 10:14:41 -0500 | [diff] [blame] | 234 | Adjacent::Status oldStatus = m_adjacencyList.getStatusOfNeighbor(neighbor); |
| 235 | m_adjacencyList.setStatusOfNeighbor(neighbor, Adjacent::STATUS_ACTIVE); |
| 236 | m_adjacencyList.setTimedOutInterestCount(neighbor, 0); |
| 237 | Adjacent::Status newStatus = m_adjacencyList.getStatusOfNeighbor(neighbor); |
Vince Lehman | cb76ade | 2014-08-28 21:24:41 -0500 | [diff] [blame] | 238 | |
dmcoomes | 5bcb39e | 2017-10-31 15:07:55 -0500 | [diff] [blame] | 239 | NLSR_LOG_DEBUG("Neighbor : " << neighbor); |
| 240 | NLSR_LOG_DEBUG("Old Status: " << oldStatus << " New Status: " << newStatus); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 241 | // change in Adjacency list |
| 242 | if ((oldStatus - newStatus) != 0) { |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 243 | if (m_confParam.getHyperbolicState() == HYPERBOLIC_STATE_ON) { |
| 244 | m_routingTable.scheduleRoutingTableCalculation(); |
Ashlesh Gawande | c5fa320 | 2016-12-05 13:21:51 -0600 | [diff] [blame] | 245 | } |
| 246 | else { |
Ashlesh Gawande | 85998a1 | 2017-12-07 22:22:13 -0600 | [diff] [blame] | 247 | m_lsdb.scheduleAdjLsaBuild(); |
Ashlesh Gawande | c5fa320 | 2016-12-05 13:21:51 -0600 | [diff] [blame] | 248 | } |
Ashlesh Gawande | e63b7fa | 2021-04-06 21:43:17 -0700 | [diff] [blame] | 249 | onInitialHelloDataValidated(neighbor); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 250 | } |
| 251 | } |
Alejandro Gil Torres | e0d2048 | 2016-03-06 23:56:19 -0600 | [diff] [blame] | 252 | // increment RCV_HELLO_DATA |
| 253 | hpIncrementSignal(Statistics::PacketType::RCV_HELLO_DATA); |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 254 | } |
| 255 | |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 256 | void |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 257 | HelloProtocol::onContentValidationFailed(const ndn::Data& data, |
Alexander Afanasyev | 0ad01f3 | 2020-06-03 14:12:58 -0400 | [diff] [blame] | 258 | const ndn::security::ValidationError& ve) |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 259 | { |
Muktadir Chowdhury | f04f989 | 2017-08-20 20:42:56 -0500 | [diff] [blame] | 260 | NLSR_LOG_DEBUG("Validation Error: " << ve); |
Yingdi Yu | 20e3a6e | 2014-05-26 23:16:10 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 263 | } // namespace nlsr |