PcapPlusPlus
pcpp::IPv4OptionData Struct Reference

#include <IPv4Layer.h>

Public Member Functions

template<typename T >
getValueAs (int valueOffset=0)
 
std::vector< IPv4AddressgetValueAsIpList ()
 
IPv4TimestampOptionValue getTimestampOptionValue ()
 
size_t getTotalSize () const
 
size_t getDataSize ()
 
IPv4OptionTypes getType ()
 

Public Attributes

uint8_t opCode
 
uint8_t len
 
uint8_t value []
 

Detailed Description

Representing a IPv4 option in a TLV (type-length-value) structure

Member Function Documentation

◆ getDataSize()

size_t pcpp::IPv4OptionData::getDataSize ( )
inline
Returns
The size of the option data (not containing the size of the option type and option length fields)

◆ getTimestampOptionValue()

IPv4TimestampOptionValue pcpp::IPv4OptionData::getTimestampOptionValue ( )
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::IPv4OptionData::getTotalSize ( ) const
inline
Returns
The total size in bytes of this IPv4 option which includes: 1[Byte] (option type) + 1[Byte] (option length) + X[Bytes] (option data length). For IPV4OPT_EndOfOtionsList and IPV4OPT_NOP the value 1 is returned

◆ getType()

IPv4OptionTypes pcpp::IPv4OptionData::getType ( )
inline
Returns
IPv4 option type casted as pcpp::IPv4OptionTypes enum

◆ getValueAs()

template<typename T >
T pcpp::IPv4OptionData::getValueAs ( int  valueOffset = 0)
inline

A templated method to retrieve the IPv4 option data as a certain type T. For example, if IPv4 option data is 4B (integer) then this method should be used as getValueAs<int>() and it will return the IPv4 option data as an integer.
Notice this return value is a copy of the data, not a pointer to the actual data

Parameters
[in]valueOffsetAn optional parameter that specifies where to start copy the IPv4 option data. For example: if option data is 20 bytes and you need only the 4 last bytes as integer then use this method like this: getValueAs<int>(16). The default is 0 - start copying from the beginning of option data
Returns
The IPv4 option data as type T

◆ getValueAsIpList()

std::vector<IPv4Address> pcpp::IPv4OptionData::getValueAsIpList ( )
inline

A method for parsing the IPv4 option value as an IP list. 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

Member Data Documentation

◆ len

uint8_t pcpp::IPv4OptionData::len

IPv4 option length

◆ opCode

uint8_t pcpp::IPv4OptionData::opCode

IPv4 option code, should be of type pcpp::IPv4OptionTypes

◆ value

uint8_t pcpp::IPv4OptionData::value[]

IPv4 option value