]> git.ipfire.org Git - thirdparty/dhcp.git/blob - includes/dhcpd.h
- Support for compressed 'domain name list' style DHCP option contents, and
[thirdparty/dhcp.git] / includes / dhcpd.h
1 /* dhcpd.h
2
3 Definitions for dhcpd... */
4
5 /*
6 * Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
8 *
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.
12 *
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.
20 *
21 * Internet Systems Consortium, Inc.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * http://www.isc.org/
26 *
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''.
33 */
34
35 #ifndef __CYGWIN32__
36 #include <sys/types.h>
37 #include <netinet/in.h>
38 #include <sys/socket.h>
39 #include <sys/un.h>
40 #include <arpa/inet.h>
41
42 #include <netdb.h>
43 #else
44 #define fd_set cygwin_fd_set
45 #include <sys/types.h>
46 #endif
47 #include <fcntl.h>
48 #include <stdio.h>
49 #include <unistd.h>
50 #include <string.h>
51 #include <stdlib.h>
52 #include <sys/stat.h>
53 #include <ctype.h>
54 #include <time.h>
55
56 #include "cdefs.h"
57 #include "osdep.h"
58
59 #include "arpa/nameser.h"
60 #if defined (NSUPDATE)
61 # include "minires/minires.h"
62 #endif
63
64 struct hash_table;
65 typedef struct hash_table group_hash_t;
66 typedef struct hash_table universe_hash_t;
67 typedef struct hash_table option_name_hash_t;
68 typedef struct hash_table option_code_hash_t;
69 typedef struct hash_table dns_zone_hash_t;
70 typedef struct hash_table lease_hash_t;
71 typedef struct hash_table host_hash_t;
72 typedef struct hash_table class_hash_t;
73
74 #include "dhcp.h"
75 #include "statement.h"
76 #include "tree.h"
77 #include "inet.h"
78 #include "dhctoken.h"
79
80 #include <isc-dhcp/result.h>
81 #include <omapip/omapip_p.h>
82
83 #if !defined (BYTE_NAME_HASH_SIZE)
84 # define BYTE_NAME_HASH_SIZE 401 /* Default would be rediculous. */
85 #endif
86 #if !defined (BYTE_CODE_HASH_SIZE)
87 # define BYTE_CODE_HASH_SIZE 254 /* Default would be rediculous. */
88 #endif
89
90 #if !defined (WORD_NAME_HASH_SIZE)
91 # define WORD_NAME_HASH_SIZE 0 /* Default. */
92 #endif
93 #if !defined (WORD_CODE_HASH_SIZE)
94 # define WORD_CODE_HASH_SIZE 0 /* Default. */
95 #endif
96
97 #if !defined (QUAD_NAME_HASH_SIZE)
98 # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
99 #endif
100 #if !defined (QUAD_CODE_HASH_SIZE)
101 # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
102 #endif
103
104 #if !defined (DNS_HASH_SIZE)
105 # define DNS_HASH_SIZE 0 /* Default. */
106 #endif
107
108 /* Default size to use for name/code hashes on user-defined option spaces. */
109 #if !defined (DEFAULT_SPACE_HASH_SIZE)
110 # define DEFAULT_SPACE_HASH_SIZE 11
111 #endif
112
113 #if !defined (NWIP_HASH_SIZE)
114 # define NWIP_HASH_SIZE 11 /* A really small table. */
115 #endif
116
117 #if !defined (FQDN_HASH_SIZE)
118 # define FQDN_HASH_SIZE 7 /* A rediculously small table. */
119 #endif
120
121 #if !defined (VIVCO_HASH_SIZE)
122 # define VIVCO_HASH_SIZE QUAD_CODE_HASH_SIZE
123 #endif
124
125 #if !defined (VIVSO_HASH_SIZE)
126 # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
127 #endif
128
129 #if !defined (VIV_ISC_HASH_SIZE)
130 # define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */
131 #endif
132
133 #if !defined (UNIVERSE_HASH_SIZE)
134 # define UNIVERSE_HASH_SIZE 11 /* A really small table. */
135 #endif
136
137 #if !defined (GROUP_HASH_SIZE)
138 # define GROUP_HASH_SIZE 0 /* Default. */
139 #endif
140
141 #if !defined (HOST_HASH_SIZE)
142 # define HOST_HASH_SIZE 0 /* Default. */
143 #endif
144
145 #if !defined (LEASE_HASH_SIZE)
146 # define LEASE_HASH_SIZE 0 /* Default. */
147 #endif
148
149 #if !defined (SCLASS_HASH_SIZE)
150 # define SCLASS_HASH_SIZE 1009 /* A less than gigantic sized table. */
151 #endif
152
153 #if !defined (AGENT_HASH_SIZE)
154 # define AGENT_HASH_SIZE 11 /* A really small table. */
155 #endif
156
157 #if !defined (SERVER_HASH_SIZE)
158 # define SERVER_HASH_SIZE (sizeof(server_options) / sizeof(struct option))
159 #endif
160
161
162
163 #if !defined (OPTION_HASH_SIZE)
164 # define OPTION_HASH_SIZE 17
165 # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */
166 # define OPTION_HASH_EXP 5 /* The exponent for that power of two. */
167 #endif
168
169 #define compute_option_hash(x) \
170 (((x) & (OPTION_HASH_PTWO - 1)) + \
171 (((x) >> OPTION_HASH_EXP) & \
172 (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
173
174 enum dhcp_shutdown_state {
175 shutdown_listeners,
176 shutdown_omapi_connections,
177 shutdown_drop_omapi_connections,
178 shutdown_dhcp,
179 shutdown_done
180 };
181
182 /* Client FQDN option, failover FQDN option, etc. */
183 typedef struct {
184 u_int8_t codes [2];
185 unsigned length;
186 u_int8_t *data;
187 } ddns_fqdn_t;
188
189 #include "failover.h"
190
191 /* A parsing context. */
192
193 struct parse {
194 int lexline;
195 int lexchar;
196 char *token_line;
197 char *prev_line;
198 char *cur_line;
199 const char *tlname;
200 int eol_token;
201
202 char line1 [81];
203 char line2 [81];
204 int lpos;
205 int line;
206 int tlpos;
207 int tline;
208 enum dhcp_token token;
209 int ugflag;
210 char *tval;
211 int tlen;
212 char tokbuf [1500];
213
214 #ifdef OLD_LEXER
215 char comments [4096];
216 int comment_index;
217 #endif
218 int warnings_occurred;
219 int file;
220 char *inbuf;
221 unsigned bufix, buflen;
222 unsigned bufsiz;
223 };
224
225 /* Variable-length array of data. */
226
227 struct string_list {
228 struct string_list *next;
229 char string [1];
230 };
231
232 /* A name server, from /etc/resolv.conf. */
233 struct name_server {
234 struct name_server *next;
235 struct sockaddr_in addr;
236 TIME rcdate;
237 };
238
239 /* A domain search list element. */
240 struct domain_search_list {
241 struct domain_search_list *next;
242 char *domain;
243 TIME rcdate;
244 };
245
246 /* Option tag structures are used to build chains of option tags, for
247 when we're sure we're not going to have enough of them to justify
248 maintaining an array. */
249
250 struct option_tag {
251 struct option_tag *next;
252 u_int8_t data [1];
253 };
254
255 /* An agent option structure. We need a special structure for the
256 Relay Agent Information option because if more than one appears in
257 a message, we have to keep them seperate. */
258
259 struct agent_options {
260 struct agent_options *next;
261 int length;
262 struct option_tag *first;
263 };
264
265 struct option_cache {
266 int refcnt;
267 struct option_cache *next;
268 struct expression *expression;
269 struct option *option;
270 struct data_string data;
271
272 #define OPTION_HAD_NULLS 0x00000001
273 u_int32_t flags;
274 };
275
276 struct option_state {
277 int refcnt;
278 int universe_count;
279 int site_universe;
280 int site_code_min;
281 VOIDPTR universes [1];
282 };
283
284 /* A dhcp packet and the pointers to its option values. */
285 struct packet {
286 struct dhcp_packet *raw;
287 int refcnt;
288 unsigned packet_length;
289 int packet_type;
290 int options_valid;
291 int client_port;
292 struct iaddr client_addr;
293 struct interface_info *interface; /* Interface on which packet
294 was received. */
295 struct hardware *haddr; /* Physical link address
296 of local sender (maybe gateway). */
297
298 /* Information for relay agent options (see
299 draft-ietf-dhc-agent-options-xx.txt). */
300 u_int8_t *circuit_id; /* Circuit ID of client connection. */
301 int circuit_id_len;
302 u_int8_t *remote_id; /* Remote ID of client. */
303 int remote_id_len;
304
305 int got_requested_address; /* True if client sent the
306 dhcp-requested-address option. */
307
308 struct shared_network *shared_network;
309 struct option_state *options;
310
311 #if !defined (PACKET_MAX_CLASSES)
312 # define PACKET_MAX_CLASSES 5
313 #endif
314 int class_count;
315 struct class *classes [PACKET_MAX_CLASSES];
316
317 int known;
318 int authenticated;
319 };
320
321 /* A network interface's MAC address. */
322
323 struct hardware {
324 u_int8_t hlen;
325 u_int8_t hbuf [17];
326 };
327
328 typedef enum {
329 server_startup = 0,
330 server_running = 1,
331 server_shutdown = 2,
332 server_hibernate = 3,
333 server_awaken = 4
334 } control_object_state_t;
335
336 typedef struct {
337 OMAPI_OBJECT_PREAMBLE;
338 control_object_state_t state;
339 } dhcp_control_object_t;
340
341 /* Lease states: */
342 #define FTS_FREE 1
343 #define FTS_ACTIVE 2
344 #define FTS_EXPIRED 3
345 #define FTS_RELEASED 4
346 #define FTS_ABANDONED 5
347 #define FTS_RESET 6
348 #define FTS_BACKUP 7
349 typedef u_int8_t binding_state_t;
350
351 /* FTS_LAST is the highest value that is valid for a lease binding state. */
352 #define FTS_LAST FTS_BACKUP
353
354 /* A dhcp lease declaration structure. */
355 struct lease {
356 OMAPI_OBJECT_PREAMBLE;
357 struct lease *next;
358 struct lease *n_uid, *n_hw;
359
360 struct iaddr ip_addr;
361 TIME starts, ends, timestamp, sort_time;
362 char *client_hostname;
363 struct binding_scope *scope;
364 struct host_decl *host;
365 struct subnet *subnet;
366 struct pool *pool;
367 struct class *billing_class;
368 struct option_chain_head *agent_options;
369
370 struct executable_statement *on_expiry;
371 struct executable_statement *on_commit;
372 struct executable_statement *on_release;
373
374 unsigned char *uid;
375 unsigned short uid_len;
376 unsigned short uid_max;
377 unsigned char uid_buf [7];
378 struct hardware hardware_addr;
379
380 u_int8_t flags;
381 # define STATIC_LEASE 1
382 # define BOOTP_LEASE 2
383 # define RESERVED_LEASE 4
384 # define MS_NULL_TERMINATION 8
385 # define ON_UPDATE_QUEUE 16
386 # define ON_ACK_QUEUE 32
387 # define UNICAST_BROADCAST_HACK 64
388 # define ON_DEFERRED_QUEUE 128
389
390 /* Persistent flags are to be preserved on a given lease structure. */
391 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
392 /* Ephemeral flags are to be preserved on a given lease (copied etc). */
393 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
394 UNICAST_BROADCAST_HACK | \
395 RESERVED_LEASE | \
396 BOOTP_LEASE)
397
398 binding_state_t binding_state;
399 binding_state_t next_binding_state;
400 binding_state_t desired_binding_state;
401
402 struct lease_state *state;
403
404 /* 'tsfp' is more of an 'effective' tsfp. It may be calculated from
405 * stos+mclt for example if it's an expired lease and the server is
406 * in partner-down state. 'atsfp' is zeroed whenever a lease is
407 * updated - and only set when the peer acknowledges it. This
408 * ensures every state change is transmitted.
409 */
410 TIME tstp; /* Time sent to partner. */
411 TIME tsfp; /* Time sent from partner. */
412 TIME atsfp; /* Actual time sent from partner. */
413 TIME cltt; /* Client last transaction time. */
414 u_int32_t last_xid; /* XID we sent in this lease's BNDUPD */
415 struct lease *next_pending;
416 };
417
418 struct lease_state {
419 struct lease_state *next;
420
421 struct interface_info *ip;
422
423 struct packet *packet; /* The incoming packet. */
424
425 TIME offered_expiry;
426
427 struct option_state *options;
428 struct data_string parameter_request_list;
429 int max_message_size;
430 unsigned char expiry[4], renewal[4], rebind[4];
431 struct data_string filename, server_name;
432 int got_requested_address;
433 int got_server_identifier;
434 struct shared_network *shared_network; /* Shared network of interface
435 on which request arrived. */
436
437 u_int32_t xid;
438 u_int16_t secs;
439 u_int16_t bootp_flags;
440 struct in_addr ciaddr;
441 struct in_addr siaddr;
442 struct in_addr giaddr;
443 u_int8_t hops;
444 u_int8_t offer;
445 struct iaddr from;
446 };
447
448 #define ROOT_GROUP 0
449 #define HOST_DECL 1
450 #define SHARED_NET_DECL 2
451 #define SUBNET_DECL 3
452 #define CLASS_DECL 4
453 #define GROUP_DECL 5
454 #define POOL_DECL 6
455
456 /* Possible modes in which discover_interfaces can run. */
457
458 #define DISCOVER_RUNNING 0
459 #define DISCOVER_SERVER 1
460 #define DISCOVER_UNCONFIGURED 2
461 #define DISCOVER_RELAY 3
462 #define DISCOVER_REQUESTED 4
463
464 /* Server option names. */
465
466 #define SV_DEFAULT_LEASE_TIME 1
467 #define SV_MAX_LEASE_TIME 2
468 #define SV_MIN_LEASE_TIME 3
469 #define SV_BOOTP_LEASE_CUTOFF 4
470 #define SV_BOOTP_LEASE_LENGTH 5
471 #define SV_BOOT_UNKNOWN_CLIENTS 6
472 #define SV_DYNAMIC_BOOTP 7
473 #define SV_ALLOW_BOOTP 8
474 #define SV_ALLOW_BOOTING 9
475 #define SV_ONE_LEASE_PER_CLIENT 10
476 #define SV_GET_LEASE_HOSTNAMES 11
477 #define SV_USE_HOST_DECL_NAMES 12
478 #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
479 #define SV_MIN_SECS 14
480 #define SV_FILENAME 15
481 #define SV_SERVER_NAME 16
482 #define SV_NEXT_SERVER 17
483 #define SV_AUTHORITATIVE 18
484 #define SV_VENDOR_OPTION_SPACE 19
485 #define SV_ALWAYS_REPLY_RFC1048 20
486 #define SV_SITE_OPTION_SPACE 21
487 #define SV_ALWAYS_BROADCAST 22
488 #define SV_DDNS_DOMAIN_NAME 23
489 #define SV_DDNS_HOST_NAME 24
490 #define SV_DDNS_REV_DOMAIN_NAME 25
491 #define SV_LEASE_FILE_NAME 26
492 #define SV_PID_FILE_NAME 27
493 #define SV_DUPLICATES 28
494 #define SV_DECLINES 29
495 #define SV_DDNS_UPDATES 30
496 #define SV_OMAPI_PORT 31
497 #define SV_LOCAL_PORT 32
498 #define SV_LIMITED_BROADCAST_ADDRESS 33
499 #define SV_REMOTE_PORT 34
500 #define SV_LOCAL_ADDRESS 35
501 #define SV_OMAPI_KEY 36
502 #define SV_STASH_AGENT_OPTIONS 37
503 #define SV_DDNS_TTL 38
504 #define SV_DDNS_UPDATE_STYLE 39
505 #define SV_CLIENT_UPDATES 40
506 #define SV_UPDATE_OPTIMIZATION 41
507 #define SV_PING_CHECKS 42
508 #define SV_UPDATE_STATIC_LEASES 43
509 #define SV_LOG_FACILITY 44
510 #define SV_DO_FORWARD_UPDATES 45
511 #define SV_PING_TIMEOUT 46
512 #define SV_RESERVE_INFINITE 47
513 #define SV_DDNS_CONFLICT_DETECT 48
514
515 #if !defined (DEFAULT_PING_TIMEOUT)
516 # define DEFAULT_PING_TIMEOUT 1
517 #endif
518
519 #if !defined (DEFAULT_DEFAULT_LEASE_TIME)
520 # define DEFAULT_DEFAULT_LEASE_TIME 43200
521 #endif
522
523 #if !defined (DEFAULT_MIN_LEASE_TIME)
524 # define DEFAULT_MIN_LEASE_TIME 300
525 #endif
526
527 #if !defined (DEFAULT_MAX_LEASE_TIME)
528 # define DEFAULT_MAX_LEASE_TIME 86400
529 #endif
530
531 #if !defined (DEFAULT_DDNS_TTL)
532 # define DEFAULT_DDNS_TTL 3600
533 #endif
534
535 /* Client option names */
536
537 #define CL_TIMEOUT 1
538 #define CL_SELECT_INTERVAL 2
539 #define CL_REBOOT_TIMEOUT 3
540 #define CL_RETRY_INTERVAL 4
541 #define CL_BACKOFF_CUTOFF 5
542 #define CL_INITIAL_INTERVAL 6
543 #define CL_BOOTP_POLICY 7
544 #define CL_SCRIPT_NAME 8
545 #define CL_REQUESTED_OPTIONS 9
546 #define CL_REQUESTED_LEASE_TIME 10
547 #define CL_SEND_OPTIONS 11
548 #define CL_MEDIA 12
549 #define CL_REJECT_LIST 13
550
551 #ifndef CL_DEFAULT_TIMEOUT
552 # define CL_DEFAULT_TIMEOUT 60
553 #endif
554
555 #ifndef CL_DEFAULT_SELECT_INTERVAL
556 # define CL_DEFAULT_SELECT_INTERVAL 0
557 #endif
558
559 #ifndef CL_DEFAULT_REBOOT_TIMEOUT
560 # define CL_DEFAULT_REBOOT_TIMEOUT 10
561 #endif
562
563 #ifndef CL_DEFAULT_RETRY_INTERVAL
564 # define CL_DEFAULT_RETRY_INTERVAL 300
565 #endif
566
567 #ifndef CL_DEFAULT_BACKOFF_CUTOFF
568 # define CL_DEFAULT_BACKOFF_CUTOFF 120
569 #endif
570
571 #ifndef CL_DEFAULT_INITIAL_INTERVAL
572 # define CL_DEFAULT_INITIAL_INTERVAL 10
573 #endif
574
575 #ifndef CL_DEFAULT_BOOTP_POLICY
576 # define CL_DEFAULT_BOOTP_POLICY P_ACCEPT
577 #endif
578
579 #ifndef CL_DEFAULT_REQUESTED_OPTIONS
580 # define CL_DEFAULT_REQUESTED_OPTIONS \
581 { DHO_SUBNET_MASK, \
582 DHO_BROADCAST_ADDRESS, \
583 DHO_TIME_OFFSET, \
584 DHO_ROUTERS, \
585 DHO_DOMAIN_NAME, \
586 DHO_DOMAIN_NAME_SERVERS, \
587 DHO_HOST_NAME }
588 #endif
589
590 struct group_object {
591 OMAPI_OBJECT_PREAMBLE;
592
593 struct group_object *n_dynamic;
594 struct group *group;
595 char *name;
596 int flags;
597 #define GROUP_OBJECT_DELETED 1
598 #define GROUP_OBJECT_DYNAMIC 2
599 #define GROUP_OBJECT_STATIC 4
600 };
601
602 /* Group of declarations that share common parameters. */
603 struct group {
604 struct group *next;
605
606 int refcnt;
607 struct group_object *object;
608 struct subnet *subnet;
609 struct shared_network *shared_network;
610 int authoritative;
611 struct executable_statement *statements;
612 };
613
614 /* A dhcp host declaration structure. */
615 struct host_decl {
616 OMAPI_OBJECT_PREAMBLE;
617 struct host_decl *n_ipaddr;
618 struct host_decl *n_dynamic;
619 char *name;
620 struct hardware interface;
621 struct data_string client_identifier;
622 struct option_cache *fixed_addr;
623 struct group *group;
624 struct group_object *named_group;
625 struct data_string auth_key_id;
626 int flags;
627 #define HOST_DECL_DELETED 1
628 #define HOST_DECL_DYNAMIC 2
629 #define HOST_DECL_STATIC 4
630 };
631
632 struct permit {
633 struct permit *next;
634 enum {
635 permit_unknown_clients,
636 permit_known_clients,
637 permit_authenticated_clients,
638 permit_unauthenticated_clients,
639 permit_all_clients,
640 permit_dynamic_bootp_clients,
641 permit_class
642 } type;
643 struct class *class;
644 };
645
646 struct pool {
647 OMAPI_OBJECT_PREAMBLE;
648 struct pool *next;
649 struct group *group;
650 struct shared_network *shared_network;
651 struct permit *permit_list;
652 struct permit *prohibit_list;
653 struct lease *active;
654 struct lease *expired;
655 struct lease *free;
656 struct lease *backup;
657 struct lease *abandoned;
658 struct lease *reserved;
659 TIME next_event_time;
660 int lease_count;
661 int free_leases;
662 int backup_leases;
663 int index;
664 #if defined (FAILOVER_PROTOCOL)
665 dhcp_failover_state_t *failover_peer;
666 #endif
667 };
668
669 struct shared_network {
670 OMAPI_OBJECT_PREAMBLE;
671 struct shared_network *next;
672 char *name;
673 struct subnet *subnets;
674 struct interface_info *interface;
675 struct pool *pools;
676 struct group *group;
677 #if defined (FAILOVER_PROTOCOL)
678 dhcp_failover_state_t *failover_peer;
679 #endif
680 };
681
682 struct subnet {
683 OMAPI_OBJECT_PREAMBLE;
684 struct subnet *next_subnet;
685 struct subnet *next_sibling;
686 struct shared_network *shared_network;
687 struct interface_info *interface;
688 struct iaddr interface_address;
689 struct iaddr net;
690 struct iaddr netmask;
691
692 struct group *group;
693 };
694
695 struct collection {
696 struct collection *next;
697
698 const char *name;
699 struct class *classes;
700 };
701
702 /* Used as an argument to parse_clasS_decl() */
703 #define CLASS_TYPE_VENDOR 0
704 #define CLASS_TYPE_USER 1
705 #define CLASS_TYPE_CLASS 2
706 #define CLASS_TYPE_SUBCLASS 3
707
708 /* XXX classes must be reference-counted. */
709 struct class {
710 OMAPI_OBJECT_PREAMBLE;
711 struct class *nic; /* Next in collection. */
712 struct class *superclass; /* Set for spawned classes only. */
713 char *name; /* Not set for spawned classes. */
714
715 /* A class may be configured to permit a limited number of leases. */
716 int lease_limit;
717 int leases_consumed;
718 struct lease **billed_leases;
719
720 /* If nonzero, class has not been saved since it was last
721 modified. */
722 int dirty;
723
724 /* Hash table containing subclasses. */
725 class_hash_t *hash;
726 struct data_string hash_string;
727
728 /* Expression used to match class. */
729 struct expression *expr;
730
731 /* Expression used to compute subclass identifiers for spawning
732 and to do subclass matching. */
733 struct expression *submatch;
734 int spawning;
735
736 struct group *group;
737
738 /* Statements to execute if class matches. */
739 struct executable_statement *statements;
740
741 #define CLASS_DECL_DELETED 1
742 #define CLASS_DECL_DYNAMIC 2
743 #define CLASS_DECL_STATIC 4
744 #define CLASS_DECL_SUBCLASS 8
745
746 int flags;
747 };
748
749 /* DHCP client lease structure... */
750 struct client_lease {
751 struct client_lease *next; /* Next lease in list. */
752 TIME expiry, renewal, rebind; /* Lease timeouts. */
753 struct iaddr address; /* Address being leased. */
754 char *server_name; /* Name of boot server. */
755 char *filename; /* Name of file we're supposed to boot. */
756 struct string_list *medium; /* Network medium. */
757 struct auth_key *key; /* Key used in basic DHCP authentication. */
758
759 unsigned int is_static : 1; /* If set, lease is from config file. */
760 unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
761
762 struct option_state *options; /* Options supplied with lease. */
763 };
764
765 /* Possible states in which the client can be. */
766 enum dhcp_state {
767 S_REBOOTING = 1,
768 S_INIT = 2,
769 S_SELECTING = 3,
770 S_REQUESTING = 4,
771 S_BOUND = 5,
772 S_RENEWING = 6,
773 S_REBINDING = 7,
774 S_STOPPED = 8
775 };
776
777 /* Authentication and BOOTP policy possibilities (not all values work
778 for each). */
779 enum policy { P_IGNORE, P_ACCEPT, P_PREFER, P_REQUIRE, P_DONT };
780
781 /* Configuration information from the config file... */
782 struct client_config {
783 /*
784 * When a message has been received, run these statements
785 * over it.
786 */
787 struct group *on_receipt;
788
789 /*
790 * When a message is sent, run these statements.
791 */
792 struct group *on_transmission;
793
794 u_int32_t *required_options; /* Options server must supply. */
795 u_int32_t *requested_options; /* Options to request from server. */
796
797 TIME timeout; /* Start to panic if we don't get a
798 lease in this time period when
799 SELECTING. */
800 TIME initial_interval; /* All exponential backoff intervals
801 start here. */
802 TIME retry_interval; /* If the protocol failed to produce
803 an address before the timeout,
804 try the protocol again after this
805 many seconds. */
806 TIME select_interval; /* Wait this many seconds from the
807 first DHCPDISCOVER before
808 picking an offered lease. */
809 TIME reboot_timeout; /* When in INIT-REBOOT, wait this
810 long before giving up and going
811 to INIT. */
812 TIME backoff_cutoff; /* When doing exponential backoff,
813 never back off to an interval
814 longer than this amount. */
815 u_int32_t requested_lease; /* Requested lease time, if user
816 doesn't configure one. */
817 struct string_list *media; /* Possible network media values. */
818 char *script_name; /* Name of config script. */
819 char *vendor_space_name; /* Name of config script. */
820 enum policy bootp_policy;
821 /* Ignore, accept or prefer BOOTP
822 responses. */
823 enum policy auth_policy;
824 /* Require authentication, prefer
825 authentication, or don't try to
826 authenticate. */
827 struct string_list *medium; /* Current network medium. */
828
829 struct iaddrmatchlist *reject_list; /* Servers to reject. */
830
831 int omapi_port; /* port on which to accept OMAPI
832 connections, or -1 for no
833 listener. */
834 int do_forward_update; /* If nonzero, and if we have the
835 information we need, update the
836 A record for the address we get. */
837 };
838
839 /* Per-interface state used in the dhcp client... */
840 struct client_state {
841 struct client_state *next;
842 struct interface_info *interface;
843 char *name;
844
845 struct client_lease *active; /* Currently active lease. */
846 struct client_lease *new; /* New lease. */
847 struct client_lease *offered_leases; /* Leases offered to us. */
848 struct client_lease *leases; /* Leases we currently hold. */
849 struct client_lease *alias; /* Alias lease. */
850
851 enum dhcp_state state; /* Current state for this interface. */
852 struct iaddr destination; /* Where to send packet. */
853 u_int32_t xid; /* Transaction ID. */
854 u_int16_t secs; /* secs value from DHCPDISCOVER. */
855 TIME first_sending; /* When was first copy sent? */
856 TIME interval; /* What's the current resend interval? */
857 int dns_update_timeout; /* Last timeout set for DNS update. */
858 struct string_list *medium; /* Last media type tried. */
859 struct dhcp_packet packet; /* Outgoing DHCP packet. */
860 unsigned packet_length; /* Actual length of generated packet. */
861
862 struct iaddr requested_address; /* Address we would like to get. */
863
864 struct client_config *config; /* Client configuration. */
865 struct string_list *env; /* Client script environment. */
866 int envc; /* Number of entries in environment. */
867
868 struct option_state *sent_options; /* Options we sent. */
869 };
870
871 /* Relay agent server list. */
872 struct server_list {
873 struct server_list *next;
874 struct sockaddr_in to;
875 } *servers;
876
877 /* Information about each network interface. */
878
879 struct interface_info {
880 OMAPI_OBJECT_PREAMBLE;
881 struct interface_info *next; /* Next interface in list... */
882 struct shared_network *shared_network;
883 /* Networks connected to this interface. */
884 struct hardware hw_address; /* Its physical address. */
885 struct in_addr *addresses; /* Addresses associated with
886 interface. */
887 int address_count; /* Number of addresses associated with
888 interface. */
889 int address_max; /* Max number of addresses we can
890 store in current buffer. */
891
892 u_int8_t *circuit_id; /* Circuit ID associated with this
893 interface. */
894 unsigned circuit_id_len; /* Length of Circuit ID, if there
895 is one. */
896 u_int8_t *remote_id; /* Remote ID associated with this
897 interface (if any). */
898 unsigned remote_id_len; /* Length of Remote ID. */
899 struct server_list *servers; /* List of relay servers for this
900 interface. */
901
902 char name [IFNAMSIZ]; /* Its name... */
903 int index; /* Its index. */
904 int rfdesc; /* Its read file descriptor. */
905 int wfdesc; /* Its write file descriptor, if
906 different. */
907 unsigned char *rbuf; /* Read buffer, if required. */
908 unsigned int rbuf_max; /* Size of read buffer. */
909 size_t rbuf_offset; /* Current offset into buffer. */
910 size_t rbuf_len; /* Length of data in buffer. */
911
912 struct ifreq *ifp; /* Pointer to ifreq struct. */
913 int configured; /* If set to 1, interface has at
914 * least one valid IP address.
915 */
916 u_int32_t flags; /* Control flags... */
917 #define INTERFACE_REQUESTED 1
918 #define INTERFACE_AUTOMATIC 2
919 #define INTERFACE_RUNNING 4
920
921 /* Only used by DHCP client code. */
922 struct client_state *client;
923 # if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
924 int dlpi_sap_length;
925 struct hardware dlpi_broadcast_addr;
926 # endif /* DLPI_SEND || DLPI_RECEIVE */
927 };
928
929 struct hardware_link {
930 struct hardware_link *next;
931 char name [IFNAMSIZ];
932 struct hardware address;
933 };
934
935 typedef void (*tvref_t)(void *, void *, const char *, int);
936 typedef void (*tvunref_t)(void *, const char *, int);
937 struct timeout {
938 struct timeout *next;
939 TIME when;
940 void (*func) PROTO ((void *));
941 void *what;
942 tvref_t ref;
943 tvunref_t unref;
944 };
945
946 struct protocol {
947 struct protocol *next;
948 int fd;
949 void (*handler) PROTO ((struct protocol *));
950 void *local;
951 };
952
953 struct dns_query; /* forward */
954
955 struct dns_wakeup {
956 struct dns_wakeup *next; /* Next wakeup in chain. */
957 void (*func) PROTO ((struct dns_query *));
958 };
959
960 struct dns_question {
961 u_int16_t type; /* Type of query. */
962 u_int16_t class; /* Class of query. */
963 unsigned char data [1]; /* Query data. */
964 };
965
966 struct dns_answer {
967 u_int16_t type; /* Type of answer. */
968 u_int16_t class; /* Class of answer. */
969 int count; /* Number of answers. */
970 unsigned char *answers[1]; /* Pointers to answers. */
971 };
972
973 struct dns_query {
974 struct dns_query *next; /* Next query in hash bucket. */
975 u_int32_t hash; /* Hash bucket index. */
976 TIME expiry; /* Query expiry time (zero if not yet
977 answered. */
978 u_int16_t id; /* Query ID (also hash table index) */
979 caddr_t waiters; /* Pointer to list of things waiting
980 on this query. */
981
982 struct dns_question *question; /* Question, internal format. */
983 struct dns_answer *answer; /* Answer, internal format. */
984
985 unsigned char *query; /* Query formatted for DNS server. */
986 unsigned len; /* Length of entire query. */
987 int sent; /* The query has been sent. */
988 struct dns_wakeup *wakeups; /* Wakeups to call if this query is
989 answered. */
990 struct name_server *next_server; /* Next server to try. */
991 int backoff; /* Current backoff, in seconds. */
992 };
993
994 struct dns_zone {
995 int refcnt;
996 TIME timeout;
997 char *name;
998 struct option_cache *primary;
999 struct option_cache *secondary;
1000 struct auth_key *key;
1001 };
1002
1003 struct icmp_state {
1004 OMAPI_OBJECT_PREAMBLE;
1005 int socket;
1006 void (*icmp_handler) PROTO ((struct iaddr, u_int8_t *, int));
1007 };
1008
1009 #include "ctrace.h"
1010
1011 /* Bitmask of dhcp option codes. */
1012 typedef unsigned char option_mask [16];
1013
1014 /* DHCP Option mask manipulation macros... */
1015 #define OPTION_ZERO(mask) (memset (mask, 0, 16))
1016 #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
1017 #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
1018 #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
1019 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
1020
1021 /* An option occupies its length plus two header bytes (code and
1022 length) for every 255 bytes that must be stored. */
1023 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
1024
1025 /* Default path to dhcpd config file. */
1026 #ifdef DEBUG
1027 #undef _PATH_DHCPD_CONF
1028 #define _PATH_DHCPD_CONF "dhcpd.conf"
1029 #undef _PATH_DHCPD_DB
1030 #define _PATH_DHCPD_DB "dhcpd.leases"
1031 #undef _PATH_DHCPD_PID
1032 #define _PATH_DHCPD_PID "dhcpd.pid"
1033 #else
1034 #ifndef _PATH_DHCPD_CONF
1035 #define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
1036 #endif
1037
1038 #ifndef _PATH_DHCPD_DB
1039 #define _PATH_DHCPD_DB "/etc/dhcpd.leases"
1040 #endif
1041
1042 #ifndef _PATH_DHCPD_PID
1043 #define _PATH_DHCPD_PID "/var/run/dhcpd.pid"
1044 #endif
1045 #endif
1046
1047 #ifndef _PATH_DHCLIENT_CONF
1048 #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
1049 #endif
1050
1051 #ifndef _PATH_DHCLIENT_SCRIPT
1052 #define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script"
1053 #endif
1054
1055 #ifndef _PATH_DHCLIENT_PID
1056 #define _PATH_DHCLIENT_PID "/var/run/dhclient.pid"
1057 #endif
1058
1059 #ifndef _PATH_DHCLIENT_DB
1060 #define _PATH_DHCLIENT_DB "/etc/dhclient.leases"
1061 #endif
1062
1063 #ifndef _PATH_RESOLV_CONF
1064 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
1065 #endif
1066
1067 #ifndef _PATH_DHCRELAY_PID
1068 #define _PATH_DHCRELAY_PID "/var/run/dhcrelay.pid"
1069 #endif
1070
1071 #ifndef DHCPD_LOG_FACILITY
1072 #define DHCPD_LOG_FACILITY LOG_DAEMON
1073 #endif
1074
1075 #define MAX_TIME 0x7fffffff
1076 #define MIN_TIME 0
1077
1078 /* External definitions... */
1079
1080 HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t)
1081 HASH_FUNCTIONS_DECL (universe, const char *, struct universe, universe_hash_t)
1082 HASH_FUNCTIONS_DECL (option_name, const char *, struct option,
1083 option_name_hash_t)
1084 HASH_FUNCTIONS_DECL (option_code, const unsigned *, struct option,
1085 option_code_hash_t)
1086 HASH_FUNCTIONS_DECL (dns_zone, const char *, struct dns_zone, dns_zone_hash_t)
1087 HASH_FUNCTIONS_DECL (lease, const unsigned char *, struct lease, lease_hash_t)
1088 HASH_FUNCTIONS_DECL (host, const unsigned char *, struct host_decl, host_hash_t)
1089 HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t)
1090
1091 /* options.c */
1092
1093 extern struct option *vendor_cfg_option;
1094 int parse_options PROTO ((struct packet *));
1095 int parse_option_buffer PROTO ((struct option_state *, const unsigned char *,
1096 unsigned, struct universe *));
1097 struct universe *find_option_universe (struct option *, const char *);
1098 int parse_encapsulated_suboptions (struct option_state *, struct option *,
1099 const unsigned char *, unsigned,
1100 struct universe *, const char *);
1101 int cons_options PROTO ((struct packet *, struct dhcp_packet *, struct lease *,
1102 struct client_state *,
1103 int, struct option_state *, struct option_state *,
1104 struct binding_scope **,
1105 int, int, int, struct data_string *, const char *));
1106 int fqdn_universe_decode (struct option_state *,
1107 const unsigned char *, unsigned, struct universe *);
1108 int store_options PROTO ((int *, unsigned char *, unsigned, struct packet *,
1109 struct lease *, struct client_state *,
1110 struct option_state *,
1111 struct option_state *, struct binding_scope **,
1112 unsigned *, int, unsigned, unsigned,
1113 int, const char *));
1114 int format_has_text(const char *);
1115 int format_min_length(const char *, struct option_cache *);
1116 const char *pretty_print_option PROTO ((struct option *, const unsigned char *,
1117 unsigned, int, int));
1118 int get_option (struct data_string *, struct universe *,
1119 struct packet *, struct lease *, struct client_state *,
1120 struct option_state *, struct option_state *,
1121 struct option_state *, struct binding_scope **, unsigned,
1122 const char *, int);
1123 void set_option (struct universe *, struct option_state *,
1124 struct option_cache *, enum statement_op);
1125 struct option_cache *lookup_option PROTO ((struct universe *,
1126 struct option_state *, unsigned));
1127 struct option_cache *lookup_hashed_option PROTO ((struct universe *,
1128 struct option_state *,
1129 unsigned));
1130 int save_option_buffer (struct universe *, struct option_state *,
1131 struct buffer *, unsigned char *, unsigned,
1132 unsigned, int);
1133 void save_option PROTO ((struct universe *,
1134 struct option_state *, struct option_cache *));
1135 void save_hashed_option PROTO ((struct universe *,
1136 struct option_state *, struct option_cache *));
1137 void delete_option PROTO ((struct universe *, struct option_state *, int));
1138 void delete_hashed_option PROTO ((struct universe *,
1139 struct option_state *, int));
1140 int option_cache_dereference PROTO ((struct option_cache **,
1141 const char *, int));
1142 int hashed_option_state_dereference PROTO ((struct universe *,
1143 struct option_state *,
1144 const char *, int));
1145 int store_option PROTO ((struct data_string *,
1146 struct universe *, struct packet *, struct lease *,
1147 struct client_state *,
1148 struct option_state *, struct option_state *,
1149 struct binding_scope **, struct option_cache *));
1150 int option_space_encapsulate PROTO ((struct data_string *,
1151 struct packet *, struct lease *,
1152 struct client_state *,
1153 struct option_state *,
1154 struct option_state *,
1155 struct binding_scope **,
1156 struct data_string *));
1157 int hashed_option_space_encapsulate PROTO ((struct data_string *,
1158 struct packet *, struct lease *,
1159 struct client_state *,
1160 struct option_state *,
1161 struct option_state *,
1162 struct binding_scope **,
1163 struct universe *));
1164 int nwip_option_space_encapsulate PROTO ((struct data_string *,
1165 struct packet *, struct lease *,
1166 struct client_state *,
1167 struct option_state *,
1168 struct option_state *,
1169 struct binding_scope **,
1170 struct universe *));
1171 int fqdn_option_space_encapsulate (struct data_string *,
1172 struct packet *, struct lease *,
1173 struct client_state *,
1174 struct option_state *,
1175 struct option_state *,
1176 struct binding_scope **,
1177 struct universe *);
1178 void suboption_foreach (struct packet *, struct lease *, struct client_state *,
1179 struct option_state *, struct option_state *,
1180 struct binding_scope **, struct universe *, void *,
1181 void (*) (struct option_cache *, struct packet *,
1182 struct lease *, struct client_state *,
1183 struct option_state *, struct option_state *,
1184 struct binding_scope **,
1185 struct universe *, void *),
1186 struct option_cache *, const char *);
1187 void option_space_foreach (struct packet *, struct lease *,
1188 struct client_state *,
1189 struct option_state *,
1190 struct option_state *,
1191 struct binding_scope **,
1192 struct universe *, void *,
1193 void (*) (struct option_cache *,
1194 struct packet *,
1195 struct lease *, struct client_state *,
1196 struct option_state *,
1197 struct option_state *,
1198 struct binding_scope **,
1199 struct universe *, void *));
1200 void hashed_option_space_foreach (struct packet *, struct lease *,
1201 struct client_state *,
1202 struct option_state *,
1203 struct option_state *,
1204 struct binding_scope **,
1205 struct universe *, void *,
1206 void (*) (struct option_cache *,
1207 struct packet *,
1208 struct lease *,
1209 struct client_state *,
1210 struct option_state *,
1211 struct option_state *,
1212 struct binding_scope **,
1213 struct universe *, void *));
1214 int linked_option_get PROTO ((struct data_string *, struct universe *,
1215 struct packet *, struct lease *,
1216 struct client_state *,
1217 struct option_state *, struct option_state *,
1218 struct option_state *, struct binding_scope **,
1219 unsigned));
1220 int linked_option_state_dereference PROTO ((struct universe *,
1221 struct option_state *,
1222 const char *, int));
1223 void save_linked_option (struct universe *, struct option_state *,
1224 struct option_cache *);
1225 void linked_option_space_foreach (struct packet *, struct lease *,
1226 struct client_state *,
1227 struct option_state *,
1228 struct option_state *,
1229 struct binding_scope **,
1230 struct universe *, void *,
1231 void (*) (struct option_cache *,
1232 struct packet *,
1233 struct lease *,
1234 struct client_state *,
1235 struct option_state *,
1236 struct option_state *,
1237 struct binding_scope **,
1238 struct universe *, void *));
1239 int linked_option_space_encapsulate (struct data_string *, struct packet *,
1240 struct lease *, struct client_state *,
1241 struct option_state *,
1242 struct option_state *,
1243 struct binding_scope **,
1244 struct universe *);
1245 void delete_linked_option (struct universe *, struct option_state *, int);
1246 struct option_cache *lookup_linked_option (struct universe *,
1247 struct option_state *, unsigned);
1248 void do_packet PROTO ((struct interface_info *,
1249 struct dhcp_packet *, unsigned,
1250 unsigned int, struct iaddr, struct hardware *));
1251
1252 /* dhcpd.c */
1253 extern TIME cur_time;
1254
1255 int ddns_update_style;
1256
1257 extern const char *path_dhcpd_conf;
1258 extern const char *path_dhcpd_db;
1259 extern const char *path_dhcpd_pid;
1260
1261 extern int dhcp_max_agent_option_packet_length;
1262
1263 int main PROTO ((int, char **, char **));
1264 void postconf_initialization (int);
1265 void postdb_startup (void);
1266 void cleanup PROTO ((void));
1267 void lease_pinged PROTO ((struct iaddr, u_int8_t *, int));
1268 void lease_ping_timeout PROTO ((void *));
1269 int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia);
1270 enum dhcp_shutdown_state shutdown_state;
1271 isc_result_t dhcp_io_shutdown (omapi_object_t *, void *);
1272 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
1273 control_object_state_t newstate);
1274
1275 /* conflex.c */
1276 isc_result_t new_parse PROTO ((struct parse **, int,
1277 char *, unsigned, const char *, int));
1278 isc_result_t end_parse PROTO ((struct parse **));
1279 enum dhcp_token next_token PROTO ((const char **, unsigned *, struct parse *));
1280 enum dhcp_token peek_token PROTO ((const char **, unsigned *, struct parse *));
1281
1282 /* confpars.c */
1283 void parse_trace_setup (void);
1284 isc_result_t readconf PROTO ((void));
1285 isc_result_t read_conf_file (const char *, struct group *, int, int);
1286 #if defined (TRACING)
1287 void trace_conf_input (trace_type_t *, unsigned, char *);
1288 void trace_conf_stop (trace_type_t *ttype);
1289 #endif
1290 isc_result_t conf_file_subparse (struct parse *, struct group *, int);
1291 isc_result_t lease_file_subparse (struct parse *);
1292 int parse_statement PROTO ((struct parse *,
1293 struct group *, int, struct host_decl *, int));
1294 #if defined (FAILOVER_PROTOCOL)
1295 void parse_failover_peer PROTO ((struct parse *, struct group *, int));
1296 void parse_failover_state_declaration (struct parse *,
1297 dhcp_failover_state_t *);
1298 void parse_failover_state PROTO ((struct parse *,
1299 enum failover_state *, TIME *));
1300 #endif
1301 int permit_list_match (struct permit *, struct permit *);
1302 void parse_pool_statement PROTO ((struct parse *, struct group *, int));
1303 int parse_boolean PROTO ((struct parse *));
1304 int parse_lbrace PROTO ((struct parse *));
1305 void parse_host_declaration PROTO ((struct parse *, struct group *));
1306 int parse_class_declaration PROTO ((struct class **, struct parse *,
1307 struct group *, int));
1308 void parse_shared_net_declaration PROTO ((struct parse *, struct group *));
1309 void parse_subnet_declaration PROTO ((struct parse *,
1310 struct shared_network *));
1311 void parse_group_declaration PROTO ((struct parse *, struct group *));
1312 int parse_fixed_addr_param PROTO ((struct option_cache **, struct parse *));
1313 TIME parse_timestamp PROTO ((struct parse *));
1314 int parse_lease_declaration PROTO ((struct lease **, struct parse *));
1315 void parse_address_range PROTO ((struct parse *, struct group *, int,
1316 struct pool *, struct lease **));
1317
1318 /* ddns.c */
1319 int ddns_updates PROTO ((struct packet *, struct lease *, struct lease *,
1320 struct lease_state *));
1321 int ddns_removals PROTO ((struct lease *));
1322
1323 /* parse.c */
1324 void add_enumeration (struct enumeration *);
1325 struct enumeration *find_enumeration (const char *, int);
1326 struct enumeration_value *find_enumeration_value (const char *, int,
1327 const char *);
1328 void skip_to_semi PROTO ((struct parse *));
1329 void skip_to_rbrace PROTO ((struct parse *, int));
1330 int parse_semi PROTO ((struct parse *));
1331 int parse_string PROTO ((struct parse *, char **, unsigned *));
1332 char *parse_host_name PROTO ((struct parse *));
1333 int parse_ip_addr_or_hostname PROTO ((struct expression **,
1334 struct parse *, int));
1335 void parse_hardware_param PROTO ((struct parse *, struct hardware *));
1336 void parse_lease_time PROTO ((struct parse *, TIME *));
1337 unsigned char *parse_numeric_aggregate PROTO ((struct parse *,
1338 unsigned char *, unsigned *,
1339 int, int, unsigned));
1340 void convert_num PROTO ((struct parse *, unsigned char *, const char *,
1341 int, unsigned));
1342 TIME parse_date PROTO ((struct parse *));
1343 isc_result_t parse_option_name PROTO ((struct parse *, int, int *,
1344 struct option **));
1345 void parse_option_space_decl PROTO ((struct parse *));
1346 int parse_option_code_definition PROTO ((struct parse *, struct option *));
1347 int parse_base64 (struct data_string *, struct parse *);
1348 int parse_cshl PROTO ((struct data_string *, struct parse *));
1349 int parse_executable_statement PROTO ((struct executable_statement **,
1350 struct parse *, int *,
1351 enum expression_context));
1352 int parse_executable_statements PROTO ((struct executable_statement **,
1353 struct parse *, int *,
1354 enum expression_context));
1355 int parse_zone (struct dns_zone *, struct parse *);
1356 int parse_key (struct parse *);
1357 int parse_on_statement PROTO ((struct executable_statement **,
1358 struct parse *, int *));
1359 int parse_switch_statement PROTO ((struct executable_statement **,
1360 struct parse *, int *));
1361 int parse_case_statement PROTO ((struct executable_statement **,
1362 struct parse *, int *,
1363 enum expression_context));
1364 int parse_if_statement PROTO ((struct executable_statement **,
1365 struct parse *, int *));
1366 int parse_boolean_expression PROTO ((struct expression **,
1367 struct parse *, int *));
1368 int parse_data_expression PROTO ((struct expression **,
1369 struct parse *, int *));
1370 int parse_numeric_expression PROTO ((struct expression **,
1371 struct parse *, int *));
1372 int parse_dns_expression PROTO ((struct expression **, struct parse *, int *));
1373 int parse_non_binary PROTO ((struct expression **, struct parse *, int *,
1374 enum expression_context));
1375 int parse_expression PROTO ((struct expression **, struct parse *, int *,
1376 enum expression_context,
1377 struct expression **, enum expr_op));
1378 int parse_option_statement PROTO ((struct executable_statement **,
1379 struct parse *, int,
1380 struct option *, enum statement_op));
1381 int parse_option_token PROTO ((struct expression **, struct parse *,
1382 const char **, struct expression *, int, int));
1383 int parse_allow_deny PROTO ((struct option_cache **, struct parse *, int));
1384 int parse_auth_key PROTO ((struct data_string *, struct parse *));
1385 int parse_warn (struct parse *, const char *, ...)
1386 __attribute__((__format__(__printf__,2,3)));
1387 struct expression *parse_domain_list (struct parse *cfile);
1388
1389
1390 /* tree.c */
1391 #if defined (NSUPDATE)
1392 extern struct __res_state resolver_state;
1393 extern int resolver_inited;
1394 #endif
1395
1396 extern struct binding_scope *global_scope;
1397 pair cons PROTO ((caddr_t, pair));
1398 int make_const_option_cache PROTO ((struct option_cache **, struct buffer **,
1399 u_int8_t *, unsigned, struct option *,
1400 const char *, int));
1401 int make_host_lookup PROTO ((struct expression **, const char *));
1402 int enter_dns_host PROTO ((struct dns_host_entry **, const char *));
1403 int make_const_data (struct expression **,
1404 const unsigned char *, unsigned, int, int,
1405 const char *, int);
1406 int make_const_int PROTO ((struct expression **, unsigned long));
1407 int make_concat PROTO ((struct expression **,
1408 struct expression *, struct expression *));
1409 int make_encapsulation PROTO ((struct expression **, struct data_string *));
1410 int make_substring PROTO ((struct expression **, struct expression *,
1411 struct expression *, struct expression *));
1412 int make_limit PROTO ((struct expression **, struct expression *, int));
1413 int make_let PROTO ((struct executable_statement **, const char *));
1414 int option_cache PROTO ((struct option_cache **, struct data_string *,
1415 struct expression *, struct option *,
1416 const char *, int));
1417 int evaluate_expression (struct binding_value **, struct packet *,
1418 struct lease *, struct client_state *,
1419 struct option_state *, struct option_state *,
1420 struct binding_scope **, struct expression *,
1421 const char *, int);
1422 int binding_value_dereference (struct binding_value **, const char *, int);
1423 #if defined (NSUPDATE)
1424 int evaluate_dns_expression PROTO ((ns_updrec **, struct packet *,
1425 struct lease *,
1426 struct client_state *,
1427 struct option_state *,
1428 struct option_state *,
1429 struct binding_scope **,
1430 struct expression *));
1431 #endif
1432 int evaluate_boolean_expression PROTO ((int *,
1433 struct packet *, struct lease *,
1434 struct client_state *,
1435 struct option_state *,
1436 struct option_state *,
1437 struct binding_scope **,
1438 struct expression *));
1439 int evaluate_data_expression PROTO ((struct data_string *,
1440 struct packet *, struct lease *,
1441 struct client_state *,
1442 struct option_state *,
1443 struct option_state *,
1444 struct binding_scope **,
1445 struct expression *, const char *, int));
1446 int evaluate_numeric_expression (unsigned long *, struct packet *,
1447 struct lease *, struct client_state *,
1448 struct option_state *, struct option_state *,
1449 struct binding_scope **,
1450 struct expression *);
1451 int evaluate_option_cache PROTO ((struct data_string *,
1452 struct packet *, struct lease *,
1453 struct client_state *,
1454 struct option_state *, struct option_state *,
1455 struct binding_scope **,
1456 struct option_cache *,
1457 const char *, int));
1458 int evaluate_boolean_option_cache PROTO ((int *,
1459 struct packet *, struct lease *,
1460 struct client_state *,
1461 struct option_state *,
1462 struct option_state *,
1463 struct binding_scope **,
1464 struct option_cache *,
1465 const char *, int));
1466 int evaluate_boolean_expression_result PROTO ((int *,
1467 struct packet *, struct lease *,
1468 struct client_state *,
1469 struct option_state *,
1470 struct option_state *,
1471 struct binding_scope **,
1472 struct expression *));
1473 void expression_dereference PROTO ((struct expression **, const char *, int));
1474 int is_dns_expression PROTO ((struct expression *));
1475 int is_boolean_expression PROTO ((struct expression *));
1476 int is_data_expression PROTO ((struct expression *));
1477 int is_numeric_expression PROTO ((struct expression *));
1478 int is_compound_expression PROTO ((struct expression *));
1479 int op_precedence PROTO ((enum expr_op, enum expr_op));
1480 enum expression_context expression_context (struct expression *);
1481 enum expression_context op_context PROTO ((enum expr_op));
1482 int write_expression PROTO ((FILE *, struct expression *, int, int, int));
1483 struct binding *find_binding PROTO ((struct binding_scope *, const char *));
1484 int free_bindings PROTO ((struct binding_scope *, const char *, int));
1485 int binding_scope_dereference PROTO ((struct binding_scope **,
1486 const char *, int));
1487 int fundef_dereference (struct fundef **, const char *, int);
1488 int data_subexpression_length (int *, struct expression *);
1489 int expr_valid_for_context (struct expression *, enum expression_context);
1490 struct binding *create_binding (struct binding_scope **, const char *);
1491 int bind_ds_value (struct binding_scope **,
1492 const char *, struct data_string *);
1493 int find_bound_string (struct data_string *,
1494 struct binding_scope *, const char *);
1495 int unset (struct binding_scope *, const char *);
1496
1497 /* dhcp.c */
1498 extern int outstanding_pings;
1499
1500 void dhcp PROTO ((struct packet *));
1501 void dhcpdiscover PROTO ((struct packet *, int));
1502 void dhcprequest PROTO ((struct packet *, int, struct lease *));
1503 void dhcprelease PROTO ((struct packet *, int));
1504 void dhcpdecline PROTO ((struct packet *, int));
1505 void dhcpinform PROTO ((struct packet *, int));
1506 void nak_lease PROTO ((struct packet *, struct iaddr *cip));
1507 void ack_lease PROTO ((struct packet *, struct lease *,
1508 unsigned int, TIME, char *, int, struct host_decl *));
1509 void dhcp_reply PROTO ((struct lease *));
1510 int find_lease PROTO ((struct lease **, struct packet *,
1511 struct shared_network *, int *, int *, struct lease *,
1512 const char *, int));
1513 int mockup_lease PROTO ((struct lease **, struct packet *,
1514 struct shared_network *,
1515 struct host_decl *));
1516 void static_lease_dereference PROTO ((struct lease *, const char *, int));
1517
1518 int allocate_lease PROTO ((struct lease **, struct packet *,
1519 struct pool *, int *));
1520 int permitted PROTO ((struct packet *, struct permit *));
1521 int locate_network PROTO ((struct packet *));
1522 int parse_agent_information_option PROTO ((struct packet *, int, u_int8_t *));
1523 unsigned cons_agent_information_options PROTO ((struct option_state *,
1524 struct dhcp_packet *,
1525 unsigned, unsigned));
1526
1527 /* bootp.c */
1528 void bootp PROTO ((struct packet *));
1529
1530 /* memory.c */
1531 int (*group_write_hook) (struct group_object *);
1532 extern struct group *root_group;
1533 extern group_hash_t *group_name_hash;
1534 isc_result_t delete_group (struct group_object *, int);
1535 isc_result_t supersede_group (struct group_object *, int);
1536 int clone_group (struct group **, struct group *, const char *, int);
1537 int write_group PROTO ((struct group_object *));
1538
1539 /* salloc.c */
1540 void relinquish_lease_hunks (void);
1541 struct lease *new_leases PROTO ((unsigned, const char *, int));
1542 #if defined (DEBUG_MEMORY_LEAKAGE) || \
1543 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1544 void relinquish_free_lease_states (void);
1545 #endif
1546 OMAPI_OBJECT_ALLOC_DECL (lease, struct lease, dhcp_type_lease)
1547 OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class)
1548 OMAPI_OBJECT_ALLOC_DECL (subclass, struct class, dhcp_type_subclass)
1549 OMAPI_OBJECT_ALLOC_DECL (pool, struct pool, dhcp_type_pool)
1550 OMAPI_OBJECT_ALLOC_DECL (host, struct host_decl, dhcp_type_host)
1551
1552 /* alloc.c */
1553 OMAPI_OBJECT_ALLOC_DECL (subnet, struct subnet, dhcp_type_subnet)
1554 OMAPI_OBJECT_ALLOC_DECL (shared_network, struct shared_network,
1555 dhcp_type_shared_network)
1556 OMAPI_OBJECT_ALLOC_DECL (group_object, struct group_object, dhcp_type_group)
1557 OMAPI_OBJECT_ALLOC_DECL (dhcp_control,
1558 dhcp_control_object_t, dhcp_type_control)
1559
1560 #if defined (DEBUG_MEMORY_LEAKAGE) || \
1561 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1562 void relinquish_free_pairs (void);
1563 void relinquish_free_expressions (void);
1564 void relinquish_free_binding_values (void);
1565 void relinquish_free_option_caches (void);
1566 void relinquish_free_packets (void);
1567 #endif
1568
1569 int option_chain_head_allocate (struct option_chain_head **,
1570 const char *, int);
1571 int option_chain_head_reference (struct option_chain_head **,
1572 struct option_chain_head *,
1573 const char *, int);
1574 int option_chain_head_dereference (struct option_chain_head **,
1575 const char *, int);
1576 int group_allocate (struct group **, const char *, int);
1577 int group_reference (struct group **, struct group *, const char *, int);
1578 int group_dereference (struct group **, const char *, int);
1579 struct dhcp_packet *new_dhcp_packet PROTO ((const char *, int));
1580 struct protocol *new_protocol PROTO ((const char *, int));
1581 struct lease_state *new_lease_state PROTO ((const char *, int));
1582 struct domain_search_list *new_domain_search_list PROTO ((const char *, int));
1583 struct name_server *new_name_server PROTO ((const char *, int));
1584 void free_name_server PROTO ((struct name_server *, const char *, int));
1585 struct option *new_option PROTO ((const char *, const char *, int));
1586 int option_reference(struct option **dest, struct option *src,
1587 const char * file, int line);
1588 int option_dereference(struct option **dest, const char *file, int line);
1589 int group_allocate (struct group **, const char *, int);
1590 int group_reference (struct group **, struct group *, const char *, int);
1591 int group_dereference (struct group **, const char *, int);
1592 struct universe *new_universe PROTO ((const char *, int));
1593 void free_universe PROTO ((struct universe *, const char *, int));
1594 void free_domain_search_list PROTO ((struct domain_search_list *,
1595 const char *, int));
1596 void free_lease_state PROTO ((struct lease_state *, const char *, int));
1597 void free_protocol PROTO ((struct protocol *, const char *, int));
1598 void free_dhcp_packet PROTO ((struct dhcp_packet *, const char *, int));
1599 struct client_lease *new_client_lease PROTO ((const char *, int));
1600 void free_client_lease PROTO ((struct client_lease *, const char *, int));
1601 struct permit *new_permit PROTO ((const char *, int));
1602 void free_permit PROTO ((struct permit *, const char *, int));
1603 pair new_pair PROTO ((const char *, int));
1604 void free_pair PROTO ((pair, const char *, int));
1605 int expression_allocate PROTO ((struct expression **, const char *, int));
1606 int expression_reference PROTO ((struct expression **,
1607 struct expression *, const char *, int));
1608 void free_expression PROTO ((struct expression *, const char *, int));
1609 int binding_value_allocate PROTO ((struct binding_value **,
1610 const char *, int));
1611 int binding_value_reference PROTO ((struct binding_value **,
1612 struct binding_value *,
1613 const char *, int));
1614 void free_binding_value PROTO ((struct binding_value *, const char *, int));
1615 int fundef_allocate PROTO ((struct fundef **, const char *, int));
1616 int fundef_reference PROTO ((struct fundef **,
1617 struct fundef *, const char *, int));
1618 int option_cache_allocate PROTO ((struct option_cache **, const char *, int));
1619 int option_cache_reference PROTO ((struct option_cache **,
1620 struct option_cache *, const char *, int));
1621 int buffer_allocate PROTO ((struct buffer **, unsigned, const char *, int));
1622 int buffer_reference PROTO ((struct buffer **, struct buffer *,
1623 const char *, int));
1624 int buffer_dereference PROTO ((struct buffer **, const char *, int));
1625 int dns_host_entry_allocate PROTO ((struct dns_host_entry **,
1626 const char *, const char *, int));
1627 int dns_host_entry_reference PROTO ((struct dns_host_entry **,
1628 struct dns_host_entry *,
1629 const char *, int));
1630 int dns_host_entry_dereference PROTO ((struct dns_host_entry **,
1631 const char *, int));
1632 int option_state_allocate PROTO ((struct option_state **, const char *, int));
1633 int option_state_reference PROTO ((struct option_state **,
1634 struct option_state *, const char *, int));
1635 int option_state_dereference PROTO ((struct option_state **,
1636 const char *, int));
1637 void data_string_copy PROTO ((struct data_string *,
1638 struct data_string *, const char *, int));
1639 void data_string_forget PROTO ((struct data_string *, const char *, int));
1640 void data_string_truncate PROTO ((struct data_string *, int));
1641 int executable_statement_allocate PROTO ((struct executable_statement **,
1642 const char *, int));
1643 int executable_statement_reference PROTO ((struct executable_statement **,
1644 struct executable_statement *,
1645 const char *, int));
1646 int packet_allocate PROTO ((struct packet **, const char *, int));
1647 int packet_reference PROTO ((struct packet **,
1648 struct packet *, const char *, int));
1649 int packet_dereference PROTO ((struct packet **, const char *, int));
1650 int binding_scope_allocate PROTO ((struct binding_scope **,
1651 const char *, int));
1652 int binding_scope_reference PROTO ((struct binding_scope **,
1653 struct binding_scope *,
1654 const char *, int));
1655 int dns_zone_allocate PROTO ((struct dns_zone **, const char *, int));
1656 int dns_zone_reference PROTO ((struct dns_zone **,
1657 struct dns_zone *, const char *, int));
1658
1659 /* print.c */
1660 #define DEFAULT_TIME_FORMAT 0
1661 #define LOCAL_TIME_FORMAT 1
1662 extern int db_time_format;
1663 char *quotify_string (const char *, const char *, int);
1664 char *quotify_buf (const unsigned char *, unsigned, const char *, int);
1665 char *print_base64 (const unsigned char *, unsigned, const char *, int);
1666 char *print_hw_addr PROTO ((int, int, unsigned char *));
1667 void print_lease PROTO ((struct lease *));
1668 void dump_raw PROTO ((const unsigned char *, unsigned));
1669 void dump_packet_option (struct option_cache *, struct packet *,
1670 struct lease *, struct client_state *,
1671 struct option_state *, struct option_state *,
1672 struct binding_scope **, struct universe *, void *);
1673 void dump_packet PROTO ((struct packet *));
1674 void hash_dump PROTO ((struct hash_table *));
1675 char *print_hex_1 PROTO ((unsigned, const u_int8_t *, unsigned));
1676 char *print_hex_2 PROTO ((unsigned, const u_int8_t *, unsigned));
1677 char *print_hex_3 PROTO ((unsigned, const u_int8_t *, unsigned));
1678 char *print_dotted_quads PROTO ((unsigned, const u_int8_t *));
1679 char *print_dec_1 PROTO ((unsigned long));
1680 char *print_dec_2 PROTO ((unsigned long));
1681 void print_expression PROTO ((const char *, struct expression *));
1682 int token_print_indent_concat (FILE *, int, int,
1683 const char *, const char *, ...);
1684 int token_indent_data_string (FILE *, int, int, const char *, const char *,
1685 struct data_string *);
1686 int token_print_indent (FILE *, int, int,
1687 const char *, const char *, const char *);
1688 void indent_spaces (FILE *, int);
1689 #if defined (NSUPDATE)
1690 void print_dns_status (int, ns_updque *);
1691 #endif
1692 const char *print_time(TIME);
1693
1694 /* socket.c */
1695 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
1696 || defined (USE_SOCKET_FALLBACK)
1697 int if_register_socket PROTO ((struct interface_info *));
1698 #endif
1699
1700 #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND)
1701 void if_reinitialize_fallback PROTO ((struct interface_info *));
1702 void if_register_fallback PROTO ((struct interface_info *));
1703 ssize_t send_fallback PROTO ((struct interface_info *,
1704 struct packet *, struct dhcp_packet *, size_t,
1705 struct in_addr,
1706 struct sockaddr_in *, struct hardware *));
1707 #endif
1708
1709 #ifdef USE_SOCKET_SEND
1710 void if_reinitialize_send PROTO ((struct interface_info *));
1711 void if_register_send PROTO ((struct interface_info *));
1712 void if_deregister_send PROTO ((struct interface_info *));
1713 ssize_t send_packet PROTO ((struct interface_info *,
1714 struct packet *, struct dhcp_packet *, size_t,
1715 struct in_addr,
1716 struct sockaddr_in *, struct hardware *));
1717 #endif
1718 #ifdef USE_SOCKET_RECEIVE
1719 void if_reinitialize_receive PROTO ((struct interface_info *));
1720 void if_register_receive PROTO ((struct interface_info *));
1721 void if_deregister_receive PROTO ((struct interface_info *));
1722 ssize_t receive_packet PROTO ((struct interface_info *,
1723 unsigned char *, size_t,
1724 struct sockaddr_in *, struct hardware *));
1725 #endif
1726
1727 #if defined (USE_SOCKET_FALLBACK)
1728 isc_result_t fallback_discard PROTO ((omapi_object_t *));
1729 #endif
1730
1731 #if defined (USE_SOCKET_SEND)
1732 int can_unicast_without_arp PROTO ((struct interface_info *));
1733 int can_receive_unicast_unconfigured PROTO ((struct interface_info *));
1734 int supports_multiple_interfaces (struct interface_info *);
1735 void maybe_setup_fallback PROTO ((void));
1736 #endif
1737
1738 /* bpf.c */
1739 #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
1740 int if_register_bpf PROTO ( (struct interface_info *));
1741 #endif
1742 #ifdef USE_BPF_SEND
1743 void if_reinitialize_send PROTO ((struct interface_info *));
1744 void if_register_send PROTO ((struct interface_info *));
1745 void if_deregister_send PROTO ((struct interface_info *));
1746 ssize_t send_packet PROTO ((struct interface_info *,
1747 struct packet *, struct dhcp_packet *, size_t,
1748 struct in_addr,
1749 struct sockaddr_in *, struct hardware *));
1750 #endif
1751 #ifdef USE_BPF_RECEIVE
1752 void if_reinitialize_receive PROTO ((struct interface_info *));
1753 void if_register_receive PROTO ((struct interface_info *));
1754 void if_deregister_receive PROTO ((struct interface_info *));
1755 ssize_t receive_packet PROTO ((struct interface_info *,
1756 unsigned char *, size_t,
1757 struct sockaddr_in *, struct hardware *));
1758 #endif
1759 #if defined (USE_BPF_SEND)
1760 int can_unicast_without_arp PROTO ((struct interface_info *));
1761 int can_receive_unicast_unconfigured PROTO ((struct interface_info *));
1762 int supports_multiple_interfaces (struct interface_info *);
1763 void maybe_setup_fallback PROTO ((void));
1764 #endif
1765
1766 /* lpf.c */
1767 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
1768 int if_register_lpf PROTO ( (struct interface_info *));
1769 #endif
1770 #ifdef USE_LPF_SEND
1771 void if_reinitialize_send PROTO ((struct interface_info *));
1772 void if_register_send PROTO ((struct interface_info *));
1773 void if_deregister_send PROTO ((struct interface_info *));
1774 ssize_t send_packet PROTO ((struct interface_info *,
1775 struct packet *, struct dhcp_packet *, size_t,
1776 struct in_addr,
1777 struct sockaddr_in *, struct hardware *));
1778 #endif
1779 #ifdef USE_LPF_RECEIVE
1780 void if_reinitialize_receive PROTO ((struct interface_info *));
1781 void if_register_receive PROTO ((struct interface_info *));
1782 void if_deregister_receive PROTO ((struct interface_info *));
1783 ssize_t receive_packet PROTO ((struct interface_info *,
1784 unsigned char *, size_t,
1785 struct sockaddr_in *, struct hardware *));
1786 #endif
1787 #if defined (USE_LPF_SEND)
1788 int can_unicast_without_arp PROTO ((struct interface_info *));
1789 int can_receive_unicast_unconfigured PROTO ((struct interface_info *));
1790 int supports_multiple_interfaces (struct interface_info *);
1791 void maybe_setup_fallback PROTO ((void));
1792 #endif
1793
1794 /* nit.c */
1795 #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
1796 int if_register_nit PROTO ( (struct interface_info *));
1797 #endif
1798
1799 #ifdef USE_NIT_SEND
1800 void if_reinitialize_send PROTO ((struct interface_info *));
1801 void if_register_send PROTO ((struct interface_info *));
1802 void if_deregister_send PROTO ((struct interface_info *));
1803 ssize_t send_packet PROTO ((struct interface_info *,
1804 struct packet *, struct dhcp_packet *, size_t,
1805 struct in_addr,
1806 struct sockaddr_in *, struct hardware *));
1807 #endif
1808 #ifdef USE_NIT_RECEIVE
1809 void if_reinitialize_receive PROTO ((struct interface_info *));
1810 void if_register_receive PROTO ((struct interface_info *));
1811 void if_deregister_receive PROTO ((struct interface_info *));
1812 ssize_t receive_packet PROTO ((struct interface_info *,
1813 unsigned char *, size_t,
1814 struct sockaddr_in *, struct hardware *));
1815 #endif
1816 #if defined (USE_NIT_SEND)
1817 int can_unicast_without_arp PROTO ((struct interface_info *));
1818 int can_receive_unicast_unconfigured PROTO ((struct interface_info *));
1819 int supports_multiple_interfaces (struct interface_info *);
1820 void maybe_setup_fallback PROTO ((void));
1821 #endif
1822
1823 /* dlpi.c */
1824 #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
1825 int if_register_dlpi PROTO ( (struct interface_info *));
1826 #endif
1827
1828 #ifdef USE_DLPI_SEND
1829 void if_reinitialize_send PROTO ((struct interface_info *));
1830 void if_register_send PROTO ((struct interface_info *));
1831 void if_deregister_send PROTO ((struct interface_info *));
1832 ssize_t send_packet PROTO ((struct interface_info *,
1833 struct packet *, struct dhcp_packet *, size_t,
1834 struct in_addr,
1835 struct sockaddr_in *, struct hardware *));
1836 #endif
1837 #ifdef USE_DLPI_RECEIVE
1838 void if_reinitialize_receive PROTO ((struct interface_info *));
1839 void if_register_receive PROTO ((struct interface_info *));
1840 void if_deregister_receive PROTO ((struct interface_info *));
1841 ssize_t receive_packet PROTO ((struct interface_info *,
1842 unsigned char *, size_t,
1843 struct sockaddr_in *, struct hardware *));
1844 #endif
1845
1846
1847 /* raw.c */
1848 #ifdef USE_RAW_SEND
1849 void if_reinitialize_send PROTO ((struct interface_info *));
1850 void if_register_send PROTO ((struct interface_info *));
1851 void if_deregister_send PROTO ((struct interface_info *));
1852 ssize_t send_packet PROTO ((struct interface_info *,
1853 struct packet *, struct dhcp_packet *, size_t,
1854 struct in_addr,
1855 struct sockaddr_in *, struct hardware *));
1856 int can_unicast_without_arp PROTO ((struct interface_info *));
1857 int can_receive_unicast_unconfigured PROTO ((struct interface_info *));
1858 int supports_multiple_interfaces (struct interface_info *);
1859 void maybe_setup_fallback PROTO ((void));
1860 #endif
1861
1862 /* discover.c */
1863 extern struct interface_info *interfaces,
1864 *dummy_interfaces, *fallback_interface;
1865 extern struct protocol *protocols;
1866 extern int quiet_interface_discovery;
1867 isc_result_t interface_setup (void);
1868 void interface_trace_setup (void);
1869
1870 extern struct in_addr limited_broadcast;
1871 extern struct in_addr local_address;
1872
1873 extern u_int16_t local_port;
1874 extern u_int16_t remote_port;
1875 extern int (*dhcp_interface_setup_hook) (struct interface_info *,
1876 struct iaddr *);
1877 extern int (*dhcp_interface_discovery_hook) (struct interface_info *);
1878 isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *);
1879
1880 extern void (*bootp_packet_handler) PROTO ((struct interface_info *,
1881 struct dhcp_packet *, unsigned,
1882 unsigned int,
1883 struct iaddr, struct hardware *));
1884 extern struct timeout *timeouts;
1885 extern omapi_object_type_t *dhcp_type_interface;
1886 #if defined (TRACING)
1887 trace_type_t *interface_trace;
1888 trace_type_t *inpacket_trace;
1889 trace_type_t *outpacket_trace;
1890 #endif
1891 extern struct interface_info **interface_vector;
1892 extern int interface_count;
1893 extern int interface_max;
1894 isc_result_t interface_initialize (omapi_object_t *, const char *, int);
1895 void discover_interfaces PROTO ((int));
1896 int setup_fallback (struct interface_info **, const char *, int);
1897 int if_readsocket PROTO ((omapi_object_t *));
1898 void reinitialize_interfaces PROTO ((void));
1899
1900 /* dispatch.c */
1901 void set_time(TIME);
1902 struct timeval *process_outstanding_timeouts (struct timeval *);
1903 void dispatch PROTO ((void));
1904 isc_result_t got_one PROTO ((omapi_object_t *));
1905 isc_result_t interface_set_value (omapi_object_t *, omapi_object_t *,
1906 omapi_data_string_t *, omapi_typed_data_t *);
1907 isc_result_t interface_get_value (omapi_object_t *, omapi_object_t *,
1908 omapi_data_string_t *, omapi_value_t **);
1909 isc_result_t interface_destroy (omapi_object_t *, const char *, int);
1910 isc_result_t interface_signal_handler (omapi_object_t *,
1911 const char *, va_list);
1912 isc_result_t interface_stuff_values (omapi_object_t *,
1913 omapi_object_t *,
1914 omapi_object_t *);
1915
1916 void add_timeout PROTO ((TIME, void (*) PROTO ((void *)), void *,
1917 tvref_t, tvunref_t));
1918 void cancel_timeout PROTO ((void (*) PROTO ((void *)), void *));
1919 void cancel_all_timeouts (void);
1920 void relinquish_timeouts (void);
1921 #if 0
1922 struct protocol *add_protocol PROTO ((const char *, int,
1923 void (*) PROTO ((struct protocol *)),
1924 void *));
1925
1926 void remove_protocol PROTO ((struct protocol *));
1927 #endif
1928 OMAPI_OBJECT_ALLOC_DECL (interface,
1929 struct interface_info, dhcp_type_interface)
1930
1931 /* tables.c */
1932 extern char *default_option_format;
1933 extern struct universe dhcp_universe;
1934 extern struct universe nwip_universe;
1935 extern struct universe fqdn_universe;
1936 extern int dhcp_option_default_priority_list [];
1937 extern int dhcp_option_default_priority_list_count;
1938 extern const char *hardware_types [256];
1939 int universe_count, universe_max;
1940 struct universe **universes;
1941 extern universe_hash_t *universe_hash;
1942 void initialize_common_option_spaces PROTO ((void));
1943 struct universe *config_universe;
1944
1945 /* stables.c */
1946 #if defined (FAILOVER_PROTOCOL)
1947 extern failover_option_t null_failover_option;
1948 extern failover_option_t skip_failover_option;
1949 extern struct failover_option_info ft_options [];
1950 extern u_int32_t fto_allowed [];
1951 extern int ft_sizes [];
1952 extern const char *dhcp_flink_state_names [];
1953 #endif
1954 extern const char *binding_state_names [];
1955
1956 extern struct universe agent_universe;
1957 extern struct universe server_universe;
1958
1959 extern struct enumeration ddns_styles;
1960 extern struct enumeration syslog_enum;
1961 void initialize_server_option_spaces PROTO ((void));
1962
1963 /* inet.c */
1964 struct iaddr subnet_number PROTO ((struct iaddr, struct iaddr));
1965 struct iaddr ip_addr PROTO ((struct iaddr, struct iaddr, u_int32_t));
1966 struct iaddr broadcast_addr PROTO ((struct iaddr, struct iaddr));
1967 u_int32_t host_addr PROTO ((struct iaddr, struct iaddr));
1968 int addr_eq PROTO ((struct iaddr, struct iaddr));
1969 int addr_match(struct iaddr *, struct iaddrmatch *);
1970 char *piaddr PROTO ((struct iaddr));
1971 char *piaddrmask (struct iaddr, struct iaddr, const char *, int);
1972
1973 /* dhclient.c */
1974 extern const char *path_dhclient_conf;
1975 extern const char *path_dhclient_db;
1976 extern const char *path_dhclient_pid;
1977 extern char *path_dhclient_script;
1978 extern int interfaces_requested;
1979
1980 extern struct client_config top_level_config;
1981
1982 void dhcpoffer PROTO ((struct packet *));
1983 void dhcpack PROTO ((struct packet *));
1984 void dhcpnak PROTO ((struct packet *));
1985
1986 void send_discover PROTO ((void *));
1987 void send_request PROTO ((void *));
1988 void send_release PROTO ((void *));
1989 void send_decline PROTO ((void *));
1990
1991 void state_reboot PROTO ((void *));
1992 void state_init PROTO ((void *));
1993 void state_selecting PROTO ((void *));
1994 void state_requesting PROTO ((void *));
1995 void state_bound PROTO ((void *));
1996 void state_stop PROTO ((void *));
1997 void state_panic PROTO ((void *));
1998
1999 void bind_lease PROTO ((struct client_state *));
2000
2001 void make_client_options PROTO ((struct client_state *,
2002 struct client_lease *, u_int8_t *,
2003 struct option_cache *, struct iaddr *,
2004 u_int32_t *, struct option_state **));
2005 void make_discover PROTO ((struct client_state *, struct client_lease *));
2006 void make_request PROTO ((struct client_state *, struct client_lease *));
2007 void make_decline PROTO ((struct client_state *, struct client_lease *));
2008 void make_release PROTO ((struct client_state *, struct client_lease *));
2009
2010 void destroy_client_lease PROTO ((struct client_lease *));
2011 void rewrite_client_leases PROTO ((void));
2012 void write_lease_option (struct option_cache *, struct packet *,
2013 struct lease *, struct client_state *,
2014 struct option_state *, struct option_state *,
2015 struct binding_scope **, struct universe *, void *);
2016 int write_client_lease PROTO ((struct client_state *,
2017 struct client_lease *, int, int));
2018 int dhcp_option_ev_name (char *, size_t, struct option *);
2019
2020 void script_init PROTO ((struct client_state *, const char *,
2021 struct string_list *));
2022 void client_option_envadd (struct option_cache *, struct packet *,
2023 struct lease *, struct client_state *,
2024 struct option_state *, struct option_state *,
2025 struct binding_scope **, struct universe *, void *);
2026 void script_write_params PROTO ((struct client_state *,
2027 const char *, struct client_lease *));
2028 int script_go PROTO ((struct client_state *));
2029 void client_envadd (struct client_state *,
2030 const char *, const char *, const char *, ...)
2031 __attribute__((__format__(__printf__,4,5)));
2032
2033 struct client_lease *packet_to_lease (struct packet *, struct client_state *);
2034 void go_daemon PROTO ((void));
2035 void write_client_pid_file PROTO ((void));
2036 void client_location_changed PROTO ((void));
2037 void do_release PROTO ((struct client_state *));
2038 int dhclient_interface_shutdown_hook (struct interface_info *);
2039 int dhclient_interface_discovery_hook (struct interface_info *);
2040 isc_result_t dhclient_interface_startup_hook (struct interface_info *);
2041 void client_dns_update_timeout (void *cp);
2042 isc_result_t client_dns_update (struct client_state *client, int, int);
2043
2044 /* db.c */
2045 int write_lease PROTO ((struct lease *));
2046 int write_host PROTO ((struct host_decl *));
2047 #if defined (FAILOVER_PROTOCOL)
2048 int write_failover_state (dhcp_failover_state_t *);
2049 #endif
2050 int db_printable PROTO ((const char *));
2051 int db_printable_len PROTO ((const unsigned char *, unsigned));
2052 isc_result_t write_named_billing_class(const void *, unsigned, void *);
2053 void write_billing_classes (void);
2054 int write_billing_class PROTO ((struct class *));
2055 void commit_leases_timeout PROTO ((void *));
2056 int commit_leases PROTO ((void));
2057 void db_startup PROTO ((int));
2058 int new_lease_file PROTO ((void));
2059 int group_writer (struct group_object *);
2060
2061 /* packet.c */
2062 u_int32_t checksum PROTO ((unsigned char *, unsigned, u_int32_t));
2063 u_int32_t wrapsum PROTO ((u_int32_t));
2064 void assemble_hw_header PROTO ((struct interface_info *, unsigned char *,
2065 unsigned *, struct hardware *));
2066 void assemble_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
2067 unsigned *, u_int32_t, u_int32_t,
2068 u_int32_t, unsigned char *, unsigned));
2069 ssize_t decode_hw_header PROTO ((struct interface_info *, unsigned char *,
2070 unsigned, struct hardware *));
2071 ssize_t decode_udp_ip_header PROTO ((struct interface_info *, unsigned char *,
2072 unsigned, struct sockaddr_in *,
2073 unsigned));
2074
2075 /* ethernet.c */
2076 void assemble_ethernet_header PROTO ((struct interface_info *, unsigned char *,
2077 unsigned *, struct hardware *));
2078 ssize_t decode_ethernet_header PROTO ((struct interface_info *,
2079 unsigned char *,
2080 unsigned, struct hardware *));
2081
2082 /* tr.c */
2083 void assemble_tr_header PROTO ((struct interface_info *, unsigned char *,
2084 unsigned *, struct hardware *));
2085 ssize_t decode_tr_header PROTO ((struct interface_info *,
2086 unsigned char *,
2087 unsigned, struct hardware *));
2088
2089 /* dhxpxlt.c */
2090 void convert_statement PROTO ((struct parse *));
2091 void convert_host_statement PROTO ((struct parse *, jrefproto));
2092 void convert_host_name PROTO ((struct parse *, jrefproto));
2093 void convert_class_statement PROTO ((struct parse *, jrefproto, int));
2094 void convert_class_decl PROTO ((struct parse *, jrefproto));
2095 void convert_lease_time PROTO ((struct parse *, jrefproto, char *));
2096 void convert_shared_net_statement PROTO ((struct parse *, jrefproto));
2097 void convert_subnet_statement PROTO ((struct parse *, jrefproto));
2098 void convert_subnet_decl PROTO ((struct parse *, jrefproto));
2099 void convert_host_decl PROTO ((struct parse *, jrefproto));
2100 void convert_hardware_decl PROTO ((struct parse *, jrefproto));
2101 void convert_hardware_addr PROTO ((struct parse *, jrefproto));
2102 void convert_filename_decl PROTO ((struct parse *, jrefproto));
2103 void convert_servername_decl PROTO ((struct parse *, jrefproto));
2104 void convert_ip_addr_or_hostname PROTO ((struct parse *, jrefproto, int));
2105 void convert_fixed_addr_decl PROTO ((struct parse *, jrefproto));
2106 void convert_option_decl PROTO ((struct parse *, jrefproto));
2107 void convert_timestamp PROTO ((struct parse *, jrefproto));
2108 void convert_lease_statement PROTO ((struct parse *, jrefproto));
2109 void convert_address_range PROTO ((struct parse *, jrefproto));
2110 void convert_date PROTO ((struct parse *, jrefproto, char *));
2111 void convert_numeric_aggregate PROTO ((struct parse *, jrefproto, int, int, int, int));
2112 void indent PROTO ((int));
2113
2114 /* route.c */
2115 void add_route_direct PROTO ((struct interface_info *, struct in_addr));
2116 void add_route_net PROTO ((struct interface_info *, struct in_addr,
2117 struct in_addr));
2118 void add_route_default_gateway PROTO ((struct interface_info *,
2119 struct in_addr));
2120 void remove_routes PROTO ((struct in_addr));
2121 void remove_if_route PROTO ((struct interface_info *, struct in_addr));
2122 void remove_all_if_routes PROTO ((struct interface_info *));
2123 void set_netmask PROTO ((struct interface_info *, struct in_addr));
2124 void set_broadcast_addr PROTO ((struct interface_info *, struct in_addr));
2125 void set_ip_address PROTO ((struct interface_info *, struct in_addr));
2126
2127 /* clparse.c */
2128 isc_result_t read_client_conf PROTO ((void));
2129 int read_client_conf_file (const char *,
2130 struct interface_info *, struct client_config *);
2131 void read_client_leases PROTO ((void));
2132 void parse_client_statement PROTO ((struct parse *, struct interface_info *,
2133 struct client_config *));
2134 int parse_X PROTO ((struct parse *, u_int8_t *, unsigned));
2135 void parse_option_list PROTO ((struct parse *, u_int32_t **));
2136 void parse_interface_declaration PROTO ((struct parse *,
2137 struct client_config *, char *));
2138 int interface_or_dummy PROTO ((struct interface_info **, const char *));
2139 void make_client_state PROTO ((struct client_state **));
2140 void make_client_config PROTO ((struct client_state *,
2141 struct client_config *));
2142 void parse_client_lease_statement PROTO ((struct parse *, int));
2143 void parse_client_lease_declaration PROTO ((struct parse *,
2144 struct client_lease *,
2145 struct interface_info **,
2146 struct client_state **));
2147 int parse_option_decl PROTO ((struct option_cache **, struct parse *));
2148 void parse_string_list PROTO ((struct parse *, struct string_list **, int));
2149 int parse_ip_addr PROTO ((struct parse *, struct iaddr *));
2150 int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *);
2151 void parse_reject_statement PROTO ((struct parse *, struct client_config *));
2152
2153 /* dhcrelay.c */
2154 void new_relay_server (char *, struct server_list **);
2155 void relay PROTO ((struct interface_info *, struct dhcp_packet *, unsigned,
2156 unsigned int, struct iaddr, struct hardware *));
2157 int strip_relay_agent_options PROTO ((struct interface_info *,
2158 struct interface_info **,
2159 struct dhcp_packet *, unsigned));
2160 int find_interface_by_agent_option PROTO ((struct dhcp_packet *,
2161 struct interface_info **,
2162 u_int8_t *, int));
2163 int add_relay_agent_options PROTO ((struct interface_info *,
2164 struct dhcp_packet *,
2165 unsigned, struct in_addr));
2166
2167 /* icmp.c */
2168 OMAPI_OBJECT_ALLOC_DECL (icmp_state, struct icmp_state, dhcp_type_icmp)
2169 extern struct icmp_state *icmp_state;
2170 void icmp_startup PROTO ((int, void (*) PROTO ((struct iaddr,
2171 u_int8_t *, int))));
2172 int icmp_readsocket PROTO ((omapi_object_t *));
2173 int icmp_echorequest PROTO ((struct iaddr *));
2174 isc_result_t icmp_echoreply PROTO ((omapi_object_t *));
2175
2176 /* dns.c */
2177 #if defined (NSUPDATE)
2178 isc_result_t find_tsig_key (ns_tsig_key **, const char *, struct dns_zone *);
2179 void tkey_free (ns_tsig_key **);
2180 #endif
2181 isc_result_t enter_dns_zone (struct dns_zone *);
2182 isc_result_t dns_zone_lookup (struct dns_zone **, const char *);
2183 int dns_zone_dereference PROTO ((struct dns_zone **, const char *, int));
2184 #if defined (NSUPDATE)
2185 isc_result_t find_cached_zone (const char *, ns_class, char *,
2186 size_t, struct in_addr *, int, int *,
2187 struct dns_zone **);
2188 void forget_zone (struct dns_zone **);
2189 void repudiate_zone (struct dns_zone **);
2190 void cache_found_zone (ns_class, char *, struct in_addr *, int);
2191 int get_dhcid (struct data_string *, int, const u_int8_t *, unsigned);
2192 isc_result_t ddns_update_a(struct data_string *, struct iaddr,
2193 struct data_string *, unsigned long, unsigned,
2194 unsigned);
2195 isc_result_t ddns_remove_a (struct data_string *,
2196 struct iaddr, struct data_string *);
2197 #endif /* NSUPDATE */
2198
2199 /* resolv.c */
2200 extern char path_resolv_conf [];
2201 struct name_server *name_servers;
2202 struct domain_search_list *domains;
2203
2204 void read_resolv_conf PROTO ((TIME));
2205 struct name_server *first_name_server PROTO ((void));
2206
2207 /* inet_addr.c */
2208 #ifdef NEED_INET_ATON
2209 int inet_aton PROTO ((const char *, struct in_addr *));
2210 #endif
2211
2212 /* class.c */
2213 extern int have_billing_classes;
2214 struct class unknown_class;
2215 struct class known_class;
2216 struct collection default_collection;
2217 struct collection *collections;
2218 struct executable_statement *default_classification_rules;
2219
2220 void classification_setup PROTO ((void));
2221 void classify_client PROTO ((struct packet *));
2222 int check_collection PROTO ((struct packet *, struct lease *,
2223 struct collection *));
2224 void classify PROTO ((struct packet *, struct class *));
2225 isc_result_t unlink_class PROTO((struct class **class));
2226 isc_result_t find_class PROTO ((struct class **, const char *,
2227 const char *, int));
2228 int unbill_class PROTO ((struct lease *, struct class *));
2229 int bill_class PROTO ((struct lease *, struct class *));
2230
2231 /* execute.c */
2232 int execute_statements PROTO ((struct binding_value **result,
2233 struct packet *, struct lease *,
2234 struct client_state *,
2235 struct option_state *, struct option_state *,
2236 struct binding_scope **,
2237 struct executable_statement *));
2238 void execute_statements_in_scope PROTO ((struct binding_value **result,
2239 struct packet *, struct lease *,
2240 struct client_state *,
2241 struct option_state *,
2242 struct option_state *,
2243 struct binding_scope **,
2244 struct group *, struct group *));
2245 int executable_statement_dereference PROTO ((struct executable_statement **,
2246 const char *, int));
2247 void write_statements (FILE *, struct executable_statement *, int);
2248 int find_matching_case (struct executable_statement **,
2249 struct packet *, struct lease *, struct client_state *,
2250 struct option_state *, struct option_state *,
2251 struct binding_scope **,
2252 struct expression *, struct executable_statement *);
2253 int executable_statement_foreach (struct executable_statement *,
2254 int (*) (struct executable_statement *,
2255 void *, int), void *, int);
2256
2257 /* comapi.c */
2258 extern omapi_object_type_t *dhcp_type_interface;
2259 extern omapi_object_type_t *dhcp_type_group;
2260 extern omapi_object_type_t *dhcp_type_shared_network;
2261 extern omapi_object_type_t *dhcp_type_subnet;
2262 extern omapi_object_type_t *dhcp_type_control;
2263 extern dhcp_control_object_t *dhcp_control_object;
2264
2265 void dhcp_common_objects_setup (void);
2266
2267 isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *,
2268 omapi_data_string_t *,
2269 omapi_typed_data_t *);
2270 isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *,
2271 omapi_data_string_t *,
2272 omapi_value_t **);
2273 isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int);
2274 isc_result_t dhcp_group_signal_handler (omapi_object_t *,
2275 const char *, va_list);
2276 isc_result_t dhcp_group_stuff_values (omapi_object_t *,
2277 omapi_object_t *,
2278 omapi_object_t *);
2279 isc_result_t dhcp_group_lookup (omapi_object_t **,
2280 omapi_object_t *, omapi_object_t *);
2281 isc_result_t dhcp_group_create (omapi_object_t **,
2282 omapi_object_t *);
2283 isc_result_t dhcp_group_remove (omapi_object_t *,
2284 omapi_object_t *);
2285
2286 isc_result_t dhcp_control_set_value (omapi_object_t *, omapi_object_t *,
2287 omapi_data_string_t *,
2288 omapi_typed_data_t *);
2289 isc_result_t dhcp_control_get_value (omapi_object_t *, omapi_object_t *,
2290 omapi_data_string_t *,
2291 omapi_value_t **);
2292 isc_result_t dhcp_control_destroy (omapi_object_t *, const char *, int);
2293 isc_result_t dhcp_control_signal_handler (omapi_object_t *,
2294 const char *, va_list);
2295 isc_result_t dhcp_control_stuff_values (omapi_object_t *,
2296 omapi_object_t *,
2297 omapi_object_t *);
2298 isc_result_t dhcp_control_lookup (omapi_object_t **,
2299 omapi_object_t *, omapi_object_t *);
2300 isc_result_t dhcp_control_create (omapi_object_t **,
2301 omapi_object_t *);
2302 isc_result_t dhcp_control_remove (omapi_object_t *,
2303 omapi_object_t *);
2304
2305 isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *,
2306 omapi_data_string_t *,
2307 omapi_typed_data_t *);
2308 isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *,
2309 omapi_data_string_t *,
2310 omapi_value_t **);
2311 isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int);
2312 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *,
2313 const char *, va_list);
2314 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *,
2315 omapi_object_t *,
2316 omapi_object_t *);
2317 isc_result_t dhcp_subnet_lookup (omapi_object_t **,
2318 omapi_object_t *, omapi_object_t *);
2319 isc_result_t dhcp_subnet_create (omapi_object_t **,
2320 omapi_object_t *);
2321 isc_result_t dhcp_subnet_remove (omapi_object_t *,
2322 omapi_object_t *);
2323
2324 isc_result_t dhcp_shared_network_set_value (omapi_object_t *,
2325 omapi_object_t *,
2326 omapi_data_string_t *,
2327 omapi_typed_data_t *);
2328 isc_result_t dhcp_shared_network_get_value (omapi_object_t *,
2329 omapi_object_t *,
2330 omapi_data_string_t *,
2331 omapi_value_t **);
2332 isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int);
2333 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *,
2334 const char *, va_list);
2335 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *,
2336 omapi_object_t *,
2337 omapi_object_t *);
2338 isc_result_t dhcp_shared_network_lookup (omapi_object_t **,
2339 omapi_object_t *, omapi_object_t *);
2340 isc_result_t dhcp_shared_network_create (omapi_object_t **,
2341 omapi_object_t *);
2342 isc_result_t dhcp_shared_network_remove (omapi_object_t *,
2343 omapi_object_t *);
2344
2345 /* omapi.c */
2346 extern int (*dhcp_interface_shutdown_hook) (struct interface_info *);
2347
2348 extern omapi_object_type_t *dhcp_type_lease;
2349 extern omapi_object_type_t *dhcp_type_pool;
2350 extern omapi_object_type_t *dhcp_type_class;
2351 extern omapi_object_type_t *dhcp_type_subclass;
2352
2353 #if defined (FAILOVER_PROTOCOL)
2354 extern omapi_object_type_t *dhcp_type_failover_state;
2355 extern omapi_object_type_t *dhcp_type_failover_link;
2356 extern omapi_object_type_t *dhcp_type_failover_listener;
2357 #endif
2358
2359 void dhcp_db_objects_setup (void);
2360
2361 isc_result_t dhcp_lease_set_value (omapi_object_t *, omapi_object_t *,
2362 omapi_data_string_t *,
2363 omapi_typed_data_t *);
2364 isc_result_t dhcp_lease_get_value (omapi_object_t *, omapi_object_t *,
2365 omapi_data_string_t *,
2366 omapi_value_t **);
2367 isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *, int);
2368 isc_result_t dhcp_lease_signal_handler (omapi_object_t *,
2369 const char *, va_list);
2370 isc_result_t dhcp_lease_stuff_values (omapi_object_t *,
2371 omapi_object_t *,
2372 omapi_object_t *);
2373 isc_result_t dhcp_lease_lookup (omapi_object_t **,
2374 omapi_object_t *, omapi_object_t *);
2375 isc_result_t dhcp_lease_create (omapi_object_t **,
2376 omapi_object_t *);
2377 isc_result_t dhcp_lease_remove (omapi_object_t *,
2378 omapi_object_t *);
2379 isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *,
2380 omapi_data_string_t *,
2381 omapi_typed_data_t *);
2382 isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *,
2383 omapi_data_string_t *,
2384 omapi_value_t **);
2385 isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int);
2386 isc_result_t dhcp_group_signal_handler (omapi_object_t *,
2387 const char *, va_list);
2388 isc_result_t dhcp_group_stuff_values (omapi_object_t *,
2389 omapi_object_t *,
2390 omapi_object_t *);
2391 isc_result_t dhcp_group_lookup (omapi_object_t **,
2392 omapi_object_t *, omapi_object_t *);
2393 isc_result_t dhcp_group_create (omapi_object_t **,
2394 omapi_object_t *);
2395 isc_result_t dhcp_group_remove (omapi_object_t *,
2396 omapi_object_t *);
2397 isc_result_t dhcp_host_set_value (omapi_object_t *, omapi_object_t *,
2398 omapi_data_string_t *,
2399 omapi_typed_data_t *);
2400 isc_result_t dhcp_host_get_value (omapi_object_t *, omapi_object_t *,
2401 omapi_data_string_t *,
2402 omapi_value_t **);
2403 isc_result_t dhcp_host_destroy (omapi_object_t *, const char *, int);
2404 isc_result_t dhcp_host_signal_handler (omapi_object_t *,
2405 const char *, va_list);
2406 isc_result_t dhcp_host_stuff_values (omapi_object_t *,
2407 omapi_object_t *,
2408 omapi_object_t *);
2409 isc_result_t dhcp_host_lookup (omapi_object_t **,
2410 omapi_object_t *, omapi_object_t *);
2411 isc_result_t dhcp_host_create (omapi_object_t **,
2412 omapi_object_t *);
2413 isc_result_t dhcp_host_remove (omapi_object_t *,
2414 omapi_object_t *);
2415 isc_result_t dhcp_pool_set_value (omapi_object_t *, omapi_object_t *,
2416 omapi_data_string_t *,
2417 omapi_typed_data_t *);
2418 isc_result_t dhcp_pool_get_value (omapi_object_t *, omapi_object_t *,
2419 omapi_data_string_t *,
2420 omapi_value_t **);
2421 isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *, int);
2422 isc_result_t dhcp_pool_signal_handler (omapi_object_t *,
2423 const char *, va_list);
2424 isc_result_t dhcp_pool_stuff_values (omapi_object_t *,
2425 omapi_object_t *,
2426 omapi_object_t *);
2427 isc_result_t dhcp_pool_lookup (omapi_object_t **,
2428 omapi_object_t *, omapi_object_t *);
2429 isc_result_t dhcp_pool_create (omapi_object_t **,
2430 omapi_object_t *);
2431 isc_result_t dhcp_pool_remove (omapi_object_t *,
2432 omapi_object_t *);
2433 isc_result_t dhcp_class_set_value (omapi_object_t *, omapi_object_t *,
2434 omapi_data_string_t *,
2435 omapi_typed_data_t *);
2436 isc_result_t dhcp_class_get_value (omapi_object_t *, omapi_object_t *,
2437 omapi_data_string_t *,
2438 omapi_value_t **);
2439 isc_result_t dhcp_class_destroy (omapi_object_t *, const char *, int);
2440 isc_result_t dhcp_class_signal_handler (omapi_object_t *,
2441 const char *, va_list);
2442 isc_result_t dhcp_class_stuff_values (omapi_object_t *,
2443 omapi_object_t *,
2444 omapi_object_t *);
2445 isc_result_t dhcp_class_lookup (omapi_object_t **,
2446 omapi_object_t *, omapi_object_t *);
2447 isc_result_t dhcp_class_create (omapi_object_t **,
2448 omapi_object_t *);
2449 isc_result_t dhcp_class_remove (omapi_object_t *,
2450 omapi_object_t *);
2451 isc_result_t dhcp_subclass_set_value (omapi_object_t *, omapi_object_t *,
2452 omapi_data_string_t *,
2453 omapi_typed_data_t *);
2454 isc_result_t dhcp_subclass_get_value (omapi_object_t *, omapi_object_t *,
2455 omapi_data_string_t *,
2456 omapi_value_t **);
2457 isc_result_t dhcp_subclass_destroy (omapi_object_t *, const char *, int);
2458 isc_result_t dhcp_subclass_signal_handler (omapi_object_t *,
2459 const char *, va_list);
2460 isc_result_t dhcp_subclass_stuff_values (omapi_object_t *,
2461 omapi_object_t *,
2462 omapi_object_t *);
2463 isc_result_t dhcp_subclass_lookup (omapi_object_t **,
2464 omapi_object_t *, omapi_object_t *);
2465 isc_result_t dhcp_subclass_create (omapi_object_t **,
2466 omapi_object_t *);
2467 isc_result_t dhcp_subclass_remove (omapi_object_t *,
2468 omapi_object_t *);
2469 isc_result_t dhcp_shared_network_set_value (omapi_object_t *,
2470 omapi_object_t *,
2471 omapi_data_string_t *,
2472 omapi_typed_data_t *);
2473 isc_result_t dhcp_shared_network_get_value (omapi_object_t *, omapi_object_t *,
2474 omapi_data_string_t *,
2475 omapi_value_t **);
2476 isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int);
2477 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *,
2478 const char *, va_list);
2479 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *,
2480 omapi_object_t *,
2481 omapi_object_t *);
2482 isc_result_t dhcp_shared_network_lookup (omapi_object_t **,
2483 omapi_object_t *, omapi_object_t *);
2484 isc_result_t dhcp_shared_network_create (omapi_object_t **,
2485 omapi_object_t *);
2486 isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *,
2487 omapi_data_string_t *,
2488 omapi_typed_data_t *);
2489 isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *,
2490 omapi_data_string_t *,
2491 omapi_value_t **);
2492 isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int);
2493 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *,
2494 const char *, va_list);
2495 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *,
2496 omapi_object_t *,
2497 omapi_object_t *);
2498 isc_result_t dhcp_subnet_lookup (omapi_object_t **,
2499 omapi_object_t *, omapi_object_t *);
2500 isc_result_t dhcp_subnet_create (omapi_object_t **,
2501 omapi_object_t *);
2502 isc_result_t dhcp_interface_set_value (omapi_object_t *,
2503 omapi_object_t *,
2504 omapi_data_string_t *,
2505 omapi_typed_data_t *);
2506 isc_result_t dhcp_interface_get_value (omapi_object_t *,
2507 omapi_object_t *,
2508 omapi_data_string_t *,
2509 omapi_value_t **);
2510 isc_result_t dhcp_interface_destroy (omapi_object_t *,
2511 const char *, int);
2512 isc_result_t dhcp_interface_signal_handler (omapi_object_t *,
2513 const char *,
2514 va_list ap);
2515 isc_result_t dhcp_interface_stuff_values (omapi_object_t *,
2516 omapi_object_t *,
2517 omapi_object_t *);
2518 isc_result_t dhcp_interface_lookup (omapi_object_t **,
2519 omapi_object_t *,
2520 omapi_object_t *);
2521 isc_result_t dhcp_interface_create (omapi_object_t **,
2522 omapi_object_t *);
2523 isc_result_t dhcp_interface_remove (omapi_object_t *,
2524 omapi_object_t *);
2525 void interface_stash (struct interface_info *);
2526 void interface_snorf (struct interface_info *, int);
2527
2528 isc_result_t binding_scope_set_value (struct binding_scope *, int,
2529 omapi_data_string_t *,
2530 omapi_typed_data_t *);
2531 isc_result_t binding_scope_get_value (omapi_value_t **,
2532 struct binding_scope *,
2533 omapi_data_string_t *);
2534 isc_result_t binding_scope_stuff_values (omapi_object_t *,
2535 struct binding_scope *);
2536
2537 /* mdb.c */
2538
2539 extern struct subnet *subnets;
2540 extern struct shared_network *shared_networks;
2541 extern host_hash_t *host_hw_addr_hash;
2542 extern host_hash_t *host_uid_hash;
2543 extern host_hash_t *host_name_hash;
2544 extern lease_hash_t *lease_uid_hash;
2545 extern lease_hash_t *lease_ip_addr_hash;
2546 extern lease_hash_t *lease_hw_addr_hash;
2547
2548 extern omapi_object_type_t *dhcp_type_host;
2549
2550 extern int numclasseswritten;
2551
2552
2553 isc_result_t enter_class PROTO ((struct class *, int, int));
2554 isc_result_t delete_class PROTO ((struct class *, int));
2555 isc_result_t enter_host PROTO ((struct host_decl *, int, int));
2556 isc_result_t delete_host PROTO ((struct host_decl *, int));
2557 int find_hosts_by_haddr PROTO ((struct host_decl **, int,
2558 const unsigned char *, unsigned,
2559 const char *, int));
2560 int find_hosts_by_uid PROTO ((struct host_decl **, const unsigned char *,
2561 unsigned, const char *, int));
2562 int find_host_for_network PROTO ((struct subnet **, struct host_decl **,
2563 struct iaddr *, struct shared_network *));
2564 void new_address_range PROTO ((struct parse *, struct iaddr, struct iaddr,
2565 struct subnet *, struct pool *,
2566 struct lease **));
2567 isc_result_t dhcp_lease_free (omapi_object_t *, const char *, int);
2568 isc_result_t dhcp_lease_get (omapi_object_t **, const char *, int);
2569 int find_grouped_subnet PROTO ((struct subnet **, struct shared_network *,
2570 struct iaddr, const char *, int));
2571 int find_subnet (struct subnet **, struct iaddr, const char *, int);
2572 void enter_shared_network PROTO ((struct shared_network *));
2573 void new_shared_network_interface PROTO ((struct parse *,
2574 struct shared_network *,
2575 const char *));
2576 int subnet_inner_than PROTO ((struct subnet *, struct subnet *, int));
2577 void enter_subnet PROTO ((struct subnet *));
2578 void enter_lease PROTO ((struct lease *));
2579 int supersede_lease PROTO ((struct lease *, struct lease *, int, int, int));
2580 void make_binding_state_transition (struct lease *);
2581 int lease_copy PROTO ((struct lease **, struct lease *, const char *, int));
2582 void release_lease PROTO ((struct lease *, struct packet *));
2583 void abandon_lease PROTO ((struct lease *, const char *));
2584 void dissociate_lease PROTO ((struct lease *));
2585 void pool_timer PROTO ((void *));
2586 int find_lease_by_uid PROTO ((struct lease **, const unsigned char *,
2587 unsigned, const char *, int));
2588 int find_lease_by_hw_addr PROTO ((struct lease **, const unsigned char *,
2589 unsigned, const char *, int));
2590 int find_lease_by_ip_addr PROTO ((struct lease **, struct iaddr,
2591 const char *, int));
2592 void uid_hash_add PROTO ((struct lease *));
2593 void uid_hash_delete PROTO ((struct lease *));
2594 void hw_hash_add PROTO ((struct lease *));
2595 void hw_hash_delete PROTO ((struct lease *));
2596 int write_leases PROTO ((void));
2597 int lease_enqueue (struct lease *);
2598 isc_result_t lease_instantiate(const void *, unsigned, void *);
2599 void expire_all_pools PROTO ((void));
2600 void dump_subnets PROTO ((void));
2601 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2602 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2603 void free_everything (void);
2604 #endif
2605
2606 /* nsupdate.c */
2607 char *ddns_rev_name (struct lease *, struct lease_state *, struct packet *);
2608 char *ddns_fwd_name (struct lease *, struct lease_state *, struct packet *);
2609 int nsupdateA (const char *, const unsigned char *, u_int32_t, int);
2610 int nsupdatePTR (const char *, const unsigned char *, u_int32_t, int);
2611 void nsupdate (struct lease *, struct lease_state *, struct packet *, int);
2612 int updateA (const struct data_string *, const struct data_string *,
2613 unsigned int, struct lease *);
2614 int updatePTR (const struct data_string *, const struct data_string *,
2615 unsigned int, struct lease *);
2616 int deleteA (const struct data_string *, const struct data_string *,
2617 struct lease *);
2618 int deletePTR (const struct data_string *, const struct data_string *,
2619 struct lease *);
2620
2621 /* failover.c */
2622 #if defined (FAILOVER_PROTOCOL)
2623 extern dhcp_failover_state_t *failover_states;
2624 void dhcp_failover_startup PROTO ((void));
2625 int dhcp_failover_write_all_states (void);
2626 isc_result_t enter_failover_peer PROTO ((dhcp_failover_state_t *));
2627 isc_result_t find_failover_peer PROTO ((dhcp_failover_state_t **,
2628 const char *, const char *, int));
2629 isc_result_t dhcp_failover_link_initiate PROTO ((omapi_object_t *));
2630 isc_result_t dhcp_failover_link_signal PROTO ((omapi_object_t *,
2631 const char *, va_list));
2632 isc_result_t dhcp_failover_link_set_value PROTO ((omapi_object_t *,
2633 omapi_object_t *,
2634 omapi_data_string_t *,
2635 omapi_typed_data_t *));
2636 isc_result_t dhcp_failover_link_get_value PROTO ((omapi_object_t *,
2637 omapi_object_t *,
2638 omapi_data_string_t *,
2639 omapi_value_t **));
2640 isc_result_t dhcp_failover_link_destroy PROTO ((omapi_object_t *,
2641 const char *, int));
2642 isc_result_t dhcp_failover_link_stuff_values PROTO ((omapi_object_t *,
2643 omapi_object_t *,
2644 omapi_object_t *));
2645 isc_result_t dhcp_failover_listen PROTO ((omapi_object_t *));
2646
2647 isc_result_t dhcp_failover_listener_signal PROTO ((omapi_object_t *,
2648 const char *,
2649 va_list));
2650 isc_result_t dhcp_failover_listener_set_value PROTO ((omapi_object_t *,
2651 omapi_object_t *,
2652 omapi_data_string_t *,
2653 omapi_typed_data_t *));
2654 isc_result_t dhcp_failover_listener_get_value PROTO ((omapi_object_t *,
2655 omapi_object_t *,
2656 omapi_data_string_t *,
2657 omapi_value_t **));
2658 isc_result_t dhcp_failover_listener_destroy PROTO ((omapi_object_t *,
2659 const char *, int));
2660 isc_result_t dhcp_failover_listener_stuff PROTO ((omapi_object_t *,
2661 omapi_object_t *,
2662 omapi_object_t *));
2663 isc_result_t dhcp_failover_register PROTO ((omapi_object_t *));
2664 isc_result_t dhcp_failover_state_signal PROTO ((omapi_object_t *,
2665 const char *, va_list));
2666 isc_result_t dhcp_failover_state_transition (dhcp_failover_state_t *,
2667 const char *);
2668 isc_result_t dhcp_failover_set_service_state (dhcp_failover_state_t *state);
2669 isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *,
2670 enum failover_state);
2671 isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *,
2672 failover_message_t *);
2673 void dhcp_failover_pool_rebalance (void *);
2674 void dhcp_failover_pool_check (struct pool *);
2675 int dhcp_failover_state_pool_check (dhcp_failover_state_t *);
2676 void dhcp_failover_timeout (void *);
2677 void dhcp_failover_send_contact (void *);
2678 isc_result_t dhcp_failover_send_state (dhcp_failover_state_t *);
2679 isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *);
2680 int dhcp_failover_queue_update (struct lease *, int);
2681 int dhcp_failover_send_acks (dhcp_failover_state_t *);
2682 void dhcp_failover_toack_queue_timeout (void *);
2683 int dhcp_failover_queue_ack (dhcp_failover_state_t *, failover_message_t *msg);
2684 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *);
2685 isc_result_t dhcp_failover_state_set_value PROTO ((omapi_object_t *,
2686 omapi_object_t *,
2687 omapi_data_string_t *,
2688 omapi_typed_data_t *));
2689 void dhcp_failover_keepalive (void *);
2690 void dhcp_failover_reconnect (void *);
2691 void dhcp_failover_startup_timeout (void *);
2692 void dhcp_failover_link_startup_timeout (void *);
2693 void dhcp_failover_listener_restart (void *);
2694 isc_result_t dhcp_failover_state_get_value PROTO ((omapi_object_t *,
2695 omapi_object_t *,
2696 omapi_data_string_t *,
2697 omapi_value_t **));
2698 isc_result_t dhcp_failover_state_destroy PROTO ((omapi_object_t *,
2699 const char *, int));
2700 isc_result_t dhcp_failover_state_stuff PROTO ((omapi_object_t *,
2701 omapi_object_t *,
2702 omapi_object_t *));
2703 isc_result_t dhcp_failover_state_lookup PROTO ((omapi_object_t **,
2704 omapi_object_t *,
2705 omapi_object_t *));
2706 isc_result_t dhcp_failover_state_create PROTO ((omapi_object_t **,
2707 omapi_object_t *));
2708 isc_result_t dhcp_failover_state_remove PROTO ((omapi_object_t *,
2709 omapi_object_t *));
2710 int dhcp_failover_state_match (dhcp_failover_state_t *, u_int8_t *, unsigned);
2711 int dhcp_failover_state_match_by_name(dhcp_failover_state_t *,
2712 failover_option_t *);
2713 const char *dhcp_failover_reject_reason_print (int);
2714 const char *dhcp_failover_state_name_print (enum failover_state);
2715 const char *dhcp_failover_message_name (unsigned);
2716 const char *dhcp_failover_option_name (unsigned);
2717 failover_option_t *dhcp_failover_option_printf (unsigned, char *,
2718 unsigned *,
2719 unsigned,
2720 const char *, ...)
2721 __attribute__((__format__(__printf__,5,6)));
2722 failover_option_t *dhcp_failover_make_option (unsigned, char *,
2723 unsigned *, unsigned, ...);
2724 isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *,
2725 omapi_object_t *, int, u_int32_t, ...);
2726 isc_result_t dhcp_failover_send_connect PROTO ((omapi_object_t *));
2727 isc_result_t dhcp_failover_send_connectack PROTO ((omapi_object_t *,
2728 dhcp_failover_state_t *,
2729 int, const char *));
2730 isc_result_t dhcp_failover_send_disconnect PROTO ((omapi_object_t *,
2731 int, const char *));
2732 isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *,
2733 struct lease *);
2734 isc_result_t dhcp_failover_send_bind_ack (dhcp_failover_state_t *,
2735 failover_message_t *,
2736 int, const char *);
2737 isc_result_t dhcp_failover_send_poolreq (dhcp_failover_state_t *);
2738 isc_result_t dhcp_failover_send_poolresp (dhcp_failover_state_t *, int);
2739 isc_result_t dhcp_failover_send_update_request (dhcp_failover_state_t *);
2740 isc_result_t dhcp_failover_send_update_request_all (dhcp_failover_state_t *);
2741 isc_result_t dhcp_failover_send_update_done (dhcp_failover_state_t *);
2742 isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *,
2743 failover_message_t *);
2744 isc_result_t dhcp_failover_process_bind_ack (dhcp_failover_state_t *,
2745 failover_message_t *);
2746 isc_result_t dhcp_failover_generate_update_queue (dhcp_failover_state_t *,
2747 int);
2748 isc_result_t dhcp_failover_process_update_request (dhcp_failover_state_t *,
2749 failover_message_t *);
2750 isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *,
2751 failover_message_t *);
2752 isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *,
2753 failover_message_t *);
2754 void dhcp_failover_recover_done (void *);
2755 void failover_print PROTO ((char *, unsigned *, unsigned, const char *));
2756 void update_partner PROTO ((struct lease *));
2757 int load_balance_mine (struct packet *, dhcp_failover_state_t *);
2758 int peer_wants_lease (struct lease *);
2759 binding_state_t normal_binding_state_transition_check (struct lease *,
2760 dhcp_failover_state_t *,
2761 binding_state_t,
2762 u_int32_t);
2763 binding_state_t
2764 conflict_binding_state_transition_check (struct lease *,
2765 dhcp_failover_state_t *,
2766 binding_state_t, u_int32_t);
2767 int lease_mine_to_reallocate (struct lease *);
2768
2769 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t,
2770 dhcp_type_failover_state)
2771 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener, dhcp_failover_listener_t,
2772 dhcp_type_failover_listener)
2773 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link, dhcp_failover_link_t,
2774 dhcp_type_failover_link)
2775 #endif /* FAILOVER_PROTOCOL */
2776
2777 const char *binding_state_print (enum failover_state);