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

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

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= will not be added to the lists. If some error occurs during the parsing or the value is invalid an empty result is returned

A structured containing the IPv4 timestamp value
size_t pcpp::IPv4OptionData::getTotalSize ( ) const
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
IPv4OptionTypes pcpp::IPv4OptionData::getType ( )
IPv4 option type casted as pcpp::IPv4OptionTypes enum
template<typename T >
T pcpp::IPv4OptionData::getValueAs ( int  valueOffset = 0)

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

[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
The IPv4 option data as type T
std::vector<IPv4Address> pcpp::IPv4OptionData::getValueAsIpList ( )

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 - 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

A vector of IPv4 addresses parsed from the IPv4 option value

Member Data Documentation

uint8_t pcpp::IPv4OptionData::len

IPv4 option length

uint8_t pcpp::IPv4OptionData::opCode

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

uint8_t pcpp::IPv4OptionData::value[]

IPv4 option value