|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
28 BOOST_CONCEPT_ASSERT((boost::EqualityComparable<Data>));
32 static_assert(std::is_base_of<tlv::Error, Data::Error>::value,
33 "Data::Error must inherit from tlv::Error");
46 template<encoding::Tag TAG>
57 size_t totalLength = 0;
60 if (!wantUnsignedPortionOnly) {
62 NDN_THROW(
Error(
"Requested wire format, but Data has not been signed"));
64 totalLength += encoder.prependBlock(m_signature.
getValue());
68 totalLength += encoder.prependBlock(m_signature.
getInfo());
71 totalLength += encoder.prependBlock(
getContent());
79 if (!wantUnsignedPortionOnly) {
80 totalLength += encoder.prependVarNumber(totalLength);
81 totalLength += encoder.prependVarNumber(
tlv::Data);
87 Data::wireEncode<encoding::EncoderTag>(
EncodingBuffer&,
bool)
const;
95 size_t totalLength = encoder.
size();
96 totalLength += encoder.appendBlock(signatureValue);
98 encoder.prependVarNumber(totalLength);
146 for (++element; element != m_wire.
elements_end(); ++element) {
147 switch (element->type()) {
149 if (lastElement >= 2) {
157 if (lastElement >= 3) {
160 m_content = *element;
165 if (lastElement >= 4) {
173 if (lastElement >= 5) {
197 if (m_fullName.
empty()) {
199 NDN_THROW(
Error(
"Cannot compute full name because Data has no wire encoding (not signed)"));
227 m_metaInfo = metaInfo;
235 const_cast<Block&
>(m_content).encode();
275 m_signature = signature;
324 os <<
"Name: " << data.
getName() <<
"\n";
const Block & getInfo() const
Get SignatureInfo as wire format.
const Block & getValue() const
Get SignatureValue.
size_t value_size() const noexcept
Return the size of TLV-VALUE, aka TLV-LENGTH.
Data & setContentType(uint32_t type)
void setValue(const Block &value)
Set SignatureValue.
Data & setMetaInfo(const MetaInfo &metaInfo)
Set MetaInfo.
element_const_iterator elements_begin() const
Equivalent to elements().begin()
void resetWire()
Clear wire encoding and cached FullName.
const Block & getContent() const
Get Content.
NDN_CXX_NODISCARD bool empty() const
Checks if the name is empty, i.e.
Data & setName(const Name &name)
Set name.
const Name & getName() const
Get name.
void reset() noexcept
Reset the Block to a default-constructed state.
a concept check for TLV abstraction with .wireDecode method and constructible from Block
EncodingImpl< EstimatorTag > EncodingEstimator
Represents an absolute name.
void wireDecode(const Block &wire)
Decode name from wire encoding.
const SignatureInfo & getSignatureInfo() const
Get SignatureInfo.
uint32_t type() const
Return the TLV-TYPE of the Block.
a concept check for TLV abstraction with .wireEncode method
void wireDecode(const Block &wire)
Decode from wire in NDN Packet Format v0.2 or v0.3.
void setInfo(const Block &info)
Decode SignatureInfo from wire format.
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Fast encoding or block size estimation.
Holds SignatureInfo and SignatureValue in a Data packet.
Data & setContent(const Block &block)
Set Content from a block.
Data & setSignatureValue(const Block &value)
Set SignatureValue.
Data & setFreshnessPeriod(time::milliseconds freshnessPeriod)
ConstBufferPtr computeDigest()
Finalize and return the digest based on all previously supplied inputs.
void parse() const
Parse TLV-VALUE into sub-elements.
Represents a Data packet.
Data & setSignature(const Signature &signature)
Set Signature.
Data & setFinalBlock(optional< name::Component > finalBlockId)
constexpr bool isCriticalType(uint32_t type)
Determine whether a TLV-TYPE is "critical" for evolvability purpose.
Represents a TLV element of NDN packet format.
size_t size() const
Return the size of the encoded wire, i.e.
std::string to_string(const T &val)
element_const_iterator elements_end() const
Equivalent to elements().end()
bool operator==(const Data &lhs, const Data &rhs)
std::ostream & operator<<(std::ostream &os, const Data &data)
tlv::SignatureTypeValue getType() const
Get SignatureType.
const Block & wireEncode() const
Encode to a Block.
void clear()
Remove all components.
bool hasWire() const noexcept
Check if the Block contains a fully encoded wire representation.
const MetaInfo & getMetaInfo() const
Get MetaInfo.
Data(const Name &name=Name())
Construct an unsigned Data packet with given name and empty Content.
const Name & getFullName() const
Get full name including implicit digest.
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
Name & appendImplicitSha256Digest(ConstBufferPtr digest)
Append an ImplicitSha256Digest component.
Block makeBinaryBlock(uint32_t type, const uint8_t *value, size_t length)
Create a TLV block copying TLV-VALUE from raw buffer.
shared_ptr< const Buffer > ConstBufferPtr
a concept check for TLV abstraction with .wireEncode method
Copyright (c) 2011-2015 Regents of the University of California.
EncodingImpl< EncoderTag > EncodingBuffer
const Signature & getSignature() const
Get Signature.