PcapPlusPlus  Next
pcpp::Asn1Record Class Referenceabstract

#include <Asn1Codec.h>

Inheritance diagram for pcpp::Asn1Record:
pcpp::Asn1ConstructedRecord pcpp::Asn1GenericRecord pcpp::Asn1PrimitiveRecord pcpp::Asn1SequenceRecord pcpp::Asn1SetRecord pcpp::Asn1BooleanRecord pcpp::Asn1IntegerRecord pcpp::Asn1NullRecord pcpp::Asn1OctetStringRecord pcpp::Asn1EnumeratedRecord

Public Member Functions

std::vector< uint8_t > encode ()
 
Asn1TagClass getTagClass () const
 
bool isConstructed () const
 
Asn1UniversalTagType getUniversalTagType () const
 
uint8_t getTagType () const
 
size_t getValueLength () const
 
size_t getTotalLength () const
 
std::string toString ()
 
template<class Asn1RecordType >
Asn1RecordType * castAs ()
 

Static Public Member Functions

static std::unique_ptr< Asn1Recorddecode (const uint8_t *data, size_t dataLen, bool lazy=true)
 

Detailed Description

Represents an ASN.1 record, as described in ITU-T Recommendation X.680: https://www.itu.int/rec/T-REC-X.680/en

https://en.wikipedia.org/wiki/ASN.1

Member Function Documentation

◆ castAs()

template<class Asn1RecordType >
Asn1RecordType* pcpp::Asn1Record::castAs ( )
inline

A templated method that accepts a class derived from Asn1Record as its template argument and attempts to cast the current instance to that type

Template Parameters
Asn1RecordTypeThe type to cast to
Returns
A pointer to the type after casting

◆ decode()

static std::unique_ptr<Asn1Record> pcpp::Asn1Record::decode ( const uint8_t *  data,
size_t  dataLen,
bool  lazy = true 
)
static

A static method to decode a byte array into an Asn1Record

Parameters
dataA byte array to decode
dataLenThe byte array length
lazyUse lazy decoding, set to true by default. Lazy decoding entails delaying the decoding of the record value until it is accessed
Returns
A smart pointer to the decoded ASN.1 record. If the byte stream is not a valid ASN.1 record an exception is thrown

◆ encode()

std::vector<uint8_t> pcpp::Asn1Record::encode ( )

Encode this record and convert it to a byte stream

Returns
A vector of bytes representing the record

◆ getTagClass()

Asn1TagClass pcpp::Asn1Record::getTagClass ( ) const
inline
Returns
The ASN.1 tag class

◆ getTagType()

uint8_t pcpp::Asn1Record::getTagType ( ) const
inline
Returns
The ASN.1 tag type value

◆ getTotalLength()

size_t pcpp::Asn1Record::getTotalLength ( ) const
inline
Returns
The total length of the record

◆ getUniversalTagType()

Asn1UniversalTagType pcpp::Asn1Record::getUniversalTagType ( ) const
Returns
The ASN.1 Universal tag type if the record is of class Universal, otherwise Asn1UniversalTagType::NotApplicable

◆ getValueLength()

size_t pcpp::Asn1Record::getValueLength ( ) const
inline
Returns
The length of the record value

◆ isConstructed()

bool pcpp::Asn1Record::isConstructed ( ) const
inline
Returns
True if it's a constructed record, or false if it's a primitive record

◆ toString()

std::string pcpp::Asn1Record::toString ( )
Returns
A string representation of the record