esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
ndnph::Data Class Reference

Data packet. More...

#include <data.hpp>

Inherits ndnph::Printable, and ndnph::RefRegion< detail::DataObj >.

Public Types

enum  CanSatisfyOptions { CanSatisfyNone = 0 , CanSatisfyInCache = 1 << 0 }
 
using Signed = detail::SignedDataRef
 Result of Data::sign operation. More...
 
- Public Types inherited from ndnph::RefRegion< detail::DataObj >
using ObjType = detail::DataObj
 

Public Member Functions

const NamegetName () const
 
void setName (const Name &v)
 
uint8_t getContentType () const
 
void setContentType (uint8_t v)
 
uint32_t getFreshnessPeriod () const
 
void setFreshnessPeriod (uint32_t v)
 
bool getIsFinalBlock () const
 
void setIsFinalBlock (bool v)
 
tlv::Value getContent () const
 
void setContent (tlv::Value v)
 
const DSigInfogetSigInfo () const
 Retrieve SignatureInfo. More...
 
void encodeTo (Encoder &encoder) const
 Prepend the original packet to Encoder. More...
 
bool decodeFrom (const Decoder::Tlv &input)
 Decode packet. More...
 
template<typename Encodable >
bool decodeFrom (Encodable &&encodable)
 Encode then decode as Data packet. More...
 
Signed sign (const PrivateKey &key, DSigInfo sigInfo=DSigInfo()) const
 Sign the packet with a private key. More...
 
bool verify (const PublicKey &key) const
 Verify the packet with a public key. More...
 
bool computeImplicitDigest (uint8_t digest[NDNPH_SHA256_LEN]) const
 Compute implicit digest. More...
 
Name getFullName (Region &region) const
 Obtain full name with implicit digest. More...
 
template<typename InterestT >
bool canSatisfy (const InterestT &interest, CanSatisfyOptions opts=CanSatisfyNone) const
 Determine whether Data can satisfy Interest. More...
 
size_t printTo (::Print &p) const final
 
 RefRegion (ObjType *obj=nullptr)
 
- Public Member Functions inherited from ndnph::Printable
 operator Esp32Printable () const
 
- Public Member Functions inherited from ndnph::RefRegion< detail::DataObj >
 RefRegion (ObjType *obj=nullptr)
 
 operator bool () const
 

Additional Inherited Members

- Protected Member Functions inherited from ndnph::RefRegion< detail::DataObj >
 ~RefRegion ()=default
 
- Protected Attributes inherited from ndnph::RefRegion< detail::DataObj >
ObjTypeobj
 

Detailed Description

Data packet.

Member Typedef Documentation

◆ Signed

Result of Data::sign operation.

Member Enumeration Documentation

◆ CanSatisfyOptions

Enumerator
CanSatisfyNone 
CanSatisfyInCache 

Member Function Documentation

◆ canSatisfy()

template<typename InterestT >
bool ndnph::Data::canSatisfy ( const InterestT &  interest,
CanSatisfyOptions  opts = CanSatisfyNone 
) const
inline

Determine whether Data can satisfy Interest.

Template Parameters
InterestTthe ndnph::Interest type.

This method only works reliably on decoded packets. For packets that are being constructed or modified, this method may give incorrect results for parameterized/signed Interests or Interest carrying implicit digest component.

◆ computeImplicitDigest()

bool ndnph::Data::computeImplicitDigest ( uint8_t  digest[NDNPH_SHA256_LEN]) const
inline

Compute implicit digest.

Precondition
Data was decoded, not being constructed.
Returns
whether success.

◆ decodeFrom() [1/2]

bool ndnph::Data::decodeFrom ( const Decoder::Tlv input)
inline

Decode packet.

◆ decodeFrom() [2/2]

template<typename Encodable >
bool ndnph::Data::decodeFrom ( Encodable &&  encodable)
inline

Encode then decode as Data packet.

This is useful for obtaining a Data packet in decoded state from the result of signing.

◆ encodeTo()

void ndnph::Data::encodeTo ( Encoder encoder) const
inline

Prepend the original packet to Encoder.

Precondition
only available on decoded packet.

◆ getContent()

tlv::Value ndnph::Data::getContent ( ) const
inline

◆ getContentType()

uint8_t ndnph::Data::getContentType ( ) const
inline

◆ getFreshnessPeriod()

uint32_t ndnph::Data::getFreshnessPeriod ( ) const
inline

◆ getFullName()

Name ndnph::Data::getFullName ( Region region) const
inline

Obtain full name with implicit digest.

See also
computeImplicitDigest() .
Returns
full name, or a falsy value upon failure.

◆ getIsFinalBlock()

bool ndnph::Data::getIsFinalBlock ( ) const
inline

◆ getName()

const Name& ndnph::Data::getName ( ) const
inline

◆ getSigInfo()

const DSigInfo* ndnph::Data::getSigInfo ( ) const
inline

Retrieve SignatureInfo.

Precondition
only available on decoded packet.

◆ printTo()

size_t ndnph::Data::printTo ( ::Print &  p) const
inlinefinalvirtual

Implements ndnph::Printable.

◆ RefRegion()

ndnph::RefRegion< Obj >::RefRegion
inlineexplicit

◆ setContent()

void ndnph::Data::setContent ( tlv::Value  v)
inline

◆ setContentType()

void ndnph::Data::setContentType ( uint8_t  v)
inline

◆ setFreshnessPeriod()

void ndnph::Data::setFreshnessPeriod ( uint32_t  v)
inline

◆ setIsFinalBlock()

void ndnph::Data::setIsFinalBlock ( bool  v)
inline

◆ setName()

void ndnph::Data::setName ( const Name v)
inline

◆ sign()

Signed ndnph::Data::sign ( const PrivateKey key,
DSigInfo  sigInfo = DSigInfo() 
) const
inline

Sign the packet with a private key.

Returns
an Encodable object. This object is valid only if Data and PrivateKey are kept alive. It's recommended to pass it to Encoder immediately without saving as variable.
Note
Unrecognized fields found during decoding are not preserved in encoding output.

◆ verify()

bool ndnph::Data::verify ( const PublicKey key) const
inline

Verify the packet with a public key.

Precondition
only available on decoded packet.
Returns
verification result.

The documentation for this class was generated from the following file: