Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 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; |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 137 | ssize_t mtu = this->getTransport()->getMtu(); |
| 138 | |
| 139 | // Make space for feature fields in fragments |
| 140 | if (m_options.reliabilityOptions.isEnabled && mtu != MTU_UNLIMITED) { |
| 141 | mtu -= LpReliability::RESERVED_HEADER_SPACE; |
| 142 | BOOST_ASSERT(mtu > 0); |
| 143 | } |
| 144 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 145 | if (m_options.allowFragmentation && mtu != MTU_UNLIMITED) { |
| 146 | bool isOk = false; |
| 147 | std::tie(isOk, frags) = m_fragmenter.fragmentPacket(pkt, mtu); |
| 148 | if (!isOk) { |
| 149 | // fragmentation failed (warning is logged by LpFragmenter) |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 150 | ++this->nFragmentationErrors; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 151 | return; |
| 152 | } |
| 153 | } |
| 154 | else { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 155 | frags.push_back(std::move(pkt)); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 156 | } |
| 157 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 158 | if (frags.size() == 1) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 159 | // even if indexed fragmentation is enabled, the fragmenter should not |
| 160 | // fragment the packet if it can fit in MTU |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 161 | BOOST_ASSERT(!frags.front().has<lp::FragIndexField>()); |
| 162 | BOOST_ASSERT(!frags.front().has<lp::FragCountField>()); |
| 163 | } |
| 164 | |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 165 | // Only assign sequences to fragments if packet contains more than 1 fragment |
| 166 | if (frags.size() > 1) { |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 167 | // Assign sequences to all fragments |
| 168 | this->assignSequences(frags); |
| 169 | } |
| 170 | |
| 171 | if (m_options.reliabilityOptions.isEnabled && frags.front().has<lp::FragmentField>()) { |
Eric Newberry | 7b0071e | 2017-07-03 17:33:31 +0000 | [diff] [blame^] | 172 | m_reliability.handleOutgoing(frags); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | for (lp::Packet& frag : frags) { |
| 176 | this->sendLpPacket(std::move(frag)); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 177 | } |
| 178 | } |
| 179 | |
| 180 | void |
| 181 | GenericLinkService::assignSequence(lp::Packet& pkt) |
| 182 | { |
| 183 | pkt.set<lp::SequenceField>(++m_lastSeqNo); |
| 184 | } |
| 185 | |
| 186 | void |
| 187 | GenericLinkService::assignSequences(std::vector<lp::Packet>& pkts) |
| 188 | { |
| 189 | std::for_each(pkts.begin(), pkts.end(), bind(&GenericLinkService::assignSequence, this, _1)); |
| 190 | } |
| 191 | |
| 192 | void |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 193 | GenericLinkService::doReceivePacket(Transport::Packet&& packet) |
| 194 | { |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 195 | try { |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 196 | lp::Packet pkt(packet.packet); |
| 197 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 198 | if (m_options.reliabilityOptions.isEnabled) { |
| 199 | m_reliability.processIncomingPacket(pkt); |
| 200 | } |
| 201 | |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 202 | if (!pkt.has<lp::FragmentField>()) { |
| 203 | NFD_LOG_FACE_TRACE("received IDLE packet: DROP"); |
| 204 | return; |
| 205 | } |
| 206 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 207 | if ((pkt.has<lp::FragIndexField>() || pkt.has<lp::FragCountField>()) && |
| 208 | !m_options.allowReassembly) { |
| 209 | NFD_LOG_FACE_WARN("received fragment, but reassembly disabled: DROP"); |
Eric Newberry | a1939ba | 2015-10-09 12:35:03 -0700 | [diff] [blame] | 210 | return; |
| 211 | } |
| 212 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 213 | bool isReassembled = false; |
| 214 | Block netPkt; |
| 215 | lp::Packet firstPkt; |
| 216 | std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.receiveFragment(packet.remoteEndpoint, |
| 217 | pkt); |
| 218 | if (isReassembled) { |
| 219 | this->decodeNetPacket(netPkt, firstPkt); |
| 220 | } |
| 221 | } |
| 222 | catch (const tlv::Error& e) { |
| 223 | ++this->nInLpInvalid; |
| 224 | NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP"); |
| 225 | } |
| 226 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 227 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 228 | void |
| 229 | GenericLinkService::decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt) |
| 230 | { |
| 231 | try { |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 232 | switch (netPkt.type()) { |
| 233 | case tlv::Interest: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 234 | if (firstPkt.has<lp::NackField>()) { |
| 235 | this->decodeNack(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 236 | } |
| 237 | else { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 238 | this->decodeInterest(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 239 | } |
| 240 | break; |
| 241 | case tlv::Data: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 242 | this->decodeData(netPkt, firstPkt); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 243 | break; |
| 244 | default: |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 245 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 246 | NFD_LOG_FACE_WARN("unrecognized network-layer packet TLV-TYPE " << netPkt.type() << ": DROP"); |
| 247 | return; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 248 | } |
| 249 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 250 | catch (const tlv::Error& e) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 251 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 252 | NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP"); |
| 253 | } |
| 254 | } |
| 255 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 256 | void |
| 257 | GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstPkt) |
| 258 | { |
| 259 | BOOST_ASSERT(netPkt.type() == tlv::Interest); |
| 260 | BOOST_ASSERT(!firstPkt.has<lp::NackField>()); |
| 261 | |
| 262 | // forwarding expects Interest to be created with make_shared |
| 263 | auto interest = make_shared<Interest>(netPkt); |
| 264 | |
| 265 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
| 266 | if (m_options.allowLocalFields) { |
Junxiao Shi | 0de23a2 | 2015-12-03 20:07:02 +0000 | [diff] [blame] | 267 | interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>())); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 268 | } |
| 269 | else { |
| 270 | NFD_LOG_FACE_WARN("received NextHopFaceId, but local fields disabled: DROP"); |
| 271 | return; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | if (firstPkt.has<lp::CachePolicyField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 276 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 277 | NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP"); |
| 278 | return; |
| 279 | } |
| 280 | |
| 281 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 282 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 283 | } |
| 284 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 285 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 286 | interest->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 287 | } |
| 288 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 289 | this->receiveInterest(*interest); |
| 290 | } |
| 291 | |
| 292 | void |
| 293 | GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt) |
| 294 | { |
| 295 | BOOST_ASSERT(netPkt.type() == tlv::Data); |
| 296 | |
| 297 | // forwarding expects Data to be created with make_shared |
| 298 | auto data = make_shared<Data>(netPkt); |
| 299 | |
| 300 | if (firstPkt.has<lp::NackField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 301 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 302 | NFD_LOG_FACE_WARN("received Nack with Data: DROP"); |
| 303 | return; |
| 304 | } |
| 305 | |
| 306 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 307 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 308 | NFD_LOG_FACE_WARN("received NextHopFaceId with Data: DROP"); |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | if (firstPkt.has<lp::CachePolicyField>()) { |
Junxiao Shi | 6eb0271 | 2017-05-27 22:48:02 +0000 | [diff] [blame] | 313 | // CachePolicy is unprivileged and does not require allowLocalFields option. |
| 314 | // In case of an invalid CachePolicyType, get<lp::CachePolicyField> will throw, |
| 315 | // so it's unnecessary to check here. |
| 316 | data->setTag(make_shared<lp::CachePolicyTag>(firstPkt.get<lp::CachePolicyField>())); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 320 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 321 | } |
| 322 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 323 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 324 | data->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 325 | } |
| 326 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 327 | this->receiveData(*data); |
| 328 | } |
| 329 | |
| 330 | void |
| 331 | GenericLinkService::decodeNack(const Block& netPkt, const lp::Packet& firstPkt) |
| 332 | { |
| 333 | BOOST_ASSERT(netPkt.type() == tlv::Interest); |
| 334 | BOOST_ASSERT(firstPkt.has<lp::NackField>()); |
| 335 | |
| 336 | lp::Nack nack((Interest(netPkt))); |
| 337 | nack.setHeader(firstPkt.get<lp::NackField>()); |
| 338 | |
| 339 | if (firstPkt.has<lp::NextHopFaceIdField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 340 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 341 | NFD_LOG_FACE_WARN("received NextHopFaceId with Nack: DROP"); |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | if (firstPkt.has<lp::CachePolicyField>()) { |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 346 | ++this->nInNetInvalid; |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 347 | NFD_LOG_FACE_WARN("received CachePolicy with Nack: DROP"); |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | if (firstPkt.has<lp::IncomingFaceIdField>()) { |
| 352 | NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE"); |
| 353 | } |
| 354 | |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 355 | if (firstPkt.has<lp::CongestionMarkField>()) { |
| 356 | nack.setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>())); |
| 357 | } |
| 358 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 359 | this->receiveNack(nack); |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 360 | } |
| 361 | |
| 362 | } // namespace face |
| 363 | } // namespace nfd |