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