3
Definitions for address trees... */
6
* Copyright (c) 2004,2005,2007 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
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
* ``http://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
77
#define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x))
79
/* All of the below definitions are mandated by draft-ietf-dhc-failover-12.
80
* The Sections referenced are Sections within that document of that
81
* version, and may be different in other documents of other versions.
84
/* Failover message options from Section 12: */
85
#define FTO_ADDRESSES_TRANSFERRED 1
86
#define FTB_ADDRESSES_TRANSFERRED 0x00000002
87
#define FTO_ASSIGNED_IP_ADDRESS 2
88
#define FTB_ASSIGNED_IP_ADDRESS 0x00000004
89
#define FTO_BINDING_STATUS 3
90
#define FTB_BINDING_STATUS 0x00000008
91
#define FTO_CLIENT_IDENTIFIER 4
92
#define FTB_CLIENT_IDENTIFIER 0x00000010
94
#define FTB_CHADDR 0x00000020
96
#define FTB_CLTT 0x00000040
97
#define FTO_REPLY_OPTIONS 7
98
#define FTB_REPLY_OPTIONS 0x00000080
99
#define FTO_REQUEST_OPTIONS 8
100
#define FTB_REQUEST_OPTIONS 0x00000100
102
#define FTB_DDNS 0x00000200
103
#define FTO_DELAYED_SERVICE 10
104
#define FTB_DELAYED_SERVICE 0x00000400
106
#define FTB_HBA 0x00000800
107
#define FTO_IP_FLAGS 12
108
#define FTB_IP_FLAGS 0x00001000
109
#define FTO_LEASE_EXPIRY 13
110
#define FTB_LEASE_EXPIRY 0x00002000
111
#define FTO_MAX_UNACKED 14
112
#define FTB_MAX_UNACKED 0x00004000
114
#define FTB_MCLT 0x00008000
115
#define FTO_MESSAGE 16
116
#define FTB_MESSAGE 0x00010000
117
#define FTO_MESSAGE_DIGEST 17
118
#define FTB_MESSAGE_DIGEST 0x00020000
119
#define FTO_POTENTIAL_EXPIRY 18
120
#define FTB_POTENTIAL_EXPIRY 0x00040000
121
#define FTO_RECEIVE_TIMER 19
122
#define FTB_RECEIVE_TIMER 0x00080000
123
#define FTO_PROTOCOL_VERSION 20
124
#define FTB_PROTOCOL_VERSION 0x00100000
125
#define FTO_REJECT_REASON 21
126
#define FTB_REJECT_REASON 0x00200000
127
#define FTO_RELATIONSHIP_NAME 22
128
#define FTB_RELATIONSHIP_NAME 0x00400000
129
#define FTO_SERVER_FLAGS 23
130
#define FTB_SERVER_FLAGS 0x00800000
131
#define FTO_SERVER_STATE 24
132
#define FTB_SERVER_STATE 0x01000000
134
#define FTB_STOS 0x02000000
135
#define FTO_TLS_REPLY 26
136
#define FTB_TLS_REPLY 0x04000000
137
#define FTO_TLS_REQUEST 27
138
#define FTB_TLS_REQUEST 0x08000000
139
#define FTO_VENDOR_CLASS 28
140
#define FTB_VENDOR_CLASS 0x10000000
141
#define FTO_VENDOR_OPTIONS 29
142
#define FTB_VENDOR_OPTIONS 0x20000000
144
#define FTO_MAX FTO_VENDOR_OPTIONS
146
/* Failover protocol message types from Section 6.1: */
147
#define FTM_POOLREQ 1
148
#define FTM_POOLRESP 2
151
#define FTM_CONNECT 5
152
#define FTM_CONNECTACK 6
153
#define FTM_UPDREQALL 7
154
#define FTM_UPDDONE 8
157
#define FTM_CONTACT 11
158
#define FTM_DISCONNECT 12
160
/* Reject reasons from Section 12.21: */
161
#define FTR_ILLEGAL_IP_ADDR 1
162
#define FTR_FATAL_CONFLICT 2
163
#define FTR_MISSING_BINDINFO 3
164
#define FTR_TIMEMISMATCH 4
165
#define FTR_INVALID_MCLT 5
166
#define FTR_MISC_REJECT 6
167
#define FTR_DUP_CONNECTION 7
168
#define FTR_INVALID_PARTNER 8
169
#define FTR_TLS_UNSUPPORTED 9
170
#define FTR_TLS_UNCONFIGURED 10
171
#define FTR_TLS_REQUIRED 11
172
#define FTR_DIGEST_UNSUPPORTED 12
173
#define FTR_DIGEST_UNCONFIGURED 13
174
#define FTR_VERSION_MISMATCH 14
175
#define FTR_OUTDATED_BIND_INFO 15
176
#define FTR_LESS_CRIT_BIND_INFO 16
177
#define FTR_NO_TRAFFIC 17
178
#define FTR_HBA_CONFLICT 18
179
#define FTR_IP_NOT_RESERVED 19
180
#define FTR_IP_DIGEST_FAILURE 20
181
#define FTR_IP_MISSING_DIGEST 21
182
#define FTR_UNKNOWN 254
184
/* Message size limitations defined in Section 6.1: */
185
#define DHCP_FAILOVER_MIN_MESSAGE_SIZE 12
186
#define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
188
/* Failover server flags from Section 12.23: */
189
#define FTF_SERVER_STARTUP 1
191
/* DDNS flags from Section 12.9. These are really their names. */
192
#define FTF_DDNS_C 0x0001
193
#define FTF_DDNS_A 0x0002
194
#define FTF_DDNS_D 0x0004
195
#define FTF_DDNS_P 0x0008
197
/* FTO_IP_FLAGS contents from Section 12.12: */
198
#define FTF_IP_FLAG_RESERVE 0x0001
199
#define FTF_IP_FLAG_BOOTP 0x0002
201
/* FTO_MESSAGE_DIGEST Type Codes from Section 12.17: */
202
#define FTT_MESSAGE_DIGEST_HMAC_MD5 0x01
204
typedef struct failover_message {
206
struct failover_message *next;
214
/* One-byte options. */
215
u_int8_t binding_status;
216
u_int8_t delayed_service;
217
u_int8_t protocol_version;
218
u_int8_t reject_reason;
219
u_int8_t server_flags;
220
u_int8_t server_state;
222
u_int8_t tls_request;
224
/* Two-byte options. */
227
/* Four-byte options. */
228
u_int32_t addresses_transferred;
229
u_int32_t assigned_addr;
232
u_int32_t max_unacked;
234
u_int32_t potential_expiry;
235
u_int32_t receive_timer;
238
/* Arbitrary field options. */
239
failover_option_t chaddr;
240
failover_option_t client_identifier;
241
failover_option_t hba;
242
failover_option_t message;
243
failover_option_t message_digest;
244
failover_option_t relationship_name;
245
failover_option_t reply_options;
246
failover_option_t request_options;
247
failover_option_t vendor_class;
248
failover_option_t vendor_options;
250
/* Special contents options. */
252
} failover_message_t;
255
OMAPI_OBJECT_PREAMBLE;
256
struct option_cache *peer_address;
259
enum dhcp_flink_state {
261
dhcp_flink_message_length_wait,
262
dhcp_flink_message_wait,
263
dhcp_flink_disconnected,
266
failover_message_t *imsg;
267
struct _dhcp_failover_state *state_object;
270
u_int8_t imsg_payoff; /* Pay*load* offset. :') */
272
} dhcp_failover_link_t;
274
typedef struct _dhcp_failover_listener {
275
OMAPI_OBJECT_PREAMBLE;
276
struct _dhcp_failover_listener *next;
277
omapi_addr_t address;
278
} dhcp_failover_listener_t;
279
#endif /* FAILOVER_PROTOCOL */
281
/* A failover peer's running state. */
282
enum failover_state {
283
unknown_state = 0, /* XXX: Not a standard state. */
286
communications_interrupted = 3,
288
potential_conflict = 5,
293
resolution_interrupted = 10,
296
/* Draft revision 12 of the failover protocol documents a RECOVER-WAIT
297
* state, but does not enumerate its value in the section 12.24
298
* table. ISC DHCP 3.0.x used value 254 even though the state was
299
* not documented at all. For the time being, we will continue to use
305
/* Service states are simplifications of failover states, particularly
306
useful because the startup state isn't actually implementable as a
307
separate failover state without maintaining a state stack. */
310
unknown_service_state,
313
service_partner_down,
318
#if defined (FAILOVER_PROTOCOL)
319
typedef struct _dhcp_failover_config {
320
struct option_cache *address;
322
u_int32_t max_flying_updates;
323
enum failover_state state;
325
u_int32_t max_response_delay;
326
} dhcp_failover_config_t;
328
typedef struct _dhcp_failover_state {
329
OMAPI_OBJECT_PREAMBLE;
330
struct _dhcp_failover_state *next;
331
char *name; /* Name of this failover instance. */
332
dhcp_failover_config_t me; /* My configuration. */
333
dhcp_failover_config_t partner; /* Partner's configuration. */
334
enum failover_state saved_state; /* Saved state during startup. */
335
struct data_string server_identifier; /* Server identifier (IP addr) */
338
u_int8_t *hba; /* Hash bucket array for load balancing. */
339
int load_balance_max_secs;
341
u_int32_t max_lease_misbalance, max_lease_ownership;
342
u_int32_t max_balance, min_balance;
343
TIME last_balance, sched_balance;
345
enum service_state service_state;
346
const char *nrr; /* Printable reason why we're in the
347
not_responding service state (empty
348
string if we are responding. */
350
dhcp_failover_link_t *link_to_peer; /* Currently-established link
355
} i_am; /* We are primary or secondary in this relationship. */
357
TIME last_packet_sent; /* Timestamp on last packet we sent. */
358
TIME last_timestamp_received; /* The last timestamp we sent that
359
has been returned by our partner. */
360
TIME skew; /* The skew between our clock and our partner's. */
361
struct lease *update_queue_head; /* List of leases we haven't sent
363
struct lease *update_queue_tail;
365
struct lease *ack_queue_head; /* List of lease updates the peer
367
struct lease *ack_queue_tail;
369
struct lease *send_update_done; /* When we get a BNDACK for this
370
lease, send an UPDDONE message. */
371
int cur_unacked_updates; /* Number of updates we've sent
372
that have not yet been acked. */
374
/* List of messages which we haven't
376
failover_message_t *toack_queue_head;
377
failover_message_t *toack_queue_tail;
378
int pending_acks; /* Number of messages in the toack
380
int pool_count; /* Number of pools referencing this
381
failover state object. */
382
int curUPD; /* If an UPDREQ* message is in motion,
383
this value indicates which one. */
384
u_int32_t updxid; /* XID of UPDREQ* message in action. */
385
} dhcp_failover_state_t;
387
#define DHCP_FAILOVER_VERSION 1
388
#endif /* FAILOVER_PROTOCOL */