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 | 47eecfc | 2013-07-07 22:56:46 -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 | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 22 | */ |
| 23 | |
Alexander Afanasyev | 09c613f | 2014-01-29 00:23:58 -0800 | [diff] [blame] | 24 | #include "interest.hpp" |
Alexander Afanasyev | e9fdb80 | 2014-02-05 17:36:51 -0800 | [diff] [blame] | 25 | #include "util/random.hpp" |
Junxiao Shi | 42c2362 | 2014-07-03 00:55:11 -0700 | [diff] [blame] | 26 | #include "util/crypto.hpp" |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 27 | #include "util/concepts.hpp" |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 28 | #include "data.hpp" |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 29 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 30 | namespace ndn { |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 31 | |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 32 | BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Interest>)); |
| 33 | BOOST_CONCEPT_ASSERT((WireEncodable<Interest>)); |
| 34 | BOOST_CONCEPT_ASSERT((WireDecodable<Interest>)); |
| 35 | static_assert(std::is_base_of<tlv::Error, Interest::Error>::value, |
| 36 | "Interest::Error must inherit from tlv::Error"); |
| 37 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 38 | uint32_t |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 39 | Interest::getNonce() const |
| 40 | { |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 41 | if (!m_nonce.hasWire()) |
| 42 | const_cast<Interest*>(this)->setNonce(random::generateWord32()); |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 43 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 44 | if (m_nonce.value_size() == sizeof(uint32_t)) |
| 45 | return *reinterpret_cast<const uint32_t*>(m_nonce.value()); |
| 46 | else { |
| 47 | // for compatibility reasons. Should be removed eventually |
| 48 | return readNonNegativeInteger(m_nonce); |
| 49 | } |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 50 | } |
| 51 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 52 | Interest& |
| 53 | Interest::setNonce(uint32_t nonce) |
| 54 | { |
| 55 | if (m_wire.hasWire() && m_nonce.value_size() == sizeof(uint32_t)) { |
| 56 | std::memcpy(const_cast<uint8_t*>(m_nonce.value()), &nonce, sizeof(nonce)); |
| 57 | } |
| 58 | else { |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 59 | m_nonce = dataBlock(tlv::Nonce, |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 60 | reinterpret_cast<const uint8_t*>(&nonce), |
| 61 | sizeof(nonce)); |
| 62 | m_wire.reset(); |
| 63 | } |
| 64 | return *this; |
| 65 | } |
Alexander Afanasyev | 840139f | 2013-12-28 15:02:50 -0800 | [diff] [blame] | 66 | |
Alexander Afanasyev | c393217 | 2014-07-10 18:53:56 -0700 | [diff] [blame] | 67 | void |
| 68 | Interest::refreshNonce() |
| 69 | { |
| 70 | if (!hasNonce()) |
| 71 | return; |
| 72 | |
| 73 | uint32_t oldNonce = getNonce(); |
| 74 | uint32_t newNonce = oldNonce; |
| 75 | while (newNonce == oldNonce) |
| 76 | newNonce = random::generateWord32(); |
| 77 | |
| 78 | setNonce(newNonce); |
| 79 | } |
| 80 | |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 81 | bool |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 82 | Interest::matchesName(const Name& name) const |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 83 | { |
Alexander Afanasyev | 1dd95c5 | 2014-03-22 19:11:36 -0700 | [diff] [blame] | 84 | if (name.size() < m_name.size()) |
| 85 | return false; |
| 86 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 87 | if (!m_name.isPrefixOf(name)) |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 88 | return false; |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 89 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 90 | if (getMinSuffixComponents() >= 0 && |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 91 | // name must include implicit digest |
| 92 | !(name.size() - m_name.size() >= static_cast<size_t>(getMinSuffixComponents()))) |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 93 | return false; |
| 94 | |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 95 | if (getMaxSuffixComponents() >= 0 && |
Alexander Afanasyev | 3b70310 | 2014-06-13 17:01:14 -0700 | [diff] [blame] | 96 | // name must include implicit digest |
| 97 | !(name.size() - m_name.size() <= static_cast<size_t>(getMaxSuffixComponents()))) |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 98 | return false; |
| 99 | |
Alexander Afanasyev | 1dd95c5 | 2014-03-22 19:11:36 -0700 | [diff] [blame] | 100 | if (!getExclude().empty() && |
| 101 | name.size() > m_name.size() && |
Alexander Afanasyev | c348f83 | 2014-02-17 16:35:17 -0800 | [diff] [blame] | 102 | getExclude().isExcluded(name[m_name.size()])) |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 103 | return false; |
| 104 | |
| 105 | return true; |
Jeff Thompson | 25b4e61 | 2013-10-10 16:03:24 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 108 | bool |
| 109 | Interest::matchesData(const Data& data) const |
| 110 | { |
Junxiao Shi | 42c2362 | 2014-07-03 00:55:11 -0700 | [diff] [blame] | 111 | size_t interestNameLength = m_name.size(); |
| 112 | const Name& dataName = data.getName(); |
| 113 | size_t fullNameLength = dataName.size() + 1; |
| 114 | |
| 115 | // check MinSuffixComponents |
| 116 | bool hasMinSuffixComponents = getMinSuffixComponents() >= 0; |
| 117 | size_t minSuffixComponents = hasMinSuffixComponents ? |
| 118 | static_cast<size_t>(getMinSuffixComponents()) : 0; |
| 119 | if (!(interestNameLength + minSuffixComponents <= fullNameLength)) |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 120 | return false; |
Junxiao Shi | 42c2362 | 2014-07-03 00:55:11 -0700 | [diff] [blame] | 121 | |
| 122 | // check MaxSuffixComponents |
| 123 | bool hasMaxSuffixComponents = getMaxSuffixComponents() >= 0; |
| 124 | if (hasMaxSuffixComponents && |
| 125 | !(interestNameLength + getMaxSuffixComponents() >= fullNameLength)) |
| 126 | return false; |
| 127 | |
| 128 | // check prefix |
| 129 | if (interestNameLength == fullNameLength) { |
Alexander Afanasyev | 56860f5 | 2014-11-07 11:51:17 -0800 | [diff] [blame] | 130 | if (m_name.get(-1).isImplicitSha256Digest()) { |
| 131 | if (m_name != data.getFullName()) |
Junxiao Shi | 42c2362 | 2014-07-03 00:55:11 -0700 | [diff] [blame] | 132 | return false; |
| 133 | } |
| 134 | else { |
| 135 | // Interest Name is same length as Data full Name, but last component isn't digest |
| 136 | // so there's no possibility of matching |
| 137 | return false; |
| 138 | } |
| 139 | } |
| 140 | else { |
| 141 | // Interest Name is a strict prefix of Data full Name |
| 142 | if (!m_name.isPrefixOf(dataName)) |
| 143 | return false; |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 144 | } |
| 145 | |
Junxiao Shi | 42c2362 | 2014-07-03 00:55:11 -0700 | [diff] [blame] | 146 | // check Exclude |
| 147 | // Exclude won't be violated if Interest Name is same as Data full Name |
| 148 | if (!getExclude().empty() && fullNameLength > interestNameLength) { |
| 149 | if (interestNameLength == fullNameLength - 1) { |
| 150 | // component to exclude is the digest |
| 151 | if (getExclude().isExcluded(data.getFullName().get(interestNameLength))) |
| 152 | return false; |
| 153 | // There's opportunity to inspect the Exclude filter and determine whether |
| 154 | // the digest would make a difference. |
| 155 | // eg. "Exclude=<Any>AA" won't exclude any digest - fullName not needed |
| 156 | // "Exclude=ZZ<Any>" excludes all digests - fullName not needed |
| 157 | // "Exclude=<Any>80000000000000000000000000000000" |
| 158 | // excludes half of the digests - fullName required |
| 159 | // But Interests that contain the exact Data Name before digest and also |
| 160 | // contain Exclude filter is too rare to optimize for, so we request |
| 161 | // fullName no mater what's in the Exclude filter. |
| 162 | } |
| 163 | else { |
| 164 | // component to exclude is not the digest |
| 165 | if (getExclude().isExcluded(dataName.get(interestNameLength))) |
| 166 | return false; |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | // check PublisherPublicKeyLocator |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 171 | const KeyLocator& publisherPublicKeyLocator = this->getPublisherPublicKeyLocator(); |
| 172 | if (!publisherPublicKeyLocator.empty()) { |
| 173 | const Signature& signature = data.getSignature(); |
| 174 | const Block& signatureInfo = signature.getInfo(); |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 175 | Block::element_const_iterator it = signatureInfo.find(tlv::KeyLocator); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 176 | if (it == signatureInfo.elements_end()) { |
| 177 | return false; |
| 178 | } |
| 179 | if (publisherPublicKeyLocator.wireEncode() != *it) { |
| 180 | return false; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | return true; |
| 185 | } |
| 186 | |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 187 | template<bool T> |
| 188 | size_t |
| 189 | Interest::wireEncode(EncodingImpl<T>& block) const |
| 190 | { |
| 191 | size_t totalLength = 0; |
| 192 | |
| 193 | // Interest ::= INTEREST-TYPE TLV-LENGTH |
| 194 | // Name |
| 195 | // Selectors? |
| 196 | // Nonce |
| 197 | // Scope? |
| 198 | // InterestLifetime? |
| 199 | |
| 200 | // (reverse encoding) |
| 201 | |
| 202 | // InterestLifetime |
| 203 | if (getInterestLifetime() >= time::milliseconds::zero() && |
| 204 | getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) |
| 205 | { |
| 206 | totalLength += prependNonNegativeIntegerBlock(block, |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 207 | tlv::InterestLifetime, |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 208 | getInterestLifetime().count()); |
| 209 | } |
| 210 | |
| 211 | // Scope |
| 212 | if (getScope() >= 0) |
| 213 | { |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 214 | totalLength += prependNonNegativeIntegerBlock(block, tlv::Scope, getScope()); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 215 | } |
| 216 | |
| 217 | // Nonce |
| 218 | getNonce(); // to ensure that Nonce is properly set |
| 219 | totalLength += block.prependBlock(m_nonce); |
| 220 | |
| 221 | // Selectors |
| 222 | if (hasSelectors()) |
| 223 | { |
| 224 | totalLength += getSelectors().wireEncode(block); |
| 225 | } |
| 226 | |
| 227 | // Name |
| 228 | totalLength += getName().wireEncode(block); |
| 229 | |
| 230 | totalLength += block.prependVarNumber(totalLength); |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 231 | totalLength += block.prependVarNumber(tlv::Interest); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 232 | return totalLength; |
| 233 | } |
| 234 | |
Alexander Afanasyev | 15f6731 | 2014-07-22 15:11:09 -0700 | [diff] [blame] | 235 | template size_t |
| 236 | Interest::wireEncode<true>(EncodingImpl<true>& block) const; |
| 237 | |
| 238 | template size_t |
| 239 | Interest::wireEncode<false>(EncodingImpl<false>& block) const; |
| 240 | |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 241 | const Block& |
| 242 | Interest::wireEncode() const |
| 243 | { |
| 244 | if (m_wire.hasWire()) |
| 245 | return m_wire; |
| 246 | |
| 247 | EncodingEstimator estimator; |
| 248 | size_t estimatedSize = wireEncode(estimator); |
| 249 | |
| 250 | EncodingBuffer buffer(estimatedSize, 0); |
| 251 | wireEncode(buffer); |
| 252 | |
| 253 | // to ensure that Nonce block points to the right memory location |
| 254 | const_cast<Interest*>(this)->wireDecode(buffer.block()); |
| 255 | |
| 256 | return m_wire; |
| 257 | } |
| 258 | |
| 259 | void |
| 260 | Interest::wireDecode(const Block& wire) |
| 261 | { |
| 262 | m_wire = wire; |
| 263 | m_wire.parse(); |
| 264 | |
| 265 | // Interest ::= INTEREST-TYPE TLV-LENGTH |
| 266 | // Name |
| 267 | // Selectors? |
| 268 | // Nonce |
| 269 | // Scope? |
| 270 | // InterestLifetime? |
| 271 | |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 272 | if (m_wire.type() != tlv::Interest) |
Junxiao Shi | c2b8d24 | 2014-11-04 08:35:29 -0700 | [diff] [blame] | 273 | throw Error("Unexpected TLV number when decoding Interest"); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 274 | |
| 275 | // Name |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 276 | m_name.wireDecode(m_wire.get(tlv::Name)); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 277 | |
| 278 | // Selectors |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 279 | Block::element_const_iterator val = m_wire.find(tlv::Selectors); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 280 | if (val != m_wire.elements_end()) |
| 281 | { |
| 282 | m_selectors.wireDecode(*val); |
| 283 | } |
| 284 | else |
| 285 | m_selectors = Selectors(); |
| 286 | |
| 287 | // Nonce |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 288 | m_nonce = m_wire.get(tlv::Nonce); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 289 | |
| 290 | // Scope |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 291 | val = m_wire.find(tlv::Scope); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 292 | if (val != m_wire.elements_end()) |
| 293 | { |
| 294 | m_scope = readNonNegativeInteger(*val); |
| 295 | } |
| 296 | else |
| 297 | m_scope = -1; |
| 298 | |
| 299 | // InterestLifetime |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 300 | val = m_wire.find(tlv::InterestLifetime); |
Alexander Afanasyev | 197e565 | 2014-06-13 16:56:31 -0700 | [diff] [blame] | 301 | if (val != m_wire.elements_end()) |
| 302 | { |
| 303 | m_interestLifetime = time::milliseconds(readNonNegativeInteger(*val)); |
| 304 | } |
| 305 | else |
| 306 | { |
| 307 | m_interestLifetime = DEFAULT_INTEREST_LIFETIME; |
| 308 | } |
| 309 | } |
| 310 | |
Alexander Afanasyev | ff2d08f | 2014-04-07 18:28:25 -0700 | [diff] [blame] | 311 | std::ostream& |
| 312 | operator<<(std::ostream& os, const Interest& interest) |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 313 | { |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 314 | os << interest.getName(); |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 315 | |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 316 | char delim = '?'; |
| 317 | |
| 318 | if (interest.getMinSuffixComponents() >= 0) { |
| 319 | os << delim << "ndn.MinSuffixComponents=" << interest.getMinSuffixComponents(); |
| 320 | delim = '&'; |
Jeff Thompson | fe55686 | 2013-07-09 13:52:55 -0700 | [diff] [blame] | 321 | } |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 322 | if (interest.getMaxSuffixComponents() >= 0) { |
| 323 | os << delim << "ndn.MaxSuffixComponents=" << interest.getMaxSuffixComponents(); |
| 324 | delim = '&'; |
Jeff Thompson | 37527d6 | 2013-08-21 11:15:54 -0700 | [diff] [blame] | 325 | } |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 326 | if (interest.getChildSelector() >= 0) { |
| 327 | os << delim << "ndn.ChildSelector=" << interest.getChildSelector(); |
| 328 | delim = '&'; |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 329 | } |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 330 | if (interest.getMustBeFresh()) { |
| 331 | os << delim << "ndn.MustBeFresh=" << interest.getMustBeFresh(); |
| 332 | delim = '&'; |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 333 | } |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 334 | if (interest.getScope() >= 0) { |
| 335 | os << delim << "ndn.Scope=" << interest.getScope(); |
| 336 | delim = '&'; |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 337 | } |
Alexander Afanasyev | aa0e7da | 2014-03-17 14:37:33 -0700 | [diff] [blame] | 338 | if (interest.getInterestLifetime() >= time::milliseconds::zero() |
| 339 | && interest.getInterestLifetime() != DEFAULT_INTEREST_LIFETIME) { |
Alexander Afanasyev | a0c5f83 | 2014-06-19 13:27:56 -0700 | [diff] [blame] | 340 | os << delim << "ndn.InterestLifetime=" << interest.getInterestLifetime().count(); |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 341 | delim = '&'; |
| 342 | } |
| 343 | |
Alexander Afanasyev | e881e93 | 2014-06-08 14:47:03 +0300 | [diff] [blame] | 344 | if (interest.hasNonce()) { |
Alexander Afanasyev | 8468198 | 2014-01-03 13:26:09 -0800 | [diff] [blame] | 345 | os << delim << "ndn.Nonce=" << interest.getNonce(); |
| 346 | delim = '&'; |
| 347 | } |
| 348 | if (!interest.getExclude().empty()) { |
| 349 | os << delim << "ndn.Exclude=" << interest.getExclude(); |
| 350 | delim = '&'; |
| 351 | } |
| 352 | |
| 353 | return os; |
Jeff Thompson | 13e280b | 2013-12-03 13:12:23 -0800 | [diff] [blame] | 354 | } |
| 355 | |
Jeff Thompson | b7f9556 | 2013-07-03 18:36:42 -0700 | [diff] [blame] | 356 | } |