3 Definitions for address trees... */
6 * Copyright (c) 2004-2017 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 2000-2003 by Internet Software Consortium
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
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 * Newmarket, NH 03857 USA
25 * https://www.isc.org/
29 #if defined (FAILOVER_PROTOCOL)
30 struct failover_option_info
{
33 enum { FT_UINT8
, FT_IPADDR
, FT_UINT32
, FT_BYTES
, FT_TEXT_OR_BYTES
,
34 FT_DDNS
, FT_DDNS1
, FT_UINT16
, FT_TEXT
,
35 FT_UNDEF
, FT_DIGEST
} type
;
46 /* Failover configuration defaults. */
47 #ifndef DEFAULT_MAX_BALANCE_TIME
48 # define DEFAULT_MAX_BALANCE_TIME 3600
51 #ifndef DEFAULT_MIN_BALANCE_TIME
52 # define DEFAULT_MIN_BALANCE_TIME 60
55 #ifndef DEFAULT_MAX_LEASE_MISBALANCE
56 # define DEFAULT_MAX_LEASE_MISBALANCE 15
59 #ifndef DEFAULT_MAX_LEASE_OWNERSHIP
60 # define DEFAULT_MAX_LEASE_OWNERSHIP 10
63 #ifndef DEFAULT_MAX_FLYING_UPDATES
64 # define DEFAULT_MAX_FLYING_UPDATES 100
67 #ifndef DEFAULT_MAX_RESPONSE_DELAY
68 # define DEFAULT_MAX_RESPONSE_DELAY 20
72 * IANA has assigned ports 647 ("dhcp-failover") and 847 ("dhcp-failover2").
73 * Of these, only port 647 is mentioned in the -12 draft revision. We're not
74 * sure if they are supposed to indicate primary and secondary? No matter,
75 * we'll stick to the -12 draft revision level.
77 #ifndef DEFAULT_FAILOVER_PORT
78 # define DEFAULT_FAILOVER_PORT 647
81 #define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x))
83 /* All of the below definitions are mandated by draft-ietf-dhc-failover-12.
84 * The Sections referenced are Sections within that document of that
85 * version, and may be different in other documents of other versions.
88 /* Failover message options from Section 12: */
89 #define FTO_ADDRESSES_TRANSFERRED 1
90 #define FTB_ADDRESSES_TRANSFERRED 0x00000002
91 #define FTO_ASSIGNED_IP_ADDRESS 2
92 #define FTB_ASSIGNED_IP_ADDRESS 0x00000004
93 #define FTO_BINDING_STATUS 3
94 #define FTB_BINDING_STATUS 0x00000008
95 #define FTO_CLIENT_IDENTIFIER 4
96 #define FTB_CLIENT_IDENTIFIER 0x00000010
98 #define FTB_CHADDR 0x00000020
100 #define FTB_CLTT 0x00000040
101 #define FTO_REPLY_OPTIONS 7
102 #define FTB_REPLY_OPTIONS 0x00000080
103 #define FTO_REQUEST_OPTIONS 8
104 #define FTB_REQUEST_OPTIONS 0x00000100
106 #define FTB_DDNS 0x00000200
107 #define FTO_DELAYED_SERVICE 10
108 #define FTB_DELAYED_SERVICE 0x00000400
110 #define FTB_HBA 0x00000800
111 #define FTO_IP_FLAGS 12
112 #define FTB_IP_FLAGS 0x00001000
113 #define FTO_LEASE_EXPIRY 13
114 #define FTB_LEASE_EXPIRY 0x00002000
115 #define FTO_MAX_UNACKED 14
116 #define FTB_MAX_UNACKED 0x00004000
118 #define FTB_MCLT 0x00008000
119 #define FTO_MESSAGE 16
120 #define FTB_MESSAGE 0x00010000
121 #define FTO_MESSAGE_DIGEST 17
122 #define FTB_MESSAGE_DIGEST 0x00020000
123 #define FTO_POTENTIAL_EXPIRY 18
124 #define FTB_POTENTIAL_EXPIRY 0x00040000
125 #define FTO_RECEIVE_TIMER 19
126 #define FTB_RECEIVE_TIMER 0x00080000
127 #define FTO_PROTOCOL_VERSION 20
128 #define FTB_PROTOCOL_VERSION 0x00100000
129 #define FTO_REJECT_REASON 21
130 #define FTB_REJECT_REASON 0x00200000
131 #define FTO_RELATIONSHIP_NAME 22
132 #define FTB_RELATIONSHIP_NAME 0x00400000
133 #define FTO_SERVER_FLAGS 23
134 #define FTB_SERVER_FLAGS 0x00800000
135 #define FTO_SERVER_STATE 24
136 #define FTB_SERVER_STATE 0x01000000
138 #define FTB_STOS 0x02000000
139 #define FTO_TLS_REPLY 26
140 #define FTB_TLS_REPLY 0x04000000
141 #define FTO_TLS_REQUEST 27
142 #define FTB_TLS_REQUEST 0x08000000
143 #define FTO_VENDOR_CLASS 28
144 #define FTB_VENDOR_CLASS 0x10000000
145 #define FTO_VENDOR_OPTIONS 29
146 #define FTB_VENDOR_OPTIONS 0x20000000
148 #define FTO_MAX FTO_VENDOR_OPTIONS
150 /* Failover protocol message types from Section 6.1: */
151 #define FTM_POOLREQ 1
152 #define FTM_POOLRESP 2
155 #define FTM_CONNECT 5
156 #define FTM_CONNECTACK 6
157 #define FTM_UPDREQALL 7
158 #define FTM_UPDDONE 8
161 #define FTM_CONTACT 11
162 #define FTM_DISCONNECT 12
164 #define FTM_MAX FTM_DISCONNECT
166 /* Reject reasons from Section 12.21: */
167 #define FTR_ILLEGAL_IP_ADDR 1
168 #define FTR_FATAL_CONFLICT 2
169 #define FTR_MISSING_BINDINFO 3
170 #define FTR_TIMEMISMATCH 4
171 #define FTR_INVALID_MCLT 5
172 #define FTR_MISC_REJECT 6
173 #define FTR_DUP_CONNECTION 7
174 #define FTR_INVALID_PARTNER 8
175 #define FTR_TLS_UNSUPPORTED 9
176 #define FTR_TLS_UNCONFIGURED 10
177 #define FTR_TLS_REQUIRED 11
178 #define FTR_DIGEST_UNSUPPORTED 12
179 #define FTR_DIGEST_UNCONFIGURED 13
180 #define FTR_VERSION_MISMATCH 14
181 #define FTR_OUTDATED_BIND_INFO 15
182 #define FTR_LESS_CRIT_BIND_INFO 16
183 #define FTR_NO_TRAFFIC 17
184 #define FTR_HBA_CONFLICT 18
185 #define FTR_IP_NOT_RESERVED 19
186 #define FTR_IP_DIGEST_FAILURE 20
187 #define FTR_IP_MISSING_DIGEST 21
188 #define FTR_UNKNOWN 254
190 /* Message size limitations defined in Section 6.1: */
191 #define DHCP_FAILOVER_MIN_MESSAGE_SIZE 12
192 #define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
194 /* Failover server flags from Section 12.23: */
195 #define FTF_SERVER_STARTUP 1
197 /* DDNS flags from Section 12.9. These are really their names. */
198 #define FTF_DDNS_C 0x0001
199 #define FTF_DDNS_A 0x0002
200 #define FTF_DDNS_D 0x0004
201 #define FTF_DDNS_P 0x0008
203 /* FTO_IP_FLAGS contents from Section 12.12: */
204 #define FTF_IP_FLAG_RESERVE 0x0001
205 #define FTF_IP_FLAG_BOOTP 0x0002
207 /* FTO_MESSAGE_DIGEST Type Codes from Section 12.17: */
208 #define FTT_MESSAGE_DIGEST_HMAC_MD5 0x01
210 typedef struct failover_message
{
212 struct failover_message
*next
;
220 /* One-byte options. */
221 u_int8_t binding_status
;
222 u_int8_t delayed_service
;
223 u_int8_t protocol_version
;
224 u_int8_t reject_reason
;
225 u_int8_t server_flags
;
226 u_int8_t server_state
;
228 u_int8_t tls_request
;
230 /* Two-byte options. */
233 /* Four-byte options. */
234 u_int32_t addresses_transferred
;
235 u_int32_t assigned_addr
;
238 u_int32_t max_unacked
;
240 u_int32_t potential_expiry
;
241 u_int32_t receive_timer
;
244 /* Arbitrary field options. */
245 failover_option_t chaddr
;
246 failover_option_t client_identifier
;
247 failover_option_t hba
;
248 failover_option_t message
;
249 failover_option_t message_digest
;
250 failover_option_t relationship_name
;
251 failover_option_t reply_options
;
252 failover_option_t request_options
;
253 failover_option_t vendor_class
;
254 failover_option_t vendor_options
;
256 /* Special contents options. */
258 } failover_message_t
;
261 OMAPI_OBJECT_PREAMBLE
;
262 struct option_cache
*peer_address
;
265 enum dhcp_flink_state
{
267 dhcp_flink_message_length_wait
,
268 dhcp_flink_message_wait
,
269 dhcp_flink_disconnected
,
272 failover_message_t
*imsg
;
273 struct _dhcp_failover_state
*state_object
;
276 u_int8_t imsg_payoff
; /* Pay*load* offset. :') */
278 } dhcp_failover_link_t
;
280 typedef struct _dhcp_failover_listener
{
281 OMAPI_OBJECT_PREAMBLE
;
282 struct _dhcp_failover_listener
*next
;
283 omapi_addr_t address
;
284 } dhcp_failover_listener_t
;
285 #endif /* FAILOVER_PROTOCOL */
287 /* A failover peer's running state. */
288 enum failover_state
{
289 unknown_state
= 0, /* XXX: Not a standard state. */
292 communications_interrupted
= 3,
294 potential_conflict
= 5,
299 resolution_interrupted
= 10,
302 /* Draft revision 12 of the failover protocol documents a RECOVER-WAIT
303 * state, but does not enumerate its value in the section 12.24
304 * table. ISC DHCP 3.0.x used value 254 even though the state was
305 * not documented at all. For the time being, we will continue to use
311 /* Service states are simplifications of failover states, particularly
312 useful because the startup state isn't actually implementable as a
313 separate failover state without maintaining a state stack. */
316 unknown_service_state
,
319 service_partner_down
,
324 #if defined (FAILOVER_PROTOCOL)
325 typedef struct _dhcp_failover_config
{
326 struct option_cache
*address
;
328 u_int32_t max_flying_updates
;
329 enum failover_state state
;
331 u_int32_t max_response_delay
;
332 } dhcp_failover_config_t
;
334 typedef struct _dhcp_failover_state
{
335 OMAPI_OBJECT_PREAMBLE
;
336 struct _dhcp_failover_state
*next
;
337 char *name
; /* Name of this failover instance. */
338 dhcp_failover_config_t me
; /* My configuration. */
339 dhcp_failover_config_t partner
; /* Partner's configuration. */
340 enum failover_state saved_state
; /* Saved state during startup. */
341 struct data_string server_identifier
; /* Server identifier (IP addr) */
344 u_int8_t
*hba
; /* Hash bucket array for load balancing. */
345 int load_balance_max_secs
;
347 u_int32_t max_lease_misbalance
, max_lease_ownership
;
348 u_int32_t max_balance
, min_balance
;
349 TIME last_balance
, sched_balance
;
351 u_int32_t auto_partner_down
;
353 enum service_state service_state
;
354 const char *nrr
; /* Printable reason why we're in the
355 not_responding service state (empty
356 string if we are responding. */
358 dhcp_failover_link_t
*link_to_peer
; /* Currently-established link
363 } i_am
; /* We are primary or secondary in this relationship. */
365 TIME last_packet_sent
; /* Timestamp on last packet we sent. */
366 TIME last_timestamp_received
; /* The last timestamp we sent that
367 has been returned by our partner. */
368 TIME skew
; /* The skew between our clock and our partner's. */
369 struct lease
*update_queue_head
; /* List of leases we haven't sent
371 struct lease
*update_queue_tail
;
373 struct lease
*ack_queue_head
; /* List of lease updates the peer
375 struct lease
*ack_queue_tail
;
377 struct lease
*send_update_done
; /* When we get a BNDACK for this
378 lease, send an UPDDONE message. */
379 int cur_unacked_updates
; /* Number of updates we've sent
380 that have not yet been acked. */
382 /* List of messages which we haven't
384 failover_message_t
*toack_queue_head
;
385 failover_message_t
*toack_queue_tail
;
386 int pending_acks
; /* Number of messages in the toack
388 int pool_count
; /* Number of pools referencing this
389 failover state object. */
390 int curUPD
; /* If an UPDREQ* message is in motion,
391 this value indicates which one. */
392 u_int32_t updxid
; /* XID of UPDREQ* message in action. */
393 } dhcp_failover_state_t
;
395 extern int check_secs_byte_order
; /* check byte order of secs field when true */
397 #define DHCP_FAILOVER_VERSION 1
398 #endif /* FAILOVER_PROTOCOL */