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