PcapPlusPlus  24.09
pcpp::IPv4Option Class Reference

#include <IPv4Layer.h>

Inheritance diagram for pcpp::IPv4Option:
pcpp::TLVRecord< uint8_t, uint8_t >

Public Member Functions

 IPv4Option (uint8_t *optionRawData)
 
 ~IPv4Option ()
 
std::vector< IPv4AddressgetValueAsIpList () const
 
IPv4TimestampOptionValue getTimestampOptionValue () const
 
IPv4OptionTypes getIPv4OptionType () const
 
size_t getTotalSize () const
 
size_t getDataSize () const
 
- Public Member Functions inherited from pcpp::TLVRecord< uint8_t, uint8_t >
 TLVRecord (uint8_t *recordRawData)
 
 TLVRecord (const TLVRecord &other)
 
virtual ~TLVRecord ()
 
void assign (uint8_t *recordRawData)
 
TLVRecordoperator= (const TLVRecord &other)
 
bool operator== (const TLVRecord &rhs) const
 
bool operator!= (const TLVRecord &rhs) const
 
uint8_t getType () const
 
uint8_t * getValue () const
 
bool isNull () const
 
bool isNotNull () const
 
uint8_t * getRecordBasePtr () const
 
void purgeRecordData ()
 
getValueAs (size_t offset=0) const
 
bool setValue (T newValue, int valueOffset=0)
 

Static Public Member Functions

static bool canAssign (const uint8_t *recordRawData, size_t tlvDataLen)
 
- Static Public Member Functions inherited from pcpp::TLVRecord< uint8_t, uint8_t >
static bool canAssign (const uint8_t *recordRawData, size_t tlvDataLen)
 

Detailed Description

A wrapper class for IPv4 options. This class does not create or modify IPv4 option records, but rather serves as a wrapper and provides useful methods for retrieving data from them

Constructor & Destructor Documentation

◆ IPv4Option()

pcpp::IPv4Option::IPv4Option ( uint8_t *  optionRawData)
inlineexplicit

A c'tor for this class that gets a pointer to the option raw data (byte array)

Parameters
[in]optionRawDataA pointer to the IPv4 option raw data

◆ ~IPv4Option()

pcpp::IPv4Option::~IPv4Option ( )
inline

A d'tor for this class, currently does nothing

Member Function Documentation

◆ canAssign()

static bool pcpp::IPv4Option::canAssign ( const uint8_t *  recordRawData,
size_t  tlvDataLen 
)
inlinestatic

Check if a pointer can be assigned to the TLV record data

Parameters
[in]recordRawDataA pointer to the TLV record raw data
[in]tlvDataLenThe size of the TLV record raw data
Returns
True if data is valid and can be assigned

◆ getDataSize()

size_t pcpp::IPv4Option::getDataSize ( ) const
inlinevirtual
Returns
The size of the record value (meaning the size of the 'V' part in TLV)

Implements pcpp::TLVRecord< uint8_t, uint8_t >.

◆ getIPv4OptionType()

IPv4OptionTypes pcpp::IPv4Option::getIPv4OptionType ( ) const
inline
Returns
IPv4 option type casted as pcpp::IPv4OptionTypes enum

◆ getTimestampOptionValue()

IPv4TimestampOptionValue pcpp::IPv4Option::getTimestampOptionValue ( ) const
inline

A method for parsing the IPv4 timestamp option value. This method is relevant only for IPv4 timestamp option. For other option types an empty result will be returned. The returned structure contains the timestamp value type (timestamp only, timestamp + IP addresses, etc.) as well as 2 vectors containing the list of timestamps and the list of IP addresses (if applicable for the timestamp value type). Blank timestamps or IP addresses (meaning zeroed values - timestamp=0 or IP address=0.0.0.0) will not be added to the lists. If some error occurs during the parsing or the value is invalid an empty result is returned

Returns
A structured containing the IPv4 timestamp value

◆ getTotalSize()

size_t pcpp::IPv4Option::getTotalSize ( ) const
inlinevirtual
Returns
The total size of the TLV record (in bytes)

Implements pcpp::TLVRecord< uint8_t, uint8_t >.

◆ getValueAsIpList()

std::vector<IPv4Address> pcpp::IPv4Option::getValueAsIpList ( ) const
inline

A method for parsing the IPv4 option value as a list of IPv4 addresses. This method is relevant only for certain types of IPv4 options which their value is a list of IPv4 addresses such as IPV4OPT_RecordRoute, IPV4OPT_StrictSourceRoute, IPV4OPT_LooseSourceRoute, etc. This method returns a vector of the IPv4 addresses. Blank IP addresses (meaning zeroed addresses - 0.0.0.0) will not be added to the returned list. If some error occurs during the parsing or the value is invalid an empty vector is returned

Returns
A vector of IPv4 addresses parsed from the IPv4 option value