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