PcapPlusPlus
|
#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
DhcpOptionData* pcpp::DhcpLayer::addOption | ( | DhcpOptionTypes | optionType, |
uint16_t | optionLen, | ||
const uint8_t * | optionData | ||
) |
Add a new DHCP option at the end of the layer (but before the DHCPOPT_END option if exists)
[in] | optionType | The type of the newly added option |
[in] | optionLen | The length of the option data |
[in] | optionData | A pointer to the option data. This data will be copied to newly added option data. Notice the length of optionData must be optionLen |
DhcpOptionData* pcpp::DhcpLayer::addOptionAfter | ( | DhcpOptionTypes | optionType, |
uint16_t | optionLen, | ||
const uint8_t * | optionData, | ||
DhcpOptionTypes | prevOption | ||
) |
Add a new DHCP option after an existing option
[in] | optionType | The type of the newly added option |
[in] | optionLen | The length of the option data |
[in] | optionData | A pointer to the option data. This data will be copied to added option data. Notice the length of optionData must be optionLength |
[in] | prevOption | The DHCP option which the newly added tag will come after. If set to DHCPOPT_UNKNOWN DHCP option will be added as the first DHCP option |
|
virtual |
Calculate the following fields:
Implements pcpp::Layer.
MacAddress pcpp::DhcpLayer::getClientHardwareAddress | ( | ) |
IPv4Address pcpp::DhcpLayer::getClientIpAddress | ( | ) |
|
inline |
Get a pointer to the DHCP header. Notice this points directly to the data, so every change will change the actual packet data
DhcpOptionData* pcpp::DhcpLayer::getFirstOptionData | ( | ) |
IPv4Address pcpp::DhcpLayer::getGatewayIpAddress | ( | ) |
|
virtual |
Implements pcpp::Layer.
DhcpMessageType pcpp::DhcpLayer::getMesageType | ( | ) |
DhcpOptionData* pcpp::DhcpLayer::getNextOptionData | ( | DhcpOptionData * | dhcpOption | ) |
Get the DHCP option that comes next to "dhcpOption" option. If "dhcpOption" is NULL then NULL will be returned. If "dhcpOption" is the last DHCP option NULL will be returned. Notice the return value is a pointer to the real data casted to DhcpOptionData type (as opposed to a copy of the option data). So changes in the return value will affect the packet data
[in] | dhcpOption | The DHCP option to start searching from |
|
inline |
DhcpOptionData* pcpp::DhcpLayer::getOptionData | ( | DhcpOptionTypes | option | ) |
Search for a DHCP option by type. Notice the return value points directly to the data, so every change will change the actual packet data
[in] | option | The DHCP option type to search |
size_t pcpp::DhcpLayer::getOptionsCount | ( | ) |
|
inlinevirtual |
Implements pcpp::Layer.
IPv4Address pcpp::DhcpLayer::getServerIpAddress | ( | ) |
IPv4Address pcpp::DhcpLayer::getYourIpAddress | ( | ) |
|
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 |
void pcpp::DhcpLayer::setClientIpAddress | ( | const IPv4Address & | addr | ) |
Set the client IPv4 address in dhcp_header::clientIpAddress
[in] | addr | The IPv4 address to set |
void pcpp::DhcpLayer::setGatewayIpAddress | ( | const IPv4Address & | addr | ) |
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 |
void pcpp::DhcpLayer::setServerIpAddress | ( | const IPv4Address & | addr | ) |
Set the server IPv4 address in dhcp_header::serverIpAddress
[in] | addr | The IPv4 address to set |
void pcpp::DhcpLayer::setYourIpAddress | ( | const IPv4Address & | addr | ) |
Set your IPv4 address in dhcp_header::yourIpAddress
[in] | addr | The IPv4 address to set |
|
virtual |
Implements pcpp::Layer.