summaryrefslogtreecommitdiffstats
path: root/src/plugins/vrrp/vrrp_packet.h
diff options
context:
space:
mode:
authorMatthew Smith <mgsmith@netgate.com>2020-02-11 11:25:32 -0600
committerDave Barach <openvpp@barachs.net>2020-02-13 19:46:30 +0000
commit39e9428b90bc74d1bb15fc17759c8ef6ad712418 (patch)
treede9317a906a7df43bf2140a654d3b7675cab8d86 /src/plugins/vrrp/vrrp_packet.h
parentf75defa7676759fa81ae75e7edd492572c6b8fd6 (diff)
vrrp: add plugin providing vrrp support
Type: feature Add a new plugin to support HA using VRRPv3 (RFC 5798). Change-Id: Iaa2c37e6172f8f41e9165f178f44d481f6e247b9 Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src/plugins/vrrp/vrrp_packet.h')
-rw-r--r--src/plugins/vrrp/vrrp_packet.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/plugins/vrrp/vrrp_packet.h b/src/plugins/vrrp/vrrp_packet.h
new file mode 100644
index 00000000000..1cbf62d7c72
--- /dev/null
+++ b/src/plugins/vrrp/vrrp_packet.h
@@ -0,0 +1,58 @@
+
+/*
+ * vrrp_packet.h - vrrp protocol/packet definitions
+ *
+ * Copyright 2019-2020 Rubicon Communications, LLC (Netgate)
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ */
+#ifndef __included_vrrp_packet_h__
+#define __included_vrrp_packet_h__
+
+#include <vnet/vnet.h>
+
+typedef CLIB_PACKED (struct
+ {
+ /* 4 bits for version (always 2 or 3), 4 bits for type (always 1) */
+ u8 vrrp_version_and_type;
+ /* VR ID */
+ u8 vr_id;
+ /* priority of sender on this VR. value of 0 means a master is abdicating */
+ u8 priority;
+ /* count of addresses being backed up by the VR */
+ u8 n_addrs;
+ /* max advertisement interval - first 4 bits are reserved and must be 0 */
+ u16 rsvd_and_max_adv_int;
+ /* checksum */
+ u16 checksum;
+ }) vrrp_header_t;
+
+typedef CLIB_PACKED (struct
+ {
+ ip4_header_t ip4; vrrp_header_t vrrp;
+ }) ip4_and_vrrp_header_t;
+
+typedef CLIB_PACKED (struct
+ {
+ ip6_header_t ip6; vrrp_header_t vrrp;
+ }) ip6_and_vrrp_header_t;
+
+/* the high 4 bits of the advertisement interval are "reserved" and
+ * should be ignored on reception. swap byte order and mask out those bits.
+ */
+always_inline u16
+vrrp_adv_int_from_packet (vrrp_header_t * pkt)
+{
+ return clib_net_to_host_u16 (pkt->rsvd_and_max_adv_int) & ((u16) 0x0fff);
+}
+
+#endif /* __included_vrrp_packet_h__ */
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */