]>
git.proxmox.com Git - mirror_frr.git/blob - vrrpd/vrrp.h
2 * VRRPD global definitions and state machine
3 * Copyright (C) 2018 Cumulus Networks, Inc.
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #include "lib/linklist.h"
29 #include "lib/privs.h"
30 #include "lib/thread.h"
32 /* Global definitions */
33 #define VRRP_DEFAULT_ADVINT 100
34 #define VRRP_DEFAULT_PRIORITY 100
35 #define VRRP_PRIO_MASTER 255
36 #define VRRP_MCAST_GROUP "224.0.0.18"
37 #define VRRP_MCAST_GROUP_HEX 0xe0000012
38 #define IPPROTO_VRRP 112
41 extern struct thread_master
*master
;
44 extern struct zebra_privs_t vrrp_privs
;
46 /* Global hash of all Virtual Routers */
47 struct hash
*vrrp_vrouters_hash
;
57 struct interface
*ifp
;
59 /* Virtual Router Identifier */
62 /* One or more IPv4 addresses associated with this Virtual Router. */
66 * One ore more IPv6 addresses associated with this Virtual Router. The
67 * first address must be the Link-Local address associated with the
72 /* Whether this VRRP Router is currently the master */
79 * Time interval between ADVERTISEMENTS (centiseconds). Default is 100
80 * centiseconds (1 second).
82 uint16_t advertisement_interval
;
84 * Advertisement interval contained in ADVERTISEMENTS received from the
85 * Master (centiseconds)
87 uint16_t master_adver_interval
;
90 * Time to skew Master_Down_Interval in centiseconds. Calculated as:
91 * (((256 - priority) * Master_Adver_Interval) / 256)
96 * Time interval for Backup to declare Master down (centiseconds).
98 * (3 * Master_Adver_Interval) + Skew_time
100 uint16_t master_down_interval
;
103 * Controls whether a (starting or restarting) higher-priority Backup
104 * router preempts a lower-priority Master router. Values are True to
105 * allow preemption and False to prohibit preemption. Default is True.
110 * Controls whether a virtual router in Master state will accept
111 * packets addressed to the address owner's IPvX address as its own if
112 * it is not the IPvX address owner. The default is False.
117 * The MAC address used for the source MAC address in VRRP
118 * advertisements and advertised in ARP responses as the MAC address to
119 * use for IP_Addresses.
121 struct ethaddr vr_mac_v4
;
122 struct ethaddr vr_mac_v6
;
124 struct thread
*t_master_down_timer
;
125 struct thread
*t_adver_timer
;
133 * Initialize VRRP global datastructures.
135 void vrrp_init(void);
138 /* Creation and destruction ------------------------------------------------ */
141 * Create and register a new VRRP Virtual Router.
144 * Base interface to configure VRRP on
147 * Virtual Router Identifier
149 struct vrrp_vrouter
*vrrp_vrouter_create(struct interface
*ifp
, uint8_t vrid
);
152 * Destroy a VRRP Virtual Router.
154 void vrrp_vrouter_destroy(struct vrrp_vrouter
*vr
);
157 /* Configuration controllers ----------------------------------------------- */
160 * Change the priority of a VRRP Virtual Router.
162 * Also recalculates timers using new priority.
165 * Virtual Router to change priority of
170 void vrrp_set_priority(struct vrrp_vrouter
*vr
, uint8_t priority
);
173 * Set Advertisement Interval on this Virtual Router.
176 * Virtual Router to change priority of
178 * advertisement_interval
179 * New advertisement interval
181 void vrrp_set_advertisement_interval(struct vrrp_vrouter
*vr
,
182 uint16_t advertisement_interval
);
185 * Add IPv4 address to a VRRP Virtual Router.
188 * Virtual Router to add IPv4 address to
193 void vrrp_add_ip(struct vrrp_vrouter
*vr
, struct in_addr v4
);
196 /* State machine ----------------------------------------------------------- */
198 #define VRRP_STATE_INITIALIZE 1
199 #define VRRP_STATE_MASTER 2
200 #define VRRP_STATE_BACKUP 3
201 #define VRRP_EVENT_STARTUP 1
202 #define VRRP_EVENT_SHUTDOWN 2
205 * This hook called whenever the state of a Virtual Router changes, after the
206 * specific internal state handlers have run.
208 * Use this if you need to react to state changes to perform non-critical
209 * tasks. Critical tasks should go in the internal state change handlers.
211 DECLARE_HOOK(vrrp_change_state_hook
, (struct vrrp_vrouter
*vr
, int to
), (vr
, to
));
214 * Trigger a VRRP event on a given Virtual Router..
217 * Virtual Router to operate on
220 * Event to kick off. All event related processing will have completed upon
221 * return of this function.
224 * < 0 if the event created an error
227 int vrrp_event(struct vrrp_vrouter
*vr
, int event
);
230 /* Other ------------------------------------------------------------------- */
233 * Find VRRP Virtual Router by Virtual Router ID
235 struct vrrp_vrouter
*vrrp_lookup(uint8_t vrid
);