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 |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 254 | */ |
Alexander Afanasyev | b790d95 | 2014-01-24 12:07:53 -0800 | [diff] [blame] | 255 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 256 | setInterestFilter(const InterestFilter& interestFilter, |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 257 | const OnInterest& onInterest, |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 258 | const RegisterPrefixSuccessCallback& onSuccess, |
| 259 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 260 | const IdentityCertificate& certificate = IdentityCertificate(), |
| 261 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 262 | |
| 263 | /** |
Alexander Afanasyev | 1b01c31 | 2014-05-26 16:58:10 +0300 | [diff] [blame] | 264 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 265 | * callback and register the filtered prefix with the connected NDN forwarder |
| 266 | * |
| 267 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 268 | * operations and is intended to be used when only one filter for the same prefix needed |
| 269 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 270 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 271 | * a series of setInterestFilter calls. |
| 272 | * |
| 273 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 274 | * @param onInterest A callback to be called when a matching interest is received |
| 275 | * @param onFailure A callback to be called when prefixRegister command fails |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 276 | * @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] | 277 | * @param certificate (optional) A certificate under which the prefix registration |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 278 | * command is signed. When omitted, a default certificate of |
| 279 | * the default identity is used to sign the registration command |
Alexander Afanasyev | 1b01c31 | 2014-05-26 16:58:10 +0300 | [diff] [blame] | 280 | * |
| 281 | * @return Opaque registered prefix ID which can be used with unsetInterestFilter or |
| 282 | * removeRegisteredPrefix |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 283 | */ |
| 284 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 285 | setInterestFilter(const InterestFilter& interestFilter, |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 286 | const OnInterest& onInterest, |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 287 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 288 | const IdentityCertificate& certificate = IdentityCertificate(), |
| 289 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 290 | |
| 291 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 292 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 293 | * callback and register the filtered prefix with the connected NDN forwarder |
| 294 | * |
| 295 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 296 | * operations and is intended to be used when only one filter for the same prefix needed |
| 297 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 298 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 299 | * a series of setInterestFilter calls. |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 300 | * |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 301 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 302 | * @param onInterest A callback to be called when a matching interest is received |
| 303 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 304 | * @param onFailure A callback to be called when prefixRegister command fails |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 305 | * @param identity A signing identity. A prefix registration command is signed |
| 306 | * under the default certificate of this identity |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 307 | * @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] | 308 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 309 | * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 310 | */ |
| 311 | const RegisteredPrefixId* |
Alexander Afanasyev | 9016496 | 2014-03-06 08:29:59 +0000 | [diff] [blame] | 312 | setInterestFilter(const InterestFilter& interestFilter, |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 313 | const OnInterest& onInterest, |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 314 | const RegisterPrefixSuccessCallback& onSuccess, |
| 315 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 316 | const Name& identity, |
| 317 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 318 | |
| 319 | /** |
Alexander Afanasyev | 1b01c31 | 2014-05-26 16:58:10 +0300 | [diff] [blame] | 320 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest |
| 321 | * callback and register the filtered prefix with the connected NDN forwarder |
| 322 | * |
| 323 | * This version of setInterestFilter combines setInterestFilter and registerPrefix |
| 324 | * operations and is intended to be used when only one filter for the same prefix needed |
| 325 | * to be set. When multiple names sharing the same prefix should be dispatched to |
| 326 | * different callbacks, use one registerPrefix call, followed (in onSuccess callback) by |
| 327 | * a series of setInterestFilter calls. |
| 328 | * |
| 329 | * @param interestFilter Interest filter (prefix part will be registered with the forwarder) |
| 330 | * @param onInterest A callback to be called when a matching interest is received |
| 331 | * @param onFailure A callback to be called when prefixRegister command fails |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 332 | * @param identity A signing identity. A prefix registration command is signed |
| 333 | * under the default certificate of this identity |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 334 | * @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] | 335 | * |
| 336 | * @return Opaque registered prefix ID which can be used with removeRegisteredPrefix |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 337 | */ |
| 338 | const RegisteredPrefixId* |
| 339 | setInterestFilter(const InterestFilter& interestFilter, |
| 340 | const OnInterest& onInterest, |
| 341 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 342 | const Name& identity, |
| 343 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 344 | |
| 345 | /** |
| 346 | * @brief Set InterestFilter to dispatch incoming matching interest to onInterest callback |
| 347 | * |
| 348 | * @param interestFilter Interest |
| 349 | * @param onInterest A callback to be called when a matching interest is received |
| 350 | * |
| 351 | * This method modifies library's FIB only, and does not register the prefix with the |
| 352 | * forwarder. It will always succeed. To register prefix with the forwarder, use |
| 353 | * registerPrefix, or use the setInterestFilter overload taking two callbacks. |
| 354 | * |
| 355 | * @return Opaque interest filter ID which can be used with unsetInterestFilter |
| 356 | */ |
| 357 | const InterestFilterId* |
| 358 | setInterestFilter(const InterestFilter& interestFilter, |
| 359 | const OnInterest& onInterest); |
| 360 | |
| 361 | |
| 362 | /** |
| 363 | * @brief Register prefix with the connected NDN forwarder |
| 364 | * |
| 365 | * This method only modifies forwarder's RIB (or FIB) and does not associate any |
| 366 | * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to |
| 367 | * the right callbacks. |
| 368 | * |
| 369 | * @param prefix A prefix to register with the connected NDN forwarder |
| 370 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 371 | * @param onFailure A callback to be called when prefixRegister command fails |
| 372 | * @param certificate (optional) A certificate under which the prefix registration |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 373 | * command is signed. When omitted, a default certificate of |
| 374 | * the default identity is used to sign the registration command |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 375 | * @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] | 376 | * |
| 377 | * @return The registered prefix ID which can be used with unregisterPrefix |
| 378 | */ |
| 379 | const RegisteredPrefixId* |
| 380 | registerPrefix(const Name& prefix, |
| 381 | const RegisterPrefixSuccessCallback& onSuccess, |
| 382 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 383 | const IdentityCertificate& certificate = IdentityCertificate(), |
| 384 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 385 | |
| 386 | /** |
| 387 | * @brief Register prefix with the connected NDN forwarder and call onInterest when a matching |
| 388 | * interest is received. |
| 389 | * |
| 390 | * This method only modifies forwarder's RIB (or FIB) and does not associate any |
| 391 | * onInterest callbacks. Use setInterestFilter method to dispatch incoming Interests to |
| 392 | * the right callbacks. |
| 393 | * |
| 394 | * @param prefix A prefix to register with the connected NDN forwarder |
| 395 | * @param onSuccess A callback to be called when prefixRegister command succeeds |
| 396 | * @param onFailure A callback to be called when prefixRegister command fails |
Junxiao Shi | 6a90f37 | 2014-10-13 20:29:30 -0700 | [diff] [blame] | 397 | * @param identity A signing identity. A prefix registration command is signed |
| 398 | * under the default certificate of this identity |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 399 | * @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] | 400 | * |
| 401 | * @return The registered prefix ID which can be used with unregisterPrefix |
| 402 | */ |
| 403 | const RegisteredPrefixId* |
| 404 | registerPrefix(const Name& prefix, |
| 405 | const RegisterPrefixSuccessCallback& onSuccess, |
| 406 | const RegisterPrefixFailureCallback& onFailure, |
Alexander Afanasyev | 0866f51 | 2014-08-11 13:25:09 -0700 | [diff] [blame] | 407 | const Name& identity, |
| 408 | uint64_t flags = nfd::ROUTE_FLAG_CHILD_INHERIT); |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 409 | |
| 410 | /** |
Alexander Afanasyev | 1b01c31 | 2014-05-26 16:58:10 +0300 | [diff] [blame] | 411 | * @brief Remove the registered prefix entry with the registeredPrefixId |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 412 | * |
| 413 | * This does not affect another registered prefix with a different registeredPrefixId, |
| 414 | * even it if has the same prefix name. If there is no entry with the |
| 415 | * registeredPrefixId, do nothing. |
| 416 | * |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 417 | * unsetInterestFilter will use the same credentials as original |
| 418 | * setInterestFilter/registerPrefix command |
| 419 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 420 | * @param registeredPrefixId The ID returned from registerPrefix |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 421 | */ |
| 422 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 423 | unsetInterestFilter(const RegisteredPrefixId* registeredPrefixId); |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 424 | |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 425 | /** |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 426 | * @brief Remove previously set InterestFilter from library's FIB |
| 427 | * |
| 428 | * This method always succeeds and will **NOT** send any request to the connected |
| 429 | * forwarder. |
| 430 | * |
| 431 | * @param interestFilterId The ID returned from setInterestFilter. |
| 432 | */ |
| 433 | void |
| 434 | unsetInterestFilter(const InterestFilterId* interestFilterId); |
| 435 | |
| 436 | /** |
| 437 | * @brief Deregister prefix from RIB (or FIB) |
| 438 | * |
| 439 | * unregisterPrefix will use the same credentials as original |
| 440 | * setInterestFilter/registerPrefix command |
| 441 | * |
| 442 | * If registeredPrefixId was obtained using setInterestFilter, the corresponding |
| 443 | * InterestFilter will be unset too. |
| 444 | * |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 445 | * @param registeredPrefixId The ID returned from registerPrefix |
| 446 | * @param onSuccess Callback to be called when operation succeeds |
| 447 | * @param onFailure Callback to be called when operation fails |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 448 | */ |
| 449 | void |
| 450 | unregisterPrefix(const RegisteredPrefixId* registeredPrefixId, |
| 451 | const UnregisterPrefixSuccessCallback& onSuccess, |
| 452 | const UnregisterPrefixFailureCallback& onFailure); |
| 453 | |
| 454 | /** |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 455 | * @brief (FOR DEBUG PURPOSES ONLY) Request direct NFD FIB management |
| 456 | */ |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 457 | void |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 458 | setDirectFibManagement(bool isDirectFibManagementRequested = false); |
Yingdi Yu | e66bf2a | 2014-04-28 17:07:36 -0700 | [diff] [blame] | 459 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 460 | /** |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 461 | * @brief Publish data packet |
| 462 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 463 | * 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] | 464 | * the cache of the local NDN forwarder. |
| 465 | * |
| 466 | * @param data Data packet to publish. It is highly recommended to use Data packet that |
| 467 | * was created using make_shared<Data>(...). Otherwise, put() will make an |
| 468 | * extra copy of the Data packet to ensure validity of published Data until |
| 469 | * asynchronous put() operation finishes. |
Alexander Afanasyev | 49bb1fb | 2014-07-21 12:54:01 -0700 | [diff] [blame] | 470 | * |
| 471 | * @throws Error when Data size exceeds maximum limit (MAX_NDN_PACKET_SIZE) |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 472 | */ |
| 473 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 474 | put(const Data& data); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 475 | |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 476 | /** |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 477 | * @brief Process any data to receive or call timeout callbacks. |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 478 | * |
| 479 | * This call will block forever (default timeout == 0) to process IO on the face. |
| 480 | * To exit, one expected to call face.shutdown() from one of the callback methods. |
| 481 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 482 | * If positive timeout is specified, then processEvents will exit after this timeout, if |
| 483 | * not stopped earlier with face.shutdown() or when all active events finish. The call |
| 484 | * can be called repeatedly, if desired. |
Alexander Afanasyev | a557d5a | 2013-12-28 21:59:03 -0800 | [diff] [blame] | 485 | * |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 486 | * If negative timeout is specified, then processEvents will not block and process only |
| 487 | * pending events. |
Alexander Afanasyev | f75a0aa | 2014-01-09 14:29:22 -0800 | [diff] [blame] | 488 | * |
Alexander Afanasyev | 984ad19 | 2014-05-02 19:11:15 -0700 | [diff] [blame] | 489 | * @param timeout maximum time to block the thread |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 490 | * @param keepThread Keep thread in a blocked state (in event processing), even when |
| 491 | * there are no outstanding events (e.g., no Interest/Data is expected) |
| 492 | * |
| 493 | * @throw This may throw an exception for reading data or in the callback for processing |
| 494 | * the data. If you call this from an main event loop, you may want to catch and |
| 495 | * log/disregard all exceptions. |
Jeff Thompson | 432c8be | 2013-08-09 16:16:08 -0700 | [diff] [blame] | 496 | */ |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 497 | void |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 498 | processEvents(const time::milliseconds& timeout = time::milliseconds::zero(), |
| 499 | bool keepThread = false); |
Jeff Thompson | 432c8be | 2013-08-09 16:16:08 -0700 | [diff] [blame] | 500 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 501 | /** |
| 502 | * @brief Shutdown face operations |
| 503 | * |
| 504 | * This method cancels all pending operations and closes connection to NDN Forwarder. |
| 505 | * |
| 506 | * Note that this method does not stop IO service and if the same IO service is shared |
| 507 | * between multiple Faces or with other IO objects (e.g., Scheduler). |
| 508 | */ |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 509 | void |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 510 | shutdown(); |
Yingdi Yu | 0d92081 | 2014-01-30 14:50:57 -0800 | [diff] [blame] | 511 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 512 | /** |
| 513 | * @brief Get shared_ptr of the IO service object |
| 514 | * |
| 515 | * @deprecated Use getIoService instead |
| 516 | */ |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 517 | DEPRECATED( |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 518 | shared_ptr<boost::asio::io_service> |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame] | 519 | ioService()) |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 520 | { |
| 521 | return m_ioService; |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * @brief Get reference to IO service object |
| 526 | */ |
| 527 | boost::asio::io_service& |
| 528 | getIoService() |
| 529 | { |
| 530 | return *m_ioService; |
| 531 | } |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 532 | |
| 533 | private: |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 534 | /** |
| 535 | * @throws Face::Error on unsupported protocol |
| 536 | */ |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 537 | void |
Alexander Afanasyev | 7682ccb | 2014-02-20 10:29:35 -0800 | [diff] [blame] | 538 | construct(const shared_ptr<Transport>& transport, |
Alexander Afanasyev | 505646e | 2014-02-24 20:13:37 -0800 | [diff] [blame] | 539 | const shared_ptr<boost::asio::io_service>& ioService); |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 540 | |
| 541 | bool |
| 542 | isSupportedNfdProtocol(const std::string& protocol); |
| 543 | |
| 544 | bool |
| 545 | isSupportedNrdProtocol(const std::string& protocol); |
| 546 | |
Alexander Afanasyev | 691c3ce | 2014-04-23 14:28:04 -0700 | [diff] [blame] | 547 | class ProcessEventsTimeout |
| 548 | { |
| 549 | }; |
| 550 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 551 | void |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 552 | onReceiveElement(const Block& wire); |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 553 | |
Alexander Afanasyev | 7dced46 | 2014-03-19 15:12:32 -0700 | [diff] [blame] | 554 | void |
| 555 | asyncShutdown(); |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 556 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 557 | static void |
| 558 | fireProcessEventsTimeout(const boost::system::error_code& error); |
| 559 | |
Jeff Thompson | b982b6d | 2013-07-15 18:15:45 -0700 | [diff] [blame] | 560 | private: |
Alexander Afanasyev | f39c537 | 2014-02-17 19:42:56 -0800 | [diff] [blame] | 561 | shared_ptr<boost::asio::io_service> m_ioService; |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 562 | |
Alexander Afanasyev | f39c537 | 2014-02-17 19:42:56 -0800 | [diff] [blame] | 563 | shared_ptr<Transport> m_transport; |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 564 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 565 | shared_ptr<nfd::Controller> m_nfdController; |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 566 | bool m_isDirectNfdFibManagementRequested; |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 567 | |
Alexander Afanasyev | 258ec2b | 2014-05-14 16:15:37 -0700 | [diff] [blame] | 568 | class Impl; |
| 569 | shared_ptr<Impl> m_impl; |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 570 | }; |
| 571 | |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 572 | inline bool |
| 573 | Face::isSupportedNfdProtocol(const std::string& protocol) |
| 574 | { |
| 575 | return protocol == "nfd-0.1"; |
| 576 | } |
| 577 | |
| 578 | inline bool |
| 579 | Face::isSupportedNrdProtocol(const std::string& protocol) |
| 580 | { |
| 581 | return protocol == "nrd-0.1"; |
| 582 | } |
| 583 | |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 584 | inline void |
| 585 | Face::setDirectFibManagement(bool isDirectFibManagementRequested/* = false*/) |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 586 | { |
Alexander Afanasyev | ee8bb1e | 2014-05-02 17:39:54 -0700 | [diff] [blame] | 587 | m_isDirectNfdFibManagementRequested = isDirectFibManagementRequested; |
Steve DiBenedetto | c07b3a2 | 2014-03-19 12:32:52 -0600 | [diff] [blame] | 588 | } |
| 589 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 590 | } // namespace ndn |
Jeff Thompson | aa4e6db | 2013-07-15 17:25:23 -0700 | [diff] [blame] | 591 | |
Alexander Afanasyev | 0222fba | 2014-02-09 23:16:02 -0800 | [diff] [blame] | 592 | #endif // NDN_FACE_HPP |