PcapPlusPlus  19.12
pcpp::IPv6Layer Class Reference

#include <IPv6Layer.h>

Inheritance diagram for pcpp::IPv6Layer:
pcpp::Layer pcpp::IDataContainer

Public Member Functions

 IPv6Layer (uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
 
 IPv6Layer ()
 
 IPv6Layer (const IPv6Address &srcIP, const IPv6Address &dstIP)
 
 IPv6Layer (const IPv6Layer &other)
 
 ~IPv6Layer ()
 
IPv6Layeroperator= (const IPv6Layer &other)
 
ip6_hdrgetIPv6Header () const
 
IPv6Address getSrcIpAddress () const
 
IPv6Address getDstIpAddress () const
 
size_t getExtensionCount () const
 
template<class TIPv6Extension >
TIPv6Extension * getExtensionOfType () const
 
template<class TIPv6Extension >
TIPv6Extension * addExtension (const TIPv6Extension &extensionHeader)
 
void removeAllExtensions ()
 
bool isFragment () const
 
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
 

Detailed Description

Represents an IPv6 protocol layer

Constructor & Destructor Documentation

◆ IPv6Layer() [1/4]

pcpp::IPv6Layer::IPv6Layer ( 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 (will be casted to ip6_hdr)
[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

◆ IPv6Layer() [2/4]

pcpp::IPv6Layer::IPv6Layer ( )

A constructor that allocates a new IPv6 header with empty fields

◆ IPv6Layer() [3/4]

pcpp::IPv6Layer::IPv6Layer ( const IPv6Address srcIP,
const IPv6Address dstIP 
)

A constructor that allocates a new IPv6 header with source and destination IPv6 addresses

Parameters
[in]srcIPSource IPv6 address
[in]dstIPDestination IPv6 address

◆ IPv6Layer() [4/4]

pcpp::IPv6Layer::IPv6Layer ( const IPv6Layer other)

A copy constructor that copies the entire header from the other IPv6Layer (including IPv6 extensions)

◆ ~IPv6Layer()

pcpp::IPv6Layer::~IPv6Layer ( )

A destrcutor for this layer

Member Function Documentation

◆ addExtension()

template<class TIPv6Extension >
TIPv6Extension * pcpp::IPv6Layer::addExtension ( const TIPv6Extension &  extensionHeader)

Add a new extension of type TIPv6Extension to the layer. This is a templated method and TIPv6Extension has to be one of the supported IPv6 extensions, meaning a class that inherits IPv6Extension. If the extension is added successfully a pointer to the newly added extension object is returned, otherwise NULL is returned

Parameters
[in]extensionHeaderThe extension object to add. Notice the object passed here is read-only, meaning its data is copied but the object itself isn't modified
Returns
If the extension is added successfully a pointer to the newly added extension object is returned. Otherwise NULL is returned

◆ computeCalculateFields()

void pcpp::IPv6Layer::computeCalculateFields ( )
virtual

Calculate the following fields:

Implements pcpp::Layer.

◆ getDstIpAddress()

IPv6Address pcpp::IPv6Layer::getDstIpAddress ( ) const
inline

Get the destination IP address in the form of IPv6Address

Returns
An IPv6Address containing the destination address

◆ getExtensionCount()

size_t pcpp::IPv6Layer::getExtensionCount ( ) const
Returns
Number of IPv6 extensions in this layer

◆ getExtensionOfType()

template<class TIPv6Extension >
TIPv6Extension * pcpp::IPv6Layer::getExtensionOfType ( ) const

A templated getter for an IPv6 extension of a type TIPv6Extension. TIPv6Extension has to be one of the supported IPv6 extensions, meaning a class that inherits IPv6Extension. If the requested extension type isn't found NULL is returned

Returns
A pointer to the extension instance or NULL if the requested extension type isn't found

◆ getHeaderLen()

size_t pcpp::IPv6Layer::getHeaderLen ( ) const
inlinevirtual
Returns
Size of ip6_hdr

Implements pcpp::Layer.

◆ getIPv6Header()

ip6_hdr* pcpp::IPv6Layer::getIPv6Header ( ) const
inline

Get a pointer to the IPv6 header. Notice this points directly to the data, so every change will change the actual packet data

Returns
A pointer to the ip6_hdr

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getSrcIpAddress()

IPv6Address pcpp::IPv6Layer::getSrcIpAddress ( ) const
inline

Get the source IP address in the form of IPv6Address

Returns
An IPv6Address containing the source address

◆ isFragment()

bool pcpp::IPv6Layer::isFragment ( ) const
Returns
True if this packet is an IPv6 fragment, meaning if it has an IPv6FragmentationHeader extension

◆ operator=()

IPv6Layer& pcpp::IPv6Layer::operator= ( const IPv6Layer other)

An assignment operator that first delete all data from current layer and then copy the entire header from the other IPv6Layer (including IPv6 extensions)

◆ parseNextLayer()

void pcpp::IPv6Layer::parseNextLayer ( )
virtual

Currently identifies the following next layers: UdpLayer, TcpLayer. Otherwise sets PayloadLayer

Implements pcpp::Layer.

◆ removeAllExtensions()

void pcpp::IPv6Layer::removeAllExtensions ( )

Remove all IPv6 extensions in this layer

◆ toString()

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

Implements pcpp::Layer.