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