2 /* $OpenBSD: ip_carp.h,v 1.8 2004/07/29 22:12:15 mcbride Exp $ */
5 * Copyright (c) 2002 Michael Shalayeff. All rights reserved.
6 * Copyright (c) 2003 Ryan McBride. All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
26 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
27 * THE POSSIBILITY OF SUCH DAMAGE.
34 * The CARP header layout is as follows:
37 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
38 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 * |Version| Type | VirtualHostID | AdvSkew | Auth Len |
40 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 * | Reserved | AdvBase | Checksum |
42 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
61 #if BYTE_ORDER == LITTLE_ENDIAN
65 #if BYTE_ORDER == BIG_ENDIAN
66 u_int8_t carp_version:4,
69 u_int8_t carp_vhid; /* virtual host id */
70 u_int8_t carp_advskew; /* advertisement skew */
71 u_int8_t carp_authlen; /* size of counter+md, 32bit chunks */
72 u_int8_t carp_pad1; /* reserved */
73 u_int8_t carp_advbase; /* advertisement interval */
75 u_int32_t carp_counter[2];
76 unsigned char carp_md[20]; /* SHA1 HMAC */
79 #define CARP_DFLTTL 255
82 #define CARP_VERSION 2
85 #define CARP_ADVERTISEMENT 0x01
87 #define CARP_KEY_LEN 20 /* a sha1 hash of a passphrase */
90 #define CARP_DFLTINTV 1
96 uint64_t carps_ipackets; /* total input packets, IPv4 */
97 uint64_t carps_ipackets6; /* total input packets, IPv6 */
98 uint64_t carps_badif; /* wrong interface */
99 uint64_t carps_badttl; /* TTL is not CARP_DFLTTL */
100 uint64_t carps_hdrops; /* packets shorter than hdr */
101 uint64_t carps_badsum; /* bad checksum */
102 uint64_t carps_badver; /* bad (incl unsupp) version */
103 uint64_t carps_badlen; /* data length does not match */
104 uint64_t carps_badauth; /* bad authentication */
105 uint64_t carps_badvhid; /* bad VHID */
106 uint64_t carps_badaddrs; /* bad address list */
108 uint64_t carps_opackets; /* total output packets, IPv4 */
109 uint64_t carps_opackets6; /* total output packets, IPv6 */
110 uint64_t carps_onomem; /* no memory for an mbuf */
111 uint64_t carps_ostates; /* total state updates sent */
113 uint64_t carps_preempt; /* if enabled, preemptions */
117 * Configuration structure for SIOCSVH SIOCGVH
121 #define CARP_STATES "INIT", "BACKUP", "MASTER"
122 #define CARP_MAXSTATE 2
126 unsigned char carpr_key[CARP_KEY_LEN];
128 #define SIOCSVH _IOWR('i', 245, struct ifreq)
129 #define SIOCGVH _IOWR('i', 246, struct ifreq)
132 * Names for CARP sysctl objects
134 #define CARPCTL_ALLOW 1 /* accept incoming CARP packets */
135 #define CARPCTL_PREEMPT 2 /* high-pri backup preemption mode */
136 #define CARPCTL_LOG 3 /* log bad packets */
137 #define CARPCTL_STATS 4 /* statistics (read-only) */
138 #define CARPCTL_ARPBALANCE 5 /* balance arp responses */
139 #define CARPCTL_MAXID 6
141 #define CARPCTL_NAMES { \
143 { "allow", CTLTYPE_INT }, \
144 { "preempt", CTLTYPE_INT }, \
145 { "log", CTLTYPE_INT }, \
146 { "stats", CTLTYPE_STRUCT }, \
147 { "arpbalance", CTLTYPE_INT }, \
151 void carp_ifdetach (struct ifnet *);
152 void carp_carpdev_state(void *);
153 void carp_input (struct mbuf *, int);
154 int carp6_input (struct mbuf **, int *, int);
155 int carp_output (struct ifnet *, struct mbuf *, struct sockaddr *,
157 int carp_iamatch (void *, struct in_ifaddr *, struct in_addr *,
159 struct ifaddr *carp_iamatch6(void *, struct in6_addr *);
160 void *carp_macmatch6(void *, struct mbuf *, const struct in6_addr *);
161 struct ifnet *carp_forus (void *, void *);
163 #endif /* _IP_CARP_H */