Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 2 | /** |
Jeff Thompson | 7687dc0 | 2013-09-13 11:54:07 -0700 | [diff] [blame] | 3 | * Copyright (C) 2013 Regents of the University of California. |
| 4 | * @author: Jeff Thompson <jefft0@remap.ucla.edu> |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 5 | * See COPYING for copyright and distribution information. |
| 6 | */ |
| 7 | |
| 8 | #ifndef NDN_NODE_HPP |
| 9 | #define NDN_NODE_HPP |
| 10 | |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 11 | #include "common.hpp" |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 12 | #include "interest.hpp" |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 13 | #include "data.hpp" |
Jeff Thompson | 1f8a31a | 2013-09-30 16:18:47 -0700 | [diff] [blame] | 14 | #include "forwarding-flags.hpp" |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 15 | #include "transport/transport.hpp" |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 16 | |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 17 | |
| 18 | namespace ndn { |
| 19 | |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 20 | /** |
| 21 | * An OnData function object is used to pass a callback to expressInterest. |
| 22 | */ |
Jeff Thompson | a6d15c8 | 2013-09-17 15:34:32 -0700 | [diff] [blame] | 23 | typedef func_lib::function<void(const ptr_lib::shared_ptr<const Interest>&, const ptr_lib::shared_ptr<Data>&)> OnData; |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * An OnTimeout function object is used to pass a callback to expressInterest. |
| 27 | */ |
Jeff Thompson | a6d15c8 | 2013-09-17 15:34:32 -0700 | [diff] [blame] | 28 | typedef func_lib::function<void(const ptr_lib::shared_ptr<const Interest>&)> OnTimeout; |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 29 | |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 30 | /** |
| 31 | * An OnInterest function object is used to pass a callback to registerPrefix. |
| 32 | */ |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 33 | typedef func_lib::function<void |
Jeff Thompson | b510e3e | 2013-10-07 18:53:20 -0700 | [diff] [blame] | 34 | (const ptr_lib::shared_ptr<const Name>&, const ptr_lib::shared_ptr<const Interest>&, Transport&, uint64_t)> OnInterest; |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 35 | |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 36 | /** |
| 37 | * An OnRegisterFailed function object is used to report when registerPrefix fails. |
| 38 | */ |
| 39 | typedef func_lib::function<void(const ptr_lib::shared_ptr<const Name>&)> OnRegisterFailed; |
| 40 | |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 41 | class Face; |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 42 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 43 | class Node { |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 44 | public: |
| 45 | /** |
Jeff Thompson | 10e3438 | 2013-08-22 13:34:46 -0700 | [diff] [blame] | 46 | * Create a new Node for communication with an NDN hub with the given Transport object and connectionInfo. |
| 47 | * @param transport A shared_ptr to a Transport object used for communication. |
| 48 | * @param transport A shared_ptr to a Transport::ConnectionInfo to be used to connect to the transport. |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 49 | */ |
Alexander Afanasyev | 0b688dc | 2013-12-18 16:43:37 -0800 | [diff] [blame] | 50 | Node(const ptr_lib::shared_ptr<Transport>& transport); |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 51 | |
| 52 | /** |
Jeff Thompson | 4fe4551 | 2013-08-23 14:06:38 -0700 | [diff] [blame] | 53 | * Send the Interest through the transport, read the entire response and call onData(interest, data). |
| 54 | * @param interest A reference to the Interest. This copies the Interest. |
| 55 | * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to |
| 56 | * use func_lib::ref() as appropriate. |
| 57 | * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it. |
| 58 | * This copies the function object, so you may need to use func_lib::ref() as appropriate. |
Jeff Thompson | 978c152 | 2013-11-12 23:03:10 -0800 | [diff] [blame] | 59 | * @param wireFormat A WireFormat object used to encode the message. |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 60 | * @return The pending interest ID which can be used with removePendingInterest. |
Jeff Thompson | 4fe4551 | 2013-08-23 14:06:38 -0700 | [diff] [blame] | 61 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 62 | uint64_t |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 63 | expressInterest(const Interest& interest, const OnData& onData, const OnTimeout& onTimeout); |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 64 | |
| 65 | /** |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 66 | * Remove the pending interest entry with the pendingInterestId from the pending interest table. |
| 67 | * This does not affect another pending interest with a different pendingInterestId, even it if has the same interest name. |
| 68 | * If there is no entry with the pendingInterestId, do nothing. |
| 69 | * @param pendingInterestId The ID returned from expressInterest. |
| 70 | */ |
| 71 | void |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 72 | removePendingInterest(uint64_t pendingInterestId); |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 75 | * Register prefix with the connected NDN hub and call onInterest when a matching interest is received. |
| 76 | * @param prefix A reference to a Name for the prefix to register. This copies the Name. |
| 77 | * @param onInterest A function object to call when a matching interest is received. This copies the function object, so you may need to |
| 78 | * use func_lib::ref() as appropriate. |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 79 | * @param onRegisterFailed A function object to call if failed to retrieve the connected hub’s ID or failed to register the prefix. |
| 80 | * This calls onRegisterFailed(prefix) where prefix is the prefix given to registerPrefix. |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 81 | * @param flags The flags for finer control of which interests are forward to the application. |
Jeff Thompson | 978c152 | 2013-11-12 23:03:10 -0800 | [diff] [blame] | 82 | * @param wireFormat A WireFormat object used to encode the message. |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 83 | * @return The registered prefix ID which can be used with removeRegisteredPrefix. |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 84 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 85 | uint64_t |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 86 | registerPrefix |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 87 | (const Name& prefix, const OnInterest& onInterest, const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags); |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 88 | |
| 89 | /** |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 90 | * Remove the registered prefix entry with the registeredPrefixId from the pending interest table. |
| 91 | * This does not affect another registered prefix with a different registeredPrefixId, even it if has the same prefix name. |
| 92 | * If there is no entry with the registeredPrefixId, do nothing. |
| 93 | * @param registeredPrefixId The ID returned from registerPrefix. |
| 94 | */ |
| 95 | void |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 96 | removeRegisteredPrefix(uint64_t registeredPrefixId); |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 97 | |
| 98 | /** |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 99 | * Process any data to receive. For each element received, call onReceivedElement. |
| 100 | * This is non-blocking and will return immediately if there is no data to receive. |
| 101 | * You should repeatedly call this from an event loop, with calls to sleep as needed so that the loop doesn't use 100% of the CPU. |
| 102 | * @throw This may throw an exception for reading data or in the callback for processing the data. If you |
| 103 | * call this from an main event loop, you may want to catch and log/disregard all exceptions. |
| 104 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 105 | void |
| 106 | processEvents(); |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 107 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 108 | const ptr_lib::shared_ptr<Transport>& |
| 109 | getTransport() { return transport_; } |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 110 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 111 | void |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 112 | shutdown(); |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 113 | |
| 114 | private: |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 115 | void |
| 116 | onReceiveElement(const Block &wire); |
| 117 | |
| 118 | private: |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 119 | class PendingInterest { |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 120 | public: |
| 121 | /** |
| 122 | * Create a new PitEntry and set the timeoutTime_ based on the current time and the interest lifetime. |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 123 | * @param pendingInterestId A unique ID for this entry, which you should get with getNextPendingInteresId(). |
Jeff Thompson | 48917f0 | 2013-08-21 17:12:45 -0700 | [diff] [blame] | 124 | * @param interest A shared_ptr for the interest. |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 125 | * @param onData A function object to call when a matching data packet is received. |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 126 | * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it. |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 127 | */ |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 128 | PendingInterest |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 129 | (uint64_t pendingInterestId, const ptr_lib::shared_ptr<const Interest>& interest, const OnData& onData, |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 130 | const OnTimeout& onTimeout); |
| 131 | |
| 132 | /** |
| 133 | * Return the next unique pending interest ID. |
| 134 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 135 | static uint64_t |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 136 | getNextPendingInterestId() |
| 137 | { |
| 138 | return ++lastPendingInterestId_; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Return the pendingInterestId given to the constructor. |
| 143 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 144 | uint64_t |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 145 | getPendingInterestId() { return pendingInterestId_; } |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 146 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 147 | const ptr_lib::shared_ptr<const Interest>& |
| 148 | getInterest() { return interest_; } |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 149 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 150 | const OnData& |
| 151 | getOnData() { return onData_; } |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 152 | |
| 153 | /** |
Jeff Thompson | 3b0ed53 | 2013-11-05 13:43:40 -0800 | [diff] [blame] | 154 | * Check if this interest is timed out. |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 155 | * @param nowMilliseconds The current time in milliseconds from ndn_getNowMilliseconds. |
Jeff Thompson | 3b0ed53 | 2013-11-05 13:43:40 -0800 | [diff] [blame] | 156 | * @return true if this interest timed out, otherwise false. |
Jeff Thompson | 48917f0 | 2013-08-21 17:12:45 -0700 | [diff] [blame] | 157 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 158 | bool |
Jeff Thompson | 3b0ed53 | 2013-11-05 13:43:40 -0800 | [diff] [blame] | 159 | isTimedOut(MillisecondsSince1970 nowMilliseconds) |
| 160 | { |
| 161 | return timeoutTimeMilliseconds_ >= 0.0 && nowMilliseconds >= timeoutTimeMilliseconds_; |
| 162 | } |
| 163 | |
| 164 | /** |
| 165 | * Call onTimeout_ (if defined). This ignores exceptions from the onTimeout_. |
| 166 | */ |
| 167 | void |
| 168 | callTimeout(); |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 169 | |
| 170 | private: |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 171 | static uint64_t lastPendingInterestId_; /**< A class variable used to get the next unique ID. */ |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 172 | |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 173 | uint64_t pendingInterestId_; /**< A unique identifier for this entry so it can be deleted */ |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 174 | ptr_lib::shared_ptr<const Interest> interest_; |
Jeff Thompson | 7aec025 | 2013-08-22 17:29:57 -0700 | [diff] [blame] | 175 | const OnData onData_; |
| 176 | const OnTimeout onTimeout_; |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 177 | |
Jeff Thompson | 9a8e82f | 2013-10-17 14:13:43 -0700 | [diff] [blame] | 178 | MillisecondsSince1970 timeoutTimeMilliseconds_; /**< The time when the interest times out in milliseconds according to ndn_getNowMilliseconds, or -1 for no timeout. */ |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 179 | }; |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 180 | |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 181 | class RegisteredPrefix { |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 182 | public: |
| 183 | /** |
| 184 | * Create a new PrefixEntry. |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 185 | * @param registeredPrefixId A unique ID for this entry, which you should get with getNextRegisteredPrefixId(). |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 186 | * @param prefix A shared_ptr for the prefix. |
| 187 | * @param onInterest A function object to call when a matching data packet is received. |
| 188 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 189 | RegisteredPrefix(uint64_t registeredPrefixId, const ptr_lib::shared_ptr<const Name>& prefix, const OnInterest& onInterest) |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 190 | : registeredPrefixId_(registeredPrefixId) |
| 191 | , prefix_(prefix) |
| 192 | , onInterest_(onInterest) |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 193 | { |
| 194 | } |
| 195 | |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 196 | /** |
| 197 | * Return the next unique entry ID. |
| 198 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 199 | static uint64_t |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 200 | getNextRegisteredPrefixId() |
| 201 | { |
| 202 | return ++lastRegisteredPrefixId_; |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * Return the registeredPrefixId given to the constructor. |
| 207 | */ |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 208 | uint64_t |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 209 | getRegisteredPrefixId() |
| 210 | { |
| 211 | return registeredPrefixId_; |
| 212 | } |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 213 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 214 | const ptr_lib::shared_ptr<const Name>& |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 215 | getPrefix() |
| 216 | { |
| 217 | return prefix_; |
| 218 | } |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 219 | |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 220 | const OnInterest& |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 221 | getOnInterest() |
| 222 | { |
| 223 | return onInterest_; |
| 224 | } |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 225 | |
| 226 | private: |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 227 | static uint64_t lastRegisteredPrefixId_; /**< A class variable used to get the next unique ID. */ |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 228 | |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 229 | uint64_t registeredPrefixId_; /**< A unique identifier for this entry so it can be deleted */ |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 230 | ptr_lib::shared_ptr<const Name> prefix_; |
| 231 | const OnInterest onInterest_; |
| 232 | }; |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 233 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 234 | typedef std::vector<ptr_lib::shared_ptr<PendingInterest> > PendingInterestTable; |
| 235 | typedef std::vector<ptr_lib::shared_ptr<RegisteredPrefix> > RegisteredPrefixTable; |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 236 | |
| 237 | /** |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 238 | * Find the entry from the pit_ where the name conforms to the entry's interest selectors, and |
| 239 | * the entry interest name is the longest that matches name. |
| 240 | * @param name The name to find the interest for (from the incoming data packet). |
| 241 | * @return The index in pit_ of the pit entry, or -1 if not found. |
| 242 | */ |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 243 | PendingInterestTable::iterator |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 244 | getEntryIndexForExpressedInterest(const Name& name); |
Jeff Thompson | 557b81e | 2013-08-21 15:13:51 -0700 | [diff] [blame] | 245 | |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 246 | /** |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 247 | * Find the first entry from the registeredPrefixTable_ where the entry prefix is the longest that matches name. |
| 248 | * @param name The name to find the PrefixEntry for (from the incoming interest packet). |
| 249 | * @return A pointer to the entry, or 0 if not found. |
| 250 | */ |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 251 | RegisteredPrefixTable::iterator |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 252 | getEntryForRegisteredPrefix(const Name& name); |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 253 | |
Jeff Thompson | 9cc4be4 | 2013-08-27 18:12:41 -0700 | [diff] [blame] | 254 | /** |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 255 | * Do the work of registerPrefix once we know we are connected with an ndndId_. |
Jeff Thompson | 1109514 | 2013-10-01 16:20:28 -0700 | [diff] [blame] | 256 | * @param registeredPrefixId The PrefixEntry::getNextRegisteredPrefixId() which registerPrefix got so it could return it to the caller. |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 257 | * @param prefix |
| 258 | * @param onInterest |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 259 | * @param onRegisterFailed |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 260 | * @param flags |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 261 | * @param wireFormat |
| 262 | */ |
Jeff Thompson | 0050abe | 2013-09-17 12:50:25 -0700 | [diff] [blame] | 263 | void |
Jeff Thompson | 590ec23 | 2013-09-18 15:55:56 -0700 | [diff] [blame] | 264 | registerPrefixHelper |
Jeff Thompson | 62992e4 | 2013-10-07 18:50:51 -0700 | [diff] [blame] | 265 | (uint64_t registeredPrefixId, const ptr_lib::shared_ptr<const Name>& prefix, const OnInterest& onInterest, |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 266 | const OnRegisterFailed& onRegisterFailed, const ForwardingFlags& flags); |
| 267 | |
Alexander Afanasyev | 1837187 | 2014-01-05 23:00:26 -0800 | [diff] [blame] | 268 | /** |
| 269 | * @brief Final stage of prefix registration, invoked when registration succeeded |
| 270 | * |
| 271 | * This method actually sets entry in a local interest filter table |
| 272 | */ |
| 273 | void |
| 274 | registerPrefixFinal(uint64_t registeredPrefixId, |
| 275 | const ptr_lib::shared_ptr<const Name>& prefix, |
| 276 | const OnInterest& onInterest, |
| 277 | const OnRegisterFailed& onRegisterFailed, |
| 278 | const ptr_lib::shared_ptr<const Interest>&, const ptr_lib::shared_ptr<Data>&); |
| 279 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 280 | void |
| 281 | checkPitExpire(); |
| 282 | |
| 283 | private: |
| 284 | boost::asio::io_service ioService_; |
| 285 | boost::asio::deadline_timer timer_; |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 286 | |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 287 | ptr_lib::shared_ptr<Transport> transport_; |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 288 | |
| 289 | PendingInterestTable pendingInterestTable_; |
| 290 | RegisteredPrefixTable registeredPrefixTable_; |
Jeff Thompson | 86507bc | 2013-08-23 20:51:38 -0700 | [diff] [blame] | 291 | Interest ndndIdFetcherInterest_; |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 292 | Buffer ndndId_; |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 293 | }; |
| 294 | |
Alexander Afanasyev | e2e0d75 | 2014-01-03 13:30:30 -0800 | [diff] [blame] | 295 | } // namespace ndn |
Jeff Thompson | bf50a1a | 2013-08-20 18:01:01 -0700 | [diff] [blame] | 296 | |
| 297 | #endif |