Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 2 | /** |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2016 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * 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 Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 22 | #include "face.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 23 | #include "detail/face-impl.hpp" |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 24 | |
Junxiao Shi | 468abc3 | 2014-11-04 09:12:47 -0700 | [diff] [blame] | 25 | #include "encoding/tlv.hpp" |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 26 | #include "security/key-chain.hpp" |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 27 | #include "security/signing-helpers.hpp" |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 28 | #include "util/time.hpp" |
| 29 | #include "util/random.hpp" |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 30 | #include "util/face-uri.hpp" |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 31 | |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 32 | // A callback scheduled through io.post and io.dispatch may be invoked after the face |
| 33 | // is destructed. To prevent this situation, these macros captures Face::m_impl as weak_ptr, |
| 34 | // and skips callback execution if the face has been destructed. |
| 35 | #define IO_CAPTURE_WEAK_IMPL(OP) \ |
| 36 | { \ |
| 37 | weak_ptr<Impl> implWeak(m_impl); \ |
| 38 | m_ioService.OP([=] { \ |
| 39 | auto impl = implWeak.lock(); \ |
| 40 | if (impl != nullptr) { |
| 41 | #define IO_CAPTURE_WEAK_IMPL_END \ |
| 42 | } \ |
| 43 | }); \ |
| 44 | } |
| 45 | |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 46 | namespace ndn { |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 47 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 48 | Face::Face(shared_ptr<Transport> transport) |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 49 | : m_internalIoService(new boost::asio::io_service()) |
| 50 | , m_ioService(*m_internalIoService) |
| 51 | , m_internalKeyChain(new KeyChain()) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 52 | , m_impl(make_shared<Impl>(*this)) |
Jeff Thompson | fb29cda | 2013-08-24 10:26:54 -0700 | [diff] [blame] | 53 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 54 | construct(transport, *m_internalKeyChain); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 55 | } |
| 56 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 57 | Face::Face(boost::asio::io_service& ioService) |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 58 | : m_ioService(ioService) |
| 59 | , m_internalKeyChain(new KeyChain()) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 60 | , m_impl(make_shared<Impl>(*this)) |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 61 | { |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 62 | construct(nullptr, *m_internalKeyChain); |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 63 | } |
| 64 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 65 | Face::Face(const std::string& host, const std::string& port) |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 66 | : m_internalIoService(new boost::asio::io_service()) |
| 67 | , m_ioService(*m_internalIoService) |
| 68 | , m_internalKeyChain(new KeyChain()) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 69 | , m_impl(make_shared<Impl>(*this)) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 70 | { |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 71 | construct(make_shared<TcpTransport>(host, port), *m_internalKeyChain); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 72 | } |
| 73 | |
Alexander Afanasyev | 8cf1c56 | 2016-06-23 16:01:55 -0700 | [diff] [blame] | 74 | Face::Face(shared_ptr<Transport> transport, KeyChain& keyChain) |
| 75 | : m_internalIoService(new boost::asio::io_service()) |
| 76 | , m_ioService(*m_internalIoService) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 77 | , m_impl(make_shared<Impl>(*this)) |
Alexander Afanasyev | 8cf1c56 | 2016-06-23 16:01:55 -0700 | [diff] [blame] | 78 | { |
| 79 | construct(transport, keyChain); |
| 80 | } |
| 81 | |
| 82 | Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService) |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 83 | : m_ioService(ioService) |
| 84 | , m_internalKeyChain(new KeyChain()) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 85 | , m_impl(make_shared<Impl>(*this)) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 86 | { |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 87 | construct(transport, *m_internalKeyChain); |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Alexander Afanasyev | 8cf1c56 | 2016-06-23 16:01:55 -0700 | [diff] [blame] | 90 | Face::Face(shared_ptr<Transport> transport, boost::asio::io_service& ioService, KeyChain& keyChain) |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 91 | : m_ioService(ioService) |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 92 | , m_impl(make_shared<Impl>(*this)) |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 93 | { |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 94 | construct(transport, keyChain); |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 95 | } |
| 96 | |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 97 | shared_ptr<Transport> |
| 98 | Face::makeDefaultTransport() |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 99 | { |
| 100 | // transport=unix:///var/run/nfd.sock |
| 101 | // transport=tcp://localhost:6363 |
| 102 | |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 103 | std::string transportUri; |
| 104 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 105 | const char* transportEnviron = getenv("NDN_CLIENT_TRANSPORT"); |
| 106 | if (transportEnviron != nullptr) { |
| 107 | transportUri = transportEnviron; |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 108 | } |
| 109 | else { |
| 110 | ConfigFile config; |
| 111 | transportUri = config.getParsedConfiguration().get<std::string>("transport", ""); |
| 112 | } |
| 113 | |
| 114 | if (transportUri.empty()) { |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 115 | // transport not specified, use default Unix transport. |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 116 | return UnixTransport::create(""); |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 117 | } |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 118 | |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 119 | std::string protocol; |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 120 | try { |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 121 | util::FaceUri uri(transportUri); |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 122 | protocol = uri.getScheme(); |
Alexander Afanasyev | 57e0036 | 2016-06-23 13:22:54 -0700 | [diff] [blame] | 123 | |
| 124 | if (protocol == "unix") { |
| 125 | return UnixTransport::create(transportUri); |
| 126 | } |
| 127 | else if (protocol == "tcp" || protocol == "tcp4" || protocol == "tcp6") { |
| 128 | return TcpTransport::create(transportUri); |
| 129 | } |
| 130 | else { |
| 131 | BOOST_THROW_EXCEPTION(ConfigFile::Error("Unsupported transport protocol \"" + protocol + "\"")); |
| 132 | } |
| 133 | } |
| 134 | catch (const Transport::Error& error) { |
| 135 | BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what())); |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 136 | } |
| 137 | catch (const util::FaceUri::Error& error) { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 138 | BOOST_THROW_EXCEPTION(ConfigFile::Error(error.what())); |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 139 | } |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | void |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 143 | Face::construct(shared_ptr<Transport> transport, KeyChain& keyChain) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 144 | { |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 145 | if (transport == nullptr) { |
| 146 | transport = makeDefaultTransport(); |
| 147 | } |
| 148 | BOOST_ASSERT(transport != nullptr); |
Alexander Afanasyev | f39c537 | 2014-02-17 19:42:56 -0800 | [diff] [blame] | 149 | m_transport = transport; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 150 | |
Alexander Afanasyev | bb64c17 | 2015-12-29 20:32:45 -0800 | [diff] [blame] | 151 | m_nfdController.reset(new nfd::Controller(*this, keyChain)); |
| 152 | |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 153 | IO_CAPTURE_WEAK_IMPL(post) { |
| 154 | impl->ensureConnected(false); |
| 155 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 156 | } |
| 157 | |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 158 | Face::~Face() = default; |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 159 | |
Alexander Afanasyev | 3a6da36 | 2015-12-29 20:31:03 -0800 | [diff] [blame] | 160 | shared_ptr<Transport> |
| 161 | Face::getTransport() |
| 162 | { |
| 163 | return m_transport; |
| 164 | } |
| 165 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 166 | const PendingInterestId* |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 167 | Face::expressInterest(const Interest& interest, |
| 168 | const DataCallback& afterSatisfied, |
| 169 | const NackCallback& afterNacked, |
| 170 | const TimeoutCallback& afterTimeout) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 171 | { |
Alexander Afanasyev | f73f063 | 2014-05-12 18:02:37 -0700 | [diff] [blame] | 172 | shared_ptr<Interest> interestToExpress = make_shared<Interest>(interest); |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 173 | |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 174 | // Use `interestToExpress` to avoid wire format creation for the original Interest |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 175 | if (interestToExpress->wireEncode().size() > MAX_NDN_PACKET_SIZE) { |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 176 | BOOST_THROW_EXCEPTION(Error("Interest size exceeds maximum limit")); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 177 | } |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 178 | |
Alexander Afanasyev | 4e50b97 | 2014-03-25 10:57:50 -0700 | [diff] [blame] | 179 | // If the same ioService thread, dispatch directly calls the method |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 180 | IO_CAPTURE_WEAK_IMPL(dispatch) { |
| 181 | impl->asyncExpressInterest(interestToExpress, afterSatisfied, afterNacked, afterTimeout); |
| 182 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 183 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 184 | return reinterpret_cast<const PendingInterestId*>(interestToExpress.get()); |
| 185 | } |
| 186 | |
| 187 | const PendingInterestId* |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 188 | Face::expressInterest(const Interest& interest, |
| 189 | const OnData& onData, |
| 190 | const OnTimeout& onTimeout) |
| 191 | { |
| 192 | return this->expressInterest( |
| 193 | interest, |
| 194 | [onData] (const Interest& interest, const Data& data) { |
| 195 | if (onData != nullptr) { |
| 196 | onData(interest, const_cast<Data&>(data)); |
| 197 | } |
| 198 | }, |
| 199 | [onTimeout] (const Interest& interest, const lp::Nack& nack) { |
| 200 | if (onTimeout != nullptr) { |
| 201 | onTimeout(interest); |
| 202 | } |
| 203 | }, |
| 204 | onTimeout |
| 205 | ); |
| 206 | } |
| 207 | |
| 208 | const PendingInterestId* |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 209 | Face::expressInterest(const Name& name, const Interest& tmpl, |
| 210 | const OnData& onData, const OnTimeout& onTimeout) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 211 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 212 | return expressInterest(Interest(tmpl).setName(name).setNonce(0), |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 213 | onData, onTimeout); |
| 214 | } |
| 215 | |
| 216 | void |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 217 | Face::removePendingInterest(const PendingInterestId* pendingInterestId) |
| 218 | { |
| 219 | IO_CAPTURE_WEAK_IMPL(post) { |
| 220 | impl->asyncRemovePendingInterest(pendingInterestId); |
| 221 | } IO_CAPTURE_WEAK_IMPL_END |
| 222 | } |
| 223 | |
| 224 | void |
| 225 | Face::removeAllPendingInterests() |
| 226 | { |
| 227 | IO_CAPTURE_WEAK_IMPL(post) { |
| 228 | impl->asyncRemoveAllPendingInterests(); |
| 229 | } IO_CAPTURE_WEAK_IMPL_END |
| 230 | } |
| 231 | |
| 232 | size_t |
| 233 | Face::getNPendingInterests() const |
| 234 | { |
| 235 | return m_impl->m_pendingInterestTable.size(); |
| 236 | } |
| 237 | |
| 238 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 239 | Face::put(const Data& data) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 240 | { |
Junxiao Shi | e7bb6c8 | 2016-08-08 23:16:35 +0000 | [diff] [blame] | 241 | Block wire = data.wireEncode(); |
| 242 | |
| 243 | shared_ptr<lp::CachePolicyTag> cachePolicyTag = data.getTag<lp::CachePolicyTag>(); |
| 244 | if (cachePolicyTag != nullptr) { |
| 245 | lp::Packet packet; |
| 246 | packet.add<lp::CachePolicyField>(*cachePolicyTag); |
| 247 | packet.add<lp::FragmentField>(std::make_pair(wire.begin(), wire.end())); |
| 248 | wire = packet.wireEncode(); |
| 249 | } |
| 250 | |
| 251 | if (wire.size() > MAX_NDN_PACKET_SIZE) |
Spyridon Mastorakis | 0d2ed2e | 2015-07-27 19:09:12 -0700 | [diff] [blame] | 252 | BOOST_THROW_EXCEPTION(Error("Data size exceeds maximum limit")); |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 253 | |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 254 | IO_CAPTURE_WEAK_IMPL(dispatch) { |
Junxiao Shi | e7bb6c8 | 2016-08-08 23:16:35 +0000 | [diff] [blame] | 255 | impl->asyncSend(wire); |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 256 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 257 | } |
| 258 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 259 | void |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 260 | Face::put(const lp::Nack& nack) |
| 261 | { |
Junxiao Shi | e7bb6c8 | 2016-08-08 23:16:35 +0000 | [diff] [blame] | 262 | lp::Packet packet; |
| 263 | packet.add<lp::NackField>(nack.getHeader()); |
| 264 | const Block& interestWire = nack.getInterest().wireEncode(); |
| 265 | packet.add<lp::FragmentField>(std::make_pair(interestWire.begin(), interestWire.end())); |
| 266 | |
| 267 | Block wire = packet.wireEncode(); |
| 268 | |
| 269 | if (wire.size() > MAX_NDN_PACKET_SIZE) |
| 270 | BOOST_THROW_EXCEPTION(Error("Nack size exceeds maximum limit")); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 271 | |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 272 | IO_CAPTURE_WEAK_IMPL(dispatch) { |
Junxiao Shi | e7bb6c8 | 2016-08-08 23:16:35 +0000 | [diff] [blame] | 273 | impl->asyncSend(wire); |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 274 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 6fcdde2 | 2014-08-22 19:03:36 -0700 | [diff] [blame] | 275 | } |
| 276 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 277 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 278 | Face::setInterestFilter(const InterestFilter& interestFilter, |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 279 | const InterestCallback& onInterest, |
| 280 | const RegisterPrefixFailureCallback& onFailure, |
| 281 | const security::SigningInfo& signingInfo, |
| 282 | uint64_t flags) |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 283 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 284 | return setInterestFilter(interestFilter, onInterest, nullptr, onFailure, signingInfo, flags); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 288 | Face::setInterestFilter(const InterestFilter& interestFilter, |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 289 | const InterestCallback& onInterest, |
| 290 | const RegisterPrefixSuccessCallback& onSuccess, |
| 291 | const RegisterPrefixFailureCallback& onFailure, |
| 292 | const security::SigningInfo& signingInfo, |
| 293 | uint64_t flags) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 294 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 295 | auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 296 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 297 | nfd::CommandOptions options; |
| 298 | options.setSigningInfo(signingInfo); |
Junxiao Shi | 388ec25 | 2014-11-02 15:19:57 -0700 | [diff] [blame] | 299 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 300 | return m_impl->registerPrefix(interestFilter.getPrefix(), filter, |
| 301 | onSuccess, onFailure, flags, options); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 304 | const InterestFilterId* |
| 305 | Face::setInterestFilter(const InterestFilter& interestFilter, |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 306 | const InterestCallback& onInterest) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 307 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 308 | auto filter = make_shared<InterestFilterRecord>(interestFilter, onInterest); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 309 | |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 310 | IO_CAPTURE_WEAK_IMPL(post) { |
| 311 | impl->asyncSetInterestFilter(filter); |
| 312 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 313 | |
| 314 | return reinterpret_cast<const InterestFilterId*>(filter.get()); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 317 | #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 318 | |
| 319 | const RegisteredPrefixId* |
| 320 | Face::setInterestFilter(const InterestFilter& interestFilter, |
| 321 | const OnInterest& onInterest, |
| 322 | const RegisterPrefixSuccessCallback& onSuccess, |
| 323 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 324 | const security::v1::IdentityCertificate& certificate, |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 325 | uint64_t flags) |
| 326 | { |
| 327 | security::SigningInfo signingInfo; |
| 328 | if (!certificate.getName().empty()) { |
| 329 | signingInfo = signingByCertificate(certificate.getName()); |
| 330 | } |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 331 | return setInterestFilter(interestFilter, onInterest, onSuccess, onFailure, signingInfo, flags); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | const RegisteredPrefixId* |
| 335 | Face::setInterestFilter(const InterestFilter& interestFilter, |
| 336 | const OnInterest& onInterest, |
| 337 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 338 | const security::v1::IdentityCertificate& certificate, |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 339 | uint64_t flags) |
| 340 | { |
| 341 | security::SigningInfo signingInfo; |
| 342 | if (!certificate.getName().empty()) { |
| 343 | signingInfo = signingByCertificate(certificate.getName()); |
| 344 | } |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 345 | return setInterestFilter(interestFilter, onInterest, onFailure, signingInfo, flags); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | const RegisteredPrefixId* |
| 349 | Face::setInterestFilter(const InterestFilter& interestFilter, |
| 350 | const OnInterest& onInterest, |
| 351 | const RegisterPrefixSuccessCallback& onSuccess, |
| 352 | const RegisterPrefixFailureCallback& onFailure, |
| 353 | const Name& identity, |
| 354 | uint64_t flags) |
| 355 | { |
| 356 | security::SigningInfo signingInfo = signingByIdentity(identity); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 357 | return setInterestFilter(interestFilter, onInterest, |
| 358 | onSuccess, onFailure, |
| 359 | signingInfo, flags); |
| 360 | } |
| 361 | |
| 362 | const RegisteredPrefixId* |
| 363 | Face::setInterestFilter(const InterestFilter& interestFilter, |
| 364 | const OnInterest& onInterest, |
| 365 | const RegisterPrefixFailureCallback& onFailure, |
| 366 | const Name& identity, |
| 367 | uint64_t flags) |
| 368 | { |
| 369 | security::SigningInfo signingInfo = signingByIdentity(identity); |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 370 | return setInterestFilter(interestFilter, onInterest, onFailure, signingInfo, flags); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 374 | |
| 375 | const RegisteredPrefixId* |
| 376 | Face::registerPrefix(const Name& prefix, |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 377 | const RegisterPrefixSuccessCallback& onSuccess, |
| 378 | const RegisterPrefixFailureCallback& onFailure, |
| 379 | const security::SigningInfo& signingInfo, |
| 380 | uint64_t flags) |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 381 | { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 382 | nfd::CommandOptions options; |
| 383 | options.setSigningInfo(signingInfo); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 384 | |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 385 | return m_impl->registerPrefix(prefix, nullptr, onSuccess, onFailure, flags, options); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 389 | const RegisteredPrefixId* |
| 390 | Face::registerPrefix(const Name& prefix, |
| 391 | const RegisterPrefixSuccessCallback& onSuccess, |
| 392 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 2fa5939 | 2016-07-29 17:24:23 -0700 | [diff] [blame] | 393 | const security::v1::IdentityCertificate& certificate, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 394 | uint64_t flags) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 395 | { |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 396 | security::SigningInfo signingInfo; |
Junxiao Shi | c6acc7a | 2015-06-23 10:03:56 -0700 | [diff] [blame] | 397 | if (!certificate.getName().empty()) { |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 398 | signingInfo = signingByCertificate(certificate.getName()); |
Junxiao Shi | 388ec25 | 2014-11-02 15:19:57 -0700 | [diff] [blame] | 399 | } |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 400 | return registerPrefix(prefix, onSuccess, onFailure, signingInfo, flags); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | const RegisteredPrefixId* |
| 404 | Face::registerPrefix(const Name& prefix, |
| 405 | const RegisterPrefixSuccessCallback& onSuccess, |
| 406 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 407 | const Name& identity, |
| 408 | uint64_t flags) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 409 | { |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 410 | security::SigningInfo signingInfo = signingByIdentity(identity); |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 411 | return registerPrefix(prefix, onSuccess, onFailure, signingInfo, flags); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 412 | } |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 413 | #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 414 | |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 415 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 416 | Face::unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 417 | { |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 418 | IO_CAPTURE_WEAK_IMPL(post) { |
| 419 | impl->asyncUnregisterPrefix(registeredPrefixId, nullptr, nullptr); |
| 420 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 421 | } |
| 422 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 423 | void |
| 424 | Face::unsetInterestFilter(const InterestFilterId* interestFilterId) |
| 425 | { |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 426 | IO_CAPTURE_WEAK_IMPL(post) { |
| 427 | impl->asyncUnsetInterestFilter(interestFilterId); |
| 428 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 429 | } |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 430 | |
| 431 | void |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 432 | Face::unregisterPrefix(const RegisteredPrefixId* registeredPrefixId, |
| 433 | const UnregisterPrefixSuccessCallback& onSuccess, |
| 434 | const UnregisterPrefixFailureCallback& onFailure) |
| 435 | { |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 436 | IO_CAPTURE_WEAK_IMPL(post) { |
| 437 | impl->asyncUnregisterPrefix(registeredPrefixId, onSuccess, onFailure); |
| 438 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 441 | void |
Junxiao Shi | c828dfc | 2016-09-15 13:26:22 +0000 | [diff] [blame^] | 442 | Face::doProcessEvents(const time::milliseconds& timeout, bool keepThread) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 443 | { |
Alexander Afanasyev | 8e15854 | 2014-11-18 00:47:18 -0500 | [diff] [blame] | 444 | if (m_ioService.stopped()) { |
| 445 | m_ioService.reset(); // ensure that run()/poll() will do some work |
| 446 | } |
| 447 | |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 448 | try { |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 449 | if (timeout < time::milliseconds::zero()) { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 450 | // do not block if timeout is negative, but process pending events |
| 451 | m_ioService.poll(); |
| 452 | return; |
| 453 | } |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 454 | |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 455 | if (timeout > time::milliseconds::zero()) { |
| 456 | boost::asio::io_service& ioService = m_ioService; |
| 457 | unique_ptr<boost::asio::io_service::work>& work = m_impl->m_ioServiceWork; |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 458 | m_impl->m_processEventsTimeoutEvent = m_impl->m_scheduler.scheduleEvent(timeout, |
| 459 | [&ioService, &work] { |
| 460 | ioService.stop(); |
| 461 | work.reset(); |
| 462 | }); |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 463 | } |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 464 | |
| 465 | if (keepThread) { |
| 466 | // work will ensure that m_ioService is running until work object exists |
Alexander Afanasyev | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 467 | m_impl->m_ioServiceWork.reset(new boost::asio::io_service::work(m_ioService)); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 468 | } |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 469 | |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 470 | m_ioService.run(); |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 471 | } |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 472 | catch (...) { |
| 473 | m_impl->m_ioServiceWork.reset(); |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 474 | m_impl->m_pendingInterestTable.clear(); |
| 475 | m_impl->m_registeredPrefixTable.clear(); |
| 476 | throw; |
| 477 | } |
Jeff Thompson | fb29cda | 2013-08-24 10:26:54 -0700 | [diff] [blame] | 478 | } |
| 479 | |
Alexander Afanasyev | a68aa7f | 2014-02-11 15:42:33 -0800 | [diff] [blame] | 480 | void |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 481 | Face::shutdown() |
Jeff Thompson | 517ffa8 | 2013-08-05 16:04:34 -0700 | [diff] [blame] | 482 | { |
Junxiao Shi | ae0b418 | 2016-08-08 22:53:17 +0000 | [diff] [blame] | 483 | IO_CAPTURE_WEAK_IMPL(post) { |
| 484 | this->asyncShutdown(); |
| 485 | } IO_CAPTURE_WEAK_IMPL_END |
Alexander Afanasyev | 7dced46 | 2014-03-19 15:12:32 -0700 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | void |
| 489 | Face::asyncShutdown() |
| 490 | { |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 491 | m_impl->m_pendingInterestTable.clear(); |
| 492 | m_impl->m_registeredPrefixTable.clear(); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 493 | |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 494 | if (m_transport->isConnected()) |
| 495 | m_transport->close(); |
| 496 | |
Alexander Afanasyev | 1f5486e | 2014-07-10 17:45:49 -0700 | [diff] [blame] | 497 | m_impl->m_ioServiceWork.reset(); |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 500 | /** |
| 501 | * @brief extract local fields from NDNLPv2 packet and tag onto a network layer packet |
| 502 | */ |
| 503 | template<typename NETPKT> |
| 504 | static void |
| 505 | extractLpLocalFields(NETPKT& netPacket, const lp::Packet& lpPacket) |
| 506 | { |
| 507 | if (lpPacket.has<lp::IncomingFaceIdField>()) { |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame] | 508 | netPacket.setTag(make_shared<lp::IncomingFaceIdTag>(lpPacket.get<lp::IncomingFaceIdField>())); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 509 | } |
| 510 | } |
| 511 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 512 | void |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 513 | Face::onReceiveElement(const Block& blockFromDaemon) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 514 | { |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 515 | lp::Packet lpPacket(blockFromDaemon); // bare Interest/Data is a valid lp::Packet, |
| 516 | // no need to distinguish |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 517 | |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 518 | Buffer::const_iterator begin, end; |
| 519 | std::tie(begin, end) = lpPacket.get<lp::FragmentField>(); |
| 520 | Block netPacket(&*begin, std::distance(begin, end)); |
| 521 | switch (netPacket.type()) { |
| 522 | case tlv::Interest: { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 523 | auto interest = make_shared<Interest>(netPacket); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 524 | if (lpPacket.has<lp::NackField>()) { |
| 525 | auto nack = make_shared<lp::Nack>(std::move(*interest)); |
| 526 | nack->setHeader(lpPacket.get<lp::NackField>()); |
| 527 | extractLpLocalFields(*nack, lpPacket); |
| 528 | m_impl->nackPendingInterests(*nack); |
| 529 | } |
| 530 | else { |
| 531 | extractLpLocalFields(*interest, lpPacket); |
| 532 | m_impl->processInterestFilters(*interest); |
| 533 | } |
| 534 | break; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 535 | } |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 536 | case tlv::Data: { |
Junxiao Shi | 103d8ed | 2016-08-07 20:34:10 +0000 | [diff] [blame] | 537 | auto data = make_shared<Data>(netPacket); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 538 | extractLpLocalFields(*data, lpPacket); |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 539 | m_impl->satisfyPendingInterests(*data); |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 540 | break; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 541 | } |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 542 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 543 | } |
| 544 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 545 | } // namespace ndn |