|
PcapPlusPlus
Next
|
#include <DhcpLayer.h>
Public Member Functions | |
| DhcpLayer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet) | |
| DhcpLayer (DhcpMessageType msgType, const MacAddress &clientMacAddr) | |
| DhcpLayer () | |
| A constructor that creates the layer from scratch with clean data. | |
| ~DhcpLayer () override=default | |
| A destructor for this layer. | |
| dhcp_header * | getDhcpHeader () const |
| BootpOpCodes | getOpCode () const |
| IPv4Address | getClientIpAddress () const |
| void | setClientIpAddress (const IPv4Address &addr) |
| IPv4Address | getServerIpAddress () const |
| void | setServerIpAddress (const IPv4Address &addr) |
| IPv4Address | getYourIpAddress () const |
| void | setYourIpAddress (const IPv4Address &addr) |
| IPv4Address | getGatewayIpAddress () const |
| void | setGatewayIpAddress (const IPv4Address &addr) |
| MacAddress | getClientHardwareAddress () const |
| void | setClientHardwareAddress (const MacAddress &addr) |
| DhcpMessageType | getMessageType () const |
| bool | setMessageType (DhcpMessageType msgType) |
| DhcpOption | getFirstOptionData () const |
| DhcpOption | getNextOptionData (DhcpOption dhcpOption) const |
| DhcpOption | getOptionData (DhcpOptionTypes option) const |
| size_t | getOptionsCount () const |
| DhcpOption | addOption (const DhcpOptionBuilder &optionBuilder) |
| DhcpOption | addOptionAfter (const DhcpOptionBuilder &optionBuilder, DhcpOptionTypes prevOption) |
| bool | removeOption (DhcpOptionTypes optionType) |
| bool | removeAllOptions () |
| void | parseNextLayer () override |
| Does nothing for this layer (DhcpLayer is always last) | |
| size_t | getHeaderLen () const override |
| void | computeCalculateFields () override |
| std::string | toString () const override |
| OsiModelLayer | getOsiModelLayer () const override |
Public Member Functions inherited from pcpp::Layer | |
| ~Layer () override | |
| Layer * | getNextLayer () const |
| Layer * | getPrevLayer () const |
| ProtocolType | getProtocol () const |
| bool | isMemberOfProtocolFamily (ProtocolTypeFamily protocolTypeFamily) const |
| uint8_t * | getData () const |
| size_t | getDataLen () const |
| uint8_t * | getLayerPayload () const |
| size_t | getLayerPayloadSize () const |
| bool | isAllocatedToPacket () const |
| void | copyData (uint8_t *toArr) const |
| uint8_t * | getDataPtr (size_t offset=0) const override |
Static Public Member Functions | |
| static bool | isDhcpPorts (uint16_t portSrc, uint16_t portDst) |
Additional Inherited Members | |
Protected Member Functions inherited from pcpp::Layer | |
| template<typename T , typename... Args> | |
| Layer * | constructNextLayer (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
| template<typename T , typename TFallback , typename... Args> | |
| Layer * | tryConstructNextLayerWithFallback (uint8_t *data, size_t dataLen, Packet *packet, Args &&... extraArgs) |
Static Protected Member Functions inherited from pcpp::Layer | |
| template<typename T > | |
| static bool | canReinterpretAs (const uint8_t *data, size_t dataLen) |
| Check if the data is large enough to reinterpret as a type. More... | |
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 |
| 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 |
|
overridevirtual |
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 |
|
inlineoverridevirtual |
Implements pcpp::Layer.
| DhcpMessageType pcpp::DhcpLayer::getMessageType | ( | ) | 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 |
|
inlineoverridevirtual |
Implements pcpp::Layer.
|
inline |
|
inline |
|
inlinestatic |
A static method that checks whether a pair of ports are considered DHCP ports
| [in] | portSrc | The source port number to check |
| [in] | portDst | The destination port number to check |
| 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::setMessageType | ( | 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 |
|
overridevirtual |
Implements pcpp::Layer.