3 Definitions for address trees... */
6 * Copyright (c) 2004,2005,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 2000-2003 by Internet Software Consortium
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * Internet Systems Consortium, Inc.
23 * Redwood City, CA 94063
25 * https://www.isc.org/
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29 * To learn more about Internet Systems Consortium, see
30 * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32 * ``http://www.nominum.com''.
35 #if defined (FAILOVER_PROTOCOL)
36 struct failover_option_info {
39 enum { FT_UINT8, FT_IPADDR, FT_UINT32, FT_BYTES, FT_TEXT_OR_BYTES,
40 FT_DDNS, FT_DDNS1, FT_UINT16, FT_TEXT,
41 FT_UNDEF, FT_DIGEST } type;
52 /* Failover configuration defaults. */
53 #ifndef DEFAULT_MAX_BALANCE_TIME
54 # define DEFAULT_MAX_BALANCE_TIME 3600
57 #ifndef DEFAULT_MIN_BALANCE_TIME
58 # define DEFAULT_MIN_BALANCE_TIME 60
61 #ifndef DEFAULT_MAX_LEASE_MISBALANCE
62 # define DEFAULT_MAX_LEASE_MISBALANCE 15
65 #ifndef DEFAULT_MAX_LEASE_OWNERSHIP
66 # define DEFAULT_MAX_LEASE_OWNERSHIP 10
69 #ifndef DEFAULT_MAX_FLYING_UPDATES
70 # define DEFAULT_MAX_FLYING_UPDATES 100
73 #ifndef DEFAULT_MAX_RESPONSE_DELAY
74 # define DEFAULT_MAX_RESPONSE_DELAY 20
78 * IANA has assigned ports 647 ("dhcp-failover") and 847 ("dhcp-failover2").
79 * Of these, only port 647 is mentioned in the -12 draft revision. We're not
80 * sure if they are supposed to indicate primary and secondary? No matter,
81 * we'll stick to the -12 draft revision level.
83 #ifndef DEFAULT_FAILOVER_PORT
84 # define DEFAULT_FAILOVER_PORT 647
87 #define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x))
89 /* All of the below definitions are mandated by draft-ietf-dhc-failover-12.
90 * The Sections referenced are Sections within that document of that
91 * version, and may be different in other documents of other versions.
94 /* Failover message options from Section 12: */
95 #define FTO_ADDRESSES_TRANSFERRED 1
96 #define FTB_ADDRESSES_TRANSFERRED 0x00000002
97 #define FTO_ASSIGNED_IP_ADDRESS 2
98 #define FTB_ASSIGNED_IP_ADDRESS 0x00000004
99 #define FTO_BINDING_STATUS 3
100 #define FTB_BINDING_STATUS 0x00000008
101 #define FTO_CLIENT_IDENTIFIER 4
102 #define FTB_CLIENT_IDENTIFIER 0x00000010
104 #define FTB_CHADDR 0x00000020
106 #define FTB_CLTT 0x00000040
107 #define FTO_REPLY_OPTIONS 7
108 #define FTB_REPLY_OPTIONS 0x00000080
109 #define FTO_REQUEST_OPTIONS 8
110 #define FTB_REQUEST_OPTIONS 0x00000100
112 #define FTB_DDNS 0x00000200
113 #define FTO_DELAYED_SERVICE 10
114 #define FTB_DELAYED_SERVICE 0x00000400
116 #define FTB_HBA 0x00000800
117 #define FTO_IP_FLAGS 12
118 #define FTB_IP_FLAGS 0x00001000
119 #define FTO_LEASE_EXPIRY 13
120 #define FTB_LEASE_EXPIRY 0x00002000
121 #define FTO_MAX_UNACKED 14
122 #define FTB_MAX_UNACKED 0x00004000
124 #define FTB_MCLT 0x00008000
125 #define FTO_MESSAGE 16
126 #define FTB_MESSAGE 0x00010000
127 #define FTO_MESSAGE_DIGEST 17
128 #define FTB_MESSAGE_DIGEST 0x00020000
129 #define FTO_POTENTIAL_EXPIRY 18
130 #define FTB_POTENTIAL_EXPIRY 0x00040000
131 #define FTO_RECEIVE_TIMER 19
132 #define FTB_RECEIVE_TIMER 0x00080000
133 #define FTO_PROTOCOL_VERSION 20
134 #define FTB_PROTOCOL_VERSION 0x00100000
135 #define FTO_REJECT_REASON 21
136 #define FTB_REJECT_REASON 0x00200000
137 #define FTO_RELATIONSHIP_NAME 22
138 #define FTB_RELATIONSHIP_NAME 0x00400000
139 #define FTO_SERVER_FLAGS 23
140 #define FTB_SERVER_FLAGS 0x00800000
141 #define FTO_SERVER_STATE 24
142 #define FTB_SERVER_STATE 0x01000000
144 #define FTB_STOS 0x02000000
145 #define FTO_TLS_REPLY 26
146 #define FTB_TLS_REPLY 0x04000000
147 #define FTO_TLS_REQUEST 27
148 #define FTB_TLS_REQUEST 0x08000000
149 #define FTO_VENDOR_CLASS 28
150 #define FTB_VENDOR_CLASS 0x10000000
151 #define FTO_VENDOR_OPTIONS 29
152 #define FTB_VENDOR_OPTIONS 0x20000000
154 #define FTO_MAX FTO_VENDOR_OPTIONS
156 /* Failover protocol message types from Section 6.1: */
157 #define FTM_POOLREQ 1
158 #define FTM_POOLRESP 2
161 #define FTM_CONNECT 5
162 #define FTM_CONNECTACK 6
163 #define FTM_UPDREQALL 7
164 #define FTM_UPDDONE 8
167 #define FTM_CONTACT 11
168 #define FTM_DISCONNECT 12
170 /* Reject reasons from Section 12.21: */
171 #define FTR_ILLEGAL_IP_ADDR 1
172 #define FTR_FATAL_CONFLICT 2
173 #define FTR_MISSING_BINDINFO 3
174 #define FTR_TIMEMISMATCH 4
175 #define FTR_INVALID_MCLT 5
176 #define FTR_MISC_REJECT 6
177 #define FTR_DUP_CONNECTION 7
178 #define FTR_INVALID_PARTNER 8
179 #define FTR_TLS_UNSUPPORTED 9
180 #define FTR_TLS_UNCONFIGURED 10
181 #define FTR_TLS_REQUIRED 11
182 #define FTR_DIGEST_UNSUPPORTED 12
183 #define FTR_DIGEST_UNCONFIGURED 13
184 #define FTR_VERSION_MISMATCH 14
185 #define FTR_OUTDATED_BIND_INFO 15
186 #define FTR_LESS_CRIT_BIND_INFO 16
187 #define FTR_NO_TRAFFIC 17
188 #define FTR_HBA_CONFLICT 18
189 #define FTR_IP_NOT_RESERVED 19
190 #define FTR_IP_DIGEST_FAILURE 20
191 #define FTR_IP_MISSING_DIGEST 21
192 #define FTR_UNKNOWN 254
194 /* Message size limitations defined in Section 6.1: */
195 #define DHCP_FAILOVER_MIN_MESSAGE_SIZE 12
196 #define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
198 /* Failover server flags from Section 12.23: */
199 #define FTF_SERVER_STARTUP 1
201 /* DDNS flags from Section 12.9. These are really their names. */
202 #define FTF_DDNS_C 0x0001
203 #define FTF_DDNS_A 0x0002
204 #define FTF_DDNS_D 0x0004
205 #define FTF_DDNS_P 0x0008
207 /* FTO_IP_FLAGS contents from Section 12.12: */
208 #define FTF_IP_FLAG_RESERVE 0x0001
209 #define FTF_IP_FLAG_BOOTP 0x0002
211 /* FTO_MESSAGE_DIGEST Type Codes from Section 12.17: */
212 #define FTT_MESSAGE_DIGEST_HMAC_MD5 0x01
214 typedef struct failover_message {
216 struct failover_message *next;
224 /* One-byte options. */
225 u_int8_t binding_status;
226 u_int8_t delayed_service;
227 u_int8_t protocol_version;
228 u_int8_t reject_reason;
229 u_int8_t server_flags;
230 u_int8_t server_state;
232 u_int8_t tls_request;
234 /* Two-byte options. */
237 /* Four-byte options. */
238 u_int32_t addresses_transferred;
239 u_int32_t assigned_addr;
242 u_int32_t max_unacked;
244 u_int32_t potential_expiry;
245 u_int32_t receive_timer;
248 /* Arbitrary field options. */
249 failover_option_t chaddr;
250 failover_option_t client_identifier;
251 failover_option_t hba;
252 failover_option_t message;
253 failover_option_t message_digest;
254 failover_option_t relationship_name;
255 failover_option_t reply_options;
256 failover_option_t request_options;
257 failover_option_t vendor_class;
258 failover_option_t vendor_options;
260 /* Special contents options. */
262 } failover_message_t;
265 OMAPI_OBJECT_PREAMBLE;
266 struct option_cache *peer_address;
269 enum dhcp_flink_state {
271 dhcp_flink_message_length_wait,
272 dhcp_flink_message_wait,
273 dhcp_flink_disconnected,
276 failover_message_t *imsg;
277 struct _dhcp_failover_state *state_object;
280 u_int8_t imsg_payoff; /* Pay*load* offset. :') */
282 } dhcp_failover_link_t;
284 typedef struct _dhcp_failover_listener {
285 OMAPI_OBJECT_PREAMBLE;
286 struct _dhcp_failover_listener *next;
287 omapi_addr_t address;
288 } dhcp_failover_listener_t;
289 #endif /* FAILOVER_PROTOCOL */
291 /* A failover peer's running state. */
292 enum failover_state {
293 unknown_state = 0, /* XXX: Not a standard state. */
296 communications_interrupted = 3,
298 potential_conflict = 5,
303 resolution_interrupted = 10,
306 /* Draft revision 12 of the failover protocol documents a RECOVER-WAIT
307 * state, but does not enumerate its value in the section 12.24
308 * table. ISC DHCP 3.0.x used value 254 even though the state was
309 * not documented at all. For the time being, we will continue to use
315 /* Service states are simplifications of failover states, particularly
316 useful because the startup state isn't actually implementable as a
317 separate failover state without maintaining a state stack. */
320 unknown_service_state,
323 service_partner_down,
328 #if defined (FAILOVER_PROTOCOL)
329 typedef struct _dhcp_failover_config {
330 struct option_cache *address;
332 u_int32_t max_flying_updates;
333 enum failover_state state;
335 u_int32_t max_response_delay;
336 } dhcp_failover_config_t;
338 typedef struct _dhcp_failover_state {
339 OMAPI_OBJECT_PREAMBLE;
340 struct _dhcp_failover_state *next;
341 char *name; /* Name of this failover instance. */
342 dhcp_failover_config_t me; /* My configuration. */
343 dhcp_failover_config_t partner; /* Partner's configuration. */
344 enum failover_state saved_state; /* Saved state during startup. */
345 struct data_string server_identifier; /* Server identifier (IP addr) */
348 u_int8_t *hba; /* Hash bucket array for load balancing. */
349 int load_balance_max_secs;
351 u_int32_t max_lease_misbalance, max_lease_ownership;
352 u_int32_t max_balance, min_balance;
353 TIME last_balance, sched_balance;
355 u_int32_t auto_partner_down;
357 enum service_state service_state;
358 const char *nrr; /* Printable reason why we're in the
359 not_responding service state (empty
360 string if we are responding. */
362 dhcp_failover_link_t *link_to_peer; /* Currently-established link
367 } i_am; /* We are primary or secondary in this relationship. */
369 TIME last_packet_sent; /* Timestamp on last packet we sent. */
370 TIME last_timestamp_received; /* The last timestamp we sent that
371 has been returned by our partner. */
372 TIME skew; /* The skew between our clock and our partner's. */
373 struct lease *update_queue_head; /* List of leases we haven't sent
375 struct lease *update_queue_tail;
377 struct lease *ack_queue_head; /* List of lease updates the peer
379 struct lease *ack_queue_tail;
381 struct lease *send_update_done; /* When we get a BNDACK for this
382 lease, send an UPDDONE message. */
383 int cur_unacked_updates; /* Number of updates we've sent
384 that have not yet been acked. */
386 /* List of messages which we haven't
388 failover_message_t *toack_queue_head;
389 failover_message_t *toack_queue_tail;
390 int pending_acks; /* Number of messages in the toack
392 int pool_count; /* Number of pools referencing this
393 failover state object. */
394 int curUPD; /* If an UPDREQ* message is in motion,
395 this value indicates which one. */
396 u_int32_t updxid; /* XID of UPDREQ* message in action. */
397 } dhcp_failover_state_t;
399 #define DHCP_FAILOVER_VERSION 1
400 #endif /* FAILOVER_PROTOCOL */