1 /* $NetBSD: dhcpd.h,v 1.6 2014/07/12 12:09:37 spz Exp $ */
4 Definitions for dhcpd... */
7 * Copyright (c) 2004-2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 1996-2003 by Internet Software Consortium
10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies.
14 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 * Internet Systems Consortium, Inc.
24 * Redwood City, CA 94063
26 * https://www.isc.org/
30 /*! \file includes/dhcpd.h */
35 #include <sys/types.h>
36 #include <netinet/in.h>
37 #include <sys/socket.h>
39 #include <arpa/inet.h>
44 #define fd_set cygwin_fd_set
45 #include <sys/types.h>
60 #include <net/route.h>
61 #include <net/if_arp.h>
63 # include <net/if_dl.h>
71 #include "arpa/nameser.h"
76 typedef struct hash_table group_hash_t
;
77 typedef struct hash_table universe_hash_t
;
78 typedef struct hash_table option_name_hash_t
;
79 typedef struct hash_table option_code_hash_t
;
80 typedef struct hash_table dns_zone_hash_t
;
81 typedef struct hash_table lease_ip_hash_t
;
82 typedef struct hash_table lease_id_hash_t
;
83 typedef struct hash_table host_hash_t
;
84 typedef struct hash_table class_hash_t
;
92 #include <omapip/isclib.h>
93 #include <omapip/result.h>
97 #include "statement.h"
100 #include "dhctoken.h"
102 #include <omapip/omapip_p.h>
104 #if defined(LDAP_CONFIGURATION)
106 # include <sys/utsname.h> /* for uname() */
109 #if !defined (BYTE_NAME_HASH_SIZE)
110 # define BYTE_NAME_HASH_SIZE 401 /* Default would be ridiculous. */
112 #if !defined (BYTE_CODE_HASH_SIZE)
113 # define BYTE_CODE_HASH_SIZE 254 /* Default would be ridiculous. */
116 /* Although it is highly improbable that a 16-bit option space might
117 * actually use 2^16 actual defined options, it is the worst case
118 * scenario we must prepare for. Having 4 options per bucket in this
119 * case is pretty reasonable.
121 #if !defined (WORD_NAME_HASH_SIZE)
122 # define WORD_NAME_HASH_SIZE 20479
124 #if !defined (WORD_CODE_HASH_SIZE)
125 # define WORD_CODE_HASH_SIZE 16384
128 /* Not only is it improbable that the 32-bit spaces might actually use 2^32
129 * defined options, it is infeasible. It would be best for this kind of
130 * space to be dynamically sized. Instead we size it at the word hash's
133 #if !defined (QUAD_NAME_HASH_SIZE)
134 # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
136 #if !defined (QUAD_CODE_HASH_SIZE)
137 # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
140 #if !defined (DNS_HASH_SIZE)
141 # define DNS_HASH_SIZE 0 /* Default. */
144 /* Default size to use for name/code hashes on user-defined option spaces. */
145 #if !defined (DEFAULT_SPACE_HASH_SIZE)
146 # define DEFAULT_SPACE_HASH_SIZE 11
149 #if !defined (NWIP_HASH_SIZE)
150 # define NWIP_HASH_SIZE 17 /* A really small table. */
153 #if !defined (FQDN_HASH_SIZE)
154 # define FQDN_HASH_SIZE 13 /* A ridiculously small table. */
157 /* I really doubt a given installation is going to have more than a few
158 * hundred vendors involved.
160 #if !defined (VIVCO_HASH_SIZE)
161 # define VIVCO_HASH_SIZE 127
164 #if !defined (VIVSO_HASH_SIZE)
165 # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
168 #if !defined (VSIO_HASH_SIZE)
169 # define VSIO_HASH_SIZE VIVCO_HASH_SIZE
172 #if !defined (VIV_ISC_HASH_SIZE)
173 # define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */
176 #if !defined (UNIVERSE_HASH_SIZE)
177 # define UNIVERSE_HASH_SIZE 13 /* A really small table. */
180 #if !defined (GROUP_HASH_SIZE)
181 # define GROUP_HASH_SIZE 0 /* Default. */
184 /* At least one person has indicated they use ~20k host records.
186 #if !defined (HOST_HASH_SIZE)
187 # define HOST_HASH_SIZE 22501
190 /* We have user reports of use of ISC DHCP numbering leases in the 200k's.
192 * We also have reports of folks using 10.0/8 as a dynamic range. The
193 * following is something of a compromise between the two. At the ~2-3
194 * hundred thousand leases, there's ~2-3 leases to search in each bucket.
196 #if !defined (LEASE_HASH_SIZE)
197 # define LEASE_HASH_SIZE 100003
200 /* It is not known what the worst case subclass hash size is. We estimate
203 #if !defined (SCLASS_HASH_SIZE)
204 # define SCLASS_HASH_SIZE 12007
207 #if !defined (AGENT_HASH_SIZE)
208 # define AGENT_HASH_SIZE 11 /* A really small table. */
211 /* The server hash size is used for both names and codes. There aren't
212 * many (roughly 50 at the moment), so we use a smaller table. If we
213 * use a 1:1 table size, then we get name collisions due to poor name
214 * hashing. So we use double the space we need, which drastically
215 * reduces collisions.
217 #if !defined (SERVER_HASH_SIZE)
218 # define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option)))
222 /* How many options are likely to appear in a single packet? */
223 #if !defined (OPTION_HASH_SIZE)
224 # define OPTION_HASH_SIZE 17
225 # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */
226 # define OPTION_HASH_EXP 5 /* The exponent for that power of two. */
229 #define compute_option_hash(x) \
230 (((x) & (OPTION_HASH_PTWO - 1)) + \
231 (((x) >> OPTION_HASH_EXP) & \
232 (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
234 enum dhcp_shutdown_state
{
236 shutdown_omapi_connections
,
237 shutdown_drop_omapi_connections
,
242 /* Client FQDN option, failover FQDN option, etc. */
249 #include "failover.h"
251 /* A parsing context. */
263 * In order to give nice output when we have a parsing error
264 * in our file, we keep track of where we are in the line so
265 * that we can show the user.
267 * We need to keep track of two lines, because we can look
268 * ahead, via the "peek" function, to the next line sometimes.
270 * The "line1" and "line2" variables act as buffers for this
271 * information. The "lpos" variable tells us where we are in the
274 * When we "put back" a character from the parsing context, we
275 * do not want to have the character appear twice in the error
276 * output. So, we set a flag, the "ugflag", which the
277 * get_char() function uses to check for this condition.
285 enum dhcp_token token
;
291 int warnings_occurred
;
294 size_t bufix
, buflen
;
297 struct parse
*saved_state
;
299 #if defined(LDAP_CONFIGURATION)
301 * LDAP configuration uses a call-back to iteratively read config
302 * off of the LDAP repository.
303 * XXX: The token stream can not be rewound reliably, so this must
304 * be addressed for DHCPv6 support.
306 int (*read_function
)(struct parse
*);
310 /* Variable-length array of data. */
313 struct string_list
*next
;
317 /* A name server, from /etc/resolv.conf. */
319 struct name_server
*next
;
320 struct sockaddr_in addr
;
324 /* A domain search list element. */
325 struct domain_search_list
{
326 struct domain_search_list
*next
;
331 /* Option tag structures are used to build chains of option tags, for
332 when we're sure we're not going to have enough of them to justify
333 maintaining an array. */
336 struct option_tag
*next
;
340 /* An agent option structure. We need a special structure for the
341 Relay Agent Information option because if more than one appears in
342 a message, we have to keep them separate. */
344 struct agent_options
{
345 struct agent_options
*next
;
347 struct option_tag
*first
;
350 struct option_cache
{
352 struct option_cache
*next
;
353 struct expression
*expression
;
354 struct option
*option
;
355 struct data_string data
;
357 #define OPTION_HAD_NULLS 0x00000001
361 struct option_state
{
369 /* A dhcp packet and the pointers to its option values. */
371 struct dhcp_packet
*raw
;
373 unsigned packet_length
;
376 unsigned char dhcpv6_msg_type
; /* DHCPv6 message type */
378 /* DHCPv6 transaction ID */
379 unsigned char dhcpv6_transaction_id
[3];
381 /* DHCPv6 relay information */
382 unsigned char dhcpv6_hop_count
;
383 struct in6_addr dhcpv6_link_address
;
384 struct in6_addr dhcpv6_peer_address
;
386 /* DHCPv6 packet containing this one, or NULL if none */
387 struct packet
*dhcpv6_container_packet
;
391 struct iaddr client_addr
;
392 struct interface_info
*interface
; /* Interface on which packet
394 struct hardware
*haddr
; /* Physical link address
395 of local sender (maybe gateway). */
397 /* Information for relay agent options (see
398 draft-ietf-dhc-agent-options-xx.txt). */
399 u_int8_t
*circuit_id
; /* Circuit ID of client connection. */
401 u_int8_t
*remote_id
; /* Remote ID of client. */
404 int got_requested_address
; /* True if client sent the
405 dhcp-requested-address option. */
407 struct shared_network
*shared_network
;
408 struct option_state
*options
;
410 #if !defined (PACKET_MAX_CLASSES)
411 # define PACKET_MAX_CLASSES 5
414 struct class *classes
[PACKET_MAX_CLASSES
];
419 /* If we stash agent options onto the packet option state, to pretend
420 * options we got in a previous exchange were still there, we need
421 * to signal this in a reliable way.
423 isc_boolean_t agent_options_stashed
;
426 * ISC_TRUE if packet received unicast (as opposed to multicast).
427 * Only used in DHCPv6.
429 isc_boolean_t unicast
;
433 * A network interface's MAC address.
434 * 20 bytes for the hardware address
435 * and 1 byte for the type tag
438 #define HARDWARE_ADDR_LEN 20
442 u_int8_t hbuf
[HARDWARE_ADDR_LEN
+ 1];
445 #if defined(LDAP_CONFIGURATION)
446 # define LDAP_BUFFER_SIZE 8192
447 # define LDAP_METHOD_STATIC 0
448 # define LDAP_METHOD_DYNAMIC 1
449 #if defined (LDAP_USE_SSL)
450 # define LDAP_SSL_OFF 0
451 # define LDAP_SSL_ON 1
452 # define LDAP_SSL_TLS 2
453 # define LDAP_SSL_LDAPS 3
456 /* This is a tree of the current configuration we are building from LDAP */
457 struct ldap_config_stack
{
458 LDAPMessage
* res
; /* Pointer returned from ldap_search */
459 LDAPMessage
* ldent
; /* Current item in LDAP that we're processing.
461 int close_brace
; /* Put a closing } after we're through with
463 int processed
; /* We set this flag if this base item has been
464 processed. After this base item is processed,
465 we can start processing the children */
466 struct ldap_config_stack
*children
;
467 struct ldap_config_stack
*next
;
475 server_hibernate
= 3,
477 } control_object_state_t
;
480 OMAPI_OBJECT_PREAMBLE
;
481 control_object_state_t state
;
482 } dhcp_control_object_t
;
487 #define FTS_EXPIRED 3
488 #define FTS_RELEASED 4
489 #define FTS_ABANDONED 5
492 typedef u_int8_t binding_state_t
;
494 /* FTS_LAST is the highest value that is valid for a lease binding state. */
495 #define FTS_LAST FTS_BACKUP
498 * A block for the on statements so we can share the structure
502 struct executable_statement
*on_expiry
;
503 struct executable_statement
*on_commit
;
504 struct executable_statement
*on_release
;
507 /* A dhcp lease declaration structure. */
509 OMAPI_OBJECT_PREAMBLE
;
511 struct lease
*n_uid
, *n_hw
;
513 struct iaddr ip_addr
;
514 TIME starts
, ends
, sort_time
;
515 char *client_hostname
;
516 struct binding_scope
*scope
;
517 struct host_decl
*host
;
518 struct subnet
*subnet
;
520 struct class *billing_class
;
521 struct option_chain_head
*agent_options
;
523 /* insert the structure directly */
524 struct on_star on_star
;
527 unsigned short uid_len
;
528 unsigned short uid_max
;
529 unsigned char uid_buf
[7];
530 struct hardware hardware_addr
;
533 # define STATIC_LEASE 1
534 # define BOOTP_LEASE 2
535 # define RESERVED_LEASE 4
536 # define MS_NULL_TERMINATION 8
537 # define ON_UPDATE_QUEUE 16
538 # define ON_ACK_QUEUE 32
539 # define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE)
540 # define UNICAST_BROADCAST_HACK 64
541 # define ON_DEFERRED_QUEUE 128
543 /* Persistent flags are to be preserved on a given lease structure. */
544 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
545 /* Ephemeral flags are to be preserved on a given lease (copied etc). */
546 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
547 UNICAST_BROADCAST_HACK | \
552 * The lease's binding state is its current state. The next binding
553 * state is the next state this lease will move into by expiration,
554 * or timers in general. The desired binding state is used on lease
555 * updates; the caller is attempting to move the lease to the desired
556 * binding state (and this may either succeed or fail, so the binding
557 * state must be preserved).
559 * The 'rewind' binding state is used in failover processing. It
560 * is used for an optimization when out of communications; it allows
561 * the server to "rewind" a lease to the previous state acknowledged
562 * by the peer, and progress forward from that point.
564 binding_state_t binding_state
;
565 binding_state_t next_binding_state
;
566 binding_state_t desired_binding_state
;
567 binding_state_t rewind_binding_state
;
569 struct lease_state
*state
;
572 * 'tsfp' is more of an 'effective' tsfp. It may be calculated from
573 * stos+mclt for example if it's an expired lease and the server is
574 * in partner-down state. 'atsfp' is zeroed whenever a lease is
575 * updated - and only set when the peer acknowledges it. This
576 * ensures every state change is transmitted.
578 TIME tstp
; /* Time sent to partner. */
579 TIME tsfp
; /* Time sent from partner. */
580 TIME atsfp
; /* Actual time sent from partner. */
581 TIME cltt
; /* Client last transaction time. */
582 u_int32_t last_xid
; /* XID we sent in this lease's BNDUPD */
583 struct lease
*next_pending
;
586 * A pointer to the state of the ddns update for this lease.
587 * It should be set while the update is in progress and cleared
588 * when the update finishes. It can be used to cancel the
589 * update if we want to do a different update.
591 struct dhcp_ddns_cb
*ddns_cb
;
595 struct lease_state
*next
;
597 struct interface_info
*ip
;
599 struct packet
*packet
; /* The incoming packet. */
603 struct option_state
*options
;
604 struct data_string parameter_request_list
;
605 int max_message_size
;
606 unsigned char expiry
[4], renewal
[4], rebind
[4];
607 struct data_string filename
, server_name
;
608 int got_requested_address
;
609 int got_server_identifier
;
610 struct shared_network
*shared_network
; /* Shared network of interface
611 on which request arrived. */
615 u_int16_t bootp_flags
;
616 struct in_addr ciaddr
;
617 struct in_addr siaddr
;
618 struct in_addr giaddr
;
626 #define SHARED_NET_DECL 2
627 #define SUBNET_DECL 3
632 /* Possible modes in which discover_interfaces can run. */
634 #define DISCOVER_RUNNING 0
635 #define DISCOVER_SERVER 1
636 #define DISCOVER_UNCONFIGURED 2
637 #define DISCOVER_RELAY 3
638 #define DISCOVER_REQUESTED 4
640 /* DDNS_UPDATE_STYLE enumerations. */
641 #define DDNS_UPDATE_STYLE_NONE 0
642 #define DDNS_UPDATE_STYLE_AD_HOC 1
643 #define DDNS_UPDATE_STYLE_INTERIM 2
644 #define DDNS_UPDATE_STYLE_STANDARD 3
646 /* Server option names. */
648 #define SV_DEFAULT_LEASE_TIME 1
649 #define SV_MAX_LEASE_TIME 2
650 #define SV_MIN_LEASE_TIME 3
651 #define SV_BOOTP_LEASE_CUTOFF 4
652 #define SV_BOOTP_LEASE_LENGTH 5
653 #define SV_BOOT_UNKNOWN_CLIENTS 6
654 #define SV_DYNAMIC_BOOTP 7
655 #define SV_ALLOW_BOOTP 8
656 #define SV_ALLOW_BOOTING 9
657 #define SV_ONE_LEASE_PER_CLIENT 10
658 #define SV_GET_LEASE_HOSTNAMES 11
659 #define SV_USE_HOST_DECL_NAMES 12
660 #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
661 #define SV_MIN_SECS 14
662 #define SV_FILENAME 15
663 #define SV_SERVER_NAME 16
664 #define SV_NEXT_SERVER 17
665 #define SV_AUTHORITATIVE 18
666 #define SV_VENDOR_OPTION_SPACE 19
667 #define SV_ALWAYS_REPLY_RFC1048 20
668 #define SV_SITE_OPTION_SPACE 21
669 #define SV_ALWAYS_BROADCAST 22
670 #define SV_DDNS_DOMAIN_NAME 23
671 #define SV_DDNS_HOST_NAME 24
672 #define SV_DDNS_REV_DOMAIN_NAME 25
673 #define SV_LEASE_FILE_NAME 26
674 #define SV_PID_FILE_NAME 27
675 #define SV_DUPLICATES 28
676 #define SV_DECLINES 29
677 #define SV_DDNS_UPDATES 30
678 #define SV_OMAPI_PORT 31
679 #define SV_LOCAL_PORT 32
680 #define SV_LIMITED_BROADCAST_ADDRESS 33
681 #define SV_REMOTE_PORT 34
682 #define SV_LOCAL_ADDRESS 35
683 #define SV_OMAPI_KEY 36
684 #define SV_STASH_AGENT_OPTIONS 37
685 #define SV_DDNS_TTL 38
686 #define SV_DDNS_UPDATE_STYLE 39
687 #define SV_CLIENT_UPDATES 40
688 #define SV_UPDATE_OPTIMIZATION 41
689 #define SV_PING_CHECKS 42
690 #define SV_UPDATE_STATIC_LEASES 43
691 #define SV_LOG_FACILITY 44
692 #define SV_DO_FORWARD_UPDATES 45
693 #define SV_PING_TIMEOUT 46
694 #define SV_RESERVE_INFINITE 47
695 #define SV_DDNS_CONFLICT_DETECT 48
696 #define SV_LEASEQUERY 49
697 #define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
698 #define SV_DO_REVERSE_UPDATES 51
699 #define SV_FQDN_REPLY 52
700 #define SV_PREFER_LIFETIME 53
701 #define SV_DHCPV6_LEASE_FILE_NAME 54
702 #define SV_DHCPV6_PID_FILE_NAME 55
703 #define SV_LIMIT_ADDRS_PER_IA 56
704 #define SV_LIMIT_PREFS_PER_IA 57
705 #define SV_DELAYED_ACK 58
706 #define SV_MAX_ACK_DELAY 59
707 #if defined(LDAP_CONFIGURATION)
708 # define SV_LDAP_SERVER 60
709 # define SV_LDAP_PORT 61
710 # define SV_LDAP_USERNAME 62
711 # define SV_LDAP_PASSWORD 63
712 # define SV_LDAP_BASE_DN 64
713 # define SV_LDAP_METHOD 65
714 # define SV_LDAP_DEBUG_FILE 66
715 # define SV_LDAP_DHCP_SERVER_CN 67
716 # define SV_LDAP_REFERRALS 68
717 #if defined (LDAP_USE_SSL)
718 # define SV_LDAP_SSL 69
719 # define SV_LDAP_TLS_REQCERT 70
720 # define SV_LDAP_TLS_CA_FILE 71
721 # define SV_LDAP_TLS_CA_DIR 72
722 # define SV_LDAP_TLS_CERT 73
723 # define SV_LDAP_TLS_KEY 74
724 # define SV_LDAP_TLS_CRLCHECK 75
725 # define SV_LDAP_TLS_CIPHERS 76
726 # define SV_LDAP_TLS_RANDFILE 77
729 #define SV_CACHE_THRESHOLD 78
730 #define SV_DONT_USE_FSYNC 79
731 #define SV_DDNS_LOCAL_ADDRESS4 80
732 #define SV_DDNS_LOCAL_ADDRESS6 81
733 #define SV_IGNORE_CLIENT_UIDS 82
735 #if !defined (DEFAULT_PING_TIMEOUT)
736 # define DEFAULT_PING_TIMEOUT 1
739 #if !defined (DEFAULT_DELAYED_ACK)
740 # define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */
743 #if !defined (DEFAULT_ACK_DELAY_SECS)
744 # define DEFAULT_ACK_DELAY_SECS 0
747 #if !defined (DEFAULT_ACK_DELAY_USECS)
748 # define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
751 #if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
752 # define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */
755 #if !defined (DEFAULT_CACHE_THRESHOLD)
756 # define DEFAULT_CACHE_THRESHOLD 25
759 #if !defined (DEFAULT_DEFAULT_LEASE_TIME)
760 # define DEFAULT_DEFAULT_LEASE_TIME 43200
763 #if !defined (DEFAULT_MIN_LEASE_TIME)
764 # define DEFAULT_MIN_LEASE_TIME 300
767 #if !defined (DEFAULT_MAX_LEASE_TIME)
768 # define DEFAULT_MAX_LEASE_TIME 86400
771 #if !defined (DEFAULT_DDNS_TTL)
772 # define DEFAULT_DDNS_TTL 3600
774 #if !defined (MAX_DEFAULT_DDNS_TTL)
775 # define MAX_DEFAULT_DDNS_TTL 3600
778 #if !defined (MIN_LEASE_WRITE)
779 # define MIN_LEASE_WRITE 15
782 /* Client option names */
785 #define CL_SELECT_INTERVAL 2
786 #define CL_REBOOT_TIMEOUT 3
787 #define CL_RETRY_INTERVAL 4
788 #define CL_BACKOFF_CUTOFF 5
789 #define CL_INITIAL_INTERVAL 6
790 #define CL_BOOTP_POLICY 7
791 #define CL_SCRIPT_NAME 8
792 #define CL_REQUESTED_OPTIONS 9
793 #define CL_REQUESTED_LEASE_TIME 10
794 #define CL_SEND_OPTIONS 11
796 #define CL_REJECT_LIST 13
798 #ifndef CL_DEFAULT_TIMEOUT
799 # define CL_DEFAULT_TIMEOUT 60
802 #ifndef CL_DEFAULT_SELECT_INTERVAL
803 # define CL_DEFAULT_SELECT_INTERVAL 0
806 #ifndef CL_DEFAULT_REBOOT_TIMEOUT
807 # define CL_DEFAULT_REBOOT_TIMEOUT 10
810 #ifndef CL_DEFAULT_RETRY_INTERVAL
811 # define CL_DEFAULT_RETRY_INTERVAL 300
814 #ifndef CL_DEFAULT_BACKOFF_CUTOFF
815 # define CL_DEFAULT_BACKOFF_CUTOFF 120
818 #ifndef CL_DEFAULT_INITIAL_INTERVAL
819 # define CL_DEFAULT_INITIAL_INTERVAL 10
822 #ifndef CL_DEFAULT_BOOTP_POLICY
823 # define CL_DEFAULT_BOOTP_POLICY P_ACCEPT
826 #ifndef CL_DEFAULT_REQUESTED_OPTIONS
827 # define CL_DEFAULT_REQUESTED_OPTIONS \
829 DHO_BROADCAST_ADDRESS, \
833 DHO_DOMAIN_NAME_SERVERS, \
837 struct group_object
{
838 OMAPI_OBJECT_PREAMBLE
;
840 struct group_object
*n_dynamic
;
844 #define GROUP_OBJECT_DELETED 1
845 #define GROUP_OBJECT_DYNAMIC 2
846 #define GROUP_OBJECT_STATIC 4
849 /* Group of declarations that share common parameters. */
854 struct group_object
*object
;
855 struct subnet
*subnet
;
856 struct shared_network
*shared_network
;
858 struct executable_statement
*statements
;
861 /* A dhcp host declaration structure. */
863 OMAPI_OBJECT_PREAMBLE
;
864 struct host_decl
*n_ipaddr
;
865 struct host_decl
*n_dynamic
;
867 struct hardware interface
;
868 struct data_string client_identifier
;
869 struct option
*host_id_option
;
870 struct data_string host_id
;
871 /* XXXSK: fixed_addr should be an array of iaddr values,
872 not an option_cache, but it's referenced in a lot of
873 places, so we'll leave it for now. */
874 struct option_cache
*fixed_addr
;
875 struct iaddrcidrnetlist
*fixed_prefix
;
877 struct group_object
*named_group
;
878 struct data_string auth_key_id
;
880 #define HOST_DECL_DELETED 1
881 #define HOST_DECL_DYNAMIC 2
882 #define HOST_DECL_STATIC 4
883 /* For v6 the host-identifer option can specify which relay
884 to use when trying to look up an option. We store the
892 permit_unknown_clients
,
893 permit_known_clients
,
894 permit_authenticated_clients
,
895 permit_unauthenticated_clients
,
897 permit_dynamic_bootp_clients
,
902 TIME after
; /* date after which this clause applies */
906 OMAPI_OBJECT_PREAMBLE
;
909 struct shared_network
*shared_network
;
910 struct permit
*permit_list
;
911 struct permit
*prohibit_list
;
912 struct lease
*active
;
913 struct lease
*expired
;
915 struct lease
*backup
;
916 struct lease
*abandoned
;
917 struct lease
*reserved
;
918 TIME next_event_time
;
923 TIME valid_from
; /* deny pool use before this date */
924 TIME valid_until
; /* deny pool use after this date */
926 #if defined (FAILOVER_PROTOCOL)
927 dhcp_failover_state_t
*failover_peer
;
931 struct shared_network
{
932 OMAPI_OBJECT_PREAMBLE
;
933 struct shared_network
*next
;
936 #define SHARED_IMPLICIT 1 /* This network was synthesized. */
939 struct subnet
*subnets
;
940 struct interface_info
*interface
;
942 struct ipv6_pond
*ipv6_pond
;
944 #if defined (FAILOVER_PROTOCOL)
945 dhcp_failover_state_t
*failover_peer
;
950 OMAPI_OBJECT_PREAMBLE
;
951 struct subnet
*next_subnet
;
952 struct subnet
*next_sibling
;
953 struct shared_network
*shared_network
;
954 struct interface_info
*interface
;
955 struct iaddr interface_address
;
957 struct iaddr netmask
;
958 int prefix_len
; /* XXX: currently for IPv6 only */
963 struct collection
*next
;
966 struct class *classes
;
969 /* Used as an argument to parse_clasS_decl() */
970 #define CLASS_TYPE_VENDOR 0
971 #define CLASS_TYPE_USER 1
972 #define CLASS_TYPE_CLASS 2
973 #define CLASS_TYPE_SUBCLASS 3
975 /* XXX classes must be reference-counted. */
977 OMAPI_OBJECT_PREAMBLE
;
978 struct class *nic
; /* Next in collection. */
979 struct class *superclass
; /* Set for spawned classes only. */
980 char *name
; /* Not set for spawned classes. */
982 /* A class may be configured to permit a limited number of leases. */
985 struct lease
**billed_leases
;
987 /* If nonzero, class has not been saved since it was last
991 /* Hash table containing subclasses. */
993 struct data_string hash_string
;
995 /* Expression used to match class. */
996 struct expression
*expr
;
998 /* Expression used to compute subclass identifiers for spawning
999 and to do subclass matching. */
1000 struct expression
*submatch
;
1003 struct group
*group
;
1005 /* Statements to execute if class matches. */
1006 struct executable_statement
*statements
;
1008 #define CLASS_DECL_DELETED 1
1009 #define CLASS_DECL_DYNAMIC 2
1010 #define CLASS_DECL_STATIC 4
1011 #define CLASS_DECL_SUBCLASS 8
1016 /* DHCP client lease structure... */
1017 struct client_lease
{
1018 struct client_lease
*next
; /* Next lease in list. */
1019 TIME expiry
, renewal
, rebind
; /* Lease timeouts. */
1020 struct iaddr address
; /* Address being leased. */
1021 char *server_name
; /* Name of boot server. */
1022 char *filename
; /* Name of file we're supposed to boot. */
1023 struct string_list
*medium
; /* Network medium. */
1024 struct auth_key
*key
; /* Key used in basic DHCP authentication. */
1026 unsigned int is_static
: 1; /* If set, lease is from config file. */
1027 unsigned int is_bootp
: 1; /* If set, lease was acquired with BOOTP. */
1029 struct option_state
*options
; /* Options supplied with lease. */
1032 /* DHCPv6 lease structures */
1034 struct dhc6_addr
*next
;
1035 struct iaddr address
;
1038 /* Address state flags. */
1039 #define DHC6_ADDR_DEPREFFED 0x01
1040 #define DHC6_ADDR_EXPIRED 0x02
1044 u_int32_t preferred_life
;
1047 struct option_state
*options
;
1051 struct dhc6_ia
*next
;
1052 unsigned char iaid
[4];
1058 struct dhc6_addr
*addrs
;
1060 struct option_state
*options
;
1064 struct dhc6_lease
*next
;
1065 struct data_string server_id
;
1067 isc_boolean_t released
;
1071 unsigned char dhcpv6_transaction_id
[3];
1072 struct dhc6_ia
*bindings
;
1074 struct option_state
*options
;
1077 /* Possible states in which the client can be. */
1089 /* Authentication and BOOTP policy possibilities (not all values work
1091 enum policy
{ P_IGNORE
, P_ACCEPT
, P_PREFER
, P_REQUIRE
, P_DONT
};
1093 /* Configuration information from the config file... */
1094 struct client_config
{
1096 * When a message has been received, run these statements
1099 struct group
*on_receipt
;
1102 * When a message is sent, run these statements.
1104 struct group
*on_transmission
;
1106 struct option
**required_options
; /* Options that MUST be present. */
1107 struct option
**requested_options
; /* Options to request (ORO/PRL). */
1109 TIME timeout
; /* Start to panic if we don't get a
1110 lease in this time period when
1112 TIME initial_delay
; /* Set initial delay before first
1114 TIME initial_interval
; /* All exponential backoff intervals
1116 TIME retry_interval
; /* If the protocol failed to produce
1117 an address before the timeout,
1118 try the protocol again after this
1120 TIME select_interval
; /* Wait this many seconds from the
1121 first DHCPDISCOVER before
1122 picking an offered lease. */
1123 TIME reboot_timeout
; /* When in INIT-REBOOT, wait this
1124 long before giving up and going
1126 TIME backoff_cutoff
; /* When doing exponential backoff,
1127 never back off to an interval
1128 longer than this amount. */
1129 u_int32_t requested_lease
; /* Requested lease time, if user
1130 doesn't configure one. */
1131 struct string_list
*media
; /* Possible network media values. */
1132 char *script_name
; /* Name of config script. */
1133 char *vendor_space_name
; /* Name of config script. */
1134 enum policy bootp_policy
;
1135 /* Ignore, accept or prefer BOOTP
1137 enum policy auth_policy
;
1138 /* Require authentication, prefer
1139 authentication, or don't try to
1141 struct string_list
*medium
; /* Current network medium. */
1143 struct iaddrmatchlist
*reject_list
; /* Servers to reject. */
1145 int omapi_port
; /* port on which to accept OMAPI
1146 connections, or -1 for no
1148 int do_forward_update
; /* If nonzero, and if we have the
1149 information we need, update the
1150 A record for the address we get. */
1153 /* Per-interface state used in the dhcp client... */
1154 /* XXX: consider union {}'ing this for v4/v6. */
1155 struct client_state
{
1156 struct client_state
*next
;
1157 struct interface_info
*interface
;
1160 /* Common values. */
1161 struct client_config
*config
; /* Client configuration. */
1162 struct string_list
*env
; /* Client script environment. */
1163 int envc
; /* Number of entries in environment. */
1164 struct option_state
*sent_options
; /* Options we sent. */
1165 enum dhcp_state state
; /* Current state for this interface. */
1166 TIME last_write
; /* Last time this state was written. */
1168 /* DHCPv4 values. */
1169 struct client_lease
*active
; /* Currently active lease. */
1170 struct client_lease
*new; /* New lease. */
1171 struct client_lease
*offered_leases
; /* Leases offered to us. */
1172 struct client_lease
*leases
; /* Leases we currently hold. */
1173 struct client_lease
*alias
; /* Alias lease. */
1175 struct iaddr destination
; /* Where to send packet. */
1176 u_int32_t xid
; /* Transaction ID. */
1177 u_int16_t secs
; /* secs value from DHCPDISCOVER. */
1178 TIME first_sending
; /* When was first copy sent? */
1179 TIME interval
; /* What's the current resend interval? */
1180 struct string_list
*medium
; /* Last media type tried. */
1181 struct dhcp_packet packet
; /* Outgoing DHCP packet. */
1182 unsigned packet_length
; /* Actual length of generated packet. */
1184 struct iaddr requested_address
; /* Address we would like to get. */
1186 /* DHCPv6 values. */
1187 unsigned char dhcpv6_transaction_id
[3];
1188 u_int8_t refresh_type
;
1190 struct dhc6_lease
*active_lease
;
1191 struct dhc6_lease
*old_lease
;
1192 struct dhc6_lease
*advertised_leases
;
1193 struct dhc6_lease
*selected_lease
;
1194 struct dhc6_lease
*held_leases
;
1196 struct timeval start_time
;
1200 /* See RFC3315 section 14. */
1201 TIME RT
; /* In hundredths of seconds. */
1202 TIME IRT
; /* In hundredths of seconds. */
1203 TIME MRC
; /* Count. */
1204 TIME MRT
; /* In hundredths of seconds. */
1205 TIME MRD
; /* In seconds, relative. */
1206 TIME next_MRD
; /* In seconds, absolute. */
1208 /* Rather than a state, we use a function that shifts around
1209 * depending what stage of life the v6 state machine is in.
1210 * This is where incoming packets are dispatched to (sometimes
1213 void (*v6_handler
)(struct packet
*, struct client_state
*);
1216 * A pointer to the state of the ddns update for this lease.
1217 * It should be set while the update is in progress and cleared
1218 * when the update finishes. It can be used to cancel the
1219 * update if we want to do a different update.
1221 struct dhcp_ddns_cb
*ddns_cb
;
1224 struct envadd_state
{
1225 struct client_state
*client
;
1229 struct dns_update_state
{
1230 struct client_state
*client
;
1231 struct iaddr address
;
1232 int dns_update_timeout
;
1235 /* Information about each network interface. */
1237 struct interface_info
{
1238 OMAPI_OBJECT_PREAMBLE
;
1239 struct interface_info
*next
; /* Next interface in list... */
1240 struct shared_network
*shared_network
;
1241 /* Networks connected to this interface. */
1242 struct hardware hw_address
; /* Its physical address. */
1243 struct in_addr
*addresses
; /* Addresses associated with this
1246 int address_count
; /* Number of addresses stored. */
1247 int address_max
; /* Size of addresses buffer. */
1248 struct in6_addr
*v6addresses
; /* IPv6 addresses associated with
1250 int v6address_count
; /* Number of IPv6 addresses associated
1251 with this interface. */
1252 int v6address_max
; /* Maximum number of IPv6 addresses
1253 we can store in current buffer. */
1255 u_int8_t
*circuit_id
; /* Circuit ID associated with this
1257 unsigned circuit_id_len
; /* Length of Circuit ID, if there
1259 u_int8_t
*remote_id
; /* Remote ID associated with this
1260 interface (if any). */
1261 unsigned remote_id_len
; /* Length of Remote ID. */
1263 char name
[IFNAMSIZ
]; /* Its name... */
1264 int index
; /* Its if_nametoindex(). */
1265 int rfdesc
; /* Its read file descriptor. */
1266 int wfdesc
; /* Its write file descriptor, if
1268 unsigned char *rbuf
; /* Read buffer, if required. */
1269 unsigned int rbuf_max
; /* Size of read buffer. */
1270 size_t rbuf_offset
; /* Current offset into buffer. */
1271 size_t rbuf_len
; /* Length of data in buffer. */
1273 struct ifreq
*ifp
; /* Pointer to ifreq struct. */
1274 int configured
; /* If set to 1, interface has at least
1275 * one valid IP address.
1277 u_int32_t flags
; /* Control flags... */
1278 #define INTERFACE_REQUESTED 1
1279 #define INTERFACE_AUTOMATIC 2
1280 #define INTERFACE_RUNNING 4
1281 #define INTERFACE_DOWNSTREAM 8
1282 #define INTERFACE_UPSTREAM 16
1283 #define INTERFACE_STREAMS (INTERFACE_DOWNSTREAM | INTERFACE_UPSTREAM)
1285 /* Only used by DHCP client code. */
1286 struct client_state
*client
;
1287 # if defined(USE_DLPI_SEND) || defined(USE_DLPI_RECEIVE) || \
1288 defined(USE_DLPI_HWADDR)
1289 int dlpi_sap_length
;
1290 struct hardware dlpi_broadcast_addr
;
1291 # endif /* DLPI_SEND || DLPI_RECEIVE */
1292 struct hardware anycast_mac_addr
;
1295 struct hardware_link
{
1296 struct hardware_link
*next
;
1297 char name
[IFNAMSIZ
];
1298 struct hardware address
;
1302 struct leasequeue
*prev
;
1303 struct leasequeue
*next
;
1304 struct lease
*lease
;
1307 typedef void (*tvref_t
)(void *, void *, const char *, int);
1308 typedef void (*tvunref_t
)(void *, const char *, int);
1310 struct timeout
*next
;
1311 struct timeval when
;
1312 void (*func
) (void *);
1316 isc_timer_t
*isc_timeout
;
1320 struct eventqueue
*next
;
1321 void (*handler
)(void *);
1325 struct protocol
*next
;
1327 void (*handler
) (struct protocol
*);
1331 struct dns_query
; /* forward */
1334 struct dns_wakeup
*next
; /* Next wakeup in chain. */
1335 void (*func
) (struct dns_query
*);
1338 struct dns_question
{
1339 u_int16_t type
; /* Type of query. */
1340 u_int16_t
class; /* Class of query. */
1341 unsigned char data
[1]; /* Query data. */
1345 u_int16_t type
; /* Type of answer. */
1346 u_int16_t
class; /* Class of answer. */
1347 int count
; /* Number of answers. */
1348 unsigned char *answers
[1]; /* Pointers to answers. */
1352 struct dns_query
*next
; /* Next query in hash bucket. */
1353 u_int32_t hash
; /* Hash bucket index. */
1354 TIME expiry
; /* Query expiry time (zero if not yet
1356 u_int16_t id
; /* Query ID (also hash table index) */
1357 caddr_t waiters
; /* Pointer to list of things waiting
1360 struct dns_question
*question
; /* Question, internal format. */
1361 struct dns_answer
*answer
; /* Answer, internal format. */
1363 unsigned char *query
; /* Query formatted for DNS server. */
1364 unsigned len
; /* Length of entire query. */
1365 int sent
; /* The query has been sent. */
1366 struct dns_wakeup
*wakeups
; /* Wakeups to call if this query is
1368 struct name_server
*next_server
; /* Next server to try. */
1369 int backoff
; /* Current backoff, in seconds. */
1372 #define DNS_ZONE_ACTIVE 0
1373 #define DNS_ZONE_INACTIVE 1
1378 struct option_cache
*primary
;
1379 struct option_cache
*secondary
;
1380 struct option_cache
*primary6
;
1381 struct option_cache
*secondary6
;
1382 struct auth_key
*key
;
1387 OMAPI_OBJECT_PREAMBLE
;
1389 void (*icmp_handler
) (struct iaddr
, u_int8_t
*, int);
1394 /* Bitmask of dhcp option codes. */
1395 typedef unsigned char option_mask
[16];
1397 /* DHCP Option mask manipulation macros... */
1398 #define OPTION_ZERO(mask) (memset (mask, 0, 16))
1399 #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
1400 #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
1401 #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
1402 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
1404 /* An option occupies its length plus two header bytes (code and
1405 length) for every 255 bytes that must be stored. */
1406 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
1408 /* Default path to dhcpd config file. */
1410 #undef _PATH_DHCPD_CONF
1411 #define _PATH_DHCPD_CONF "dhcpd.conf"
1412 #undef _PATH_DHCPD_DB
1413 #define _PATH_DHCPD_DB "dhcpd.leases"
1414 #undef _PATH_DHCPD6_DB
1415 #define _PATH_DHCPD6_DB "dhcpd6.leases"
1416 #undef _PATH_DHCPD_PID
1417 #define _PATH_DHCPD_PID "dhcpd.pid"
1418 #undef _PATH_DHCPD6_PID
1419 #define _PATH_DHCPD6_PID "dhcpd6.pid"
1422 #ifndef _PATH_DHCPD_CONF
1423 #define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
1426 #ifndef _PATH_DHCPD_DB
1427 #define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
1430 #ifndef _PATH_DHCPD6_DB
1431 #define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
1434 #ifndef _PATH_DHCPD_PID
1435 #define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid"
1438 #ifndef _PATH_DHCPD6_PID
1439 #define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid"
1444 #ifndef _PATH_DHCLIENT_CONF
1445 #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
1448 #ifndef _PATH_DHCLIENT_SCRIPT
1449 #define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script"
1452 #ifndef _PATH_DHCLIENT_PID
1453 #define _PATH_DHCLIENT_PID LOCALSTATEDIR"/run/dhclient.pid"
1456 #ifndef _PATH_DHCLIENT6_PID
1457 #define _PATH_DHCLIENT6_PID LOCALSTATEDIR"/run/dhclient6.pid"
1460 #ifndef _PATH_DHCLIENT_DB
1461 #define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases"
1464 #ifndef _PATH_DHCLIENT6_DB
1465 #define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases"
1468 #ifndef _PATH_RESOLV_CONF
1469 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
1472 #ifndef _PATH_DHCRELAY_PID
1473 #define _PATH_DHCRELAY_PID LOCALSTATEDIR"/run/dhcrelay.pid"
1476 #ifndef _PATH_DHCRELAY6_PID
1477 #define _PATH_DHCRELAY6_PID LOCALSTATEDIR"/run/dhcrelay6.pid"
1480 #ifndef DHCPD_LOG_FACILITY
1481 #define DHCPD_LOG_FACILITY LOG_DAEMON
1484 #define MAX_TIME 0x7fffffff
1487 /* these are referenced */
1488 typedef struct hash_table ia_hash_t
;
1489 typedef struct hash_table iasubopt_hash_t
;
1491 /* IAADDR/IAPREFIX lease */
1494 int refcnt
; /* reference count */
1495 struct in6_addr addr
; /* IPv6 address/prefix */
1496 u_int8_t plen
; /* iaprefix prefix length */
1497 binding_state_t state
; /* state */
1498 struct binding_scope
*scope
; /* "set var = value;" */
1499 time_t hard_lifetime_end_time
; /* time address expires */
1500 time_t soft_lifetime_end_time
; /* time ephemeral expires */
1501 u_int32_t prefer
; /* cached preferred lifetime */
1502 u_int32_t valid
; /* cached valid lifetime */
1503 struct ia_xx
*ia
; /* IA for this lease */
1504 struct ipv6_pool
*ipv6_pool
; /* pool for this lease */
1506 * For now, just pick an arbitrary time to keep old hard leases
1507 * around (value in seconds).
1509 #define EXPIRED_IPV6_CLEANUP_TIME (60*60)
1511 int heap_index
; /* index into heap, or -1
1512 (internal use only) */
1515 * A pointer to the state of the ddns update for this lease.
1516 * It should be set while the update is in progress and cleared
1517 * when the update finishes. It can be used to cancel the
1518 * update if we want to do a different update.
1520 struct dhcp_ddns_cb
*ddns_cb
;
1522 /* space for the on * executable statements */
1523 struct on_star on_star
;
1527 int refcnt
; /* reference count */
1528 struct data_string iaid_duid
; /* from the client */
1529 u_int16_t ia_type
; /* IA_XX */
1530 int num_iasubopt
; /* number of IAADDR/PREFIX */
1531 int max_iasubopt
; /* space available for IAADDR/PREFIX */
1532 time_t cltt
; /* client last transaction time */
1533 struct iasubopt
**iasubopt
; /* pointers to the IAADDR/IAPREFIXs */
1536 extern ia_hash_t
*ia_na_active
;
1537 extern ia_hash_t
*ia_ta_active
;
1538 extern ia_hash_t
*ia_pd_active
;
1542 * \brief ipv6_pool structure
1544 * This structure is part of a range of addresses or prefixes.
1545 * A range6 or prefix6 statement will map to one or more of these
1546 * with each pool being a simple block of the form xxxx/yyy and
1547 * all the pools adding up to comprise the entire range. When
1548 * choosing an address or prefix the code will walk through the
1549 * pools until it finds one that is available.
1551 * The naming for this structure is unfortunate as there is also
1552 * a v4 pool structure and the two are not equivalent. The v4
1553 * pool matches the ipv6_pond structure. I considered changing the
1554 * name of this structure but concluded that doing so would be worse
1555 * than leaving it as is. Changing it adds some risk and makes for
1556 * larger differences between the 4.1 & 4.2 code and the 4.3 code.
1561 int refcnt
; /* reference count */
1562 u_int16_t pool_type
; /* IA_xx */
1563 struct in6_addr start_addr
; /* first IPv6 address */
1564 int bits
; /* number of bits, CIDR style */
1565 int units
; /* allocation unit in bits */
1566 iasubopt_hash_t
*leases
; /* non-free leases */
1567 int num_active
; /* count of active leases */
1568 isc_heap_t
*active_timeouts
; /* timeouts for active leases */
1569 int num_inactive
; /* count of inactive leases */
1570 isc_heap_t
*inactive_timeouts
; /* timeouts for expired or
1572 struct shared_network
*shared_network
; /* shared_network for
1574 struct subnet
*subnet
; /* subnet for this pool */
1575 struct ipv6_pond
*ipv6_pond
; /* pond for this pool */
1580 * \brief ipv6_pond structure
1582 * This structure is the ipv6 version of the v4 pool structure.
1583 * It contains the address and prefix information via the pointers
1584 * to the ipv6_pools and the allowability of this pool for a given
1585 * client via the permit lists and the valid TIMEs.
1591 struct ipv6_pond
*next
;
1592 struct group
*group
;
1593 struct shared_network
*shared_network
; /* backpointer to the enclosing
1595 struct permit
*permit_list
; /* allow clients from this list */
1596 struct permit
*prohibit_list
; /* deny clients from this list */
1597 TIME valid_from
; /* deny pool use before this date */
1598 TIME valid_until
; /* deny pool use after this date */
1600 struct ipv6_pool
**ipv6_pools
; /* NULL-terminated array */
1601 int last_ipv6_pool
; /* offset of last IPv6 pool
1602 used to issue a lease */
1605 /* Flags and state for dhcp_ddns_cb_t */
1606 #define DDNS_UPDATE_ADDR 0x01
1607 #define DDNS_UPDATE_PTR 0x02
1608 #define DDNS_INCLUDE_RRSET 0x04
1609 #define DDNS_CONFLICT_OVERRIDE 0x08
1610 #define DDNS_CLIENT_DID_UPDATE 0x10
1611 #define DDNS_EXECUTE_NEXT 0x20
1612 #define DDNS_ABORT 0x40
1613 #define DDNS_STATIC_LEASE 0x80
1614 #define DDNS_ACTIVE_LEASE 0x100
1616 * The following two groups are separate and we could reuse
1617 * values but not reusing them may be useful in the future.
1619 #define DDNS_STATE_CLEANUP 0 // The previous step failed, cleanup
1621 #define DDNS_STATE_ADD_FW_NXDOMAIN 1
1622 #define DDNS_STATE_ADD_FW_YXDHCID 2
1623 #define DDNS_STATE_ADD_PTR 3
1625 #define DDNS_STATE_REM_FW_YXDHCID 17
1626 #define DDNS_STATE_REM_FW_NXRR 18
1627 #define DDNS_STATE_REM_PTR 19
1630 * Flags for the dns print function
1632 #define DDNS_PRINT_INBOUND 1
1633 #define DDNS_PRINT_OUTBOUND 0
1635 struct dhcp_ddns_cb
;
1637 typedef void (*ddns_action_t
)(struct dhcp_ddns_cb
*ddns_cb
,
1638 isc_result_t result
);
1640 typedef struct dhcp_ddns_cb
{
1641 struct data_string fwd_name
;
1642 struct data_string rev_name
;
1643 struct data_string dhcid
;
1644 struct iaddr address
;
1649 unsigned char zone_name
[DHCP_MAXDNS_WIRE
];
1650 isc_sockaddrlist_t zone_server_list
;
1651 isc_sockaddr_t zone_addrs
[DHCP_MAXNS
];
1652 int zone_addr_count
;
1653 struct dns_zone
*zone
;
1658 ddns_action_t cur_func
;
1660 struct dhcp_ddns_cb
* next_op
;
1662 /* Lease or client state that triggered the ddns operation */
1664 struct binding_scope
**scope
;
1669 dns_rdataclass_t dhcid_class
;
1673 extern struct ipv6_pool
**pools
;
1674 extern int num_pools
;
1676 /* External definitions... */
1678 HASH_FUNCTIONS_DECL (group
, const char *, struct group_object
, group_hash_t
)
1679 HASH_FUNCTIONS_DECL (universe
, const char *, struct universe
, universe_hash_t
)
1680 HASH_FUNCTIONS_DECL (option_name
, const char *, struct option
,
1682 HASH_FUNCTIONS_DECL (option_code
, const unsigned *, struct option
,
1684 HASH_FUNCTIONS_DECL (dns_zone
, const char *, struct dns_zone
, dns_zone_hash_t
)
1685 HASH_FUNCTIONS_DECL(lease_ip
, const unsigned char *, struct lease
,
1687 HASH_FUNCTIONS_DECL(lease_id
, const unsigned char *, struct lease
,
1689 HASH_FUNCTIONS_DECL (host
, const unsigned char *, struct host_decl
, host_hash_t
)
1690 HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t
)
1694 extern struct option
*vendor_cfg_option
;
1695 int parse_options (struct packet
*);
1696 int parse_option_buffer (struct option_state
*, const unsigned char *,
1697 unsigned, struct universe
*);
1698 struct universe
*find_option_universe (struct option
*, const char *);
1699 int parse_encapsulated_suboptions (struct option_state
*, struct option
*,
1700 const unsigned char *, unsigned,
1701 struct universe
*, const char *);
1702 int cons_options (struct packet
*, struct dhcp_packet
*, struct lease
*,
1703 struct client_state
*,
1704 int, struct option_state
*, struct option_state
*,
1705 struct binding_scope
**,
1706 int, int, int, struct data_string
*, const char *);
1707 int fqdn_universe_decode (struct option_state
*,
1708 const unsigned char *, unsigned, struct universe
*);
1709 struct option_cache
*
1710 lookup_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1713 save_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1714 struct option_cache
*oc
, isc_boolean_t appendp
);
1716 delete_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1719 fqdn6_option_space_foreach(struct packet
*packet
, struct lease
*lease
,
1720 struct client_state
*client_state
,
1721 struct option_state
*in_options
,
1722 struct option_state
*cfg_options
,
1723 struct binding_scope
**scope
,
1724 struct universe
*u
, void *stuff
,
1725 void (*func
)(struct option_cache
*,
1728 struct client_state
*,
1729 struct option_state
*,
1730 struct option_state
*,
1731 struct binding_scope
**,
1732 struct universe
*, void *));
1734 fqdn6_option_space_encapsulate(struct data_string
*result
,
1735 struct packet
*packet
, struct lease
*lease
,
1736 struct client_state
*client_state
,
1737 struct option_state
*in_options
,
1738 struct option_state
*cfg_options
,
1739 struct binding_scope
**scope
,
1740 struct universe
*universe
);
1742 fqdn6_universe_decode(struct option_state
*options
,
1743 const unsigned char *buffer
, unsigned length
,
1744 struct universe
*u
);
1745 int append_option(struct data_string
*dst
, struct universe
*universe
,
1746 struct option
*option
, struct data_string
*src
);
1748 store_options(int *ocount
,
1749 unsigned char *buffer
, unsigned buflen
, unsigned index
,
1750 struct packet
*packet
, struct lease
*lease
,
1751 struct client_state
*client_state
,
1752 struct option_state
*in_options
,
1753 struct option_state
*cfg_options
,
1754 struct binding_scope
**scope
,
1755 unsigned *priority_list
, int priority_len
,
1756 unsigned first_cutoff
, int second_cutoff
, int terminate
,
1757 const char *vuname
);
1758 int store_options6(char *, int, struct option_state
*, struct packet
*,
1759 const int *, struct data_string
*);
1760 int format_has_text(const char *);
1761 int format_min_length(const char *, struct option_cache
*);
1762 const char *pretty_print_option (struct option
*, const unsigned char *,
1763 unsigned, int, int);
1764 int pretty_escape(char **, char *, const unsigned char **,
1765 const unsigned char *);
1766 int get_option (struct data_string
*, struct universe
*,
1767 struct packet
*, struct lease
*, struct client_state
*,
1768 struct option_state
*, struct option_state
*,
1769 struct option_state
*, struct binding_scope
**, unsigned,
1771 void set_option (struct universe
*, struct option_state
*,
1772 struct option_cache
*, enum statement_op
);
1773 struct option_cache
*lookup_option (struct universe
*,
1774 struct option_state
*, unsigned);
1775 struct option_cache
*lookup_hashed_option (struct universe
*,
1776 struct option_state
*,
1778 struct option_cache
*next_hashed_option(struct universe
*,
1779 struct option_state
*,
1780 struct option_cache
*);
1781 int save_option_buffer (struct universe
*, struct option_state
*,
1782 struct buffer
*, unsigned char *, unsigned,
1784 int append_option_buffer(struct universe
*, struct option_state
*,
1785 struct buffer
*, unsigned char *, unsigned,
1787 void build_server_oro(struct data_string
*, struct option_state
*,
1789 void save_option(struct universe
*, struct option_state
*,
1790 struct option_cache
*);
1791 void also_save_option(struct universe
*, struct option_state
*,
1792 struct option_cache
*);
1793 void save_hashed_option(struct universe
*, struct option_state
*,
1794 struct option_cache
*, isc_boolean_t appendp
);
1795 void delete_option (struct universe
*, struct option_state
*, int);
1796 void delete_hashed_option (struct universe
*,
1797 struct option_state
*, int);
1798 int option_cache_dereference (struct option_cache
**,
1800 int hashed_option_state_dereference (struct universe
*,
1801 struct option_state
*,
1803 int store_option (struct data_string
*,
1804 struct universe
*, struct packet
*, struct lease
*,
1805 struct client_state
*,
1806 struct option_state
*, struct option_state
*,
1807 struct binding_scope
**, struct option_cache
*);
1808 int option_space_encapsulate (struct data_string
*,
1809 struct packet
*, struct lease
*,
1810 struct client_state
*,
1811 struct option_state
*,
1812 struct option_state
*,
1813 struct binding_scope
**,
1814 struct data_string
*);
1815 int hashed_option_space_encapsulate (struct data_string
*,
1816 struct packet
*, struct lease
*,
1817 struct client_state
*,
1818 struct option_state
*,
1819 struct option_state
*,
1820 struct binding_scope
**,
1822 int nwip_option_space_encapsulate (struct data_string
*,
1823 struct packet
*, struct lease
*,
1824 struct client_state
*,
1825 struct option_state
*,
1826 struct option_state
*,
1827 struct binding_scope
**,
1829 int fqdn_option_space_encapsulate (struct data_string
*,
1830 struct packet
*, struct lease
*,
1831 struct client_state
*,
1832 struct option_state
*,
1833 struct option_state
*,
1834 struct binding_scope
**,
1836 void suboption_foreach (struct packet
*, struct lease
*, struct client_state
*,
1837 struct option_state
*, struct option_state
*,
1838 struct binding_scope
**, struct universe
*, void *,
1839 void (*) (struct option_cache
*, struct packet
*,
1840 struct lease
*, struct client_state
*,
1841 struct option_state
*, struct option_state
*,
1842 struct binding_scope
**,
1843 struct universe
*, void *),
1844 struct option_cache
*, const char *);
1845 void option_space_foreach (struct packet
*, struct lease
*,
1846 struct client_state
*,
1847 struct option_state
*,
1848 struct option_state
*,
1849 struct binding_scope
**,
1850 struct universe
*, void *,
1851 void (*) (struct option_cache
*,
1853 struct lease
*, struct client_state
*,
1854 struct option_state
*,
1855 struct option_state
*,
1856 struct binding_scope
**,
1857 struct universe
*, void *));
1858 void hashed_option_space_foreach (struct packet
*, struct lease
*,
1859 struct client_state
*,
1860 struct option_state
*,
1861 struct option_state
*,
1862 struct binding_scope
**,
1863 struct universe
*, void *,
1864 void (*) (struct option_cache
*,
1867 struct client_state
*,
1868 struct option_state
*,
1869 struct option_state
*,
1870 struct binding_scope
**,
1871 struct universe
*, void *));
1872 int linked_option_get (struct data_string
*, struct universe
*,
1873 struct packet
*, struct lease
*,
1874 struct client_state
*,
1875 struct option_state
*, struct option_state
*,
1876 struct option_state
*, struct binding_scope
**,
1878 int linked_option_state_dereference (struct universe
*,
1879 struct option_state
*,
1881 void save_linked_option(struct universe
*, struct option_state
*,
1882 struct option_cache
*, isc_boolean_t appendp
);
1883 void linked_option_space_foreach (struct packet
*, struct lease
*,
1884 struct client_state
*,
1885 struct option_state
*,
1886 struct option_state
*,
1887 struct binding_scope
**,
1888 struct universe
*, void *,
1889 void (*) (struct option_cache
*,
1892 struct client_state
*,
1893 struct option_state
*,
1894 struct option_state
*,
1895 struct binding_scope
**,
1896 struct universe
*, void *));
1897 int linked_option_space_encapsulate (struct data_string
*, struct packet
*,
1898 struct lease
*, struct client_state
*,
1899 struct option_state
*,
1900 struct option_state
*,
1901 struct binding_scope
**,
1903 void delete_linked_option (struct universe
*, struct option_state
*, int);
1904 struct option_cache
*lookup_linked_option (struct universe
*,
1905 struct option_state
*, unsigned);
1906 void do_packet (struct interface_info
*,
1907 struct dhcp_packet
*, unsigned,
1908 unsigned int, struct iaddr
, struct hardware
*);
1909 void do_packet6(struct interface_info
*, const char *,
1910 int, int, const struct iaddr
*, isc_boolean_t
);
1911 int packet6_len_okay(const char *, int);
1913 int validate_packet(struct packet
*);
1915 int add_option(struct option_state
*options
,
1916 unsigned int option_num
,
1918 unsigned int data_len
);
1921 extern struct timeval cur_tv
;
1922 #define cur_time cur_tv.tv_sec
1924 extern int ddns_update_style
;
1925 extern int dont_use_fsync
;
1927 extern const char *path_dhcpd_conf
;
1928 extern const char *path_dhcpd_db
;
1929 extern const char *path_dhcpd_pid
;
1931 extern int dhcp_max_agent_option_packet_length
;
1932 extern struct eventqueue
*rw_queue_empty
;
1934 int main(int, char **);
1935 void postconf_initialization(int);
1936 void postdb_startup(void);
1937 void cleanup (void);
1938 void lease_pinged (struct iaddr
, u_int8_t
*, int);
1939 void lease_ping_timeout (void *);
1940 int dhcpd_interface_setup_hook (struct interface_info
*ip
, struct iaddr
*ia
);
1941 extern enum dhcp_shutdown_state shutdown_state
;
1942 isc_result_t
dhcp_io_shutdown (omapi_object_t
*, void *);
1943 isc_result_t
dhcp_set_control_state (control_object_state_t oldstate
,
1944 control_object_state_t newstate
);
1945 #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1946 void relinquish_ackqueue(void);
1950 isc_result_t
new_parse (struct parse
**, int,
1951 char *, unsigned, const char *, int);
1952 isc_result_t
end_parse (struct parse
**);
1953 isc_result_t
save_parse_state(struct parse
*cfile
);
1954 isc_result_t
restore_parse_state(struct parse
*cfile
);
1955 enum dhcp_token
next_token (const char **, unsigned *, struct parse
*);
1956 enum dhcp_token
peek_token (const char **, unsigned *, struct parse
*);
1957 enum dhcp_token
next_raw_token(const char **rval
, unsigned *rlen
,
1958 struct parse
*cfile
);
1959 enum dhcp_token
peek_raw_token(const char **rval
, unsigned *rlen
,
1960 struct parse
*cfile
);
1962 * Use skip_token when we are skipping a token we have previously
1963 * used peek_token on as we know what the result will be in this case.
1965 #define skip_token(a,b,c) ((void) next_token((a),(b),(c)))
1969 void parse_trace_setup (void);
1970 isc_result_t
readconf (void);
1971 isc_result_t
read_conf_file (const char *, struct group
*, int, int);
1972 #if defined (TRACING)
1973 void trace_conf_input (trace_type_t
*, unsigned, char *);
1974 void trace_conf_stop (trace_type_t
*ttype
);
1976 isc_result_t
conf_file_subparse (struct parse
*, struct group
*, int);
1977 isc_result_t
lease_file_subparse (struct parse
*);
1978 int parse_statement (struct parse
*, struct group
*, int,
1979 struct host_decl
*, int);
1980 #if defined (FAILOVER_PROTOCOL)
1981 void parse_failover_peer (struct parse
*, struct group
*, int);
1982 void parse_failover_state_declaration (struct parse
*,
1983 dhcp_failover_state_t
*);
1984 void parse_failover_state (struct parse
*,
1985 enum failover_state
*, TIME
*);
1987 int permit_list_match (struct permit
*, struct permit
*);
1988 void parse_pool_statement (struct parse
*, struct group
*, int);
1989 int parse_lbrace (struct parse
*);
1990 void parse_host_declaration (struct parse
*, struct group
*);
1991 int parse_class_declaration (struct class **, struct parse
*,
1992 struct group
*, int);
1993 void parse_shared_net_declaration (struct parse
*, struct group
*);
1994 void parse_subnet_declaration (struct parse
*,
1995 struct shared_network
*);
1996 void parse_subnet6_declaration (struct parse
*,
1997 struct shared_network
*);
1998 void parse_group_declaration (struct parse
*, struct group
*);
1999 int parse_fixed_addr_param (struct option_cache
**,
2000 struct parse
*, enum dhcp_token
);
2001 int parse_lease_declaration (struct lease
**, struct parse
*);
2002 int parse_ip6_addr(struct parse
*, struct iaddr
*);
2003 int parse_ip6_addr_expr(struct expression
**, struct parse
*);
2004 int parse_ip6_prefix(struct parse
*, struct iaddr
*, u_int8_t
*);
2005 void parse_address_range (struct parse
*, struct group
*, int,
2006 struct pool
*, struct lease
**);
2007 void parse_address_range6(struct parse
*cfile
, struct group
*group
,
2008 struct ipv6_pond
*);
2009 void parse_prefix6(struct parse
*cfile
, struct group
*group
,
2010 struct ipv6_pond
*);
2011 void parse_fixed_prefix6(struct parse
*cfile
, struct host_decl
*host_decl
);
2012 void parse_ia_na_declaration(struct parse
*);
2013 void parse_ia_ta_declaration(struct parse
*);
2014 void parse_ia_pd_declaration(struct parse
*);
2015 void parse_server_duid(struct parse
*cfile
);
2016 void parse_server_duid_conf(struct parse
*cfile
);
2017 void parse_pool6_statement (struct parse
*, struct group
*, int);
2020 int ddns_updates(struct packet
*, struct lease
*, struct lease
*,
2021 struct iasubopt
*, struct iasubopt
*, struct option_state
*);
2022 isc_result_t
ddns_removals(struct lease
*, struct iasubopt
*,
2023 struct dhcp_ddns_cb
*, isc_boolean_t
);
2024 #if defined (TRACING)
2025 void trace_ddns_init(void);
2029 void add_enumeration (struct enumeration
*);
2030 struct enumeration
*find_enumeration (const char *, int);
2031 struct enumeration_value
*find_enumeration_value (const char *, int,
2034 void skip_to_semi (struct parse
*);
2035 void skip_to_rbrace (struct parse
*, int);
2036 int parse_semi (struct parse
*);
2037 int parse_string (struct parse
*, char **, unsigned *);
2038 char *parse_host_name (struct parse
*);
2039 int parse_ip_addr_or_hostname (struct expression
**,
2040 struct parse
*, int);
2041 void parse_hardware_param (struct parse
*, struct hardware
*);
2042 void parse_lease_time (struct parse
*, TIME
*);
2043 unsigned char *parse_numeric_aggregate (struct parse
*,
2044 unsigned char *, unsigned *,
2045 int, int, unsigned);
2046 void convert_num (struct parse
*, unsigned char *, const char *,
2048 TIME
parse_date (struct parse
*);
2049 TIME
parse_date_core(struct parse
*);
2050 isc_result_t
parse_option_name (struct parse
*, int, int *,
2052 void parse_option_space_decl (struct parse
*);
2053 int parse_option_code_definition (struct parse
*, struct option
*);
2054 int parse_base64 (struct data_string
*, struct parse
*);
2055 int parse_cshl (struct data_string
*, struct parse
*);
2056 int parse_executable_statement (struct executable_statement
**,
2057 struct parse
*, int *,
2058 enum expression_context
);
2059 int parse_executable_statements (struct executable_statement
**,
2060 struct parse
*, int *,
2061 enum expression_context
);
2062 int parse_zone (struct dns_zone
*, struct parse
*);
2063 int parse_key (struct parse
*);
2064 int parse_on_statement (struct executable_statement
**,
2065 struct parse
*, int *);
2066 int parse_switch_statement (struct executable_statement
**,
2067 struct parse
*, int *);
2068 int parse_case_statement (struct executable_statement
**,
2069 struct parse
*, int *,
2070 enum expression_context
);
2071 int parse_if_statement (struct executable_statement
**,
2072 struct parse
*, int *);
2073 int parse_boolean_expression (struct expression
**,
2074 struct parse
*, int *);
2075 int parse_boolean (struct parse
*);
2076 int parse_data_expression (struct expression
**,
2077 struct parse
*, int *);
2078 int parse_numeric_expression (struct expression
**,
2079 struct parse
*, int *);
2080 int parse_dns_expression (struct expression
**, struct parse
*, int *);
2081 int parse_non_binary (struct expression
**, struct parse
*, int *,
2082 enum expression_context
);
2083 int parse_expression (struct expression
**, struct parse
*, int *,
2084 enum expression_context
,
2085 struct expression
**, enum expr_op
);
2086 int parse_option_data(struct expression
**expr
, struct parse
*cfile
,
2087 int lookups
, struct option
*option
);
2088 int parse_option_statement (struct executable_statement
**,
2089 struct parse
*, int,
2090 struct option
*, enum statement_op
);
2091 int parse_option_token (struct expression
**, struct parse
*,
2092 const char **, struct expression
*, int, int);
2093 int parse_allow_deny (struct option_cache
**, struct parse
*, int);
2094 int parse_auth_key (struct data_string
*, struct parse
*);
2095 int parse_warn (struct parse
*, const char *, ...)
2096 __attribute__((__format__(__printf__
,2,3)));
2097 struct expression
*parse_domain_list(struct parse
*cfile
, int);
2101 extern struct binding_scope
*global_scope
;
2102 pair
cons (caddr_t
, pair
);
2103 int make_const_option_cache (struct option_cache
**, struct buffer
**,
2104 u_int8_t
*, unsigned, struct option
*,
2106 int make_host_lookup (struct expression
**, const char *);
2107 int enter_dns_host (struct dns_host_entry
**, const char *);
2108 int make_const_data (struct expression
**,
2109 const unsigned char *, unsigned, int, int,
2111 int make_const_int (struct expression
**, unsigned long);
2112 int make_concat (struct expression
**,
2113 struct expression
*, struct expression
*);
2114 int make_encapsulation (struct expression
**, struct data_string
*);
2115 int make_substring (struct expression
**, struct expression
*,
2116 struct expression
*, struct expression
*);
2117 int make_limit (struct expression
**, struct expression
*, int);
2118 int make_let (struct executable_statement
**, const char *);
2119 int option_cache (struct option_cache
**, struct data_string
*,
2120 struct expression
*, struct option
*,
2122 int evaluate_expression (struct binding_value
**, struct packet
*,
2123 struct lease
*, struct client_state
*,
2124 struct option_state
*, struct option_state
*,
2125 struct binding_scope
**, struct expression
*,
2127 int binding_value_dereference (struct binding_value
**, const char *, int);
2128 int evaluate_boolean_expression (int *,
2129 struct packet
*, struct lease
*,
2130 struct client_state
*,
2131 struct option_state
*,
2132 struct option_state
*,
2133 struct binding_scope
**,
2134 struct expression
*);
2135 int evaluate_data_expression (struct data_string
*,
2136 struct packet
*, struct lease
*,
2137 struct client_state
*,
2138 struct option_state
*,
2139 struct option_state
*,
2140 struct binding_scope
**,
2141 struct expression
*,
2143 int evaluate_numeric_expression (unsigned long *, struct packet
*,
2144 struct lease
*, struct client_state
*,
2145 struct option_state
*, struct option_state
*,
2146 struct binding_scope
**,
2147 struct expression
*);
2148 int evaluate_option_cache (struct data_string
*,
2149 struct packet
*, struct lease
*,
2150 struct client_state
*,
2151 struct option_state
*, struct option_state
*,
2152 struct binding_scope
**,
2153 struct option_cache
*,
2155 int evaluate_boolean_option_cache (int *,
2156 struct packet
*, struct lease
*,
2157 struct client_state
*,
2158 struct option_state
*,
2159 struct option_state
*,
2160 struct binding_scope
**,
2161 struct option_cache
*,
2163 int evaluate_boolean_expression_result (int *,
2164 struct packet
*, struct lease
*,
2165 struct client_state
*,
2166 struct option_state
*,
2167 struct option_state
*,
2168 struct binding_scope
**,
2169 struct expression
*);
2170 void expression_dereference (struct expression
**, const char *, int);
2171 int is_dns_expression (struct expression
*);
2172 int is_boolean_expression (struct expression
*);
2173 int is_data_expression (struct expression
*);
2174 int is_numeric_expression (struct expression
*);
2175 int is_compound_expression (struct expression
*);
2176 int op_precedence (enum expr_op
, enum expr_op
);
2177 enum expression_context
expression_context (struct expression
*);
2178 enum expression_context
op_context (enum expr_op
);
2179 int write_expression (FILE *, struct expression
*, int, int, int);
2180 struct binding
*find_binding (struct binding_scope
*, const char *);
2181 int free_bindings (struct binding_scope
*, const char *, int);
2182 int binding_scope_dereference (struct binding_scope
**,
2184 int fundef_dereference (struct fundef
**, const char *, int);
2185 int data_subexpression_length (int *, struct expression
*);
2186 int expr_valid_for_context (struct expression
*, enum expression_context
);
2187 struct binding
*create_binding (struct binding_scope
**, const char *);
2188 int bind_ds_value (struct binding_scope
**,
2189 const char *, struct data_string
*);
2190 int find_bound_string (struct data_string
*,
2191 struct binding_scope
*, const char *);
2192 int unset (struct binding_scope
*, const char *);
2193 int data_string_sprintfa(struct data_string
*ds
, const char *fmt
, ...);
2196 extern int outstanding_pings
;
2197 extern int max_outstanding_acks
;
2198 extern int max_ack_delay_secs
;
2199 extern int max_ack_delay_usecs
;
2201 void dhcp (struct packet
*);
2202 void dhcpdiscover (struct packet
*, int);
2203 void dhcprequest (struct packet
*, int, struct lease
*);
2204 void dhcprelease (struct packet
*, int);
2205 void dhcpdecline (struct packet
*, int);
2206 void dhcpinform (struct packet
*, int);
2207 void nak_lease (struct packet
*, struct iaddr
*cip
);
2208 void ack_lease (struct packet
*, struct lease
*,
2209 unsigned int, TIME
, char *, int, struct host_decl
*);
2210 void delayed_ack_enqueue(struct lease
*);
2211 void commit_leases_readerdry(void *);
2212 void flush_ackqueue(void *);
2213 void dhcp_reply (struct lease
*);
2214 int find_lease (struct lease
**, struct packet
*,
2215 struct shared_network
*, int *, int *, struct lease
*,
2217 int mockup_lease (struct lease
**, struct packet
*,
2218 struct shared_network
*,
2219 struct host_decl
*);
2220 void static_lease_dereference (struct lease
*, const char *, int);
2222 int allocate_lease (struct lease
**, struct packet
*,
2223 struct pool
*, int *);
2224 int permitted (struct packet
*, struct permit
*);
2225 int locate_network (struct packet
*);
2226 int parse_agent_information_option (struct packet
*, int, u_int8_t
*);
2227 unsigned cons_agent_information_options (struct option_state
*,
2228 struct dhcp_packet
*,
2229 unsigned, unsigned);
2230 void get_server_source_address(struct in_addr
*from
,
2231 struct option_state
*options
,
2232 struct option_state
*out_options
,
2233 struct packet
*packet
);
2234 void setup_server_source_address(struct in_addr
*from
,
2235 struct option_state
*options
,
2236 struct packet
*packet
);
2238 /* dhcpleasequery.c */
2239 void dhcpleasequery (struct packet
*, int);
2240 void dhcpv6_leasequery (struct data_string
*, struct packet
*);
2243 isc_boolean_t
server_duid_isset(void);
2244 void copy_server_duid(struct data_string
*ds
, const char *file
, int line
);
2245 void set_server_duid(struct data_string
*new_duid
);
2246 isc_result_t
set_server_duid_from_option(void);
2247 void set_server_duid_type(int type
);
2248 isc_result_t
generate_new_server_duid(void);
2249 isc_result_t
get_client_id(struct packet
*, struct data_string
*);
2250 void dhcpv6(struct packet
*);
2253 void bootp (struct packet
*);
2256 extern int (*group_write_hook
) (struct group_object
*);
2257 extern struct group
*root_group
;
2258 extern group_hash_t
*group_name_hash
;
2259 isc_result_t
delete_group (struct group_object
*, int);
2260 isc_result_t
supersede_group (struct group_object
*, int);
2261 int clone_group (struct group
**, struct group
*, const char *, int);
2262 int write_group (struct group_object
*);
2265 void relinquish_lease_hunks (void);
2266 struct lease
*new_leases (unsigned, const char *, int);
2267 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2268 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2269 void relinquish_free_lease_states (void);
2271 OMAPI_OBJECT_ALLOC_DECL (lease
, struct lease
, dhcp_type_lease
)
2272 OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class
)
2273 OMAPI_OBJECT_ALLOC_DECL (subclass
, struct class, dhcp_type_subclass
)
2274 OMAPI_OBJECT_ALLOC_DECL (pool
, struct pool
, dhcp_type_pool
)
2275 OMAPI_OBJECT_ALLOC_DECL (host
, struct host_decl
, dhcp_type_host
)
2278 OMAPI_OBJECT_ALLOC_DECL (subnet
, struct subnet
, dhcp_type_subnet
)
2279 OMAPI_OBJECT_ALLOC_DECL (shared_network
, struct shared_network
,
2280 dhcp_type_shared_network
)
2281 OMAPI_OBJECT_ALLOC_DECL (group_object
, struct group_object
, dhcp_type_group
)
2282 OMAPI_OBJECT_ALLOC_DECL (dhcp_control
,
2283 dhcp_control_object_t
, dhcp_type_control
)
2285 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2286 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2287 void relinquish_free_pairs (void);
2288 void relinquish_free_expressions (void);
2289 void relinquish_free_binding_values (void);
2290 void relinquish_free_option_caches (void);
2291 void relinquish_free_packets (void);
2294 int option_chain_head_allocate (struct option_chain_head
**,
2296 int option_chain_head_reference (struct option_chain_head
**,
2297 struct option_chain_head
*,
2299 int option_chain_head_dereference (struct option_chain_head
**,
2301 int group_allocate (struct group
**, const char *, int);
2302 int group_reference (struct group
**, struct group
*, const char *, int);
2303 int group_dereference (struct group
**, const char *, int);
2304 struct dhcp_packet
*new_dhcp_packet (const char *, int);
2305 struct protocol
*new_protocol (const char *, int);
2306 struct lease_state
*new_lease_state (const char *, int);
2307 struct domain_search_list
*new_domain_search_list (const char *, int);
2308 struct name_server
*new_name_server (const char *, int);
2309 void free_name_server (struct name_server
*, const char *, int);
2310 struct option
*new_option (const char *, const char *, int);
2311 int option_reference(struct option
**dest
, struct option
*src
,
2312 const char * file
, int line
);
2313 int option_dereference(struct option
**dest
, const char *file
, int line
);
2314 struct universe
*new_universe (const char *, int);
2315 void free_universe (struct universe
*, const char *, int);
2316 void free_domain_search_list (struct domain_search_list
*,
2318 void free_lease_state (struct lease_state
*, const char *, int);
2319 void free_protocol (struct protocol
*, const char *, int);
2320 void free_dhcp_packet (struct dhcp_packet
*, const char *, int);
2321 struct client_lease
*new_client_lease (const char *, int);
2322 void free_client_lease (struct client_lease
*, const char *, int);
2323 struct permit
*new_permit (const char *, int);
2324 void free_permit (struct permit
*, const char *, int);
2325 pair
new_pair (const char *, int);
2326 void free_pair (pair
, const char *, int);
2327 int expression_allocate (struct expression
**, const char *, int);
2328 int expression_reference (struct expression
**,
2329 struct expression
*, const char *, int);
2330 void free_expression (struct expression
*, const char *, int);
2331 int binding_value_allocate (struct binding_value
**,
2333 int binding_value_reference (struct binding_value
**,
2334 struct binding_value
*,
2336 void free_binding_value (struct binding_value
*, const char *, int);
2337 int fundef_allocate (struct fundef
**, const char *, int);
2338 int fundef_reference (struct fundef
**,
2339 struct fundef
*, const char *, int);
2340 int option_cache_allocate (struct option_cache
**, const char *, int);
2341 int option_cache_reference (struct option_cache
**,
2342 struct option_cache
*, const char *, int);
2343 int buffer_allocate (struct buffer
**, unsigned, const char *, int);
2344 int buffer_reference (struct buffer
**, struct buffer
*,
2346 int buffer_dereference (struct buffer
**, const char *, int);
2347 int dns_host_entry_allocate (struct dns_host_entry
**,
2348 const char *, const char *, int);
2349 int dns_host_entry_reference (struct dns_host_entry
**,
2350 struct dns_host_entry
*,
2352 int dns_host_entry_dereference (struct dns_host_entry
**,
2354 int option_state_allocate (struct option_state
**, const char *, int);
2355 int option_state_reference (struct option_state
**,
2356 struct option_state
*, const char *, int);
2357 int option_state_dereference (struct option_state
**,
2359 void data_string_copy(struct data_string
*, const struct data_string
*,
2361 void data_string_forget (struct data_string
*, const char *, int);
2362 void data_string_truncate (struct data_string
*, int);
2363 int executable_statement_allocate (struct executable_statement
**,
2365 int executable_statement_reference (struct executable_statement
**,
2366 struct executable_statement
*,
2368 int packet_allocate (struct packet
**, const char *, int);
2369 int packet_reference (struct packet
**,
2370 struct packet
*, const char *, int);
2371 int packet_dereference (struct packet
**, const char *, int);
2372 int binding_scope_allocate (struct binding_scope
**,
2374 int binding_scope_reference (struct binding_scope
**,
2375 struct binding_scope
*,
2377 int dns_zone_allocate (struct dns_zone
**, const char *, int);
2378 int dns_zone_reference (struct dns_zone
**,
2379 struct dns_zone
*, const char *, int);
2382 #define DEFAULT_TIME_FORMAT 0
2383 #define LOCAL_TIME_FORMAT 1
2384 extern int db_time_format
;
2385 char *quotify_string (const char *, const char *, int);
2386 char *quotify_buf (const unsigned char *, unsigned, const char *, int);
2387 char *print_base64 (const unsigned char *, unsigned, const char *, int);
2388 char *print_hw_addr (const int, const int, const unsigned char *);
2389 void print_lease (struct lease
*);
2390 void dump_raw (const unsigned char *, unsigned);
2391 void dump_packet_option (struct option_cache
*, struct packet
*,
2392 struct lease
*, struct client_state
*,
2393 struct option_state
*, struct option_state
*,
2394 struct binding_scope
**, struct universe
*, void *);
2395 void dump_packet (struct packet
*);
2396 void hash_dump (struct hash_table
*);
2397 char *print_hex (unsigned, const u_int8_t
*, unsigned, unsigned);
2398 void print_hex_only (unsigned, const u_int8_t
*, unsigned, char *);
2399 void print_hex_or_string (unsigned, const u_int8_t
*, unsigned, char *);
2400 #define print_hex_1(len, data, limit) print_hex(len, data, limit, 0)
2401 #define print_hex_2(len, data, limit) print_hex(len, data, limit, 1)
2402 #define print_hex_3(len, data, limit) print_hex(len, data, limit, 2)
2403 char *print_dotted_quads (unsigned, const u_int8_t
*);
2404 char *print_dec_1 (unsigned long);
2405 char *print_dec_2 (unsigned long);
2406 void print_expression (const char *, struct expression
*);
2407 int token_print_indent_concat (FILE *, int, int,
2408 const char *, const char *, ...);
2409 int token_indent_data_string (FILE *, int, int, const char *, const char *,
2410 struct data_string
*);
2411 int token_print_indent (FILE *, int, int,
2412 const char *, const char *, const char *);
2413 void indent_spaces (FILE *, int);
2414 #if defined (NSUPDATE)
2415 void print_dns_status (int, struct dhcp_ddns_cb
*, isc_result_t
);
2417 const char *print_time(TIME
);
2419 void get_hw_addr(const char *name
, struct hardware
*hw
);
2422 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
2423 || defined (USE_SOCKET_FALLBACK)
2424 int if_register_socket(struct interface_info
*, int, int *, struct in6_addr
*);
2427 #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND)
2428 void if_reinitialize_fallback (struct interface_info
*);
2429 void if_register_fallback (struct interface_info
*);
2430 ssize_t
send_fallback (struct interface_info
*,
2431 struct packet
*, struct dhcp_packet
*, size_t,
2433 struct sockaddr_in
*, struct hardware
*);
2434 ssize_t
send_fallback6(struct interface_info
*, struct packet
*,
2435 struct dhcp_packet
*, size_t, struct in6_addr
*,
2436 struct sockaddr_in6
*, struct hardware
*);
2439 #ifdef USE_SOCKET_SEND
2440 void if_reinitialize_send (struct interface_info
*);
2441 void if_register_send (struct interface_info
*);
2442 void if_deregister_send (struct interface_info
*);
2443 ssize_t
send_packet (struct interface_info
*,
2444 struct packet
*, struct dhcp_packet
*, size_t,
2446 struct sockaddr_in
*, struct hardware
*);
2448 ssize_t
send_packet6(struct interface_info
*, const unsigned char *, size_t,
2449 struct sockaddr_in6
*);
2450 #ifdef USE_SOCKET_RECEIVE
2451 void if_reinitialize_receive (struct interface_info
*);
2452 void if_register_receive (struct interface_info
*);
2453 void if_deregister_receive (struct interface_info
*);
2454 ssize_t
receive_packet (struct interface_info
*,
2455 unsigned char *, size_t,
2456 struct sockaddr_in
*, struct hardware
*);
2459 #if defined (USE_SOCKET_FALLBACK)
2460 isc_result_t
fallback_discard (omapi_object_t
*);
2463 #if defined (USE_SOCKET_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);
2470 void if_register6(struct interface_info
*info
, int do_multicast
);
2471 void if_register_linklocal6(struct interface_info
*info
);
2472 ssize_t
receive_packet6(struct interface_info
*interface
,
2473 unsigned char *buf
, size_t len
,
2474 struct sockaddr_in6
*from
, struct in6_addr
*to_addr
,
2475 unsigned int *if_index
);
2476 void if_deregister6(struct interface_info
*info
);
2480 #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
2481 int if_register_bpf (struct interface_info
*);
2484 void if_reinitialize_send (struct interface_info
*);
2485 void if_register_send (struct interface_info
*);
2486 void if_deregister_send (struct interface_info
*);
2487 ssize_t
send_packet (struct interface_info
*,
2488 struct packet
*, struct dhcp_packet
*, size_t,
2490 struct sockaddr_in
*, struct hardware
*);
2492 #ifdef USE_BPF_RECEIVE
2493 void if_reinitialize_receive (struct interface_info
*);
2494 void if_register_receive (struct interface_info
*);
2495 void if_deregister_receive (struct interface_info
*);
2496 ssize_t
receive_packet (struct interface_info
*,
2497 unsigned char *, size_t,
2498 struct sockaddr_in
*, struct hardware
*);
2500 #if defined (USE_BPF_SEND)
2501 int can_unicast_without_arp (struct interface_info
*);
2502 int can_receive_unicast_unconfigured (struct interface_info
*);
2503 int supports_multiple_interfaces (struct interface_info
*);
2504 void maybe_setup_fallback (void);
2508 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
2509 int if_register_lpf (struct interface_info
*);
2512 void if_reinitialize_send (struct interface_info
*);
2513 void if_register_send (struct interface_info
*);
2514 void if_deregister_send (struct interface_info
*);
2515 ssize_t
send_packet (struct interface_info
*,
2516 struct packet
*, struct dhcp_packet
*, size_t,
2518 struct sockaddr_in
*, struct hardware
*);
2520 #ifdef USE_LPF_RECEIVE
2521 void if_reinitialize_receive (struct interface_info
*);
2522 void if_register_receive (struct interface_info
*);
2523 void if_deregister_receive (struct interface_info
*);
2524 ssize_t
receive_packet (struct interface_info
*,
2525 unsigned char *, size_t,
2526 struct sockaddr_in
*, struct hardware
*);
2528 #if defined (USE_LPF_SEND)
2529 int can_unicast_without_arp (struct interface_info
*);
2530 int can_receive_unicast_unconfigured (struct interface_info
*);
2531 int supports_multiple_interfaces (struct interface_info
*);
2532 void maybe_setup_fallback (void);
2536 #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
2537 int if_register_nit (struct interface_info
*);
2541 void if_reinitialize_send (struct interface_info
*);
2542 void if_register_send (struct interface_info
*);
2543 void if_deregister_send (struct interface_info
*);
2544 ssize_t
send_packet (struct interface_info
*,
2545 struct packet
*, struct dhcp_packet
*, size_t,
2547 struct sockaddr_in
*, struct hardware
*);
2549 #ifdef USE_NIT_RECEIVE
2550 void if_reinitialize_receive (struct interface_info
*);
2551 void if_register_receive (struct interface_info
*);
2552 void if_deregister_receive (struct interface_info
*);
2553 ssize_t
receive_packet (struct interface_info
*,
2554 unsigned char *, size_t,
2555 struct sockaddr_in
*, struct hardware
*);
2557 #if defined (USE_NIT_SEND)
2558 int can_unicast_without_arp (struct interface_info
*);
2559 int can_receive_unicast_unconfigured (struct interface_info
*);
2560 int supports_multiple_interfaces (struct interface_info
*);
2561 void maybe_setup_fallback (void);
2565 #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
2566 int if_register_dlpi (struct interface_info
*);
2569 #ifdef USE_DLPI_SEND
2570 int can_unicast_without_arp (struct interface_info
*);
2571 int can_receive_unicast_unconfigured (struct interface_info
*);
2572 void if_reinitialize_send (struct interface_info
*);
2573 void if_register_send (struct interface_info
*);
2574 void if_deregister_send (struct interface_info
*);
2575 ssize_t
send_packet (struct interface_info
*,
2576 struct packet
*, struct dhcp_packet
*, size_t,
2578 struct sockaddr_in
*, struct hardware
*);
2579 int supports_multiple_interfaces (struct interface_info
*);
2580 void maybe_setup_fallback (void);
2582 #ifdef USE_DLPI_RECEIVE
2583 void if_reinitialize_receive (struct interface_info
*);
2584 void if_register_receive (struct interface_info
*);
2585 void if_deregister_receive (struct interface_info
*);
2586 ssize_t
receive_packet (struct interface_info
*,
2587 unsigned char *, size_t,
2588 struct sockaddr_in
*, struct hardware
*);
2594 void if_reinitialize_send (struct interface_info
*);
2595 void if_register_send (struct interface_info
*);
2596 void if_deregister_send (struct interface_info
*);
2597 ssize_t
send_packet (struct interface_info
*, struct packet
*,
2598 struct dhcp_packet
*, size_t, struct in_addr
,
2599 struct sockaddr_in
*, struct hardware
*);
2600 int can_unicast_without_arp (struct interface_info
*);
2601 int can_receive_unicast_unconfigured (struct interface_info
*);
2602 int supports_multiple_interfaces (struct interface_info
*);
2603 void maybe_setup_fallback (void);
2607 extern struct interface_info
*interfaces
,
2608 *dummy_interfaces
, *fallback_interface
;
2609 extern struct protocol
*protocols
;
2610 extern int quiet_interface_discovery
;
2611 isc_result_t
interface_setup (void);
2612 void interface_trace_setup (void);
2614 extern struct in_addr limited_broadcast
;
2615 extern int local_family
;
2616 extern struct in_addr local_address
;
2618 extern u_int16_t local_port
;
2619 extern u_int16_t remote_port
;
2620 extern int (*dhcp_interface_setup_hook
) (struct interface_info
*,
2622 extern int (*dhcp_interface_discovery_hook
) (struct interface_info
*);
2623 extern isc_result_t (*dhcp_interface_startup_hook
) (struct interface_info
*);
2625 extern void (*bootp_packet_handler
) (struct interface_info
*,
2626 struct dhcp_packet
*, unsigned,
2628 struct iaddr
, struct hardware
*);
2629 extern void (*dhcpv6_packet_handler
)(struct interface_info
*,
2631 int, const struct iaddr
*, isc_boolean_t
);
2632 extern struct timeout
*timeouts
;
2633 extern omapi_object_type_t
*dhcp_type_interface
;
2634 #if defined (TRACING)
2635 extern trace_type_t
*interface_trace
;
2636 extern trace_type_t
*inpacket_trace
;
2637 extern trace_type_t
*outpacket_trace
;
2639 extern struct interface_info
**interface_vector
;
2640 extern int interface_count
;
2641 extern int interface_max
;
2642 isc_result_t
interface_initialize(omapi_object_t
*, const char *, int);
2643 void discover_interfaces(int);
2644 int setup_fallback (struct interface_info
**, const char *, int);
2645 int if_readsocket (omapi_object_t
*);
2646 void reinitialize_interfaces (void);
2649 void set_time(TIME
);
2650 struct timeval
*process_outstanding_timeouts (struct timeval
*);
2651 void dispatch (void);
2652 isc_result_t
got_one(omapi_object_t
*);
2653 isc_result_t
got_one_v6(omapi_object_t
*);
2654 isc_result_t
interface_set_value (omapi_object_t
*, omapi_object_t
*,
2655 omapi_data_string_t
*, omapi_typed_data_t
*);
2656 isc_result_t
interface_get_value (omapi_object_t
*, omapi_object_t
*,
2657 omapi_data_string_t
*, omapi_value_t
**);
2658 isc_result_t
interface_destroy (omapi_object_t
*, const char *, int);
2659 isc_result_t
interface_signal_handler (omapi_object_t
*,
2660 const char *, va_list);
2661 isc_result_t
interface_stuff_values (omapi_object_t
*,
2665 void add_timeout (struct timeval
*, void (*) (void *), void *,
2666 tvref_t
, tvunref_t
);
2667 void cancel_timeout (void (*) (void *), void *);
2668 void cancel_all_timeouts (void);
2669 void relinquish_timeouts (void);
2671 OMAPI_OBJECT_ALLOC_DECL (interface
,
2672 struct interface_info
, dhcp_type_interface
)
2675 extern char *default_option_format
;
2676 extern struct universe dhcp_universe
;
2677 extern struct universe dhcpv6_universe
;
2678 extern struct universe nwip_universe
;
2679 extern struct universe fqdn_universe
;
2680 extern struct universe vsio_universe
;
2681 extern int dhcp_option_default_priority_list
[];
2682 extern int dhcp_option_default_priority_list_count
;
2683 extern const char *hardware_types
[256];
2684 extern int universe_count
, universe_max
;
2685 extern struct universe
**universes
;
2686 extern universe_hash_t
*universe_hash
;
2687 void initialize_common_option_spaces (void);
2688 extern struct universe
*config_universe
;
2691 #if defined (FAILOVER_PROTOCOL)
2692 extern failover_option_t null_failover_option
;
2693 extern failover_option_t skip_failover_option
;
2694 extern struct failover_option_info ft_options
[];
2695 extern u_int32_t fto_allowed
[];
2696 extern int ft_sizes
[];
2697 extern const char *dhcp_flink_state_names
[];
2699 extern const char *binding_state_names
[];
2701 extern struct universe agent_universe
;
2702 extern struct universe server_universe
;
2704 extern struct enumeration ddns_styles
;
2705 extern struct enumeration syslog_enum
;
2706 void initialize_server_option_spaces (void);
2709 struct iaddr
subnet_number (struct iaddr
, struct iaddr
);
2710 struct iaddr
ip_addr (struct iaddr
, struct iaddr
, u_int32_t
);
2711 struct iaddr
broadcast_addr (struct iaddr
, struct iaddr
);
2712 u_int32_t
host_addr (struct iaddr
, struct iaddr
);
2713 int addr_eq (struct iaddr
, struct iaddr
);
2714 int addr_match(struct iaddr
*, struct iaddrmatch
*);
2715 int addr_cmp(const struct iaddr
*a1
, const struct iaddr
*a2
);
2716 int addr_or(struct iaddr
*result
,
2717 const struct iaddr
*a1
, const struct iaddr
*a2
);
2718 int addr_and(struct iaddr
*result
,
2719 const struct iaddr
*a1
, const struct iaddr
*a2
);
2720 isc_boolean_t
is_cidr_mask_valid(const struct iaddr
*addr
, int bits
);
2721 isc_result_t
range2cidr(struct iaddrcidrnetlist
**result
,
2722 const struct iaddr
*lo
, const struct iaddr
*hi
);
2723 isc_result_t
free_iaddrcidrnetlist(struct iaddrcidrnetlist
**result
);
2724 const char *piaddr (struct iaddr
);
2725 char *piaddrmask(struct iaddr
*, struct iaddr
*);
2726 char *piaddrcidr(const struct iaddr
*, unsigned int);
2727 u_int16_t
validate_port(char *);
2732 extern int wanted_ia_na
;
2733 extern int wanted_ia_ta
;
2734 extern int wanted_ia_pd
;
2736 extern const char *path_dhclient_conf
;
2737 extern const char *path_dhclient_db
;
2738 extern const char *path_dhclient_pid
;
2739 extern char *path_dhclient_script
;
2740 extern int interfaces_requested
;
2741 extern struct data_string default_duid
;
2742 extern int duid_type
;
2744 extern struct client_config top_level_config
;
2746 void dhcpoffer (struct packet
*);
2747 void dhcpack (struct packet
*);
2748 void dhcpnak (struct packet
*);
2750 void send_discover (void *);
2751 void send_request (void *);
2752 void send_release (void *);
2753 void send_decline (void *);
2755 void state_reboot (void *);
2756 void state_init (void *);
2757 void state_selecting (void *);
2758 void state_requesting (void *);
2759 void state_bound (void *);
2760 void state_stop (void *);
2761 void state_panic (void *);
2763 void bind_lease (struct client_state
*);
2765 void make_client_options (struct client_state
*,
2766 struct client_lease
*, u_int8_t
*,
2767 struct option_cache
*, struct iaddr
*,
2768 struct option
**, struct option_state
**);
2769 void make_discover (struct client_state
*, struct client_lease
*);
2770 void make_request (struct client_state
*, struct client_lease
*);
2771 void make_decline (struct client_state
*, struct client_lease
*);
2772 void make_release (struct client_state
*, struct client_lease
*);
2774 void destroy_client_lease (struct client_lease
*);
2775 void rewrite_client_leases (void);
2776 void write_lease_option (struct option_cache
*, struct packet
*,
2777 struct lease
*, struct client_state
*,
2778 struct option_state
*, struct option_state
*,
2779 struct binding_scope
**, struct universe
*, void *);
2780 int write_client_lease (struct client_state
*, struct client_lease
*, int, int);
2781 isc_result_t
write_client6_lease(struct client_state
*client
,
2782 struct dhc6_lease
*lease
,
2783 int rewrite
, int sync
);
2784 int dhcp_option_ev_name (char *, size_t, struct option
*);
2786 void script_init (struct client_state
*, const char *,
2787 struct string_list
*);
2788 void client_option_envadd (struct option_cache
*, struct packet
*,
2789 struct lease
*, struct client_state
*,
2790 struct option_state
*, struct option_state
*,
2791 struct binding_scope
**, struct universe
*, void *);
2792 void script_write_params (struct client_state
*, const char *,
2793 struct client_lease
*);
2794 void script_write_requested (struct client_state
*);
2795 int script_go (struct client_state
*);
2796 void client_envadd (struct client_state
*,
2797 const char *, const char *, const char *, ...)
2798 __attribute__((__format__(__printf__
,4,5)));
2800 struct client_lease
*packet_to_lease (struct packet
*, struct client_state
*);
2801 void go_daemon (void);
2802 void finish_daemon (void);
2803 void write_client_pid_file (void);
2804 void client_location_changed (void);
2805 void do_release (struct client_state
*);
2806 int dhclient_interface_shutdown_hook (struct interface_info
*);
2807 int dhclient_interface_discovery_hook (struct interface_info
*);
2808 isc_result_t
dhclient_interface_startup_hook (struct interface_info
*);
2809 void dhclient_schedule_updates(struct client_state
*client
,
2810 struct iaddr
*addr
, int offset
);
2811 void client_dns_update_timeout (void *cp
);
2812 isc_result_t
client_dns_update(struct client_state
*client
,
2813 dhcp_ddns_cb_t
*ddns_cb
);
2814 void client_dns_remove(struct client_state
*client
, struct iaddr
*addr
);
2816 void dhcpv4_client_assignments(void);
2817 void dhcpv6_client_assignments(void);
2818 void form_duid(struct data_string
*duid
, const char *file
, int line
);
2821 void dhc6_lease_destroy(struct dhc6_lease
**src
, const char *file
, int line
);
2822 void start_init6(struct client_state
*client
);
2823 void start_info_request6(struct client_state
*client
);
2824 void start_confirm6(struct client_state
*client
);
2825 void start_release6(struct client_state
*client
);
2826 void start_selecting6(struct client_state
*client
);
2827 void unconfigure6(struct client_state
*client
, const char *reason
);
2830 int write_lease (struct lease
*);
2831 int write_host (struct host_decl
*);
2832 int write_server_duid(void);
2833 #if defined (FAILOVER_PROTOCOL)
2834 int write_failover_state (dhcp_failover_state_t
*);
2836 int db_printable (const unsigned char *);
2837 int db_printable_len (const unsigned char *, unsigned);
2838 isc_result_t
write_named_billing_class(const void *, unsigned, void *);
2839 void write_billing_classes (void);
2840 int write_billing_class (struct class *);
2841 void commit_leases_timeout (void *);
2842 void commit_leases_readerdry(void *);
2843 int commit_leases (void);
2844 int commit_leases_timed (void);
2845 void db_startup (int);
2846 int new_lease_file (void);
2847 int group_writer (struct group_object
*);
2848 int write_ia(const struct ia_xx
*);
2851 u_int32_t
checksum (unsigned char *, unsigned, u_int32_t
);
2852 u_int32_t
wrapsum (u_int32_t
);
2853 void assemble_hw_header (struct interface_info
*, unsigned char *,
2854 unsigned *, struct hardware
*);
2855 void assemble_udp_ip_header (struct interface_info
*, unsigned char *,
2856 unsigned *, u_int32_t
, u_int32_t
,
2857 u_int32_t
, unsigned char *, unsigned);
2858 ssize_t
decode_hw_header (struct interface_info
*, unsigned char *,
2859 unsigned, struct hardware
*);
2860 ssize_t
decode_udp_ip_header (struct interface_info
*, unsigned char *,
2861 unsigned, struct sockaddr_in
*,
2862 unsigned, unsigned *);
2865 void assemble_ethernet_header (struct interface_info
*, unsigned char *,
2866 unsigned *, struct hardware
*);
2867 ssize_t
decode_ethernet_header (struct interface_info
*,
2869 unsigned, struct hardware
*);
2872 void assemble_tr_header (struct interface_info
*, unsigned char *,
2873 unsigned *, struct hardware
*);
2874 ssize_t
decode_tr_header (struct interface_info
*,
2876 unsigned, struct hardware
*);
2879 void convert_statement (struct parse
*);
2880 void convert_host_statement (struct parse
*, jrefproto
);
2881 void convert_host_name (struct parse
*, jrefproto
);
2882 void convert_class_statement (struct parse
*, jrefproto
, int);
2883 void convert_class_decl (struct parse
*, jrefproto
);
2884 void convert_lease_time (struct parse
*, jrefproto
, char *);
2885 void convert_shared_net_statement (struct parse
*, jrefproto
);
2886 void convert_subnet_statement (struct parse
*, jrefproto
);
2887 void convert_subnet_decl (struct parse
*, jrefproto
);
2888 void convert_host_decl (struct parse
*, jrefproto
);
2889 void convert_hardware_decl (struct parse
*, jrefproto
);
2890 void convert_hardware_addr (struct parse
*, jrefproto
);
2891 void convert_filename_decl (struct parse
*, jrefproto
);
2892 void convert_servername_decl (struct parse
*, jrefproto
);
2893 void convert_ip_addr_or_hostname (struct parse
*, jrefproto
, int);
2894 void convert_fixed_addr_decl (struct parse
*, jrefproto
);
2895 void convert_option_decl (struct parse
*, jrefproto
);
2896 void convert_lease_statement (struct parse
*, jrefproto
);
2897 void convert_address_range (struct parse
*, jrefproto
);
2898 void convert_date (struct parse
*, jrefproto
, char *);
2899 void convert_numeric_aggregate (struct parse
*, jrefproto
, int, int, int, int);
2903 void add_route_direct (struct interface_info
*, struct in_addr
);
2904 void add_route_net (struct interface_info
*, struct in_addr
, struct in_addr
);
2905 void add_route_default_gateway (struct interface_info
*, struct in_addr
);
2906 void remove_routes (struct in_addr
);
2907 void remove_if_route (struct interface_info
*, struct in_addr
);
2908 void remove_all_if_routes (struct interface_info
*);
2909 void set_netmask (struct interface_info
*, struct in_addr
);
2910 void set_broadcast_addr (struct interface_info
*, struct in_addr
);
2911 void set_ip_address (struct interface_info
*, struct in_addr
);
2914 isc_result_t
read_client_conf (void);
2915 int read_client_conf_file (const char *,
2916 struct interface_info
*, struct client_config
*);
2917 void read_client_leases (void);
2918 void parse_client_statement (struct parse
*, struct interface_info
*,
2919 struct client_config
*);
2920 int parse_X (struct parse
*, u_int8_t
*, unsigned);
2921 int parse_option_list (struct parse
*, struct option
***);
2922 void parse_interface_declaration (struct parse
*,
2923 struct client_config
*, char *);
2924 int interface_or_dummy (struct interface_info
**, const char *);
2925 void make_client_state (struct client_state
**);
2926 void make_client_config (struct client_state
*, struct client_config
*);
2927 void parse_client_lease_statement (struct parse
*, int);
2928 void parse_client_lease_declaration (struct parse
*,
2929 struct client_lease
*,
2930 struct interface_info
**,
2931 struct client_state
**);
2932 int parse_option_decl (struct option_cache
**, struct parse
*);
2933 void parse_string_list (struct parse
*, struct string_list
**, int);
2934 int parse_ip_addr (struct parse
*, struct iaddr
*);
2935 int parse_ip_addr_with_subnet(struct parse
*, struct iaddrmatch
*);
2936 void parse_reject_statement (struct parse
*, struct client_config
*);
2939 OMAPI_OBJECT_ALLOC_DECL (icmp_state
, struct icmp_state
, dhcp_type_icmp
)
2940 extern struct icmp_state
*icmp_state
;
2941 void icmp_startup (int, void (*) (struct iaddr
, u_int8_t
*, int));
2942 int icmp_readsocket (omapi_object_t
*);
2943 int icmp_echorequest (struct iaddr
*);
2944 isc_result_t
icmp_echoreply (omapi_object_t
*);
2947 isc_result_t
enter_dns_zone (struct dns_zone
*);
2948 isc_result_t
dns_zone_lookup (struct dns_zone
**, const char *);
2949 int dns_zone_dereference (struct dns_zone
**, const char *, int);
2950 #if defined (NSUPDATE)
2951 #define FIND_FORWARD 0
2952 #define FIND_REVERSE 1
2953 isc_result_t
find_tsig_key (ns_tsig_key
**, const char *, struct dns_zone
*);
2954 void tkey_free (ns_tsig_key
**);
2955 isc_result_t
find_cached_zone (dhcp_ddns_cb_t
*, int);
2956 void forget_zone (struct dns_zone
**);
2957 void repudiate_zone (struct dns_zone
**);
2958 int get_dhcid (dhcp_ddns_cb_t
*, int, const u_int8_t
*, unsigned);
2959 void dhcid_tolease (struct data_string
*, struct data_string
*);
2960 isc_result_t
dhcid_fromlease (struct data_string
*, struct data_string
*);
2961 isc_result_t
ddns_update_fwd(struct data_string
*, struct iaddr
,
2962 struct data_string
*, unsigned long, unsigned,
2964 isc_result_t
ddns_remove_fwd(struct data_string
*,
2965 struct iaddr
, struct data_string
*);
2966 #endif /* NSUPDATE */
2968 dhcp_ddns_cb_t
*ddns_cb_alloc(const char *file
, int line
);
2969 void ddns_cb_free (dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2970 void ddns_cb_forget_zone (dhcp_ddns_cb_t
*ddns_cb
);
2972 ddns_modify_fwd(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2974 ddns_modify_ptr(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2976 ddns_cancel(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2979 extern char path_resolv_conf
[];
2980 extern struct name_server
*name_servers
;
2981 extern struct domain_search_list
*domains
;
2983 void read_resolv_conf (TIME
);
2984 struct name_server
*first_name_server (void);
2987 #ifdef NEED_INET_ATON
2988 int inet_aton (const char *, struct in_addr
*);
2992 extern int have_billing_classes
;
2993 struct class unknown_class
;
2994 struct class known_class
;
2995 struct collection default_collection
;
2996 struct collection
*collections
;
2997 extern struct executable_statement
*default_classification_rules
;
2999 void classification_setup (void);
3000 void classify_client (struct packet
*);
3001 int check_collection (struct packet
*, struct lease
*, struct collection
*);
3002 void classify (struct packet
*, struct class *);
3003 isc_result_t
unlink_class (struct class **class);
3004 isc_result_t
find_class (struct class **, const char *,
3006 int unbill_class (struct lease
*, struct class *);
3007 int bill_class (struct lease
*, struct class *);
3010 int execute_statements (struct binding_value
**result
,
3011 struct packet
*, struct lease
*,
3012 struct client_state
*,
3013 struct option_state
*, struct option_state
*,
3014 struct binding_scope
**,
3015 struct executable_statement
*,
3017 void execute_statements_in_scope (struct binding_value
**result
,
3018 struct packet
*, struct lease
*,
3019 struct client_state
*,
3020 struct option_state
*,
3021 struct option_state
*,
3022 struct binding_scope
**,
3023 struct group
*, struct group
*,
3025 int executable_statement_dereference (struct executable_statement
**,
3027 void write_statements (FILE *, struct executable_statement
*, int);
3028 int find_matching_case (struct executable_statement
**,
3029 struct packet
*, struct lease
*, struct client_state
*,
3030 struct option_state
*, struct option_state
*,
3031 struct binding_scope
**,
3032 struct expression
*, struct executable_statement
*);
3033 int executable_statement_foreach (struct executable_statement
*,
3034 int (*) (struct executable_statement
*,
3035 void *, int), void *, int);
3038 extern omapi_object_type_t
*dhcp_type_group
;
3039 extern omapi_object_type_t
*dhcp_type_shared_network
;
3040 extern omapi_object_type_t
*dhcp_type_subnet
;
3041 extern omapi_object_type_t
*dhcp_type_control
;
3042 extern dhcp_control_object_t
*dhcp_control_object
;
3044 void dhcp_common_objects_setup (void);
3046 isc_result_t
dhcp_group_set_value (omapi_object_t
*, omapi_object_t
*,
3047 omapi_data_string_t
*,
3048 omapi_typed_data_t
*);
3049 isc_result_t
dhcp_group_get_value (omapi_object_t
*, omapi_object_t
*,
3050 omapi_data_string_t
*,
3052 isc_result_t
dhcp_group_destroy (omapi_object_t
*, const char *, int);
3053 isc_result_t
dhcp_group_signal_handler (omapi_object_t
*,
3054 const char *, va_list);
3055 isc_result_t
dhcp_group_stuff_values (omapi_object_t
*,
3058 isc_result_t
dhcp_group_lookup (omapi_object_t
**,
3059 omapi_object_t
*, omapi_object_t
*);
3060 isc_result_t
dhcp_group_create (omapi_object_t
**,
3062 isc_result_t
dhcp_group_remove (omapi_object_t
*,
3065 isc_result_t
dhcp_control_set_value (omapi_object_t
*, omapi_object_t
*,
3066 omapi_data_string_t
*,
3067 omapi_typed_data_t
*);
3068 isc_result_t
dhcp_control_get_value (omapi_object_t
*, omapi_object_t
*,
3069 omapi_data_string_t
*,
3071 isc_result_t
dhcp_control_destroy (omapi_object_t
*, const char *, int);
3072 isc_result_t
dhcp_control_signal_handler (omapi_object_t
*,
3073 const char *, va_list);
3074 isc_result_t
dhcp_control_stuff_values (omapi_object_t
*,
3077 isc_result_t
dhcp_control_lookup (omapi_object_t
**,
3078 omapi_object_t
*, omapi_object_t
*);
3079 isc_result_t
dhcp_control_create (omapi_object_t
**,
3081 isc_result_t
dhcp_control_remove (omapi_object_t
*,
3084 isc_result_t
dhcp_subnet_set_value (omapi_object_t
*, omapi_object_t
*,
3085 omapi_data_string_t
*,
3086 omapi_typed_data_t
*);
3087 isc_result_t
dhcp_subnet_get_value (omapi_object_t
*, omapi_object_t
*,
3088 omapi_data_string_t
*,
3090 isc_result_t
dhcp_subnet_destroy (omapi_object_t
*, const char *, int);
3091 isc_result_t
dhcp_subnet_signal_handler (omapi_object_t
*,
3092 const char *, va_list);
3093 isc_result_t
dhcp_subnet_stuff_values (omapi_object_t
*,
3096 isc_result_t
dhcp_subnet_lookup (omapi_object_t
**,
3097 omapi_object_t
*, omapi_object_t
*);
3098 isc_result_t
dhcp_subnet_create (omapi_object_t
**,
3100 isc_result_t
dhcp_subnet_remove (omapi_object_t
*,
3103 isc_result_t
dhcp_shared_network_set_value (omapi_object_t
*,
3105 omapi_data_string_t
*,
3106 omapi_typed_data_t
*);
3107 isc_result_t
dhcp_shared_network_get_value (omapi_object_t
*,
3109 omapi_data_string_t
*,
3111 isc_result_t
dhcp_shared_network_destroy (omapi_object_t
*, const char *, int);
3112 isc_result_t
dhcp_shared_network_signal_handler (omapi_object_t
*,
3113 const char *, va_list);
3114 isc_result_t
dhcp_shared_network_stuff_values (omapi_object_t
*,
3117 isc_result_t
dhcp_shared_network_lookup (omapi_object_t
**,
3118 omapi_object_t
*, omapi_object_t
*);
3119 isc_result_t
dhcp_shared_network_create (omapi_object_t
**,
3121 isc_result_t
dhcp_shared_network_remove (omapi_object_t
*,
3125 extern int (*dhcp_interface_shutdown_hook
) (struct interface_info
*);
3127 extern omapi_object_type_t
*dhcp_type_lease
;
3128 extern omapi_object_type_t
*dhcp_type_pool
;
3129 extern omapi_object_type_t
*dhcp_type_class
;
3130 extern omapi_object_type_t
*dhcp_type_subclass
;
3132 #if defined (FAILOVER_PROTOCOL)
3133 extern omapi_object_type_t
*dhcp_type_failover_state
;
3134 extern omapi_object_type_t
*dhcp_type_failover_link
;
3135 extern omapi_object_type_t
*dhcp_type_failover_listener
;
3138 void dhcp_db_objects_setup (void);
3140 isc_result_t
dhcp_lease_set_value (omapi_object_t
*, omapi_object_t
*,
3141 omapi_data_string_t
*,
3142 omapi_typed_data_t
*);
3143 isc_result_t
dhcp_lease_get_value (omapi_object_t
*, omapi_object_t
*,
3144 omapi_data_string_t
*,
3146 isc_result_t
dhcp_lease_destroy (omapi_object_t
*, const char *, int);
3147 isc_result_t
dhcp_lease_signal_handler (omapi_object_t
*,
3148 const char *, va_list);
3149 isc_result_t
dhcp_lease_stuff_values (omapi_object_t
*,
3152 isc_result_t
dhcp_lease_lookup (omapi_object_t
**,
3153 omapi_object_t
*, omapi_object_t
*);
3154 isc_result_t
dhcp_lease_create (omapi_object_t
**,
3156 isc_result_t
dhcp_lease_remove (omapi_object_t
*,
3158 isc_result_t
dhcp_host_set_value (omapi_object_t
*, omapi_object_t
*,
3159 omapi_data_string_t
*,
3160 omapi_typed_data_t
*);
3161 isc_result_t
dhcp_host_get_value (omapi_object_t
*, omapi_object_t
*,
3162 omapi_data_string_t
*,
3164 isc_result_t
dhcp_host_destroy (omapi_object_t
*, const char *, int);
3165 isc_result_t
dhcp_host_signal_handler (omapi_object_t
*,
3166 const char *, va_list);
3167 isc_result_t
dhcp_host_stuff_values (omapi_object_t
*,
3170 isc_result_t
dhcp_host_lookup (omapi_object_t
**,
3171 omapi_object_t
*, omapi_object_t
*);
3172 isc_result_t
dhcp_host_create (omapi_object_t
**,
3174 isc_result_t
dhcp_host_remove (omapi_object_t
*,
3176 isc_result_t
dhcp_pool_set_value (omapi_object_t
*, omapi_object_t
*,
3177 omapi_data_string_t
*,
3178 omapi_typed_data_t
*);
3179 isc_result_t
dhcp_pool_get_value (omapi_object_t
*, omapi_object_t
*,
3180 omapi_data_string_t
*,
3182 isc_result_t
dhcp_pool_destroy (omapi_object_t
*, const char *, int);
3183 isc_result_t
dhcp_pool_signal_handler (omapi_object_t
*,
3184 const char *, va_list);
3185 isc_result_t
dhcp_pool_stuff_values (omapi_object_t
*,
3188 isc_result_t
dhcp_pool_lookup (omapi_object_t
**,
3189 omapi_object_t
*, omapi_object_t
*);
3190 isc_result_t
dhcp_pool_create (omapi_object_t
**,
3192 isc_result_t
dhcp_pool_remove (omapi_object_t
*,
3194 isc_result_t
dhcp_class_set_value (omapi_object_t
*, omapi_object_t
*,
3195 omapi_data_string_t
*,
3196 omapi_typed_data_t
*);
3197 isc_result_t
dhcp_class_get_value (omapi_object_t
*, omapi_object_t
*,
3198 omapi_data_string_t
*,
3200 isc_result_t
dhcp_class_destroy (omapi_object_t
*, const char *, int);
3201 isc_result_t
dhcp_class_signal_handler (omapi_object_t
*,
3202 const char *, va_list);
3203 isc_result_t
dhcp_class_stuff_values (omapi_object_t
*,
3206 isc_result_t
dhcp_class_lookup (omapi_object_t
**,
3207 omapi_object_t
*, omapi_object_t
*);
3208 isc_result_t
dhcp_class_create (omapi_object_t
**,
3210 isc_result_t
dhcp_class_remove (omapi_object_t
*,
3212 isc_result_t
dhcp_subclass_set_value (omapi_object_t
*, omapi_object_t
*,
3213 omapi_data_string_t
*,
3214 omapi_typed_data_t
*);
3215 isc_result_t
dhcp_subclass_get_value (omapi_object_t
*, omapi_object_t
*,
3216 omapi_data_string_t
*,
3218 isc_result_t
dhcp_subclass_destroy (omapi_object_t
*, const char *, int);
3219 isc_result_t
dhcp_subclass_signal_handler (omapi_object_t
*,
3220 const char *, va_list);
3221 isc_result_t
dhcp_subclass_stuff_values (omapi_object_t
*,
3224 isc_result_t
dhcp_subclass_lookup (omapi_object_t
**,
3225 omapi_object_t
*, omapi_object_t
*);
3226 isc_result_t
dhcp_subclass_create (omapi_object_t
**,
3228 isc_result_t
dhcp_subclass_remove (omapi_object_t
*,
3230 isc_result_t
dhcp_interface_set_value (omapi_object_t
*,
3232 omapi_data_string_t
*,
3233 omapi_typed_data_t
*);
3234 isc_result_t
dhcp_interface_get_value (omapi_object_t
*,
3236 omapi_data_string_t
*,
3238 isc_result_t
dhcp_interface_destroy (omapi_object_t
*,
3240 isc_result_t
dhcp_interface_signal_handler (omapi_object_t
*,
3243 isc_result_t
dhcp_interface_stuff_values (omapi_object_t
*,
3246 isc_result_t
dhcp_interface_lookup (omapi_object_t
**,
3249 isc_result_t
dhcp_interface_create (omapi_object_t
**,
3251 isc_result_t
dhcp_interface_remove (omapi_object_t
*,
3253 void interface_stash (struct interface_info
*);
3254 void interface_snorf (struct interface_info
*, int);
3256 isc_result_t
binding_scope_set_value (struct binding_scope
*, int,
3257 omapi_data_string_t
*,
3258 omapi_typed_data_t
*);
3259 isc_result_t
binding_scope_get_value (omapi_value_t
**,
3260 struct binding_scope
*,
3261 omapi_data_string_t
*);
3262 isc_result_t
binding_scope_stuff_values (omapi_object_t
*,
3263 struct binding_scope
*);
3265 void register_eventhandler(struct eventqueue
**, void (*handler
)(void *));
3266 void unregister_eventhandler(struct eventqueue
**, void (*handler
)(void *));
3267 void trigger_event(struct eventqueue
**);
3271 extern struct subnet
*subnets
;
3272 extern struct shared_network
*shared_networks
;
3273 extern host_hash_t
*host_hw_addr_hash
;
3274 extern host_hash_t
*host_uid_hash
;
3275 extern host_hash_t
*host_name_hash
;
3276 extern lease_id_hash_t
*lease_uid_hash
;
3277 extern lease_ip_hash_t
*lease_ip_addr_hash
;
3278 extern lease_id_hash_t
*lease_hw_addr_hash
;
3280 extern omapi_object_type_t
*dhcp_type_host
;
3282 extern int numclasseswritten
;
3285 isc_result_t
enter_class (struct class *, int, int);
3286 isc_result_t
delete_class (struct class *, int);
3287 isc_result_t
enter_host (struct host_decl
*, int, int);
3288 isc_result_t
delete_host (struct host_decl
*, int);
3289 void change_host_uid(struct host_decl
*host
, const char *data
, int len
);
3290 int find_hosts_by_haddr (struct host_decl
**, int,
3291 const unsigned char *, unsigned,
3293 int find_hosts_by_uid (struct host_decl
**, const unsigned char *,
3294 unsigned, const char *, int);
3295 int find_hosts_by_option(struct host_decl
**, struct packet
*,
3296 struct option_state
*, const char *, int);
3297 int find_host_for_network (struct subnet
**, struct host_decl
**,
3298 struct iaddr
*, struct shared_network
*);
3299 void new_address_range (struct parse
*, struct iaddr
, struct iaddr
,
3300 struct subnet
*, struct pool
*,
3302 isc_result_t
dhcp_lease_free (omapi_object_t
*, const char *, int);
3303 isc_result_t
dhcp_lease_get (omapi_object_t
**, const char *, int);
3304 int find_grouped_subnet (struct subnet
**, struct shared_network
*,
3305 struct iaddr
, const char *, int);
3306 int find_subnet(struct subnet
**, struct iaddr
, const char *, int);
3307 void enter_shared_network (struct shared_network
*);
3308 void new_shared_network_interface (struct parse
*,
3309 struct shared_network
*,
3311 int subnet_inner_than(const struct subnet
*, const struct subnet
*, int);
3312 void enter_subnet (struct subnet
*);
3313 void enter_lease (struct lease
*);
3314 int supersede_lease (struct lease
*, struct lease
*, int, int, int);
3315 void make_binding_state_transition (struct lease
*);
3316 int lease_copy (struct lease
**, struct lease
*, const char *, int);
3317 void release_lease (struct lease
*, struct packet
*);
3318 void abandon_lease (struct lease
*, const char *);
3320 /* this appears to be unused and I plan to remove it SAR */
3321 void dissociate_lease (struct lease
*);
3323 void pool_timer (void *);
3324 int find_lease_by_uid (struct lease
**, const unsigned char *,
3325 unsigned, const char *, int);
3326 int find_lease_by_hw_addr (struct lease
**, const unsigned char *,
3327 unsigned, const char *, int);
3328 int find_lease_by_ip_addr (struct lease
**, struct iaddr
,
3330 void uid_hash_add (struct lease
*);
3331 void uid_hash_delete (struct lease
*);
3332 void hw_hash_add (struct lease
*);
3333 void hw_hash_delete (struct lease
*);
3334 int write_leases (void);
3335 int write_leases6(void);
3336 int lease_enqueue (struct lease
*);
3337 isc_result_t
lease_instantiate(const void *, unsigned, void *);
3338 void expire_all_pools (void);
3339 void dump_subnets (void);
3340 #if defined (DEBUG_MEMORY_LEAKAGE) || \
3341 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
3342 void free_everything (void);
3346 #if defined (FAILOVER_PROTOCOL)
3347 extern dhcp_failover_state_t
*failover_states
;
3348 void dhcp_failover_startup (void);
3349 int dhcp_failover_write_all_states (void);
3350 isc_result_t
enter_failover_peer (dhcp_failover_state_t
*);
3351 isc_result_t
find_failover_peer (dhcp_failover_state_t
**,
3352 const char *, const char *, int);
3353 isc_result_t
dhcp_failover_link_initiate (omapi_object_t
*);
3354 isc_result_t
dhcp_failover_link_signal (omapi_object_t
*,
3355 const char *, va_list);
3356 isc_result_t
dhcp_failover_link_set_value (omapi_object_t
*,
3358 omapi_data_string_t
*,
3359 omapi_typed_data_t
*);
3360 isc_result_t
dhcp_failover_link_get_value (omapi_object_t
*,
3362 omapi_data_string_t
*,
3364 isc_result_t
dhcp_failover_link_destroy (omapi_object_t
*,
3366 isc_result_t
dhcp_failover_link_stuff_values (omapi_object_t
*,
3369 isc_result_t
dhcp_failover_listen (omapi_object_t
*);
3371 isc_result_t
dhcp_failover_listener_signal (omapi_object_t
*,
3374 isc_result_t
dhcp_failover_listener_set_value (omapi_object_t
*,
3376 omapi_data_string_t
*,
3377 omapi_typed_data_t
*);
3378 isc_result_t
dhcp_failover_listener_get_value (omapi_object_t
*,
3380 omapi_data_string_t
*,
3382 isc_result_t
dhcp_failover_listener_destroy (omapi_object_t
*,
3384 isc_result_t
dhcp_failover_listener_stuff (omapi_object_t
*,
3387 isc_result_t
dhcp_failover_register (omapi_object_t
*);
3388 isc_result_t
dhcp_failover_state_signal (omapi_object_t
*,
3389 const char *, va_list);
3390 isc_result_t
dhcp_failover_state_transition (dhcp_failover_state_t
*,
3392 isc_result_t
dhcp_failover_set_service_state (dhcp_failover_state_t
*state
);
3393 isc_result_t
dhcp_failover_set_state (dhcp_failover_state_t
*,
3394 enum failover_state
);
3395 isc_result_t
dhcp_failover_peer_state_changed (dhcp_failover_state_t
*,
3396 failover_message_t
*);
3397 void dhcp_failover_pool_rebalance (void *);
3398 void dhcp_failover_pool_check (struct pool
*);
3399 int dhcp_failover_state_pool_check (dhcp_failover_state_t
*);
3400 void dhcp_failover_timeout (void *);
3401 void dhcp_failover_send_contact (void *);
3402 isc_result_t
dhcp_failover_send_state (dhcp_failover_state_t
*);
3403 isc_result_t
dhcp_failover_send_updates (dhcp_failover_state_t
*);
3404 int dhcp_failover_queue_update (struct lease
*, int);
3405 int dhcp_failover_send_acks (dhcp_failover_state_t
*);
3406 void dhcp_failover_toack_queue_timeout (void *);
3407 int dhcp_failover_queue_ack (dhcp_failover_state_t
*, failover_message_t
*msg
);
3408 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t
*, struct lease
*);
3409 isc_result_t
dhcp_failover_state_set_value (omapi_object_t
*,
3411 omapi_data_string_t
*,
3412 omapi_typed_data_t
*);
3413 void dhcp_failover_keepalive (void *);
3414 void dhcp_failover_reconnect (void *);
3415 void dhcp_failover_startup_timeout (void *);
3416 void dhcp_failover_link_startup_timeout (void *);
3417 void dhcp_failover_listener_restart (void *);
3418 void dhcp_failover_auto_partner_down(void *vs
);
3419 isc_result_t
dhcp_failover_state_get_value (omapi_object_t
*,
3421 omapi_data_string_t
*,
3423 isc_result_t
dhcp_failover_state_destroy (omapi_object_t
*,
3425 isc_result_t
dhcp_failover_state_stuff (omapi_object_t
*,
3428 isc_result_t
dhcp_failover_state_lookup (omapi_object_t
**,
3431 isc_result_t
dhcp_failover_state_create (omapi_object_t
**,
3433 isc_result_t
dhcp_failover_state_remove (omapi_object_t
*,
3435 int dhcp_failover_state_match (dhcp_failover_state_t
*, u_int8_t
*, unsigned);
3436 int dhcp_failover_state_match_by_name(dhcp_failover_state_t
*,
3437 failover_option_t
*);
3438 const char *dhcp_failover_reject_reason_print (int);
3439 const char *dhcp_failover_state_name_print (enum failover_state
);
3440 const char *dhcp_failover_message_name (unsigned);
3441 const char *dhcp_failover_option_name (unsigned);
3442 failover_option_t
*dhcp_failover_option_printf (unsigned, char *,
3446 __attribute__((__format__(__printf__
,5,6)));
3447 failover_option_t
*dhcp_failover_make_option (unsigned, char *,
3448 unsigned *, unsigned, ...);
3449 isc_result_t
dhcp_failover_put_message (dhcp_failover_link_t
*,
3450 omapi_object_t
*, int, u_int32_t
, ...);
3451 isc_result_t
dhcp_failover_send_connect (omapi_object_t
*);
3452 isc_result_t
dhcp_failover_send_connectack (omapi_object_t
*,
3453 dhcp_failover_state_t
*,
3455 isc_result_t
dhcp_failover_send_disconnect (omapi_object_t
*,
3457 isc_result_t
dhcp_failover_send_bind_update (dhcp_failover_state_t
*,
3459 isc_result_t
dhcp_failover_send_bind_ack (dhcp_failover_state_t
*,
3460 failover_message_t
*,
3462 isc_result_t
dhcp_failover_send_poolreq (dhcp_failover_state_t
*);
3463 isc_result_t
dhcp_failover_send_poolresp (dhcp_failover_state_t
*, int);
3464 isc_result_t
dhcp_failover_send_update_request (dhcp_failover_state_t
*);
3465 isc_result_t
dhcp_failover_send_update_request_all (dhcp_failover_state_t
*);
3466 isc_result_t
dhcp_failover_send_update_done (dhcp_failover_state_t
*);
3467 isc_result_t
dhcp_failover_process_bind_update (dhcp_failover_state_t
*,
3468 failover_message_t
*);
3469 isc_result_t
dhcp_failover_process_bind_ack (dhcp_failover_state_t
*,
3470 failover_message_t
*);
3471 isc_result_t
dhcp_failover_generate_update_queue (dhcp_failover_state_t
*,
3473 isc_result_t
dhcp_failover_process_update_request (dhcp_failover_state_t
*,
3474 failover_message_t
*);
3475 isc_result_t
dhcp_failover_process_update_request_all (dhcp_failover_state_t
*,
3476 failover_message_t
*);
3477 isc_result_t
dhcp_failover_process_update_done (dhcp_failover_state_t
*,
3478 failover_message_t
*);
3479 void ia_remove_all_lease(struct ia_xx
*ia
, const char *file
, int line
);
3480 void dhcp_failover_recover_done (void *);
3481 void failover_print (char *, unsigned *, unsigned, const char *);
3482 void update_partner (struct lease
*);
3483 int load_balance_mine (struct packet
*, dhcp_failover_state_t
*);
3484 int peer_wants_lease (struct lease
*);
3485 binding_state_t
normal_binding_state_transition_check (struct lease
*,
3486 dhcp_failover_state_t
*,
3490 conflict_binding_state_transition_check (struct lease
*,
3491 dhcp_failover_state_t
*,
3492 binding_state_t
, u_int32_t
);
3493 int lease_mine_to_reallocate (struct lease
*);
3495 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state
, dhcp_failover_state_t
,
3496 dhcp_type_failover_state
)
3497 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener
, dhcp_failover_listener_t
,
3498 dhcp_type_failover_listener
)
3499 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link
, dhcp_failover_link_t
,
3500 dhcp_type_failover_link
)
3501 #endif /* FAILOVER_PROTOCOL */
3503 const char *binding_state_print (enum failover_state
);
3506 #if defined(LDAP_CONFIGURATION)
3507 extern struct enumeration ldap_methods
;
3508 #if defined (LDAP_USE_SSL)
3509 extern struct enumeration ldap_ssl_usage_enum
;
3510 extern struct enumeration ldap_tls_reqcert_enum
;
3511 extern struct enumeration ldap_tls_crlcheck_enum
;
3513 isc_result_t
ldap_read_config (void);
3514 int find_haddr_in_ldap (struct host_decl
**, int, unsigned,
3515 const unsigned char *, const char *, int);
3516 int find_subclass_in_ldap (struct class *, struct class **,
3517 struct data_string
*);
3521 HASH_FUNCTIONS_DECL(ia
, unsigned char *, struct ia_xx
, ia_hash_t
)
3522 HASH_FUNCTIONS_DECL(iasubopt
, struct in6_addr
*, struct iasubopt
,
3525 isc_result_t
iasubopt_allocate(struct iasubopt
**iasubopt
,
3526 const char *file
, int line
);
3527 isc_result_t
iasubopt_reference(struct iasubopt
**iasubopt
,
3528 struct iasubopt
*src
,
3529 const char *file
, int line
);
3530 isc_result_t
iasubopt_dereference(struct iasubopt
**iasubopt
,
3531 const char *file
, int line
);
3533 isc_result_t
ia_make_key(struct data_string
*key
, u_int32_t iaid
,
3534 const char *duid
, unsigned int duid_len
,
3535 const char *file
, int line
);
3536 isc_result_t
ia_allocate(struct ia_xx
**ia
, u_int32_t iaid
,
3537 const char *duid
, unsigned int duid_len
,
3538 const char *file
, int line
);
3539 isc_result_t
ia_reference(struct ia_xx
**ia
, struct ia_xx
*src
,
3540 const char *file
, int line
);
3541 isc_result_t
ia_dereference(struct ia_xx
**ia
,
3542 const char *file
, int line
);
3543 isc_result_t
ia_add_iasubopt(struct ia_xx
*ia
, struct iasubopt
*iasubopt
,
3544 const char *file
, int line
);
3545 void ia_remove_iasubopt(struct ia_xx
*ia
, struct iasubopt
*iasubopt
,
3546 const char *file
, int line
);
3547 isc_boolean_t
ia_equal(const struct ia_xx
*a
, const struct ia_xx
*b
);
3549 isc_result_t
ipv6_pool_allocate(struct ipv6_pool
**pool
, u_int16_t type
,
3550 const struct in6_addr
*start_addr
,
3551 int bits
, int units
,
3552 const char *file
, int line
);
3553 isc_result_t
ipv6_pool_reference(struct ipv6_pool
**pool
,
3554 struct ipv6_pool
*src
,
3555 const char *file
, int line
);
3556 isc_result_t
ipv6_pool_dereference(struct ipv6_pool
**pool
,
3557 const char *file
, int line
);
3558 isc_result_t
create_lease6(struct ipv6_pool
*pool
,
3559 struct iasubopt
**addr
,
3560 unsigned int *attempts
,
3561 const struct data_string
*uid
,
3562 time_t soft_lifetime_end_time
);
3563 isc_result_t
add_lease6(struct ipv6_pool
*pool
,
3564 struct iasubopt
*lease
,
3565 time_t valid_lifetime_end_time
);
3566 isc_result_t
renew_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3567 isc_result_t
expire_lease6(struct iasubopt
**leasep
,
3568 struct ipv6_pool
*pool
, time_t now
);
3569 isc_result_t
release_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3570 isc_result_t
decline_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3571 isc_boolean_t
lease6_exists(const struct ipv6_pool
*pool
,
3572 const struct in6_addr
*addr
);
3573 isc_boolean_t
lease6_usable(struct iasubopt
*lease
);
3574 isc_result_t
cleanup_lease6(ia_hash_t
*ia_table
,
3575 struct ipv6_pool
*pool
,
3576 struct iasubopt
*lease
,
3578 isc_result_t
mark_lease_unavailble(struct ipv6_pool
*pool
,
3579 const struct in6_addr
*addr
);
3580 isc_result_t
create_prefix6(struct ipv6_pool
*pool
,
3581 struct iasubopt
**pref
,
3582 unsigned int *attempts
,
3583 const struct data_string
*uid
,
3584 time_t soft_lifetime_end_time
);
3585 isc_boolean_t
prefix6_exists(const struct ipv6_pool
*pool
,
3586 const struct in6_addr
*pref
, u_int8_t plen
);
3588 isc_result_t
add_ipv6_pool(struct ipv6_pool
*pool
);
3589 isc_result_t
find_ipv6_pool(struct ipv6_pool
**pool
, u_int16_t type
,
3590 const struct in6_addr
*addr
);
3591 isc_boolean_t
ipv6_in_pool(const struct in6_addr
*addr
,
3592 const struct ipv6_pool
*pool
);
3593 isc_result_t
ipv6_pond_allocate(struct ipv6_pond
**pond
,
3594 const char *file
, int line
);
3595 isc_result_t
ipv6_pond_reference(struct ipv6_pond
**pond
,
3596 struct ipv6_pond
*src
,
3597 const char *file
, int line
);
3598 isc_result_t
ipv6_pond_dereference(struct ipv6_pond
**pond
,
3599 const char *file
, int line
);
3601 isc_result_t
renew_leases(struct ia_xx
*ia
);
3602 isc_result_t
release_leases(struct ia_xx
*ia
);
3603 isc_result_t
decline_leases(struct ia_xx
*ia
);
3604 void schedule_lease_timeout(struct ipv6_pool
*pool
);
3605 void schedule_all_ipv6_lease_timeouts(void);
3607 void mark_hosts_unavailable(void);
3608 void mark_phosts_unavailable(void);
3609 void mark_interfaces_unavailable(void);
3611 #define MAX_ADDRESS_STRING_LEN \
3612 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))