PcapPlusPlus  21.05+
pcpp::DhcpV6Layer Class Reference

#include <DhcpV6Layer.h>

Inheritance diagram for pcpp::DhcpV6Layer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 DhcpV6Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 DhcpV6Layer (DhcpV6MessageType messageType, uint32_t transactionId)
 
DhcpV6MessageType getMessageType () const
 
std::string getMessageTypeAsString () const
 
void setMessageType (DhcpV6MessageType messageType)
 
uint32_t getTransactionID () const
 
void setTransactionID (uint32_t transactionId) const
 
DhcpV6Option getFirstOptionData () const
 
DhcpV6Option getNextOptionData (DhcpV6Option dhcpv6Option) const
 
DhcpV6Option getOptionData (DhcpV6OptionType option) const
 
size_t getOptionCount () const
 
DhcpV6Option addOption (const DhcpV6OptionBuilder &optionBuilder)
 
DhcpV6Option addOptionAfter (const DhcpV6OptionBuilder &optionBuilder, DhcpV6OptionType optionType)
 
DhcpV6Option addOptionBefore (const DhcpV6OptionBuilder &optionBuilder, DhcpV6OptionType optionType)
 
bool removeOption (DhcpV6OptionType optionType)
 
bool removeAllOptions ()
 
void parseNextLayer ()
 
size_t getHeaderLen () const
 
void computeCalculateFields ()
 
std::string toString () const
 
OsiModelLayer getOsiModelLayer () const
 
- Public Member Functions inherited from pcpp::Layer
virtual ~Layer ()
 
LayergetNextLayer () const
 
LayergetPrevLayer () const
 
ProtocolType getProtocol () 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
 

Static Public Member Functions

static bool isDhcpV6Port (uint16_t port)
 
static bool isDataValid (const uint8_t *data, size_t dataLen)
 

Detailed Description

Represents a DHCPv6 (Dynamic Host Configuration Protocol version 6) protocol layer

Constructor & Destructor Documentation

◆ DhcpV6Layer() [1/2]

pcpp::DhcpV6Layer::DhcpV6Layer ( uint8_t *  data,
size_t  dataLen,
Layer prevLayer,
Packet packet 
)

A constructor that creates the layer from an existing packet raw data

Parameters
[in]dataA pointer to the raw data
[in]dataLenSize of the data in bytes
[in]prevLayerA pointer to the previous layer
[in]packetA pointer to the Packet instance where layer will be stored in

◆ DhcpV6Layer() [2/2]

pcpp::DhcpV6Layer::DhcpV6Layer ( DhcpV6MessageType  messageType,
uint32_t  transactionId 
)

A constructor that creates the layer from scratch

Parameters
[in]messageTypeA DHCPv6 message type to be set
[in]transactionIdThe transaction ID to be set. Notice the transaction ID is 3-byte long so the value shouldn't exceed 0xFFFFFF

Member Function Documentation

◆ addOption()

DhcpV6Option pcpp::DhcpV6Layer::addOption ( const DhcpV6OptionBuilder optionBuilder)

Add a new DHCPv6 option at the end of the layer

Parameters
[in]optionBuilderA DhcpV6OptionBuilder object that contains the requested DHCPv6 option data to add
Returns
A DhcpV6Option object containing the newly added DHCP option data or logical NULL (DhcpV6Option::isNull() == true) if addition failed

◆ addOptionAfter()

DhcpV6Option pcpp::DhcpV6Layer::addOptionAfter ( const DhcpV6OptionBuilder optionBuilder,
DhcpV6OptionType  optionType 
)

Add a new DHCPv6 option after an existing one

Parameters
[in]optionBuilderA DhcpV6OptionBuilder object that contains the requested DHCPv6 option data to add
[in]optionTypeThe DHCPv6 option type which the newly added option will come after
Returns
A DhcpV6Option object containing the newly added DHCPv6 option data or logical NULL (DhcpV6Option::isNull() == true) if addition failed

◆ addOptionBefore()

DhcpV6Option pcpp::DhcpV6Layer::addOptionBefore ( const DhcpV6OptionBuilder optionBuilder,
DhcpV6OptionType  optionType 
)

Add a new DHCPv6 option before an existing one

Parameters
[in]optionBuilderA DhcpV6OptionBuilder object that contains the requested DHCPv6 option data to add
[in]optionTypeThe DHCPv6 option type which the newly added option will come before
Returns
A DhcpV6Option object containing the newly added DHCPv6 option data or logical NULL (DhcpV6Option::isNull() == true) if addition failed

◆ computeCalculateFields()

void pcpp::DhcpV6Layer::computeCalculateFields ( )
inlinevirtual

Does nothing for this layer

Implements pcpp::Layer.

◆ getFirstOptionData()

DhcpV6Option pcpp::DhcpV6Layer::getFirstOptionData ( ) const
Returns
The first DHCPv6 option in the packet. If there are no DHCPv6 options the returned value will contain a logical NULL (DhcpV6Option::isNull() == true)

◆ getHeaderLen()

size_t pcpp::DhcpV6Layer::getHeaderLen ( ) const
inlinevirtual
Returns
The size of dhcpv6_header + size of options

Implements pcpp::Layer.

◆ getMessageType()

DhcpV6MessageType pcpp::DhcpV6Layer::getMessageType ( ) const
Returns
The message type of this DHCPv6 message

◆ getMessageTypeAsString()

std::string pcpp::DhcpV6Layer::getMessageTypeAsString ( ) const
Returns
The string value of the message type of this DHCPv6 message

◆ getNextOptionData()

DhcpV6Option pcpp::DhcpV6Layer::getNextOptionData ( DhcpV6Option  dhcpv6Option) const

Get the DHCPv6 option that comes after a given option. If the given option was the last one, the returned value will contain a logical NULL (DhcpV6Option::isNull() == true)

Parameters
[in]dhcpv6OptionA given DHCPv6 option
Returns
A DhcpV6Option object containing the option data that comes next, or logical NULL if the given DHCPv6 option: (1) was the last one; (2) contains a logical NULL or (3) doesn't belong to this packet

◆ getOptionCount()

size_t pcpp::DhcpV6Layer::getOptionCount ( ) const
Returns
The number of DHCPv6 options in this layer

◆ getOptionData()

DhcpV6Option pcpp::DhcpV6Layer::getOptionData ( DhcpV6OptionType  option) const

Get a DHCPv6 option by type

Parameters
[in]optionDHCPv6 option type
Returns
A DhcpV6OptionType object containing the first DHCP option data that matches this type, or logical NULL (DhcpV6Option::isNull() == true) if no such option found

◆ getOsiModelLayer()

OsiModelLayer pcpp::DhcpV6Layer::getOsiModelLayer ( ) const
inlinevirtual
Returns
The OSI Model layer this protocol belongs to

Implements pcpp::Layer.

◆ getTransactionID()

uint32_t pcpp::DhcpV6Layer::getTransactionID ( ) const
Returns
The transaction ID of this DHCPv6 message

◆ isDataValid()

bool pcpp::DhcpV6Layer::isDataValid ( const uint8_t *  data,
size_t  dataLen 
)
inlinestatic

A static method that validates the input data

Parameters
[in]dataThe pointer to the beginning of a byte stream of an DHCPv6 layer
[in]dataLenThe length of the byte stream
Returns
True if the data is valid and can represent an DHCPv6 layer

◆ isDhcpV6Port()

bool pcpp::DhcpV6Layer::isDhcpV6Port ( uint16_t  port)
inlinestatic

A static method that checks whether a port is considered as a DHCPv6 port

Parameters
[in]portThe port number to check
Returns
True if this is a DHCPv6 port number, false otherwise

◆ parseNextLayer()

void pcpp::DhcpV6Layer::parseNextLayer ( )
inlinevirtual

Does nothing for this layer (DhcpV6Layer is always last)

Implements pcpp::Layer.

◆ removeAllOptions()

bool pcpp::DhcpV6Layer::removeAllOptions ( )

Remove all DHCPv6 options in this layer

Returns
True if all DHCPv6 options were successfully removed or false if removal failed for some reason

◆ removeOption()

bool pcpp::DhcpV6Layer::removeOption ( DhcpV6OptionType  optionType)

Remove an existing DHCPv6 option from the layer

Parameters
[in]optionTypeThe DHCPv6 option type to remove
Returns
True if DHCPv6 option was successfully removed or false if type wasn't found or if removal failed

◆ setMessageType()

void pcpp::DhcpV6Layer::setMessageType ( DhcpV6MessageType  messageType)

Set the message type for this layer

Parameters
[in]messageTypeThe message type to set
Returns
No return value

◆ setTransactionID()

void pcpp::DhcpV6Layer::setTransactionID ( uint32_t  transactionId) const

Set the transaction ID for this DHCPv6 message

Parameters
[in]transactionIdThe transaction ID value to set
Returns
No return value

◆ toString()

std::string pcpp::DhcpV6Layer::toString ( ) const
virtual
Returns
A string representation of the layer most important data (should look like the layer description in Wireshark)

Implements pcpp::Layer.