PcapPlusPlus  21.05
pcpp::TLVRecordReader< TLVRecordType > Class Template Reference

#include <TLVData.h>

Public Member Functions

 TLVRecordReader ()
 
 TLVRecordReader (const TLVRecordReader &other)
 
virtual ~TLVRecordReader ()
 
TLVRecordReaderoperator= (const TLVRecordReader &other)
 
TLVRecordType getFirstTLVRecord (uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
 
TLVRecordType getNextTLVRecord (TLVRecordType &record, uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
 
TLVRecordType getTLVRecord (uint8_t recordType, uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
 
size_t getTLVRecordCount (uint8_t *tlvDataBasePtr, size_t tlvDataLen) const
 
void changeTLVRecordCount (int changedBy)
 

Detailed Description

template<typename TLVRecordType>
class pcpp::TLVRecordReader< TLVRecordType >

A class for reading TLV records data out of a byte stream. This class contains helper methods for retrieving and counting TLV records. This is a template class that expects template argument class derived from TLVRecord.

Constructor & Destructor Documentation

◆ TLVRecordReader() [1/2]

template<typename TLVRecordType>
pcpp::TLVRecordReader< TLVRecordType >::TLVRecordReader ( )
inline

A default c'tor for this class

◆ TLVRecordReader() [2/2]

template<typename TLVRecordType>
pcpp::TLVRecordReader< TLVRecordType >::TLVRecordReader ( const TLVRecordReader< TLVRecordType > &  other)
inline

A default copy c'tor for this class

◆ ~TLVRecordReader()

template<typename TLVRecordType>
virtual pcpp::TLVRecordReader< TLVRecordType >::~TLVRecordReader ( )
inlinevirtual

A d'tor for this class which currently does nothing

Member Function Documentation

◆ changeTLVRecordCount()

template<typename TLVRecordType>
void pcpp::TLVRecordReader< TLVRecordType >::changeTLVRecordCount ( int  changedBy)
inline

As described in getTLVRecordCount(), the TLV record count is being cached for efficiency purposes. So if the number of TLV records change, it's the user's responsibility to call this method with the number of TLV records being added or removed. If records were added the change should be a positive number, or a negative number if records were removed

Parameters
[in]changedByNumber of records that were added or removed

◆ getFirstTLVRecord()

template<typename TLVRecordType>
TLVRecordType pcpp::TLVRecordReader< TLVRecordType >::getFirstTLVRecord ( uint8_t *  tlvDataBasePtr,
size_t  tlvDataLen 
) const
inline

Get the first TLV record out of a byte stream

Parameters
[in]tlvDataBasePtrA pointer to the TLV data byte stream
[in]tlvDataLenThe TLV data byte stream length
Returns
An instance of type TLVRecordType that contains the first TLV record. If tlvDataBasePtr is NULL or tlvDataLen is zero the returned TLVRecordType instance will be logically NULL, meaning TLVRecordType.isNull() will return true

◆ getNextTLVRecord()

template<typename TLVRecordType>
TLVRecordType pcpp::TLVRecordReader< TLVRecordType >::getNextTLVRecord ( TLVRecordType &  record,
uint8_t *  tlvDataBasePtr,
size_t  tlvDataLen 
) const
inline

Get a TLV record that follows a given TLV record in a byte stream

Parameters
[in]recordA given TLV record
[in]tlvDataBasePtrA pointer to the TLV data byte stream
[in]tlvDataLenThe TLV data byte stream length
Returns
An instance of type TLVRecordType that wraps the record following the record given as input. If the input record.isNull() is true or if the next record is out of bounds of the byte stream, a logical NULL instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true

◆ getTLVRecord()

template<typename TLVRecordType>
TLVRecordType pcpp::TLVRecordReader< TLVRecordType >::getTLVRecord ( uint8_t  recordType,
uint8_t *  tlvDataBasePtr,
size_t  tlvDataLen 
) const
inline

Search for the first TLV record that corresponds to a given record type (the 'T' in Type-Length-Value)

Parameters
[in]recordTypeThe record type to search for
[in]tlvDataBasePtrA pointer to the TLV data byte stream
[in]tlvDataLenThe TLV data byte stream length
Returns
An instance of type TLVRecordType that contains the result record. If record was not found a logical NULL instance of TLVRecordType will be returned, meaning TLVRecordType.isNull() will return true

◆ getTLVRecordCount()

template<typename TLVRecordType>
size_t pcpp::TLVRecordReader< TLVRecordType >::getTLVRecordCount ( uint8_t *  tlvDataBasePtr,
size_t  tlvDataLen 
) const
inline

Get the TLV record count in a given TLV data byte stream. For efficiency purposes the count is being cached so only the first call to this method will go over all the TLV records, while all consequent calls will return the cached number. This implies that if there is a change in the number of records, it's the user's responsibility to call changeTLVRecordCount() with the record count change

Parameters
[in]tlvDataBasePtrA pointer to the TLV data byte stream
[in]tlvDataLenThe TLV data byte stream length
Returns
The TLV record count

◆ operator=()

template<typename TLVRecordType>
TLVRecordReader& pcpp::TLVRecordReader< TLVRecordType >::operator= ( const TLVRecordReader< TLVRecordType > &  other)
inline

Overload of the assignment operator for this class

Parameters
[in]otherThe TLVRecordReader instance to assign