Actions
Bug #1284
closedEncodingBuffer::prependNonNegativeInteger differs from example in TLV spec
Start date:
02/24/2014
Due date:
% Done:
100%
Estimated time:
0.50 h
Description
NDN-TLV Non Negative Integer Encoding has an example:
255 => TT01FF
This code encodes it as TT0200FF:
// g++ encoding-buffer_nonNegativeInteger_255.cpp -lndn-cpp-dev -pthread -lboost_system -lboost_filesystem -lcrypto -lcryptopp -lsqlite3
#include <ndn-cpp-dev/encoding/encoding-buffer.hpp>
#include <cstdio>
int
main()
{
ndn::EncodingBuffer blk;
size_t length = blk.prependNonNegativeInteger(255);
blk.prependVarNumber(length);
blk.prependVarNumber(0xe0);
for (ndn::Buffer::const_iterator it = blk.begin(); it != blk.end(); ++it) {
printf("%02x", *it);
}
}
Both encoding are permissible, because NDN-TLV spec does not require encoding with minimum number of octets.
But it's better to match the example in the spec.
Version: commit 7682ccbed444da1967f203aaa03959f4a3545979
Platform: Ubuntu 12.04
Updated by Alex Afanasyev over 11 years ago
- Assignee set to Alex Afanasyev
- Start date set to 02/24/2014
- Estimated time set to 0.50 h
Updated by Alex Afanasyev over 11 years ago
- Status changed from New to Code review
- % Done changed from 0 to 100
Updated by Alex Afanasyev over 11 years ago
- Status changed from Code review to Closed
Actions