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