PcapPlusPlus
21.05
|
#include <IPv4Layer.h>
Static Public Member Functions | |
static bool | isDataValid (const uint8_t *data, size_t dataLen) |
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. Please notice that if iphdr::totalLength is equal to zero (which can happen in TCP Segmentation Offloading), this flag is ignored and the layer data length is calculated by the actual data captured on the wire |
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)
IPv4Option pcpp::IPv4Layer::addOption | ( | const IPv4OptionBuilder & | optionBuilder | ) |
Add a new IPv4 option at the end of the layer (after the last IPv4 option)
[in] | optionBuilder | An IPv4OptionBuilder object that contains the IPv4 option data to be added |
IPv4Option pcpp::IPv4Layer::addOptionAfter | ( | const IPv4OptionBuilder & | optionBuilder, |
IPv4OptionTypes | prevOptionType = IPV4OPT_Unknown |
||
) |
Add a new IPv4 option after an existing one
[in] | optionBuilder | An IPv4OptionBuilder object that contains the requested IPv4 option data to be added |
[in] | prevOptionType | The IPv4 option which the newly added option should come after. This is an optional parameter which gets a default value of IPV4OPT_Unknown if omitted, which means the new option will be added as the first option in the layer |
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
|
inlinevirtual |
Get the destination IP address in the form of IPAddress. This method is very similar to getDstIPv4Address(), but adds a level of abstraction because IPAddress can be used for both IPv4 and IPv6 addresses
Implements pcpp::IPLayer.
|
inline |
|
inline |
Get the destination IP address in the form of IPv4Address
IPv4Option pcpp::IPv4Layer::getFirstOption | ( | ) | const |
uint8_t pcpp::IPv4Layer::getFragmentFlags | ( | ) | const |
uint16_t pcpp::IPv4Layer::getFragmentOffset | ( | ) | const |
|
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
IPv4Option pcpp::IPv4Layer::getNextOption | ( | IPv4Option & | option | ) | const |
Get the IPv4 option that comes after a given option. If the given option was the last one, the returned value will contain a logical NULL (IPv4Option::isNull() == true)
[in] | option | An IPv4 option object that exists in the current layer |
IPv4Option pcpp::IPv4Layer::getOption | ( | IPv4OptionTypes | option | ) | const |
Get an IPv4 option by type.
[in] | option | IPv4 option type |
size_t pcpp::IPv4Layer::getOptionCount | ( | ) | const |
|
inlinevirtual |
Implements pcpp::Layer.
|
inlinevirtual |
Get the source IP address in the form of IPAddress. This method is very similar to getSrcIPv4Address(), but adds a level of abstraction because IPAddress can be used for both IPv4 and IPv6 addresses
Implements pcpp::IPLayer.
|
inline |
|
inline |
Get the source IP address in the form of IPv4Address
|
inlinestatic |
A static method that validates the input data
[in] | data | The pointer to the beginning of a byte stream of IP packet |
[in] | dataLen | The length of the byte stream |
bool pcpp::IPv4Layer::isFirstFragment | ( | ) | const |
bool pcpp::IPv4Layer::isFragment | ( | ) | const |
bool pcpp::IPv4Layer::isLastFragment | ( | ) | const |
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:
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.