]>
Commit | Line | Data |
---|---|---|
b3677620 TL |
1 | /* failover.h |
2 | ||
3 | Definitions for address trees... */ | |
4 | ||
5 | /* | |
6 | * Copyright (c) 1999 Internet Software Consortium. | |
49733f31 | 7 | * All rights reserved. |
b3677620 | 8 | * |
49733f31 TL |
9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | |
b3677620 | 12 | * |
49733f31 TL |
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. | |
b3677620 | 21 | * |
49733f31 TL |
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 | |
34 | * SUCH DAMAGE. | |
35 | * | |
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''. | |
b3677620 TL |
42 | */ |
43 | ||
438f5f95 | 44 | #if defined (FAILOVER_PROTOCOL) |
d9eefc5d | 45 | struct failover_option_info { |
b3677620 | 46 | int code; |
c689c0c9 | 47 | const char *name; |
2ac47e02 TL |
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; | |
b3677620 | 51 | int num_present; |
d9eefc5d TL |
52 | int offset; |
53 | u_int32_t bit; | |
b3677620 TL |
54 | }; |
55 | ||
d9eefc5d | 56 | typedef struct { |
c689c0c9 | 57 | unsigned count; |
d9eefc5d TL |
58 | u_int8_t *data; |
59 | } failover_option_t; | |
60 | ||
c689c0c9 | 61 | #define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x)) |
b3677620 TL |
62 | |
63 | #define FTO_BINDING_STATUS 1 | |
64 | #define FTB_BINDING_STATUS 0x00000002 | |
65 | #define FTO_ASSIGNED_IP_ADDRESS 2 | |
66 | #define FTB_ASSIGNED_IP_ADDRESS 0x00000004 | |
67 | #define FTO_SERVER_ADDR 3 | |
68 | #define FTB_SERVER_ADDR 0x00000008 | |
69 | #define FTO_ADDRESSES_TRANSFERRED 4 | |
70 | #define FTB_ADDRESSES_TRANSFERRED 0x00000010 | |
71 | #define FTO_CLIENT_IDENTIFIER 5 | |
72 | #define FTB_CLIENT_IDENTIFIER 0x00000020 | |
c689c0c9 TL |
73 | #define FTO_CHADDR 6 |
74 | #define FTB_CHADDR 0x00000040 | |
b3677620 TL |
75 | #define FTO_DDNS 7 |
76 | #define FTB_DDNS 0x00000080 | |
77 | #define FTO_REJECT_REASON 8 | |
78 | #define FTB_REJECT_REASON 0x00000100 | |
79 | #define FTO_MESSAGE 9 | |
80 | #define FTB_MESSAGE 0x00000200 | |
81 | #define FTO_MCLT 10 | |
82 | #define FTB_MCLT 0x00000400 | |
83 | #define FTO_VENDOR_CLASS 11 | |
84 | #define FTB_VENDOR_CLASS 0x00000800 | |
c689c0c9 TL |
85 | #define FTO_LEASE_EXPIRY 13 |
86 | #define FTB_LEASE_EXPIRY 0x00002000 | |
b3677620 TL |
87 | #define FTO_POTENTIAL_EXPIRY 14 |
88 | #define FTB_POTENTIAL_EXPIRY 0x00004000 | |
89 | #define FTO_GRACE_EXPIRY 15 | |
90 | #define FTB_GRACE_EXPIRY 0x00008000 | |
91 | #define FTO_CLTT 16 | |
92 | #define FTB_CLTT 0x00010000 | |
93 | #define FTO_STOS 17 | |
94 | #define FTB_STOS 0x00020000 | |
95 | #define FTO_SERVER_STATE 18 | |
96 | #define FTB_SERVER_STATE 0x00040000 | |
97 | #define FTO_SERVER_FLAGS 19 | |
98 | #define FTB_SERVER_FLAGS 0x00080000 | |
99 | #define FTO_VENDOR_OPTIONS 20 | |
100 | #define FTB_VENDOR_OPTIONS 0x00100000 | |
101 | #define FTO_MAX_UNACKED 21 | |
102 | #define FTB_MAX_UNACKED 0x00200000 | |
103 | #define FTO_RECEIVE_TIMER 23 | |
104 | #define FTB_RECEIVE_TIMER 0x00800000 | |
105 | #define FTO_HBA 24 | |
106 | #define FTB_HBA 0x01000000 | |
107 | #define FTO_MESSAGE_DIGEST 25 | |
108 | #define FTB_MESSAGE_DIGEST 0x02000000 | |
109 | #define FTO_PROTOCOL_VERSION 26 | |
110 | #define FTB_PROTOCOL_VERSION 0x04000000 | |
111 | #define FTO_TLS_REQUEST 27 | |
112 | #define FTB_TLS_REQUEST 0x08000000 | |
113 | #define FTO_TLS_REPLY 28 | |
114 | #define FTB_TLS_REPLY 0x10000000 | |
115 | #define FTO_REQUEST_OPTIONS 29 | |
116 | #define FTB_REQUEST_OPTIONS 0x20000000 | |
117 | #define FTO_REPLY_OPTIONS 30 | |
118 | #define FTB_REPLY_OPTIONS 0x40000000 | |
119 | #define FTO_MAX FTO_REPLY_OPTIONS | |
120 | ||
121 | #define FTM_POOLREQ 1 | |
122 | #define FTM_POOLRESP 2 | |
123 | #define FTM_BNDUPD 3 | |
124 | #define FTM_BNDACK 4 | |
125 | #define FTM_CONNECT 5 | |
126 | #define FTM_CONNECTACK 6 | |
127 | #define FTM_UPDREQ 7 | |
128 | #define FTM_UPDDONE 8 | |
129 | #define FTM_UPDREQALL 9 | |
130 | #define FTM_STATE 10 | |
131 | #define FTM_CONTACT 11 | |
132 | #define FTM_DISCONNECT 12 | |
d9eefc5d TL |
133 | |
134 | #define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048 | |
135 | ||
136 | typedef struct { | |
137 | u_int8_t type; | |
c689c0c9 TL |
138 | |
139 | u_int8_t binding_status; | |
140 | u_int8_t protocol_version; | |
141 | u_int8_t reject_reason; | |
142 | u_int8_t server_flags; | |
143 | u_int8_t server_state; | |
144 | u_int8_t tls_reply; | |
145 | u_int8_t tls_request; | |
146 | u_int32_t stos; | |
d9eefc5d TL |
147 | u_int32_t time; |
148 | u_int32_t xid; | |
c689c0c9 TL |
149 | u_int32_t addresses_transferred; |
150 | u_int32_t assigned_addr; | |
151 | u_int32_t client_ltt; | |
152 | u_int32_t expiry; | |
153 | u_int32_t grace_expiry; | |
154 | u_int32_t max_unacked; | |
155 | u_int32_t mclt; | |
156 | u_int32_t potential_expiry; | |
157 | u_int32_t receive_timer; | |
158 | u_int32_t server_addr; | |
159 | failover_option_t chaddr; | |
160 | failover_option_t client_identifier; | |
161 | failover_option_t hba; | |
162 | failover_option_t message; | |
163 | failover_option_t reply_options; | |
164 | failover_option_t request_options; | |
165 | ddns_fqdn_t ddns; | |
166 | failover_option_t vendor_class; | |
167 | failover_option_t vendor_options; | |
168 | ||
d9eefc5d TL |
169 | int options_present; |
170 | } failover_message_t; | |
171 | ||
172 | typedef struct { | |
173 | OMAPI_OBJECT_PREAMBLE; | |
80f2771e | 174 | struct option_cache *peer_address; |
d9eefc5d TL |
175 | unsigned peer_port; |
176 | int options_present; | |
177 | enum dhcp_flink_state { | |
178 | dhcp_flink_start, | |
179 | dhcp_flink_message_length_wait, | |
180 | dhcp_flink_message_wait, | |
181 | dhcp_flink_disconnected, | |
182 | dhcp_flink_state_max | |
183 | } state; | |
184 | failover_message_t *imsg; | |
c689c0c9 | 185 | struct _dhcp_failover_state *state_object; |
d9eefc5d TL |
186 | u_int16_t imsg_len; |
187 | unsigned imsg_count; | |
188 | u_int8_t imsg_payoff; /* Pay*load* offset. :') */ | |
c689c0c9 | 189 | u_int32_t xid; |
d9eefc5d TL |
190 | } dhcp_failover_link_t; |
191 | ||
192 | typedef struct { | |
193 | OMAPI_OBJECT_PREAMBLE; | |
194 | unsigned local_port; | |
d9eefc5d | 195 | } dhcp_failover_listener_t; |
438f5f95 | 196 | #endif /* FAILOVER_PROTOCOL */ |
d9eefc5d | 197 | |
80f2771e TL |
198 | /* A failover peer. */ |
199 | enum failover_state { | |
200 | invalid_state, | |
201 | partner_down, | |
202 | normal, | |
203 | communications_interrupted, | |
204 | potential_conflict, | |
205 | recover | |
206 | }; | |
207 | ||
438f5f95 | 208 | #if defined (FAILOVER_PROTOCOL) |
d9eefc5d TL |
209 | typedef struct _dhcp_failover_state { |
210 | OMAPI_OBJECT_PREAMBLE; | |
211 | struct _dhcp_failover_state *next; | |
80f2771e TL |
212 | char *name; /* Name of this failover instance. */ |
213 | struct option_cache *address; /* Partner's IP address or hostname. */ | |
d9eefc5d | 214 | int listen_port; |
80f2771e | 215 | int port; /* Partner's TCP port. */ |
c689c0c9 | 216 | struct iaddr server_addr; |
80f2771e TL |
217 | u_int32_t max_flying_updates; |
218 | u_int32_t mclt; | |
c689c0c9 | 219 | u_int8_t *hba; |
80f2771e TL |
220 | |
221 | enum failover_state partner_state; | |
222 | TIME partner_stos; | |
223 | enum failover_state my_state; | |
224 | TIME my_stos; | |
225 | ||
226 | enum { | |
227 | primary, secondary | |
228 | } i_am; /* We are primary or secondary in this relationship. */ | |
229 | ||
230 | TIME last_packet_sent; /* Timestamp on last packet we sent. */ | |
231 | TIME last_timestamp_received; /* The last timestamp we sent that | |
232 | has been returned by our partner. */ | |
233 | TIME skew; /* The skew between our clock and our partner's. */ | |
234 | u_int32_t max_transmit_idle; /* Always send a poll if we haven't sent | |
235 | some other packet more recently than | |
236 | this. */ | |
237 | u_int32_t max_response_delay; /* If the returned timestamp on the | |
238 | last packet we received is older | |
239 | than this, communications have been | |
240 | interrupted. */ | |
241 | /* The ack queue and update queue are circular lists, so you can | |
242 | tell whether or not a lease is on one of the lists by looking | |
243 | at its next pointer. Or maybe we should just flag it as | |
244 | UPDATE_PENDING or ACK_PENDING. But anyway, two seperate | |
245 | queues. Hm. Maybe these should be hash tables, with no pointer | |
246 | from the peer to the lease. */ | |
247 | struct lease *update_queue; /* List of leases we haven't sent | |
248 | to peer. */ | |
249 | struct lease *ack_queue; /* List of lease updates the peer | |
250 | hasn't yet acked. */ | |
251 | int cur_unacked_updates; /* Number of updates we've sent | |
252 | that have not yet been acked. */ | |
d9eefc5d TL |
253 | } dhcp_failover_state_t; |
254 | ||
c689c0c9 | 255 | #define DHCP_FAILOVER_VERSION 1 |
438f5f95 | 256 | #endif /* FAILOVER_PROTOCOL */ |