~ubuntu-branches/debian/wheezy/isc-dhcp/wheezy

« back to all changes in this revision

Viewing changes to .pc/cve-2011-4868.patch/includes/dhcpd.h

  • Committer: Package Import Robot
  • Author(s): Michael Gilbert, Andrew Pollock, Michael Gilbert
  • Date: 2012-04-28 16:00:49 UTC
  • Revision ID: package-import@ubuntu.com-20120428160049-e9p426h82w2i6qdq
Tags: 4.2.2.dfsg.1-5
[ Andrew Pollock ]
* debian/dhclient.conf: send the hostname (closes: #151820) 

[ Michael Gilbert ]
* Fix cve-2011-4868: error in DDNS handling with IPv6 (closes: #655746)
* Fix cve-2011-4539: error in regular expression handling
  (closes: #652259)
* Make dependencies diff-able
* Add myself to uploaders
* Remove all automatically generated files in clean rule
* Medium urgency for security updates

Show diffs side-by-side

added added

removed removed

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