Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, Regents of the University of California, |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
| 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #include "generic-link-service.hpp" |
Junxiao Shi | cbc8e94 | 2016-09-06 03:17:45 +0000 | [diff] [blame] | 27 | #include <ndn-cxx/lp/tags.hpp> |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 28 | |
| 29 | namespace nfd { |
| 30 | namespace face { |
| 31 | |
| 32 | NFD_LOG_INIT("GenericLinkService"); |
| 33 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 34 | GenericLinkService::Options::Options() |
| 35 | : allowLocalFields(false) |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 36 | , allowFragmentation(false) |
| 37 | , allowReassembly(false) |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 38 | { |
| 39 | } |
| 40 | |
| 41 | GenericLinkService::GenericLinkService(const GenericLinkService::Options& options) |
Eric Newberry | 73bcad3 | 2017-04-25 17:57:35 -0700 | [diff] [blame] | 42 | : m_options(options) |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 43 | , m_fragmenter(m_options.fragmenterOptions, this) |
| 44 | , m_reassembler(m_options.reassemblerOptions, this) |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 45 | , m_reliability(m_options.reliabilityOptions, this) |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 46 | , m_lastSeqNo(-2) |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 47 | { |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 48 | m_reassembler.beforeTimeout.connect(bind([this] { ++this->nReassemblyTimeouts; })); |
Eric Newberry | 73bcad3 | 2017-04-25 17:57:35 -0700 | [diff] [blame] | 49 | nReassembling.observe(&m_reassembler); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 50 | } |
| 51 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 52 | void |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 53 | GenericLinkService::setOptions(const GenericLinkService::Options& options) |
| 54 | { |
| 55 | m_options = options; |
| 56 | m_fragmenter.setOptions(m_options.fragmenterOptions); |
| 57 | m_reassembler.setOptions(m_options.reassemblerOptions); |
| 58 | m_reliability.setOptions(m_options.reliabilityOptions); |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | GenericLinkService::requestIdlePacket() |
| 63 | { |
| 64 | // No need to request Acks to attach to this packet from LpReliability, as they are already |
| 65 | // attached in sendLpPacket |
| 66 | this->sendLpPacket({}); |
| 67 | } |
| 68 | |
| 69 | void |
| 70 | GenericLinkService::sendLpPacket(lp::Packet&& pkt) |
| 71 | { |
| 72 | const ssize_t mtu = this->getTransport()->getMtu(); |
| 73 | if (m_options.reliabilityOptions.isEnabled) { |
| 74 | m_reliability.piggyback(pkt, mtu); |
| 75 | } |
| 76 | |
| 77 | Transport::Packet tp(pkt.wireEncode()); |
| 78 | if (mtu != MTU_UNLIMITED && tp.packet.size() > static_cast<size_t>(mtu)) { |
| 79 | ++this->nOutOverMtu; |
| 80 | NFD_LOG_FACE_WARN("attempted to send packet over MTU limit"); |
| 81 | return; |
| 82 | } |
| 83 | this->sendPacket(std::move(tp)); |
| 84 | } |
| 85 | |
| 86 | void |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 87 | GenericLinkService::doSendInterest(const Interest& interest) |
| 88 | { |
| 89 | lp::Packet lpPacket(interest.wireEncode()); |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 90 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 91 | encodeLpFields(interest, lpPacket); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 92 | |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 93 | this->sendNetPacket(std::move(lpPacket)); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | void |
| 97 | GenericLinkService::doSendData(const Data& data) |
| 98 | { |
| 99 | lp::Packet lpPacket(data.wireEncode()); |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 100 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 101 | encodeLpFields(data, lpPacket); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 102 | |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 103 | this->sendNetPacket(std::move(lpPacket)); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | void |
| 107 | GenericLinkService::doSendNack(const lp::Nack& nack) |
| 108 | { |
| 109 | lp::Packet lpPacket(nack.getInterest().wireEncode()); |
| 110 | lpPacket.add<lp::NackField>(nack.getHeader()); |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 111 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 112 | encodeLpFields(nack, lpPacket); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 113 | |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 114 | this->sendNetPacket(std::move(lpPacket)); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 115 | } |
| 116 | |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 117 | void |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 118 | GenericLinkService::encodeLpFields(const ndn::TagHost& netPkt, lp::Packet& lpPacket) |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 119 | { |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 120 | if (m_options.allowLocalFields) { |
| 121 | shared_ptr<lp::IncomingFaceIdTag> incomingFaceIdTag = netPkt.getTag<lp::IncomingFaceIdTag>(); |
| 122 | if (incomingFaceIdTag != nullptr) { |
| 123 | lpPacket.add<lp::IncomingFaceIdField>(*incomingFaceIdTag); |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | shared_ptr<lp::CongestionMarkTag> congestionMarkTag = netPkt.getTag<lp::CongestionMarkTag>(); |
| 128 | if (congestionMarkTag != nullptr) { |
| 129 | lpPacket.add<lp::CongestionMarkField>(*congestionMarkTag); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 130 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 131 | } |
| 132 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 133 | void |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 134 | GenericLinkService::sendNetPacket(lp::Packet&& pkt) |
| 135 | { |
| 136 | std::vector<lp::Packet> frags; |
| 137 | const ssize_t mtu = this->getTransport()->getMtu(); |
| 138 | if (m_options.allowFragmentation && mtu != MTU_UNLIMITED) { |
| 139 | bool isOk = false; |
| 140 | std::tie(isOk, frags) = m_fragmenter.fragmentPacket(pkt, mtu); |
| 141 | if (!isOk) { |
| 142 | // fragmentation failed (warning is logged by LpFragmenter) |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 143 | ++this->nFragmentationErrors; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 144 | return; |
| 145 | } |
| 146 | } |
| 147 | else { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 148 | frags.push_back(std::move(pkt)); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 149 | } |
| 150 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 151 | if (frags.size() == 1) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 152 | // even if indexed fragmentation is enabled, the fragmenter should not |
| 153 | // fragment the packet if it can fit in MTU |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 154 | BOOST_ASSERT(!frags.front().has<lp::FragIndexField>()); |
| 155 | BOOST_ASSERT(!frags.front().has<lp::FragCountField>()); |
| 156 | } |
| 157 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 158 | // Only assign sequences to fragments if reliability enabled and packet contains a fragment, |
| 159 | // or there is more than 1 fragment |
| 160 | if ((m_options.reliabilityOptions.isEnabled && frags.front().has<lp::FragmentField>()) || |
| 161 | frags.size() > 1) { |
| 162 | // Assign sequences to all fragments |
| 163 | this->assignSequences(frags); |
| 164 | } |
| 165 | |
| 166 | if (m_options.reliabilityOptions.isEnabled && frags.front().has<lp::FragmentField>()) { |
| 167 | m_reliability.observeOutgoing(frags); |
| 168 | } |
| 169 | |
| 170 | for (lp::Packet& frag : frags) { |
| 171 | this->sendLpPacket(std::move(frag)); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
| 175 | void |
| 176 | GenericLinkService::assignSequence(lp::Packet& pkt) |
| 177 | { |
| 178 | pkt.set<lp::SequenceField>(++m_lastSeqNo); |
| 179 | } |
| 180 | |
| 181 | void |
| 182 | GenericLinkService::assignSequences(std::vector<lp::Packet>& pkts) |
| 183 | { |
| 184 | std::for_each(pkts.begin(), pkts.end(), bind(&GenericLinkService::assignSequence, this, _1)); |
| 185 | } |
| 186 | |
| 187 | void |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 188 | GenericLinkService::doReceivePacket(Transport::Packet&& packet) |
| 189 | { |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 190 | try { |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 191 | lp::Packet pkt(packet.packet); |
| 192 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 193 | if (m_options.reliabilityOptions.isEnabled) { |
| 194 | m_reliability.processIncomingPacket(pkt); |
| 195 | } |
| 196 | |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 197 | if (!pkt.has<lp::FragmentField>()) { |
| 198 | NFD_LOG_FACE_TRACE("received IDLE packet: DROP"); |
| 199 | return; |
| 200 | } |
| 201 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 202 | if ((pkt.has<lp::FragIndexField>() || pkt.has<lp::FragCountField>()) && |
| 203 | !m_options.allowReassembly) { |
| 204 | NFD_LOG_FACE_WARN("received fragment, but reassembly disabled: DROP"); |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 205 | return; |
| 206 | } |
| 207 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 208 | bool isReassembled = false; |
| 209 | Block netPkt; |
| 210 | lp::Packet firstPkt; |
| 211 | std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.receiveFragment(packet.remoteEndpoint, |
| 212 | pkt); |
| 213 | if (isReassembled) { |
| 214 | this->decodeNetPacket(netPkt, firstPkt); |
| 215 | } |
| 216 | } |
| 217 | catch (const tlv::Error& e) { |
| 218 | ++this->nInLpInvalid; |
| 219 | NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP"); |
| 220 | } |
| 221 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 222 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 223 | void |
| 224 | GenericLinkService::decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt) |
| 225 | { |
| 226 | try { |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 227 | switch (netPkt.type()) { |
| 228 | case tlv::Interest: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 229 | if (firstPkt.has<lp::NackField>()) { |
| 230 | this->decodeNack(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 231 | } |
| 232 | else { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 233 | this->decodeInterest(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 234 | } |
| 235 | break; |
| 236 | case tlv::Data: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 237 | this->decodeData(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 238 | break; |
| 239 | default: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 240 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 241 | NFD_LOG_FACE_WARN("unrecognized network-layer packet TLV-TYPE " << netPkt.type() << ": DROP"); |
| 242 | return; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 243 | } |
| 244 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 245 | catch (const tlv::Error& e) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 246 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 247 | NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP"); |
| 248 | } |
| 249 | } |
| 250 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 251 | void |
| 252 | GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstPkt) |
| 253 | { |
| 254 | BOOST_ASSERT(netPkt.type() == tlv::Interest); |
| 255 | BOOST_ASSERT(!firstPkt.has<lp::NackField>()); |
| 256 | |
| 257 | // forwarding expects Interest to be created with make_shared |
| 258 | auto interest = make_shared<Interest>(netPkt); |
| 259 | |
| 260 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
| 261 | if (m_options.allowLocalFields) { |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 262 | interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>())); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 263 | } |
| 264 | else { |
| 265 | NFD_LOG_FACE_WARN("received NextHopFaceId, but local fields disabled: DROP"); |
| 266 | return; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if (firstPkt.has<lp::CachePolicyField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 271 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 272 | NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP"); |
| 273 | return; |
| 274 | } |
| 275 | |
| 276 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 277 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 278 | } |
| 279 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 280 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 281 | interest->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 282 | } |
| 283 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 284 | this->receiveInterest(*interest); |
| 285 | } |
| 286 | |
| 287 | void |
| 288 | GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt) |
| 289 | { |
| 290 | BOOST_ASSERT(netPkt.type() == tlv::Data); |
| 291 | |
| 292 | // forwarding expects Data to be created with make_shared |
| 293 | auto data = make_shared<Data>(netPkt); |
| 294 | |
| 295 | if (firstPkt.has<lp::NackField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 296 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 297 | NFD_LOG_FACE_WARN("received Nack with Data: DROP"); |
| 298 | return; |
| 299 | } |
| 300 | |
| 301 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 302 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 303 | NFD_LOG_FACE_WARN("received NextHopFaceId with Data: DROP"); |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | if (firstPkt.has<lp::CachePolicyField>()) { |
Junxiao Shi | 6eb0271 | 2017-05-27 22:48:02 +0000 | [diff] [blame] | 308 | // CachePolicy is unprivileged and does not require allowLocalFields option. |
| 309 | // In case of an invalid CachePolicyType, get<lp::CachePolicyField> will throw, |
| 310 | // so it's unnecessary to check here. |
| 311 | data->setTag(make_shared<lp::CachePolicyTag>(firstPkt.get<lp::CachePolicyField>())); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 315 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 316 | } |
| 317 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 318 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 319 | data->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 320 | } |
| 321 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 322 | this->receiveData(*data); |
| 323 | } |
| 324 | |
| 325 | void |
| 326 | GenericLinkService::decodeNack(const Block& netPkt, const lp::Packet& firstPkt) |
| 327 | { |
| 328 | BOOST_ASSERT(netPkt.type() == tlv::Interest); |
| 329 | BOOST_ASSERT(firstPkt.has<lp::NackField>()); |
| 330 | |
| 331 | lp::Nack nack((Interest(netPkt))); |
| 332 | nack.setHeader(firstPkt.get<lp::NackField>()); |
| 333 | |
| 334 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 335 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 336 | NFD_LOG_FACE_WARN("received NextHopFaceId with Nack: DROP"); |
| 337 | return; |
| 338 | } |
| 339 | |
| 340 | if (firstPkt.has<lp::CachePolicyField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 341 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 342 | NFD_LOG_FACE_WARN("received CachePolicy with Nack: DROP"); |
| 343 | return; |
| 344 | } |
| 345 | |
| 346 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 347 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 348 | } |
| 349 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 350 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 351 | nack.setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 352 | } |
| 353 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 354 | this->receiveNack(nack); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | } // namespace face |
| 358 | } // namespace nfd |