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