aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/vrrp/vrrp_packet.h
blob: d5725b6a1a5fb412528e94be55e87a4d5f1a23d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * 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);
}

/* Fields from VRRP advertisement packets needed by main thread */
typedef struct vrrp_input_process_args
{
  u32 vr_index;
  ip46_address_t src_addr;
  u8 priority;
  u8 max_adv_int;
} vrrp_input_process_args_t;

#endif /* __included_vrrp_packet_h__ */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */