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