Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2014, Regents of the University of California. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 7 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 8 | * |
| 9 | * This file licensed under New BSD License. See COPYING for detailed information about |
| 10 | * ndn-cxx library copyright, permissions, and redistribution restrictions. |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef NDN_SELECTORS_HPP |
| 14 | #define NDN_SELECTORS_HPP |
| 15 | |
| 16 | #include "common.hpp" |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 17 | #include "key-locator.hpp" |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 18 | #include "exclude.hpp" |
| 19 | #include "encoding/encoding-buffer.hpp" |
| 20 | |
| 21 | namespace ndn { |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 22 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 23 | /** |
| 24 | * @brief Abstraction implementing Interest selectors |
| 25 | */ |
| 26 | class Selectors |
| 27 | { |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 28 | public: |
| 29 | Selectors() |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 30 | : m_minSuffixComponents(-1) |
| 31 | , m_maxSuffixComponents(-1) |
| 32 | , m_childSelector(-1) |
| 33 | , m_mustBeFresh(false) |
| 34 | { |
| 35 | } |
| 36 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 37 | /** @deprecated Selectors().setX(...).setY(...) |
| 38 | */ |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame^] | 39 | DEPRECATED( |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 40 | Selectors(int minSuffixComponents, int maxSuffixComponents, |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 41 | const Exclude& exclude, |
| 42 | int childSelector, |
Alexander Afanasyev | 9c57818 | 2014-05-14 17:28:28 -0700 | [diff] [blame^] | 43 | bool mustBeFresh)) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 44 | : m_minSuffixComponents(minSuffixComponents) |
| 45 | , m_maxSuffixComponents(maxSuffixComponents) |
| 46 | , m_exclude(exclude) |
| 47 | , m_childSelector(childSelector) |
| 48 | , m_mustBeFresh(mustBeFresh) |
| 49 | { |
| 50 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 51 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 52 | /** |
| 53 | * @brief Create from wire encoding |
| 54 | */ |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 55 | Selectors(const Block& wire) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 56 | { |
| 57 | wireDecode(wire); |
| 58 | } |
| 59 | |
| 60 | bool |
| 61 | empty() const; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 62 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 63 | /** |
| 64 | * @brief Fast encoding or block size estimation |
| 65 | */ |
| 66 | template<bool T> |
| 67 | size_t |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 68 | wireEncode(EncodingImpl<T>& block) const; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 69 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 70 | /** |
| 71 | * @brief Encode to a wire format |
| 72 | */ |
| 73 | const Block& |
| 74 | wireEncode() const; |
| 75 | |
| 76 | /** |
| 77 | * @brief Decode the input from wire format |
| 78 | */ |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 79 | void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 80 | wireDecode(const Block& wire); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 81 | |
| 82 | /////////////////////////////////////////////////////////////////////////////// |
| 83 | /////////////////////////////////////////////////////////////////////////////// |
| 84 | /////////////////////////////////////////////////////////////////////////////// |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 85 | |
| 86 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 87 | getMinSuffixComponents() const |
| 88 | { |
| 89 | return m_minSuffixComponents; |
| 90 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 91 | |
| 92 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 93 | setMinSuffixComponents(int minSuffixComponents) |
| 94 | { |
| 95 | m_minSuffixComponents = minSuffixComponents; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 96 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 97 | return *this; |
| 98 | } |
| 99 | |
| 100 | // |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 101 | |
| 102 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 103 | getMaxSuffixComponents() const |
| 104 | { |
| 105 | return m_maxSuffixComponents; |
| 106 | } |
| 107 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 108 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 109 | setMaxSuffixComponents(int maxSuffixComponents) |
| 110 | { |
| 111 | m_maxSuffixComponents = maxSuffixComponents; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 112 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 113 | return *this; |
| 114 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 115 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 116 | // |
| 117 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 118 | const KeyLocator& |
| 119 | getPublisherPublicKeyLocator() const |
| 120 | { |
| 121 | return m_publisherPublicKeyLocator; |
| 122 | } |
| 123 | |
| 124 | Selectors& |
| 125 | setPublisherPublicKeyLocator(const KeyLocator& keyLocator) |
| 126 | { |
| 127 | m_publisherPublicKeyLocator = keyLocator; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 128 | m_wire.reset(); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 129 | return *this; |
| 130 | } |
| 131 | |
| 132 | // |
| 133 | |
| 134 | const Exclude& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 135 | getExclude() const |
| 136 | { |
| 137 | return m_exclude; |
| 138 | } |
| 139 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 140 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 141 | setExclude(const Exclude& exclude) |
| 142 | { |
| 143 | m_exclude = exclude; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 144 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 145 | return *this; |
| 146 | } |
| 147 | |
| 148 | // |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 149 | |
| 150 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 151 | getChildSelector() const |
| 152 | { |
| 153 | return m_childSelector; |
| 154 | } |
| 155 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 156 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 157 | setChildSelector(int childSelector) |
| 158 | { |
| 159 | m_childSelector = childSelector; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 160 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 161 | return *this; |
| 162 | } |
| 163 | |
| 164 | // |
| 165 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 166 | int |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 167 | getMustBeFresh() const |
| 168 | { |
| 169 | return m_mustBeFresh; |
| 170 | } |
| 171 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 172 | Selectors& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 173 | setMustBeFresh(bool mustBeFresh) |
| 174 | { |
| 175 | m_mustBeFresh = mustBeFresh; |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 176 | m_wire.reset(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 177 | return *this; |
| 178 | } |
| 179 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 180 | public: // EqualityComparable concept |
| 181 | bool |
| 182 | operator==(const Selectors& other) const |
| 183 | { |
| 184 | return wireEncode() == other.wireEncode(); |
| 185 | } |
| 186 | |
| 187 | bool |
| 188 | operator!=(const Selectors& other) const |
| 189 | { |
| 190 | return !(*this == other); |
| 191 | } |
| 192 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 193 | private: |
| 194 | int m_minSuffixComponents; |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 195 | int m_maxSuffixComponents; |
| 196 | KeyLocator m_publisherPublicKeyLocator; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 197 | Exclude m_exclude; |
| 198 | int m_childSelector; |
| 199 | bool m_mustBeFresh; |
| 200 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 201 | mutable Block m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 202 | }; |
| 203 | |
| 204 | inline bool |
| 205 | Selectors::empty() const |
| 206 | { |
| 207 | return |
| 208 | (m_minSuffixComponents < 0 && |
| 209 | m_maxSuffixComponents < 0 && |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 210 | m_publisherPublicKeyLocator.empty() && |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 211 | m_exclude.empty() && |
| 212 | m_childSelector < 0 && |
| 213 | !m_mustBeFresh); |
| 214 | } |
| 215 | |
| 216 | template<bool T> |
| 217 | inline size_t |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 218 | Selectors::wireEncode(EncodingImpl<T>& block) const |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 219 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 220 | size_t totalLength = 0; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 221 | |
| 222 | // Selectors ::= SELECTORS-TYPE TLV-LENGTH |
| 223 | // MinSuffixComponents? |
| 224 | // MaxSuffixComponents? |
| 225 | // PublisherPublicKeyLocator? |
| 226 | // Exclude? |
| 227 | // ChildSelector? |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 228 | // MustBeFresh? |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 229 | |
| 230 | // (reverse encoding) |
| 231 | |
| 232 | // MustBeFresh |
| 233 | if (getMustBeFresh()) |
| 234 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 235 | totalLength += prependBooleanBlock(block, Tlv::MustBeFresh); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | // ChildSelector |
| 239 | if (getChildSelector() >= 0) |
| 240 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 241 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::ChildSelector, getChildSelector()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | // Exclude |
| 245 | if (!getExclude().empty()) |
| 246 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 247 | totalLength += getExclude().wireEncode(block); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 248 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 249 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 250 | // PublisherPublicKeyLocator |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 251 | if (!getPublisherPublicKeyLocator().empty()) |
| 252 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 253 | totalLength += getPublisherPublicKeyLocator().wireEncode(block); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 256 | // MaxSuffixComponents |
| 257 | if (getMaxSuffixComponents() >= 0) |
| 258 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 259 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::MaxSuffixComponents, |
| 260 | getMaxSuffixComponents()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 261 | } |
| 262 | |
| 263 | // MinSuffixComponents |
| 264 | if (getMinSuffixComponents() >= 0) |
| 265 | { |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 266 | totalLength += prependNonNegativeIntegerBlock(block, Tlv::MinSuffixComponents, |
| 267 | getMinSuffixComponents()); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 268 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 269 | |
Alexander Afanasyev | fdbfc6d | 2014-04-14 15:12:11 -0700 | [diff] [blame] | 270 | totalLength += block.prependVarNumber(totalLength); |
| 271 | totalLength += block.prependVarNumber(Tlv::Selectors); |
| 272 | return totalLength; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 273 | } |
| 274 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 275 | inline const Block& |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 276 | Selectors::wireEncode() const |
| 277 | { |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 278 | if (m_wire.hasWire()) |
| 279 | return m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 280 | |
| 281 | EncodingEstimator estimator; |
| 282 | size_t estimatedSize = wireEncode(estimator); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 283 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 284 | EncodingBuffer buffer(estimatedSize, 0); |
| 285 | wireEncode(buffer); |
| 286 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 287 | m_wire = buffer.block(); |
| 288 | return m_wire; |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | inline void |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 292 | Selectors::wireDecode(const Block& wire) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 293 | { |
| 294 | if (wire.type() != Tlv::Selectors) |
| 295 | throw Tlv::Error("Unexpected TLV type when decoding Selectors"); |
| 296 | |
| 297 | *this = Selectors(); |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 298 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 299 | m_wire = wire; |
| 300 | m_wire.parse(); |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 301 | |
| 302 | // MinSuffixComponents |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 303 | Block::element_const_iterator val = m_wire.find(Tlv::MinSuffixComponents); |
| 304 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 305 | { |
| 306 | m_minSuffixComponents = readNonNegativeInteger(*val); |
| 307 | } |
| 308 | |
| 309 | // MaxSuffixComponents |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 310 | val = m_wire.find(Tlv::MaxSuffixComponents); |
| 311 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 312 | { |
| 313 | m_maxSuffixComponents = readNonNegativeInteger(*val); |
| 314 | } |
| 315 | |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 316 | // PublisherPublicKeyLocator |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 317 | val = m_wire.find(Tlv::KeyLocator); |
| 318 | if (val != m_wire.elements_end()) |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 319 | { |
| 320 | m_publisherPublicKeyLocator.wireDecode(*val); |
| 321 | } |
| 322 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 323 | // Exclude |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 324 | val = m_wire.find(Tlv::Exclude); |
| 325 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 326 | { |
| 327 | m_exclude.wireDecode(*val); |
| 328 | } |
| 329 | |
| 330 | // ChildSelector |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 331 | val = m_wire.find(Tlv::ChildSelector); |
| 332 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 333 | { |
| 334 | m_childSelector = readNonNegativeInteger(*val); |
| 335 | } |
| 336 | |
| 337 | //MustBeFresh aka AnswerOriginKind |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 338 | val = m_wire.find(Tlv::MustBeFresh); |
| 339 | if (val != m_wire.elements_end()) |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 340 | { |
| 341 | m_mustBeFresh = true; |
| 342 | } |
| 343 | } |
Junxiao Shi | b332e78 | 2014-03-31 14:23:46 -0700 | [diff] [blame] | 344 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 345 | } // namespace ndn |
| 346 | |
| 347 | #endif // NDN_SELECTORS_HPP |