PcapPlusPlus
20.08
|
#include <DhcpLayer.h>
Represents a DHCP (Dynamic Host Configuration Protocol) protocol layer
A constructor that creates the layer from an existing packet raw data
[in] | data | A pointer to the raw data |
[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 |
pcpp::DhcpLayer::DhcpLayer | ( | DhcpMessageType | msgType, |
const MacAddress & | clientMacAddr | ||
) |
A constructor that creates the layer from scratch. Adds a DHCPOPT_DHCP_MESSAGE_TYPE and a DHCPOPT_END options
[in] | msgType | A DHCP message type to be set |
[in] | clientMacAddr | A client MAC address to set in dhcp_header::clientHardwareAddress field |
pcpp::DhcpLayer::DhcpLayer | ( | ) |
A constructor that creates the layer from scratch with clean data
|
inlinevirtual |
A destructor for this layer
DhcpOption pcpp::DhcpLayer::addOption | ( | const DhcpOptionBuilder & | optionBuilder | ) |
Add a new DHCP option at the end of the layer
[in] | optionBuilder | A DhcpOptionBuilder object that contains the requested DHCP option data to add |
DhcpOption pcpp::DhcpLayer::addOptionAfter | ( | const DhcpOptionBuilder & | optionBuilder, |
DhcpOptionTypes | prevOption | ||
) |
Add a new DHCP option after an existing one
[in] | optionBuilder | A DhcpOptionBuilder object that contains the requested DHCP option data to add |
[in] | prevOption | The DHCP option type which the newly added option will come after |
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
MacAddress pcpp::DhcpLayer::getClientHardwareAddress | ( | ) | const |
|
inline |
|
inline |
Get a pointer to the DHCP header. Notice this points directly to the data, so every change will change the actual packet data
DhcpOption pcpp::DhcpLayer::getFirstOptionData | ( | ) | const |
|
inline |
|
inlinevirtual |
Implements pcpp::Layer.
DhcpMessageType pcpp::DhcpLayer::getMesageType | ( | ) | const |
DhcpOption pcpp::DhcpLayer::getNextOptionData | ( | DhcpOption | dhcpOption | ) | const |
Get the DHCP option that comes after a given option. If the given option was the last one, the returned value will contain a logical NULL (DhcpOption::isNull() == true)
[in] | dhcpOption | A given DHCP option |
|
inline |
DhcpOption pcpp::DhcpLayer::getOptionData | ( | DhcpOptionTypes | option | ) | const |
Get a DHCP option by type
[in] | option | DHCP option type |
size_t pcpp::DhcpLayer::getOptionsCount | ( | ) | const |
|
inlinevirtual |
Implements pcpp::Layer.
|
inline |
|
inline |
|
inlinevirtual |
Does nothing for this layer (DhcpLayer is always last)
Implements pcpp::Layer.
bool pcpp::DhcpLayer::removeAllOptions | ( | ) |
Remove all DHCP options in this layer
bool pcpp::DhcpLayer::removeOption | ( | DhcpOptionTypes | optionType | ) |
Remove an existing DHCP option from the layer
[in] | optionType | The DHCP option type to remove |
void pcpp::DhcpLayer::setClientHardwareAddress | ( | const MacAddress & | addr | ) |
Set a MAC address into the first 6 bytes of dhcp_header::clientHardwareAddress. This method also sets dhcp_header::hardwareType to 1 (Ethernet) and dhcp_header::hardwareAddressLength to 6 (MAC address length)
[in] | addr | The MAC address to set |
|
inline |
Set the client IPv4 address in dhcp_header::clientIpAddress
[in] | addr | The IPv4 address to set |
|
inline |
Set the gateway IPv4 address in dhcp_header::gatewayIpAddress
[in] | addr | The IPv4 address to set |
bool pcpp::DhcpLayer::setMesageType | ( | DhcpMessageType | msgType | ) |
Set DHCP message type. This method searches for existing DHCPOPT_DHCP_MESSAGE_TYPE option. If found, it sets the requested message type as its value. If not, it creates a DHCPOPT_DHCP_MESSAGE_TYPE option and sets the requested message type as its value
[in] | msgType | Message type to set |
|
inline |
Set the server IPv4 address in dhcp_header::serverIpAddress
[in] | addr | The IPv4 address to set |
|
inline |
Set your IPv4 address in dhcp_header::yourIpAddress
[in] | addr | The IPv4 address to set |
|
virtual |
Implements pcpp::Layer.