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 | 9d158f0 | 2015-02-17 21:30:19 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2015 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 | |
Jeff Thompson | b9e3c8e | 2013-08-02 11:42:51 -0700 | [diff] [blame] | 22 | #ifndef NDN_FACE_HPP |
Jeff Thompson | a0d18c9 | 2013-08-06 13:55:32 -0700 | [diff] [blame] | 23 | #define NDN_FACE_HPP |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 24 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 25 | #include "common.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 26 | |
| 27 | #include "name.hpp" |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 28 | #include "interest.hpp" |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 29 | #include "interest-filter.hpp" |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 30 | #include "data.hpp" |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame] | 31 | #include "encoding/nfd-constants.hpp" |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 32 | #include "lp/nack.hpp" |
Junxiao Shi | 4b46998 | 2015-12-03 18:20:19 +0000 | [diff] [blame] | 33 | #include "security/signing-info.hpp" |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 34 | |
| 35 | #define NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 36 | |
| 37 | #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 38 | #include "security/identity-certificate.hpp" |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 39 | #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 40 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 41 | namespace boost { |
| 42 | namespace asio { |
| 43 | class io_service; |
| 44 | } |
| 45 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 46 | |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 47 | namespace ndn { |
| 48 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 49 | class Transport; |
| 50 | |
| 51 | class PendingInterestId; |
| 52 | class RegisteredPrefixId; |
| 53 | class InterestFilterId; |
| 54 | |
Yingdi Yu | 1b0311c | 2015-06-10 14:58:47 -0700 | [diff] [blame] | 55 | namespace security { |
| 56 | class KeyChain; |
| 57 | } |
| 58 | using security::KeyChain; |
| 59 | |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 60 | namespace nfd { |
| 61 | class Controller; |
| 62 | } |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 63 | |
Jeff Thompson | fe08e5a | 2013-08-13 11:15:59 -0700 | [diff] [blame] | 64 | /** |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 65 | * @brief Callback called when expressed Interest gets satisfied with a Data packet |
| 66 | */ |
| 67 | typedef function<void(const Interest&, const Data&)> DataCallback; |
| 68 | |
| 69 | /** |
| 70 | * @brief Callback called when Nack is sent in response to expressed Interest |
| 71 | */ |
| 72 | typedef function<void(const Interest&, const lp::Nack&)> NackCallback; |
| 73 | |
| 74 | /** |
| 75 | * @brief Callback called when expressed Interest times out |
| 76 | */ |
| 77 | typedef function<void(const Interest&)> TimeoutCallback; |
| 78 | |
| 79 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 80 | * @brief Callback called when expressed Interest gets satisfied with Data packet |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 81 | * @deprecated use DataCallback |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 82 | */ |
| 83 | typedef function<void(const Interest&, Data&)> OnData; |
| 84 | |
| 85 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 86 | * @brief Callback called when expressed Interest times out |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 87 | * @deprecated use TimeoutCallback |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 88 | */ |
| 89 | typedef function<void(const Interest&)> OnTimeout; |
| 90 | |
| 91 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 92 | * @brief Callback called when incoming Interest matches the specified InterestFilter |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 93 | */ |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 94 | typedef function<void (const InterestFilter&, const Interest&)> OnInterest; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 95 | |
| 96 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 97 | * @brief Callback called when registerPrefix or setInterestFilter command succeeds |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 98 | */ |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 99 | typedef function<void(const Name&)> RegisterPrefixSuccessCallback; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 100 | |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 101 | /** |
| 102 | * @brief Callback called when registerPrefix or setInterestFilter command fails |
| 103 | */ |
| 104 | typedef function<void(const Name&, const std::string&)> RegisterPrefixFailureCallback; |
| 105 | |
| 106 | /** |
| 107 | * @brief Callback called when unregisterPrefix or unsetInterestFilter command succeeds |
| 108 | */ |
| 109 | typedef function<void()> UnregisterPrefixSuccessCallback; |
| 110 | |
| 111 | /** |
| 112 | * @brief Callback called when unregisterPrefix or unsetInterestFilter command fails |
| 113 | */ |
| 114 | typedef function<void(const std::string&)> UnregisterPrefixFailureCallback; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 115 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 116 | /** |
| 117 | * @brief Abstraction to communicate with local or remote NDN forwarder |
Jeff Thompson | fe08e5a | 2013-08-13 11:15:59 -0700 | [diff] [blame] | 118 | */ |
Alexander Afanasyev | 8460afb | 2014-02-15 20:31:42 -0800 | [diff] [blame] | 119 | class Face : noncopyable |
| 120 | { |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 121 | public: |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 122 | class Error : public std::runtime_error |
| 123 | { |
| 124 | public: |
| 125 | explicit |
| 126 | Error(const std::string& what) |
| 127 | : std::runtime_error(what) |
| 128 | { |
| 129 | } |
| 130 | }; |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 131 | |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 132 | public: // constructors |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 133 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 134 | * @brief Create a new Face using the default transport (UnixTransport) |
| 135 | * |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 136 | * @throws ConfigFile::Error on configuration file parse failure |
| 137 | * @throws Face::Error on unsupported protocol |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 138 | */ |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 139 | Face(); |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 140 | |
| 141 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 142 | * @brief Create a new Face using the default transport (UnixTransport) |
| 143 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 144 | * @par Usage examples: |
| 145 | * |
| 146 | * Face face1; |
| 147 | * Face face2(face1.getIoService()); |
| 148 | * |
| 149 | * // Now the following ensures that events on both faces are processed |
| 150 | * face1.processEvents(); |
| 151 | * // or face1.getIoService().run(); |
| 152 | * |
| 153 | * @par or |
| 154 | * |
| 155 | * boost::asio::io_service ioService; |
| 156 | * Face face1(ioService); |
| 157 | * Face face2(ioService); |
| 158 | * ... |
| 159 | * |
| 160 | * ioService.run(); |
| 161 | * |
| 162 | * @param ioService A reference to boost::io_service object that should control all |
| 163 | * IO operations. |
| 164 | * @throws ConfigFile::Error on configuration file parse failure |
| 165 | * @throws Face::Error on unsupported protocol |
| 166 | */ |
| 167 | explicit |
| 168 | Face(boost::asio::io_service& ioService); |
| 169 | |
| 170 | /** |
| 171 | * @brief Create a new Face using TcpTransport |
| 172 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 173 | * @param host The host of the NDN forwarder |
| 174 | * @param port (optional) The port or service name of the NDN forwarder (**default**: "6363") |
| 175 | * |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 176 | * @throws Face::Error on unsupported protocol |
Jeff Thompson | fe08e5a | 2013-08-13 11:15:59 -0700 | [diff] [blame] | 177 | */ |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 178 | Face(const std::string& host, const std::string& port = "6363"); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 179 | |
| 180 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 181 | * @brief Create a new Face using the given Transport |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 182 | * |
| 183 | * @param transport A shared_ptr to a Transport object used for communication |
| 184 | * |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 185 | * @throws Face::Error on unsupported protocol |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 186 | */ |
Alexander Afanasyev | f7ca320 | 2014-02-14 22:28:31 -0800 | [diff] [blame] | 187 | explicit |
| 188 | Face(const shared_ptr<Transport>& transport); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 189 | |
| 190 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 191 | * @brief Create a new Face using the given Transport and IO service object |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 192 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 193 | * @sa Face(boost::asio::io_service&) |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 194 | * |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 195 | * @throws Face::Error on unsupported protocol |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 196 | */ |
| 197 | Face(const shared_ptr<Transport>& transport, |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 198 | boost::asio::io_service& ioService); |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 199 | |
Jeff Thompson | 4fe4551 | 2013-08-23 14:06:38 -0700 | [diff] [blame] | 200 | /** |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 201 | * @brief Create a new Face using the given Transport and IO service object |
| 202 | * @param transport the Transport used for communication |
| 203 | * @param ioService the io_service that controls all IO operations |
| 204 | * @param keyChain the KeyChain to sign commands |
| 205 | * @throws Face::Error on unsupported protocol |
| 206 | * @note shared_ptr is passed by value because ownership is shared with this class |
| 207 | */ |
| 208 | Face(shared_ptr<Transport> transport, |
| 209 | boost::asio::io_service& ioService, |
| 210 | KeyChain& keyChain); |
| 211 | |
| 212 | ~Face(); |
| 213 | |
| 214 | public: // consumer |
| 215 | /** |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 216 | * @brief Express Interest |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 217 | * @param interest the Interest; a copy will be made, so that the caller is not |
| 218 | * required to maintain the argument unchanged |
| 219 | * @param afterSatisfied function to be invoked if Data is returned |
| 220 | * @param afterNacked function to be invoked if Network NACK is returned |
| 221 | * @param afterTimeout function to be invoked if neither Data nor Network NACK |
| 222 | * is returned within InterestLifetime |
| 223 | */ |
| 224 | const PendingInterestId* |
| 225 | expressInterest(const Interest& interest, |
| 226 | const DataCallback& afterSatisfied, |
| 227 | const NackCallback& afterNacked, |
| 228 | const TimeoutCallback& afterTimeout); |
| 229 | |
| 230 | /** |
| 231 | * @brief Express Interest |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 232 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 233 | * @param interest An Interest to be expressed |
| 234 | * @param onData Callback to be called when a matching data packet is received |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 235 | * @param onTimeout (optional) A function object to call if the interest times out or is Nacked |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 236 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 237 | * @return The pending interest ID which can be used with removePendingInterest |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 238 | * |
| 239 | * @throws Error when Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE) |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 240 | * |
| 241 | * @deprecated use expressInterest(Interest, DataCallback, NackCallback, TimeoutCallback) |
Jeff Thompson | 4fe4551 | 2013-08-23 14:06:38 -0700 | [diff] [blame] | 242 | */ |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 243 | const PendingInterestId* |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 244 | expressInterest(const Interest& interest, |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 245 | const OnData& onData, |
| 246 | const OnTimeout& onTimeout = nullptr); |
Jeff Thompson | 4fe4551 | 2013-08-23 14:06:38 -0700 | [diff] [blame] | 247 | |
| 248 | /** |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 249 | * @brief Express Interest using name and Interest template |
| 250 | * |
| 251 | * @param name Name of the Interest |
| 252 | * @param tmpl Interest template to fill parameters |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 253 | * @param onData Callback to be called when a matching data packet is received |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 254 | * @param onTimeout (optional) A function object to call if the interest times out or is Nacked |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 255 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 256 | * @return Opaque pending interest ID which can be used with removePendingInterest |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 257 | * |
| 258 | * @throws Error when Interest size exceeds maximum limit (MAX_NDN_PACKET_SIZE) |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 259 | * |
| 260 | * @deprecated use expressInterest(Interest, DataCallback, NackCallback, TimeoutCallback) |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 261 | */ |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 262 | const PendingInterestId* |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 263 | expressInterest(const Name& name, |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 264 | const Interest& tmpl, |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 265 | const OnData& onData, |
| 266 | const OnTimeout& onTimeout = nullptr); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 267 | |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 268 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 269 | * @brief Cancel previously expressed Interest |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 270 | * |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 271 | * @param pendingInterestId The ID returned from expressInterest. |
| 272 | */ |
| 273 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 274 | removePendingInterest(const PendingInterestId* pendingInterestId); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 275 | |
Jeff Thompson | 432c8be | 2013-08-09 16:16:08 -0700 | [diff] [blame] | 276 | /** |
Ilya Moiseenko | 56b0bf8 | 2015-11-08 11:14:28 -0500 | [diff] [blame] | 277 | * @brief Cancel all previously expressed Interests |
| 278 | */ |
| 279 | void |
| 280 | removeAllPendingInterests(); |
| 281 | |
| 282 | /** |
Alexander Afanasyev | 6fcdde2 | 2014-08-22 19:03:36 -0700 | [diff] [blame] | 283 | * @brief Get number of pending Interests |
| 284 | */ |
| 285 | size_t |
| 286 | getNPendingInterests() const; |
| 287 | |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 288 | public: // producer |
Alexander Afanasyev | 6fcdde2 | 2014-08-22 19:03:36 -0700 | [diff] [blame] | 289 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 290 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 291 | * callback and register the filtered prefix with the connected NDN forwarder |
| 292 | * |
| 293 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 294 | * operations and is intended to be used when only one filter for the same prefix needed |
| 295 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 296 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 297 | * a series of setInterestFilter calls. |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 298 | * |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 299 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 300 | * @param onInterest A callback to be called when a matching interest is received |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 301 | * @param onFailure A callback to be called when prefixRegister command fails |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 302 | * @param flags (optional) RIB flags |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 303 | * @param signingInfo (optional) Signing parameters. When omitted, a default parameters |
| 304 | * used in the signature will be used. |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 305 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 306 | * @return Opaque registered prefix ID which can be used with unsetInterestFilter or |
| 307 | * removeRegisteredPrefix |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 308 | */ |
| 309 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 310 | setInterestFilter(const InterestFilter& interestFilter, |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 311 | const OnInterest& onInterest, |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 312 | const RegisterPrefixFailureCallback& onFailure, |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 313 | const security::SigningInfo& signingInfo = security::SigningInfo(), |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 314 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 315 | |
| 316 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 317 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 318 | * callback and register the filtered prefix with the connected NDN forwarder |
| 319 | * |
| 320 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 321 | * operations and is intended to be used when only one filter for the same prefix needed |
| 322 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 323 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 324 | * a series of setInterestFilter calls. |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 325 | * |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 326 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 327 | * @param onInterest A callback to be called when a matching interest is received |
| 328 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 329 | * @param onFailure A callback to be called when prefixRegister command fails |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 330 | * @param flags (optional) RIB flags |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 331 | * @param signingInfo (optional) Signing parameters. When omitted, a default parameters |
| 332 | * used in the signature will be used. |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 333 | * |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 334 | * @return Opaque registered prefix ID which can be used with unsetInterestFilter or |
| 335 | * removeRegisteredPrefix |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 336 | */ |
| 337 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 338 | setInterestFilter(const InterestFilter& interestFilter, |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 339 | const OnInterest& onInterest, |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 340 | const RegisterPrefixSuccessCallback& onSuccess, |
| 341 | const RegisterPrefixFailureCallback& onFailure, |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 342 | const security::SigningInfo& signingInfo = security::SigningInfo(), |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 343 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 344 | |
| 345 | /** |
| 346 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest callback |
| 347 | * |
| 348 | * @param interestFilter Interest |
| 349 | * @param onInterest A callback to be called when a matching interest is received |
| 350 | * |
| 351 | * This method modifies library's FIB only, and does not register the prefix with the |
| 352 | * forwarder. It will always succeed. To register prefix with the forwarder, use |
| 353 | * registerPrefix, or use the setInterestFilter overload taking two callbacks. |
| 354 | * |
| 355 | * @return Opaque interest filter ID which can be used with unsetInterestFilter |
| 356 | */ |
| 357 | const InterestFilterId* |
| 358 | setInterestFilter(const InterestFilter& interestFilter, |
| 359 | const OnInterest& onInterest); |
| 360 | |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 361 | #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 362 | /** |
| 363 | * @deprecated Use override with SigningInfo instead of this function |
| 364 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 365 | * callback and register the filtered prefix with the connected NDN forwarder |
| 366 | * |
| 367 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 368 | * operations and is intended to be used when only one filter for the same prefix needed |
| 369 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 370 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 371 | * a series of setInterestFilter calls. |
| 372 | * |
| 373 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 374 | * @param onInterest A callback to be called when a matching interest is received |
| 375 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 376 | * @param onFailure A callback to be called when prefixRegister command fails |
| 377 | * @param flags (optional) RIB flags |
| 378 | * @param certificate (optional) A certificate under which the prefix registration |
| 379 | * command is signed. When omitted, a default certificate of |
| 380 | * the default identity is used to sign the registration command |
| 381 | * |
| 382 | * @return Opaque registered prefix ID which can be used with unsetInterestFilter or |
| 383 | * removeRegisteredPrefix |
| 384 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 385 | DEPRECATED( |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 386 | const RegisteredPrefixId* |
| 387 | setInterestFilter(const InterestFilter& interestFilter, |
| 388 | const OnInterest& onInterest, |
| 389 | const RegisterPrefixSuccessCallback& onSuccess, |
| 390 | const RegisterPrefixFailureCallback& onFailure, |
| 391 | const IdentityCertificate& certificate, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 392 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 393 | |
| 394 | /** |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 395 | * @deprecated Use override with SigningInfo instead of this function |
| 396 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 397 | * callback and register the filtered prefix with the connected NDN forwarder |
| 398 | * |
| 399 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 400 | * operations and is intended to be used when only one filter for the same prefix needed |
| 401 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 402 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 403 | * a series of setInterestFilter calls. |
| 404 | * |
| 405 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 406 | * @param onInterest A callback to be called when a matching interest is received |
| 407 | * @param onFailure A callback to be called when prefixRegister command fails |
| 408 | * @param flags (optional) RIB flags |
| 409 | * @param certificate (optional) A certificate under which the prefix registration |
| 410 | * command is signed. When omitted, a default certificate of |
| 411 | * the default identity is used to sign the registration command |
| 412 | * |
| 413 | * @return Opaque registered prefix ID which can be used with unsetInterestFilter or |
| 414 | * removeRegisteredPrefix |
| 415 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 416 | DEPRECATED( |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 417 | const RegisteredPrefixId* |
| 418 | setInterestFilter(const InterestFilter& interestFilter, |
| 419 | const OnInterest& onInterest, |
| 420 | const RegisterPrefixFailureCallback& onFailure, |
| 421 | const IdentityCertificate& certificate, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 422 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 423 | |
| 424 | /** |
| 425 | * @deprecated Use override with SigningInfo instead of this function |
| 426 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 427 | * callback and register the filtered prefix with the connected NDN forwarder |
| 428 | * |
| 429 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 430 | * operations and is intended to be used when only one filter for the same prefix needed |
| 431 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 432 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 433 | * a series of setInterestFilter calls. |
| 434 | * |
| 435 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 436 | * @param onInterest A callback to be called when a matching interest is received |
| 437 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 438 | * @param onFailure A callback to be called when prefixRegister command fails |
| 439 | * @param identity A signing identity. A prefix registration command is signed |
| 440 | * under the default certificate of this identity |
| 441 | * @param flags (optional) RIB flags |
| 442 | * |
| 443 | * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix |
| 444 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 445 | DEPRECATED( |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 446 | const RegisteredPrefixId* |
| 447 | setInterestFilter(const InterestFilter& interestFilter, |
| 448 | const OnInterest& onInterest, |
| 449 | const RegisterPrefixSuccessCallback& onSuccess, |
| 450 | const RegisterPrefixFailureCallback& onFailure, |
| 451 | const Name& identity, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 452 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 453 | |
| 454 | /** |
| 455 | * @deprecated Use override with SigningInfo instead of this function |
| 456 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 457 | * callback and register the filtered prefix with the connected NDN forwarder |
| 458 | * |
| 459 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 460 | * operations and is intended to be used when only one filter for the same prefix needed |
| 461 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 462 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 463 | * a series of setInterestFilter calls. |
| 464 | * |
| 465 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 466 | * @param onInterest A callback to be called when a matching interest is received |
| 467 | * @param onFailure A callback to be called when prefixRegister command fails |
| 468 | * @param identity A signing identity. A prefix registration command is signed |
| 469 | * under the default certificate of this identity |
| 470 | * @param flags (optional) RIB flags |
| 471 | * |
| 472 | * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix |
| 473 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 474 | DEPRECATED( |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 475 | const RegisteredPrefixId* |
| 476 | setInterestFilter(const InterestFilter& interestFilter, |
| 477 | const OnInterest& onInterest, |
| 478 | const RegisterPrefixFailureCallback& onFailure, |
| 479 | const Name& identity, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 480 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 481 | #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 482 | |
| 483 | /** |
| 484 | * @brief Register prefix with the connected NDN forwarder |
| 485 | * |
| 486 | * This method only modifies forwarder's RIB and does not associate any |
| 487 | * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to |
| 488 | * the right callbacks. |
| 489 | * |
| 490 | * @param prefix A prefix to register with the connected NDN forwarder |
| 491 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 492 | * @param onFailure A callback to be called when prefixRegister command fails |
| 493 | * @param signingInfo (optional) Signing parameters. When omitted, a default parameters |
| 494 | * used in the signature will be used. |
Alexander Afanasyev | f2a4622 | 2015-09-17 18:01:30 -0700 | [diff] [blame] | 495 | * @param flags Prefix registration flags |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 496 | * |
| 497 | * @return The registered prefix ID which can be used with unregisterPrefix |
Alexander Afanasyev | f2a4622 | 2015-09-17 18:01:30 -0700 | [diff] [blame] | 498 | * @see nfd::RouteFlags |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 499 | */ |
| 500 | const RegisteredPrefixId* |
| 501 | registerPrefix(const Name& prefix, |
| 502 | const RegisterPrefixSuccessCallback& onSuccess, |
| 503 | const RegisterPrefixFailureCallback& onFailure, |
| 504 | const security::SigningInfo& signingInfo = security::SigningInfo(), |
| 505 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
| 506 | |
| 507 | #ifdef NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
| 508 | /** |
| 509 | * @deprecated Use override with SigningInfo instead of this function |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 510 | * @brief Register prefix with the connected NDN forwarder |
| 511 | * |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 512 | * This method only modifies forwarder's RIB and does not associate any |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 513 | * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to |
| 514 | * the right callbacks. |
| 515 | * |
| 516 | * @param prefix A prefix to register with the connected NDN forwarder |
| 517 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 518 | * @param onFailure A callback to be called when prefixRegister command fails |
| 519 | * @param certificate (optional) A certificate under which the prefix registration |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 520 | * command is signed. When omitted, a default certificate of |
| 521 | * the default identity is used to sign the registration command |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 522 | * @param flags (optional) RIB flags |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 523 | * |
| 524 | * @return The registered prefix ID which can be used with unregisterPrefix |
| 525 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 526 | DEPRECATED( |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 527 | const RegisteredPrefixId* |
| 528 | registerPrefix(const Name& prefix, |
| 529 | const RegisterPrefixSuccessCallback& onSuccess, |
| 530 | const RegisterPrefixFailureCallback& onFailure, |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 531 | const IdentityCertificate& certificate, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 532 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 533 | |
| 534 | /** |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 535 | * @deprecated Use override with SigningInfo instead of this function |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 536 | * @brief Register prefix with the connected NDN forwarder and call onInterest when a matching |
| 537 | * interest is received. |
| 538 | * |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 539 | * This method only modifies forwarder's RIB and does not associate any |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 540 | * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to |
| 541 | * the right callbacks. |
| 542 | * |
| 543 | * @param prefix A prefix to register with the connected NDN forwarder |
| 544 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 545 | * @param onFailure A callback to be called when prefixRegister command fails |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 546 | * @param identity A signing identity. A prefix registration command is signed |
| 547 | * under the default certificate of this identity |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 548 | * @param flags (optional) RIB flags |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 549 | * |
| 550 | * @return The registered prefix ID which can be used with unregisterPrefix |
| 551 | */ |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 552 | DEPRECATED( |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 553 | const RegisteredPrefixId* |
| 554 | registerPrefix(const Name& prefix, |
| 555 | const RegisterPrefixSuccessCallback& onSuccess, |
| 556 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 557 | const Name& identity, |
philo | bb778e7 | 2015-08-25 14:49:19 -0700 | [diff] [blame] | 558 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT)); |
Joao Pereira | 0b3cac5 | 2015-07-02 14:49:49 -0400 | [diff] [blame] | 559 | #endif // NDN_FACE_KEEP_DEPRECATED_REGISTRATION_SIGNING |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 560 | |
| 561 | /** |
Alexander Afanasyev | 1b01c31 | 2014-05-26 16:58:10 +0300 | [diff] [blame] | 562 | * @brief Remove the registered prefix entry with the registeredPrefixId |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 563 | * |
| 564 | * This does not affect another registered prefix with a different registeredPrefixId, |
| 565 | * even it if has the same prefix name. If there is no entry with the |
| 566 | * registeredPrefixId, do nothing. |
| 567 | * |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 568 | * unsetInterestFilter will use the same credentials as original |
| 569 | * setInterestFilter/registerPrefix command |
| 570 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 571 | * @param registeredPrefixId The ID returned from registerPrefix |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 572 | */ |
| 573 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 574 | unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId); |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 575 | |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 576 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 577 | * @brief Remove previously set InterestFilter from library's FIB |
| 578 | * |
| 579 | * This method always succeeds and will **NOT** send any request to the connected |
| 580 | * forwarder. |
| 581 | * |
| 582 | * @param interestFilterId The ID returned from setInterestFilter. |
| 583 | */ |
| 584 | void |
| 585 | unsetInterestFilter(const InterestFilterId* interestFilterId); |
| 586 | |
| 587 | /** |
Joao Pereira | ba1e3b9 | 2015-06-01 17:50:37 -0400 | [diff] [blame] | 588 | * @brief Unregister prefix from RIB |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 589 | * |
| 590 | * unregisterPrefix will use the same credentials as original |
| 591 | * setInterestFilter/registerPrefix command |
| 592 | * |
| 593 | * If registeredPrefixId was obtained using setInterestFilter, the corresponding |
| 594 | * InterestFilter will be unset too. |
| 595 | * |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 596 | * @param registeredPrefixId The ID returned from registerPrefix |
| 597 | * @param onSuccess Callback to be called when operation succeeds |
| 598 | * @param onFailure Callback to be called when operation fails |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 599 | */ |
| 600 | void |
| 601 | unregisterPrefix(const RegisteredPrefixId* registeredPrefixId, |
| 602 | const UnregisterPrefixSuccessCallback& onSuccess, |
| 603 | const UnregisterPrefixFailureCallback& onFailure); |
| 604 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 605 | /** |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 606 | * @brief Publish data packet |
| 607 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 608 | * This method can be called to satisfy the incoming Interest or to put Data packet into |
Alexander Afanasyev | 6a05b4b | 2014-07-18 17:23:00 -0700 | [diff] [blame] | 609 | * the cache of the local NDN forwarder. |
| 610 | * |
| 611 | * @param data Data packet to publish. It is highly recommended to use Data packet that |
| 612 | * was created using make_shared<Data>(...). Otherwise, put() will make an |
| 613 | * extra copy of the Data packet to ensure validity of published Data until |
| 614 | * asynchronous put() operation finishes. |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 615 | * |
| 616 | * @throws Error when Data size exceeds maximum limit (MAX_NDN_PACKET_SIZE) |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 617 | */ |
| 618 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 619 | put(const Data& data); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 620 | |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 621 | /** |
| 622 | * @brief sends a Network NACK |
| 623 | * @param nack the Nack; a copy will be made, so that the caller is not required to |
| 624 | * maintain the argument unchanged |
| 625 | */ |
| 626 | void |
| 627 | put(const lp::Nack& nack); |
| 628 | |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 629 | public: // IO routine |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 630 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 631 | * @brief Process any data to receive or call timeout callbacks. |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 632 | * |
| 633 | * This call will block forever (default timeout == 0) to process IO on the face. |
| 634 | * To exit, one expected to call face.shutdown() from one of the callback methods. |
| 635 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 636 | * If positive timeout is specified, then processEvents will exit after this timeout, if |
| 637 | * not stopped earlier with face.shutdown() or when all active events finish. The call |
| 638 | * can be called repeatedly, if desired. |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 639 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 640 | * If negative timeout is specified, then processEvents will not block and process only |
| 641 | * pending events. |
Alexander Afanasyev | f75a0aa | 2014-01-09 14:29:22 -0800 | [diff] [blame] | 642 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 643 | * @param timeout maximum time to block the thread |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 644 | * @param keepThread Keep thread in a blocked state (in event processing), even when |
| 645 | * there are no outstanding events (e.g., no Interest/Data is expected) |
| 646 | * |
| 647 | * @throw This may throw an exception for reading data or in the callback for processing |
| 648 | * the data. If you call this from an main event loop, you may want to catch and |
| 649 | * log/disregard all exceptions. |
Jeff Thompson | 432c8be | 2013-08-09 16:16:08 -0700 | [diff] [blame] | 650 | */ |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 651 | void |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 652 | processEvents(const time::milliseconds& timeout = time::milliseconds::zero(), |
| 653 | bool keepThread = false); |
Jeff Thompson | 432c8be | 2013-08-09 16:16:08 -0700 | [diff] [blame] | 654 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 655 | /** |
| 656 | * @brief Shutdown face operations |
| 657 | * |
| 658 | * This method cancels all pending operations and closes connection to NDN Forwarder. |
| 659 | * |
| 660 | * Note that this method does not stop IO service and if the same IO service is shared |
| 661 | * between multiple Faces or with other IO objects (e.g., Scheduler). |
| 662 | */ |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 663 | void |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 664 | shutdown(); |
Yingdi Yu | 0d92081 | 2014-01-30 14:50:57 -0800 | [diff] [blame] | 665 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 666 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 667 | * @brief Get reference to IO service object |
| 668 | */ |
| 669 | boost::asio::io_service& |
| 670 | getIoService() |
| 671 | { |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 672 | return m_ioService; |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 673 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 674 | |
Alexander Afanasyev | 3a6da36 | 2015-12-29 20:31:03 -0800 | [diff] [blame^] | 675 | NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED: |
| 676 | /** |
| 677 | * @brief Get the underlying transport of the face |
| 678 | */ |
| 679 | shared_ptr<Transport> |
| 680 | getTransport(); |
| 681 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 682 | private: |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 683 | |
| 684 | /** |
| 685 | * @throws ConfigFile::Error on parse error and unsupported protocols |
| 686 | */ |
| 687 | void |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 688 | construct(KeyChain& keyChain); |
Steve DiBenedetto | a8659ff | 2014-12-04 14:50:28 -0700 | [diff] [blame] | 689 | |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 690 | /** |
| 691 | * @throws Face::Error on unsupported protocol |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 692 | * @note shared_ptr is passed by value because ownership is transferred to this function |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 693 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 694 | void |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 695 | construct(shared_ptr<Transport> transport, KeyChain& keyChain); |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 696 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 697 | void |
Eric Newberry | 83872fd | 2015-08-06 17:01:24 -0700 | [diff] [blame] | 698 | onReceiveElement(const Block& blockFromDaemon); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 699 | |
Alexander Afanasyev | 7dced46 | 2014-03-19 15:12:32 -0700 | [diff] [blame] | 700 | void |
| 701 | asyncShutdown(); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 702 | |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 703 | private: |
Junxiao Shi | 2cced06 | 2014-11-02 21:27:38 -0700 | [diff] [blame] | 704 | /// the IO service owned by this Face, could be null |
| 705 | unique_ptr<boost::asio::io_service> m_internalIoService; |
| 706 | /// the IO service used by this Face |
| 707 | boost::asio::io_service& m_ioService; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 708 | |
Alexander Afanasyev | f39c537 | 2014-02-17 19:42:56 -0800 | [diff] [blame] | 709 | shared_ptr<Transport> m_transport; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 710 | |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 711 | /** @brief if not null, a pointer to an internal KeyChain owned by Face |
| 712 | * @note if a KeyChain is supplied to constructor, this pointer will be null, |
| 713 | * and the passed KeyChain is given to nfdController; |
| 714 | * currently Face does not keep the KeyChain passed in constructor |
| 715 | * because it's not needed, but this may change in the future |
| 716 | */ |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 717 | unique_ptr<KeyChain> m_internalKeyChain; |
Junxiao Shi | edd834e | 2014-10-28 20:28:58 -0700 | [diff] [blame] | 718 | |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 719 | unique_ptr<nfd::Controller> m_nfdController; |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 720 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 721 | class Impl; |
Joao Pereira | 68c0d88 | 2015-05-19 14:27:55 -0400 | [diff] [blame] | 722 | unique_ptr<Impl> m_impl; |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 723 | }; |
| 724 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 725 | } // namespace ndn |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 726 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 727 | #endif // NDN_FACE_HPP |