Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 2 | /* |
Alexander Afanasyev | 1013fd0 | 2017-01-03 13:19:03 -0800 | [diff] [blame] | 3 | * Copyright (c) 2013-2017 Regents of the University of California. |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 6 | * |
Alexander Afanasyev | c169a81 | 2014-05-20 20:37:29 -0400 | [diff] [blame] | 7 | * ndn-cxx library is free software: you can redistribute it and/or modify it under the |
| 8 | * terms of the GNU Lesser General Public License as published by the Free Software |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY |
| 12 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 13 | * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received copies of the GNU General Public License and GNU Lesser |
| 16 | * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see |
| 17 | * <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 20 | */ |
| 21 | |
| 22 | #ifndef NDN_INTEREST_HPP |
Jeff Thompson | 2d27e2f | 2013-08-09 12:55:00 -0700 | [diff] [blame] | 23 | #define NDN_INTEREST_HPP |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 24 | |
Junxiao Shi | 9c154cb | 2017-07-07 22:14:54 +0000 | [diff] [blame] | 25 | #include "delegation-list.hpp" |
Jeff Thompson | 5341219 | 2013-08-06 13:35:50 -0700 | [diff] [blame] | 26 | #include "name.hpp" |
Eric Newberry | c3a4679 | 2017-09-24 14:54:24 -0700 | [diff] [blame^] | 27 | #include "packet-base.hpp" |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 28 | #include "selectors.hpp" |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 29 | #include "util/time.hpp" |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 30 | |
| 31 | namespace ndn { |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 32 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 33 | class Data; |
| 34 | |
Junxiao Shi | 7007a3c | 2014-11-20 22:37:55 -0700 | [diff] [blame] | 35 | /** @var const unspecified_duration_type DEFAULT_INTEREST_LIFETIME; |
| 36 | * @brief default value for InterestLifetime |
| 37 | */ |
| 38 | const time::milliseconds DEFAULT_INTEREST_LIFETIME = time::milliseconds(4000); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 39 | |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 40 | /** @brief represents an Interest packet |
Jeff Thompson | 8238d00 | 2013-07-10 11:56:49 -0700 | [diff] [blame] | 41 | */ |
Eric Newberry | c3a4679 | 2017-09-24 14:54:24 -0700 | [diff] [blame^] | 42 | class Interest : public PacketBase, public enable_shared_from_this<Interest> |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 43 | { |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 44 | public: |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 45 | class Error : public tlv::Error |
| 46 | { |
| 47 | public: |
| 48 | explicit |
| 49 | Error(const std::string& what) |
| 50 | : tlv::Error(what) |
| 51 | { |
| 52 | } |
| 53 | }; |
| 54 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 55 | /** @brief Create a new Interest with the given name and interest lifetime |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 56 | * @throw std::invalid_argument InterestLifetime is negative |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 57 | * @warning In certain contexts that use Interest::shared_from_this(), Interest must be created |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 58 | * using `make_shared`. Otherwise, .shared_from_this() will trigger undefined behavior. |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 59 | */ |
Junxiao Shi | 909ffef | 2017-07-07 22:12:27 +0000 | [diff] [blame] | 60 | explicit |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 61 | Interest(const Name& name = Name(), time::milliseconds interestLifetime = DEFAULT_INTEREST_LIFETIME); |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 62 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 63 | /** @brief Create from wire encoding |
| 64 | * @warning In certain contexts that use Interest::shared_from_this(), Interest must be created |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 65 | * using `make_shared`. Otherwise, .shared_from_this() will trigger undefined behavior. |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 66 | */ |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 67 | explicit |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 68 | Interest(const Block& wire); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 69 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 70 | /** |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 71 | * @brief Fast encoding or block size estimation |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 72 | */ |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 73 | template<encoding::Tag TAG> |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 74 | size_t |
Alexander Afanasyev | d5c48e0 | 2015-06-24 11:58:14 -0700 | [diff] [blame] | 75 | wireEncode(EncodingImpl<TAG>& encoder) const; |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 76 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 77 | /** |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 78 | * @brief Encode to a wire format |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 79 | */ |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 80 | const Block& |
Alexander Afanasyev | 1eb961a | 2014-01-03 13:51:49 -0800 | [diff] [blame] | 81 | wireEncode() const; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 82 | |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 83 | /** |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 84 | * @brief Decode from the wire format |
Jeff Thompson | 1b4a7b1 | 2013-11-15 12:00:02 -0800 | [diff] [blame] | 85 | */ |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 86 | void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 87 | wireDecode(const Block& wire); |
Alexander Afanasyev | 6d48bc1 | 2014-02-18 00:10:51 -0800 | [diff] [blame] | 88 | |
| 89 | /** |
| 90 | * @brief Check if already has wire |
| 91 | */ |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 92 | bool |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 93 | hasWire() const |
| 94 | { |
| 95 | return m_wire.hasWire(); |
| 96 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 97 | |
Jeff Thompson | d9e278c | 2013-07-08 15:20:13 -0700 | [diff] [blame] | 98 | /** |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 99 | * @brief Encode the name according to the NDN URI Scheme |
| 100 | * |
| 101 | * If there are interest selectors, this method will append "?" and add the selectors as |
| 102 | * a query string. For example, "/test/name?ndn.ChildSelector=1" |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 103 | */ |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 104 | std::string |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 105 | toUri() const; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 106 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 107 | public: // matching |
| 108 | /** @brief Check if Interest, including selectors, matches the given @p name |
| 109 | * @param name The name to be matched. If this is a Data name, it shall contain the |
| 110 | * implicit digest component |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 111 | */ |
| 112 | bool |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 113 | matchesName(const Name& name) const; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 114 | |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 115 | /** |
| 116 | * @brief Check if Interest can be satisfied by @p data. |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 117 | * |
Alexander Afanasyev | 770827c | 2014-05-13 17:42:55 -0700 | [diff] [blame] | 118 | * This method considers Name, MinSuffixComponents, MaxSuffixComponents, |
| 119 | * PublisherPublicKeyLocator, and Exclude. |
| 120 | * This method does not consider ChildSelector and MustBeFresh. |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 121 | */ |
| 122 | bool |
| 123 | matchesData(const Data& data) const; |
| 124 | |
Alexander Afanasyev | 1013fd0 | 2017-01-03 13:19:03 -0800 | [diff] [blame] | 125 | /** |
| 126 | * @brief Check if Interest matches @p other interest |
| 127 | * |
| 128 | * Interest matches @p other if both have the same name, selectors, and link. Other fields |
| 129 | * (e.g., Nonce) may be different. |
| 130 | * |
| 131 | * @todo Implement distinguishing interests by link. The current implementation checks only |
| 132 | * name+selectors (Issue #3162). |
| 133 | */ |
| 134 | bool |
| 135 | matchesInterest(const Interest& other) const; |
| 136 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 137 | public: // Name, Nonce, and Guiders |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 138 | const Name& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 139 | getName() const |
Jeff Thompson | c0486c1 | 2013-07-16 14:36:16 -0700 | [diff] [blame] | 140 | { |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 141 | return m_name; |
| 142 | } |
| 143 | |
| 144 | Interest& |
| 145 | setName(const Name& name) |
| 146 | { |
| 147 | m_name = name; |
| 148 | m_wire.reset(); |
| 149 | return *this; |
Jeff Thompson | c0486c1 | 2013-07-16 14:36:16 -0700 | [diff] [blame] | 150 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 151 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 152 | /** @brief Check if Nonce set |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 153 | */ |
| 154 | bool |
| 155 | hasNonce() const |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 156 | { |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 157 | return static_cast<bool>(m_nonce); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 160 | /** @brief Get nonce |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 161 | * |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 162 | * If nonce was not set before this call, it will be automatically assigned to a random value |
| 163 | */ |
| 164 | uint32_t |
| 165 | getNonce() const; |
| 166 | |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 167 | /** @brief Set nonce |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 168 | */ |
| 169 | Interest& |
| 170 | setNonce(uint32_t nonce); |
| 171 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 172 | /** @brief Refresh nonce |
Alexander Afanasyev | c393217 | 2014-07-10 18:53:56 -0700 | [diff] [blame] | 173 | * |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 174 | * It's guaranteed that new nonce value differs from the existing one. |
Alexander Afanasyev | c393217 | 2014-07-10 18:53:56 -0700 | [diff] [blame] | 175 | * |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 176 | * If nonce is already set, it will be updated to a different random value. |
| 177 | * If nonce is not set, this method does nothing. |
Alexander Afanasyev | c393217 | 2014-07-10 18:53:56 -0700 | [diff] [blame] | 178 | */ |
| 179 | void |
| 180 | refreshNonce(); |
| 181 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 182 | time::milliseconds |
| 183 | getInterestLifetime() const |
| 184 | { |
| 185 | return m_interestLifetime; |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * @brief Set Interest's lifetime |
| 190 | * @throw std::invalid_argument specified lifetime is < 0 |
| 191 | */ |
| 192 | Interest& |
| 193 | setInterestLifetime(time::milliseconds interestLifetime); |
| 194 | |
Junxiao Shi | 9c154cb | 2017-07-07 22:14:54 +0000 | [diff] [blame] | 195 | const DelegationList& |
| 196 | getForwardingHint() const |
| 197 | { |
| 198 | return m_forwardingHint; |
| 199 | } |
| 200 | |
| 201 | Interest& |
| 202 | setForwardingHint(const DelegationList& value); |
| 203 | |
Junxiao Shi | b2a7033 | 2017-07-07 22:15:03 +0000 | [diff] [blame] | 204 | /** @brief modify ForwardingHint in-place |
| 205 | * @tparam Modifier a unary function that accepts DelegationList& |
| 206 | * |
| 207 | * This is equivalent to, but more efficient (avoids copying) than: |
| 208 | * @code |
| 209 | * auto fh = interest.getForwardingHint(); |
| 210 | * modifier(fh); |
| 211 | * interest.setForwardingHint(fh); |
| 212 | * @endcode |
| 213 | */ |
| 214 | template<typename Modifier> |
| 215 | Interest& |
| 216 | modifyForwardingHint(const Modifier& modifier) |
| 217 | { |
| 218 | modifier(m_forwardingHint); |
| 219 | m_wire.reset(); |
| 220 | return *this; |
| 221 | } |
| 222 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 223 | public: // Selectors |
| 224 | /** |
| 225 | * @return true if Interest has any selector present |
| 226 | */ |
| 227 | bool |
| 228 | hasSelectors() const |
| 229 | { |
| 230 | return !m_selectors.empty(); |
| 231 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 232 | |
Junxiao Shi | 2af905b | 2014-11-27 13:10:54 -0700 | [diff] [blame] | 233 | const Selectors& |
| 234 | getSelectors() const |
| 235 | { |
| 236 | return m_selectors; |
| 237 | } |
| 238 | |
| 239 | Interest& |
| 240 | setSelectors(const Selectors& selectors) |
| 241 | { |
| 242 | m_selectors = selectors; |
| 243 | m_wire.reset(); |
| 244 | return *this; |
| 245 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 246 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 247 | int |
| 248 | getMinSuffixComponents() const |
| 249 | { |
| 250 | return m_selectors.getMinSuffixComponents(); |
| 251 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 252 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 253 | Interest& |
| 254 | setMinSuffixComponents(int minSuffixComponents) |
| 255 | { |
| 256 | m_selectors.setMinSuffixComponents(minSuffixComponents); |
| 257 | m_wire.reset(); |
| 258 | return *this; |
| 259 | } |
| 260 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 261 | int |
| 262 | getMaxSuffixComponents() const |
| 263 | { |
| 264 | return m_selectors.getMaxSuffixComponents(); |
| 265 | } |
| 266 | |
| 267 | Interest& |
| 268 | setMaxSuffixComponents(int maxSuffixComponents) |
| 269 | { |
| 270 | m_selectors.setMaxSuffixComponents(maxSuffixComponents); |
| 271 | m_wire.reset(); |
| 272 | return *this; |
| 273 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 274 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 275 | const KeyLocator& |
| 276 | getPublisherPublicKeyLocator() const |
| 277 | { |
| 278 | return m_selectors.getPublisherPublicKeyLocator(); |
| 279 | } |
| 280 | |
| 281 | Interest& |
| 282 | setPublisherPublicKeyLocator(const KeyLocator& keyLocator) |
| 283 | { |
| 284 | m_selectors.setPublisherPublicKeyLocator(keyLocator); |
| 285 | m_wire.reset(); |
| 286 | return *this; |
| 287 | } |
| 288 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 289 | const Exclude& |
| 290 | getExclude() const |
| 291 | { |
| 292 | return m_selectors.getExclude(); |
| 293 | } |
| 294 | |
| 295 | Interest& |
| 296 | setExclude(const Exclude& exclude) |
| 297 | { |
| 298 | m_selectors.setExclude(exclude); |
| 299 | m_wire.reset(); |
| 300 | return *this; |
| 301 | } |
| 302 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 303 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 304 | getChildSelector() const |
| 305 | { |
| 306 | return m_selectors.getChildSelector(); |
| 307 | } |
| 308 | |
| 309 | Interest& |
| 310 | setChildSelector(int childSelector) |
| 311 | { |
| 312 | m_selectors.setChildSelector(childSelector); |
| 313 | m_wire.reset(); |
| 314 | return *this; |
| 315 | } |
| 316 | |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 317 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 318 | getMustBeFresh() const |
| 319 | { |
| 320 | return m_selectors.getMustBeFresh(); |
| 321 | } |
| 322 | |
| 323 | Interest& |
| 324 | setMustBeFresh(bool mustBeFresh) |
| 325 | { |
| 326 | m_selectors.setMustBeFresh(mustBeFresh); |
| 327 | m_wire.reset(); |
| 328 | return *this; |
| 329 | } |
| 330 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 331 | private: |
| 332 | Name m_name; |
| 333 | Selectors m_selectors; |
Junxiao Shi | 2dd711d | 2017-07-21 13:40:52 +0000 | [diff] [blame] | 334 | mutable optional<uint32_t> m_nonce; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 335 | time::milliseconds m_interestLifetime; |
Junxiao Shi | 9c154cb | 2017-07-07 22:14:54 +0000 | [diff] [blame] | 336 | DelegationList m_forwardingHint; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 337 | |
| 338 | mutable Block m_wire; |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 339 | }; |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 340 | |
Davide Pesavento | 88a0d81 | 2017-08-19 21:31:42 -0400 | [diff] [blame] | 341 | NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Interest); |
| 342 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 343 | std::ostream& |
| 344 | operator<<(std::ostream& os, const Interest& interest); |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 345 | |
Junxiao Shi | 899277a | 2017-07-07 22:12:12 +0000 | [diff] [blame] | 346 | inline bool |
| 347 | operator==(const Interest& lhs, const Interest& rhs) |
| 348 | { |
| 349 | return lhs.wireEncode() == rhs.wireEncode(); |
| 350 | } |
| 351 | |
| 352 | inline bool |
| 353 | operator!=(const Interest& lhs, const Interest& rhs) |
| 354 | { |
| 355 | return !(lhs == rhs); |
| 356 | } |
| 357 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 358 | } // namespace ndn |
| 359 | |
| 360 | #endif // NDN_INTEREST_HPP |