3 Definitions for address trees... */
6 * Copyright (c) 2000-2001 Internet Software Consortium.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of The Internet Software Consortium nor the names
19 * of its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
23 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * This software has been written for the Internet Software Consortium
37 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
38 * To learn more about the Internet Software Consortium, see
39 * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
40 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
41 * ``http://www.nominum.com''.
44 #if defined (FAILOVER_PROTOCOL)
45 struct failover_option_info {
48 enum { FT_UINT8, FT_IPADDR, FT_UINT32, FT_BYTES, FT_TEXT_OR_BYTES,
49 FT_DDNS, FT_DDNS1, FT_UINT16, FT_TEXT,
50 FT_UNDEF, FT_DIGEST } type;
61 #define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x))
63 /* Failover message options: */
64 #define FTO_BINDING_STATUS 1
65 #define FTB_BINDING_STATUS 0x00000002
66 #define FTO_ASSIGNED_IP_ADDRESS 2
67 #define FTB_ASSIGNED_IP_ADDRESS 0x00000004
68 #define FTO_SERVER_ADDR 3
69 #define FTB_SERVER_ADDR 0x00000008
70 #define FTO_ADDRESSES_TRANSFERRED 4
71 #define FTB_ADDRESSES_TRANSFERRED 0x00000010
72 #define FTO_CLIENT_IDENTIFIER 5
73 #define FTB_CLIENT_IDENTIFIER 0x00000020
75 #define FTB_CHADDR 0x00000040
77 #define FTB_DDNS 0x00000080
78 #define FTO_REJECT_REASON 8
79 #define FTB_REJECT_REASON 0x00000100
81 #define FTB_MESSAGE 0x00000200
83 #define FTB_MCLT 0x00000400
84 #define FTO_VENDOR_CLASS 11
85 #define FTB_VENDOR_CLASS 0x00000800
86 #define FTO_LEASE_EXPIRY 13
87 #define FTB_LEASE_EXPIRY 0x00002000
88 #define FTO_POTENTIAL_EXPIRY 14
89 #define FTB_POTENTIAL_EXPIRY 0x00004000
90 #define FTO_GRACE_EXPIRY 15
91 #define FTB_GRACE_EXPIRY 0x00008000
93 #define FTB_CLTT 0x00010000
95 #define FTB_STOS 0x00020000
96 #define FTO_SERVER_STATE 18
97 #define FTB_SERVER_STATE 0x00040000
98 #define FTO_SERVER_FLAGS 19
99 #define FTB_SERVER_FLAGS 0x00080000
100 #define FTO_VENDOR_OPTIONS 20
101 #define FTB_VENDOR_OPTIONS 0x00100000
102 #define FTO_MAX_UNACKED 21
103 #define FTB_MAX_UNACKED 0x00200000
104 #define FTO_RECEIVE_TIMER 23
105 #define FTB_RECEIVE_TIMER 0x00800000
107 #define FTB_HBA 0x01000000
108 #define FTO_MESSAGE_DIGEST 25
109 #define FTB_MESSAGE_DIGEST 0x02000000
110 #define FTO_PROTOCOL_VERSION 26
111 #define FTB_PROTOCOL_VERSION 0x04000000
112 #define FTO_TLS_REQUEST 27
113 #define FTB_TLS_REQUEST 0x08000000
114 #define FTO_TLS_REPLY 28
115 #define FTB_TLS_REPLY 0x10000000
116 #define FTO_REQUEST_OPTIONS 29
117 #define FTB_REQUEST_OPTIONS 0x20000000
118 #define FTO_REPLY_OPTIONS 30
119 #define FTB_REPLY_OPTIONS 0x40000000
120 #define FTO_MAX FTO_REPLY_OPTIONS
122 /* Failover protocol message types: */
123 #define FTM_POOLREQ 1
124 #define FTM_POOLRESP 2
127 #define FTM_CONNECT 5
128 #define FTM_CONNECTACK 6
130 #define FTM_UPDDONE 8
131 #define FTM_UPDREQALL 9
133 #define FTM_CONTACT 11
134 #define FTM_DISCONNECT 12
136 /* Reject reasons: */
138 #define FTR_ILLEGAL_IP_ADDR 1
139 #define FTR_FATAL_CONFLICT 2
140 #define FTR_MISSING_BINDINFO 3
141 #define FTR_TIMEMISMATCH 4
142 #define FTR_INVALID_MCLT 5
143 #define FTR_MISC_REJECT 6
144 #define FTR_DUP_CONNECTION 7
145 #define FTR_INVALID_PARTNER 8
146 #define FTR_TLS_UNSUPPORTED 9
147 #define FTR_TLS_UNCONFIGURED 10
148 #define FTR_TLS_REQUIRED 11
149 #define FTR_DIGEST_UNSUPPORTED 12
150 #define FTR_DIGEST_UNCONFIGURED 13
151 #define FTR_VERSION_MISMATCH 14
152 #define FTR_MISSING_BIND_INFO 15
153 #define FTR_OUTDATED_BIND_INFO 16
154 #define FTR_LESS_CRIT_BIND_INFO 17
155 #define FTR_NO_TRAFFIC 18
156 #define FTR_HBA_CONFLICT 19
157 #define FTR_UNKNOWN 254
159 #define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
161 /* Failover server flags. */
162 #define FTF_STARTUP 1
164 typedef struct failover_message {
166 struct failover_message *next;
170 u_int8_t binding_status;
171 u_int8_t protocol_version;
172 u_int8_t reject_reason;
173 u_int8_t server_flags;
174 u_int8_t server_state;
176 u_int8_t tls_request;
180 u_int32_t addresses_transferred;
181 u_int32_t assigned_addr;
182 u_int32_t client_ltt;
184 u_int32_t grace_expiry;
185 u_int32_t max_unacked;
187 u_int32_t potential_expiry;
188 u_int32_t receive_timer;
189 u_int32_t server_addr;
190 failover_option_t chaddr;
191 failover_option_t client_identifier;
192 failover_option_t hba;
193 failover_option_t message;
194 failover_option_t reply_options;
195 failover_option_t request_options;
197 failover_option_t vendor_class;
198 failover_option_t vendor_options;
201 } failover_message_t;
204 OMAPI_OBJECT_PREAMBLE;
205 struct option_cache *peer_address;
208 enum dhcp_flink_state {
210 dhcp_flink_message_length_wait,
211 dhcp_flink_message_wait,
212 dhcp_flink_disconnected,
215 failover_message_t *imsg;
216 struct _dhcp_failover_state *state_object;
219 u_int8_t imsg_payoff; /* Pay*load* offset. :') */
221 } dhcp_failover_link_t;
223 typedef struct _dhcp_failover_listener {
224 OMAPI_OBJECT_PREAMBLE;
225 struct _dhcp_failover_listener *next;
226 omapi_addr_t address;
227 } dhcp_failover_listener_t;
228 #endif /* FAILOVER_PROTOCOL */
230 /* A failover peer. */
231 enum failover_state {
235 communications_interrupted,
236 resolution_interrupted,
246 /* Service states are simplifications of failover states, particularly
247 useful because the startup state isn't actually implementable as a
248 seperate failover state without maintaining a state stack. */
251 unknown_service_state,
254 service_partner_down,
259 #if defined (FAILOVER_PROTOCOL)
260 typedef struct _dhcp_failover_config {
261 struct option_cache *address;
263 u_int32_t max_flying_updates;
264 enum failover_state state;
266 u_int32_t max_response_delay;
267 } dhcp_failover_config_t;
269 typedef struct _dhcp_failover_state {
270 OMAPI_OBJECT_PREAMBLE;
271 struct _dhcp_failover_state *next;
272 char *name; /* Name of this failover instance. */
273 dhcp_failover_config_t me; /* My configuration. */
274 dhcp_failover_config_t partner; /* Partner's configuration. */
275 enum failover_state saved_state; /* Saved state during startup. */
276 struct data_string server_identifier; /* Server identifier (IP addr) */
279 u_int8_t *hba; /* Hash bucket array for load balancing. */
280 int load_balance_max_secs;
282 enum service_state service_state;
283 const char *nrr; /* Printable reason why we're in the
284 not_responding service state (empty
285 string if we are responding. */
287 dhcp_failover_link_t *link_to_peer; /* Currently-established link
292 } i_am; /* We are primary or secondary in this relationship. */
294 TIME last_packet_sent; /* Timestamp on last packet we sent. */
295 TIME last_timestamp_received; /* The last timestamp we sent that
296 has been returned by our partner. */
297 TIME skew; /* The skew between our clock and our partner's. */
298 struct lease *update_queue_head; /* List of leases we haven't sent
300 struct lease *update_queue_tail;
302 struct lease *ack_queue_head; /* List of lease updates the peer
304 struct lease *ack_queue_tail;
306 struct lease *send_update_done; /* When we get a BNDACK for this
307 lease, send an UPDDONE message. */
308 int cur_unacked_updates; /* Number of updates we've sent
309 that have not yet been acked. */
311 /* List of messages which we haven't
313 failover_message_t *toack_queue_head;
314 failover_message_t *toack_queue_tail;
315 int pending_acks; /* Number of messages in the toack
317 int pool_count; /* Number of pools referencing this
318 failover state object. */
319 } dhcp_failover_state_t;
321 #define DHCP_FAILOVER_VERSION 1
322 #endif /* FAILOVER_PROTOCOL */