PcapPlusPlus  23.09
pcpp::VrrpLayer Class Referenceabstract

#include <VrrpLayer.h>

Inheritance diagram for pcpp::VrrpLayer:
pcpp::Layer pcpp::IDataContainer pcpp::VrrpV2Layer pcpp::VrrpV3Layer

Public Types

enum  VrrpType { VrrpType_Unknown = 0, VrrpType_Advertisement = 1 }
 
enum  VrrpPriority { Default, Stop, Owner, Other }
 

Public Member Functions

IPAddress::AddressType getAddressType () const
 
uint8_t getVersion () const
 
VrrpType getType () const
 
uint8_t getVirtualRouterID () const
 
void setVirtualRouterID (uint8_t virtualRouterID)
 
uint8_t getPriority () const
 
VrrpPriority getPriorityAsEnum () const
 
void setPriority (uint8_t priority)
 
uint16_t getChecksum () const
 
void calculateAndSetChecksum ()
 
virtual uint16_t calculateChecksum () const =0
 
bool isChecksumCorrect () const
 
uint8_t getIPAddressesCount () const
 
std::vector< IPAddressgetIPAddresses () const
 
bool addIPAddresses (const std::vector< IPAddress > &ipAddresses)
 
bool addIPAddress (const IPAddress &ipAddress)
 
bool removeIPAddressAtIndex (int index)
 
bool removeAllIPAddresses ()
 
void parseNextLayer () override
 
void computeCalculateFields () override
 
size_t getHeaderLen () const override
 
std::string toString () const override
 
OsiModelLayer getOsiModelLayer () const override
 
- 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 ProtocolType getVersionFromData (uint8_t *data, size_t dataLen)
 

Detailed Description

A base class for all VRRP (Virtual Router Redundancy Protocol) protocol classes. This is an abstract class and cannot be instantiated, only its child classes can be instantiated. The inherited classes represent the different versions of the protocol: VRRPv2 and VRRPv3

Member Enumeration Documentation

◆ VrrpPriority

An enum describing VRRP special priority values

Enumerator
Default 

Default priority for a backup VRRP router (value of 100)

Stop 

Current Master has stopped participating in VRRP (value of 0)

Owner 

This VRRP router owns the virtual router's IP address(es) (value of 255)

Other 

Other priority

◆ VrrpType

VRRP message types

Enumerator
VrrpType_Unknown 

Unknown VRRP message

VrrpType_Advertisement 

VRRP advertisement message

Member Function Documentation

◆ addIPAddress()

bool pcpp::VrrpLayer::addIPAddress ( const IPAddress ipAddress)

Add a virtual IP address at a the end of the virtual IP address list. The vrrp_header::ipAddressCount field will be incremented accordingly

Parameters
[in]ipAddressVirtual IP address to add
Returns
true if add successfully, false otherwise

◆ addIPAddresses()

bool pcpp::VrrpLayer::addIPAddresses ( const std::vector< IPAddress > &  ipAddresses)

Add a list of virtual IP addresses at a the end of the virtual IP address list. The vrrp_header::ipAddressCount field will be incremented accordingly

Parameters
[in]ipAddressesA vector containing all the virtual IP address
Returns
true if added successfully, false otherwise

◆ calculateAndSetChecksum()

void pcpp::VrrpLayer::calculateAndSetChecksum ( )

Fill the checksum from header and data and write the result to vrrp_header::checksum

◆ calculateChecksum()

virtual uint16_t pcpp::VrrpLayer::calculateChecksum ( ) const
pure virtual

Calculate the checksum from header and data and write the result to vrrp_header::checksum

Returns
The checksum result

Implemented in pcpp::VrrpV3Layer, and pcpp::VrrpV2Layer.

◆ computeCalculateFields()

void pcpp::VrrpLayer::computeCalculateFields ( )
overridevirtual

Calculate the VRRP checksum

Implements pcpp::Layer.

◆ getAddressType()

IPAddress::AddressType pcpp::VrrpLayer::getAddressType ( ) const
Returns
The VRRP IP Address type

◆ getChecksum()

uint16_t pcpp::VrrpLayer::getChecksum ( ) const
Returns
VRRP checksum of this message

◆ getHeaderLen()

size_t pcpp::VrrpLayer::getHeaderLen ( ) const
inlineoverridevirtual
Returns
The message size in bytes which include the size of the basic header + the size of the IP address(es)

Implements pcpp::Layer.

◆ getIPAddresses()

std::vector<IPAddress> pcpp::VrrpLayer::getIPAddresses ( ) const
Returns
A list of the virtual IP addresses in this message

◆ getIPAddressesCount()

uint8_t pcpp::VrrpLayer::getIPAddressesCount ( ) const
Returns
The count of VRRP virtual IP addresses in this message

◆ getOsiModelLayer()

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

Implements pcpp::Layer.

◆ getPriority()

uint8_t pcpp::VrrpLayer::getPriority ( ) const
Returns
The priority in this message

◆ getPriorityAsEnum()

VrrpPriority pcpp::VrrpLayer::getPriorityAsEnum ( ) const
Returns
An enum describing VRRP priority

◆ getType()

VrrpType pcpp::VrrpLayer::getType ( ) const
Returns
VRRP type set in vrrp_header::type as VrrpLayer::VrrpType enum.

◆ getVersion()

uint8_t pcpp::VrrpLayer::getVersion ( ) const
Returns
VRRP version of this message

◆ getVersionFromData()

static ProtocolType pcpp::VrrpLayer::getVersionFromData ( uint8_t *  data,
size_t  dataLen 
)
static

A static method that validates the input data

Parameters
[in]dataVRRP raw data (byte stream)
[in]dataLenThe length of the byte stream
Returns
One of the values VRRPv2, VRRPv3 according to detected VRRP version or UnknownProtocol if couldn't detect VRRP version

◆ getVirtualRouterID()

uint8_t pcpp::VrrpLayer::getVirtualRouterID ( ) const
Returns
The virtual router id (vrId) in this message

◆ isChecksumCorrect()

bool pcpp::VrrpLayer::isChecksumCorrect ( ) const
Returns
True if VRRP checksum is correct

◆ parseNextLayer()

void pcpp::VrrpLayer::parseNextLayer ( )
inlineoverridevirtual

Does nothing for this layer (VRRP layer is always last)

Implements pcpp::Layer.

◆ removeAllIPAddresses()

bool pcpp::VrrpLayer::removeAllIPAddresses ( )

Remove all virtual IP addresses in the message. The vrrp_header::ipAddressCount field will be set to 0

Returns
True if virtual IP addresses were cleared successfully or false otherwise. If false is returned an appropriate error message will be printed to log

◆ removeIPAddressAtIndex()

bool pcpp::VrrpLayer::removeIPAddressAtIndex ( int  index)

Remove a virtual IP address at a certain index. The vrrp_header::ipAddressCount field will be decremented accordingly

Parameters
[in]indexThe index of the virtual IP address to be removed
Returns
True if virtual IP address was removed successfully or false otherwise. If false is returned an appropriate error message will be printed to log

◆ setPriority()

void pcpp::VrrpLayer::setPriority ( uint8_t  priority)

Set the priority

Parameters
prioritynew priority to set

◆ setVirtualRouterID()

void pcpp::VrrpLayer::setVirtualRouterID ( uint8_t  virtualRouterID)

Set the virtual router ID

Parameters
virtualRouterIDnew ID to set

◆ toString()

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

Implements pcpp::Layer.