3 Definitions for dhcpd... */
6 * Copyright (c) 2004-2014 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * Internet Systems Consortium, Inc.
23 * Redwood City, CA 94063
25 * https://www.isc.org/
29 /*! \file includes/dhcpd.h */
34 #include <sys/types.h>
35 #include <netinet/in.h>
36 #include <sys/socket.h>
38 #include <arpa/inet.h>
43 #define fd_set cygwin_fd_set
44 #include <sys/types.h>
59 #include <net/route.h>
60 #include <net/if_arp.h>
62 # include <net/if_dl.h>
70 #include "arpa/nameser.h"
75 typedef struct hash_table group_hash_t
;
76 typedef struct hash_table universe_hash_t
;
77 typedef struct hash_table option_name_hash_t
;
78 typedef struct hash_table option_code_hash_t
;
79 typedef struct hash_table dns_zone_hash_t
;
80 typedef struct hash_table lease_ip_hash_t
;
81 typedef struct hash_table lease_id_hash_t
;
82 typedef struct hash_table host_hash_t
;
83 typedef struct hash_table class_hash_t
;
91 #include <omapip/isclib.h>
92 #include <omapip/result.h>
96 #include "statement.h"
101 #include <omapip/omapip_p.h>
103 #if defined(LDAP_CONFIGURATION)
105 # include <sys/utsname.h> /* for uname() */
108 #if !defined (BYTE_NAME_HASH_SIZE)
109 # define BYTE_NAME_HASH_SIZE 401 /* Default would be ridiculous. */
111 #if !defined (BYTE_CODE_HASH_SIZE)
112 # define BYTE_CODE_HASH_SIZE 254 /* Default would be ridiculous. */
115 /* Although it is highly improbable that a 16-bit option space might
116 * actually use 2^16 actual defined options, it is the worst case
117 * scenario we must prepare for. Having 4 options per bucket in this
118 * case is pretty reasonable.
120 #if !defined (WORD_NAME_HASH_SIZE)
121 # define WORD_NAME_HASH_SIZE 20479
123 #if !defined (WORD_CODE_HASH_SIZE)
124 # define WORD_CODE_HASH_SIZE 16384
127 /* Not only is it improbable that the 32-bit spaces might actually use 2^32
128 * defined options, it is infeasible. It would be best for this kind of
129 * space to be dynamically sized. Instead we size it at the word hash's
132 #if !defined (QUAD_NAME_HASH_SIZE)
133 # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
135 #if !defined (QUAD_CODE_HASH_SIZE)
136 # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
139 #if !defined (DNS_HASH_SIZE)
140 # define DNS_HASH_SIZE 0 /* Default. */
143 /* Default size to use for name/code hashes on user-defined option spaces. */
144 #if !defined (DEFAULT_SPACE_HASH_SIZE)
145 # define DEFAULT_SPACE_HASH_SIZE 11
148 #if !defined (NWIP_HASH_SIZE)
149 # define NWIP_HASH_SIZE 17 /* A really small table. */
152 #if !defined (FQDN_HASH_SIZE)
153 # define FQDN_HASH_SIZE 13 /* A ridiculously small table. */
156 /* I really doubt a given installation is going to have more than a few
157 * hundred vendors involved.
159 #if !defined (VIVCO_HASH_SIZE)
160 # define VIVCO_HASH_SIZE 127
163 #if !defined (VIVSO_HASH_SIZE)
164 # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
167 #if !defined (VSIO_HASH_SIZE)
168 # define VSIO_HASH_SIZE VIVCO_HASH_SIZE
171 #if !defined (VIV_ISC_HASH_SIZE)
172 # define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */
175 #if !defined (UNIVERSE_HASH_SIZE)
176 # define UNIVERSE_HASH_SIZE 13 /* A really small table. */
179 #if !defined (GROUP_HASH_SIZE)
180 # define GROUP_HASH_SIZE 0 /* Default. */
183 /* At least one person has indicated they use ~20k host records.
185 #if !defined (HOST_HASH_SIZE)
186 # define HOST_HASH_SIZE 22501
189 /* We have user reports of use of ISC DHCP numbering leases in the 200k's.
191 * We also have reports of folks using 10.0/8 as a dynamic range. The
192 * following is something of a compromise between the two. At the ~2-3
193 * hundred thousand leases, there's ~2-3 leases to search in each bucket.
195 #if !defined (LEASE_HASH_SIZE)
196 # define LEASE_HASH_SIZE 100003
199 /* It is not known what the worst case subclass hash size is. We estimate
202 #if !defined (SCLASS_HASH_SIZE)
203 # define SCLASS_HASH_SIZE 12007
206 #if !defined (AGENT_HASH_SIZE)
207 # define AGENT_HASH_SIZE 11 /* A really small table. */
210 /* The server hash size is used for both names and codes. There aren't
211 * many (roughly 50 at the moment), so we use a smaller table. If we
212 * use a 1:1 table size, then we get name collisions due to poor name
213 * hashing. So we use double the space we need, which drastically
214 * reduces collisions.
216 #if !defined (SERVER_HASH_SIZE)
217 # define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option)))
221 /* How many options are likely to appear in a single packet? */
222 #if !defined (OPTION_HASH_SIZE)
223 # define OPTION_HASH_SIZE 17
224 # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */
225 # define OPTION_HASH_EXP 5 /* The exponent for that power of two. */
228 #define compute_option_hash(x) \
229 (((x) & (OPTION_HASH_PTWO - 1)) + \
230 (((x) >> OPTION_HASH_EXP) & \
231 (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
233 enum dhcp_shutdown_state
{
235 shutdown_omapi_connections
,
236 shutdown_drop_omapi_connections
,
241 /* Client FQDN option, failover FQDN option, etc. */
248 #include "failover.h"
250 /* A parsing context. */
262 * In order to give nice output when we have a parsing error
263 * in our file, we keep track of where we are in the line so
264 * that we can show the user.
266 * We need to keep track of two lines, because we can look
267 * ahead, via the "peek" function, to the next line sometimes.
269 * The "line1" and "line2" variables act as buffers for this
270 * information. The "lpos" variable tells us where we are in the
273 * When we "put back" a character from the parsing context, we
274 * do not want to have the character appear twice in the error
275 * output. So, we set a flag, the "ugflag", which the
276 * get_char() function uses to check for this condition.
284 enum dhcp_token token
;
290 int warnings_occurred
;
293 size_t bufix
, buflen
;
296 struct parse
*saved_state
;
298 #if defined(LDAP_CONFIGURATION)
300 * LDAP configuration uses a call-back to iteratively read config
301 * off of the LDAP repository.
302 * XXX: The token stream can not be rewound reliably, so this must
303 * be addressed for DHCPv6 support.
305 int (*read_function
)(struct parse
*);
309 /* Variable-length array of data. */
312 struct string_list
*next
;
316 /* A name server, from /etc/resolv.conf. */
318 struct name_server
*next
;
319 struct sockaddr_in addr
;
323 /* A domain search list element. */
324 struct domain_search_list
{
325 struct domain_search_list
*next
;
330 /* Option tag structures are used to build chains of option tags, for
331 when we're sure we're not going to have enough of them to justify
332 maintaining an array. */
335 struct option_tag
*next
;
339 /* An agent option structure. We need a special structure for the
340 Relay Agent Information option because if more than one appears in
341 a message, we have to keep them separate. */
343 struct agent_options
{
344 struct agent_options
*next
;
346 struct option_tag
*first
;
349 struct option_cache
{
351 struct option_cache
*next
;
352 struct expression
*expression
;
353 struct option
*option
;
354 struct data_string data
;
356 #define OPTION_HAD_NULLS 0x00000001
360 struct option_state
{
368 /* A dhcp packet and the pointers to its option values. */
370 struct dhcp_packet
*raw
;
372 unsigned packet_length
;
375 unsigned char dhcpv6_msg_type
; /* DHCPv6 message type */
377 /* DHCPv6 transaction ID */
378 unsigned char dhcpv6_transaction_id
[3];
380 /* DHCPv6 relay information */
381 unsigned char dhcpv6_hop_count
;
382 struct in6_addr dhcpv6_link_address
;
383 struct in6_addr dhcpv6_peer_address
;
385 /* DHCPv6 packet containing this one, or NULL if none */
386 struct packet
*dhcpv6_container_packet
;
390 struct iaddr client_addr
;
391 struct interface_info
*interface
; /* Interface on which packet
393 struct hardware
*haddr
; /* Physical link address
394 of local sender (maybe gateway). */
396 /* Information for relay agent options (see
397 draft-ietf-dhc-agent-options-xx.txt). */
398 u_int8_t
*circuit_id
; /* Circuit ID of client connection. */
400 u_int8_t
*remote_id
; /* Remote ID of client. */
403 int got_requested_address
; /* True if client sent the
404 dhcp-requested-address option. */
406 struct shared_network
*shared_network
;
407 struct option_state
*options
;
409 #if !defined (PACKET_MAX_CLASSES)
410 # define PACKET_MAX_CLASSES 5
413 struct class *classes
[PACKET_MAX_CLASSES
];
418 /* If we stash agent options onto the packet option state, to pretend
419 * options we got in a previous exchange were still there, we need
420 * to signal this in a reliable way.
422 isc_boolean_t agent_options_stashed
;
425 * ISC_TRUE if packet received unicast (as opposed to multicast).
426 * Only used in DHCPv6.
428 isc_boolean_t unicast
;
432 * A network interface's MAC address.
433 * 20 bytes for the hardware address
434 * and 1 byte for the type tag
437 #define HARDWARE_ADDR_LEN 20
441 u_int8_t hbuf
[HARDWARE_ADDR_LEN
+ 1];
444 #if defined(LDAP_CONFIGURATION)
445 # define LDAP_BUFFER_SIZE 8192
446 # define LDAP_METHOD_STATIC 0
447 # define LDAP_METHOD_DYNAMIC 1
448 #if defined (LDAP_USE_SSL)
449 # define LDAP_SSL_OFF 0
450 # define LDAP_SSL_ON 1
451 # define LDAP_SSL_TLS 2
452 # define LDAP_SSL_LDAPS 3
455 /* This is a tree of the current configuration we are building from LDAP */
456 struct ldap_config_stack
{
457 LDAPMessage
* res
; /* Pointer returned from ldap_search */
458 LDAPMessage
* ldent
; /* Current item in LDAP that we're processing.
460 int close_brace
; /* Put a closing } after we're through with
462 int processed
; /* We set this flag if this base item has been
463 processed. After this base item is processed,
464 we can start processing the children */
465 struct ldap_config_stack
*children
;
466 struct ldap_config_stack
*next
;
474 server_hibernate
= 3,
476 } control_object_state_t
;
479 OMAPI_OBJECT_PREAMBLE
;
480 control_object_state_t state
;
481 } dhcp_control_object_t
;
486 #define FTS_EXPIRED 3
487 #define FTS_RELEASED 4
488 #define FTS_ABANDONED 5
491 typedef u_int8_t binding_state_t
;
493 /* FTS_LAST is the highest value that is valid for a lease binding state. */
494 #define FTS_LAST FTS_BACKUP
497 * A block for the on statements so we can share the structure
501 struct executable_statement
*on_expiry
;
502 struct executable_statement
*on_commit
;
503 struct executable_statement
*on_release
;
506 /* A dhcp lease declaration structure. */
508 OMAPI_OBJECT_PREAMBLE
;
510 struct lease
*n_uid
, *n_hw
;
512 struct iaddr ip_addr
;
513 TIME starts
, ends
, sort_time
;
514 char *client_hostname
;
515 struct binding_scope
*scope
;
516 struct host_decl
*host
;
517 struct subnet
*subnet
;
519 struct class *billing_class
;
520 struct option_chain_head
*agent_options
;
522 /* insert the structure directly */
523 struct on_star on_star
;
526 unsigned short uid_len
;
527 unsigned short uid_max
;
528 unsigned char uid_buf
[7];
529 struct hardware hardware_addr
;
532 # define STATIC_LEASE 1
533 # define BOOTP_LEASE 2
534 # define RESERVED_LEASE 4
535 # define MS_NULL_TERMINATION 8
536 # define ON_UPDATE_QUEUE 16
537 # define ON_ACK_QUEUE 32
538 # define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE)
539 # define UNICAST_BROADCAST_HACK 64
540 # define ON_DEFERRED_QUEUE 128
542 /* Persistent flags are to be preserved on a given lease structure. */
543 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
544 /* Ephemeral flags are to be preserved on a given lease (copied etc). */
545 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
546 UNICAST_BROADCAST_HACK | \
551 * The lease's binding state is its current state. The next binding
552 * state is the next state this lease will move into by expiration,
553 * or timers in general. The desired binding state is used on lease
554 * updates; the caller is attempting to move the lease to the desired
555 * binding state (and this may either succeed or fail, so the binding
556 * state must be preserved).
558 * The 'rewind' binding state is used in failover processing. It
559 * is used for an optimization when out of communications; it allows
560 * the server to "rewind" a lease to the previous state acknowledged
561 * by the peer, and progress forward from that point.
563 binding_state_t binding_state
;
564 binding_state_t next_binding_state
;
565 binding_state_t desired_binding_state
;
566 binding_state_t rewind_binding_state
;
568 struct lease_state
*state
;
571 * 'tsfp' is more of an 'effective' tsfp. It may be calculated from
572 * stos+mclt for example if it's an expired lease and the server is
573 * in partner-down state. 'atsfp' is zeroed whenever a lease is
574 * updated - and only set when the peer acknowledges it. This
575 * ensures every state change is transmitted.
577 TIME tstp
; /* Time sent to partner. */
578 TIME tsfp
; /* Time sent from partner. */
579 TIME atsfp
; /* Actual time sent from partner. */
580 TIME cltt
; /* Client last transaction time. */
581 u_int32_t last_xid
; /* XID we sent in this lease's BNDUPD */
582 struct lease
*next_pending
;
585 * A pointer to the state of the ddns update for this lease.
586 * It should be set while the update is in progress and cleared
587 * when the update finishes. It can be used to cancel the
588 * update if we want to do a different update.
590 struct dhcp_ddns_cb
*ddns_cb
;
594 struct lease_state
*next
;
596 struct interface_info
*ip
;
598 struct packet
*packet
; /* The incoming packet. */
602 struct option_state
*options
;
603 struct data_string parameter_request_list
;
604 int max_message_size
;
605 unsigned char expiry
[4], renewal
[4], rebind
[4];
606 struct data_string filename
, server_name
;
607 int got_requested_address
;
608 int got_server_identifier
;
609 struct shared_network
*shared_network
; /* Shared network of interface
610 on which request arrived. */
614 u_int16_t bootp_flags
;
615 struct in_addr ciaddr
;
616 struct in_addr siaddr
;
617 struct in_addr giaddr
;
625 #define SHARED_NET_DECL 2
626 #define SUBNET_DECL 3
631 /* Possible modes in which discover_interfaces can run. */
633 #define DISCOVER_RUNNING 0
634 #define DISCOVER_SERVER 1
635 #define DISCOVER_UNCONFIGURED 2
636 #define DISCOVER_RELAY 3
637 #define DISCOVER_REQUESTED 4
639 /* DDNS_UPDATE_STYLE enumerations. */
640 #define DDNS_UPDATE_STYLE_NONE 0
641 #define DDNS_UPDATE_STYLE_AD_HOC 1
642 #define DDNS_UPDATE_STYLE_INTERIM 2
643 #define DDNS_UPDATE_STYLE_STANDARD 3
645 /* Server option names. */
647 #define SV_DEFAULT_LEASE_TIME 1
648 #define SV_MAX_LEASE_TIME 2
649 #define SV_MIN_LEASE_TIME 3
650 #define SV_BOOTP_LEASE_CUTOFF 4
651 #define SV_BOOTP_LEASE_LENGTH 5
652 #define SV_BOOT_UNKNOWN_CLIENTS 6
653 #define SV_DYNAMIC_BOOTP 7
654 #define SV_ALLOW_BOOTP 8
655 #define SV_ALLOW_BOOTING 9
656 #define SV_ONE_LEASE_PER_CLIENT 10
657 #define SV_GET_LEASE_HOSTNAMES 11
658 #define SV_USE_HOST_DECL_NAMES 12
659 #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
660 #define SV_MIN_SECS 14
661 #define SV_FILENAME 15
662 #define SV_SERVER_NAME 16
663 #define SV_NEXT_SERVER 17
664 #define SV_AUTHORITATIVE 18
665 #define SV_VENDOR_OPTION_SPACE 19
666 #define SV_ALWAYS_REPLY_RFC1048 20
667 #define SV_SITE_OPTION_SPACE 21
668 #define SV_ALWAYS_BROADCAST 22
669 #define SV_DDNS_DOMAIN_NAME 23
670 #define SV_DDNS_HOST_NAME 24
671 #define SV_DDNS_REV_DOMAIN_NAME 25
672 #define SV_LEASE_FILE_NAME 26
673 #define SV_PID_FILE_NAME 27
674 #define SV_DUPLICATES 28
675 #define SV_DECLINES 29
676 #define SV_DDNS_UPDATES 30
677 #define SV_OMAPI_PORT 31
678 #define SV_LOCAL_PORT 32
679 #define SV_LIMITED_BROADCAST_ADDRESS 33
680 #define SV_REMOTE_PORT 34
681 #define SV_LOCAL_ADDRESS 35
682 #define SV_OMAPI_KEY 36
683 #define SV_STASH_AGENT_OPTIONS 37
684 #define SV_DDNS_TTL 38
685 #define SV_DDNS_UPDATE_STYLE 39
686 #define SV_CLIENT_UPDATES 40
687 #define SV_UPDATE_OPTIMIZATION 41
688 #define SV_PING_CHECKS 42
689 #define SV_UPDATE_STATIC_LEASES 43
690 #define SV_LOG_FACILITY 44
691 #define SV_DO_FORWARD_UPDATES 45
692 #define SV_PING_TIMEOUT 46
693 #define SV_RESERVE_INFINITE 47
694 #define SV_DDNS_CONFLICT_DETECT 48
695 #define SV_LEASEQUERY 49
696 #define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
697 #define SV_DO_REVERSE_UPDATES 51
698 #define SV_FQDN_REPLY 52
699 #define SV_PREFER_LIFETIME 53
700 #define SV_DHCPV6_LEASE_FILE_NAME 54
701 #define SV_DHCPV6_PID_FILE_NAME 55
702 #define SV_LIMIT_ADDRS_PER_IA 56
703 #define SV_LIMIT_PREFS_PER_IA 57
704 #define SV_DELAYED_ACK 58
705 #define SV_MAX_ACK_DELAY 59
706 #if defined(LDAP_CONFIGURATION)
707 # define SV_LDAP_SERVER 60
708 # define SV_LDAP_PORT 61
709 # define SV_LDAP_USERNAME 62
710 # define SV_LDAP_PASSWORD 63
711 # define SV_LDAP_BASE_DN 64
712 # define SV_LDAP_METHOD 65
713 # define SV_LDAP_DEBUG_FILE 66
714 # define SV_LDAP_DHCP_SERVER_CN 67
715 # define SV_LDAP_REFERRALS 68
716 #if defined (LDAP_USE_SSL)
717 # define SV_LDAP_SSL 69
718 # define SV_LDAP_TLS_REQCERT 70
719 # define SV_LDAP_TLS_CA_FILE 71
720 # define SV_LDAP_TLS_CA_DIR 72
721 # define SV_LDAP_TLS_CERT 73
722 # define SV_LDAP_TLS_KEY 74
723 # define SV_LDAP_TLS_CRLCHECK 75
724 # define SV_LDAP_TLS_CIPHERS 76
725 # define SV_LDAP_TLS_RANDFILE 77
728 #define SV_CACHE_THRESHOLD 78
729 #define SV_DONT_USE_FSYNC 79
730 #define SV_DDNS_LOCAL_ADDRESS4 80
731 #define SV_DDNS_LOCAL_ADDRESS6 81
732 #define SV_IGNORE_CLIENT_UIDS 82
733 #define SV_LOG_THRESHOLD_LOW 83
734 #define SV_LOG_THRESHOLD_HIGH 84
736 #if !defined (DEFAULT_PING_TIMEOUT)
737 # define DEFAULT_PING_TIMEOUT 1
740 #if !defined (DEFAULT_DELAYED_ACK)
741 # define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */
744 #if !defined (DEFAULT_ACK_DELAY_SECS)
745 # define DEFAULT_ACK_DELAY_SECS 0
748 #if !defined (DEFAULT_ACK_DELAY_USECS)
749 # define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
752 #if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
753 # define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */
756 #if !defined (DEFAULT_CACHE_THRESHOLD)
757 # define DEFAULT_CACHE_THRESHOLD 25
760 #if !defined (DEFAULT_DEFAULT_LEASE_TIME)
761 # define DEFAULT_DEFAULT_LEASE_TIME 43200
764 #if !defined (DEFAULT_MIN_LEASE_TIME)
765 # define DEFAULT_MIN_LEASE_TIME 300
768 #if !defined (DEFAULT_MAX_LEASE_TIME)
769 # define DEFAULT_MAX_LEASE_TIME 86400
772 #if !defined (DEFAULT_DDNS_TTL)
773 # define DEFAULT_DDNS_TTL 3600
775 #if !defined (MAX_DEFAULT_DDNS_TTL)
776 # define MAX_DEFAULT_DDNS_TTL 3600
779 #if !defined (MIN_LEASE_WRITE)
780 # define MIN_LEASE_WRITE 15
783 /* Client option names */
786 #define CL_SELECT_INTERVAL 2
787 #define CL_REBOOT_TIMEOUT 3
788 #define CL_RETRY_INTERVAL 4
789 #define CL_BACKOFF_CUTOFF 5
790 #define CL_INITIAL_INTERVAL 6
791 #define CL_BOOTP_POLICY 7
792 #define CL_SCRIPT_NAME 8
793 #define CL_REQUESTED_OPTIONS 9
794 #define CL_REQUESTED_LEASE_TIME 10
795 #define CL_SEND_OPTIONS 11
797 #define CL_REJECT_LIST 13
799 #ifndef CL_DEFAULT_TIMEOUT
800 # define CL_DEFAULT_TIMEOUT 60
803 #ifndef CL_DEFAULT_SELECT_INTERVAL
804 # define CL_DEFAULT_SELECT_INTERVAL 0
807 #ifndef CL_DEFAULT_REBOOT_TIMEOUT
808 # define CL_DEFAULT_REBOOT_TIMEOUT 10
811 #ifndef CL_DEFAULT_RETRY_INTERVAL
812 # define CL_DEFAULT_RETRY_INTERVAL 300
815 #ifndef CL_DEFAULT_BACKOFF_CUTOFF
816 # define CL_DEFAULT_BACKOFF_CUTOFF 120
819 #ifndef CL_DEFAULT_INITIAL_INTERVAL
820 # define CL_DEFAULT_INITIAL_INTERVAL 10
823 #ifndef CL_DEFAULT_BOOTP_POLICY
824 # define CL_DEFAULT_BOOTP_POLICY P_ACCEPT
827 #ifndef CL_DEFAULT_REQUESTED_OPTIONS
828 # define CL_DEFAULT_REQUESTED_OPTIONS \
830 DHO_BROADCAST_ADDRESS, \
834 DHO_DOMAIN_NAME_SERVERS, \
838 struct group_object
{
839 OMAPI_OBJECT_PREAMBLE
;
841 struct group_object
*n_dynamic
;
845 #define GROUP_OBJECT_DELETED 1
846 #define GROUP_OBJECT_DYNAMIC 2
847 #define GROUP_OBJECT_STATIC 4
850 /* Group of declarations that share common parameters. */
855 struct group_object
*object
;
856 struct subnet
*subnet
;
857 struct shared_network
*shared_network
;
859 struct executable_statement
*statements
;
862 /* A dhcp host declaration structure. */
864 OMAPI_OBJECT_PREAMBLE
;
865 struct host_decl
*n_ipaddr
;
866 struct host_decl
*n_dynamic
;
868 struct hardware interface
;
869 struct data_string client_identifier
;
870 struct option
*host_id_option
;
871 struct data_string host_id
;
872 /* XXXSK: fixed_addr should be an array of iaddr values,
873 not an option_cache, but it's referenced in a lot of
874 places, so we'll leave it for now. */
875 struct option_cache
*fixed_addr
;
876 struct iaddrcidrnetlist
*fixed_prefix
;
878 struct group_object
*named_group
;
879 struct data_string auth_key_id
;
881 #define HOST_DECL_DELETED 1
882 #define HOST_DECL_DYNAMIC 2
883 #define HOST_DECL_STATIC 4
884 /* For v6 the host-identifer option can specify which relay
885 to use when trying to look up an option. We store the
893 permit_unknown_clients
,
894 permit_known_clients
,
895 permit_authenticated_clients
,
896 permit_unauthenticated_clients
,
898 permit_dynamic_bootp_clients
,
903 TIME after
; /* date after which this clause applies */
907 OMAPI_OBJECT_PREAMBLE
;
910 struct shared_network
*shared_network
;
911 struct permit
*permit_list
;
912 struct permit
*prohibit_list
;
913 struct lease
*active
;
914 struct lease
*expired
;
916 struct lease
*backup
;
917 struct lease
*abandoned
;
918 struct lease
*reserved
;
919 TIME next_event_time
;
924 TIME valid_from
; /* deny pool use before this date */
925 TIME valid_until
; /* deny pool use after this date */
927 #if defined (FAILOVER_PROTOCOL)
928 dhcp_failover_state_t
*failover_peer
;
930 int logged
; /* already logged a message */
931 int low_threshold
; /* low threshold to restart logging */
934 struct shared_network
{
935 OMAPI_OBJECT_PREAMBLE
;
936 struct shared_network
*next
;
939 #define SHARED_IMPLICIT 1 /* This network was synthesized. */
942 struct subnet
*subnets
;
943 struct interface_info
*interface
;
945 struct ipv6_pond
*ipv6_pond
;
947 #if defined (FAILOVER_PROTOCOL)
948 dhcp_failover_state_t
*failover_peer
;
953 OMAPI_OBJECT_PREAMBLE
;
954 struct subnet
*next_subnet
;
955 struct subnet
*next_sibling
;
956 struct shared_network
*shared_network
;
957 struct interface_info
*interface
;
958 struct iaddr interface_address
;
960 struct iaddr netmask
;
961 int prefix_len
; /* XXX: currently for IPv6 only */
966 struct collection
*next
;
969 struct class *classes
;
972 /* Used as an argument to parse_clasS_decl() */
973 #define CLASS_TYPE_VENDOR 0
974 #define CLASS_TYPE_USER 1
975 #define CLASS_TYPE_CLASS 2
976 #define CLASS_TYPE_SUBCLASS 3
978 /* XXX classes must be reference-counted. */
980 OMAPI_OBJECT_PREAMBLE
;
981 struct class *nic
; /* Next in collection. */
982 struct class *superclass
; /* Set for spawned classes only. */
983 char *name
; /* Not set for spawned classes. */
985 /* A class may be configured to permit a limited number of leases. */
988 struct lease
**billed_leases
;
990 /* If nonzero, class has not been saved since it was last
994 /* Hash table containing subclasses. */
996 struct data_string hash_string
;
998 /* Expression used to match class. */
999 struct expression
*expr
;
1001 /* Expression used to compute subclass identifiers for spawning
1002 and to do subclass matching. */
1003 struct expression
*submatch
;
1006 struct group
*group
;
1008 /* Statements to execute if class matches. */
1009 struct executable_statement
*statements
;
1011 #define CLASS_DECL_DELETED 1
1012 #define CLASS_DECL_DYNAMIC 2
1013 #define CLASS_DECL_STATIC 4
1014 #define CLASS_DECL_SUBCLASS 8
1019 /* DHCP client lease structure... */
1020 struct client_lease
{
1021 struct client_lease
*next
; /* Next lease in list. */
1022 TIME expiry
, renewal
, rebind
; /* Lease timeouts. */
1023 struct iaddr address
; /* Address being leased. */
1024 char *server_name
; /* Name of boot server. */
1025 char *filename
; /* Name of file we're supposed to boot. */
1026 struct string_list
*medium
; /* Network medium. */
1027 struct auth_key
*key
; /* Key used in basic DHCP authentication. */
1029 unsigned int is_static
: 1; /* If set, lease is from config file. */
1030 unsigned int is_bootp
: 1; /* If set, lease was acquired with BOOTP. */
1032 struct option_state
*options
; /* Options supplied with lease. */
1033 struct iaddr next_srv_addr
; /* Address of the next server to use */
1036 /* DHCPv6 lease structures */
1038 struct dhc6_addr
*next
;
1039 struct iaddr address
;
1042 /* Address state flags. */
1043 #define DHC6_ADDR_DEPREFFED 0x01
1044 #define DHC6_ADDR_EXPIRED 0x02
1048 u_int32_t preferred_life
;
1051 struct option_state
*options
;
1055 struct dhc6_ia
*next
;
1056 unsigned char iaid
[4];
1062 struct dhc6_addr
*addrs
;
1064 struct option_state
*options
;
1068 struct dhc6_lease
*next
;
1069 struct data_string server_id
;
1071 isc_boolean_t released
;
1075 unsigned char dhcpv6_transaction_id
[3];
1076 struct dhc6_ia
*bindings
;
1078 struct option_state
*options
;
1081 /* Possible states in which the client can be. */
1093 /* Authentication and BOOTP policy possibilities (not all values work
1095 enum policy
{ P_IGNORE
, P_ACCEPT
, P_PREFER
, P_REQUIRE
, P_DONT
};
1097 /* Configuration information from the config file... */
1098 struct client_config
{
1100 * When a message has been received, run these statements
1103 struct group
*on_receipt
;
1106 * When a message is sent, run these statements.
1108 struct group
*on_transmission
;
1110 struct option
**required_options
; /* Options that MUST be present. */
1111 struct option
**requested_options
; /* Options to request (ORO/PRL). */
1113 TIME timeout
; /* Start to panic if we don't get a
1114 lease in this time period when
1116 TIME initial_delay
; /* Set initial delay before first
1118 TIME initial_interval
; /* All exponential backoff intervals
1120 TIME retry_interval
; /* If the protocol failed to produce
1121 an address before the timeout,
1122 try the protocol again after this
1124 TIME select_interval
; /* Wait this many seconds from the
1125 first DHCPDISCOVER before
1126 picking an offered lease. */
1127 TIME reboot_timeout
; /* When in INIT-REBOOT, wait this
1128 long before giving up and going
1130 TIME backoff_cutoff
; /* When doing exponential backoff,
1131 never back off to an interval
1132 longer than this amount. */
1133 u_int32_t requested_lease
; /* Requested lease time, if user
1134 doesn't configure one. */
1135 struct string_list
*media
; /* Possible network media values. */
1136 char *script_name
; /* Name of config script. */
1137 char *vendor_space_name
; /* Name of config script. */
1138 enum policy bootp_policy
;
1139 /* Ignore, accept or prefer BOOTP
1141 enum policy auth_policy
;
1142 /* Require authentication, prefer
1143 authentication, or don't try to
1145 struct string_list
*medium
; /* Current network medium. */
1147 struct iaddrmatchlist
*reject_list
; /* Servers to reject. */
1149 int omapi_port
; /* port on which to accept OMAPI
1150 connections, or -1 for no
1152 int do_forward_update
; /* If nonzero, and if we have the
1153 information we need, update the
1154 A record for the address we get. */
1157 /* Per-interface state used in the dhcp client... */
1158 /* XXX: consider union {}'ing this for v4/v6. */
1159 struct client_state
{
1160 struct client_state
*next
;
1161 struct interface_info
*interface
;
1164 /* Common values. */
1165 struct client_config
*config
; /* Client configuration. */
1166 struct string_list
*env
; /* Client script environment. */
1167 int envc
; /* Number of entries in environment. */
1168 struct option_state
*sent_options
; /* Options we sent. */
1169 enum dhcp_state state
; /* Current state for this interface. */
1170 TIME last_write
; /* Last time this state was written. */
1172 /* DHCPv4 values. */
1173 struct client_lease
*active
; /* Currently active lease. */
1174 struct client_lease
*new; /* New lease. */
1175 struct client_lease
*offered_leases
; /* Leases offered to us. */
1176 struct client_lease
*leases
; /* Leases we currently hold. */
1177 struct client_lease
*alias
; /* Alias lease. */
1179 struct iaddr destination
; /* Where to send packet. */
1180 u_int32_t xid
; /* Transaction ID. */
1181 u_int16_t secs
; /* secs value from DHCPDISCOVER. */
1182 TIME first_sending
; /* When was first copy sent? */
1183 TIME interval
; /* What's the current resend interval? */
1184 struct string_list
*medium
; /* Last media type tried. */
1185 struct dhcp_packet packet
; /* Outgoing DHCP packet. */
1186 unsigned packet_length
; /* Actual length of generated packet. */
1188 struct iaddr requested_address
; /* Address we would like to get. */
1190 /* DHCPv6 values. */
1191 unsigned char dhcpv6_transaction_id
[3];
1192 u_int8_t refresh_type
;
1194 struct dhc6_lease
*active_lease
;
1195 struct dhc6_lease
*old_lease
;
1196 struct dhc6_lease
*advertised_leases
;
1197 struct dhc6_lease
*selected_lease
;
1198 struct dhc6_lease
*held_leases
;
1200 struct timeval start_time
;
1204 /* See RFC3315 section 14. */
1205 TIME RT
; /* In hundredths of seconds. */
1206 TIME IRT
; /* In hundredths of seconds. */
1207 TIME MRC
; /* Count. */
1208 TIME MRT
; /* In hundredths of seconds. */
1209 TIME MRD
; /* In seconds, relative. */
1210 TIME next_MRD
; /* In seconds, absolute. */
1212 /* Rather than a state, we use a function that shifts around
1213 * depending what stage of life the v6 state machine is in.
1214 * This is where incoming packets are dispatched to (sometimes
1217 void (*v6_handler
)(struct packet
*, struct client_state
*);
1220 * A pointer to the state of the ddns update for this lease.
1221 * It should be set while the update is in progress and cleared
1222 * when the update finishes. It can be used to cancel the
1223 * update if we want to do a different update.
1225 struct dhcp_ddns_cb
*ddns_cb
;
1228 struct envadd_state
{
1229 struct client_state
*client
;
1233 struct dns_update_state
{
1234 struct client_state
*client
;
1235 struct iaddr address
;
1236 int dns_update_timeout
;
1239 /* Information about each network interface. */
1241 struct interface_info
{
1242 OMAPI_OBJECT_PREAMBLE
;
1243 struct interface_info
*next
; /* Next interface in list... */
1244 struct shared_network
*shared_network
;
1245 /* Networks connected to this interface. */
1246 struct hardware hw_address
; /* Its physical address. */
1247 struct in_addr
*addresses
; /* Addresses associated with this
1250 int address_count
; /* Number of addresses stored. */
1251 int address_max
; /* Size of addresses buffer. */
1252 struct in6_addr
*v6addresses
; /* IPv6 addresses associated with
1254 int v6address_count
; /* Number of IPv6 addresses associated
1255 with this interface. */
1256 int v6address_max
; /* Maximum number of IPv6 addresses
1257 we can store in current buffer. */
1259 u_int8_t
*circuit_id
; /* Circuit ID associated with this
1261 unsigned circuit_id_len
; /* Length of Circuit ID, if there
1263 u_int8_t
*remote_id
; /* Remote ID associated with this
1264 interface (if any). */
1265 unsigned remote_id_len
; /* Length of Remote ID. */
1267 char name
[IFNAMSIZ
]; /* Its name... */
1268 int index
; /* Its if_nametoindex(). */
1269 int rfdesc
; /* Its read file descriptor. */
1270 int wfdesc
; /* Its write file descriptor, if
1272 unsigned char *rbuf
; /* Read buffer, if required. */
1273 unsigned int rbuf_max
; /* Size of read buffer. */
1274 size_t rbuf_offset
; /* Current offset into buffer. */
1275 size_t rbuf_len
; /* Length of data in buffer. */
1277 struct ifreq
*ifp
; /* Pointer to ifreq struct. */
1278 int configured
; /* If set to 1, interface has at least
1279 * one valid IP address.
1281 u_int32_t flags
; /* Control flags... */
1282 #define INTERFACE_REQUESTED 1
1283 #define INTERFACE_AUTOMATIC 2
1284 #define INTERFACE_RUNNING 4
1285 #define INTERFACE_DOWNSTREAM 8
1286 #define INTERFACE_UPSTREAM 16
1287 #define INTERFACE_STREAMS (INTERFACE_DOWNSTREAM | INTERFACE_UPSTREAM)
1289 /* Only used by DHCP client code. */
1290 struct client_state
*client
;
1291 # if defined(USE_DLPI_SEND) || defined(USE_DLPI_RECEIVE) || \
1292 defined(USE_DLPI_HWADDR)
1293 int dlpi_sap_length
;
1294 struct hardware dlpi_broadcast_addr
;
1295 # endif /* DLPI_SEND || DLPI_RECEIVE */
1296 struct hardware anycast_mac_addr
;
1299 struct hardware_link
{
1300 struct hardware_link
*next
;
1301 char name
[IFNAMSIZ
];
1302 struct hardware address
;
1306 struct leasequeue
*prev
;
1307 struct leasequeue
*next
;
1308 struct lease
*lease
;
1311 typedef void (*tvref_t
)(void *, void *, const char *, int);
1312 typedef void (*tvunref_t
)(void *, const char *, int);
1314 struct timeout
*next
;
1315 struct timeval when
;
1316 void (*func
) (void *);
1320 isc_timer_t
*isc_timeout
;
1324 struct eventqueue
*next
;
1325 void (*handler
)(void *);
1329 struct protocol
*next
;
1331 void (*handler
) (struct protocol
*);
1335 struct dns_query
; /* forward */
1338 struct dns_wakeup
*next
; /* Next wakeup in chain. */
1339 void (*func
) (struct dns_query
*);
1342 struct dns_question
{
1343 u_int16_t type
; /* Type of query. */
1344 u_int16_t
class; /* Class of query. */
1345 unsigned char data
[1]; /* Query data. */
1349 u_int16_t type
; /* Type of answer. */
1350 u_int16_t
class; /* Class of answer. */
1351 int count
; /* Number of answers. */
1352 unsigned char *answers
[1]; /* Pointers to answers. */
1356 struct dns_query
*next
; /* Next query in hash bucket. */
1357 u_int32_t hash
; /* Hash bucket index. */
1358 TIME expiry
; /* Query expiry time (zero if not yet
1360 u_int16_t id
; /* Query ID (also hash table index) */
1361 caddr_t waiters
; /* Pointer to list of things waiting
1364 struct dns_question
*question
; /* Question, internal format. */
1365 struct dns_answer
*answer
; /* Answer, internal format. */
1367 unsigned char *query
; /* Query formatted for DNS server. */
1368 unsigned len
; /* Length of entire query. */
1369 int sent
; /* The query has been sent. */
1370 struct dns_wakeup
*wakeups
; /* Wakeups to call if this query is
1372 struct name_server
*next_server
; /* Next server to try. */
1373 int backoff
; /* Current backoff, in seconds. */
1376 #define DNS_ZONE_ACTIVE 0
1377 #define DNS_ZONE_INACTIVE 1
1382 struct option_cache
*primary
;
1383 struct option_cache
*secondary
;
1384 struct option_cache
*primary6
;
1385 struct option_cache
*secondary6
;
1386 struct auth_key
*key
;
1391 OMAPI_OBJECT_PREAMBLE
;
1393 void (*icmp_handler
) (struct iaddr
, u_int8_t
*, int);
1398 /* Bitmask of dhcp option codes. */
1399 typedef unsigned char option_mask
[16];
1401 /* DHCP Option mask manipulation macros... */
1402 #define OPTION_ZERO(mask) (memset (mask, 0, 16))
1403 #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
1404 #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
1405 #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
1406 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
1408 /* An option occupies its length plus two header bytes (code and
1409 length) for every 255 bytes that must be stored. */
1410 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
1412 /* Default path to dhcpd config file. */
1414 #undef _PATH_DHCPD_CONF
1415 #define _PATH_DHCPD_CONF "dhcpd.conf"
1416 #undef _PATH_DHCPD_DB
1417 #define _PATH_DHCPD_DB "dhcpd.leases"
1418 #undef _PATH_DHCPD6_DB
1419 #define _PATH_DHCPD6_DB "dhcpd6.leases"
1420 #undef _PATH_DHCPD_PID
1421 #define _PATH_DHCPD_PID "dhcpd.pid"
1422 #undef _PATH_DHCPD6_PID
1423 #define _PATH_DHCPD6_PID "dhcpd6.pid"
1426 #ifndef _PATH_DHCPD_CONF
1427 #define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
1430 #ifndef _PATH_DHCPD_DB
1431 #define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
1434 #ifndef _PATH_DHCPD6_DB
1435 #define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
1438 #ifndef _PATH_DHCPD_PID
1439 #define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid"
1442 #ifndef _PATH_DHCPD6_PID
1443 #define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid"
1448 #ifndef _PATH_DHCLIENT_CONF
1449 #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
1452 #ifndef _PATH_DHCLIENT_SCRIPT
1453 #define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script"
1456 #ifndef _PATH_DHCLIENT_PID
1457 #define _PATH_DHCLIENT_PID LOCALSTATEDIR"/run/dhclient.pid"
1460 #ifndef _PATH_DHCLIENT6_PID
1461 #define _PATH_DHCLIENT6_PID LOCALSTATEDIR"/run/dhclient6.pid"
1464 #ifndef _PATH_DHCLIENT_DB
1465 #define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases"
1468 #ifndef _PATH_DHCLIENT6_DB
1469 #define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases"
1472 #ifndef _PATH_RESOLV_CONF
1473 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
1476 #ifndef _PATH_DHCRELAY_PID
1477 #define _PATH_DHCRELAY_PID LOCALSTATEDIR"/run/dhcrelay.pid"
1480 #ifndef _PATH_DHCRELAY6_PID
1481 #define _PATH_DHCRELAY6_PID LOCALSTATEDIR"/run/dhcrelay6.pid"
1484 #ifndef DHCPD_LOG_FACILITY
1485 #define DHCPD_LOG_FACILITY LOG_DAEMON
1488 #define MAX_TIME 0x7fffffff
1492 /* include the pid in the syslog messages */
1493 #define DHCP_LOG_OPTIONS LOG_NDELAY | LOG_PID
1495 #define DHCP_LOG_OPTIONS LOG_NDELAY
1497 /* these are referenced */
1498 typedef struct hash_table ia_hash_t
;
1499 typedef struct hash_table iasubopt_hash_t
;
1501 /* IAADDR/IAPREFIX lease */
1504 int refcnt
; /* reference count */
1505 struct in6_addr addr
; /* IPv6 address/prefix */
1506 u_int8_t plen
; /* iaprefix prefix length */
1507 binding_state_t state
; /* state */
1508 struct binding_scope
*scope
; /* "set var = value;" */
1509 time_t hard_lifetime_end_time
; /* time address expires */
1510 time_t soft_lifetime_end_time
; /* time ephemeral expires */
1511 u_int32_t prefer
; /* cached preferred lifetime */
1512 u_int32_t valid
; /* cached valid lifetime */
1513 struct ia_xx
*ia
; /* IA for this lease */
1514 struct ipv6_pool
*ipv6_pool
; /* pool for this lease */
1516 * For now, just pick an arbitrary time to keep old hard leases
1517 * around (value in seconds).
1519 #define EXPIRED_IPV6_CLEANUP_TIME (60*60)
1521 int heap_index
; /* index into heap, or -1
1522 (internal use only) */
1525 * A pointer to the state of the ddns update for this lease.
1526 * It should be set while the update is in progress and cleared
1527 * when the update finishes. It can be used to cancel the
1528 * update if we want to do a different update.
1530 struct dhcp_ddns_cb
*ddns_cb
;
1532 /* space for the on * executable statements */
1533 struct on_star on_star
;
1537 int refcnt
; /* reference count */
1538 struct data_string iaid_duid
; /* from the client */
1539 u_int16_t ia_type
; /* IA_XX */
1540 int num_iasubopt
; /* number of IAADDR/PREFIX */
1541 int max_iasubopt
; /* space available for IAADDR/PREFIX */
1542 time_t cltt
; /* client last transaction time */
1543 struct iasubopt
**iasubopt
; /* pointers to the IAADDR/IAPREFIXs */
1546 extern ia_hash_t
*ia_na_active
;
1547 extern ia_hash_t
*ia_ta_active
;
1548 extern ia_hash_t
*ia_pd_active
;
1552 * \brief ipv6_pool structure
1554 * This structure is part of a range of addresses or prefixes.
1555 * A range6 or prefix6 statement will map to one or more of these
1556 * with each pool being a simple block of the form xxxx/yyy and
1557 * all the pools adding up to comprise the entire range. When
1558 * choosing an address or prefix the code will walk through the
1559 * pools until it finds one that is available.
1561 * The naming for this structure is unfortunate as there is also
1562 * a v4 pool structure and the two are not equivalent. The v4
1563 * pool matches the ipv6_pond structure. I considered changing the
1564 * name of this structure but concluded that doing so would be worse
1565 * than leaving it as is. Changing it adds some risk and makes for
1566 * larger differences between the 4.1 & 4.2 code and the 4.3 code.
1571 int refcnt
; /* reference count */
1572 u_int16_t pool_type
; /* IA_xx */
1573 struct in6_addr start_addr
; /* first IPv6 address */
1574 int bits
; /* number of bits, CIDR style */
1575 int units
; /* allocation unit in bits */
1576 iasubopt_hash_t
*leases
; /* non-free leases */
1577 int num_active
; /* count of active leases */
1578 isc_heap_t
*active_timeouts
; /* timeouts for active leases */
1579 int num_inactive
; /* count of inactive leases */
1580 isc_heap_t
*inactive_timeouts
; /* timeouts for expired or
1582 struct shared_network
*shared_network
; /* shared_network for
1584 struct subnet
*subnet
; /* subnet for this pool */
1585 struct ipv6_pond
*ipv6_pond
; /* pond for this pool */
1590 * \brief ipv6_pond structure
1592 * This structure is the ipv6 version of the v4 pool structure.
1593 * It contains the address and prefix information via the pointers
1594 * to the ipv6_pools and the allowability of this pool for a given
1595 * client via the permit lists and the valid TIMEs.
1601 struct ipv6_pond
*next
;
1602 struct group
*group
;
1603 struct shared_network
*shared_network
; /* backpointer to the enclosing
1605 struct permit
*permit_list
; /* allow clients from this list */
1606 struct permit
*prohibit_list
; /* deny clients from this list */
1607 TIME valid_from
; /* deny pool use before this date */
1608 TIME valid_until
; /* deny pool use after this date */
1610 struct ipv6_pool
**ipv6_pools
; /* NULL-terminated array */
1611 int last_ipv6_pool
; /* offset of last IPv6 pool
1612 used to issue a lease */
1613 int num_total
; /* Total number of elements in the pond */
1614 int num_active
; /* Number of elements in the pond in use */
1615 int logged
; /* already logged a message */
1616 int low_threshold
; /* low threshold to restart logging */
1619 /* Flags and state for dhcp_ddns_cb_t */
1620 #define DDNS_UPDATE_ADDR 0x01
1621 #define DDNS_UPDATE_PTR 0x02
1622 #define DDNS_INCLUDE_RRSET 0x04
1623 #define DDNS_CONFLICT_OVERRIDE 0x08
1624 #define DDNS_CLIENT_DID_UPDATE 0x10
1625 #define DDNS_EXECUTE_NEXT 0x20
1626 #define DDNS_ABORT 0x40
1627 #define DDNS_STATIC_LEASE 0x80
1628 #define DDNS_ACTIVE_LEASE 0x100
1630 * The following two groups are separate and we could reuse
1631 * values but not reusing them may be useful in the future.
1633 #define DDNS_STATE_CLEANUP 0 // The previous step failed, cleanup
1635 #define DDNS_STATE_ADD_FW_NXDOMAIN 1
1636 #define DDNS_STATE_ADD_FW_YXDHCID 2
1637 #define DDNS_STATE_ADD_PTR 3
1639 #define DDNS_STATE_REM_FW_YXDHCID 17
1640 #define DDNS_STATE_REM_FW_NXRR 18
1641 #define DDNS_STATE_REM_PTR 19
1644 * Flags for the dns print function
1646 #define DDNS_PRINT_INBOUND 1
1647 #define DDNS_PRINT_OUTBOUND 0
1649 struct dhcp_ddns_cb
;
1651 typedef void (*ddns_action_t
)(struct dhcp_ddns_cb
*ddns_cb
,
1652 isc_result_t result
);
1654 typedef struct dhcp_ddns_cb
{
1655 struct data_string fwd_name
;
1656 struct data_string rev_name
;
1657 struct data_string dhcid
;
1658 struct iaddr address
;
1663 unsigned char zone_name
[DHCP_MAXDNS_WIRE
];
1664 isc_sockaddrlist_t zone_server_list
;
1665 isc_sockaddr_t zone_addrs
[DHCP_MAXNS
];
1666 int zone_addr_count
;
1667 struct dns_zone
*zone
;
1672 ddns_action_t cur_func
;
1674 struct dhcp_ddns_cb
* next_op
;
1676 /* Lease or client state that triggered the ddns operation */
1678 struct binding_scope
**scope
;
1683 dns_rdataclass_t dhcid_class
;
1687 extern struct ipv6_pool
**pools
;
1688 extern int num_pools
;
1690 /* External definitions... */
1692 HASH_FUNCTIONS_DECL (group
, const char *, struct group_object
, group_hash_t
)
1693 HASH_FUNCTIONS_DECL (universe
, const char *, struct universe
, universe_hash_t
)
1694 HASH_FUNCTIONS_DECL (option_name
, const char *, struct option
,
1696 HASH_FUNCTIONS_DECL (option_code
, const unsigned *, struct option
,
1698 HASH_FUNCTIONS_DECL (dns_zone
, const char *, struct dns_zone
, dns_zone_hash_t
)
1699 HASH_FUNCTIONS_DECL(lease_ip
, const unsigned char *, struct lease
,
1701 HASH_FUNCTIONS_DECL(lease_id
, const unsigned char *, struct lease
,
1703 HASH_FUNCTIONS_DECL (host
, const unsigned char *, struct host_decl
, host_hash_t
)
1704 HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t
)
1708 extern struct option
*vendor_cfg_option
;
1709 int parse_options (struct packet
*);
1710 int parse_option_buffer (struct option_state
*, const unsigned char *,
1711 unsigned, struct universe
*);
1712 struct universe
*find_option_universe (struct option
*, const char *);
1713 int parse_encapsulated_suboptions (struct option_state
*, struct option
*,
1714 const unsigned char *, unsigned,
1715 struct universe
*, const char *);
1716 int cons_options (struct packet
*, struct dhcp_packet
*, struct lease
*,
1717 struct client_state
*,
1718 int, struct option_state
*, struct option_state
*,
1719 struct binding_scope
**,
1720 int, int, int, struct data_string
*, const char *);
1721 int fqdn_universe_decode (struct option_state
*,
1722 const unsigned char *, unsigned, struct universe
*);
1723 struct option_cache
*
1724 lookup_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1727 save_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1728 struct option_cache
*oc
, isc_boolean_t appendp
);
1730 delete_fqdn6_option(struct universe
*universe
, struct option_state
*options
,
1733 fqdn6_option_space_foreach(struct packet
*packet
, struct lease
*lease
,
1734 struct client_state
*client_state
,
1735 struct option_state
*in_options
,
1736 struct option_state
*cfg_options
,
1737 struct binding_scope
**scope
,
1738 struct universe
*u
, void *stuff
,
1739 void (*func
)(struct option_cache
*,
1742 struct client_state
*,
1743 struct option_state
*,
1744 struct option_state
*,
1745 struct binding_scope
**,
1746 struct universe
*, void *));
1748 fqdn6_option_space_encapsulate(struct data_string
*result
,
1749 struct packet
*packet
, struct lease
*lease
,
1750 struct client_state
*client_state
,
1751 struct option_state
*in_options
,
1752 struct option_state
*cfg_options
,
1753 struct binding_scope
**scope
,
1754 struct universe
*universe
);
1756 fqdn6_universe_decode(struct option_state
*options
,
1757 const unsigned char *buffer
, unsigned length
,
1758 struct universe
*u
);
1759 int append_option(struct data_string
*dst
, struct universe
*universe
,
1760 struct option
*option
, struct data_string
*src
);
1762 store_options(int *ocount
,
1763 unsigned char *buffer
, unsigned buflen
, unsigned index
,
1764 struct packet
*packet
, struct lease
*lease
,
1765 struct client_state
*client_state
,
1766 struct option_state
*in_options
,
1767 struct option_state
*cfg_options
,
1768 struct binding_scope
**scope
,
1769 unsigned *priority_list
, int priority_len
,
1770 unsigned first_cutoff
, int second_cutoff
, int terminate
,
1771 const char *vuname
);
1772 int store_options6(char *, int, struct option_state
*, struct packet
*,
1773 const int *, struct data_string
*);
1774 int format_has_text(const char *);
1775 int format_min_length(const char *, struct option_cache
*);
1776 const char *pretty_print_option (struct option
*, const unsigned char *,
1777 unsigned, int, int);
1778 int pretty_escape(char **, char *, const unsigned char **,
1779 const unsigned char *);
1780 int get_option (struct data_string
*, struct universe
*,
1781 struct packet
*, struct lease
*, struct client_state
*,
1782 struct option_state
*, struct option_state
*,
1783 struct option_state
*, struct binding_scope
**, unsigned,
1785 int get_option_int (int *, struct universe
*,
1786 struct packet
*, struct lease
*, struct client_state
*,
1787 struct option_state
*, struct option_state
*,
1788 struct option_state
*, struct binding_scope
**, unsigned,
1790 void set_option (struct universe
*, struct option_state
*,
1791 struct option_cache
*, enum statement_op
);
1792 struct option_cache
*lookup_option (struct universe
*,
1793 struct option_state
*, unsigned);
1794 struct option_cache
*lookup_hashed_option (struct universe
*,
1795 struct option_state
*,
1797 struct option_cache
*next_hashed_option(struct universe
*,
1798 struct option_state
*,
1799 struct option_cache
*);
1800 int save_option_buffer (struct universe
*, struct option_state
*,
1801 struct buffer
*, unsigned char *, unsigned,
1803 int append_option_buffer(struct universe
*, struct option_state
*,
1804 struct buffer
*, unsigned char *, unsigned,
1806 void build_server_oro(struct data_string
*, struct option_state
*,
1808 void save_option(struct universe
*, struct option_state
*,
1809 struct option_cache
*);
1810 void also_save_option(struct universe
*, struct option_state
*,
1811 struct option_cache
*);
1812 void save_hashed_option(struct universe
*, struct option_state
*,
1813 struct option_cache
*, isc_boolean_t appendp
);
1814 void delete_option (struct universe
*, struct option_state
*, int);
1815 void delete_hashed_option (struct universe
*,
1816 struct option_state
*, int);
1817 int option_cache_dereference (struct option_cache
**,
1819 int hashed_option_state_dereference (struct universe
*,
1820 struct option_state
*,
1822 int store_option (struct data_string
*,
1823 struct universe
*, struct packet
*, struct lease
*,
1824 struct client_state
*,
1825 struct option_state
*, struct option_state
*,
1826 struct binding_scope
**, struct option_cache
*);
1827 int option_space_encapsulate (struct data_string
*,
1828 struct packet
*, struct lease
*,
1829 struct client_state
*,
1830 struct option_state
*,
1831 struct option_state
*,
1832 struct binding_scope
**,
1833 struct data_string
*);
1834 int hashed_option_space_encapsulate (struct data_string
*,
1835 struct packet
*, struct lease
*,
1836 struct client_state
*,
1837 struct option_state
*,
1838 struct option_state
*,
1839 struct binding_scope
**,
1841 int nwip_option_space_encapsulate (struct data_string
*,
1842 struct packet
*, struct lease
*,
1843 struct client_state
*,
1844 struct option_state
*,
1845 struct option_state
*,
1846 struct binding_scope
**,
1848 int fqdn_option_space_encapsulate (struct data_string
*,
1849 struct packet
*, struct lease
*,
1850 struct client_state
*,
1851 struct option_state
*,
1852 struct option_state
*,
1853 struct binding_scope
**,
1855 void suboption_foreach (struct packet
*, struct lease
*, struct client_state
*,
1856 struct option_state
*, struct option_state
*,
1857 struct binding_scope
**, struct universe
*, void *,
1858 void (*) (struct option_cache
*, struct packet
*,
1859 struct lease
*, struct client_state
*,
1860 struct option_state
*, struct option_state
*,
1861 struct binding_scope
**,
1862 struct universe
*, void *),
1863 struct option_cache
*, const char *);
1864 void option_space_foreach (struct packet
*, struct lease
*,
1865 struct client_state
*,
1866 struct option_state
*,
1867 struct option_state
*,
1868 struct binding_scope
**,
1869 struct universe
*, void *,
1870 void (*) (struct option_cache
*,
1872 struct lease
*, struct client_state
*,
1873 struct option_state
*,
1874 struct option_state
*,
1875 struct binding_scope
**,
1876 struct universe
*, void *));
1877 void hashed_option_space_foreach (struct packet
*, struct lease
*,
1878 struct client_state
*,
1879 struct option_state
*,
1880 struct option_state
*,
1881 struct binding_scope
**,
1882 struct universe
*, void *,
1883 void (*) (struct option_cache
*,
1886 struct client_state
*,
1887 struct option_state
*,
1888 struct option_state
*,
1889 struct binding_scope
**,
1890 struct universe
*, void *));
1891 int linked_option_get (struct data_string
*, struct universe
*,
1892 struct packet
*, struct lease
*,
1893 struct client_state
*,
1894 struct option_state
*, struct option_state
*,
1895 struct option_state
*, struct binding_scope
**,
1897 int linked_option_state_dereference (struct universe
*,
1898 struct option_state
*,
1900 void save_linked_option(struct universe
*, struct option_state
*,
1901 struct option_cache
*, isc_boolean_t appendp
);
1902 void linked_option_space_foreach (struct packet
*, struct lease
*,
1903 struct client_state
*,
1904 struct option_state
*,
1905 struct option_state
*,
1906 struct binding_scope
**,
1907 struct universe
*, void *,
1908 void (*) (struct option_cache
*,
1911 struct client_state
*,
1912 struct option_state
*,
1913 struct option_state
*,
1914 struct binding_scope
**,
1915 struct universe
*, void *));
1916 int linked_option_space_encapsulate (struct data_string
*, struct packet
*,
1917 struct lease
*, struct client_state
*,
1918 struct option_state
*,
1919 struct option_state
*,
1920 struct binding_scope
**,
1922 void delete_linked_option (struct universe
*, struct option_state
*, int);
1923 struct option_cache
*lookup_linked_option (struct universe
*,
1924 struct option_state
*, unsigned);
1925 void do_packet (struct interface_info
*,
1926 struct dhcp_packet
*, unsigned,
1927 unsigned int, struct iaddr
, struct hardware
*);
1928 void do_packet6(struct interface_info
*, const char *,
1929 int, int, const struct iaddr
*, isc_boolean_t
);
1930 int packet6_len_okay(const char *, int);
1932 int validate_packet(struct packet
*);
1934 int add_option(struct option_state
*options
,
1935 unsigned int option_num
,
1937 unsigned int data_len
);
1940 extern struct timeval cur_tv
;
1941 #define cur_time cur_tv.tv_sec
1943 extern int ddns_update_style
;
1944 extern int dont_use_fsync
;
1946 extern const char *path_dhcpd_conf
;
1947 extern const char *path_dhcpd_db
;
1948 extern const char *path_dhcpd_pid
;
1950 extern int dhcp_max_agent_option_packet_length
;
1951 extern struct eventqueue
*rw_queue_empty
;
1953 int main(int, char **);
1954 void postconf_initialization(int);
1955 void postdb_startup(void);
1956 void cleanup (void);
1957 void lease_pinged (struct iaddr
, u_int8_t
*, int);
1958 void lease_ping_timeout (void *);
1959 int dhcpd_interface_setup_hook (struct interface_info
*ip
, struct iaddr
*ia
);
1960 extern enum dhcp_shutdown_state shutdown_state
;
1961 isc_result_t
dhcp_io_shutdown (omapi_object_t
*, void *);
1962 isc_result_t
dhcp_set_control_state (control_object_state_t oldstate
,
1963 control_object_state_t newstate
);
1964 #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1965 void relinquish_ackqueue(void);
1969 isc_result_t
new_parse (struct parse
**, int,
1970 char *, unsigned, const char *, int);
1971 isc_result_t
end_parse (struct parse
**);
1972 isc_result_t
save_parse_state(struct parse
*cfile
);
1973 isc_result_t
restore_parse_state(struct parse
*cfile
);
1974 enum dhcp_token
next_token (const char **, unsigned *, struct parse
*);
1975 enum dhcp_token
peek_token (const char **, unsigned *, struct parse
*);
1976 enum dhcp_token
next_raw_token(const char **rval
, unsigned *rlen
,
1977 struct parse
*cfile
);
1978 enum dhcp_token
peek_raw_token(const char **rval
, unsigned *rlen
,
1979 struct parse
*cfile
);
1981 * Use skip_token when we are skipping a token we have previously
1982 * used peek_token on as we know what the result will be in this case.
1984 #define skip_token(a,b,c) ((void) next_token((a),(b),(c)))
1988 void parse_trace_setup (void);
1989 isc_result_t
readconf (void);
1990 isc_result_t
read_conf_file (const char *, struct group
*, int, int);
1991 #if defined (TRACING)
1992 void trace_conf_input (trace_type_t
*, unsigned, char *);
1993 void trace_conf_stop (trace_type_t
*ttype
);
1995 isc_result_t
conf_file_subparse (struct parse
*, struct group
*, int);
1996 isc_result_t
lease_file_subparse (struct parse
*);
1997 int parse_statement (struct parse
*, struct group
*, int,
1998 struct host_decl
*, int);
1999 #if defined (FAILOVER_PROTOCOL)
2000 void parse_failover_peer (struct parse
*, struct group
*, int);
2001 void parse_failover_state_declaration (struct parse
*,
2002 dhcp_failover_state_t
*);
2003 void parse_failover_state (struct parse
*,
2004 enum failover_state
*, TIME
*);
2006 int permit_list_match (struct permit
*, struct permit
*);
2007 void parse_pool_statement (struct parse
*, struct group
*, int);
2008 int parse_lbrace (struct parse
*);
2009 void parse_host_declaration (struct parse
*, struct group
*);
2010 int parse_class_declaration (struct class **, struct parse
*,
2011 struct group
*, int);
2012 void parse_shared_net_declaration (struct parse
*, struct group
*);
2013 void parse_subnet_declaration (struct parse
*,
2014 struct shared_network
*);
2015 void parse_subnet6_declaration (struct parse
*,
2016 struct shared_network
*);
2017 void parse_group_declaration (struct parse
*, struct group
*);
2018 int parse_fixed_addr_param (struct option_cache
**,
2019 struct parse
*, enum dhcp_token
);
2020 int parse_lease_declaration (struct lease
**, struct parse
*);
2021 int parse_ip6_addr(struct parse
*, struct iaddr
*);
2022 int parse_ip6_addr_expr(struct expression
**, struct parse
*);
2023 int parse_ip6_prefix(struct parse
*, struct iaddr
*, u_int8_t
*);
2024 void parse_address_range (struct parse
*, struct group
*, int,
2025 struct pool
*, struct lease
**);
2026 void parse_address_range6(struct parse
*cfile
, struct group
*group
,
2027 struct ipv6_pond
*);
2028 void parse_prefix6(struct parse
*cfile
, struct group
*group
,
2029 struct ipv6_pond
*);
2030 void parse_fixed_prefix6(struct parse
*cfile
, struct host_decl
*host_decl
);
2031 void parse_ia_na_declaration(struct parse
*);
2032 void parse_ia_ta_declaration(struct parse
*);
2033 void parse_ia_pd_declaration(struct parse
*);
2034 void parse_server_duid(struct parse
*cfile
);
2035 void parse_server_duid_conf(struct parse
*cfile
);
2036 void parse_pool6_statement (struct parse
*, struct group
*, int);
2039 int ddns_updates(struct packet
*, struct lease
*, struct lease
*,
2040 struct iasubopt
*, struct iasubopt
*, struct option_state
*);
2041 isc_result_t
ddns_removals(struct lease
*, struct iasubopt
*,
2042 struct dhcp_ddns_cb
*, isc_boolean_t
);
2043 #if defined (TRACING)
2044 void trace_ddns_init(void);
2048 void add_enumeration (struct enumeration
*);
2049 struct enumeration
*find_enumeration (const char *, int);
2050 struct enumeration_value
*find_enumeration_value (const char *, int,
2053 void skip_to_semi (struct parse
*);
2054 void skip_to_rbrace (struct parse
*, int);
2055 int parse_semi (struct parse
*);
2056 int parse_string (struct parse
*, char **, unsigned *);
2057 char *parse_host_name (struct parse
*);
2058 int parse_ip_addr_or_hostname (struct expression
**,
2059 struct parse
*, int);
2060 void parse_hardware_param (struct parse
*, struct hardware
*);
2061 void parse_lease_time (struct parse
*, TIME
*);
2062 unsigned char *parse_numeric_aggregate (struct parse
*,
2063 unsigned char *, unsigned *,
2064 int, int, unsigned);
2065 void convert_num (struct parse
*, unsigned char *, const char *,
2067 TIME
parse_date (struct parse
*);
2068 TIME
parse_date_core(struct parse
*);
2069 isc_result_t
parse_option_name (struct parse
*, int, int *,
2071 void parse_option_space_decl (struct parse
*);
2072 int parse_option_code_definition (struct parse
*, struct option
*);
2073 int parse_base64 (struct data_string
*, struct parse
*);
2074 int parse_cshl (struct data_string
*, struct parse
*);
2075 int parse_executable_statement (struct executable_statement
**,
2076 struct parse
*, int *,
2077 enum expression_context
);
2078 int parse_executable_statements (struct executable_statement
**,
2079 struct parse
*, int *,
2080 enum expression_context
);
2081 int parse_zone (struct dns_zone
*, struct parse
*);
2082 int parse_key (struct parse
*);
2083 int parse_on_statement (struct executable_statement
**,
2084 struct parse
*, int *);
2085 int parse_switch_statement (struct executable_statement
**,
2086 struct parse
*, int *);
2087 int parse_case_statement (struct executable_statement
**,
2088 struct parse
*, int *,
2089 enum expression_context
);
2090 int parse_if_statement (struct executable_statement
**,
2091 struct parse
*, int *);
2092 int parse_boolean_expression (struct expression
**,
2093 struct parse
*, int *);
2094 int parse_boolean (struct parse
*);
2095 int parse_data_expression (struct expression
**,
2096 struct parse
*, int *);
2097 int parse_numeric_expression (struct expression
**,
2098 struct parse
*, int *);
2099 int parse_dns_expression (struct expression
**, struct parse
*, int *);
2100 int parse_non_binary (struct expression
**, struct parse
*, int *,
2101 enum expression_context
);
2102 int parse_expression (struct expression
**, struct parse
*, int *,
2103 enum expression_context
,
2104 struct expression
**, enum expr_op
);
2105 int parse_option_data(struct expression
**expr
, struct parse
*cfile
,
2106 int lookups
, struct option
*option
);
2107 int parse_option_statement (struct executable_statement
**,
2108 struct parse
*, int,
2109 struct option
*, enum statement_op
);
2110 int parse_option_token (struct expression
**, struct parse
*,
2111 const char **, struct expression
*, int, int);
2112 int parse_allow_deny (struct option_cache
**, struct parse
*, int);
2113 int parse_auth_key (struct data_string
*, struct parse
*);
2114 int parse_warn (struct parse
*, const char *, ...)
2115 __attribute__((__format__(__printf__
,2,3)));
2116 struct expression
*parse_domain_list(struct parse
*cfile
, int);
2120 extern struct binding_scope
*global_scope
;
2121 pair
cons (caddr_t
, pair
);
2122 int make_const_option_cache (struct option_cache
**, struct buffer
**,
2123 u_int8_t
*, unsigned, struct option
*,
2125 int make_host_lookup (struct expression
**, const char *);
2126 int enter_dns_host (struct dns_host_entry
**, const char *);
2127 int make_const_data (struct expression
**,
2128 const unsigned char *, unsigned, int, int,
2130 int make_const_int (struct expression
**, unsigned long);
2131 int make_concat (struct expression
**,
2132 struct expression
*, struct expression
*);
2133 int make_encapsulation (struct expression
**, struct data_string
*);
2134 int make_substring (struct expression
**, struct expression
*,
2135 struct expression
*, struct expression
*);
2136 int make_limit (struct expression
**, struct expression
*, int);
2137 int make_let (struct executable_statement
**, const char *);
2138 int option_cache (struct option_cache
**, struct data_string
*,
2139 struct expression
*, struct option
*,
2141 int evaluate_expression (struct binding_value
**, struct packet
*,
2142 struct lease
*, struct client_state
*,
2143 struct option_state
*, struct option_state
*,
2144 struct binding_scope
**, struct expression
*,
2146 int binding_value_dereference (struct binding_value
**, const char *, int);
2147 int evaluate_boolean_expression (int *,
2148 struct packet
*, struct lease
*,
2149 struct client_state
*,
2150 struct option_state
*,
2151 struct option_state
*,
2152 struct binding_scope
**,
2153 struct expression
*);
2154 int evaluate_data_expression (struct data_string
*,
2155 struct packet
*, struct lease
*,
2156 struct client_state
*,
2157 struct option_state
*,
2158 struct option_state
*,
2159 struct binding_scope
**,
2160 struct expression
*,
2162 int evaluate_numeric_expression (unsigned long *, struct packet
*,
2163 struct lease
*, struct client_state
*,
2164 struct option_state
*, struct option_state
*,
2165 struct binding_scope
**,
2166 struct expression
*);
2167 int evaluate_option_cache (struct data_string
*,
2168 struct packet
*, struct lease
*,
2169 struct client_state
*,
2170 struct option_state
*, struct option_state
*,
2171 struct binding_scope
**,
2172 struct option_cache
*,
2174 int evaluate_boolean_option_cache (int *,
2175 struct packet
*, struct lease
*,
2176 struct client_state
*,
2177 struct option_state
*,
2178 struct option_state
*,
2179 struct binding_scope
**,
2180 struct option_cache
*,
2182 int evaluate_boolean_expression_result (int *,
2183 struct packet
*, struct lease
*,
2184 struct client_state
*,
2185 struct option_state
*,
2186 struct option_state
*,
2187 struct binding_scope
**,
2188 struct expression
*);
2189 void expression_dereference (struct expression
**, const char *, int);
2190 int is_dns_expression (struct expression
*);
2191 int is_boolean_expression (struct expression
*);
2192 int is_data_expression (struct expression
*);
2193 int is_numeric_expression (struct expression
*);
2194 int is_compound_expression (struct expression
*);
2195 int op_precedence (enum expr_op
, enum expr_op
);
2196 enum expression_context
expression_context (struct expression
*);
2197 enum expression_context
op_context (enum expr_op
);
2198 int write_expression (FILE *, struct expression
*, int, int, int);
2199 struct binding
*find_binding (struct binding_scope
*, const char *);
2200 int free_bindings (struct binding_scope
*, const char *, int);
2201 int binding_scope_dereference (struct binding_scope
**,
2203 int fundef_dereference (struct fundef
**, const char *, int);
2204 int data_subexpression_length (int *, struct expression
*);
2205 int expr_valid_for_context (struct expression
*, enum expression_context
);
2206 struct binding
*create_binding (struct binding_scope
**, const char *);
2207 int bind_ds_value (struct binding_scope
**,
2208 const char *, struct data_string
*);
2209 int find_bound_string (struct data_string
*,
2210 struct binding_scope
*, const char *);
2211 int unset (struct binding_scope
*, const char *);
2212 int data_string_sprintfa(struct data_string
*ds
, const char *fmt
, ...);
2215 extern int outstanding_pings
;
2216 extern int max_outstanding_acks
;
2217 extern int max_ack_delay_secs
;
2218 extern int max_ack_delay_usecs
;
2220 void dhcp (struct packet
*);
2221 void dhcpdiscover (struct packet
*, int);
2222 void dhcprequest (struct packet
*, int, struct lease
*);
2223 void dhcprelease (struct packet
*, int);
2224 void dhcpdecline (struct packet
*, int);
2225 void dhcpinform (struct packet
*, int);
2226 void nak_lease (struct packet
*, struct iaddr
*cip
);
2227 void ack_lease (struct packet
*, struct lease
*,
2228 unsigned int, TIME
, char *, int, struct host_decl
*);
2229 void delayed_ack_enqueue(struct lease
*);
2230 void commit_leases_readerdry(void *);
2231 void flush_ackqueue(void *);
2232 void dhcp_reply (struct lease
*);
2233 int find_lease (struct lease
**, struct packet
*,
2234 struct shared_network
*, int *, int *, struct lease
*,
2236 int mockup_lease (struct lease
**, struct packet
*,
2237 struct shared_network
*,
2238 struct host_decl
*);
2239 void static_lease_dereference (struct lease
*, const char *, int);
2241 int allocate_lease (struct lease
**, struct packet
*,
2242 struct pool
*, int *);
2243 int permitted (struct packet
*, struct permit
*);
2244 int locate_network (struct packet
*);
2245 int parse_agent_information_option (struct packet
*, int, u_int8_t
*);
2246 unsigned cons_agent_information_options (struct option_state
*,
2247 struct dhcp_packet
*,
2248 unsigned, unsigned);
2249 void get_server_source_address(struct in_addr
*from
,
2250 struct option_state
*options
,
2251 struct option_state
*out_options
,
2252 struct packet
*packet
);
2253 void setup_server_source_address(struct in_addr
*from
,
2254 struct option_state
*options
,
2255 struct packet
*packet
);
2257 /* dhcpleasequery.c */
2258 void dhcpleasequery (struct packet
*, int);
2259 void dhcpv6_leasequery (struct data_string
*, struct packet
*);
2262 isc_boolean_t
server_duid_isset(void);
2263 void copy_server_duid(struct data_string
*ds
, const char *file
, int line
);
2264 void set_server_duid(struct data_string
*new_duid
);
2265 isc_result_t
set_server_duid_from_option(void);
2266 void set_server_duid_type(int type
);
2267 isc_result_t
generate_new_server_duid(void);
2268 isc_result_t
get_client_id(struct packet
*, struct data_string
*);
2269 void dhcpv6(struct packet
*);
2272 void bootp (struct packet
*);
2275 extern int (*group_write_hook
) (struct group_object
*);
2276 extern struct group
*root_group
;
2277 extern group_hash_t
*group_name_hash
;
2278 isc_result_t
delete_group (struct group_object
*, int);
2279 isc_result_t
supersede_group (struct group_object
*, int);
2280 int clone_group (struct group
**, struct group
*, const char *, int);
2281 int write_group (struct group_object
*);
2284 void relinquish_lease_hunks (void);
2285 struct lease
*new_leases (unsigned, const char *, int);
2286 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2287 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2288 void relinquish_free_lease_states (void);
2290 OMAPI_OBJECT_ALLOC_DECL (lease
, struct lease
, dhcp_type_lease
)
2291 OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class
)
2292 OMAPI_OBJECT_ALLOC_DECL (subclass
, struct class, dhcp_type_subclass
)
2293 OMAPI_OBJECT_ALLOC_DECL (pool
, struct pool
, dhcp_type_pool
)
2294 OMAPI_OBJECT_ALLOC_DECL (host
, struct host_decl
, dhcp_type_host
)
2297 OMAPI_OBJECT_ALLOC_DECL (subnet
, struct subnet
, dhcp_type_subnet
)
2298 OMAPI_OBJECT_ALLOC_DECL (shared_network
, struct shared_network
,
2299 dhcp_type_shared_network
)
2300 OMAPI_OBJECT_ALLOC_DECL (group_object
, struct group_object
, dhcp_type_group
)
2301 OMAPI_OBJECT_ALLOC_DECL (dhcp_control
,
2302 dhcp_control_object_t
, dhcp_type_control
)
2304 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2305 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2306 void relinquish_free_pairs (void);
2307 void relinquish_free_expressions (void);
2308 void relinquish_free_binding_values (void);
2309 void relinquish_free_option_caches (void);
2310 void relinquish_free_packets (void);
2313 int option_chain_head_allocate (struct option_chain_head
**,
2315 int option_chain_head_reference (struct option_chain_head
**,
2316 struct option_chain_head
*,
2318 int option_chain_head_dereference (struct option_chain_head
**,
2320 int group_allocate (struct group
**, const char *, int);
2321 int group_reference (struct group
**, struct group
*, const char *, int);
2322 int group_dereference (struct group
**, const char *, int);
2323 struct dhcp_packet
*new_dhcp_packet (const char *, int);
2324 struct protocol
*new_protocol (const char *, int);
2325 struct lease_state
*new_lease_state (const char *, int);
2326 struct domain_search_list
*new_domain_search_list (const char *, int);
2327 struct name_server
*new_name_server (const char *, int);
2328 void free_name_server (struct name_server
*, const char *, int);
2329 struct option
*new_option (const char *, const char *, int);
2330 int option_reference(struct option
**dest
, struct option
*src
,
2331 const char * file
, int line
);
2332 int option_dereference(struct option
**dest
, const char *file
, int line
);
2333 struct universe
*new_universe (const char *, int);
2334 void free_universe (struct universe
*, const char *, int);
2335 void free_domain_search_list (struct domain_search_list
*,
2337 void free_lease_state (struct lease_state
*, const char *, int);
2338 void free_protocol (struct protocol
*, const char *, int);
2339 void free_dhcp_packet (struct dhcp_packet
*, const char *, int);
2340 struct client_lease
*new_client_lease (const char *, int);
2341 void free_client_lease (struct client_lease
*, const char *, int);
2342 struct permit
*new_permit (const char *, int);
2343 void free_permit (struct permit
*, const char *, int);
2344 pair
new_pair (const char *, int);
2345 void free_pair (pair
, const char *, int);
2346 int expression_allocate (struct expression
**, const char *, int);
2347 int expression_reference (struct expression
**,
2348 struct expression
*, const char *, int);
2349 void free_expression (struct expression
*, const char *, int);
2350 int binding_value_allocate (struct binding_value
**,
2352 int binding_value_reference (struct binding_value
**,
2353 struct binding_value
*,
2355 void free_binding_value (struct binding_value
*, const char *, int);
2356 int fundef_allocate (struct fundef
**, const char *, int);
2357 int fundef_reference (struct fundef
**,
2358 struct fundef
*, const char *, int);
2359 int option_cache_allocate (struct option_cache
**, const char *, int);
2360 int option_cache_reference (struct option_cache
**,
2361 struct option_cache
*, const char *, int);
2362 int buffer_allocate (struct buffer
**, unsigned, const char *, int);
2363 int buffer_reference (struct buffer
**, struct buffer
*,
2365 int buffer_dereference (struct buffer
**, const char *, int);
2366 int dns_host_entry_allocate (struct dns_host_entry
**,
2367 const char *, const char *, int);
2368 int dns_host_entry_reference (struct dns_host_entry
**,
2369 struct dns_host_entry
*,
2371 int dns_host_entry_dereference (struct dns_host_entry
**,
2373 int option_state_allocate (struct option_state
**, const char *, int);
2374 int option_state_reference (struct option_state
**,
2375 struct option_state
*, const char *, int);
2376 int option_state_dereference (struct option_state
**,
2378 void data_string_copy(struct data_string
*, const struct data_string
*,
2380 void data_string_forget (struct data_string
*, const char *, int);
2381 void data_string_truncate (struct data_string
*, int);
2382 int executable_statement_allocate (struct executable_statement
**,
2384 int executable_statement_reference (struct executable_statement
**,
2385 struct executable_statement
*,
2387 int packet_allocate (struct packet
**, const char *, int);
2388 int packet_reference (struct packet
**,
2389 struct packet
*, const char *, int);
2390 int packet_dereference (struct packet
**, const char *, int);
2391 int binding_scope_allocate (struct binding_scope
**,
2393 int binding_scope_reference (struct binding_scope
**,
2394 struct binding_scope
*,
2396 int dns_zone_allocate (struct dns_zone
**, const char *, int);
2397 int dns_zone_reference (struct dns_zone
**,
2398 struct dns_zone
*, const char *, int);
2401 #define DEFAULT_TIME_FORMAT 0
2402 #define LOCAL_TIME_FORMAT 1
2403 extern int db_time_format
;
2404 char *quotify_string (const char *, const char *, int);
2405 char *quotify_buf (const unsigned char *, unsigned, const char *, int);
2406 char *print_base64 (const unsigned char *, unsigned, const char *, int);
2407 char *print_hw_addr (const int, const int, const unsigned char *);
2408 void print_lease (struct lease
*);
2409 void dump_raw (const unsigned char *, unsigned);
2410 void dump_packet_option (struct option_cache
*, struct packet
*,
2411 struct lease
*, struct client_state
*,
2412 struct option_state
*, struct option_state
*,
2413 struct binding_scope
**, struct universe
*, void *);
2414 void dump_packet (struct packet
*);
2415 void hash_dump (struct hash_table
*);
2416 char *print_hex (unsigned, const u_int8_t
*, unsigned, unsigned);
2417 void print_hex_only (unsigned, const u_int8_t
*, unsigned, char *);
2418 void print_hex_or_string (unsigned, const u_int8_t
*, unsigned, char *);
2419 #define print_hex_1(len, data, limit) print_hex(len, data, limit, 0)
2420 #define print_hex_2(len, data, limit) print_hex(len, data, limit, 1)
2421 #define print_hex_3(len, data, limit) print_hex(len, data, limit, 2)
2422 char *print_dotted_quads (unsigned, const u_int8_t
*);
2423 char *print_dec_1 (unsigned long);
2424 char *print_dec_2 (unsigned long);
2425 void print_expression (const char *, struct expression
*);
2426 int token_print_indent_concat (FILE *, int, int,
2427 const char *, const char *, ...);
2428 int token_indent_data_string (FILE *, int, int, const char *, const char *,
2429 struct data_string
*);
2430 int token_print_indent (FILE *, int, int,
2431 const char *, const char *, const char *);
2432 void indent_spaces (FILE *, int);
2433 #if defined (NSUPDATE)
2434 void print_dns_status (int, struct dhcp_ddns_cb
*, isc_result_t
);
2436 const char *print_time(TIME
);
2438 void get_hw_addr(const char *name
, struct hardware
*hw
);
2441 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
2442 || defined (USE_SOCKET_FALLBACK)
2443 int if_register_socket(struct interface_info
*, int, int *, struct in6_addr
*);
2446 #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND)
2447 void if_reinitialize_fallback (struct interface_info
*);
2448 void if_register_fallback (struct interface_info
*);
2449 ssize_t
send_fallback (struct interface_info
*,
2450 struct packet
*, struct dhcp_packet
*, size_t,
2452 struct sockaddr_in
*, struct hardware
*);
2453 ssize_t
send_fallback6(struct interface_info
*, struct packet
*,
2454 struct dhcp_packet
*, size_t, struct in6_addr
*,
2455 struct sockaddr_in6
*, struct hardware
*);
2458 #ifdef USE_SOCKET_SEND
2459 void if_reinitialize_send (struct interface_info
*);
2460 void if_register_send (struct interface_info
*);
2461 void if_deregister_send (struct interface_info
*);
2462 ssize_t
send_packet (struct interface_info
*,
2463 struct packet
*, struct dhcp_packet
*, size_t,
2465 struct sockaddr_in
*, struct hardware
*);
2467 ssize_t
send_packet6(struct interface_info
*, const unsigned char *, size_t,
2468 struct sockaddr_in6
*);
2469 #ifdef USE_SOCKET_RECEIVE
2470 void if_reinitialize_receive (struct interface_info
*);
2471 void if_register_receive (struct interface_info
*);
2472 void if_deregister_receive (struct interface_info
*);
2473 ssize_t
receive_packet (struct interface_info
*,
2474 unsigned char *, size_t,
2475 struct sockaddr_in
*, struct hardware
*);
2478 #if defined (USE_SOCKET_FALLBACK)
2479 isc_result_t
fallback_discard (omapi_object_t
*);
2482 #if defined (USE_SOCKET_SEND)
2483 int can_unicast_without_arp (struct interface_info
*);
2484 int can_receive_unicast_unconfigured (struct interface_info
*);
2485 int supports_multiple_interfaces (struct interface_info
*);
2486 void maybe_setup_fallback (void);
2489 void if_register6(struct interface_info
*info
, int do_multicast
);
2490 void if_register_linklocal6(struct interface_info
*info
);
2491 ssize_t
receive_packet6(struct interface_info
*interface
,
2492 unsigned char *buf
, size_t len
,
2493 struct sockaddr_in6
*from
, struct in6_addr
*to_addr
,
2494 unsigned int *if_index
);
2495 void if_deregister6(struct interface_info
*info
);
2499 #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
2500 int if_register_bpf (struct interface_info
*);
2503 void if_reinitialize_send (struct interface_info
*);
2504 void if_register_send (struct interface_info
*);
2505 void if_deregister_send (struct interface_info
*);
2506 ssize_t
send_packet (struct interface_info
*,
2507 struct packet
*, struct dhcp_packet
*, size_t,
2509 struct sockaddr_in
*, struct hardware
*);
2511 #ifdef USE_BPF_RECEIVE
2512 void if_reinitialize_receive (struct interface_info
*);
2513 void if_register_receive (struct interface_info
*);
2514 void if_deregister_receive (struct interface_info
*);
2515 ssize_t
receive_packet (struct interface_info
*,
2516 unsigned char *, size_t,
2517 struct sockaddr_in
*, struct hardware
*);
2519 #if defined (USE_BPF_SEND)
2520 int can_unicast_without_arp (struct interface_info
*);
2521 int can_receive_unicast_unconfigured (struct interface_info
*);
2522 int supports_multiple_interfaces (struct interface_info
*);
2523 void maybe_setup_fallback (void);
2527 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
2528 int if_register_lpf (struct interface_info
*);
2531 void if_reinitialize_send (struct interface_info
*);
2532 void if_register_send (struct interface_info
*);
2533 void if_deregister_send (struct interface_info
*);
2534 ssize_t
send_packet (struct interface_info
*,
2535 struct packet
*, struct dhcp_packet
*, size_t,
2537 struct sockaddr_in
*, struct hardware
*);
2539 #ifdef USE_LPF_RECEIVE
2540 void if_reinitialize_receive (struct interface_info
*);
2541 void if_register_receive (struct interface_info
*);
2542 void if_deregister_receive (struct interface_info
*);
2543 ssize_t
receive_packet (struct interface_info
*,
2544 unsigned char *, size_t,
2545 struct sockaddr_in
*, struct hardware
*);
2547 #if defined (USE_LPF_SEND)
2548 int can_unicast_without_arp (struct interface_info
*);
2549 int can_receive_unicast_unconfigured (struct interface_info
*);
2550 int supports_multiple_interfaces (struct interface_info
*);
2551 void maybe_setup_fallback (void);
2555 #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
2556 int if_register_nit (struct interface_info
*);
2560 void if_reinitialize_send (struct interface_info
*);
2561 void if_register_send (struct interface_info
*);
2562 void if_deregister_send (struct interface_info
*);
2563 ssize_t
send_packet (struct interface_info
*,
2564 struct packet
*, struct dhcp_packet
*, size_t,
2566 struct sockaddr_in
*, struct hardware
*);
2568 #ifdef USE_NIT_RECEIVE
2569 void if_reinitialize_receive (struct interface_info
*);
2570 void if_register_receive (struct interface_info
*);
2571 void if_deregister_receive (struct interface_info
*);
2572 ssize_t
receive_packet (struct interface_info
*,
2573 unsigned char *, size_t,
2574 struct sockaddr_in
*, struct hardware
*);
2576 #if defined (USE_NIT_SEND)
2577 int can_unicast_without_arp (struct interface_info
*);
2578 int can_receive_unicast_unconfigured (struct interface_info
*);
2579 int supports_multiple_interfaces (struct interface_info
*);
2580 void maybe_setup_fallback (void);
2584 #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
2585 int if_register_dlpi (struct interface_info
*);
2588 #ifdef USE_DLPI_SEND
2589 int can_unicast_without_arp (struct interface_info
*);
2590 int can_receive_unicast_unconfigured (struct interface_info
*);
2591 void if_reinitialize_send (struct interface_info
*);
2592 void if_register_send (struct interface_info
*);
2593 void if_deregister_send (struct interface_info
*);
2594 ssize_t
send_packet (struct interface_info
*,
2595 struct packet
*, struct dhcp_packet
*, size_t,
2597 struct sockaddr_in
*, struct hardware
*);
2598 int supports_multiple_interfaces (struct interface_info
*);
2599 void maybe_setup_fallback (void);
2601 #ifdef USE_DLPI_RECEIVE
2602 void if_reinitialize_receive (struct interface_info
*);
2603 void if_register_receive (struct interface_info
*);
2604 void if_deregister_receive (struct interface_info
*);
2605 ssize_t
receive_packet (struct interface_info
*,
2606 unsigned char *, size_t,
2607 struct sockaddr_in
*, struct hardware
*);
2613 void if_reinitialize_send (struct interface_info
*);
2614 void if_register_send (struct interface_info
*);
2615 void if_deregister_send (struct interface_info
*);
2616 ssize_t
send_packet (struct interface_info
*, struct packet
*,
2617 struct dhcp_packet
*, size_t, struct in_addr
,
2618 struct sockaddr_in
*, struct hardware
*);
2619 int can_unicast_without_arp (struct interface_info
*);
2620 int can_receive_unicast_unconfigured (struct interface_info
*);
2621 int supports_multiple_interfaces (struct interface_info
*);
2622 void maybe_setup_fallback (void);
2626 extern struct interface_info
*interfaces
,
2627 *dummy_interfaces
, *fallback_interface
;
2628 extern struct protocol
*protocols
;
2629 extern int quiet_interface_discovery
;
2630 isc_result_t
interface_setup (void);
2631 void interface_trace_setup (void);
2633 extern struct in_addr limited_broadcast
;
2634 extern int local_family
;
2635 extern struct in_addr local_address
;
2637 extern u_int16_t local_port
;
2638 extern u_int16_t remote_port
;
2639 extern int (*dhcp_interface_setup_hook
) (struct interface_info
*,
2641 extern int (*dhcp_interface_discovery_hook
) (struct interface_info
*);
2642 extern isc_result_t (*dhcp_interface_startup_hook
) (struct interface_info
*);
2644 extern void (*bootp_packet_handler
) (struct interface_info
*,
2645 struct dhcp_packet
*, unsigned,
2647 struct iaddr
, struct hardware
*);
2648 extern void (*dhcpv6_packet_handler
)(struct interface_info
*,
2650 int, const struct iaddr
*, isc_boolean_t
);
2651 extern struct timeout
*timeouts
;
2652 extern omapi_object_type_t
*dhcp_type_interface
;
2653 #if defined (TRACING)
2654 extern trace_type_t
*interface_trace
;
2655 extern trace_type_t
*inpacket_trace
;
2656 extern trace_type_t
*outpacket_trace
;
2658 extern struct interface_info
**interface_vector
;
2659 extern int interface_count
;
2660 extern int interface_max
;
2661 isc_result_t
interface_initialize(omapi_object_t
*, const char *, int);
2662 void discover_interfaces(int);
2663 int setup_fallback (struct interface_info
**, const char *, int);
2664 int if_readsocket (omapi_object_t
*);
2665 void reinitialize_interfaces (void);
2668 void set_time(TIME
);
2669 struct timeval
*process_outstanding_timeouts (struct timeval
*);
2670 void dispatch (void);
2671 isc_result_t
got_one(omapi_object_t
*);
2672 isc_result_t
got_one_v6(omapi_object_t
*);
2673 isc_result_t
interface_set_value (omapi_object_t
*, omapi_object_t
*,
2674 omapi_data_string_t
*, omapi_typed_data_t
*);
2675 isc_result_t
interface_get_value (omapi_object_t
*, omapi_object_t
*,
2676 omapi_data_string_t
*, omapi_value_t
**);
2677 isc_result_t
interface_destroy (omapi_object_t
*, const char *, int);
2678 isc_result_t
interface_signal_handler (omapi_object_t
*,
2679 const char *, va_list);
2680 isc_result_t
interface_stuff_values (omapi_object_t
*,
2684 void add_timeout (struct timeval
*, void (*) (void *), void *,
2685 tvref_t
, tvunref_t
);
2686 void cancel_timeout (void (*) (void *), void *);
2687 void cancel_all_timeouts (void);
2688 void relinquish_timeouts (void);
2690 OMAPI_OBJECT_ALLOC_DECL (interface
,
2691 struct interface_info
, dhcp_type_interface
)
2694 extern char *default_option_format
;
2695 extern struct universe dhcp_universe
;
2696 extern struct universe dhcpv6_universe
;
2697 extern struct universe nwip_universe
;
2698 extern struct universe fqdn_universe
;
2699 extern struct universe vsio_universe
;
2700 extern int dhcp_option_default_priority_list
[];
2701 extern int dhcp_option_default_priority_list_count
;
2702 extern const char *hardware_types
[256];
2703 extern int universe_count
, universe_max
;
2704 extern struct universe
**universes
;
2705 extern universe_hash_t
*universe_hash
;
2706 void initialize_common_option_spaces (void);
2707 extern struct universe
*config_universe
;
2710 #if defined (FAILOVER_PROTOCOL)
2711 extern failover_option_t null_failover_option
;
2712 extern failover_option_t skip_failover_option
;
2713 extern struct failover_option_info ft_options
[];
2714 extern u_int32_t fto_allowed
[];
2715 extern int ft_sizes
[];
2716 extern const char *dhcp_flink_state_names
[];
2718 extern const char *binding_state_names
[];
2720 extern struct universe agent_universe
;
2721 extern struct universe server_universe
;
2723 extern struct enumeration ddns_styles
;
2724 extern struct enumeration syslog_enum
;
2725 void initialize_server_option_spaces (void);
2728 struct iaddr
subnet_number (struct iaddr
, struct iaddr
);
2729 struct iaddr
ip_addr (struct iaddr
, struct iaddr
, u_int32_t
);
2730 struct iaddr
broadcast_addr (struct iaddr
, struct iaddr
);
2731 u_int32_t
host_addr (struct iaddr
, struct iaddr
);
2732 int addr_eq (struct iaddr
, struct iaddr
);
2733 int addr_match(struct iaddr
*, struct iaddrmatch
*);
2734 int addr_cmp(const struct iaddr
*a1
, const struct iaddr
*a2
);
2735 int addr_or(struct iaddr
*result
,
2736 const struct iaddr
*a1
, const struct iaddr
*a2
);
2737 int addr_and(struct iaddr
*result
,
2738 const struct iaddr
*a1
, const struct iaddr
*a2
);
2739 isc_boolean_t
is_cidr_mask_valid(const struct iaddr
*addr
, int bits
);
2740 isc_result_t
range2cidr(struct iaddrcidrnetlist
**result
,
2741 const struct iaddr
*lo
, const struct iaddr
*hi
);
2742 isc_result_t
free_iaddrcidrnetlist(struct iaddrcidrnetlist
**result
);
2743 const char *piaddr (struct iaddr
);
2744 char *piaddrmask(struct iaddr
*, struct iaddr
*);
2745 char *piaddrcidr(const struct iaddr
*, unsigned int);
2746 u_int16_t
validate_port(char *);
2751 extern int wanted_ia_na
;
2752 extern int wanted_ia_ta
;
2753 extern int wanted_ia_pd
;
2755 extern const char *path_dhclient_conf
;
2756 extern const char *path_dhclient_db
;
2757 extern const char *path_dhclient_pid
;
2758 extern char *path_dhclient_script
;
2759 extern int interfaces_requested
;
2760 extern struct data_string default_duid
;
2761 extern int duid_type
;
2762 extern const char *path_dhclient_duid
;
2764 extern struct client_config top_level_config
;
2766 void dhcpoffer (struct packet
*);
2767 void dhcpack (struct packet
*);
2768 void dhcpnak (struct packet
*);
2770 void send_discover (void *);
2771 void send_request (void *);
2772 void send_release (void *);
2773 void send_decline (void *);
2775 void state_reboot (void *);
2776 void state_init (void *);
2777 void state_selecting (void *);
2778 void state_requesting (void *);
2779 void state_bound (void *);
2780 void state_stop (void *);
2781 void state_panic (void *);
2783 void bind_lease (struct client_state
*);
2785 void make_client_options (struct client_state
*,
2786 struct client_lease
*, u_int8_t
*,
2787 struct option_cache
*, struct iaddr
*,
2788 struct option
**, struct option_state
**);
2789 void make_discover (struct client_state
*, struct client_lease
*);
2790 void make_request (struct client_state
*, struct client_lease
*);
2791 void make_decline (struct client_state
*, struct client_lease
*);
2792 void make_release (struct client_state
*, struct client_lease
*);
2794 void destroy_client_lease (struct client_lease
*);
2795 void rewrite_client_leases (void);
2796 void write_lease_option (struct option_cache
*, struct packet
*,
2797 struct lease
*, struct client_state
*,
2798 struct option_state
*, struct option_state
*,
2799 struct binding_scope
**, struct universe
*, void *);
2800 int write_client_lease (struct client_state
*, struct client_lease
*, int, int);
2801 isc_result_t
write_client6_lease(struct client_state
*client
,
2802 struct dhc6_lease
*lease
,
2803 int rewrite
, int sync
);
2804 int dhcp_option_ev_name (char *, size_t, struct option
*);
2806 void script_init (struct client_state
*, const char *,
2807 struct string_list
*);
2808 void client_option_envadd (struct option_cache
*, struct packet
*,
2809 struct lease
*, struct client_state
*,
2810 struct option_state
*, struct option_state
*,
2811 struct binding_scope
**, struct universe
*, void *);
2812 void script_write_params (struct client_state
*, const char *,
2813 struct client_lease
*);
2814 void script_write_requested (struct client_state
*);
2815 int script_go (struct client_state
*);
2816 void client_envadd (struct client_state
*,
2817 const char *, const char *, const char *, ...)
2818 __attribute__((__format__(__printf__
,4,5)));
2820 struct client_lease
*packet_to_lease (struct packet
*, struct client_state
*);
2821 void go_daemon (void);
2822 void write_client_pid_file (void);
2823 void client_location_changed (void);
2824 void do_release (struct client_state
*);
2825 int dhclient_interface_shutdown_hook (struct interface_info
*);
2826 int dhclient_interface_discovery_hook (struct interface_info
*);
2827 isc_result_t
dhclient_interface_startup_hook (struct interface_info
*);
2828 void dhclient_schedule_updates(struct client_state
*client
,
2829 struct iaddr
*addr
, int offset
);
2830 void client_dns_update_timeout (void *cp
);
2831 isc_result_t
client_dns_update(struct client_state
*client
,
2832 dhcp_ddns_cb_t
*ddns_cb
);
2833 void client_dns_remove(struct client_state
*client
, struct iaddr
*addr
);
2835 void dhcpv4_client_assignments(void);
2836 void dhcpv6_client_assignments(void);
2837 void form_duid(struct data_string
*duid
, const char *file
, int line
);
2840 void dhc6_lease_destroy(struct dhc6_lease
**src
, const char *file
, int line
);
2841 void start_init6(struct client_state
*client
);
2842 void start_info_request6(struct client_state
*client
);
2843 void start_confirm6(struct client_state
*client
);
2844 void start_release6(struct client_state
*client
);
2845 void start_selecting6(struct client_state
*client
);
2846 void unconfigure6(struct client_state
*client
, const char *reason
);
2849 int write_lease (struct lease
*);
2850 int write_host (struct host_decl
*);
2851 int write_server_duid(void);
2852 #if defined (FAILOVER_PROTOCOL)
2853 int write_failover_state (dhcp_failover_state_t
*);
2855 int db_printable (const unsigned char *);
2856 int db_printable_len (const unsigned char *, unsigned);
2857 isc_result_t
write_named_billing_class(const void *, unsigned, void *);
2858 void write_billing_classes (void);
2859 int write_billing_class (struct class *);
2860 void commit_leases_timeout (void *);
2861 void commit_leases_readerdry(void *);
2862 int commit_leases (void);
2863 int commit_leases_timed (void);
2864 void db_startup (int);
2865 int new_lease_file (void);
2866 int group_writer (struct group_object
*);
2867 int write_ia(const struct ia_xx
*);
2870 u_int32_t
checksum (unsigned char *, unsigned, u_int32_t
);
2871 u_int32_t
wrapsum (u_int32_t
);
2872 void assemble_hw_header (struct interface_info
*, unsigned char *,
2873 unsigned *, struct hardware
*);
2874 void assemble_udp_ip_header (struct interface_info
*, unsigned char *,
2875 unsigned *, u_int32_t
, u_int32_t
,
2876 u_int32_t
, unsigned char *, unsigned);
2877 ssize_t
decode_hw_header (struct interface_info
*, unsigned char *,
2878 unsigned, struct hardware
*);
2879 ssize_t
decode_udp_ip_header (struct interface_info
*, unsigned char *,
2880 unsigned, struct sockaddr_in
*,
2881 unsigned, unsigned *);
2884 void assemble_ethernet_header (struct interface_info
*, unsigned char *,
2885 unsigned *, struct hardware
*);
2886 ssize_t
decode_ethernet_header (struct interface_info
*,
2888 unsigned, struct hardware
*);
2891 void assemble_tr_header (struct interface_info
*, unsigned char *,
2892 unsigned *, struct hardware
*);
2893 ssize_t
decode_tr_header (struct interface_info
*,
2895 unsigned, struct hardware
*);
2898 void convert_statement (struct parse
*);
2899 void convert_host_statement (struct parse
*, jrefproto
);
2900 void convert_host_name (struct parse
*, jrefproto
);
2901 void convert_class_statement (struct parse
*, jrefproto
, int);
2902 void convert_class_decl (struct parse
*, jrefproto
);
2903 void convert_lease_time (struct parse
*, jrefproto
, char *);
2904 void convert_shared_net_statement (struct parse
*, jrefproto
);
2905 void convert_subnet_statement (struct parse
*, jrefproto
);
2906 void convert_subnet_decl (struct parse
*, jrefproto
);
2907 void convert_host_decl (struct parse
*, jrefproto
);
2908 void convert_hardware_decl (struct parse
*, jrefproto
);
2909 void convert_hardware_addr (struct parse
*, jrefproto
);
2910 void convert_filename_decl (struct parse
*, jrefproto
);
2911 void convert_servername_decl (struct parse
*, jrefproto
);
2912 void convert_ip_addr_or_hostname (struct parse
*, jrefproto
, int);
2913 void convert_fixed_addr_decl (struct parse
*, jrefproto
);
2914 void convert_option_decl (struct parse
*, jrefproto
);
2915 void convert_lease_statement (struct parse
*, jrefproto
);
2916 void convert_address_range (struct parse
*, jrefproto
);
2917 void convert_date (struct parse
*, jrefproto
, char *);
2918 void convert_numeric_aggregate (struct parse
*, jrefproto
, int, int, int, int);
2922 void add_route_direct (struct interface_info
*, struct in_addr
);
2923 void add_route_net (struct interface_info
*, struct in_addr
, struct in_addr
);
2924 void add_route_default_gateway (struct interface_info
*, struct in_addr
);
2925 void remove_routes (struct in_addr
);
2926 void remove_if_route (struct interface_info
*, struct in_addr
);
2927 void remove_all_if_routes (struct interface_info
*);
2928 void set_netmask (struct interface_info
*, struct in_addr
);
2929 void set_broadcast_addr (struct interface_info
*, struct in_addr
);
2930 void set_ip_address (struct interface_info
*, struct in_addr
);
2933 isc_result_t
read_client_conf (void);
2934 int read_client_conf_file (const char *,
2935 struct interface_info
*, struct client_config
*);
2936 void read_client_leases (void);
2937 void read_client_duid (void);
2938 void parse_client_statement (struct parse
*, struct interface_info
*,
2939 struct client_config
*);
2940 int parse_X (struct parse
*, u_int8_t
*, unsigned);
2941 int parse_option_list (struct parse
*, struct option
***);
2942 void parse_interface_declaration (struct parse
*,
2943 struct client_config
*, char *);
2944 int interface_or_dummy (struct interface_info
**, const char *);
2945 void make_client_state (struct client_state
**);
2946 void make_client_config (struct client_state
*, struct client_config
*);
2947 void parse_client_lease_statement (struct parse
*, int);
2948 void parse_client_lease_declaration (struct parse
*,
2949 struct client_lease
*,
2950 struct interface_info
**,
2951 struct client_state
**);
2952 int parse_option_decl (struct option_cache
**, struct parse
*);
2953 void parse_string_list (struct parse
*, struct string_list
**, int);
2954 int parse_ip_addr (struct parse
*, struct iaddr
*);
2955 int parse_ip_addr_with_subnet(struct parse
*, struct iaddrmatch
*);
2956 void parse_reject_statement (struct parse
*, struct client_config
*);
2959 OMAPI_OBJECT_ALLOC_DECL (icmp_state
, struct icmp_state
, dhcp_type_icmp
)
2960 extern struct icmp_state
*icmp_state
;
2961 void icmp_startup (int, void (*) (struct iaddr
, u_int8_t
*, int));
2962 int icmp_readsocket (omapi_object_t
*);
2963 int icmp_echorequest (struct iaddr
*);
2964 isc_result_t
icmp_echoreply (omapi_object_t
*);
2967 isc_result_t
enter_dns_zone (struct dns_zone
*);
2968 isc_result_t
dns_zone_lookup (struct dns_zone
**, const char *);
2969 int dns_zone_dereference (struct dns_zone
**, const char *, int);
2970 #if defined (NSUPDATE)
2971 #define FIND_FORWARD 0
2972 #define FIND_REVERSE 1
2973 isc_result_t
find_tsig_key (ns_tsig_key
**, const char *, struct dns_zone
*);
2974 void tkey_free (ns_tsig_key
**);
2975 isc_result_t
find_cached_zone (dhcp_ddns_cb_t
*, int);
2976 void forget_zone (struct dns_zone
**);
2977 void repudiate_zone (struct dns_zone
**);
2978 int get_dhcid (dhcp_ddns_cb_t
*, int, const u_int8_t
*, unsigned);
2979 void dhcid_tolease (struct data_string
*, struct data_string
*);
2980 isc_result_t
dhcid_fromlease (struct data_string
*, struct data_string
*);
2981 isc_result_t
ddns_update_fwd(struct data_string
*, struct iaddr
,
2982 struct data_string
*, unsigned long, unsigned,
2984 isc_result_t
ddns_remove_fwd(struct data_string
*,
2985 struct iaddr
, struct data_string
*);
2986 #endif /* NSUPDATE */
2988 dhcp_ddns_cb_t
*ddns_cb_alloc(const char *file
, int line
);
2989 void ddns_cb_free (dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2990 void ddns_cb_forget_zone (dhcp_ddns_cb_t
*ddns_cb
);
2992 ddns_modify_fwd(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2994 ddns_modify_ptr(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2996 ddns_cancel(dhcp_ddns_cb_t
*ddns_cb
, const char *file
, int line
);
2999 extern char path_resolv_conf
[];
3000 extern struct name_server
*name_servers
;
3001 extern struct domain_search_list
*domains
;
3003 void read_resolv_conf (TIME
);
3004 struct name_server
*first_name_server (void);
3007 #ifdef NEED_INET_ATON
3008 int inet_aton (const char *, struct in_addr
*);
3012 extern int have_billing_classes
;
3013 struct class unknown_class
;
3014 struct class known_class
;
3015 struct collection default_collection
;
3016 struct collection
*collections
;
3017 extern struct executable_statement
*default_classification_rules
;
3019 void classification_setup (void);
3020 void classify_client (struct packet
*);
3021 int check_collection (struct packet
*, struct lease
*, struct collection
*);
3022 void classify (struct packet
*, struct class *);
3023 isc_result_t
unlink_class (struct class **class);
3024 isc_result_t
find_class (struct class **, const char *,
3026 int unbill_class (struct lease
*, struct class *);
3027 int bill_class (struct lease
*, struct class *);
3030 int execute_statements (struct binding_value
**result
,
3031 struct packet
*, struct lease
*,
3032 struct client_state
*,
3033 struct option_state
*, struct option_state
*,
3034 struct binding_scope
**,
3035 struct executable_statement
*,
3037 void execute_statements_in_scope (struct binding_value
**result
,
3038 struct packet
*, struct lease
*,
3039 struct client_state
*,
3040 struct option_state
*,
3041 struct option_state
*,
3042 struct binding_scope
**,
3043 struct group
*, struct group
*,
3045 int executable_statement_dereference (struct executable_statement
**,
3047 void write_statements (FILE *, struct executable_statement
*, int);
3048 int find_matching_case (struct executable_statement
**,
3049 struct packet
*, struct lease
*, struct client_state
*,
3050 struct option_state
*, struct option_state
*,
3051 struct binding_scope
**,
3052 struct expression
*, struct executable_statement
*);
3053 int executable_statement_foreach (struct executable_statement
*,
3054 int (*) (struct executable_statement
*,
3055 void *, int), void *, int);
3058 extern omapi_object_type_t
*dhcp_type_group
;
3059 extern omapi_object_type_t
*dhcp_type_shared_network
;
3060 extern omapi_object_type_t
*dhcp_type_subnet
;
3061 extern omapi_object_type_t
*dhcp_type_control
;
3062 extern dhcp_control_object_t
*dhcp_control_object
;
3064 void dhcp_common_objects_setup (void);
3066 isc_result_t
dhcp_group_set_value (omapi_object_t
*, omapi_object_t
*,
3067 omapi_data_string_t
*,
3068 omapi_typed_data_t
*);
3069 isc_result_t
dhcp_group_get_value (omapi_object_t
*, omapi_object_t
*,
3070 omapi_data_string_t
*,
3072 isc_result_t
dhcp_group_destroy (omapi_object_t
*, const char *, int);
3073 isc_result_t
dhcp_group_signal_handler (omapi_object_t
*,
3074 const char *, va_list);
3075 isc_result_t
dhcp_group_stuff_values (omapi_object_t
*,
3078 isc_result_t
dhcp_group_lookup (omapi_object_t
**,
3079 omapi_object_t
*, omapi_object_t
*);
3080 isc_result_t
dhcp_group_create (omapi_object_t
**,
3082 isc_result_t
dhcp_group_remove (omapi_object_t
*,
3085 isc_result_t
dhcp_control_set_value (omapi_object_t
*, omapi_object_t
*,
3086 omapi_data_string_t
*,
3087 omapi_typed_data_t
*);
3088 isc_result_t
dhcp_control_get_value (omapi_object_t
*, omapi_object_t
*,
3089 omapi_data_string_t
*,
3091 isc_result_t
dhcp_control_destroy (omapi_object_t
*, const char *, int);
3092 isc_result_t
dhcp_control_signal_handler (omapi_object_t
*,
3093 const char *, va_list);
3094 isc_result_t
dhcp_control_stuff_values (omapi_object_t
*,
3097 isc_result_t
dhcp_control_lookup (omapi_object_t
**,
3098 omapi_object_t
*, omapi_object_t
*);
3099 isc_result_t
dhcp_control_create (omapi_object_t
**,
3101 isc_result_t
dhcp_control_remove (omapi_object_t
*,
3104 isc_result_t
dhcp_subnet_set_value (omapi_object_t
*, omapi_object_t
*,
3105 omapi_data_string_t
*,
3106 omapi_typed_data_t
*);
3107 isc_result_t
dhcp_subnet_get_value (omapi_object_t
*, omapi_object_t
*,
3108 omapi_data_string_t
*,
3110 isc_result_t
dhcp_subnet_destroy (omapi_object_t
*, const char *, int);
3111 isc_result_t
dhcp_subnet_signal_handler (omapi_object_t
*,
3112 const char *, va_list);
3113 isc_result_t
dhcp_subnet_stuff_values (omapi_object_t
*,
3116 isc_result_t
dhcp_subnet_lookup (omapi_object_t
**,
3117 omapi_object_t
*, omapi_object_t
*);
3118 isc_result_t
dhcp_subnet_create (omapi_object_t
**,
3120 isc_result_t
dhcp_subnet_remove (omapi_object_t
*,
3123 isc_result_t
dhcp_shared_network_set_value (omapi_object_t
*,
3125 omapi_data_string_t
*,
3126 omapi_typed_data_t
*);
3127 isc_result_t
dhcp_shared_network_get_value (omapi_object_t
*,
3129 omapi_data_string_t
*,
3131 isc_result_t
dhcp_shared_network_destroy (omapi_object_t
*, const char *, int);
3132 isc_result_t
dhcp_shared_network_signal_handler (omapi_object_t
*,
3133 const char *, va_list);
3134 isc_result_t
dhcp_shared_network_stuff_values (omapi_object_t
*,
3137 isc_result_t
dhcp_shared_network_lookup (omapi_object_t
**,
3138 omapi_object_t
*, omapi_object_t
*);
3139 isc_result_t
dhcp_shared_network_create (omapi_object_t
**,
3141 isc_result_t
dhcp_shared_network_remove (omapi_object_t
*,
3145 extern int (*dhcp_interface_shutdown_hook
) (struct interface_info
*);
3147 extern omapi_object_type_t
*dhcp_type_lease
;
3148 extern omapi_object_type_t
*dhcp_type_pool
;
3149 extern omapi_object_type_t
*dhcp_type_class
;
3150 extern omapi_object_type_t
*dhcp_type_subclass
;
3152 #if defined (FAILOVER_PROTOCOL)
3153 extern omapi_object_type_t
*dhcp_type_failover_state
;
3154 extern omapi_object_type_t
*dhcp_type_failover_link
;
3155 extern omapi_object_type_t
*dhcp_type_failover_listener
;
3158 void dhcp_db_objects_setup (void);
3160 isc_result_t
dhcp_lease_set_value (omapi_object_t
*, omapi_object_t
*,
3161 omapi_data_string_t
*,
3162 omapi_typed_data_t
*);
3163 isc_result_t
dhcp_lease_get_value (omapi_object_t
*, omapi_object_t
*,
3164 omapi_data_string_t
*,
3166 isc_result_t
dhcp_lease_destroy (omapi_object_t
*, const char *, int);
3167 isc_result_t
dhcp_lease_signal_handler (omapi_object_t
*,
3168 const char *, va_list);
3169 isc_result_t
dhcp_lease_stuff_values (omapi_object_t
*,
3172 isc_result_t
dhcp_lease_lookup (omapi_object_t
**,
3173 omapi_object_t
*, omapi_object_t
*);
3174 isc_result_t
dhcp_lease_create (omapi_object_t
**,
3176 isc_result_t
dhcp_lease_remove (omapi_object_t
*,
3178 isc_result_t
dhcp_host_set_value (omapi_object_t
*, omapi_object_t
*,
3179 omapi_data_string_t
*,
3180 omapi_typed_data_t
*);
3181 isc_result_t
dhcp_host_get_value (omapi_object_t
*, omapi_object_t
*,
3182 omapi_data_string_t
*,
3184 isc_result_t
dhcp_host_destroy (omapi_object_t
*, const char *, int);
3185 isc_result_t
dhcp_host_signal_handler (omapi_object_t
*,
3186 const char *, va_list);
3187 isc_result_t
dhcp_host_stuff_values (omapi_object_t
*,
3190 isc_result_t
dhcp_host_lookup (omapi_object_t
**,
3191 omapi_object_t
*, omapi_object_t
*);
3192 isc_result_t
dhcp_host_create (omapi_object_t
**,
3194 isc_result_t
dhcp_host_remove (omapi_object_t
*,
3196 isc_result_t
dhcp_pool_set_value (omapi_object_t
*, omapi_object_t
*,
3197 omapi_data_string_t
*,
3198 omapi_typed_data_t
*);
3199 isc_result_t
dhcp_pool_get_value (omapi_object_t
*, omapi_object_t
*,
3200 omapi_data_string_t
*,
3202 isc_result_t
dhcp_pool_destroy (omapi_object_t
*, const char *, int);
3203 isc_result_t
dhcp_pool_signal_handler (omapi_object_t
*,
3204 const char *, va_list);
3205 isc_result_t
dhcp_pool_stuff_values (omapi_object_t
*,
3208 isc_result_t
dhcp_pool_lookup (omapi_object_t
**,
3209 omapi_object_t
*, omapi_object_t
*);
3210 isc_result_t
dhcp_pool_create (omapi_object_t
**,
3212 isc_result_t
dhcp_pool_remove (omapi_object_t
*,
3214 isc_result_t
dhcp_class_set_value (omapi_object_t
*, omapi_object_t
*,
3215 omapi_data_string_t
*,
3216 omapi_typed_data_t
*);
3217 isc_result_t
dhcp_class_get_value (omapi_object_t
*, omapi_object_t
*,
3218 omapi_data_string_t
*,
3220 isc_result_t
dhcp_class_destroy (omapi_object_t
*, const char *, int);
3221 isc_result_t
dhcp_class_signal_handler (omapi_object_t
*,
3222 const char *, va_list);
3223 isc_result_t
dhcp_class_stuff_values (omapi_object_t
*,
3226 isc_result_t
dhcp_class_lookup (omapi_object_t
**,
3227 omapi_object_t
*, omapi_object_t
*);
3228 isc_result_t
dhcp_class_create (omapi_object_t
**,
3230 isc_result_t
dhcp_class_remove (omapi_object_t
*,
3232 isc_result_t
dhcp_subclass_set_value (omapi_object_t
*, omapi_object_t
*,
3233 omapi_data_string_t
*,
3234 omapi_typed_data_t
*);
3235 isc_result_t
dhcp_subclass_get_value (omapi_object_t
*, omapi_object_t
*,
3236 omapi_data_string_t
*,
3238 isc_result_t
dhcp_subclass_destroy (omapi_object_t
*, const char *, int);
3239 isc_result_t
dhcp_subclass_signal_handler (omapi_object_t
*,
3240 const char *, va_list);
3241 isc_result_t
dhcp_subclass_stuff_values (omapi_object_t
*,
3244 isc_result_t
dhcp_subclass_lookup (omapi_object_t
**,
3245 omapi_object_t
*, omapi_object_t
*);
3246 isc_result_t
dhcp_subclass_create (omapi_object_t
**,
3248 isc_result_t
dhcp_subclass_remove (omapi_object_t
*,
3250 isc_result_t
dhcp_interface_set_value (omapi_object_t
*,
3252 omapi_data_string_t
*,
3253 omapi_typed_data_t
*);
3254 isc_result_t
dhcp_interface_get_value (omapi_object_t
*,
3256 omapi_data_string_t
*,
3258 isc_result_t
dhcp_interface_destroy (omapi_object_t
*,
3260 isc_result_t
dhcp_interface_signal_handler (omapi_object_t
*,
3263 isc_result_t
dhcp_interface_stuff_values (omapi_object_t
*,
3266 isc_result_t
dhcp_interface_lookup (omapi_object_t
**,
3269 isc_result_t
dhcp_interface_create (omapi_object_t
**,
3271 isc_result_t
dhcp_interface_remove (omapi_object_t
*,
3273 void interface_stash (struct interface_info
*);
3274 void interface_snorf (struct interface_info
*, int);
3276 isc_result_t
binding_scope_set_value (struct binding_scope
*, int,
3277 omapi_data_string_t
*,
3278 omapi_typed_data_t
*);
3279 isc_result_t
binding_scope_get_value (omapi_value_t
**,
3280 struct binding_scope
*,
3281 omapi_data_string_t
*);
3282 isc_result_t
binding_scope_stuff_values (omapi_object_t
*,
3283 struct binding_scope
*);
3285 void register_eventhandler(struct eventqueue
**, void (*handler
)(void *));
3286 void unregister_eventhandler(struct eventqueue
**, void (*handler
)(void *));
3287 void trigger_event(struct eventqueue
**);
3291 extern struct subnet
*subnets
;
3292 extern struct shared_network
*shared_networks
;
3293 extern host_hash_t
*host_hw_addr_hash
;
3294 extern host_hash_t
*host_uid_hash
;
3295 extern host_hash_t
*host_name_hash
;
3296 extern lease_id_hash_t
*lease_uid_hash
;
3297 extern lease_ip_hash_t
*lease_ip_addr_hash
;
3298 extern lease_id_hash_t
*lease_hw_addr_hash
;
3300 extern omapi_object_type_t
*dhcp_type_host
;
3302 extern int numclasseswritten
;
3305 isc_result_t
enter_class (struct class *, int, int);
3306 isc_result_t
delete_class (struct class *, int);
3307 isc_result_t
enter_host (struct host_decl
*, int, int);
3308 isc_result_t
delete_host (struct host_decl
*, int);
3309 void change_host_uid(struct host_decl
*host
, const char *data
, int len
);
3310 int find_hosts_by_haddr (struct host_decl
**, int,
3311 const unsigned char *, unsigned,
3313 int find_hosts_by_uid (struct host_decl
**, const unsigned char *,
3314 unsigned, const char *, int);
3315 int find_hosts_by_option(struct host_decl
**, struct packet
*,
3316 struct option_state
*, const char *, int);
3317 int find_host_for_network (struct subnet
**, struct host_decl
**,
3318 struct iaddr
*, struct shared_network
*);
3319 void new_address_range (struct parse
*, struct iaddr
, struct iaddr
,
3320 struct subnet
*, struct pool
*,
3322 isc_result_t
dhcp_lease_free (omapi_object_t
*, const char *, int);
3323 isc_result_t
dhcp_lease_get (omapi_object_t
**, const char *, int);
3324 int find_grouped_subnet (struct subnet
**, struct shared_network
*,
3325 struct iaddr
, const char *, int);
3326 int find_subnet(struct subnet
**, struct iaddr
, const char *, int);
3327 void enter_shared_network (struct shared_network
*);
3328 void new_shared_network_interface (struct parse
*,
3329 struct shared_network
*,
3331 int subnet_inner_than(const struct subnet
*, const struct subnet
*, int);
3332 void enter_subnet (struct subnet
*);
3333 void enter_lease (struct lease
*);
3334 int supersede_lease (struct lease
*, struct lease
*, int, int, int);
3335 void make_binding_state_transition (struct lease
*);
3336 int lease_copy (struct lease
**, struct lease
*, const char *, int);
3337 void release_lease (struct lease
*, struct packet
*);
3338 void abandon_lease (struct lease
*, const char *);
3340 /* this appears to be unused and I plan to remove it SAR */
3341 void dissociate_lease (struct lease
*);
3343 void pool_timer (void *);
3344 int find_lease_by_uid (struct lease
**, const unsigned char *,
3345 unsigned, const char *, int);
3346 int find_lease_by_hw_addr (struct lease
**, const unsigned char *,
3347 unsigned, const char *, int);
3348 int find_lease_by_ip_addr (struct lease
**, struct iaddr
,
3350 void uid_hash_add (struct lease
*);
3351 void uid_hash_delete (struct lease
*);
3352 void hw_hash_add (struct lease
*);
3353 void hw_hash_delete (struct lease
*);
3354 int write_leases (void);
3355 int write_leases6(void);
3356 int lease_enqueue (struct lease
*);
3357 isc_result_t
lease_instantiate(const void *, unsigned, void *);
3358 void expire_all_pools (void);
3359 void dump_subnets (void);
3360 #if defined (DEBUG_MEMORY_LEAKAGE) || \
3361 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
3362 void free_everything (void);
3366 #if defined (FAILOVER_PROTOCOL)
3367 extern dhcp_failover_state_t
*failover_states
;
3368 void dhcp_failover_startup (void);
3369 int dhcp_failover_write_all_states (void);
3370 isc_result_t
enter_failover_peer (dhcp_failover_state_t
*);
3371 isc_result_t
find_failover_peer (dhcp_failover_state_t
**,
3372 const char *, const char *, int);
3373 isc_result_t
dhcp_failover_link_initiate (omapi_object_t
*);
3374 isc_result_t
dhcp_failover_link_signal (omapi_object_t
*,
3375 const char *, va_list);
3376 isc_result_t
dhcp_failover_link_set_value (omapi_object_t
*,
3378 omapi_data_string_t
*,
3379 omapi_typed_data_t
*);
3380 isc_result_t
dhcp_failover_link_get_value (omapi_object_t
*,
3382 omapi_data_string_t
*,
3384 isc_result_t
dhcp_failover_link_destroy (omapi_object_t
*,
3386 isc_result_t
dhcp_failover_link_stuff_values (omapi_object_t
*,
3389 isc_result_t
dhcp_failover_listen (omapi_object_t
*);
3391 isc_result_t
dhcp_failover_listener_signal (omapi_object_t
*,
3394 isc_result_t
dhcp_failover_listener_set_value (omapi_object_t
*,
3396 omapi_data_string_t
*,
3397 omapi_typed_data_t
*);
3398 isc_result_t
dhcp_failover_listener_get_value (omapi_object_t
*,
3400 omapi_data_string_t
*,
3402 isc_result_t
dhcp_failover_listener_destroy (omapi_object_t
*,
3404 isc_result_t
dhcp_failover_listener_stuff (omapi_object_t
*,
3407 isc_result_t
dhcp_failover_register (omapi_object_t
*);
3408 isc_result_t
dhcp_failover_state_signal (omapi_object_t
*,
3409 const char *, va_list);
3410 isc_result_t
dhcp_failover_state_transition (dhcp_failover_state_t
*,
3412 isc_result_t
dhcp_failover_set_service_state (dhcp_failover_state_t
*state
);
3413 isc_result_t
dhcp_failover_set_state (dhcp_failover_state_t
*,
3414 enum failover_state
);
3415 isc_result_t
dhcp_failover_peer_state_changed (dhcp_failover_state_t
*,
3416 failover_message_t
*);
3417 void dhcp_failover_pool_rebalance (void *);
3418 void dhcp_failover_pool_check (struct pool
*);
3419 int dhcp_failover_state_pool_check (dhcp_failover_state_t
*);
3420 void dhcp_failover_timeout (void *);
3421 void dhcp_failover_send_contact (void *);
3422 isc_result_t
dhcp_failover_send_state (dhcp_failover_state_t
*);
3423 isc_result_t
dhcp_failover_send_updates (dhcp_failover_state_t
*);
3424 int dhcp_failover_queue_update (struct lease
*, int);
3425 int dhcp_failover_send_acks (dhcp_failover_state_t
*);
3426 void dhcp_failover_toack_queue_timeout (void *);
3427 int dhcp_failover_queue_ack (dhcp_failover_state_t
*, failover_message_t
*msg
);
3428 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t
*, struct lease
*);
3429 isc_result_t
dhcp_failover_state_set_value (omapi_object_t
*,
3431 omapi_data_string_t
*,
3432 omapi_typed_data_t
*);
3433 void dhcp_failover_keepalive (void *);
3434 void dhcp_failover_reconnect (void *);
3435 void dhcp_failover_startup_timeout (void *);
3436 void dhcp_failover_link_startup_timeout (void *);
3437 void dhcp_failover_listener_restart (void *);
3438 void dhcp_failover_auto_partner_down(void *vs
);
3439 isc_result_t
dhcp_failover_state_get_value (omapi_object_t
*,
3441 omapi_data_string_t
*,
3443 isc_result_t
dhcp_failover_state_destroy (omapi_object_t
*,
3445 isc_result_t
dhcp_failover_state_stuff (omapi_object_t
*,
3448 isc_result_t
dhcp_failover_state_lookup (omapi_object_t
**,
3451 isc_result_t
dhcp_failover_state_create (omapi_object_t
**,
3453 isc_result_t
dhcp_failover_state_remove (omapi_object_t
*,
3455 int dhcp_failover_state_match (dhcp_failover_state_t
*, u_int8_t
*, unsigned);
3456 int dhcp_failover_state_match_by_name(dhcp_failover_state_t
*,
3457 failover_option_t
*);
3458 const char *dhcp_failover_reject_reason_print (int);
3459 const char *dhcp_failover_state_name_print (enum failover_state
);
3460 const char *dhcp_failover_message_name (unsigned);
3461 const char *dhcp_failover_option_name (unsigned);
3462 failover_option_t
*dhcp_failover_option_printf (unsigned, char *,
3466 __attribute__((__format__(__printf__
,5,6)));
3467 failover_option_t
*dhcp_failover_make_option (unsigned, char *,
3468 unsigned *, unsigned, ...);
3469 isc_result_t
dhcp_failover_put_message (dhcp_failover_link_t
*,
3470 omapi_object_t
*, int, u_int32_t
, ...);
3471 isc_result_t
dhcp_failover_send_connect (omapi_object_t
*);
3472 isc_result_t
dhcp_failover_send_connectack (omapi_object_t
*,
3473 dhcp_failover_state_t
*,
3475 isc_result_t
dhcp_failover_send_disconnect (omapi_object_t
*,
3477 isc_result_t
dhcp_failover_send_bind_update (dhcp_failover_state_t
*,
3479 isc_result_t
dhcp_failover_send_bind_ack (dhcp_failover_state_t
*,
3480 failover_message_t
*,
3482 isc_result_t
dhcp_failover_send_poolreq (dhcp_failover_state_t
*);
3483 isc_result_t
dhcp_failover_send_poolresp (dhcp_failover_state_t
*, int);
3484 isc_result_t
dhcp_failover_send_update_request (dhcp_failover_state_t
*);
3485 isc_result_t
dhcp_failover_send_update_request_all (dhcp_failover_state_t
*);
3486 isc_result_t
dhcp_failover_send_update_done (dhcp_failover_state_t
*);
3487 isc_result_t
dhcp_failover_process_bind_update (dhcp_failover_state_t
*,
3488 failover_message_t
*);
3489 isc_result_t
dhcp_failover_process_bind_ack (dhcp_failover_state_t
*,
3490 failover_message_t
*);
3491 isc_result_t
dhcp_failover_generate_update_queue (dhcp_failover_state_t
*,
3493 isc_result_t
dhcp_failover_process_update_request (dhcp_failover_state_t
*,
3494 failover_message_t
*);
3495 isc_result_t
dhcp_failover_process_update_request_all (dhcp_failover_state_t
*,
3496 failover_message_t
*);
3497 isc_result_t
dhcp_failover_process_update_done (dhcp_failover_state_t
*,
3498 failover_message_t
*);
3499 void ia_remove_all_lease(struct ia_xx
*ia
, const char *file
, int line
);
3500 void dhcp_failover_recover_done (void *);
3501 void failover_print (char *, unsigned *, unsigned, const char *);
3502 void update_partner (struct lease
*);
3503 int load_balance_mine (struct packet
*, dhcp_failover_state_t
*);
3504 int peer_wants_lease (struct lease
*);
3505 binding_state_t
normal_binding_state_transition_check (struct lease
*,
3506 dhcp_failover_state_t
*,
3510 conflict_binding_state_transition_check (struct lease
*,
3511 dhcp_failover_state_t
*,
3512 binding_state_t
, u_int32_t
);
3513 int lease_mine_to_reallocate (struct lease
*);
3515 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state
, dhcp_failover_state_t
,
3516 dhcp_type_failover_state
)
3517 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener
, dhcp_failover_listener_t
,
3518 dhcp_type_failover_listener
)
3519 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link
, dhcp_failover_link_t
,
3520 dhcp_type_failover_link
)
3521 #endif /* FAILOVER_PROTOCOL */
3523 const char *binding_state_print (enum failover_state
);
3526 #if defined(LDAP_CONFIGURATION)
3527 extern struct enumeration ldap_methods
;
3528 #if defined (LDAP_USE_SSL)
3529 extern struct enumeration ldap_ssl_usage_enum
;
3530 extern struct enumeration ldap_tls_reqcert_enum
;
3531 extern struct enumeration ldap_tls_crlcheck_enum
;
3533 isc_result_t
ldap_read_config (void);
3534 int find_haddr_in_ldap (struct host_decl
**, int, unsigned,
3535 const unsigned char *, const char *, int);
3536 int find_subclass_in_ldap (struct class *, struct class **,
3537 struct data_string
*);
3541 HASH_FUNCTIONS_DECL(ia
, unsigned char *, struct ia_xx
, ia_hash_t
)
3542 HASH_FUNCTIONS_DECL(iasubopt
, struct in6_addr
*, struct iasubopt
,
3545 isc_result_t
iasubopt_allocate(struct iasubopt
**iasubopt
,
3546 const char *file
, int line
);
3547 isc_result_t
iasubopt_reference(struct iasubopt
**iasubopt
,
3548 struct iasubopt
*src
,
3549 const char *file
, int line
);
3550 isc_result_t
iasubopt_dereference(struct iasubopt
**iasubopt
,
3551 const char *file
, int line
);
3553 isc_result_t
ia_make_key(struct data_string
*key
, u_int32_t iaid
,
3554 const char *duid
, unsigned int duid_len
,
3555 const char *file
, int line
);
3556 isc_result_t
ia_allocate(struct ia_xx
**ia
, u_int32_t iaid
,
3557 const char *duid
, unsigned int duid_len
,
3558 const char *file
, int line
);
3559 isc_result_t
ia_reference(struct ia_xx
**ia
, struct ia_xx
*src
,
3560 const char *file
, int line
);
3561 isc_result_t
ia_dereference(struct ia_xx
**ia
,
3562 const char *file
, int line
);
3563 isc_result_t
ia_add_iasubopt(struct ia_xx
*ia
, struct iasubopt
*iasubopt
,
3564 const char *file
, int line
);
3565 void ia_remove_iasubopt(struct ia_xx
*ia
, struct iasubopt
*iasubopt
,
3566 const char *file
, int line
);
3567 isc_boolean_t
ia_equal(const struct ia_xx
*a
, const struct ia_xx
*b
);
3569 isc_result_t
ipv6_pool_allocate(struct ipv6_pool
**pool
, u_int16_t type
,
3570 const struct in6_addr
*start_addr
,
3571 int bits
, int units
,
3572 const char *file
, int line
);
3573 isc_result_t
ipv6_pool_reference(struct ipv6_pool
**pool
,
3574 struct ipv6_pool
*src
,
3575 const char *file
, int line
);
3576 isc_result_t
ipv6_pool_dereference(struct ipv6_pool
**pool
,
3577 const char *file
, int line
);
3578 isc_result_t
create_lease6(struct ipv6_pool
*pool
,
3579 struct iasubopt
**addr
,
3580 unsigned int *attempts
,
3581 const struct data_string
*uid
,
3582 time_t soft_lifetime_end_time
);
3583 isc_result_t
add_lease6(struct ipv6_pool
*pool
,
3584 struct iasubopt
*lease
,
3585 time_t valid_lifetime_end_time
);
3586 isc_result_t
renew_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3587 isc_result_t
expire_lease6(struct iasubopt
**leasep
,
3588 struct ipv6_pool
*pool
, time_t now
);
3589 isc_result_t
release_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3590 isc_result_t
decline_lease6(struct ipv6_pool
*pool
, struct iasubopt
*lease
);
3591 isc_boolean_t
lease6_exists(const struct ipv6_pool
*pool
,
3592 const struct in6_addr
*addr
);
3593 isc_boolean_t
lease6_usable(struct iasubopt
*lease
);
3594 isc_result_t
cleanup_lease6(ia_hash_t
*ia_table
,
3595 struct ipv6_pool
*pool
,
3596 struct iasubopt
*lease
,
3598 isc_result_t
mark_lease_unavailble(struct ipv6_pool
*pool
,
3599 const struct in6_addr
*addr
);
3600 isc_result_t
create_prefix6(struct ipv6_pool
*pool
,
3601 struct iasubopt
**pref
,
3602 unsigned int *attempts
,
3603 const struct data_string
*uid
,
3604 time_t soft_lifetime_end_time
);
3605 isc_boolean_t
prefix6_exists(const struct ipv6_pool
*pool
,
3606 const struct in6_addr
*pref
, u_int8_t plen
);
3608 isc_result_t
add_ipv6_pool(struct ipv6_pool
*pool
);
3609 isc_result_t
find_ipv6_pool(struct ipv6_pool
**pool
, u_int16_t type
,
3610 const struct in6_addr
*addr
);
3611 isc_boolean_t
ipv6_in_pool(const struct in6_addr
*addr
,
3612 const struct ipv6_pool
*pool
);
3613 isc_result_t
ipv6_pond_allocate(struct ipv6_pond
**pond
,
3614 const char *file
, int line
);
3615 isc_result_t
ipv6_pond_reference(struct ipv6_pond
**pond
,
3616 struct ipv6_pond
*src
,
3617 const char *file
, int line
);
3618 isc_result_t
ipv6_pond_dereference(struct ipv6_pond
**pond
,
3619 const char *file
, int line
);
3621 isc_result_t
renew_leases(struct ia_xx
*ia
);
3622 isc_result_t
release_leases(struct ia_xx
*ia
);
3623 isc_result_t
decline_leases(struct ia_xx
*ia
);
3624 void schedule_lease_timeout(struct ipv6_pool
*pool
);
3625 void schedule_all_ipv6_lease_timeouts();
3627 void mark_hosts_unavailable(void);
3628 void mark_phosts_unavailable(void);
3629 void mark_interfaces_unavailable(void);
3631 #define MAX_ADDRESS_STRING_LEN \
3632 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))
3634 /* Find the percentage of count. We need to try two different
3635 * ways to avoid rounding mistakes.
3637 #define FIND_PERCENT(count, percent) \
3638 ((count) > (INT_MAX / 100) ? \
3639 ((count) / 100) * (percent) : ((count) * (percent)) / 100)