1*1cb875aeSCathy Zhou /*
2*1cb875aeSCathy Zhou  * CDDL HEADER START
3*1cb875aeSCathy Zhou  *
4*1cb875aeSCathy Zhou  * The contents of this file are subject to the terms of the
5*1cb875aeSCathy Zhou  * Common Development and Distribution License (the "License").
6*1cb875aeSCathy Zhou  * You may not use this file except in compliance with the License.
7*1cb875aeSCathy Zhou  *
8*1cb875aeSCathy Zhou  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*1cb875aeSCathy Zhou  * or http://www.opensolaris.org/os/licensing.
10*1cb875aeSCathy Zhou  * See the License for the specific language governing permissions
11*1cb875aeSCathy Zhou  * and limitations under the License.
12*1cb875aeSCathy Zhou  *
13*1cb875aeSCathy Zhou  * When distributing Covered Code, include this CDDL HEADER in each
14*1cb875aeSCathy Zhou  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*1cb875aeSCathy Zhou  * If applicable, add the following below this CDDL HEADER, with the
16*1cb875aeSCathy Zhou  * fields enclosed by brackets "[]" replaced with your own identifying
17*1cb875aeSCathy Zhou  * information: Portions Copyright [yyyy] [name of copyright owner]
18*1cb875aeSCathy Zhou  *
19*1cb875aeSCathy Zhou  * CDDL HEADER END
20*1cb875aeSCathy Zhou  */
21*1cb875aeSCathy Zhou 
22*1cb875aeSCathy Zhou /*
23*1cb875aeSCathy Zhou  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24*1cb875aeSCathy Zhou  * Use is subject to license terms.
25*1cb875aeSCathy Zhou  */
26*1cb875aeSCathy Zhou 
27*1cb875aeSCathy Zhou #ifndef	_VRRP_H
28*1cb875aeSCathy Zhou #define	_VRRP_H
29*1cb875aeSCathy Zhou 
30*1cb875aeSCathy Zhou #include <stdint.h>
31*1cb875aeSCathy Zhou 
32*1cb875aeSCathy Zhou #ifdef __cplusplus
33*1cb875aeSCathy Zhou extern "C" {
34*1cb875aeSCathy Zhou #endif
35*1cb875aeSCathy Zhou 
36*1cb875aeSCathy Zhou typedef struct vrrp_pkt_s {
37*1cb875aeSCathy Zhou 	uint8_t		vp_vers_type;
38*1cb875aeSCathy Zhou 	uint8_t		vp_vrid;
39*1cb875aeSCathy Zhou 	uint8_t		vp_prio;
40*1cb875aeSCathy Zhou 	uint8_t		vp_ipnum;
41*1cb875aeSCathy Zhou 	uint16_t	vp_rsvd_adver_int;
42*1cb875aeSCathy Zhou 	uint16_t	vp_chksum;
43*1cb875aeSCathy Zhou 	/* then follows <vp_ipnum> IPvX addresses */
44*1cb875aeSCathy Zhou 	/* then follows NO authentification data */
45*1cb875aeSCathy Zhou } vrrp_pkt_t;
46*1cb875aeSCathy Zhou 
47*1cb875aeSCathy Zhou #define	IPPROTO_VRRP		112	/* IP protocol number */
48*1cb875aeSCathy Zhou #define	VRRP_AUTH_LEN		0	/* XXX length of a chunk of Auth Data */
49*1cb875aeSCathy Zhou 
50*1cb875aeSCathy Zhou #define	VRRP_IP_TTL		255	/* IPv4 TTL, IPv6 hop limit */
51*1cb875aeSCathy Zhou #define	VRRP_VERSION		3	/* current version */
52*1cb875aeSCathy Zhou #define	VRRP_PKT_ADVERT		1	/* packet type */
53*1cb875aeSCathy Zhou #define	VRRP_VER_MASK		0xf0	/* version mask */
54*1cb875aeSCathy Zhou #define	VRRP_TYPE_MASK		0x0f	/* packet type mask */
55*1cb875aeSCathy Zhou 
56*1cb875aeSCathy Zhou #define	VRRP_PRI_OWNER		255	/* priority of IP address owner */
57*1cb875aeSCathy Zhou #define	VRRP_PRI_MIN		1	/* minimum priority */
58*1cb875aeSCathy Zhou #define	VRRP_PRIO_ZERO		0	/* stop participating VRRP */
59*1cb875aeSCathy Zhou #define	VRRP_PRI_DEFAULT	VRRP_PRI_OWNER	/* default priority */
60*1cb875aeSCathy Zhou 
61*1cb875aeSCathy Zhou #define	VRRP_VRID_NONE		0
62*1cb875aeSCathy Zhou #define	VRRP_VRID_MIN		1
63*1cb875aeSCathy Zhou #define	VRRP_VRID_MAX		255
64*1cb875aeSCathy Zhou 
65*1cb875aeSCathy Zhou #define	CENTISEC2MSEC(centisec)	((centisec) * 10)
66*1cb875aeSCathy Zhou #define	MSEC2CENTISEC(msec)	((msec) / 10)
67*1cb875aeSCathy Zhou 
68*1cb875aeSCathy Zhou /* Max advertisement interval, in msec */
69*1cb875aeSCathy Zhou #define	VRRP_MAX_ADVER_INT_MIN	CENTISEC2MSEC(1)
70*1cb875aeSCathy Zhou #define	VRRP_MAX_ADVER_INT_MAX	CENTISEC2MSEC(4095)	/* (2^12 -1) */
71*1cb875aeSCathy Zhou #define	VRRP_MAX_ADVER_INT_DFLT	CENTISEC2MSEC(100)	/* 1 sec */
72*1cb875aeSCathy Zhou 
73*1cb875aeSCathy Zhou #ifdef __cplusplus
74*1cb875aeSCathy Zhou }
75*1cb875aeSCathy Zhou #endif
76*1cb875aeSCathy Zhou 
77*1cb875aeSCathy Zhou #endif	/* _VRRP_H */