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