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