PcapPlusPlus
|
#include <IPv4Layer.h>
Represents an IPv4 protocol layer
pcpp::IPv4Layer::IPv4Layer | ( | uint8_t * | data, |
size_t | dataLen, | ||
Layer * | prevLayer, | ||
Packet * | packet, | ||
bool | setTotalLenAsDataLen | ||
) |
A constructor that creates the layer from an existing packet raw data
[in] | data | A pointer to the raw data (will be casted to iphdr) |
[in] | dataLen | Size of the data in bytes |
[in] | prevLayer | A pointer to the previous layer |
[in] | packet | A pointer to the Packet instance where layer will be stored in |
[in] | setTotalLenAsDataLen | When setting this value to "true" or when using the other c'tor, the layer data length is calculated from iphdr::totalLength field. When setting to "false" the data length is set as the value of dataLen parameter |
pcpp::IPv4Layer::IPv4Layer | ( | ) |
A constructor that allocates a new IPv4 header with empty fields
pcpp::IPv4Layer::IPv4Layer | ( | const IPv4Address & | srcIP, |
const IPv4Address & | dstIP | ||
) |
A constructor that allocates a new IPv4 header with source and destination IPv4 addresses
[in] | srcIP | Source IPv4 address |
[in] | dstIP | Destination IPv4 address |
pcpp::IPv4Layer::IPv4Layer | ( | const IPv4Layer & | other | ) |
A copy constructor that copy the entire header from the other IPv4Layer (including IPv4 options)
IPv4OptionData* pcpp::IPv4Layer::addOption | ( | IPv4OptionTypes | optionType, |
uint8_t | optionDataLength, | ||
const uint8_t * | optionData | ||
) |
Add an IPv4 option
[in] | optionType | The IPv4 option type to add |
[in] | optionDataLength | The length of the option data [in bytes]. For IPV4OPT_NOP and IPV4OPT_EndOfOtionsList this parameter must be 0 otherwise the method will fail |
[in] | optionData | A byte array containing the IPv4 option data (should be in size indicated in optionDataLength). For IPV4OPT_NOP and IPV4OPT_EndOfOtionsList this parameter is ignored (expected to be NULL) |
IPv4OptionData* pcpp::IPv4Layer::addOption | ( | IPv4OptionTypes | optionType, |
const std::vector< IPv4Address > & | ipList | ||
) |
Add an IPv4 option with value of IP address list. This method is relevant only for option types which value is IP address list such as IPV4OPT_StrictSourceRoute, IPV4OPT_RecordRoute and IPV4OPT_LooseSourceRoute. Please note this method calculates and sets the pointer field in the option value automatically
[in] | optionType | The IPv4 option type to add (should be option type which value is IP address list) |
[in] | ipList | The list of IP addresses to set. Please note this method doesn't automatically adds zero IP addresses (with value of 0.0.0.0), so if you want the option value to include zero values please add them to the list |
IPv4OptionData* pcpp::IPv4Layer::addOptionAfter | ( | IPv4OptionTypes | optionType, |
uint8_t | optionDataLength, | ||
const uint8_t * | optionData, | ||
IPv4OptionTypes | prevOption = IPV4OPT_Unknown |
||
) |
Add an IPv4 option after an existing option
[in] | optionType | The IPv4 option type to add |
[in] | optionDataLength | The length of the option data [in bytes]. For IPV4OPT_NOP and IPV4OPT_EndOfOtionsList this parameter must be 0 otherwise the method will fail |
[in] | optionData | A byte array containing the IPv4 option data (should be in size indicated in optionDataLength). For IPV4OPT_NOP and IPV4OPT_EndOfOtionsList this parameter is ignored (expected to be NULL) |
[in] | prevOption | The option type which the new option should be added after. It's an optional parameter, if it's not set or set to an option that doesn't exist the new option will be added as the first option in the layer |
IPv4OptionData* pcpp::IPv4Layer::addOptionAfter | ( | IPv4OptionTypes | optionType, |
const std::vector< IPv4Address > & | ipList, | ||
IPv4OptionTypes | prevOption = IPV4OPT_Unknown |
||
) |
Add an IPv4 option with value of IP address list after an existing option. This method is relevant only for option types which value is IP address list such as IPV4OPT_StrictSourceRoute, IPV4OPT_RecordRoute and IPV4OPT_LooseSourceRoute. Please note this method calculates and sets the pointer field in the option value automatically
[in] | optionType | The IPv4 option type to add (should be option type which value is IP address list) |
[in] | ipList | The list of IP addresses to set. Please note this method doesn't automatically adds zero IP addresses (with value of 0.0.0.0), so if you want the option value to include zero values please add them to the list |
[in] | prevOption | The option type which the new option should be added after. It's an optional parameter, if it's not set or set to an option that doesn't exist the new option will be added as the first option in the layer |
IPv4OptionData* pcpp::IPv4Layer::addTimestampOption | ( | const IPv4TimestampOptionValue & | timestampValue | ) |
Add an IPv4 timestamp option. Please note that timestamp type of IPv4TimestampOptionValue::TimestampsForPrespecifiedIPs is currently not supported. Please also note this method calculates and sets the pointer field in the timestamp option value automatically
[in] | timestampValue | Timestamp option value to set, including timestamp type (timestamp only or timestamp and IP) and a list of timestamps and/or IP addresses |
IPv4OptionData* pcpp::IPv4Layer::addTimestampOptionAfter | ( | const IPv4TimestampOptionValue & | timestampValue, |
IPv4OptionTypes | prevOption = IPV4OPT_Unknown |
||
) |
Add an IPv4 timestamp option after some existing option. Please note that timestamp type of IPv4TimestampOptionValue::TimestampsForPrespecifiedIPs is currently not supported. Please also note this method calculates and sets the pointer field in the timestamp option value automatically
[in] | timestampValue | Timestamp option value to set, including timestamp type (timestamp only or timestamp and IP) and a list of timestamps and/or IP addresses |
[in] | prevOption | The option type which the new option should be added after. It's an optional parameter, if it's not set or set to an option that doesn't exist the new option will be added as the first option in the layer |
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
|
inline |
Get the destination IP address in the form of IPv4Address
IPv4OptionData* pcpp::IPv4Layer::getFirstOptionData | ( | ) |
uint8_t pcpp::IPv4Layer::getFragmentFlags | ( | ) |
uint16_t pcpp::IPv4Layer::getFragmentOffset | ( | ) |
|
inlinevirtual |
Implements pcpp::Layer.
|
inline |
Get a pointer to the IPv4 header. Notice this points directly to the data, so every change will change the actual packet data
IPv4OptionData* pcpp::IPv4Layer::getNextOptionData | ( | IPv4OptionData * | option | ) |
Get the IPv4 option which comes next to "option" parameter. If "option" is NULL then NULL will be returned. If "option" is the last IPv4 option NULL will be returned. Notice the return value is a pointer to the real data casted to IPv4OptionData type (as opposed to a copy of the option data). So changes in the return value will affect the packet data
[in] | option | The IPv4 option to start searching from |
IPv4OptionData* pcpp::IPv4Layer::getOptionData | ( | IPv4OptionTypes | option | ) |
Get a pointer to an IPv4 option. Notice this points directly to the data, so every change will change the actual packet data
[in] | option | The IPv4 option to get |
size_t pcpp::IPv4Layer::getOptionsCount | ( | ) |
|
inlinevirtual |
Implements pcpp::Layer.
|
inline |
Get the source IP address in the form of IPv4Address
bool pcpp::IPv4Layer::isFirstFragment | ( | ) |
bool pcpp::IPv4Layer::isFragment | ( | ) |
bool pcpp::IPv4Layer::isLastFragment | ( | ) |
An assignment operator that first delete all data from current layer and then copy the entire header from the other IPv4Layer (including IPv4 options)
|
virtual |
Currently identifies the following next layers: UdpLayer, TcpLayer. Otherwise sets PayloadLayer
Implements pcpp::Layer.
bool pcpp::IPv4Layer::removeAllOptions | ( | ) |
Remove all IPv4 options from the layer
bool pcpp::IPv4Layer::removeOption | ( | IPv4OptionTypes | option | ) |
Remove an IPv4 option
[in] | option | The option type to remove |
|
inline |
Set the dest IP address
[in] | ipAddr | The IP address to set |
|
inline |
Set the source IP address
[in] | ipAddr | The IP address to set |
|
virtual |
Implements pcpp::Layer.