blob: aaf8b63ed380e0c796f037f6e1be0c25daa0c407 [file] [log] [blame]
Alexander Afanasyevc169a812014-05-20 20:37:29 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Junxiao Shi4460e822017-08-07 22:02:45 +00002/*
Alexander Afanasyev4c9a3d52017-01-03 17:45:19 -08003 * Copyright (c) 2013-2017 Regents of the University of California.
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07004 *
5 * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
Alexander Afanasyevdfa52c42014-04-24 21:10:11 -07006 *
Alexander Afanasyevc169a812014-05-20 20:37:29 -04007 * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later version.
10 *
11 * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14 *
15 * You should have received copies of the GNU General Public License and GNU Lesser
16 * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17 * <http://www.gnu.org/licenses/>.
18 *
19 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070020 */
21
Alexander Afanasyev09c613f2014-01-29 00:23:58 -080022#include "face.hpp"
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -070023#include "detail/face-impl.hpp"
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070024
Junxiao Shi468abc32014-11-04 09:12:47 -070025#include "encoding/tlv.hpp"
Junxiao Shi25467942017-06-30 02:53:14 +000026#include "net/face-uri.hpp"
Junxiao Shic6acc7a2015-06-23 10:03:56 -070027#include "security/signing-helpers.hpp"
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080028#include "util/random.hpp"
Junxiao Shi4460e822017-08-07 22:02:45 +000029#include "util/time.hpp"
30
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080031#include "ns3/node-list.h"
32#include "ns3/ndnSIM/helper/ndn-stack-helper.hpp"
33#include "ns3/ndnSIM/NFD/daemon/face/generic-link-service.hpp"
34#include "ns3/ndnSIM/NFD/daemon/face/internal-transport.hpp"
35
Junxiao Shi4460e822017-08-07 22:02:45 +000036// NDN_LOG_INIT(ndn.Face) is declared in face-impl.hpp
Jeff Thompsonb982b6d2013-07-15 18:15:45 -070037
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080038// A callback scheduled through io.post and io.dispatch may be invoked after the face
39// is destructed. To prevent this situation, these macros captures Face::m_impl as weak_ptr,
40// and skips callback execution if the face has been destructed.
41
Junxiao Shiae0b4182016-08-08 22:53:17 +000042#define IO_CAPTURE_WEAK_IMPL(OP) \
43 { \
44 weak_ptr<Impl> implWeak(m_impl); \
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080045 m_impl->m_scheduler.scheduleEvent(time::seconds(0), [=] { \
Junxiao Shiae0b4182016-08-08 22:53:17 +000046 auto impl = implWeak.lock(); \
47 if (impl != nullptr) {
48#define IO_CAPTURE_WEAK_IMPL_END \
49 } \
50 }); \
51 }
52
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -070053namespace ndn {
Alexander Afanasyevb790d952014-01-24 12:07:53 -080054
Junxiao Shib6e276f2017-08-14 20:10:04 +000055Face::OversizedPacketError::OversizedPacketError(char pktType, const Name& name, size_t wireSize)
56 : Error((pktType == 'I' ? "Interest " : pktType == 'D' ? "Data " : "Nack ") +
57 name.toUri() + " encodes into " + to_string(wireSize) + " octets, "
58 "exceeding the implementation limit of " + to_string(MAX_NDN_PACKET_SIZE) + " octets")
59 , pktType(pktType)
60 , name(name)
61 , wireSize(wireSize)
62{
63}
64
Junxiao Shi103d8ed2016-08-07 20:34:10 +000065Face::Face(shared_ptr<Transport> transport)
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080066 : m_impl(new Impl(*this))
Jeff Thompsonfb29cda2013-08-24 10:26:54 -070067{
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080068 construct(transport, ns3::ndn::StackHelper::getKeyChain());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080069}
70
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -070071Face::Face(boost::asio::io_service& ioService)
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080072 : m_impl(new Impl(*this))
Alexander Afanasyev691c3ce2014-04-23 14:28:04 -070073{
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080074 construct(nullptr, ns3::ndn::StackHelper::getKeyChain());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080075}
76
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070077Face::Face(shared_ptr<Transport> transport, KeyChain& keyChain)
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080078 : m_impl(new Impl(*this))
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070079{
Junxiao Shib6e276f2017-08-14 20:10:04 +000080 construct(std::move(transport), keyChain);
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070081}
82
83Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService)
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080084 : m_impl(new Impl(*this))
Alexander Afanasyev0222fba2014-02-09 23:16:02 -080085{
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080086 construct(transport, ns3::ndn::StackHelper::getKeyChain());
Junxiao Shiedd834e2014-10-28 20:28:58 -070087}
88
Alexander Afanasyev8cf1c562016-06-23 16:01:55 -070089Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService, KeyChain& keyChain)
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080090 : m_impl(new Impl(*this))
Junxiao Shiedd834e2014-10-28 20:28:58 -070091{
Junxiao Shib6e276f2017-08-14 20:10:04 +000092 construct(std::move(transport), keyChain);
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -080093}
94
Alexander Afanasyevbb64c172015-12-29 20:32:45 -080095shared_ptr<Transport>
96Face::makeDefaultTransport()
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -070097{
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -080098 ns3::Ptr<ns3::Node> node = ns3::NodeList::GetNode(ns3::Simulator::GetContext());
99 NS_ASSERT_MSG(node->GetObject<ns3::ndn::L3Protocol>() != 0,
100 "NDN stack should be installed on the node " << node);
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700101
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -0800102 auto uri = ::nfd::FaceUri("ndnFace://" + boost::lexical_cast<std::string>(node->GetId()));
Alexander Afanasyev57e00362016-06-23 13:22:54 -0700103
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -0800104 ::nfd::face::GenericLinkService::Options serviceOpts;
105 serviceOpts.allowLocalFields = true;
Alexander Afanasyev57e00362016-06-23 13:22:54 -0700106
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -0800107 auto nfdFace = make_shared<::nfd::Face>(make_unique<::nfd::face::GenericLinkService>(serviceOpts),
108 make_unique<::nfd::face::InternalForwarderTransport>(uri, uri));
109 auto forwarderTransport = static_cast<::nfd::face::InternalForwarderTransport*>(nfdFace->getTransport());
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700110
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -0800111 auto clientTransport = make_shared<::nfd::face::InternalClientTransport>();
112 clientTransport->connectToForwarder(forwarderTransport);
Alexander Afanasyev57e00362016-06-23 13:22:54 -0700113
Spyridon Mastorakis7bb7eb42016-11-28 18:03:05 -0800114 node->GetObject<ns3::ndn::L3Protocol>()->addFace(nfdFace);;
115
116 return clientTransport;
Steve DiBenedettoa8659ff2014-12-04 14:50:28 -0700117}
118
119void
Joao Pereira68c0d882015-05-19 14:27:55 -0400120Face::construct(shared_ptr<Transport> transport, KeyChain& keyChain)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800121{
Alexander Afanasyevbb64c172015-12-29 20:32:45 -0800122 if (transport == nullptr) {
123 transport = makeDefaultTransport();
124 }
125 BOOST_ASSERT(transport != nullptr);
Junxiao Shib6e276f2017-08-14 20:10:04 +0000126 m_transport = std::move(transport);
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800127
Junxiao Shib6e276f2017-08-14 20:10:04 +0000128 m_nfdController = make_unique<nfd::Controller>(*this, keyChain);
Alexander Afanasyevbb64c172015-12-29 20:32:45 -0800129
Junxiao Shiae0b4182016-08-08 22:53:17 +0000130 IO_CAPTURE_WEAK_IMPL(post) {
131 impl->ensureConnected(false);
132 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800133}
134
Joao Pereira68c0d882015-05-19 14:27:55 -0400135Face::~Face() = default;
Junxiao Shiedd834e2014-10-28 20:28:58 -0700136
Alexander Afanasyev3a6da362015-12-29 20:31:03 -0800137shared_ptr<Transport>
138Face::getTransport()
139{
140 return m_transport;
141}
142
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800143const PendingInterestId*
Eric Newberry83872fd2015-08-06 17:01:24 -0700144Face::expressInterest(const Interest& interest,
145 const DataCallback& afterSatisfied,
146 const NackCallback& afterNacked,
147 const TimeoutCallback& afterTimeout)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800148{
Junxiao Shib6e276f2017-08-14 20:10:04 +0000149 shared_ptr<Interest> interest2 = make_shared<Interest>(interest);
150 interest2->getNonce();
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800151
Junxiao Shiae0b4182016-08-08 22:53:17 +0000152 IO_CAPTURE_WEAK_IMPL(dispatch) {
Junxiao Shib6e276f2017-08-14 20:10:04 +0000153 impl->asyncExpressInterest(interest2, afterSatisfied, afterNacked, afterTimeout);
Junxiao Shiae0b4182016-08-08 22:53:17 +0000154 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800155
Junxiao Shib6e276f2017-08-14 20:10:04 +0000156 return reinterpret_cast<const PendingInterestId*>(interest2.get());
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800157}
158
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800159void
Junxiao Shiae0b4182016-08-08 22:53:17 +0000160Face::removePendingInterest(const PendingInterestId* pendingInterestId)
161{
162 IO_CAPTURE_WEAK_IMPL(post) {
163 impl->asyncRemovePendingInterest(pendingInterestId);
164 } IO_CAPTURE_WEAK_IMPL_END
165}
166
167void
168Face::removeAllPendingInterests()
169{
170 IO_CAPTURE_WEAK_IMPL(post) {
171 impl->asyncRemoveAllPendingInterests();
172 } IO_CAPTURE_WEAK_IMPL_END
173}
174
175size_t
176Face::getNPendingInterests() const
177{
178 return m_impl->m_pendingInterestTable.size();
179}
180
181void
Junxiao Shib6e276f2017-08-14 20:10:04 +0000182Face::put(Data data)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800183{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000184 IO_CAPTURE_WEAK_IMPL(dispatch) {
Junxiao Shib6e276f2017-08-14 20:10:04 +0000185 impl->asyncPutData(data);
Junxiao Shiae0b4182016-08-08 22:53:17 +0000186 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800187}
188
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800189void
Junxiao Shib6e276f2017-08-14 20:10:04 +0000190Face::put(lp::Nack nack)
Eric Newberry83872fd2015-08-06 17:01:24 -0700191{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000192 IO_CAPTURE_WEAK_IMPL(dispatch) {
Junxiao Shib6e276f2017-08-14 20:10:04 +0000193 impl->asyncPutNack(nack);
Junxiao Shiae0b4182016-08-08 22:53:17 +0000194 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev6fcdde22014-08-22 19:03:36 -0700195}
196
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800197const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000198Face::setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000199 const InterestCallback& onInterest,
200 const RegisterPrefixFailureCallback& onFailure,
201 const security::SigningInfo& signingInfo,
202 uint64_t flags)
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700203{
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000204 return setInterestFilter(interestFilter, onInterest, nullptr, onFailure, signingInfo, flags);
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700205}
206
207const RegisteredPrefixId*
Alexander Afanasyev90164962014-03-06 08:29:59 +0000208Face::setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000209 const InterestCallback& onInterest,
210 const RegisterPrefixSuccessCallback& onSuccess,
211 const RegisterPrefixFailureCallback& onFailure,
212 const security::SigningInfo& signingInfo,
213 uint64_t flags)
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700214{
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000215 auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest);
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700216
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000217 nfd::CommandOptions options;
218 options.setSigningInfo(signingInfo);
Junxiao Shi388ec252014-11-02 15:19:57 -0700219
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000220 return m_impl->registerPrefix(interestFilter.getPrefix(), filter,
221 onSuccess, onFailure, flags, options);
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700222}
223
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700224const InterestFilterId*
225Face::setInterestFilter(const InterestFilter& interestFilter,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000226 const InterestCallback& onInterest)
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700227{
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000228 auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest);
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700229
Junxiao Shiae0b4182016-08-08 22:53:17 +0000230 IO_CAPTURE_WEAK_IMPL(post) {
231 impl->asyncSetInterestFilter(filter);
232 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700233
234 return reinterpret_cast<const InterestFilterId*>(filter.get());
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700235}
236
Joao Pereira0b3cac52015-07-02 14:49:49 -0400237const RegisteredPrefixId*
238Face::registerPrefix(const Name& prefix,
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000239 const RegisterPrefixSuccessCallback& onSuccess,
240 const RegisterPrefixFailureCallback& onFailure,
241 const security::SigningInfo& signingInfo,
242 uint64_t flags)
Joao Pereira0b3cac52015-07-02 14:49:49 -0400243{
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000244 nfd::CommandOptions options;
245 options.setSigningInfo(signingInfo);
Joao Pereira0b3cac52015-07-02 14:49:49 -0400246
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000247 return m_impl->registerPrefix(prefix, nullptr, onSuccess, onFailure, flags, options);
Joao Pereira0b3cac52015-07-02 14:49:49 -0400248}
249
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700250void
Alexander Afanasyev7682ccb2014-02-20 10:29:35 -0800251Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800252{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000253 IO_CAPTURE_WEAK_IMPL(post) {
254 impl->asyncUnregisterPrefix(registeredPrefixId, nullptr, nullptr);
255 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800256}
257
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700258void
259Face::unsetInterestFilter(const InterestFilterId* interestFilterId)
260{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000261 IO_CAPTURE_WEAK_IMPL(post) {
262 impl->asyncUnsetInterestFilter(interestFilterId);
263 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700264}
Yingdi Yue66bf2a2014-04-28 17:07:36 -0700265
266void
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700267Face::unregisterPrefix(const RegisteredPrefixId* registeredPrefixId,
268 const UnregisterPrefixSuccessCallback& onSuccess,
269 const UnregisterPrefixFailureCallback& onFailure)
270{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000271 IO_CAPTURE_WEAK_IMPL(post) {
272 impl->asyncUnregisterPrefix(registeredPrefixId, onSuccess, onFailure);
273 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700274}
275
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800276void
Junxiao Shi2ed9e072017-08-13 16:45:48 +0000277Face::doProcessEvents(time::milliseconds timeout, bool keepThread)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800278{
Jeff Thompsonfb29cda2013-08-24 10:26:54 -0700279}
280
Alexander Afanasyeva68aa7f2014-02-11 15:42:33 -0800281void
Jeff Thompson0050abe2013-09-17 12:50:25 -0700282Face::shutdown()
Jeff Thompson517ffa82013-08-05 16:04:34 -0700283{
Junxiao Shiae0b4182016-08-08 22:53:17 +0000284 IO_CAPTURE_WEAK_IMPL(post) {
285 this->asyncShutdown();
286 } IO_CAPTURE_WEAK_IMPL_END
Alexander Afanasyev7dced462014-03-19 15:12:32 -0700287}
288
289void
290Face::asyncShutdown()
291{
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700292 m_impl->m_pendingInterestTable.clear();
293 m_impl->m_registeredPrefixTable.clear();
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800294
Alexander Afanasyev984ad192014-05-02 19:11:15 -0700295 if (m_transport->isConnected())
296 m_transport->close();
Jeff Thompsonaa4e6db2013-07-15 17:25:23 -0700297}
298
Eric Newberry83872fd2015-08-06 17:01:24 -0700299/**
300 * @brief extract local fields from NDNLPv2 packet and tag onto a network layer packet
301 */
Eric Newberry4d261b62016-11-10 13:40:09 -0700302template<typename NetPkt>
Eric Newberry83872fd2015-08-06 17:01:24 -0700303static void
Eric Newberry4d261b62016-11-10 13:40:09 -0700304extractLpLocalFields(NetPkt& netPacket, const lp::Packet& lpPacket)
Eric Newberry83872fd2015-08-06 17:01:24 -0700305{
Junxiao Shib38e6d42017-08-16 16:15:28 +0000306 addTagFromField<lp::IncomingFaceIdTag, lp::IncomingFaceIdField>(netPacket, lpPacket);
307 addTagFromField<lp::CongestionMarkTag, lp::CongestionMarkField>(netPacket, lpPacket);
Spyridon Mastorakise1ae0962016-12-06 15:21:44 -0800308
309 if (lpPacket.has<lp::HopCountTagField>()) {
310 netPacket.setTag(make_shared<lp::HopCountTag>(lpPacket.get<lp::HopCountTagField>() + 1));
311 }
Eric Newberry83872fd2015-08-06 17:01:24 -0700312}
313
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800314void
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800315Face::onReceiveElement(const Block& blockFromDaemon)
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800316{
Eric Newberry83872fd2015-08-06 17:01:24 -0700317 lp::Packet lpPacket(blockFromDaemon); // bare Interest/Data is a valid lp::Packet,
318 // no need to distinguish
Alexander Afanasyev6d48bc12014-02-18 00:10:51 -0800319
Eric Newberry83872fd2015-08-06 17:01:24 -0700320 Buffer::const_iterator begin, end;
321 std::tie(begin, end) = lpPacket.get<lp::FragmentField>();
322 Block netPacket(&*begin, std::distance(begin, end));
323 switch (netPacket.type()) {
324 case tlv::Interest: {
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000325 auto interest = make_shared<Interest>(netPacket);
Eric Newberry83872fd2015-08-06 17:01:24 -0700326 if (lpPacket.has<lp::NackField>()) {
327 auto nack = make_shared<lp::Nack>(std::move(*interest));
328 nack->setHeader(lpPacket.get<lp::NackField>());
329 extractLpLocalFields(*nack, lpPacket);
Junxiao Shi4460e822017-08-07 22:02:45 +0000330 NDN_LOG_DEBUG(">N " << nack->getInterest() << '~' << nack->getHeader().getReason());
Eric Newberry83872fd2015-08-06 17:01:24 -0700331 m_impl->nackPendingInterests(*nack);
332 }
333 else {
334 extractLpLocalFields(*interest, lpPacket);
Junxiao Shi4460e822017-08-07 22:02:45 +0000335 NDN_LOG_DEBUG(">I " << *interest);
Junxiao Shi1ad0b4b2017-08-18 14:19:14 +0000336 m_impl->processIncomingInterest(std::move(interest));
Eric Newberry83872fd2015-08-06 17:01:24 -0700337 }
338 break;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800339 }
Eric Newberry83872fd2015-08-06 17:01:24 -0700340 case tlv::Data: {
Junxiao Shi103d8ed2016-08-07 20:34:10 +0000341 auto data = make_shared<Data>(netPacket);
Eric Newberry83872fd2015-08-06 17:01:24 -0700342 extractLpLocalFields(*data, lpPacket);
Junxiao Shi4460e822017-08-07 22:02:45 +0000343 NDN_LOG_DEBUG(">D " << data->getName());
Alexander Afanasyev258ec2b2014-05-14 16:15:37 -0700344 m_impl->satisfyPendingInterests(*data);
Eric Newberry83872fd2015-08-06 17:01:24 -0700345 break;
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800346 }
Eric Newberry83872fd2015-08-06 17:01:24 -0700347 }
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800348}
349
Alexander Afanasyev0222fba2014-02-09 23:16:02 -0800350} // namespace ndn