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