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 | db7464d | 2017-07-13 03:11:17 +0000 | [diff] [blame] | 2 | /* |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 3 | * Copyright (c) 2013-2018 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 | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 20 | */ |
| 21 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 22 | #include "encoding/block.hpp" |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 23 | #include "encoding/block-helpers.hpp" |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 24 | |
Alexander Afanasyev | b1db7c6 | 2014-04-03 14:57:25 -0700 | [diff] [blame] | 25 | #include "boost-test.hpp" |
Junxiao Shi | 72c0c64 | 2018-04-20 15:41:09 +0000 | [diff] [blame] | 26 | #include <boost/lexical_cast.hpp> |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 27 | #include <cstring> |
| 28 | #include <sstream> |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 29 | |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 30 | namespace ndn { |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 31 | namespace tests { |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 32 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 33 | BOOST_AUTO_TEST_SUITE(Encoding) |
| 34 | BOOST_AUTO_TEST_SUITE(TestBlock) |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 35 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 36 | BOOST_AUTO_TEST_SUITE(Construction) |
| 37 | |
| 38 | static const uint8_t TEST_BUFFER[] = { |
| 39 | 0x00, 0x01, 0xfa, // ok |
| 40 | 0x01, 0x01, 0xfb, // ok |
| 41 | 0x03, 0x02, 0xff // bad: TLV-LENGTH is 2 but there's only 1-octet TLV-VALUE |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 42 | }; |
Alexander Afanasyev | 2d0b457 | 2014-02-24 16:02:12 -0800 | [diff] [blame] | 43 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 44 | BOOST_AUTO_TEST_CASE(Empty) |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 45 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 46 | Block b; |
| 47 | BOOST_CHECK_EQUAL(b.empty(), true); |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 48 | } |
Alexander Afanasyev | 937aa78 | 2014-03-21 13:17:57 -0700 | [diff] [blame] | 49 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 50 | BOOST_AUTO_TEST_CASE(FromEncodingBuffer) |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 51 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 52 | const uint8_t VALUE[4] = {0x11, 0x12, 0x13, 0x14}; |
| 53 | |
| 54 | EncodingBuffer encoder; |
| 55 | size_t length = encoder.prependByteArray(VALUE, sizeof(VALUE)); |
| 56 | encoder.prependVarNumber(length); |
| 57 | encoder.prependVarNumber(0xe0); |
| 58 | |
| 59 | Block b = encoder.block(); |
| 60 | BOOST_CHECK_EQUAL(b.type(), 0xe0); |
| 61 | BOOST_CHECK_EQUAL(b.value_size(), sizeof(VALUE)); |
| 62 | BOOST_CHECK_EQUAL_COLLECTIONS(b.value_begin(), b.value_end(), |
| 63 | VALUE, VALUE + sizeof(VALUE)); |
| 64 | |
| 65 | b = Block(encoder); |
| 66 | BOOST_CHECK_EQUAL(b.type(), 0xe0); |
| 67 | BOOST_CHECK_EQUAL(b.value_size(), sizeof(VALUE)); |
| 68 | BOOST_CHECK_EQUAL_COLLECTIONS(b.value_begin(), b.value_end(), |
| 69 | VALUE, VALUE + sizeof(VALUE)); |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 70 | } |
Alexander Afanasyev | 937aa78 | 2014-03-21 13:17:57 -0700 | [diff] [blame] | 71 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 72 | BOOST_AUTO_TEST_CASE(FromEmptyEncodingBuffer) |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 73 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 74 | EncodingBuffer encoder; |
| 75 | Block b; |
| 76 | BOOST_CHECK_THROW(b = Block(encoder), tlv::Error); |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 77 | } |
Alexander Afanasyev | 2d0b457 | 2014-02-24 16:02:12 -0800 | [diff] [blame] | 78 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 79 | BOOST_AUTO_TEST_CASE(FromBlock) |
Alexander Afanasyev | 4448d29 | 2015-08-09 20:11:37 -0700 | [diff] [blame] | 80 | { |
| 81 | static uint8_t buffer[] = {0x80, 0x06, 0x81, 0x01, 0x01, 0x82, 0x01, 0x01}; |
| 82 | Block block(buffer, sizeof(buffer)); |
| 83 | |
| 84 | Block derivedBlock(block, block.begin(), block.end()); |
| 85 | BOOST_CHECK_EQUAL(derivedBlock.wire(), block.wire()); // pointers should match |
| 86 | BOOST_CHECK(derivedBlock == block); // blocks should match |
| 87 | |
| 88 | derivedBlock = Block(block, block.begin() + 2, block.begin() + 5); |
| 89 | BOOST_CHECK(derivedBlock.begin() == block.begin() + 2); |
| 90 | BOOST_CHECK(derivedBlock == Block(buffer + 2, 3)); |
| 91 | |
| 92 | Buffer otherBuffer(buffer, sizeof(buffer)); |
Junxiao Shi | db7464d | 2017-07-13 03:11:17 +0000 | [diff] [blame] | 93 | BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), block.end()), std::invalid_argument); |
| 94 | BOOST_CHECK_THROW(Block(block, block.begin(), otherBuffer.end()), std::invalid_argument); |
| 95 | BOOST_CHECK_THROW(Block(block, otherBuffer.begin(), otherBuffer.end()), std::invalid_argument); |
Alexander Afanasyev | 4448d29 | 2015-08-09 20:11:37 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 98 | BOOST_AUTO_TEST_CASE(FromBlockCopyOnWriteModifyOriginal) |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 99 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 100 | const uint8_t BUFFER[] = { |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 101 | 0x05, 0x0b, 0x07, 0x03, 0x01, 0x02, 0x03, 0x0a, 0x04, 0x04, 0x05, 0x06, 0x07, |
| 102 | }; |
| 103 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 104 | Block b1(BUFFER, sizeof(BUFFER)); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 105 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 106 | Block b2(b1, b1.begin(), b1.end()); |
| 107 | auto buf2 = b2.getBuffer(); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 108 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 109 | b1.parse(); |
| 110 | b1.remove(tlv::Name); |
| 111 | b1.encode(); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 112 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 113 | b2.parse(); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 114 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 115 | BOOST_CHECK_EQUAL_COLLECTIONS(b2.begin(), b2.end(), BUFFER, BUFFER + sizeof(BUFFER)); |
| 116 | BOOST_CHECK_EQUAL(buf2, b2.getBuffer()); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 119 | BOOST_AUTO_TEST_CASE(FromBlockCopyOnWriteModifyCopy) |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 120 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 121 | const uint8_t BUFFER[] = { |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 122 | 0x05, 0x0b, 0x07, 0x03, 0x01, 0x02, 0x03, 0x0a, 0x04, 0x04, 0x05, 0x06, 0x07, |
| 123 | }; |
| 124 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 125 | Block b1(BUFFER, sizeof(BUFFER)); |
| 126 | auto buf1 = b1.getBuffer(); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 127 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 128 | Block b2(b1, b1.begin(), b1.end()); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 129 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 130 | b2.parse(); |
| 131 | b2.remove(tlv::Name); |
| 132 | b2.encode(); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 133 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 134 | b1.parse(); |
| 135 | BOOST_CHECK_EQUAL_COLLECTIONS(b1.begin(), b1.end(), BUFFER, BUFFER + sizeof(BUFFER)); |
| 136 | BOOST_CHECK_EQUAL(buf1, b1.getBuffer()); |
Eric Newberry | 6235aac | 2015-08-13 16:03:47 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 139 | BOOST_AUTO_TEST_CASE(FromType) |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 140 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 141 | Block b1(4); |
| 142 | BOOST_CHECK_EQUAL(b1.empty(), false); |
| 143 | BOOST_CHECK_EQUAL(b1.type(), 4); |
| 144 | BOOST_CHECK_EQUAL(b1.size(), 2); // 1-octet TLV-TYPE and 1-octet TLV-LENGTH |
| 145 | BOOST_CHECK_EQUAL(b1.value_size(), 0); |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 146 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 147 | Block b2(258); |
| 148 | BOOST_CHECK_EQUAL(b2.type(), 258); |
| 149 | BOOST_CHECK_EQUAL(b2.size(), 4); // 3-octet TLV-TYPE and 1-octet TLV-LENGTH |
| 150 | BOOST_CHECK_EQUAL(b2.value_size(), 0); |
Alexander Afanasyev | 937aa78 | 2014-03-21 13:17:57 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 153 | BOOST_AUTO_TEST_CASE(FromStream) |
Alexander Afanasyev | 21ef239 | 2014-03-25 12:40:22 -0700 | [diff] [blame] | 154 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 155 | std::stringstream stream; |
| 156 | stream.write(reinterpret_cast<const char*>(TEST_BUFFER), sizeof(TEST_BUFFER)); |
| 157 | stream.seekg(0); |
Alexander Afanasyev | 21ef239 | 2014-03-25 12:40:22 -0700 | [diff] [blame] | 158 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 159 | Block b = Block::fromStream(stream); |
| 160 | BOOST_CHECK_EQUAL(b.type(), 0); |
| 161 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 162 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 163 | BOOST_CHECK_EQUAL(*b.wire(), 0x00); |
| 164 | BOOST_CHECK_EQUAL(*b.value(), 0xfa); |
Alexander Afanasyev | 21ef239 | 2014-03-25 12:40:22 -0700 | [diff] [blame] | 165 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 166 | b = Block::fromStream(stream); |
| 167 | BOOST_CHECK_EQUAL(b.type(), 1); |
| 168 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 169 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 170 | BOOST_CHECK_EQUAL(*b.wire(), 0x01); |
| 171 | BOOST_CHECK_EQUAL(*b.value(), 0xfb); |
Alexander Afanasyev | 21ef239 | 2014-03-25 12:40:22 -0700 | [diff] [blame] | 172 | |
Steve DiBenedetto | 54ce668 | 2014-07-22 13:22:57 -0600 | [diff] [blame] | 173 | BOOST_CHECK_THROW(Block::fromStream(stream), tlv::Error); |
Alexander Afanasyev | 21ef239 | 2014-03-25 12:40:22 -0700 | [diff] [blame] | 174 | } |
| 175 | |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 176 | BOOST_AUTO_TEST_CASE(FromStreamWhitespace) // Bug 2728 |
| 177 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 178 | const uint8_t PACKET[] = { |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 179 | 0x06, 0x20, // Data |
| 180 | 0x07, 0x11, // Name |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 181 | 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, // GenericNameComponent 'hello' |
| 182 | 0x08, 0x01, 0x31, // GenericNameComponent '1' |
| 183 | 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64, // GenericNameComponent 'world' |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 184 | 0x14, 0x00, // MetaInfo empty |
| 185 | 0x15, 0x00, // Content empty |
| 186 | 0x16, 0x05, // SignatureInfo |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 187 | 0x1b, 0x01, 0x01, // SignatureType RSA |
| 188 | 0x1c, 0x00, // KeyLocator empty |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 189 | 0x17, 0x00 // SignatureValue empty |
| 190 | }; |
| 191 | // TLV-LENGTH of <Data> is 0x20 which happens to be ASCII whitespace |
| 192 | |
| 193 | std::stringstream stream; |
| 194 | stream.write(reinterpret_cast<const char*>(PACKET), sizeof(PACKET)); |
| 195 | stream.seekg(0); |
| 196 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 197 | Block b = Block::fromStream(stream); |
| 198 | BOOST_CHECK_EQUAL(b.type(), 6); |
| 199 | BOOST_CHECK_EQUAL(b.value_size(), 32); |
| 200 | b.parse(); |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Junxiao Shi | 760cc7b | 2017-07-22 19:17:49 +0000 | [diff] [blame] | 203 | BOOST_AUTO_TEST_CASE(FromStreamZeroLength) |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 204 | { |
Junxiao Shi | 760cc7b | 2017-07-22 19:17:49 +0000 | [diff] [blame] | 205 | const uint8_t BUFFER[] = {0x70, 0x00, |
| 206 | 0x71, 0x03, 0x86, 0x11, 0x24, |
| 207 | 0x72, 0x00}; |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 208 | |
| 209 | std::stringstream stream; |
| 210 | stream.write(reinterpret_cast<const char*>(BUFFER), sizeof(BUFFER)); |
| 211 | stream.seekg(0); |
| 212 | |
Junxiao Shi | 760cc7b | 2017-07-22 19:17:49 +0000 | [diff] [blame] | 213 | Block b1 = Block::fromStream(stream); |
| 214 | BOOST_CHECK_EQUAL(b1.type(), 0x70); |
| 215 | BOOST_CHECK_EQUAL(b1.value_size(), 0); |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 216 | |
Junxiao Shi | 760cc7b | 2017-07-22 19:17:49 +0000 | [diff] [blame] | 217 | Block b2 = Block::fromStream(stream); |
| 218 | BOOST_CHECK_EQUAL(b2.type(), 0x71); |
| 219 | BOOST_CHECK_EQUAL(b2.value_size(), 3); |
| 220 | const uint8_t EXPECTED_VALUE2[] = {0x86, 0x11, 0x24}; |
| 221 | BOOST_CHECK_EQUAL_COLLECTIONS(b2.value_begin(), b2.value_end(), |
| 222 | EXPECTED_VALUE2, EXPECTED_VALUE2 + sizeof(EXPECTED_VALUE2)); |
| 223 | |
| 224 | Block b3 = Block::fromStream(stream); |
| 225 | BOOST_CHECK_EQUAL(b3.type(), 0x72); |
| 226 | BOOST_CHECK_EQUAL(b3.value_size(), 0); |
| 227 | |
| 228 | BOOST_CHECK_THROW(Block::fromStream(stream), tlv::Error); |
| 229 | } |
| 230 | |
| 231 | BOOST_AUTO_TEST_CASE(FromStreamPacketTooLarge) |
| 232 | { |
| 233 | const uint8_t BUFFER[] = {0x07, 0xfe, 0x00, 0x01, 0x00, 0x00}; |
| 234 | |
| 235 | std::stringstream stream; |
| 236 | stream.write(reinterpret_cast<const char*>(BUFFER), sizeof(BUFFER)); |
| 237 | for (int i = 0; i < 0x10000; ++i) { |
| 238 | stream.put('\0'); |
| 239 | } |
| 240 | stream.seekg(0); |
| 241 | |
| 242 | BOOST_CHECK_THROW(Block::fromStream(stream), tlv::Error); |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | BOOST_AUTO_TEST_CASE(FromWireBuffer) |
| 246 | { |
| 247 | ConstBufferPtr buffer = make_shared<Buffer>(TEST_BUFFER, sizeof(TEST_BUFFER)); |
| 248 | |
| 249 | size_t offset = 0; |
| 250 | bool isOk = false; |
| 251 | Block b; |
| 252 | std::tie(isOk, b) = Block::fromBuffer(buffer, offset); |
| 253 | BOOST_CHECK(isOk); |
| 254 | BOOST_CHECK_EQUAL(b.type(), 0); |
| 255 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 256 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 257 | BOOST_CHECK_EQUAL(*b.wire(), 0x00); |
| 258 | BOOST_CHECK_EQUAL(*b.value(), 0xfa); |
| 259 | offset += b.size(); |
| 260 | |
| 261 | std::tie(isOk, b) = Block::fromBuffer(buffer, offset); |
| 262 | BOOST_CHECK(isOk); |
| 263 | BOOST_CHECK_EQUAL(b.type(), 1); |
| 264 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 265 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 266 | BOOST_CHECK_EQUAL(*b.wire(), 0x01); |
| 267 | BOOST_CHECK_EQUAL(*b.value(), 0xfb); |
| 268 | offset += b.size(); |
| 269 | |
| 270 | std::tie(isOk, b) = Block::fromBuffer(buffer, offset); |
| 271 | BOOST_CHECK(!isOk); |
| 272 | } |
| 273 | |
| 274 | BOOST_AUTO_TEST_CASE(FromRawBuffer) |
| 275 | { |
| 276 | size_t offset = 0; |
| 277 | bool isOk = false; |
| 278 | Block b; |
| 279 | std::tie(isOk, b) = Block::fromBuffer(TEST_BUFFER + offset, sizeof(TEST_BUFFER) - offset); |
| 280 | BOOST_CHECK(isOk); |
| 281 | BOOST_CHECK_EQUAL(b.type(), 0); |
| 282 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 283 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 284 | BOOST_CHECK_EQUAL(*b.wire(), 0x00); |
| 285 | BOOST_CHECK_EQUAL(*b.value(), 0xfa); |
| 286 | offset += b.size(); |
| 287 | |
| 288 | std::tie(isOk, b) = Block::fromBuffer(TEST_BUFFER + offset, sizeof(TEST_BUFFER) - offset); |
| 289 | BOOST_CHECK(isOk); |
| 290 | BOOST_CHECK_EQUAL(b.type(), 1); |
| 291 | BOOST_CHECK_EQUAL(b.size(), 3); |
| 292 | BOOST_CHECK_EQUAL(b.value_size(), 1); |
| 293 | BOOST_CHECK_EQUAL(*b.wire(), 0x01); |
| 294 | BOOST_CHECK_EQUAL(*b.value(), 0xfb); |
| 295 | offset += b.size(); |
| 296 | |
| 297 | std::tie(isOk, b) = Block::fromBuffer(TEST_BUFFER + offset, sizeof(TEST_BUFFER) - offset); |
| 298 | BOOST_CHECK(!isOk); |
Junxiao Shi | f0da789 | 2015-04-04 22:16:16 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 301 | BOOST_AUTO_TEST_SUITE_END() // Construction |
| 302 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 303 | BOOST_AUTO_TEST_SUITE(SubElements) |
| 304 | |
| 305 | BOOST_AUTO_TEST_CASE(Parse) |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 306 | { |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 307 | const uint8_t PACKET[] = { |
| 308 | 0x06, 0x20, // Data |
| 309 | 0x07, 0x11, // Name |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 310 | 0x08, 0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, // GenericNameComponent 'hello' |
| 311 | 0x08, 0x01, 0x31, // GenericNameComponent '1' |
| 312 | 0x08, 0x05, 0x77, 0x6f, 0x72, 0x6c, 0x64, // GenericNameComponent 'world' |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 313 | 0x14, 0x00, // MetaInfo empty |
| 314 | 0x15, 0x00, // Content empty |
| 315 | 0x16, 0x05, // SignatureInfo |
| 316 | 0x1b, 0x01, 0x01, // SignatureType RSA |
| 317 | 0x1c, 0x00, // KeyLocator empty |
| 318 | 0x17, 0x00 // SignatureValue empty |
| 319 | }; |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 320 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 321 | Block data(PACKET, sizeof(PACKET)); |
| 322 | data.parse(); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 323 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 324 | BOOST_CHECK_EQUAL(data.elements_size(), 5); |
| 325 | BOOST_CHECK_EQUAL(data.elements().at(0).type(), 0x07); |
| 326 | BOOST_CHECK_EQUAL(data.elements().at(0).elements().size(), 0); // parse is not recursive |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 327 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 328 | BOOST_CHECK(data.get(0x15) == data.elements().at(2)); |
| 329 | BOOST_CHECK_THROW(data.get(0x01), Block::Error); |
| 330 | |
| 331 | BOOST_CHECK(data.find(0x15) == data.elements_begin() + 2); |
| 332 | BOOST_CHECK(data.find(0x01) == data.elements_end()); |
Junxiao Shi | af8eeea | 2014-03-31 20:10:56 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 335 | BOOST_AUTO_TEST_CASE(InsertBeginning) |
| 336 | { |
| 337 | Block masterBlock(tlv::Name); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 338 | Block firstBlock = makeStringBlock(tlv::GenericNameComponent, "firstName"); |
| 339 | Block secondBlock = makeStringBlock(tlv::GenericNameComponent, "secondName"); |
| 340 | Block thirdBlock = makeStringBlock(tlv::GenericNameComponent, "thirdName"); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 341 | |
| 342 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 0); |
| 343 | masterBlock.push_back(secondBlock); |
| 344 | masterBlock.push_back(thirdBlock); |
| 345 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 2); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 346 | Block::element_const_iterator it = masterBlock.find(tlv::GenericNameComponent); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 347 | BOOST_CHECK_EQUAL(*it == secondBlock, true); |
| 348 | |
| 349 | it = masterBlock.insert(it, firstBlock); |
| 350 | |
| 351 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 3); |
| 352 | BOOST_CHECK_EQUAL(*(it + 1) == secondBlock, true); |
| 353 | BOOST_CHECK_EQUAL(*(masterBlock.elements_begin()) == firstBlock, true); |
| 354 | } |
| 355 | |
| 356 | BOOST_AUTO_TEST_CASE(InsertEnd) |
| 357 | { |
| 358 | Block masterBlock(tlv::Name); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 359 | Block firstBlock = makeStringBlock(tlv::GenericNameComponent, "firstName"); |
| 360 | Block secondBlock = makeStringBlock(tlv::GenericNameComponent, "secondName"); |
| 361 | Block thirdBlock = makeStringBlock(tlv::GenericNameComponent, "thirdName"); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 362 | |
| 363 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 0); |
| 364 | masterBlock.push_back(firstBlock); |
| 365 | masterBlock.push_back(secondBlock); |
| 366 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 2); |
| 367 | Block::element_const_iterator it = masterBlock.elements_end(); |
| 368 | BOOST_CHECK_EQUAL(*(it - 1) == secondBlock, true); |
| 369 | |
| 370 | it = masterBlock.insert(it, thirdBlock); |
| 371 | |
| 372 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 3); |
| 373 | BOOST_CHECK_EQUAL(*(it - 1) == secondBlock, true); |
| 374 | BOOST_CHECK_EQUAL(*(masterBlock.elements_end() - 1) == thirdBlock, true); |
| 375 | } |
| 376 | |
| 377 | BOOST_AUTO_TEST_CASE(InsertMiddle) |
| 378 | { |
| 379 | Block masterBlock(tlv::Name); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 380 | Block firstBlock = makeStringBlock(tlv::GenericNameComponent, "firstName"); |
| 381 | Block secondBlock = makeStringBlock(tlv::GenericNameComponent, "secondName"); |
| 382 | Block thirdBlock = makeStringBlock(tlv::GenericNameComponent, "thirdName"); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 383 | |
| 384 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 0); |
| 385 | masterBlock.push_back(firstBlock); |
| 386 | masterBlock.push_back(thirdBlock); |
| 387 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 2); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 388 | Block::element_const_iterator it = masterBlock.find(tlv::GenericNameComponent); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 389 | BOOST_CHECK_EQUAL(*it == firstBlock, true); |
| 390 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 391 | it = masterBlock.insert(it + 1, secondBlock); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 392 | |
| 393 | BOOST_CHECK_EQUAL(*it == secondBlock, true); |
| 394 | BOOST_CHECK_EQUAL(*(it + 1) == thirdBlock, true); |
| 395 | BOOST_CHECK_EQUAL(*(it - 1) == firstBlock, true); |
| 396 | } |
| 397 | |
| 398 | BOOST_AUTO_TEST_CASE(EraseSingleElement) |
| 399 | { |
| 400 | Block masterBlock(tlv::Name); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 401 | Block firstBlock = makeStringBlock(tlv::GenericNameComponent, "firstName"); |
| 402 | Block secondBlock = makeStringBlock(tlv::GenericNameComponent, "secondName"); |
| 403 | Block thirdBlock = makeStringBlock(tlv::GenericNameComponent, "thirdName"); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 404 | |
| 405 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 0); |
| 406 | masterBlock.push_back(firstBlock); |
| 407 | masterBlock.push_back(secondBlock); |
| 408 | masterBlock.push_back(thirdBlock); |
| 409 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 3); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 410 | Block::element_const_iterator it = masterBlock.find(tlv::GenericNameComponent); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 411 | it++; |
| 412 | BOOST_CHECK_EQUAL(*it == secondBlock, true); |
| 413 | |
| 414 | it = masterBlock.erase(it); |
| 415 | |
| 416 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 2); |
| 417 | BOOST_CHECK_EQUAL(*(it) == thirdBlock, true); |
| 418 | BOOST_CHECK_EQUAL(*(it - 1) == firstBlock, true); |
| 419 | } |
| 420 | |
| 421 | BOOST_AUTO_TEST_CASE(EraseRange) |
| 422 | { |
| 423 | Block masterBlock(tlv::Name); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 424 | Block firstBlock = makeStringBlock(tlv::GenericNameComponent, "firstName"); |
| 425 | Block secondBlock = makeStringBlock(tlv::GenericNameComponent, "secondName"); |
| 426 | Block thirdBlock = makeStringBlock(tlv::GenericNameComponent, "thirdName"); |
| 427 | Block fourthBlock = makeStringBlock(tlv::GenericNameComponent, "fourthName"); |
| 428 | Block fifthBlock = makeStringBlock(tlv::GenericNameComponent, "fifthName"); |
| 429 | Block sixthBlock = makeStringBlock(tlv::GenericNameComponent, "sixthName"); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 430 | |
| 431 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 0); |
| 432 | masterBlock.push_back(firstBlock); |
| 433 | masterBlock.push_back(secondBlock); |
| 434 | masterBlock.push_back(thirdBlock); |
| 435 | masterBlock.push_back(fourthBlock); |
| 436 | masterBlock.push_back(fifthBlock); |
| 437 | masterBlock.push_back(sixthBlock); |
| 438 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 6); |
Junxiao Shi | 4ffbb9d | 2018-03-31 17:16:35 +0000 | [diff] [blame] | 439 | Block::element_const_iterator itStart = masterBlock.find(tlv::GenericNameComponent); |
Joao Pereira | 7476ebf | 2015-07-07 14:54:39 -0400 | [diff] [blame] | 440 | itStart++; |
| 441 | Block::element_const_iterator itEnd = itStart + 3; |
| 442 | BOOST_CHECK_EQUAL(*itStart == secondBlock, true); |
| 443 | BOOST_CHECK_EQUAL(*itEnd == fifthBlock, true); |
| 444 | |
| 445 | Block::element_const_iterator newIt = masterBlock.erase(itStart, itEnd); |
| 446 | |
| 447 | BOOST_CHECK_EQUAL(masterBlock.elements_size(), 3); |
| 448 | BOOST_CHECK_EQUAL(*(newIt) == fifthBlock, true); |
| 449 | BOOST_CHECK_EQUAL(*(newIt - 1) == firstBlock, true); |
| 450 | } |
| 451 | |
Eric Newberry | a3d9fc0 | 2015-07-26 10:55:44 -0700 | [diff] [blame] | 452 | BOOST_AUTO_TEST_CASE(Remove) |
| 453 | { |
| 454 | Block block(tlv::Data); |
| 455 | block.push_back(makeNonNegativeIntegerBlock(tlv::ContentType, 0)); |
| 456 | block.push_back(makeNonNegativeIntegerBlock(tlv::FreshnessPeriod, 123)); |
| 457 | block.push_back(makeStringBlock(tlv::Name, "ndn:/test-prefix")); |
| 458 | block.push_back(makeNonNegativeIntegerBlock(tlv::ContentType, 2)); |
| 459 | block.push_back(makeNonNegativeIntegerBlock(tlv::ContentType, 1)); |
| 460 | |
| 461 | BOOST_CHECK_EQUAL(5, block.elements_size()); |
| 462 | BOOST_REQUIRE_NO_THROW(block.remove(tlv::ContentType)); |
| 463 | BOOST_CHECK_EQUAL(2, block.elements_size()); |
| 464 | |
| 465 | Block::element_container elements = block.elements(); |
| 466 | |
| 467 | BOOST_CHECK_EQUAL(tlv::FreshnessPeriod, elements[0].type()); |
| 468 | BOOST_CHECK_EQUAL(123, readNonNegativeInteger(elements[0])); |
| 469 | BOOST_CHECK_EQUAL(tlv::Name, elements[1].type()); |
| 470 | BOOST_CHECK(readString(elements[1]).compare("ndn:/test-prefix") == 0); |
| 471 | } |
| 472 | |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 473 | BOOST_AUTO_TEST_SUITE_END() // SubElements |
| 474 | |
| 475 | BOOST_AUTO_TEST_CASE(Equality) |
| 476 | { |
Davide Pesavento | b10024c | 2017-09-22 01:36:44 -0400 | [diff] [blame] | 477 | const uint8_t one[] = {0x08, 0x00}; |
| 478 | Block a(one, sizeof(one)); |
| 479 | Block b(one, sizeof(one)); |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 480 | BOOST_CHECK_EQUAL(a == b, true); |
| 481 | BOOST_CHECK_EQUAL(a != b, false); |
| 482 | |
Davide Pesavento | b10024c | 2017-09-22 01:36:44 -0400 | [diff] [blame] | 483 | const uint8_t two[] = {0x06, 0x00}; |
| 484 | Block c(two, sizeof(two)); |
| 485 | Block d(one, sizeof(one)); |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 486 | BOOST_CHECK_EQUAL(c == d, false); |
| 487 | BOOST_CHECK_EQUAL(c != d, true); |
| 488 | |
Davide Pesavento | b10024c | 2017-09-22 01:36:44 -0400 | [diff] [blame] | 489 | const uint8_t three[] = {0x06, 0x01, 0xcc}; |
| 490 | Block e(two, sizeof(two)); |
| 491 | Block f(three, sizeof(three)); |
Junxiao Shi | dc4277a | 2017-07-17 11:34:02 +0000 | [diff] [blame] | 492 | BOOST_CHECK_EQUAL(e == f, false); |
| 493 | BOOST_CHECK_EQUAL(e != f, true); |
| 494 | } |
| 495 | |
Junxiao Shi | 72c0c64 | 2018-04-20 15:41:09 +0000 | [diff] [blame] | 496 | BOOST_AUTO_TEST_CASE(Print) |
| 497 | { |
| 498 | // default constructed |
| 499 | Block b; |
| 500 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(b), "[invalid]"); |
| 501 | |
| 502 | // zero length |
| 503 | b = "0700"_block; |
| 504 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(b), "7[empty]"); |
| 505 | |
| 506 | // unparsed |
| 507 | b = "0E10FF7E4E6B3B21C902660F16ED589FCCCC"_block; |
| 508 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(b), |
| 509 | "14[16]=FF7E4E6B3B21C902660F16ED589FCCCC"); |
| 510 | // set and restore format flags |
| 511 | { |
| 512 | std::ostringstream oss; |
| 513 | oss << std::showbase << std::hex << 0xd23c4 << b << 0x4981e; |
| 514 | BOOST_CHECK_EQUAL(oss.str(), "0xd23c414[16]=FF7E4E6B3B21C902660F16ED589FCCCC0x4981e"); |
| 515 | } |
| 516 | |
| 517 | // parsed |
| 518 | b = "FD010808 0502CADD 59024E42"_block; |
| 519 | b.parse(); |
| 520 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(b), |
| 521 | "264[8]={5[2]=CADD,89[2]=4E42}"); |
| 522 | |
| 523 | // parsed then modified: print modified sub-elements |
| 524 | b = "FD010808 0502CADD 59024E42"_block; |
| 525 | b.parse(); |
| 526 | b.erase(b.elements_begin()); |
| 527 | b.push_back("10022386"_block); |
| 528 | BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(b), |
| 529 | "264[8]={89[2]=4E42,16[2]=2386}"); |
| 530 | } |
| 531 | |
Junxiao Shi | 2b322eb | 2018-08-24 10:43:27 -0600 | [diff] [blame] | 532 | BOOST_AUTO_TEST_SUITE(BlockLiteral) |
| 533 | |
| 534 | BOOST_AUTO_TEST_CASE(Simple) |
| 535 | { |
| 536 | Block b0 = "0000"_block; |
| 537 | BOOST_CHECK_EQUAL(b0.type(), 0x00); |
| 538 | BOOST_CHECK_EQUAL(b0.value_size(), 0); |
| 539 | |
| 540 | Block b1 = "0101A0"_block; |
| 541 | BOOST_CHECK_EQUAL(b1.type(), 0x01); |
| 542 | BOOST_REQUIRE_EQUAL(b1.value_size(), 1); |
| 543 | BOOST_CHECK_EQUAL(b1.value()[0], 0xA0); |
| 544 | } |
| 545 | |
| 546 | BOOST_AUTO_TEST_CASE(Comment) |
| 547 | { |
| 548 | Block b0 = "a2b0c0d2eBf0G.B 1+"_block; |
| 549 | BOOST_CHECK_EQUAL(b0.type(), 0x20); |
| 550 | BOOST_REQUIRE_EQUAL(b0.value_size(), 2); |
| 551 | BOOST_CHECK_EQUAL(b0.value()[0], 0xB0); |
| 552 | BOOST_CHECK_EQUAL(b0.value()[1], 0xB1); |
| 553 | } |
| 554 | |
| 555 | BOOST_AUTO_TEST_CASE(BadInput) |
| 556 | { |
| 557 | BOOST_CHECK_THROW(""_block, std::invalid_argument); |
| 558 | BOOST_CHECK_THROW("1"_block, std::invalid_argument); |
| 559 | BOOST_CHECK_THROW("333"_block, std::invalid_argument); |
| 560 | |
| 561 | BOOST_CHECK_THROW("0202C0"_block, tlv::Error); |
| 562 | BOOST_CHECK_THROW("0201C0C1"_block, tlv::Error); |
| 563 | } |
| 564 | |
| 565 | BOOST_AUTO_TEST_SUITE_END() // BlockLiteral |
| 566 | |
Davide Pesavento | eee3e82 | 2016-11-26 19:19:34 +0100 | [diff] [blame] | 567 | BOOST_AUTO_TEST_SUITE_END() // TestBlock |
| 568 | BOOST_AUTO_TEST_SUITE_END() // Encoding |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 569 | |
Alexander Afanasyev | 7463389 | 2015-02-08 18:08:46 -0800 | [diff] [blame] | 570 | } // namespace tests |
Alexander Afanasyev | 233750e | 2014-02-16 00:50:07 -0800 | [diff] [blame] | 571 | } // namespace ndn |