PcapPlusPlus
pcpp::TcpOptionData Struct Reference

#include <TcpLayer.h>

Public Member Functions

template<typename T >
getValueAs (int valueOffset=0)
 
template<typename T >
void setValue (T newValue, int valueOffset=0)
 
size_t getTotalSize () const
 
TcpOption getType ()
 

Public Attributes

uint8_t option
 
uint8_t len
 
uint8_t value []
 

Detailed Description

Representing a TCP option in a TLV (type-length-value) type

Member Function Documentation

◆ getTotalSize()

size_t pcpp::TcpOptionData::getTotalSize ( ) const
inline
Returns
The total size in bytes of this TCP option which includes: 1[Byte] (option type) + 1[Byte] (option length) + X[Bytes] (option data length)

◆ getType()

TcpOption pcpp::TcpOptionData::getType ( )
inline
Returns
TCP option type casted as TcpOption enum

◆ getValueAs()

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

A templated method to retrieve the TCP option data as a certain type T. For example, if option data is 4B (integer) then this method should be used as getValueAs<int>() and it will return the TCP 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 TCP 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 copy from the beginning of option data
Returns
The TCP option data as type T

◆ setValue()

template<typename T >
void pcpp::TcpOptionData::setValue ( newValue,
int  valueOffset = 0 
)
inline

A templated method to copy data of type T into the TCP option data. For example: if option data is 4[Bytes] long use this method with <int> to set an integer value into the TCP option data: setValue<int>(num)

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

Member Data Documentation

◆ len

uint8_t pcpp::TcpOptionData::len

TCP option length

◆ option

uint8_t pcpp::TcpOptionData::option

TCP option type, should be on of TcpOption

◆ value

uint8_t pcpp::TcpOptionData::value[]

TCP option value