67 #if (BYTE_ORDER == LITTLE_ENDIAN)
101 static_assert(
sizeof(
vrrp_header) == 8,
"vrrp_header size is not 8 bytes");
110 bool addIPAddressesAt(
const std::vector<IPAddress>& ipAddresses,
int offset);
112 uint8_t getIPAddressLen()
const;
114 bool isIPAddressValid(
IPAddress& ipAddress)
const;
116 uint8_t* getFirstIPAddressPtr()
const;
118 uint8_t* getNextIPAddressPtr(uint8_t* ipAddressPtr)
const;
120 IPAddress getIPAddressFromData(uint8_t* data)
const;
122 void copyIPAddressToData(uint8_t* data,
const IPAddress& ipAddress)
const;
129 :
Layer(data, dataLen, prevLayer, packet, vrrpVer), m_AddressType(addressType)
143 virtual void serializeVrrpLayer(
ObjectScope& serializer)
const = 0;
277 static std::vector<FieldDescriptor>
all()
281 std::copy(extra.begin(), extra.end(), std::back_inserter(result));
318 struct vrrpv2_auth_adv
354 explicit VrrpV2Layer(uint8_t virtualRouterId, uint8_t priority, uint8_t advInt, uint8_t authType = 0);
388 return canReinterpretAs<vrrp_header>(data, dataLen);
397 static std::vector<FieldDescriptor>
all()
401 std::copy(extra.begin(), extra.end(), std::back_inserter(result));
414 void serializeVrrpLayer(
ObjectScope& serializer)
const override;
423 struct vrrpv3_rsvd_adv
469 return canReinterpretAs<vrrp_header>(data, dataLen);
478 static std::vector<FieldDescriptor>
all()
481 std::initializer_list<FieldDescriptor> extra{
MaxAdvInt };
482 std::copy(extra.begin(), extra.end(), std::back_inserter(result));
491 void serializeVrrpLayer(
ObjectScope& serializer)
const override;
Definition: IpAddress.h:318
AddressType
An enum representing the address type: IPv4 or IPv6.
Definition: IpAddress.h:322
Definition: Serializers.h:230
Definition: VrrpLayer.h:108
bool isChecksumCorrect() const
void setVirtualRouterID(uint8_t virtualRouterID)
virtual uint16_t calculateChecksum() const =0
static ProtocolType getVersionFromData(uint8_t *data, size_t dataLen)
size_t getHeaderLen() const override
Definition: VrrpLayer.h:259
uint8_t getPriority() const
bool addIPAddresses(const std::vector< IPAddress > &ipAddresses)
IPAddress::AddressType getAddressType() const
void parseNextLayer() override
Does nothing for this layer (VRRP layer is always last)
Definition: VrrpLayer.h:251
std::string toString() const override
void calculateAndSetChecksum()
Fill the checksum from header and data and write the result to vrrp_header::checksum.
uint8_t getIPAddressesCount() const
VrrpPriority getPriorityAsEnum() const
VrrpType
VRRP message types.
Definition: VrrpLayer.h:148
@ VrrpType_Unknown
Unknown VRRP message.
Definition: VrrpLayer.h:150
@ VrrpType_Advertisement
VRRP advertisement message.
Definition: VrrpLayer.h:153
void computeCalculateFields() override
Calculate the VRRP checksum.
uint8_t getVersion() const
bool removeIPAddressAtIndex(int index)
uint8_t getVirtualRouterID() const
void setPriority(uint8_t priority)
OsiModelLayer getOsiModelLayer() const override
Definition: VrrpLayer.h:266
uint16_t getChecksum() const
std::vector< IPAddress > getIPAddresses() const
bool removeAllIPAddresses()
VrrpPriority
An enum describing VRRP special priority values.
Definition: VrrpLayer.h:158
@ Other
Other priority.
Definition: VrrpLayer.h:166
@ Stop
Current Master has stopped participating in VRRP (value of 0)
Definition: VrrpLayer.h:162
@ Default
Default priority for a backup VRRP router (value of 100)
Definition: VrrpLayer.h:160
@ Owner
This VRRP router owns the virtual router's IP address(es) (value of 255)
Definition: VrrpLayer.h:164
void serializeLayer(ObjectScope &serializer) const override
bool addIPAddress(const IPAddress &ipAddress)
Definition: VrrpLayer.h:316
VrrpAuthType
VRRP v2 authentication types.
Definition: VrrpLayer.h:327
@ Other
Other/Unknown Authentication Type.
@ MD5
Cisco VRRP MD5 Authentication.
@ IPAuthenticationHeader
IP Authentication Header.
@ NoAuthentication
No Authentication.
@ SimpleTextPassword
Simple Text Password.
uint8_t getAdvInt() const
~VrrpV2Layer() override=default
A destructor for this layer (does nothing)
VrrpAuthType getAuthTypeAsEnum() const
VrrpV2Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet)
Definition: VrrpLayer.h:345
static bool isDataValid(uint8_t const *data, size_t dataLen)
Definition: VrrpLayer.h:386
uint16_t calculateChecksum() const override
void setAdvInt(uint8_t advInt)
uint8_t getAuthType() const
void setAuthType(uint8_t authType)
VrrpV2Layer(uint8_t virtualRouterId, uint8_t priority, uint8_t advInt, uint8_t authType=0)
Definition: VrrpLayer.h:421
uint16_t calculateChecksum() const override
~VrrpV3Layer() override=default
A destructor for this layer (does nothing)
void setMaxAdvInt(uint16_t maxAdvInt)
static bool isDataValid(uint8_t const *data, size_t dataLen)
Definition: VrrpLayer.h:467
VrrpV3Layer(uint8_t *data, size_t dataLen, Layer *prevLayer, Packet *packet, IPAddress::AddressType addressType)
Definition: VrrpLayer.h:435
VrrpV3Layer(IPAddress::AddressType addressType, uint8_t virtualRouterId, uint8_t priority, uint16_t maxAdvInt)
uint16_t getMaxAdvInt() const
const ProtocolType VRRPv3
VRRP version 3 protocol.
Definition: ProtocolType.h:219
uint8_t ProtocolType
Definition: ProtocolType.h:38
const ProtocolType VRRPv2
VRRP version 2 protocol.
Definition: ProtocolType.h:216
The main namespace for the PcapPlusPlus lib.
Definition: AssertionUtils.h:19
OsiModelLayer
An enum representing OSI model layers.
Definition: ProtocolType.h:425
@ OsiModelNetworkLayer
Network layer (layer 3)
Definition: ProtocolType.h:431
Definition: Serializers.h:18
static std::vector< FieldDescriptor > all()
Definition: Layer.h:214
static constexpr uint16_t MaxID
Maximum field ID used by the layer.
Definition: Layer.h:229
Definition: VrrpLayer.h:275
static constexpr uint16_t MaxID
Maximum field ID used by the layer.
Definition: VrrpLayer.h:308
static const FieldDescriptor Checksum
Field descriptor for the VRRP checksum, written as a hex value.
Definition: VrrpLayer.h:299
static const FieldDescriptor Priority
Field descriptor for the priority category, written as a string: "Default", "Stop",...
Definition: VrrpLayer.h:293
static std::vector< FieldDescriptor > all()
Definition: VrrpLayer.h:277
static const FieldDescriptor IPAddresses
Field descriptor for the array of virtual router IP addresses.
Definition: VrrpLayer.h:302
static const FieldDescriptor PriorityValue
Field descriptor for the raw priority value, written as a number.
Definition: VrrpLayer.h:296
static const FieldDescriptor VirtualRouterID
Field descriptor for the virtual router ID (VRID), written as a number.
Definition: VrrpLayer.h:289
static const FieldDescriptor IPAddress
Field descriptor for a single entry of the IPAddresses array, written as an IP address string.
Definition: VrrpLayer.h:305
static const FieldDescriptor Type
Field descriptor for the VRRP message type, written as a string.
Definition: VrrpLayer.h:286
Definition: VrrpLayer.h:395
static std::vector< FieldDescriptor > all()
Definition: VrrpLayer.h:397
static const FieldDescriptor AuthType
Field descriptor for the authentication type, written as a string (see VrrpV2Layer::VrrpAuthType).
Definition: VrrpLayer.h:410
static const FieldDescriptor AdvInt
Field descriptor for the advertisement interval (in seconds), written as a number.
Definition: VrrpLayer.h:406
Definition: VrrpLayer.h:476
static std::vector< FieldDescriptor > all()
Definition: VrrpLayer.h:478
static const FieldDescriptor MaxAdvInt
Field descriptor for the maximum advertisement interval (in centiseconds), written as a number.
Definition: VrrpLayer.h:487