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