00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #if defined (FAILOVER_PROTOCOL)
00030 struct failover_option_info {
00031 int code;
00032 const char *name;
00033 enum { FT_UINT8, FT_IPADDR, FT_UINT32, FT_BYTES, FT_TEXT_OR_BYTES,
00034 FT_DDNS, FT_DDNS1, FT_UINT16, FT_TEXT,
00035 FT_UNDEF, FT_DIGEST } type;
00036 int num_present;
00037 int offset;
00038 u_int32_t bit;
00039 };
00040
00041 typedef struct {
00042 unsigned count;
00043 u_int8_t *data;
00044 } failover_option_t;
00045
00046
00047 #ifndef DEFAULT_MAX_BALANCE_TIME
00048 # define DEFAULT_MAX_BALANCE_TIME 3600
00049 #endif
00050
00051 #ifndef DEFAULT_MIN_BALANCE_TIME
00052 # define DEFAULT_MIN_BALANCE_TIME 60
00053 #endif
00054
00055 #ifndef DEFAULT_MAX_LEASE_MISBALANCE
00056 # define DEFAULT_MAX_LEASE_MISBALANCE 15
00057 #endif
00058
00059 #ifndef DEFAULT_MAX_LEASE_OWNERSHIP
00060 # define DEFAULT_MAX_LEASE_OWNERSHIP 10
00061 #endif
00062
00063 #ifndef DEFAULT_MAX_FLYING_UPDATES
00064 # define DEFAULT_MAX_FLYING_UPDATES 100
00065 #endif
00066
00067 #ifndef DEFAULT_MAX_RESPONSE_DELAY
00068 # define DEFAULT_MAX_RESPONSE_DELAY 20
00069 #endif
00070
00071
00072
00073
00074
00075
00076
00077 #ifndef DEFAULT_FAILOVER_PORT
00078 # define DEFAULT_FAILOVER_PORT 647
00079 #endif
00080
00081 #define FM_OFFSET(x) (long)(&(((failover_message_t *)0) -> x))
00082
00083
00084
00085
00086
00087
00088
00089 #define FTO_ADDRESSES_TRANSFERRED 1
00090 #define FTB_ADDRESSES_TRANSFERRED 0x00000002
00091 #define FTO_ASSIGNED_IP_ADDRESS 2
00092 #define FTB_ASSIGNED_IP_ADDRESS 0x00000004
00093 #define FTO_BINDING_STATUS 3
00094 #define FTB_BINDING_STATUS 0x00000008
00095 #define FTO_CLIENT_IDENTIFIER 4
00096 #define FTB_CLIENT_IDENTIFIER 0x00000010
00097 #define FTO_CHADDR 5
00098 #define FTB_CHADDR 0x00000020
00099 #define FTO_CLTT 6
00100 #define FTB_CLTT 0x00000040
00101 #define FTO_REPLY_OPTIONS 7
00102 #define FTB_REPLY_OPTIONS 0x00000080
00103 #define FTO_REQUEST_OPTIONS 8
00104 #define FTB_REQUEST_OPTIONS 0x00000100
00105 #define FTO_DDNS 9
00106 #define FTB_DDNS 0x00000200
00107 #define FTO_DELAYED_SERVICE 10
00108 #define FTB_DELAYED_SERVICE 0x00000400
00109 #define FTO_HBA 11
00110 #define FTB_HBA 0x00000800
00111 #define FTO_IP_FLAGS 12
00112 #define FTB_IP_FLAGS 0x00001000
00113 #define FTO_LEASE_EXPIRY 13
00114 #define FTB_LEASE_EXPIRY 0x00002000
00115 #define FTO_MAX_UNACKED 14
00116 #define FTB_MAX_UNACKED 0x00004000
00117 #define FTO_MCLT 15
00118 #define FTB_MCLT 0x00008000
00119 #define FTO_MESSAGE 16
00120 #define FTB_MESSAGE 0x00010000
00121 #define FTO_MESSAGE_DIGEST 17
00122 #define FTB_MESSAGE_DIGEST 0x00020000
00123 #define FTO_POTENTIAL_EXPIRY 18
00124 #define FTB_POTENTIAL_EXPIRY 0x00040000
00125 #define FTO_RECEIVE_TIMER 19
00126 #define FTB_RECEIVE_TIMER 0x00080000
00127 #define FTO_PROTOCOL_VERSION 20
00128 #define FTB_PROTOCOL_VERSION 0x00100000
00129 #define FTO_REJECT_REASON 21
00130 #define FTB_REJECT_REASON 0x00200000
00131 #define FTO_RELATIONSHIP_NAME 22
00132 #define FTB_RELATIONSHIP_NAME 0x00400000
00133 #define FTO_SERVER_FLAGS 23
00134 #define FTB_SERVER_FLAGS 0x00800000
00135 #define FTO_SERVER_STATE 24
00136 #define FTB_SERVER_STATE 0x01000000
00137 #define FTO_STOS 25
00138 #define FTB_STOS 0x02000000
00139 #define FTO_TLS_REPLY 26
00140 #define FTB_TLS_REPLY 0x04000000
00141 #define FTO_TLS_REQUEST 27
00142 #define FTB_TLS_REQUEST 0x08000000
00143 #define FTO_VENDOR_CLASS 28
00144 #define FTB_VENDOR_CLASS 0x10000000
00145 #define FTO_VENDOR_OPTIONS 29
00146 #define FTB_VENDOR_OPTIONS 0x20000000
00147
00148 #define FTO_MAX FTO_VENDOR_OPTIONS
00149
00150
00151 #define FTM_POOLREQ 1
00152 #define FTM_POOLRESP 2
00153 #define FTM_BNDUPD 3
00154 #define FTM_BNDACK 4
00155 #define FTM_CONNECT 5
00156 #define FTM_CONNECTACK 6
00157 #define FTM_UPDREQALL 7
00158 #define FTM_UPDDONE 8
00159 #define FTM_UPDREQ 9
00160 #define FTM_STATE 10
00161 #define FTM_CONTACT 11
00162 #define FTM_DISCONNECT 12
00163
00164
00165 #define FTR_ILLEGAL_IP_ADDR 1
00166 #define FTR_FATAL_CONFLICT 2
00167 #define FTR_MISSING_BINDINFO 3
00168 #define FTR_TIMEMISMATCH 4
00169 #define FTR_INVALID_MCLT 5
00170 #define FTR_MISC_REJECT 6
00171 #define FTR_DUP_CONNECTION 7
00172 #define FTR_INVALID_PARTNER 8
00173 #define FTR_TLS_UNSUPPORTED 9
00174 #define FTR_TLS_UNCONFIGURED 10
00175 #define FTR_TLS_REQUIRED 11
00176 #define FTR_DIGEST_UNSUPPORTED 12
00177 #define FTR_DIGEST_UNCONFIGURED 13
00178 #define FTR_VERSION_MISMATCH 14
00179 #define FTR_OUTDATED_BIND_INFO 15
00180 #define FTR_LESS_CRIT_BIND_INFO 16
00181 #define FTR_NO_TRAFFIC 17
00182 #define FTR_HBA_CONFLICT 18
00183 #define FTR_IP_NOT_RESERVED 19
00184 #define FTR_IP_DIGEST_FAILURE 20
00185 #define FTR_IP_MISSING_DIGEST 21
00186 #define FTR_UNKNOWN 254
00187
00188
00189 #define DHCP_FAILOVER_MIN_MESSAGE_SIZE 12
00190 #define DHCP_FAILOVER_MAX_MESSAGE_SIZE 2048
00191
00192
00193 #define FTF_SERVER_STARTUP 1
00194
00195
00196 #define FTF_DDNS_C 0x0001
00197 #define FTF_DDNS_A 0x0002
00198 #define FTF_DDNS_D 0x0004
00199 #define FTF_DDNS_P 0x0008
00200
00201
00202 #define FTF_IP_FLAG_RESERVE 0x0001
00203 #define FTF_IP_FLAG_BOOTP 0x0002
00204
00205
00206 #define FTT_MESSAGE_DIGEST_HMAC_MD5 0x01
00207
00208 typedef struct failover_message {
00209 int refcnt;
00210 struct failover_message *next;
00211
00212 int options_present;
00213
00214 u_int32_t time;
00215 u_int32_t xid;
00216 u_int8_t type;
00217
00218
00219 u_int8_t binding_status;
00220 u_int8_t delayed_service;
00221 u_int8_t protocol_version;
00222 u_int8_t reject_reason;
00223 u_int8_t server_flags;
00224 u_int8_t server_state;
00225 u_int8_t tls_reply;
00226 u_int8_t tls_request;
00227
00228
00229 u_int16_t ip_flags;
00230
00231
00232 u_int32_t addresses_transferred;
00233 u_int32_t assigned_addr;
00234 u_int32_t cltt;
00235 u_int32_t expiry;
00236 u_int32_t max_unacked;
00237 u_int32_t mclt;
00238 u_int32_t potential_expiry;
00239 u_int32_t receive_timer;
00240 u_int32_t stos;
00241
00242
00243 failover_option_t chaddr;
00244 failover_option_t client_identifier;
00245 failover_option_t hba;
00246 failover_option_t message;
00247 failover_option_t message_digest;
00248 failover_option_t relationship_name;
00249 failover_option_t reply_options;
00250 failover_option_t request_options;
00251 failover_option_t vendor_class;
00252 failover_option_t vendor_options;
00253
00254
00255 ddns_fqdn_t ddns;
00256 } failover_message_t;
00257
00258 typedef struct {
00259 OMAPI_OBJECT_PREAMBLE;
00260 struct option_cache *peer_address;
00261 unsigned peer_port;
00262 int options_present;
00263 enum dhcp_flink_state {
00264 dhcp_flink_start,
00265 dhcp_flink_message_length_wait,
00266 dhcp_flink_message_wait,
00267 dhcp_flink_disconnected,
00268 dhcp_flink_state_max
00269 } state;
00270 failover_message_t *imsg;
00271 struct _dhcp_failover_state *state_object;
00272 u_int16_t imsg_len;
00273 unsigned imsg_count;
00274 u_int8_t imsg_payoff;
00275 u_int32_t xid;
00276 } dhcp_failover_link_t;
00277
00278 typedef struct _dhcp_failover_listener {
00279 OMAPI_OBJECT_PREAMBLE;
00280 struct _dhcp_failover_listener *next;
00281 omapi_addr_t address;
00282 } dhcp_failover_listener_t;
00283 #endif
00284
00285
00286 enum failover_state {
00287 unknown_state = 0,
00288 startup = 1,
00289 normal = 2,
00290 communications_interrupted = 3,
00291 partner_down = 4,
00292 potential_conflict = 5,
00293 recover = 6,
00294 paused = 7,
00295 shut_down = 8,
00296 recover_done = 9,
00297 resolution_interrupted = 10,
00298 conflict_done = 11,
00299
00300
00301
00302
00303
00304
00305
00306 recover_wait = 254
00307 };
00308
00309
00310
00311
00312
00313 enum service_state {
00314 unknown_service_state,
00315 cooperating,
00316 not_cooperating,
00317 service_partner_down,
00318 not_responding,
00319 service_startup
00320 };
00321
00322 #if defined (FAILOVER_PROTOCOL)
00323 typedef struct _dhcp_failover_config {
00324 struct option_cache *address;
00325 int port;
00326 u_int32_t max_flying_updates;
00327 enum failover_state state;
00328 TIME stos;
00329 u_int32_t max_response_delay;
00330 } dhcp_failover_config_t;
00331
00332 typedef struct _dhcp_failover_state {
00333 OMAPI_OBJECT_PREAMBLE;
00334 struct _dhcp_failover_state *next;
00335 char *name;
00336 dhcp_failover_config_t me;
00337 dhcp_failover_config_t partner;
00338 enum failover_state saved_state;
00339 struct data_string server_identifier;
00340 u_int32_t mclt;
00341
00342 u_int8_t *hba;
00343 int load_balance_max_secs;
00344
00345 u_int32_t max_lease_misbalance, max_lease_ownership;
00346 u_int32_t max_balance, min_balance;
00347 TIME last_balance, sched_balance;
00348
00349 u_int32_t auto_partner_down;
00350
00351 enum service_state service_state;
00352 const char *nrr;
00353
00354
00355
00356 dhcp_failover_link_t *link_to_peer;
00357
00358
00359 enum {
00360 primary, secondary
00361 } i_am;
00362
00363 TIME last_packet_sent;
00364 TIME last_timestamp_received;
00365
00366 TIME skew;
00367 struct lease *update_queue_head;
00368
00369 struct lease *update_queue_tail;
00370
00371 struct lease *ack_queue_head;
00372
00373 struct lease *ack_queue_tail;
00374
00375 struct lease *send_update_done;
00376
00377 int cur_unacked_updates;
00378
00379
00380
00381
00382 failover_message_t *toack_queue_head;
00383 failover_message_t *toack_queue_tail;
00384 int pending_acks;
00385
00386 int pool_count;
00387
00388 int curUPD;
00389
00390 u_int32_t updxid;
00391 } dhcp_failover_state_t;
00392
00393 #define DHCP_FAILOVER_VERSION 1
00394 #endif