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