3 Definitions for dhcpd... */
6 * Copyright (c) 2004-2011 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/
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29 * To learn more about Internet Systems Consortium, see
30 * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32 * ``http://www.nominum.com''.
38 #include <sys/types.h>
39 #include <netinet/in.h>
40 #include <sys/socket.h>
42 #include <arpa/inet.h>
47 #define fd_set cygwin_fd_set
48 #include <sys/types.h>
63 #include <net/route.h>
64 #include <net/if_arp.h>
66 # include <net/if_dl.h>
74 #include "arpa/nameser.h"
79 typedef struct hash_table group_hash_t;
80 typedef struct hash_table universe_hash_t;
81 typedef struct hash_table option_name_hash_t;
82 typedef struct hash_table option_code_hash_t;
83 typedef struct hash_table dns_zone_hash_t;
84 typedef struct hash_table lease_ip_hash_t;
85 typedef struct hash_table lease_id_hash_t;
86 typedef struct hash_table host_hash_t;
87 typedef struct hash_table class_hash_t;
95 #include <omapip/isclib.h>
96 #include <omapip/result.h>
100 #include "statement.h"
103 #include "dhctoken.h"
105 #include <omapip/omapip_p.h>
107 #if defined(LDAP_CONFIGURATION)
109 # include <sys/utsname.h> /* for uname() */
112 #if !defined (BYTE_NAME_HASH_SIZE)
113 # define BYTE_NAME_HASH_SIZE 401 /* Default would be ridiculous. */
115 #if !defined (BYTE_CODE_HASH_SIZE)
116 # define BYTE_CODE_HASH_SIZE 254 /* Default would be ridiculous. */
119 /* Although it is highly improbable that a 16-bit option space might
120 * actually use 2^16 actual defined options, it is the worst case
121 * scenario we must prepare for. Having 4 options per bucket in this
122 * case is pretty reasonable.
124 #if !defined (WORD_NAME_HASH_SIZE)
125 # define WORD_NAME_HASH_SIZE 20479
127 #if !defined (WORD_CODE_HASH_SIZE)
128 # define WORD_CODE_HASH_SIZE 16384
131 /* Not only is it improbable that the 32-bit spaces might actually use 2^32
132 * defined options, it is infeasible. It would be best for this kind of
133 * space to be dynamically sized. Instead we size it at the word hash's
136 #if !defined (QUAD_NAME_HASH_SIZE)
137 # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
139 #if !defined (QUAD_CODE_HASH_SIZE)
140 # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
143 #if !defined (DNS_HASH_SIZE)
144 # define DNS_HASH_SIZE 0 /* Default. */
147 /* Default size to use for name/code hashes on user-defined option spaces. */
148 #if !defined (DEFAULT_SPACE_HASH_SIZE)
149 # define DEFAULT_SPACE_HASH_SIZE 11
152 #if !defined (NWIP_HASH_SIZE)
153 # define NWIP_HASH_SIZE 17 /* A really small table. */
156 #if !defined (FQDN_HASH_SIZE)
157 # define FQDN_HASH_SIZE 13 /* A ridiculously small table. */
160 /* I really doubt a given installation is going to have more than a few
161 * hundred vendors involved.
163 #if !defined (VIVCO_HASH_SIZE)
164 # define VIVCO_HASH_SIZE 127
167 #if !defined (VIVSO_HASH_SIZE)
168 # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
171 #if !defined (VSIO_HASH_SIZE)
172 # define VSIO_HASH_SIZE VIVCO_HASH_SIZE
175 #if !defined (VIV_ISC_HASH_SIZE)
176 # define VIV_ISC_HASH_SIZE 3 /* An incredulously small table. */
179 #if !defined (UNIVERSE_HASH_SIZE)
180 # define UNIVERSE_HASH_SIZE 13 /* A really small table. */
183 #if !defined (GROUP_HASH_SIZE)
184 # define GROUP_HASH_SIZE 0 /* Default. */
187 /* At least one person has indicated they use ~20k host records.
189 #if !defined (HOST_HASH_SIZE)
190 # define HOST_HASH_SIZE 22501
193 /* We have user reports of use of ISC DHCP numbering leases in the 200k's.
195 * We also have reports of folks using 10.0/8 as a dynamic range. The
196 * following is something of a compromise between the two. At the ~2-3
197 * hundred thousand leases, there's ~2-3 leases to search in each bucket.
199 #if !defined (LEASE_HASH_SIZE)
200 # define LEASE_HASH_SIZE 100003
203 /* It is not known what the worst case subclass hash size is. We estimate
206 #if !defined (SCLASS_HASH_SIZE)
207 # define SCLASS_HASH_SIZE 12007
210 #if !defined (AGENT_HASH_SIZE)
211 # define AGENT_HASH_SIZE 11 /* A really small table. */
214 /* The server hash size is used for both names and codes. There aren't
215 * many (roughly 50 at the moment), so we use a smaller table. If we
216 * use a 1:1 table size, then we get name collisions due to poor name
217 * hashing. So we use double the space we need, which drastically
218 * reduces collisions.
220 #if !defined (SERVER_HASH_SIZE)
221 # define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option)))
225 /* How many options are likely to appear in a single packet? */
226 #if !defined (OPTION_HASH_SIZE)
227 # define OPTION_HASH_SIZE 17
228 # define OPTION_HASH_PTWO 32 /* Next power of two above option hash. */
229 # define OPTION_HASH_EXP 5 /* The exponent for that power of two. */
232 #define compute_option_hash(x) \
233 (((x) & (OPTION_HASH_PTWO - 1)) + \
234 (((x) >> OPTION_HASH_EXP) & \
235 (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
237 enum dhcp_shutdown_state {
239 shutdown_omapi_connections,
240 shutdown_drop_omapi_connections,
245 /* Client FQDN option, failover FQDN option, etc. */
252 #include "failover.h"
254 /* A parsing context. */
266 * In order to give nice output when we have a parsing error
267 * in our file, we keep track of where we are in the line so
268 * that we can show the user.
270 * We need to keep track of two lines, because we can look
271 * ahead, via the "peek" function, to the next line sometimes.
273 * The "line1" and "line2" variables act as buffers for this
274 * information. The "lpos" variable tells us where we are in the
277 * When we "put back" a character from the parsing context, we
278 * do not want to have the character appear twice in the error
279 * output. So, we set a flag, the "ugflag", which the
280 * get_char() function uses to check for this condition.
288 enum dhcp_token token;
294 int warnings_occurred;
297 size_t bufix, buflen;
300 struct parse *saved_state;
302 #if defined(LDAP_CONFIGURATION)
304 * LDAP configuration uses a call-back to iteratively read config
305 * off of the LDAP repository.
306 * XXX: The token stream can not be rewound reliably, so this must
307 * be addressed for DHCPv6 support.
309 int (*read_function)(struct parse *);
313 /* Variable-length array of data. */
316 struct string_list *next;
320 /* A name server, from /etc/resolv.conf. */
322 struct name_server *next;
323 struct sockaddr_in addr;
327 /* A domain search list element. */
328 struct domain_search_list {
329 struct domain_search_list *next;
334 /* Option tag structures are used to build chains of option tags, for
335 when we're sure we're not going to have enough of them to justify
336 maintaining an array. */
339 struct option_tag *next;
343 /* An agent option structure. We need a special structure for the
344 Relay Agent Information option because if more than one appears in
345 a message, we have to keep them separate. */
347 struct agent_options {
348 struct agent_options *next;
350 struct option_tag *first;
353 struct option_cache {
355 struct option_cache *next;
356 struct expression *expression;
357 struct option *option;
358 struct data_string data;
360 #define OPTION_HAD_NULLS 0x00000001
364 struct option_state {
372 /* A dhcp packet and the pointers to its option values. */
374 struct dhcp_packet *raw;
376 unsigned packet_length;
379 unsigned char dhcpv6_msg_type; /* DHCPv6 message type */
381 /* DHCPv6 transaction ID */
382 unsigned char dhcpv6_transaction_id[3];
384 /* DHCPv6 relay information */
385 unsigned char dhcpv6_hop_count;
386 struct in6_addr dhcpv6_link_address;
387 struct in6_addr dhcpv6_peer_address;
389 /* DHCPv6 packet containing this one, or NULL if none */
390 struct packet *dhcpv6_container_packet;
394 struct iaddr client_addr;
395 struct interface_info *interface; /* Interface on which packet
397 struct hardware *haddr; /* Physical link address
398 of local sender (maybe gateway). */
400 /* Information for relay agent options (see
401 draft-ietf-dhc-agent-options-xx.txt). */
402 u_int8_t *circuit_id; /* Circuit ID of client connection. */
404 u_int8_t *remote_id; /* Remote ID of client. */
407 int got_requested_address; /* True if client sent the
408 dhcp-requested-address option. */
410 struct shared_network *shared_network;
411 struct option_state *options;
413 #if !defined (PACKET_MAX_CLASSES)
414 # define PACKET_MAX_CLASSES 5
417 struct class *classes [PACKET_MAX_CLASSES];
422 /* If we stash agent options onto the packet option state, to pretend
423 * options we got in a previous exchange were still there, we need
424 * to signal this in a reliable way.
426 isc_boolean_t agent_options_stashed;
429 * ISC_TRUE if packet received unicast (as opposed to multicast).
430 * Only used in DHCPv6.
432 isc_boolean_t unicast;
435 /* A network interface's MAC address. */
442 #if defined(LDAP_CONFIGURATION)
443 # define LDAP_BUFFER_SIZE 8192
444 # define LDAP_METHOD_STATIC 0
445 # define LDAP_METHOD_DYNAMIC 1
446 #if defined (LDAP_USE_SSL)
447 # define LDAP_SSL_OFF 0
448 # define LDAP_SSL_ON 1
449 # define LDAP_SSL_TLS 2
450 # define LDAP_SSL_LDAPS 3
453 /* This is a tree of the current configuration we are building from LDAP */
454 struct ldap_config_stack {
455 LDAPMessage * res; /* Pointer returned from ldap_search */
456 LDAPMessage * ldent; /* Current item in LDAP that we're processing.
458 int close_brace; /* Put a closing } after we're through with
460 int processed; /* We set this flag if this base item has been
461 processed. After this base item is processed,
462 we can start processing the children */
463 struct ldap_config_stack *children;
464 struct ldap_config_stack *next;
472 server_hibernate = 3,
474 } control_object_state_t;
477 OMAPI_OBJECT_PREAMBLE;
478 control_object_state_t state;
479 } dhcp_control_object_t;
484 #define FTS_EXPIRED 3
485 #define FTS_RELEASED 4
486 #define FTS_ABANDONED 5
489 typedef u_int8_t binding_state_t;
491 /* FTS_LAST is the highest value that is valid for a lease binding state. */
492 #define FTS_LAST FTS_BACKUP
494 /* A dhcp lease declaration structure. */
496 OMAPI_OBJECT_PREAMBLE;
498 struct lease *n_uid, *n_hw;
500 struct iaddr ip_addr;
501 TIME starts, ends, sort_time;
502 char *client_hostname;
503 struct binding_scope *scope;
504 struct host_decl *host;
505 struct subnet *subnet;
507 struct class *billing_class;
508 struct option_chain_head *agent_options;
510 struct executable_statement *on_expiry;
511 struct executable_statement *on_commit;
512 struct executable_statement *on_release;
515 unsigned short uid_len;
516 unsigned short uid_max;
517 unsigned char uid_buf [7];
518 struct hardware hardware_addr;
521 # define STATIC_LEASE 1
522 # define BOOTP_LEASE 2
523 # define RESERVED_LEASE 4
524 # define MS_NULL_TERMINATION 8
525 # define ON_UPDATE_QUEUE 16
526 # define ON_ACK_QUEUE 32
527 # define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE)
528 # define UNICAST_BROADCAST_HACK 64
529 # define ON_DEFERRED_QUEUE 128
531 /* Persistent flags are to be preserved on a given lease structure. */
532 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
533 /* Ephemeral flags are to be preserved on a given lease (copied etc). */
534 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
535 UNICAST_BROADCAST_HACK | \
540 * The lease's binding state is its current state. The next binding
541 * state is the next state this lease will move into by expiration,
542 * or timers in general. The desired binding state is used on lease
543 * updates; the caller is attempting to move the lease to the desired
544 * binding state (and this may either succeed or fail, so the binding
545 * state must be preserved).
547 * The 'rewind' binding state is used in failover processing. It
548 * is used for an optimization when out of communications; it allows
549 * the server to "rewind" a lease to the previous state acknowledged
550 * by the peer, and progress forward from that point.
552 binding_state_t binding_state;
553 binding_state_t next_binding_state;
554 binding_state_t desired_binding_state;
555 binding_state_t rewind_binding_state;
557 struct lease_state *state;
560 * 'tsfp' is more of an 'effective' tsfp. It may be calculated from
561 * stos+mclt for example if it's an expired lease and the server is
562 * in partner-down state. 'atsfp' is zeroed whenever a lease is
563 * updated - and only set when the peer acknowledges it. This
564 * ensures every state change is transmitted.
566 TIME tstp; /* Time sent to partner. */
567 TIME tsfp; /* Time sent from partner. */
568 TIME atsfp; /* Actual time sent from partner. */
569 TIME cltt; /* Client last transaction time. */
570 u_int32_t last_xid; /* XID we sent in this lease's BNDUPD */
571 struct lease *next_pending;
574 * A pointer to the state of the ddns update for this lease.
575 * It should be set while the update is in progress and cleared
576 * when the update finishes. It can be used to cancel the
577 * update if we want to do a different update.
579 struct dhcp_ddns_cb *ddns_cb;
583 struct lease_state *next;
585 struct interface_info *ip;
587 struct packet *packet; /* The incoming packet. */
591 struct option_state *options;
592 struct data_string parameter_request_list;
593 int max_message_size;
594 unsigned char expiry[4], renewal[4], rebind[4];
595 struct data_string filename, server_name;
596 int got_requested_address;
597 int got_server_identifier;
598 struct shared_network *shared_network; /* Shared network of interface
599 on which request arrived. */
603 u_int16_t bootp_flags;
604 struct in_addr ciaddr;
605 struct in_addr siaddr;
606 struct in_addr giaddr;
614 #define SHARED_NET_DECL 2
615 #define SUBNET_DECL 3
620 /* Possible modes in which discover_interfaces can run. */
622 #define DISCOVER_RUNNING 0
623 #define DISCOVER_SERVER 1
624 #define DISCOVER_UNCONFIGURED 2
625 #define DISCOVER_RELAY 3
626 #define DISCOVER_REQUESTED 4
628 /* DDNS_UPDATE_STYLE enumerations. */
629 #define DDNS_UPDATE_STYLE_NONE 0
630 #define DDNS_UPDATE_STYLE_AD_HOC 1
631 #define DDNS_UPDATE_STYLE_INTERIM 2
633 /* Server option names. */
635 #define SV_DEFAULT_LEASE_TIME 1
636 #define SV_MAX_LEASE_TIME 2
637 #define SV_MIN_LEASE_TIME 3
638 #define SV_BOOTP_LEASE_CUTOFF 4
639 #define SV_BOOTP_LEASE_LENGTH 5
640 #define SV_BOOT_UNKNOWN_CLIENTS 6
641 #define SV_DYNAMIC_BOOTP 7
642 #define SV_ALLOW_BOOTP 8
643 #define SV_ALLOW_BOOTING 9
644 #define SV_ONE_LEASE_PER_CLIENT 10
645 #define SV_GET_LEASE_HOSTNAMES 11
646 #define SV_USE_HOST_DECL_NAMES 12
647 #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
648 #define SV_MIN_SECS 14
649 #define SV_FILENAME 15
650 #define SV_SERVER_NAME 16
651 #define SV_NEXT_SERVER 17
652 #define SV_AUTHORITATIVE 18
653 #define SV_VENDOR_OPTION_SPACE 19
654 #define SV_ALWAYS_REPLY_RFC1048 20
655 #define SV_SITE_OPTION_SPACE 21
656 #define SV_ALWAYS_BROADCAST 22
657 #define SV_DDNS_DOMAIN_NAME 23
658 #define SV_DDNS_HOST_NAME 24
659 #define SV_DDNS_REV_DOMAIN_NAME 25
660 #define SV_LEASE_FILE_NAME 26
661 #define SV_PID_FILE_NAME 27
662 #define SV_DUPLICATES 28
663 #define SV_DECLINES 29
664 #define SV_DDNS_UPDATES 30
665 #define SV_OMAPI_PORT 31
666 #define SV_LOCAL_PORT 32
667 #define SV_LIMITED_BROADCAST_ADDRESS 33
668 #define SV_REMOTE_PORT 34
669 #define SV_LOCAL_ADDRESS 35
670 #define SV_OMAPI_KEY 36
671 #define SV_STASH_AGENT_OPTIONS 37
672 #define SV_DDNS_TTL 38
673 #define SV_DDNS_UPDATE_STYLE 39
674 #define SV_CLIENT_UPDATES 40
675 #define SV_UPDATE_OPTIMIZATION 41
676 #define SV_PING_CHECKS 42
677 #define SV_UPDATE_STATIC_LEASES 43
678 #define SV_LOG_FACILITY 44
679 #define SV_DO_FORWARD_UPDATES 45
680 #define SV_PING_TIMEOUT 46
681 #define SV_RESERVE_INFINITE 47
682 #define SV_DDNS_CONFLICT_DETECT 48
683 #define SV_LEASEQUERY 49
684 #define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
685 #define SV_DO_REVERSE_UPDATES 51
686 #define SV_FQDN_REPLY 52
687 #define SV_PREFER_LIFETIME 53
688 #define SV_DHCPV6_LEASE_FILE_NAME 54
689 #define SV_DHCPV6_PID_FILE_NAME 55
690 #define SV_LIMIT_ADDRS_PER_IA 56
691 #define SV_LIMIT_PREFS_PER_IA 57
692 #define SV_DELAYED_ACK 58
693 #define SV_MAX_ACK_DELAY 59
694 #if defined(LDAP_CONFIGURATION)
695 # define SV_LDAP_SERVER 60
696 # define SV_LDAP_PORT 61
697 # define SV_LDAP_USERNAME 62
698 # define SV_LDAP_PASSWORD 63
699 # define SV_LDAP_BASE_DN 64
700 # define SV_LDAP_METHOD 65
701 # define SV_LDAP_DEBUG_FILE 66
702 # define SV_LDAP_DHCP_SERVER_CN 67
703 # define SV_LDAP_REFERRALS 68
704 #if defined (LDAP_USE_SSL)
705 # define SV_LDAP_SSL 69
706 # define SV_LDAP_TLS_REQCERT 70
707 # define SV_LDAP_TLS_CA_FILE 71
708 # define SV_LDAP_TLS_CA_DIR 72
709 # define SV_LDAP_TLS_CERT 73
710 # define SV_LDAP_TLS_KEY 74
711 # define SV_LDAP_TLS_CRLCHECK 75
712 # define SV_LDAP_TLS_CIPHERS 76
713 # define SV_LDAP_TLS_RANDFILE 77
717 #if !defined (DEFAULT_PING_TIMEOUT)
718 # define DEFAULT_PING_TIMEOUT 1
721 #if !defined (DEFAULT_DELAYED_ACK)
722 # define DEFAULT_DELAYED_ACK 28 /* default SO_SNDBUF size / 576 bytes */
725 #if !defined (DEFAULT_ACK_DELAY_SECS)
726 # define DEFAULT_ACK_DELAY_SECS 0
729 #if !defined (DEFAULT_ACK_DELAY_USECS)
730 # define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
733 #if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
734 # define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */
737 #if defined(LDAP_CONFIGURATION)
738 # define SV_LDAP_SERVER 60
739 # define SV_LDAP_PORT 61
740 # define SV_LDAP_USERNAME 62
741 # define SV_LDAP_PASSWORD 63
742 # define SV_LDAP_BASE_DN 64
743 # define SV_LDAP_METHOD 65
744 # define SV_LDAP_DEBUG_FILE 66
745 # define SV_LDAP_DHCP_SERVER_CN 67
746 # define SV_LDAP_REFERRALS 68
747 #if defined (LDAP_USE_SSL)
748 # define SV_LDAP_SSL 69
749 # define SV_LDAP_TLS_REQCERT 70
750 # define SV_LDAP_TLS_CA_FILE 71
751 # define SV_LDAP_TLS_CA_DIR 72
752 # define SV_LDAP_TLS_CERT 73
753 # define SV_LDAP_TLS_KEY 74
754 # define SV_LDAP_TLS_CRLCHECK 75
755 # define SV_LDAP_TLS_CIPHERS 76
756 # define SV_LDAP_TLS_RANDFILE 77
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
889 permit_unknown_clients,
890 permit_known_clients,
891 permit_authenticated_clients,
892 permit_unauthenticated_clients,
894 permit_dynamic_bootp_clients,
899 TIME after; /* date after which this clause applies */
903 OMAPI_OBJECT_PREAMBLE;
906 struct shared_network *shared_network;
907 struct permit *permit_list;
908 struct permit *prohibit_list;
909 struct lease *active;
910 struct lease *expired;
912 struct lease *backup;
913 struct lease *abandoned;
914 struct lease *reserved;
915 TIME next_event_time;
920 TIME valid_from; /* deny pool use before this date */
921 TIME valid_until; /* deny pool use after this date */
923 #if defined (FAILOVER_PROTOCOL)
924 dhcp_failover_state_t *failover_peer;
928 struct shared_network {
929 OMAPI_OBJECT_PREAMBLE;
930 struct shared_network *next;
933 #define SHARED_IMPLICIT 1 /* This network was synthesized. */
936 struct subnet *subnets;
937 struct interface_info *interface;
939 struct ipv6_pool **ipv6_pools; /* NULL-terminated array */
940 int last_ipv6_pool; /* offset of last IPv6 pool
941 used to issue a lease */
943 #if defined (FAILOVER_PROTOCOL)
944 dhcp_failover_state_t *failover_peer;
949 OMAPI_OBJECT_PREAMBLE;
950 struct subnet *next_subnet;
951 struct subnet *next_sibling;
952 struct shared_network *shared_network;
953 struct interface_info *interface;
954 struct iaddr interface_address;
956 struct iaddr netmask;
957 int prefix_len; /* XXX: currently for IPv6 only */
962 struct collection *next;
965 struct class *classes;
968 /* Used as an argument to parse_clasS_decl() */
969 #define CLASS_TYPE_VENDOR 0
970 #define CLASS_TYPE_USER 1
971 #define CLASS_TYPE_CLASS 2
972 #define CLASS_TYPE_SUBCLASS 3
974 /* XXX classes must be reference-counted. */
976 OMAPI_OBJECT_PREAMBLE;
977 struct class *nic; /* Next in collection. */
978 struct class *superclass; /* Set for spawned classes only. */
979 char *name; /* Not set for spawned classes. */
981 /* A class may be configured to permit a limited number of leases. */
984 struct lease **billed_leases;
986 /* If nonzero, class has not been saved since it was last
990 /* Hash table containing subclasses. */
992 struct data_string hash_string;
994 /* Expression used to match class. */
995 struct expression *expr;
997 /* Expression used to compute subclass identifiers for spawning
998 and to do subclass matching. */
999 struct expression *submatch;
1002 struct group *group;
1004 /* Statements to execute if class matches. */
1005 struct executable_statement *statements;
1007 #define CLASS_DECL_DELETED 1
1008 #define CLASS_DECL_DYNAMIC 2
1009 #define CLASS_DECL_STATIC 4
1010 #define CLASS_DECL_SUBCLASS 8
1015 /* DHCP client lease structure... */
1016 struct client_lease {
1017 struct client_lease *next; /* Next lease in list. */
1018 TIME expiry, renewal, rebind; /* Lease timeouts. */
1019 struct iaddr address; /* Address being leased. */
1020 char *server_name; /* Name of boot server. */
1021 char *filename; /* Name of file we're supposed to boot. */
1022 struct string_list *medium; /* Network medium. */
1023 struct auth_key *key; /* Key used in basic DHCP authentication. */
1025 unsigned int is_static : 1; /* If set, lease is from config file. */
1026 unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
1028 struct option_state *options; /* Options supplied with lease. */
1031 /* DHCPv6 lease structures */
1033 struct dhc6_addr *next;
1034 struct iaddr address;
1037 /* Address state flags. */
1038 #define DHC6_ADDR_DEPREFFED 0x01
1039 #define DHC6_ADDR_EXPIRED 0x02
1043 u_int32_t preferred_life;
1046 struct option_state *options;
1050 struct dhc6_ia *next;
1051 unsigned char iaid[4];
1057 struct dhc6_addr *addrs;
1059 struct option_state *options;
1063 struct dhc6_lease *next;
1064 struct data_string server_id;
1066 isc_boolean_t released;
1070 unsigned char dhcpv6_transaction_id[3];
1071 struct dhc6_ia *bindings;
1073 struct option_state *options;
1076 /* Possible states in which the client can be. */
1088 /* Authentication and BOOTP policy possibilities (not all values work
1090 enum policy { P_IGNORE, P_ACCEPT, P_PREFER, P_REQUIRE, P_DONT };
1092 /* Configuration information from the config file... */
1093 struct client_config {
1095 * When a message has been received, run these statements
1098 struct group *on_receipt;
1101 * When a message is sent, run these statements.
1103 struct group *on_transmission;
1105 struct option **required_options; /* Options that MUST be present. */
1106 struct option **requested_options; /* Options to request (ORO/PRL). */
1108 TIME timeout; /* Start to panic if we don't get a
1109 lease in this time period when
1111 TIME initial_delay; /* Set initial delay before first
1113 TIME initial_interval; /* All exponential backoff intervals
1115 TIME retry_interval; /* If the protocol failed to produce
1116 an address before the timeout,
1117 try the protocol again after this
1119 TIME select_interval; /* Wait this many seconds from the
1120 first DHCPDISCOVER before
1121 picking an offered lease. */
1122 TIME reboot_timeout; /* When in INIT-REBOOT, wait this
1123 long before giving up and going
1125 TIME backoff_cutoff; /* When doing exponential backoff,
1126 never back off to an interval
1127 longer than this amount. */
1128 u_int32_t requested_lease; /* Requested lease time, if user
1129 doesn't configure one. */
1130 struct string_list *media; /* Possible network media values. */
1131 char *script_name; /* Name of config script. */
1132 char *vendor_space_name; /* Name of config script. */
1133 enum policy bootp_policy;
1134 /* Ignore, accept or prefer BOOTP
1136 enum policy auth_policy;
1137 /* Require authentication, prefer
1138 authentication, or don't try to
1140 struct string_list *medium; /* Current network medium. */
1142 struct iaddrmatchlist *reject_list; /* Servers to reject. */
1144 int omapi_port; /* port on which to accept OMAPI
1145 connections, or -1 for no
1147 int do_forward_update; /* If nonzero, and if we have the
1148 information we need, update the
1149 A record for the address we get. */
1152 /* Per-interface state used in the dhcp client... */
1153 /* XXX: consider union {}'ing this for v4/v6. */
1154 struct client_state {
1155 struct client_state *next;
1156 struct interface_info *interface;
1159 /* Common values. */
1160 struct client_config *config; /* Client configuration. */
1161 struct string_list *env; /* Client script environment. */
1162 int envc; /* Number of entries in environment. */
1163 struct option_state *sent_options; /* Options we sent. */
1164 enum dhcp_state state; /* Current state for this interface. */
1165 TIME last_write; /* Last time this state was written. */
1167 /* DHCPv4 values. */
1168 struct client_lease *active; /* Currently active lease. */
1169 struct client_lease *new; /* New lease. */
1170 struct client_lease *offered_leases; /* Leases offered to us. */
1171 struct client_lease *leases; /* Leases we currently hold. */
1172 struct client_lease *alias; /* Alias lease. */
1174 struct iaddr destination; /* Where to send packet. */
1175 u_int32_t xid; /* Transaction ID. */
1176 u_int16_t secs; /* secs value from DHCPDISCOVER. */
1177 TIME first_sending; /* When was first copy sent? */
1178 TIME interval; /* What's the current resend interval? */
1179 struct string_list *medium; /* Last media type tried. */
1180 struct dhcp_packet packet; /* Outgoing DHCP packet. */
1181 unsigned packet_length; /* Actual length of generated packet. */
1183 struct iaddr requested_address; /* Address we would like to get. */
1185 /* DHCPv6 values. */
1186 unsigned char dhcpv6_transaction_id[3];
1187 u_int8_t refresh_type;
1189 struct dhc6_lease *active_lease;
1190 struct dhc6_lease *old_lease;
1191 struct dhc6_lease *advertised_leases;
1192 struct dhc6_lease *selected_lease;
1193 struct dhc6_lease *held_leases;
1195 struct timeval start_time;
1199 /* See RFC3315 section 14. */
1200 TIME RT; /* In hundredths of seconds. */
1201 TIME IRT; /* In hundredths of seconds. */
1202 TIME MRC; /* Count. */
1203 TIME MRT; /* In hundredths of seconds. */
1204 TIME MRD; /* In seconds, relative. */
1205 TIME next_MRD; /* In seconds, absolute. */
1207 /* Rather than a state, we use a function that shifts around
1208 * depending what stage of life the v6 state machine is in.
1209 * This is where incoming packets are dispatched to (sometimes
1212 void (*v6_handler)(struct packet *, struct client_state *);
1215 * A pointer to the state of the ddns update for this lease.
1216 * It should be set while the update is in progress and cleared
1217 * when the update finishes. It can be used to cancel the
1218 * update if we want to do a different update.
1220 struct dhcp_ddns_cb *ddns_cb;
1223 struct envadd_state {
1224 struct client_state *client;
1228 struct dns_update_state {
1229 struct client_state *client;
1230 struct iaddr address;
1231 int dns_update_timeout;
1234 /* Information about each network interface. */
1236 struct interface_info {
1237 OMAPI_OBJECT_PREAMBLE;
1238 struct interface_info *next; /* Next interface in list... */
1239 struct shared_network *shared_network;
1240 /* Networks connected to this interface. */
1241 struct hardware hw_address; /* Its physical address. */
1242 struct in_addr *addresses; /* Addresses associated with this
1245 int address_count; /* Number of addresses stored. */
1246 int address_max; /* Size of addresses buffer. */
1247 struct in6_addr *v6addresses; /* IPv6 addresses associated with
1249 int v6address_count; /* Number of IPv6 addresses associated
1250 with this interface. */
1251 int v6address_max; /* Maximum number of IPv6 addresses
1252 we can store in current buffer. */
1254 u_int8_t *circuit_id; /* Circuit ID associated with this
1256 unsigned circuit_id_len; /* Length of Circuit ID, if there
1258 u_int8_t *remote_id; /* Remote ID associated with this
1259 interface (if any). */
1260 unsigned remote_id_len; /* Length of Remote ID. */
1262 char name [IFNAMSIZ]; /* Its name... */
1263 int index; /* Its if_nametoindex(). */
1264 int rfdesc; /* Its read file descriptor. */
1265 int wfdesc; /* Its write file descriptor, if
1267 unsigned char *rbuf; /* Read buffer, if required. */
1268 unsigned int rbuf_max; /* Size of read buffer. */
1269 size_t rbuf_offset; /* Current offset into buffer. */
1270 size_t rbuf_len; /* Length of data in buffer. */
1272 struct ifreq *ifp; /* Pointer to ifreq struct. */
1273 int configured; /* If set to 1, interface has at least
1274 * one valid IP address.
1276 u_int32_t flags; /* Control flags... */
1277 #define INTERFACE_REQUESTED 1
1278 #define INTERFACE_AUTOMATIC 2
1279 #define INTERFACE_RUNNING 4
1280 #define INTERFACE_DOWNSTREAM 8
1281 #define INTERFACE_UPSTREAM 16
1282 #define INTERFACE_STREAMS (INTERFACE_DOWNSTREAM | INTERFACE_UPSTREAM)
1284 /* Only used by DHCP client code. */
1285 struct client_state *client;
1286 # if defined(USE_DLPI_SEND) || defined(USE_DLPI_RECEIVE) || \
1287 defined(USE_DLPI_HWADDR)
1288 int dlpi_sap_length;
1289 struct hardware dlpi_broadcast_addr;
1290 # endif /* DLPI_SEND || DLPI_RECEIVE */
1291 struct hardware anycast_mac_addr;
1294 struct hardware_link {
1295 struct hardware_link *next;
1296 char name [IFNAMSIZ];
1297 struct hardware address;
1301 struct leasequeue *prev;
1302 struct leasequeue *next;
1303 struct lease *lease;
1306 typedef void (*tvref_t)(void *, void *, const char *, int);
1307 typedef void (*tvunref_t)(void *, const char *, int);
1309 struct timeout *next;
1310 struct timeval when;
1311 void (*func) (void *);
1315 isc_timer_t *isc_timeout;
1319 struct eventqueue *next;
1320 void (*handler)(void *);
1324 struct protocol *next;
1326 void (*handler) (struct protocol *);
1330 struct dns_query; /* forward */
1333 struct dns_wakeup *next; /* Next wakeup in chain. */
1334 void (*func) (struct dns_query *);
1337 struct dns_question {
1338 u_int16_t type; /* Type of query. */
1339 u_int16_t class; /* Class of query. */
1340 unsigned char data [1]; /* Query data. */
1344 u_int16_t type; /* Type of answer. */
1345 u_int16_t class; /* Class of answer. */
1346 int count; /* Number of answers. */
1347 unsigned char *answers[1]; /* Pointers to answers. */
1351 struct dns_query *next; /* Next query in hash bucket. */
1352 u_int32_t hash; /* Hash bucket index. */
1353 TIME expiry; /* Query expiry time (zero if not yet
1355 u_int16_t id; /* Query ID (also hash table index) */
1356 caddr_t waiters; /* Pointer to list of things waiting
1359 struct dns_question *question; /* Question, internal format. */
1360 struct dns_answer *answer; /* Answer, internal format. */
1362 unsigned char *query; /* Query formatted for DNS server. */
1363 unsigned len; /* Length of entire query. */
1364 int sent; /* The query has been sent. */
1365 struct dns_wakeup *wakeups; /* Wakeups to call if this query is
1367 struct name_server *next_server; /* Next server to try. */
1368 int backoff; /* Current backoff, in seconds. */
1375 struct option_cache *primary;
1376 struct option_cache *secondary;
1377 struct option_cache *primary6;
1378 struct option_cache *secondary6;
1379 struct auth_key *key;
1383 OMAPI_OBJECT_PREAMBLE;
1385 void (*icmp_handler) (struct iaddr, u_int8_t *, int);
1390 /* Bitmask of dhcp option codes. */
1391 typedef unsigned char option_mask [16];
1393 /* DHCP Option mask manipulation macros... */
1394 #define OPTION_ZERO(mask) (memset (mask, 0, 16))
1395 #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
1396 #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
1397 #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
1398 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
1400 /* An option occupies its length plus two header bytes (code and
1401 length) for every 255 bytes that must be stored. */
1402 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
1404 /* Default path to dhcpd config file. */
1406 #undef _PATH_DHCPD_CONF
1407 #define _PATH_DHCPD_CONF "dhcpd.conf"
1408 #undef _PATH_DHCPD_DB
1409 #define _PATH_DHCPD_DB "dhcpd.leases"
1410 #undef _PATH_DHCPD6_DB
1411 #define _PATH_DHCPD6_DB "dhcpd6.leases"
1412 #undef _PATH_DHCPD_PID
1413 #define _PATH_DHCPD_PID "dhcpd.pid"
1414 #undef _PATH_DHCPD6_PID
1415 #define _PATH_DHCPD6_PID "dhcpd6.pid"
1418 #ifndef _PATH_DHCPD_CONF
1419 #define _PATH_DHCPD_CONF "/etc/dhcpd.conf"
1422 #ifndef _PATH_DHCPD_DB
1423 #define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
1426 #ifndef _PATH_DHCPD6_DB
1427 #define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
1430 #ifndef _PATH_DHCPD_PID
1431 #define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid"
1434 #ifndef _PATH_DHCPD6_PID
1435 #define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid"
1440 #ifndef _PATH_DHCLIENT_CONF
1441 #define _PATH_DHCLIENT_CONF "/etc/dhclient.conf"
1444 #ifndef _PATH_DHCLIENT_SCRIPT
1445 #define _PATH_DHCLIENT_SCRIPT "/sbin/dhclient-script"
1448 #ifndef _PATH_DHCLIENT_PID
1449 #define _PATH_DHCLIENT_PID LOCALSTATEDIR"/run/dhclient.pid"
1452 #ifndef _PATH_DHCLIENT6_PID
1453 #define _PATH_DHCLIENT6_PID LOCALSTATEDIR"/run/dhclient6.pid"
1456 #ifndef _PATH_DHCLIENT_DB
1457 #define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases"
1460 #ifndef _PATH_DHCLIENT6_DB
1461 #define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases"
1464 #ifndef _PATH_RESOLV_CONF
1465 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
1468 #ifndef _PATH_DHCRELAY_PID
1469 #define _PATH_DHCRELAY_PID LOCALSTATEDIR"/run/dhcrelay.pid"
1472 #ifndef _PATH_DHCRELAY6_PID
1473 #define _PATH_DHCRELAY6_PID LOCALSTATEDIR"/run/dhcrelay6.pid"
1476 #ifndef DHCPD_LOG_FACILITY
1477 #define DHCPD_LOG_FACILITY LOG_DAEMON
1480 #define MAX_TIME 0x7fffffff
1483 /* these are referenced */
1484 typedef struct hash_table ia_hash_t;
1485 typedef struct hash_table iasubopt_hash_t;
1487 /* IAADDR/IAPREFIX lease */
1490 int refcnt; /* reference count */
1491 struct in6_addr addr; /* IPv6 address/prefix */
1492 u_int8_t plen; /* iaprefix prefix length */
1493 binding_state_t state; /* state */
1494 struct binding_scope *scope; /* "set var = value;" */
1495 time_t hard_lifetime_end_time; /* time address expires */
1496 time_t soft_lifetime_end_time; /* time ephemeral expires */
1497 u_int32_t prefer; /* cached preferred lifetime */
1498 u_int32_t valid; /* cached valid lifetime */
1499 struct ia_xx *ia; /* IA for this lease */
1500 struct ipv6_pool *ipv6_pool; /* pool for this lease */
1502 * For now, just pick an arbitrary time to keep old hard leases
1503 * around (value in seconds).
1505 #define EXPIRED_IPV6_CLEANUP_TIME (60*60)
1507 int heap_index; /* index into heap, or -1
1508 (internal use only) */
1511 * A pointer to the state of the ddns update for this lease.
1512 * It should be set while the update is in progress and cleared
1513 * when the update finishes. It can be used to cancel the
1514 * update if we want to do a different update.
1516 struct dhcp_ddns_cb *ddns_cb;
1521 int refcnt; /* reference count */
1522 struct data_string iaid_duid; /* from the client */
1523 u_int16_t ia_type; /* IA_XX */
1524 int num_iasubopt; /* number of IAADDR/PREFIX */
1525 int max_iasubopt; /* space available for IAADDR/PREFIX */
1526 time_t cltt; /* client last transaction time */
1527 struct iasubopt **iasubopt; /* pointers to the IAADDR/IAPREFIXs */
1530 extern ia_hash_t *ia_na_active;
1531 extern ia_hash_t *ia_ta_active;
1532 extern ia_hash_t *ia_pd_active;
1535 int refcnt; /* reference count */
1536 u_int16_t pool_type; /* IA_xx */
1537 struct in6_addr start_addr; /* first IPv6 address */
1538 int bits; /* number of bits, CIDR style */
1539 int units; /* allocation unit in bits */
1540 iasubopt_hash_t *leases; /* non-free leases */
1541 int num_active; /* count of active leases */
1542 isc_heap_t *active_timeouts; /* timeouts for active leases */
1543 int num_inactive; /* count of inactive leases */
1544 isc_heap_t *inactive_timeouts; /* timeouts for expired or
1546 struct shared_network *shared_network; /* shared_network for
1548 struct subnet *subnet; /* subnet for this pool */
1551 /* Flags and state for dhcp_ddns_cb_t */
1552 #define DDNS_UPDATE_ADDR 0x01
1553 #define DDNS_UPDATE_PTR 0x02
1554 #define DDNS_INCLUDE_RRSET 0x04
1555 #define DDNS_CONFLICT_OVERRIDE 0x08
1556 #define DDNS_CLIENT_DID_UPDATE 0x10
1557 #define DDNS_EXECUTE_NEXT 0x20
1558 #define DDNS_ABORT 0x40
1559 #define DDNS_STATIC_LEASE 0x80
1560 #define DDNS_ACTIVE_LEASE 0x100
1562 * The following two groups are separate and we could reuse
1563 * values but not reusing them may be useful in the future.
1565 #define DDNS_STATE_CLEANUP 0 // The previous step failed, cleanup
1567 #define DDNS_STATE_ADD_FW_NXDOMAIN 1
1568 #define DDNS_STATE_ADD_FW_YXDHCID 2
1569 #define DDNS_STATE_ADD_PTR 3
1571 #define DDNS_STATE_REM_FW_YXDHCID 17
1572 #define DDNS_STATE_REM_FW_NXRR 18
1573 #define DDNS_STATE_REM_PTR 19
1576 * Flags for the dns print function
1578 #define DDNS_PRINT_INBOUND 1
1579 #define DDNS_PRINT_OUTBOUND 0
1581 struct dhcp_ddns_cb;
1583 typedef void (*ddns_action_t)(struct dhcp_ddns_cb *ddns_cb,
1584 isc_result_t result);
1586 typedef struct dhcp_ddns_cb {
1587 struct data_string fwd_name;
1588 struct data_string rev_name;
1589 struct data_string dhcid;
1590 struct iaddr address;
1595 unsigned char zone_name[DHCP_MAXDNS_WIRE];
1596 isc_sockaddrlist_t zone_server_list;
1597 isc_sockaddr_t zone_addrs[DHCP_MAXNS];
1598 int zone_addr_count;
1599 struct dns_zone *zone;
1604 ddns_action_t cur_func;
1606 struct dhcp_ddns_cb * next_op;
1608 /* Lease or client state that triggered the ddns operation */
1610 struct binding_scope **scope;
1616 extern struct ipv6_pool **pools;
1617 extern int num_pools;
1619 /* External definitions... */
1621 HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t)
1622 HASH_FUNCTIONS_DECL (universe, const char *, struct universe, universe_hash_t)
1623 HASH_FUNCTIONS_DECL (option_name, const char *, struct option,
1625 HASH_FUNCTIONS_DECL (option_code, const unsigned *, struct option,
1627 HASH_FUNCTIONS_DECL (dns_zone, const char *, struct dns_zone, dns_zone_hash_t)
1628 HASH_FUNCTIONS_DECL(lease_ip, const unsigned char *, struct lease,
1630 HASH_FUNCTIONS_DECL(lease_id, const unsigned char *, struct lease,
1632 HASH_FUNCTIONS_DECL (host, const unsigned char *, struct host_decl, host_hash_t)
1633 HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t)
1637 extern struct option *vendor_cfg_option;
1638 int parse_options (struct packet *);
1639 int parse_option_buffer (struct option_state *, const unsigned char *,
1640 unsigned, struct universe *);
1641 struct universe *find_option_universe (struct option *, const char *);
1642 int parse_encapsulated_suboptions (struct option_state *, struct option *,
1643 const unsigned char *, unsigned,
1644 struct universe *, const char *);
1645 int cons_options (struct packet *, struct dhcp_packet *, struct lease *,
1646 struct client_state *,
1647 int, struct option_state *, struct option_state *,
1648 struct binding_scope **,
1649 int, int, int, struct data_string *, const char *);
1650 int fqdn_universe_decode (struct option_state *,
1651 const unsigned char *, unsigned, struct universe *);
1652 struct option_cache *
1653 lookup_fqdn6_option(struct universe *universe, struct option_state *options,
1656 save_fqdn6_option(struct universe *universe, struct option_state *options,
1657 struct option_cache *oc, isc_boolean_t appendp);
1659 delete_fqdn6_option(struct universe *universe, struct option_state *options,
1662 fqdn6_option_space_foreach(struct packet *packet, struct lease *lease,
1663 struct client_state *client_state,
1664 struct option_state *in_options,
1665 struct option_state *cfg_options,
1666 struct binding_scope **scope,
1667 struct universe *u, void *stuff,
1668 void (*func)(struct option_cache *,
1671 struct client_state *,
1672 struct option_state *,
1673 struct option_state *,
1674 struct binding_scope **,
1675 struct universe *, void *));
1677 fqdn6_option_space_encapsulate(struct data_string *result,
1678 struct packet *packet, struct lease *lease,
1679 struct client_state *client_state,
1680 struct option_state *in_options,
1681 struct option_state *cfg_options,
1682 struct binding_scope **scope,
1683 struct universe *universe);
1685 fqdn6_universe_decode(struct option_state *options,
1686 const unsigned char *buffer, unsigned length,
1687 struct universe *u);
1688 int append_option(struct data_string *dst, struct universe *universe,
1689 struct option *option, struct data_string *src);
1691 store_options(int *ocount,
1692 unsigned char *buffer, unsigned buflen, unsigned index,
1693 struct packet *packet, struct lease *lease,
1694 struct client_state *client_state,
1695 struct option_state *in_options,
1696 struct option_state *cfg_options,
1697 struct binding_scope **scope,
1698 unsigned *priority_list, int priority_len,
1699 unsigned first_cutoff, int second_cutoff, int terminate,
1700 const char *vuname);
1701 int store_options6(char *, int, struct option_state *, struct packet *,
1702 const int *, struct data_string *);
1703 int format_has_text(const char *);
1704 int format_min_length(const char *, struct option_cache *);
1705 const char *pretty_print_option (struct option *, const unsigned char *,
1706 unsigned, int, int);
1707 int pretty_escape(char **, char *, const unsigned char **,
1708 const unsigned char *);
1709 int get_option (struct data_string *, struct universe *,
1710 struct packet *, struct lease *, struct client_state *,
1711 struct option_state *, struct option_state *,
1712 struct option_state *, struct binding_scope **, unsigned,
1714 void set_option (struct universe *, struct option_state *,
1715 struct option_cache *, enum statement_op);
1716 struct option_cache *lookup_option (struct universe *,
1717 struct option_state *, unsigned);
1718 struct option_cache *lookup_hashed_option (struct universe *,
1719 struct option_state *,
1721 struct option_cache *next_hashed_option(struct universe *,
1722 struct option_state *,
1723 struct option_cache *);
1724 int save_option_buffer (struct universe *, struct option_state *,
1725 struct buffer *, unsigned char *, unsigned,
1727 int append_option_buffer(struct universe *, struct option_state *,
1728 struct buffer *, unsigned char *, unsigned,
1730 void build_server_oro(struct data_string *, struct option_state *,
1732 void save_option(struct universe *, struct option_state *,
1733 struct option_cache *);
1734 void also_save_option(struct universe *, struct option_state *,
1735 struct option_cache *);
1736 void save_hashed_option(struct universe *, struct option_state *,
1737 struct option_cache *, isc_boolean_t appendp);
1738 void delete_option (struct universe *, struct option_state *, int);
1739 void delete_hashed_option (struct universe *,
1740 struct option_state *, int);
1741 int option_cache_dereference (struct option_cache **,
1743 int hashed_option_state_dereference (struct universe *,
1744 struct option_state *,
1746 int store_option (struct data_string *,
1747 struct universe *, struct packet *, struct lease *,
1748 struct client_state *,
1749 struct option_state *, struct option_state *,
1750 struct binding_scope **, struct option_cache *);
1751 int option_space_encapsulate (struct data_string *,
1752 struct packet *, struct lease *,
1753 struct client_state *,
1754 struct option_state *,
1755 struct option_state *,
1756 struct binding_scope **,
1757 struct data_string *);
1758 int hashed_option_space_encapsulate (struct data_string *,
1759 struct packet *, struct lease *,
1760 struct client_state *,
1761 struct option_state *,
1762 struct option_state *,
1763 struct binding_scope **,
1765 int nwip_option_space_encapsulate (struct data_string *,
1766 struct packet *, struct lease *,
1767 struct client_state *,
1768 struct option_state *,
1769 struct option_state *,
1770 struct binding_scope **,
1772 int fqdn_option_space_encapsulate (struct data_string *,
1773 struct packet *, struct lease *,
1774 struct client_state *,
1775 struct option_state *,
1776 struct option_state *,
1777 struct binding_scope **,
1779 void suboption_foreach (struct packet *, struct lease *, struct client_state *,
1780 struct option_state *, struct option_state *,
1781 struct binding_scope **, struct universe *, void *,
1782 void (*) (struct option_cache *, struct packet *,
1783 struct lease *, struct client_state *,
1784 struct option_state *, struct option_state *,
1785 struct binding_scope **,
1786 struct universe *, void *),
1787 struct option_cache *, const char *);
1788 void option_space_foreach (struct packet *, struct lease *,
1789 struct client_state *,
1790 struct option_state *,
1791 struct option_state *,
1792 struct binding_scope **,
1793 struct universe *, void *,
1794 void (*) (struct option_cache *,
1796 struct lease *, struct client_state *,
1797 struct option_state *,
1798 struct option_state *,
1799 struct binding_scope **,
1800 struct universe *, void *));
1801 void hashed_option_space_foreach (struct packet *, struct lease *,
1802 struct client_state *,
1803 struct option_state *,
1804 struct option_state *,
1805 struct binding_scope **,
1806 struct universe *, void *,
1807 void (*) (struct option_cache *,
1810 struct client_state *,
1811 struct option_state *,
1812 struct option_state *,
1813 struct binding_scope **,
1814 struct universe *, void *));
1815 int linked_option_get (struct data_string *, struct universe *,
1816 struct packet *, struct lease *,
1817 struct client_state *,
1818 struct option_state *, struct option_state *,
1819 struct option_state *, struct binding_scope **,
1821 int linked_option_state_dereference (struct universe *,
1822 struct option_state *,
1824 void save_linked_option(struct universe *, struct option_state *,
1825 struct option_cache *, isc_boolean_t appendp);
1826 void linked_option_space_foreach (struct packet *, struct lease *,
1827 struct client_state *,
1828 struct option_state *,
1829 struct option_state *,
1830 struct binding_scope **,
1831 struct universe *, void *,
1832 void (*) (struct option_cache *,
1835 struct client_state *,
1836 struct option_state *,
1837 struct option_state *,
1838 struct binding_scope **,
1839 struct universe *, void *));
1840 int linked_option_space_encapsulate (struct data_string *, struct packet *,
1841 struct lease *, struct client_state *,
1842 struct option_state *,
1843 struct option_state *,
1844 struct binding_scope **,
1846 void delete_linked_option (struct universe *, struct option_state *, int);
1847 struct option_cache *lookup_linked_option (struct universe *,
1848 struct option_state *, unsigned);
1849 void do_packet (struct interface_info *,
1850 struct dhcp_packet *, unsigned,
1851 unsigned int, struct iaddr, struct hardware *);
1852 void do_packet6(struct interface_info *, const char *,
1853 int, int, const struct iaddr *, isc_boolean_t);
1854 int packet6_len_okay(const char *, int);
1856 int add_option(struct option_state *options,
1857 unsigned int option_num,
1859 unsigned int data_len);
1862 extern struct timeval cur_tv;
1863 #define cur_time cur_tv.tv_sec
1865 extern int ddns_update_style;
1867 extern const char *path_dhcpd_conf;
1868 extern const char *path_dhcpd_db;
1869 extern const char *path_dhcpd_pid;
1871 extern int dhcp_max_agent_option_packet_length;
1872 extern struct eventqueue *rw_queue_empty;
1874 int main(int, char **);
1875 void postconf_initialization(int);
1876 void postdb_startup(void);
1877 void cleanup (void);
1878 void lease_pinged (struct iaddr, u_int8_t *, int);
1879 void lease_ping_timeout (void *);
1880 int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia);
1881 extern enum dhcp_shutdown_state shutdown_state;
1882 isc_result_t dhcp_io_shutdown (omapi_object_t *, void *);
1883 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
1884 control_object_state_t newstate);
1885 #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
1886 void relinquish_ackqueue(void);
1890 isc_result_t new_parse (struct parse **, int,
1891 char *, unsigned, const char *, int);
1892 isc_result_t end_parse (struct parse **);
1893 isc_result_t save_parse_state(struct parse *cfile);
1894 isc_result_t restore_parse_state(struct parse *cfile);
1895 enum dhcp_token next_token (const char **, unsigned *, struct parse *);
1896 enum dhcp_token peek_token (const char **, unsigned *, struct parse *);
1897 enum dhcp_token next_raw_token(const char **rval, unsigned *rlen,
1898 struct parse *cfile);
1899 enum dhcp_token peek_raw_token(const char **rval, unsigned *rlen,
1900 struct parse *cfile);
1903 void parse_trace_setup (void);
1904 isc_result_t readconf (void);
1905 isc_result_t read_conf_file (const char *, struct group *, int, int);
1906 #if defined (TRACING)
1907 void trace_conf_input (trace_type_t *, unsigned, char *);
1908 void trace_conf_stop (trace_type_t *ttype);
1910 isc_result_t conf_file_subparse (struct parse *, struct group *, int);
1911 isc_result_t lease_file_subparse (struct parse *);
1912 int parse_statement (struct parse *, struct group *, int,
1913 struct host_decl *, int);
1914 #if defined (FAILOVER_PROTOCOL)
1915 void parse_failover_peer (struct parse *, struct group *, int);
1916 void parse_failover_state_declaration (struct parse *,
1917 dhcp_failover_state_t *);
1918 void parse_failover_state (struct parse *,
1919 enum failover_state *, TIME *);
1921 int permit_list_match (struct permit *, struct permit *);
1922 void parse_pool_statement (struct parse *, struct group *, int);
1923 int parse_lbrace (struct parse *);
1924 void parse_host_declaration (struct parse *, struct group *);
1925 int parse_class_declaration (struct class **, struct parse *,
1926 struct group *, int);
1927 void parse_shared_net_declaration (struct parse *, struct group *);
1928 void parse_subnet_declaration (struct parse *,
1929 struct shared_network *);
1930 void parse_subnet6_declaration (struct parse *,
1931 struct shared_network *);
1932 void parse_group_declaration (struct parse *, struct group *);
1933 int parse_fixed_addr_param (struct option_cache **,
1934 struct parse *, enum dhcp_token);
1935 int parse_lease_declaration (struct lease **, struct parse *);
1936 int parse_ip6_addr(struct parse *, struct iaddr *);
1937 int parse_ip6_addr_expr(struct expression **, struct parse *);
1938 int parse_ip6_prefix(struct parse *, struct iaddr *, u_int8_t *);
1939 void parse_address_range (struct parse *, struct group *, int,
1940 struct pool *, struct lease **);
1941 void parse_address_range6(struct parse *cfile, struct group *group);
1942 void parse_prefix6(struct parse *cfile, struct group *group);
1943 void parse_fixed_prefix6(struct parse *cfile, struct host_decl *host_decl);
1944 void parse_ia_na_declaration(struct parse *);
1945 void parse_ia_ta_declaration(struct parse *);
1946 void parse_ia_pd_declaration(struct parse *);
1947 void parse_server_duid(struct parse *cfile);
1948 void parse_server_duid_conf(struct parse *cfile);
1951 int ddns_updates(struct packet *, struct lease *, struct lease *,
1952 struct iasubopt *, struct iasubopt *, struct option_state *);
1953 int ddns_removals(struct lease *, struct iasubopt *, struct dhcp_ddns_cb *, isc_boolean_t);
1954 #if defined (TRACING)
1955 void trace_ddns_init(void);
1959 void add_enumeration (struct enumeration *);
1960 struct enumeration *find_enumeration (const char *, int);
1961 struct enumeration_value *find_enumeration_value (const char *, int,
1964 void skip_to_semi (struct parse *);
1965 void skip_to_rbrace (struct parse *, int);
1966 int parse_semi (struct parse *);
1967 int parse_string (struct parse *, char **, unsigned *);
1968 char *parse_host_name (struct parse *);
1969 int parse_ip_addr_or_hostname (struct expression **,
1970 struct parse *, int);
1971 void parse_hardware_param (struct parse *, struct hardware *);
1972 void parse_lease_time (struct parse *, TIME *);
1973 unsigned char *parse_numeric_aggregate (struct parse *,
1974 unsigned char *, unsigned *,
1975 int, int, unsigned);
1976 void convert_num (struct parse *, unsigned char *, const char *,
1978 TIME parse_date (struct parse *);
1979 TIME parse_date_core(struct parse *);
1980 isc_result_t parse_option_name (struct parse *, int, int *,
1982 void parse_option_space_decl (struct parse *);
1983 int parse_option_code_definition (struct parse *, struct option *);
1984 int parse_base64 (struct data_string *, struct parse *);
1985 int parse_cshl (struct data_string *, struct parse *);
1986 int parse_executable_statement (struct executable_statement **,
1987 struct parse *, int *,
1988 enum expression_context);
1989 int parse_executable_statements (struct executable_statement **,
1990 struct parse *, int *,
1991 enum expression_context);
1992 int parse_zone (struct dns_zone *, struct parse *);
1993 int parse_key (struct parse *);
1994 int parse_on_statement (struct executable_statement **,
1995 struct parse *, int *);
1996 int parse_switch_statement (struct executable_statement **,
1997 struct parse *, int *);
1998 int parse_case_statement (struct executable_statement **,
1999 struct parse *, int *,
2000 enum expression_context);
2001 int parse_if_statement (struct executable_statement **,
2002 struct parse *, int *);
2003 int parse_boolean_expression (struct expression **,
2004 struct parse *, int *);
2005 int parse_boolean (struct parse *);
2006 int parse_data_expression (struct expression **,
2007 struct parse *, int *);
2008 int parse_numeric_expression (struct expression **,
2009 struct parse *, int *);
2010 int parse_dns_expression (struct expression **, struct parse *, int *);
2011 int parse_non_binary (struct expression **, struct parse *, int *,
2012 enum expression_context);
2013 int parse_expression (struct expression **, struct parse *, int *,
2014 enum expression_context,
2015 struct expression **, enum expr_op);
2016 int parse_option_data(struct expression **expr, struct parse *cfile,
2017 int lookups, struct option *option);
2018 int parse_option_statement (struct executable_statement **,
2019 struct parse *, int,
2020 struct option *, enum statement_op);
2021 int parse_option_token (struct expression **, struct parse *,
2022 const char **, struct expression *, int, int);
2023 int parse_allow_deny (struct option_cache **, struct parse *, int);
2024 int parse_auth_key (struct data_string *, struct parse *);
2025 int parse_warn (struct parse *, const char *, ...)
2026 __attribute__((__format__(__printf__,2,3)));
2027 struct expression *parse_domain_list(struct parse *cfile, int);
2031 #if defined (NSUPDATE)
2032 extern struct __res_state resolver_state;
2033 extern int resolver_inited;
2036 extern struct binding_scope *global_scope;
2037 pair cons (caddr_t, pair);
2038 int make_const_option_cache (struct option_cache **, struct buffer **,
2039 u_int8_t *, unsigned, struct option *,
2041 int make_host_lookup (struct expression **, const char *);
2042 int enter_dns_host (struct dns_host_entry **, const char *);
2043 int make_const_data (struct expression **,
2044 const unsigned char *, unsigned, int, int,
2046 int make_const_int (struct expression **, unsigned long);
2047 int make_concat (struct expression **,
2048 struct expression *, struct expression *);
2049 int make_encapsulation (struct expression **, struct data_string *);
2050 int make_substring (struct expression **, struct expression *,
2051 struct expression *, struct expression *);
2052 int make_limit (struct expression **, struct expression *, int);
2053 int make_let (struct executable_statement **, const char *);
2054 int option_cache (struct option_cache **, struct data_string *,
2055 struct expression *, struct option *,
2057 int evaluate_expression (struct binding_value **, struct packet *,
2058 struct lease *, struct client_state *,
2059 struct option_state *, struct option_state *,
2060 struct binding_scope **, struct expression *,
2062 int binding_value_dereference (struct binding_value **, const char *, int);
2063 #if defined (NSUPDATE_OLD)
2064 int evaluate_dns_expression (ns_updrec **, struct packet *,
2066 struct client_state *,
2067 struct option_state *,
2068 struct option_state *,
2069 struct binding_scope **,
2070 struct expression *);
2072 int evaluate_boolean_expression (int *,
2073 struct packet *, struct lease *,
2074 struct client_state *,
2075 struct option_state *,
2076 struct option_state *,
2077 struct binding_scope **,
2078 struct expression *);
2079 int evaluate_data_expression (struct data_string *,
2080 struct packet *, struct lease *,
2081 struct client_state *,
2082 struct option_state *,
2083 struct option_state *,
2084 struct binding_scope **,
2085 struct expression *, const char *, int);
2086 int evaluate_numeric_expression (unsigned long *, struct packet *,
2087 struct lease *, struct client_state *,
2088 struct option_state *, struct option_state *,
2089 struct binding_scope **,
2090 struct expression *);
2091 int evaluate_option_cache (struct data_string *,
2092 struct packet *, struct lease *,
2093 struct client_state *,
2094 struct option_state *, struct option_state *,
2095 struct binding_scope **,
2096 struct option_cache *,
2098 int evaluate_boolean_option_cache (int *,
2099 struct packet *, struct lease *,
2100 struct client_state *,
2101 struct option_state *,
2102 struct option_state *,
2103 struct binding_scope **,
2104 struct option_cache *,
2106 int evaluate_boolean_expression_result (int *,
2107 struct packet *, struct lease *,
2108 struct client_state *,
2109 struct option_state *,
2110 struct option_state *,
2111 struct binding_scope **,
2112 struct expression *);
2113 void expression_dereference (struct expression **, const char *, int);
2114 int is_dns_expression (struct expression *);
2115 int is_boolean_expression (struct expression *);
2116 int is_data_expression (struct expression *);
2117 int is_numeric_expression (struct expression *);
2118 int is_compound_expression (struct expression *);
2119 int op_precedence (enum expr_op, enum expr_op);
2120 enum expression_context expression_context (struct expression *);
2121 enum expression_context op_context (enum expr_op);
2122 int write_expression (FILE *, struct expression *, int, int, int);
2123 struct binding *find_binding (struct binding_scope *, const char *);
2124 int free_bindings (struct binding_scope *, const char *, int);
2125 int binding_scope_dereference (struct binding_scope **,
2127 int fundef_dereference (struct fundef **, const char *, int);
2128 int data_subexpression_length (int *, struct expression *);
2129 int expr_valid_for_context (struct expression *, enum expression_context);
2130 struct binding *create_binding (struct binding_scope **, const char *);
2131 int bind_ds_value (struct binding_scope **,
2132 const char *, struct data_string *);
2133 int find_bound_string (struct data_string *,
2134 struct binding_scope *, const char *);
2135 int unset (struct binding_scope *, const char *);
2136 int data_string_sprintfa(struct data_string *ds, const char *fmt, ...);
2139 extern int outstanding_pings;
2140 extern int max_outstanding_acks;
2141 extern int max_ack_delay_secs;
2142 extern int max_ack_delay_usecs;
2144 void dhcp (struct packet *);
2145 void dhcpdiscover (struct packet *, int);
2146 void dhcprequest (struct packet *, int, struct lease *);
2147 void dhcprelease (struct packet *, int);
2148 void dhcpdecline (struct packet *, int);
2149 void dhcpinform (struct packet *, int);
2150 void nak_lease (struct packet *, struct iaddr *cip);
2151 void ack_lease (struct packet *, struct lease *,
2152 unsigned int, TIME, char *, int, struct host_decl *);
2153 void delayed_ack_enqueue(struct lease *);
2154 void commit_leases_readerdry(void *);
2155 void flush_ackqueue(void *);
2156 void dhcp_reply (struct lease *);
2157 int find_lease (struct lease **, struct packet *,
2158 struct shared_network *, int *, int *, struct lease *,
2160 int mockup_lease (struct lease **, struct packet *,
2161 struct shared_network *,
2162 struct host_decl *);
2163 void static_lease_dereference (struct lease *, const char *, int);
2165 int allocate_lease (struct lease **, struct packet *,
2166 struct pool *, int *);
2167 int permitted (struct packet *, struct permit *);
2168 int locate_network (struct packet *);
2169 int parse_agent_information_option (struct packet *, int, u_int8_t *);
2170 unsigned cons_agent_information_options (struct option_state *,
2171 struct dhcp_packet *,
2172 unsigned, unsigned);
2173 void get_server_source_address(struct in_addr *from,
2174 struct option_state *options,
2175 struct packet *packet);
2177 /* dhcpleasequery.c */
2178 void dhcpleasequery (struct packet *, int);
2179 void dhcpv6_leasequery (struct data_string *, struct packet *);
2182 isc_boolean_t server_duid_isset(void);
2183 void copy_server_duid(struct data_string *ds, const char *file, int line);
2184 void set_server_duid(struct data_string *new_duid);
2185 isc_result_t set_server_duid_from_option(void);
2186 void set_server_duid_type(int type);
2187 isc_result_t generate_new_server_duid(void);
2188 isc_result_t get_client_id(struct packet *, struct data_string *);
2189 void dhcpv6(struct packet *);
2192 void bootp (struct packet *);
2195 extern int (*group_write_hook) (struct group_object *);
2196 extern struct group *root_group;
2197 extern group_hash_t *group_name_hash;
2198 isc_result_t delete_group (struct group_object *, int);
2199 isc_result_t supersede_group (struct group_object *, int);
2200 int clone_group (struct group **, struct group *, const char *, int);
2201 int write_group (struct group_object *);
2204 void relinquish_lease_hunks (void);
2205 struct lease *new_leases (unsigned, const char *, int);
2206 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2207 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2208 void relinquish_free_lease_states (void);
2210 OMAPI_OBJECT_ALLOC_DECL (lease, struct lease, dhcp_type_lease)
2211 OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class)
2212 OMAPI_OBJECT_ALLOC_DECL (subclass, struct class, dhcp_type_subclass)
2213 OMAPI_OBJECT_ALLOC_DECL (pool, struct pool, dhcp_type_pool)
2214 OMAPI_OBJECT_ALLOC_DECL (host, struct host_decl, dhcp_type_host)
2217 OMAPI_OBJECT_ALLOC_DECL (subnet, struct subnet, dhcp_type_subnet)
2218 OMAPI_OBJECT_ALLOC_DECL (shared_network, struct shared_network,
2219 dhcp_type_shared_network)
2220 OMAPI_OBJECT_ALLOC_DECL (group_object, struct group_object, dhcp_type_group)
2221 OMAPI_OBJECT_ALLOC_DECL (dhcp_control,
2222 dhcp_control_object_t, dhcp_type_control)
2224 #if defined (DEBUG_MEMORY_LEAKAGE) || \
2225 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
2226 void relinquish_free_pairs (void);
2227 void relinquish_free_expressions (void);
2228 void relinquish_free_binding_values (void);
2229 void relinquish_free_option_caches (void);
2230 void relinquish_free_packets (void);
2233 int option_chain_head_allocate (struct option_chain_head **,
2235 int option_chain_head_reference (struct option_chain_head **,
2236 struct option_chain_head *,
2238 int option_chain_head_dereference (struct option_chain_head **,
2240 int group_allocate (struct group **, const char *, int);
2241 int group_reference (struct group **, struct group *, const char *, int);
2242 int group_dereference (struct group **, const char *, int);
2243 struct dhcp_packet *new_dhcp_packet (const char *, int);
2244 struct protocol *new_protocol (const char *, int);
2245 struct lease_state *new_lease_state (const char *, int);
2246 struct domain_search_list *new_domain_search_list (const char *, int);
2247 struct name_server *new_name_server (const char *, int);
2248 void free_name_server (struct name_server *, const char *, int);
2249 struct option *new_option (const char *, const char *, int);
2250 int option_reference(struct option **dest, struct option *src,
2251 const char * file, int line);
2252 int option_dereference(struct option **dest, const char *file, int line);
2253 struct universe *new_universe (const char *, int);
2254 void free_universe (struct universe *, const char *, int);
2255 void free_domain_search_list (struct domain_search_list *,
2257 void free_lease_state (struct lease_state *, const char *, int);
2258 void free_protocol (struct protocol *, const char *, int);
2259 void free_dhcp_packet (struct dhcp_packet *, const char *, int);
2260 struct client_lease *new_client_lease (const char *, int);
2261 void free_client_lease (struct client_lease *, const char *, int);
2262 struct permit *new_permit (const char *, int);
2263 void free_permit (struct permit *, const char *, int);
2264 pair new_pair (const char *, int);
2265 void free_pair (pair, const char *, int);
2266 int expression_allocate (struct expression **, const char *, int);
2267 int expression_reference (struct expression **,
2268 struct expression *, const char *, int);
2269 void free_expression (struct expression *, const char *, int);
2270 int binding_value_allocate (struct binding_value **,
2272 int binding_value_reference (struct binding_value **,
2273 struct binding_value *,
2275 void free_binding_value (struct binding_value *, const char *, int);
2276 int fundef_allocate (struct fundef **, const char *, int);
2277 int fundef_reference (struct fundef **,
2278 struct fundef *, const char *, int);
2279 int option_cache_allocate (struct option_cache **, const char *, int);
2280 int option_cache_reference (struct option_cache **,
2281 struct option_cache *, const char *, int);
2282 int buffer_allocate (struct buffer **, unsigned, const char *, int);
2283 int buffer_reference (struct buffer **, struct buffer *,
2285 int buffer_dereference (struct buffer **, const char *, int);
2286 int dns_host_entry_allocate (struct dns_host_entry **,
2287 const char *, const char *, int);
2288 int dns_host_entry_reference (struct dns_host_entry **,
2289 struct dns_host_entry *,
2291 int dns_host_entry_dereference (struct dns_host_entry **,
2293 int option_state_allocate (struct option_state **, const char *, int);
2294 int option_state_reference (struct option_state **,
2295 struct option_state *, const char *, int);
2296 int option_state_dereference (struct option_state **,
2298 void data_string_copy(struct data_string *, const struct data_string *,
2300 void data_string_forget (struct data_string *, const char *, int);
2301 void data_string_truncate (struct data_string *, int);
2302 int executable_statement_allocate (struct executable_statement **,
2304 int executable_statement_reference (struct executable_statement **,
2305 struct executable_statement *,
2307 int packet_allocate (struct packet **, const char *, int);
2308 int packet_reference (struct packet **,
2309 struct packet *, const char *, int);
2310 int packet_dereference (struct packet **, const char *, int);
2311 int binding_scope_allocate (struct binding_scope **,
2313 int binding_scope_reference (struct binding_scope **,
2314 struct binding_scope *,
2316 int dns_zone_allocate (struct dns_zone **, const char *, int);
2317 int dns_zone_reference (struct dns_zone **,
2318 struct dns_zone *, const char *, int);
2321 #define DEFAULT_TIME_FORMAT 0
2322 #define LOCAL_TIME_FORMAT 1
2323 extern int db_time_format;
2324 char *quotify_string (const char *, const char *, int);
2325 char *quotify_buf (const unsigned char *, unsigned, const char *, int);
2326 char *print_base64 (const unsigned char *, unsigned, const char *, int);
2327 char *print_hw_addr (const int, const int, const unsigned char *);
2328 void print_lease (struct lease *);
2329 void dump_raw (const unsigned char *, unsigned);
2330 void dump_packet_option (struct option_cache *, struct packet *,
2331 struct lease *, struct client_state *,
2332 struct option_state *, struct option_state *,
2333 struct binding_scope **, struct universe *, void *);
2334 void dump_packet (struct packet *);
2335 void hash_dump (struct hash_table *);
2336 char *print_hex (unsigned, const u_int8_t *, unsigned, unsigned);
2337 void print_hex_only (unsigned, const u_int8_t *, unsigned, char *);
2338 void print_hex_or_string (unsigned, const u_int8_t *, unsigned, char *);
2339 #define print_hex_1(len, data, limit) print_hex(len, data, limit, 0)
2340 #define print_hex_2(len, data, limit) print_hex(len, data, limit, 1)
2341 #define print_hex_3(len, data, limit) print_hex(len, data, limit, 2)
2342 char *print_dotted_quads (unsigned, const u_int8_t *);
2343 char *print_dec_1 (unsigned long);
2344 char *print_dec_2 (unsigned long);
2345 void print_expression (const char *, struct expression *);
2346 int token_print_indent_concat (FILE *, int, int,
2347 const char *, const char *, ...);
2348 int token_indent_data_string (FILE *, int, int, const char *, const char *,
2349 struct data_string *);
2350 int token_print_indent (FILE *, int, int,
2351 const char *, const char *, const char *);
2352 void indent_spaces (FILE *, int);
2353 #if defined (NSUPDATE)
2354 void print_dns_status (int, struct dhcp_ddns_cb *, isc_result_t);
2356 const char *print_time(TIME);
2358 void get_hw_addr(const char *name, struct hardware *hw);
2361 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
2362 || defined (USE_SOCKET_FALLBACK)
2363 int if_register_socket(struct interface_info *, int, int *);
2366 #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND)
2367 void if_reinitialize_fallback (struct interface_info *);
2368 void if_register_fallback (struct interface_info *);
2369 ssize_t send_fallback (struct interface_info *,
2370 struct packet *, struct dhcp_packet *, size_t,
2372 struct sockaddr_in *, struct hardware *);
2373 ssize_t send_fallback6(struct interface_info *, struct packet *,
2374 struct dhcp_packet *, size_t, struct in6_addr,
2375 struct sockaddr_in6 *, struct hardware *);
2378 #ifdef USE_SOCKET_SEND
2379 void if_reinitialize_send (struct interface_info *);
2380 void if_register_send (struct interface_info *);
2381 void if_deregister_send (struct interface_info *);
2382 ssize_t send_packet (struct interface_info *,
2383 struct packet *, struct dhcp_packet *, size_t,
2385 struct sockaddr_in *, struct hardware *);
2387 ssize_t send_packet6(struct interface_info *, const unsigned char *, size_t,
2388 struct sockaddr_in6 *);
2389 #ifdef USE_SOCKET_RECEIVE
2390 void if_reinitialize_receive (struct interface_info *);
2391 void if_register_receive (struct interface_info *);
2392 void if_deregister_receive (struct interface_info *);
2393 ssize_t receive_packet (struct interface_info *,
2394 unsigned char *, size_t,
2395 struct sockaddr_in *, struct hardware *);
2398 #if defined (USE_SOCKET_FALLBACK)
2399 isc_result_t fallback_discard (omapi_object_t *);
2402 #if defined (USE_SOCKET_SEND)
2403 int can_unicast_without_arp (struct interface_info *);
2404 int can_receive_unicast_unconfigured (struct interface_info *);
2405 int supports_multiple_interfaces (struct interface_info *);
2406 void maybe_setup_fallback (void);
2409 void if_register6(struct interface_info *info, int do_multicast);
2410 ssize_t receive_packet6(struct interface_info *interface,
2411 unsigned char *buf, size_t len,
2412 struct sockaddr_in6 *from, struct in6_addr *to_addr,
2413 unsigned int *if_index);
2414 void if_deregister6(struct interface_info *info);
2418 #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
2419 int if_register_bpf (struct interface_info *);
2422 void if_reinitialize_send (struct interface_info *);
2423 void if_register_send (struct interface_info *);
2424 void if_deregister_send (struct interface_info *);
2425 ssize_t send_packet (struct interface_info *,
2426 struct packet *, struct dhcp_packet *, size_t,
2428 struct sockaddr_in *, struct hardware *);
2430 #ifdef USE_BPF_RECEIVE
2431 void if_reinitialize_receive (struct interface_info *);
2432 void if_register_receive (struct interface_info *);
2433 void if_deregister_receive (struct interface_info *);
2434 ssize_t receive_packet (struct interface_info *,
2435 unsigned char *, size_t,
2436 struct sockaddr_in *, struct hardware *);
2438 #if defined (USE_BPF_SEND)
2439 int can_unicast_without_arp (struct interface_info *);
2440 int can_receive_unicast_unconfigured (struct interface_info *);
2441 int supports_multiple_interfaces (struct interface_info *);
2442 void maybe_setup_fallback (void);
2446 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
2447 int if_register_lpf (struct interface_info *);
2450 void if_reinitialize_send (struct interface_info *);
2451 void if_register_send (struct interface_info *);
2452 void if_deregister_send (struct interface_info *);
2453 ssize_t send_packet (struct interface_info *,
2454 struct packet *, struct dhcp_packet *, size_t,
2456 struct sockaddr_in *, struct hardware *);
2458 #ifdef USE_LPF_RECEIVE
2459 void if_reinitialize_receive (struct interface_info *);
2460 void if_register_receive (struct interface_info *);
2461 void if_deregister_receive (struct interface_info *);
2462 ssize_t receive_packet (struct interface_info *,
2463 unsigned char *, size_t,
2464 struct sockaddr_in *, struct hardware *);
2466 #if defined (USE_LPF_SEND)
2467 int can_unicast_without_arp (struct interface_info *);
2468 int can_receive_unicast_unconfigured (struct interface_info *);
2469 int supports_multiple_interfaces (struct interface_info *);
2470 void maybe_setup_fallback (void);
2474 #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
2475 int if_register_nit (struct interface_info *);
2479 void if_reinitialize_send (struct interface_info *);
2480 void if_register_send (struct interface_info *);
2481 void if_deregister_send (struct interface_info *);
2482 ssize_t send_packet (struct interface_info *,
2483 struct packet *, struct dhcp_packet *, size_t,
2485 struct sockaddr_in *, struct hardware *);
2487 #ifdef USE_NIT_RECEIVE
2488 void if_reinitialize_receive (struct interface_info *);
2489 void if_register_receive (struct interface_info *);
2490 void if_deregister_receive (struct interface_info *);
2491 ssize_t receive_packet (struct interface_info *,
2492 unsigned char *, size_t,
2493 struct sockaddr_in *, struct hardware *);
2495 #if defined (USE_NIT_SEND)
2496 int can_unicast_without_arp (struct interface_info *);
2497 int can_receive_unicast_unconfigured (struct interface_info *);
2498 int supports_multiple_interfaces (struct interface_info *);
2499 void maybe_setup_fallback (void);
2503 #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
2504 int if_register_dlpi (struct interface_info *);
2507 #ifdef USE_DLPI_SEND
2508 int can_unicast_without_arp (struct interface_info *);
2509 int can_receive_unicast_unconfigured (struct interface_info *);
2510 void if_reinitialize_send (struct interface_info *);
2511 void if_register_send (struct interface_info *);
2512 void if_deregister_send (struct interface_info *);
2513 ssize_t send_packet (struct interface_info *,
2514 struct packet *, struct dhcp_packet *, size_t,
2516 struct sockaddr_in *, struct hardware *);
2517 int supports_multiple_interfaces (struct interface_info *);
2518 void maybe_setup_fallback (void);
2520 #ifdef USE_DLPI_RECEIVE
2521 void if_reinitialize_receive (struct interface_info *);
2522 void if_register_receive (struct interface_info *);
2523 void if_deregister_receive (struct interface_info *);
2524 ssize_t receive_packet (struct interface_info *,
2525 unsigned char *, size_t,
2526 struct sockaddr_in *, struct hardware *);
2532 void if_reinitialize_send (struct interface_info *);
2533 void if_register_send (struct interface_info *);
2534 void if_deregister_send (struct interface_info *);
2535 ssize_t send_packet (struct interface_info *, struct packet *,
2536 struct dhcp_packet *, size_t, struct in_addr,
2537 struct sockaddr_in *, struct hardware *);
2538 int can_unicast_without_arp (struct interface_info *);
2539 int can_receive_unicast_unconfigured (struct interface_info *);
2540 int supports_multiple_interfaces (struct interface_info *);
2541 void maybe_setup_fallback (void);
2545 extern struct interface_info *interfaces,
2546 *dummy_interfaces, *fallback_interface;
2547 extern struct protocol *protocols;
2548 extern int quiet_interface_discovery;
2549 isc_result_t interface_setup (void);
2550 void interface_trace_setup (void);
2552 extern struct in_addr limited_broadcast;
2553 extern int local_family;
2554 extern struct in_addr local_address;
2555 extern struct in6_addr local_address6;
2557 extern u_int16_t local_port;
2558 extern u_int16_t remote_port;
2559 extern int (*dhcp_interface_setup_hook) (struct interface_info *,
2561 extern int (*dhcp_interface_discovery_hook) (struct interface_info *);
2562 extern isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *);
2564 extern void (*bootp_packet_handler) (struct interface_info *,
2565 struct dhcp_packet *, unsigned,
2567 struct iaddr, struct hardware *);
2568 extern void (*dhcpv6_packet_handler)(struct interface_info *,
2570 int, const struct iaddr *, isc_boolean_t);
2571 extern struct timeout *timeouts;
2572 extern omapi_object_type_t *dhcp_type_interface;
2573 #if defined (TRACING)
2574 extern trace_type_t *interface_trace;
2575 extern trace_type_t *inpacket_trace;
2576 extern trace_type_t *outpacket_trace;
2578 extern struct interface_info **interface_vector;
2579 extern int interface_count;
2580 extern int interface_max;
2581 isc_result_t interface_initialize(omapi_object_t *, const char *, int);
2582 void discover_interfaces(int);
2583 int setup_fallback (struct interface_info **, const char *, int);
2584 int if_readsocket (omapi_object_t *);
2585 void reinitialize_interfaces (void);
2588 void set_time(TIME);
2589 struct timeval *process_outstanding_timeouts (struct timeval *);
2590 void dispatch (void);
2591 isc_result_t got_one(omapi_object_t *);
2592 isc_result_t got_one_v6(omapi_object_t *);
2593 isc_result_t interface_set_value (omapi_object_t *, omapi_object_t *,
2594 omapi_data_string_t *, omapi_typed_data_t *);
2595 isc_result_t interface_get_value (omapi_object_t *, omapi_object_t *,
2596 omapi_data_string_t *, omapi_value_t **);
2597 isc_result_t interface_destroy (omapi_object_t *, const char *, int);
2598 isc_result_t interface_signal_handler (omapi_object_t *,
2599 const char *, va_list);
2600 isc_result_t interface_stuff_values (omapi_object_t *,
2604 void add_timeout (struct timeval *, void (*) (void *), void *,
2605 tvref_t, tvunref_t);
2606 void cancel_timeout (void (*) (void *), void *);
2607 void cancel_all_timeouts (void);
2608 void relinquish_timeouts (void);
2610 OMAPI_OBJECT_ALLOC_DECL (interface,
2611 struct interface_info, dhcp_type_interface)
2614 extern char *default_option_format;
2615 extern struct universe dhcp_universe;
2616 extern struct universe dhcpv6_universe;
2617 extern struct universe nwip_universe;
2618 extern struct universe fqdn_universe;
2619 extern struct universe vsio_universe;
2620 extern int dhcp_option_default_priority_list [];
2621 extern int dhcp_option_default_priority_list_count;
2622 extern const char *hardware_types [256];
2623 extern int universe_count, universe_max;
2624 extern struct universe **universes;
2625 extern universe_hash_t *universe_hash;
2626 void initialize_common_option_spaces (void);
2627 extern struct universe *config_universe;
2630 #if defined (FAILOVER_PROTOCOL)
2631 extern failover_option_t null_failover_option;
2632 extern failover_option_t skip_failover_option;
2633 extern struct failover_option_info ft_options [];
2634 extern u_int32_t fto_allowed [];
2635 extern int ft_sizes [];
2636 extern const char *dhcp_flink_state_names [];
2638 extern const char *binding_state_names [];
2640 extern struct universe agent_universe;
2641 extern struct universe server_universe;
2643 extern struct enumeration ddns_styles;
2644 extern struct enumeration syslog_enum;
2645 void initialize_server_option_spaces (void);
2648 struct iaddr subnet_number (struct iaddr, struct iaddr);
2649 struct iaddr ip_addr (struct iaddr, struct iaddr, u_int32_t);
2650 struct iaddr broadcast_addr (struct iaddr, struct iaddr);
2651 u_int32_t host_addr (struct iaddr, struct iaddr);
2652 int addr_eq (struct iaddr, struct iaddr);
2653 int addr_match(struct iaddr *, struct iaddrmatch *);
2654 int addr_cmp(const struct iaddr *a1, const struct iaddr *a2);
2655 int addr_or(struct iaddr *result,
2656 const struct iaddr *a1, const struct iaddr *a2);
2657 int addr_and(struct iaddr *result,
2658 const struct iaddr *a1, const struct iaddr *a2);
2659 isc_boolean_t is_cidr_mask_valid(const struct iaddr *addr, int bits);
2660 isc_result_t range2cidr(struct iaddrcidrnetlist **result,
2661 const struct iaddr *lo, const struct iaddr *hi);
2662 isc_result_t free_iaddrcidrnetlist(struct iaddrcidrnetlist **result);
2663 const char *piaddr (struct iaddr);
2664 char *piaddrmask(struct iaddr *, struct iaddr *);
2665 char *piaddrcidr(const struct iaddr *, unsigned int);
2666 u_int16_t validate_port(char *);
2671 extern int wanted_ia_na;
2672 extern int wanted_ia_ta;
2673 extern int wanted_ia_pd;
2675 extern const char *path_dhclient_conf;
2676 extern const char *path_dhclient_db;
2677 extern const char *path_dhclient_pid;
2678 extern char *path_dhclient_script;
2679 extern int interfaces_requested;
2680 extern struct data_string default_duid;
2681 extern int duid_type;
2683 extern struct client_config top_level_config;
2685 void dhcpoffer (struct packet *);
2686 void dhcpack (struct packet *);
2687 void dhcpnak (struct packet *);
2689 void send_discover (void *);
2690 void send_request (void *);
2691 void send_release (void *);
2692 void send_decline (void *);
2694 void state_reboot (void *);
2695 void state_init (void *);
2696 void state_selecting (void *);
2697 void state_requesting (void *);
2698 void state_bound (void *);
2699 void state_stop (void *);
2700 void state_panic (void *);
2702 void bind_lease (struct client_state *);
2704 void make_client_options (struct client_state *,
2705 struct client_lease *, u_int8_t *,
2706 struct option_cache *, struct iaddr *,
2707 struct option **, struct option_state **);
2708 void make_discover (struct client_state *, struct client_lease *);
2709 void make_request (struct client_state *, struct client_lease *);
2710 void make_decline (struct client_state *, struct client_lease *);
2711 void make_release (struct client_state *, struct client_lease *);
2713 void destroy_client_lease (struct client_lease *);
2714 void rewrite_client_leases (void);
2715 void write_lease_option (struct option_cache *, struct packet *,
2716 struct lease *, struct client_state *,
2717 struct option_state *, struct option_state *,
2718 struct binding_scope **, struct universe *, void *);
2719 int write_client_lease (struct client_state *, struct client_lease *, int, int);
2720 isc_result_t write_client6_lease(struct client_state *client,
2721 struct dhc6_lease *lease,
2722 int rewrite, int sync);
2723 int dhcp_option_ev_name (char *, size_t, struct option *);
2725 void script_init (struct client_state *, const char *,
2726 struct string_list *);
2727 void client_option_envadd (struct option_cache *, struct packet *,
2728 struct lease *, struct client_state *,
2729 struct option_state *, struct option_state *,
2730 struct binding_scope **, struct universe *, void *);
2731 void script_write_params (struct client_state *, const char *,
2732 struct client_lease *);
2733 int script_go (struct client_state *);
2734 void client_envadd (struct client_state *,
2735 const char *, const char *, const char *, ...)
2736 __attribute__((__format__(__printf__,4,5)));
2738 struct client_lease *packet_to_lease (struct packet *, struct client_state *);
2739 void go_daemon (void);
2740 void write_client_pid_file (void);
2741 void client_location_changed (void);
2742 void do_release (struct client_state *);
2743 int dhclient_interface_shutdown_hook (struct interface_info *);
2744 int dhclient_interface_discovery_hook (struct interface_info *);
2745 isc_result_t dhclient_interface_startup_hook (struct interface_info *);
2746 void dhclient_schedule_updates(struct client_state *client,
2747 struct iaddr *addr, int offset);
2748 void client_dns_update_timeout (void *cp);
2749 isc_result_t client_dns_update(struct client_state *client,
2750 dhcp_ddns_cb_t *ddns_cb);
2751 void client_dns_remove(struct client_state *client, struct iaddr *addr);
2753 void dhcpv4_client_assignments(void);
2754 void dhcpv6_client_assignments(void);
2757 void form_duid(struct data_string *duid, const char *file, int line);
2758 void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
2759 void start_init6(struct client_state *client);
2760 void start_info_request6(struct client_state *client);
2761 void start_confirm6(struct client_state *client);
2762 void start_release6(struct client_state *client);
2763 void start_selecting6(struct client_state *client);
2764 void unconfigure6(struct client_state *client, const char *reason);
2767 int write_lease (struct lease *);
2768 int write_host (struct host_decl *);
2769 int write_server_duid(void);
2770 #if defined (FAILOVER_PROTOCOL)
2771 int write_failover_state (dhcp_failover_state_t *);
2773 int db_printable (const unsigned char *);
2774 int db_printable_len (const unsigned char *, unsigned);
2775 isc_result_t write_named_billing_class(const void *, unsigned, void *);
2776 void write_billing_classes (void);
2777 int write_billing_class (struct class *);
2778 void commit_leases_timeout (void *);
2779 void commit_leases_readerdry(void *);
2780 int commit_leases (void);
2781 void db_startup (int);
2782 int new_lease_file (void);
2783 int group_writer (struct group_object *);
2784 int write_ia(const struct ia_xx *);
2787 u_int32_t checksum (unsigned char *, unsigned, u_int32_t);
2788 u_int32_t wrapsum (u_int32_t);
2789 void assemble_hw_header (struct interface_info *, unsigned char *,
2790 unsigned *, struct hardware *);
2791 void assemble_udp_ip_header (struct interface_info *, unsigned char *,
2792 unsigned *, u_int32_t, u_int32_t,
2793 u_int32_t, unsigned char *, unsigned);
2794 ssize_t decode_hw_header (struct interface_info *, unsigned char *,
2795 unsigned, struct hardware *);
2796 ssize_t decode_udp_ip_header (struct interface_info *, unsigned char *,
2797 unsigned, struct sockaddr_in *,
2798 unsigned, unsigned *);
2801 void assemble_ethernet_header (struct interface_info *, unsigned char *,
2802 unsigned *, struct hardware *);
2803 ssize_t decode_ethernet_header (struct interface_info *,
2805 unsigned, struct hardware *);
2808 void assemble_tr_header (struct interface_info *, unsigned char *,
2809 unsigned *, struct hardware *);
2810 ssize_t decode_tr_header (struct interface_info *,
2812 unsigned, struct hardware *);
2815 void convert_statement (struct parse *);
2816 void convert_host_statement (struct parse *, jrefproto);
2817 void convert_host_name (struct parse *, jrefproto);
2818 void convert_class_statement (struct parse *, jrefproto, int);
2819 void convert_class_decl (struct parse *, jrefproto);
2820 void convert_lease_time (struct parse *, jrefproto, char *);
2821 void convert_shared_net_statement (struct parse *, jrefproto);
2822 void convert_subnet_statement (struct parse *, jrefproto);
2823 void convert_subnet_decl (struct parse *, jrefproto);
2824 void convert_host_decl (struct parse *, jrefproto);
2825 void convert_hardware_decl (struct parse *, jrefproto);
2826 void convert_hardware_addr (struct parse *, jrefproto);
2827 void convert_filename_decl (struct parse *, jrefproto);
2828 void convert_servername_decl (struct parse *, jrefproto);
2829 void convert_ip_addr_or_hostname (struct parse *, jrefproto, int);
2830 void convert_fixed_addr_decl (struct parse *, jrefproto);
2831 void convert_option_decl (struct parse *, jrefproto);
2832 void convert_lease_statement (struct parse *, jrefproto);
2833 void convert_address_range (struct parse *, jrefproto);
2834 void convert_date (struct parse *, jrefproto, char *);
2835 void convert_numeric_aggregate (struct parse *, jrefproto, int, int, int, int);
2839 void add_route_direct (struct interface_info *, struct in_addr);
2840 void add_route_net (struct interface_info *, struct in_addr, struct in_addr);
2841 void add_route_default_gateway (struct interface_info *, struct in_addr);
2842 void remove_routes (struct in_addr);
2843 void remove_if_route (struct interface_info *, struct in_addr);
2844 void remove_all_if_routes (struct interface_info *);
2845 void set_netmask (struct interface_info *, struct in_addr);
2846 void set_broadcast_addr (struct interface_info *, struct in_addr);
2847 void set_ip_address (struct interface_info *, struct in_addr);
2850 isc_result_t read_client_conf (void);
2851 int read_client_conf_file (const char *,
2852 struct interface_info *, struct client_config *);
2853 void read_client_leases (void);
2854 void parse_client_statement (struct parse *, struct interface_info *,
2855 struct client_config *);
2856 int parse_X (struct parse *, u_int8_t *, unsigned);
2857 int parse_option_list (struct parse *, struct option ***);
2858 void parse_interface_declaration (struct parse *,
2859 struct client_config *, char *);
2860 int interface_or_dummy (struct interface_info **, const char *);
2861 void make_client_state (struct client_state **);
2862 void make_client_config (struct client_state *, struct client_config *);
2863 void parse_client_lease_statement (struct parse *, int);
2864 void parse_client_lease_declaration (struct parse *,
2865 struct client_lease *,
2866 struct interface_info **,
2867 struct client_state **);
2868 int parse_option_decl (struct option_cache **, struct parse *);
2869 void parse_string_list (struct parse *, struct string_list **, int);
2870 int parse_ip_addr (struct parse *, struct iaddr *);
2871 int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *);
2872 void parse_reject_statement (struct parse *, struct client_config *);
2875 OMAPI_OBJECT_ALLOC_DECL (icmp_state, struct icmp_state, dhcp_type_icmp)
2876 extern struct icmp_state *icmp_state;
2877 void icmp_startup (int, void (*) (struct iaddr, u_int8_t *, int));
2878 int icmp_readsocket (omapi_object_t *);
2879 int icmp_echorequest (struct iaddr *);
2880 isc_result_t icmp_echoreply (omapi_object_t *);
2883 #if defined (NSUPDATE)
2884 isc_result_t find_tsig_key (ns_tsig_key **, const char *, struct dns_zone *);
2885 void tkey_free (ns_tsig_key **);
2887 isc_result_t enter_dns_zone (struct dns_zone *);
2888 isc_result_t dns_zone_lookup (struct dns_zone **, const char *);
2889 int dns_zone_dereference (struct dns_zone **, const char *, int);
2890 #if defined (NSUPDATE)
2891 #define FIND_FORWARD 0
2892 #define FIND_REVERSE 1
2893 isc_result_t find_cached_zone (dhcp_ddns_cb_t *, int);
2894 void forget_zone (struct dns_zone **);
2895 void repudiate_zone (struct dns_zone **);
2896 //void cache_found_zone (ns_class, char *, struct in_addr *, int);
2897 int get_dhcid (struct data_string *, int, const u_int8_t *, unsigned);
2898 void dhcid_tolease (struct data_string *, struct data_string *);
2899 isc_result_t dhcid_fromlease (struct data_string *, struct data_string *);
2900 isc_result_t ddns_update_fwd(struct data_string *, struct iaddr,
2901 struct data_string *, unsigned long, unsigned,
2903 isc_result_t ddns_remove_fwd(struct data_string *,
2904 struct iaddr, struct data_string *);
2905 #endif /* NSUPDATE */
2908 extern char path_resolv_conf [];
2909 extern struct name_server *name_servers;
2910 extern struct domain_search_list *domains;
2912 void read_resolv_conf (TIME);
2913 struct name_server *first_name_server (void);
2916 #ifdef NEED_INET_ATON
2917 int inet_aton (const char *, struct in_addr *);
2921 extern int have_billing_classes;
2922 struct class unknown_class;
2923 struct class known_class;
2924 struct collection default_collection;
2925 struct collection *collections;
2926 extern struct executable_statement *default_classification_rules;
2928 void classification_setup (void);
2929 void classify_client (struct packet *);
2930 int check_collection (struct packet *, struct lease *, struct collection *);
2931 void classify (struct packet *, struct class *);
2932 isc_result_t unlink_class (struct class **class);
2933 isc_result_t find_class (struct class **, const char *,
2935 int unbill_class (struct lease *, struct class *);
2936 int bill_class (struct lease *, struct class *);
2939 int execute_statements (struct binding_value **result,
2940 struct packet *, struct lease *,
2941 struct client_state *,
2942 struct option_state *, struct option_state *,
2943 struct binding_scope **,
2944 struct executable_statement *);
2945 void execute_statements_in_scope (struct binding_value **result,
2946 struct packet *, struct lease *,
2947 struct client_state *,
2948 struct option_state *,
2949 struct option_state *,
2950 struct binding_scope **,
2951 struct group *, struct group *);
2952 int executable_statement_dereference (struct executable_statement **,
2954 void write_statements (FILE *, struct executable_statement *, int);
2955 int find_matching_case (struct executable_statement **,
2956 struct packet *, struct lease *, struct client_state *,
2957 struct option_state *, struct option_state *,
2958 struct binding_scope **,
2959 struct expression *, struct executable_statement *);
2960 int executable_statement_foreach (struct executable_statement *,
2961 int (*) (struct executable_statement *,
2962 void *, int), void *, int);
2965 extern omapi_object_type_t *dhcp_type_group;
2966 extern omapi_object_type_t *dhcp_type_shared_network;
2967 extern omapi_object_type_t *dhcp_type_subnet;
2968 extern omapi_object_type_t *dhcp_type_control;
2969 extern dhcp_control_object_t *dhcp_control_object;
2971 void dhcp_common_objects_setup (void);
2973 isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *,
2974 omapi_data_string_t *,
2975 omapi_typed_data_t *);
2976 isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *,
2977 omapi_data_string_t *,
2979 isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int);
2980 isc_result_t dhcp_group_signal_handler (omapi_object_t *,
2981 const char *, va_list);
2982 isc_result_t dhcp_group_stuff_values (omapi_object_t *,
2985 isc_result_t dhcp_group_lookup (omapi_object_t **,
2986 omapi_object_t *, omapi_object_t *);
2987 isc_result_t dhcp_group_create (omapi_object_t **,
2989 isc_result_t dhcp_group_remove (omapi_object_t *,
2992 isc_result_t dhcp_control_set_value (omapi_object_t *, omapi_object_t *,
2993 omapi_data_string_t *,
2994 omapi_typed_data_t *);
2995 isc_result_t dhcp_control_get_value (omapi_object_t *, omapi_object_t *,
2996 omapi_data_string_t *,
2998 isc_result_t dhcp_control_destroy (omapi_object_t *, const char *, int);
2999 isc_result_t dhcp_control_signal_handler (omapi_object_t *,
3000 const char *, va_list);
3001 isc_result_t dhcp_control_stuff_values (omapi_object_t *,
3004 isc_result_t dhcp_control_lookup (omapi_object_t **,
3005 omapi_object_t *, omapi_object_t *);
3006 isc_result_t dhcp_control_create (omapi_object_t **,
3008 isc_result_t dhcp_control_remove (omapi_object_t *,
3011 isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *,
3012 omapi_data_string_t *,
3013 omapi_typed_data_t *);
3014 isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *,
3015 omapi_data_string_t *,
3017 isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int);
3018 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *,
3019 const char *, va_list);
3020 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *,
3023 isc_result_t dhcp_subnet_lookup (omapi_object_t **,
3024 omapi_object_t *, omapi_object_t *);
3025 isc_result_t dhcp_subnet_create (omapi_object_t **,
3027 isc_result_t dhcp_subnet_remove (omapi_object_t *,
3030 isc_result_t dhcp_shared_network_set_value (omapi_object_t *,
3032 omapi_data_string_t *,
3033 omapi_typed_data_t *);
3034 isc_result_t dhcp_shared_network_get_value (omapi_object_t *,
3036 omapi_data_string_t *,
3038 isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int);
3039 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *,
3040 const char *, va_list);
3041 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *,
3044 isc_result_t dhcp_shared_network_lookup (omapi_object_t **,
3045 omapi_object_t *, omapi_object_t *);
3046 isc_result_t dhcp_shared_network_create (omapi_object_t **,
3048 isc_result_t dhcp_shared_network_remove (omapi_object_t *,
3052 extern int (*dhcp_interface_shutdown_hook) (struct interface_info *);
3054 extern omapi_object_type_t *dhcp_type_lease;
3055 extern omapi_object_type_t *dhcp_type_pool;
3056 extern omapi_object_type_t *dhcp_type_class;
3057 extern omapi_object_type_t *dhcp_type_subclass;
3059 #if defined (FAILOVER_PROTOCOL)
3060 extern omapi_object_type_t *dhcp_type_failover_state;
3061 extern omapi_object_type_t *dhcp_type_failover_link;
3062 extern omapi_object_type_t *dhcp_type_failover_listener;
3065 void dhcp_db_objects_setup (void);
3067 isc_result_t dhcp_lease_set_value (omapi_object_t *, omapi_object_t *,
3068 omapi_data_string_t *,
3069 omapi_typed_data_t *);
3070 isc_result_t dhcp_lease_get_value (omapi_object_t *, omapi_object_t *,
3071 omapi_data_string_t *,
3073 isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *, int);
3074 isc_result_t dhcp_lease_signal_handler (omapi_object_t *,
3075 const char *, va_list);
3076 isc_result_t dhcp_lease_stuff_values (omapi_object_t *,
3079 isc_result_t dhcp_lease_lookup (omapi_object_t **,
3080 omapi_object_t *, omapi_object_t *);
3081 isc_result_t dhcp_lease_create (omapi_object_t **,
3083 isc_result_t dhcp_lease_remove (omapi_object_t *,
3085 isc_result_t dhcp_host_set_value (omapi_object_t *, omapi_object_t *,
3086 omapi_data_string_t *,
3087 omapi_typed_data_t *);
3088 isc_result_t dhcp_host_get_value (omapi_object_t *, omapi_object_t *,
3089 omapi_data_string_t *,
3091 isc_result_t dhcp_host_destroy (omapi_object_t *, const char *, int);
3092 isc_result_t dhcp_host_signal_handler (omapi_object_t *,
3093 const char *, va_list);
3094 isc_result_t dhcp_host_stuff_values (omapi_object_t *,
3097 isc_result_t dhcp_host_lookup (omapi_object_t **,
3098 omapi_object_t *, omapi_object_t *);
3099 isc_result_t dhcp_host_create (omapi_object_t **,
3101 isc_result_t dhcp_host_remove (omapi_object_t *,
3103 isc_result_t dhcp_pool_set_value (omapi_object_t *, omapi_object_t *,
3104 omapi_data_string_t *,
3105 omapi_typed_data_t *);
3106 isc_result_t dhcp_pool_get_value (omapi_object_t *, omapi_object_t *,
3107 omapi_data_string_t *,
3109 isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *, int);
3110 isc_result_t dhcp_pool_signal_handler (omapi_object_t *,
3111 const char *, va_list);
3112 isc_result_t dhcp_pool_stuff_values (omapi_object_t *,
3115 isc_result_t dhcp_pool_lookup (omapi_object_t **,
3116 omapi_object_t *, omapi_object_t *);
3117 isc_result_t dhcp_pool_create (omapi_object_t **,
3119 isc_result_t dhcp_pool_remove (omapi_object_t *,
3121 isc_result_t dhcp_class_set_value (omapi_object_t *, omapi_object_t *,
3122 omapi_data_string_t *,
3123 omapi_typed_data_t *);
3124 isc_result_t dhcp_class_get_value (omapi_object_t *, omapi_object_t *,
3125 omapi_data_string_t *,
3127 isc_result_t dhcp_class_destroy (omapi_object_t *, const char *, int);
3128 isc_result_t dhcp_class_signal_handler (omapi_object_t *,
3129 const char *, va_list);
3130 isc_result_t dhcp_class_stuff_values (omapi_object_t *,
3133 isc_result_t dhcp_class_lookup (omapi_object_t **,
3134 omapi_object_t *, omapi_object_t *);
3135 isc_result_t dhcp_class_create (omapi_object_t **,
3137 isc_result_t dhcp_class_remove (omapi_object_t *,
3139 isc_result_t dhcp_subclass_set_value (omapi_object_t *, omapi_object_t *,
3140 omapi_data_string_t *,
3141 omapi_typed_data_t *);
3142 isc_result_t dhcp_subclass_get_value (omapi_object_t *, omapi_object_t *,
3143 omapi_data_string_t *,
3145 isc_result_t dhcp_subclass_destroy (omapi_object_t *, const char *, int);
3146 isc_result_t dhcp_subclass_signal_handler (omapi_object_t *,
3147 const char *, va_list);
3148 isc_result_t dhcp_subclass_stuff_values (omapi_object_t *,
3151 isc_result_t dhcp_subclass_lookup (omapi_object_t **,
3152 omapi_object_t *, omapi_object_t *);
3153 isc_result_t dhcp_subclass_create (omapi_object_t **,
3155 isc_result_t dhcp_subclass_remove (omapi_object_t *,
3157 isc_result_t dhcp_interface_set_value (omapi_object_t *,
3159 omapi_data_string_t *,
3160 omapi_typed_data_t *);
3161 isc_result_t dhcp_interface_get_value (omapi_object_t *,
3163 omapi_data_string_t *,
3165 isc_result_t dhcp_interface_destroy (omapi_object_t *,
3167 isc_result_t dhcp_interface_signal_handler (omapi_object_t *,
3170 isc_result_t dhcp_interface_stuff_values (omapi_object_t *,
3173 isc_result_t dhcp_interface_lookup (omapi_object_t **,
3176 isc_result_t dhcp_interface_create (omapi_object_t **,
3178 isc_result_t dhcp_interface_remove (omapi_object_t *,
3180 void interface_stash (struct interface_info *);
3181 void interface_snorf (struct interface_info *, int);
3183 isc_result_t binding_scope_set_value (struct binding_scope *, int,
3184 omapi_data_string_t *,
3185 omapi_typed_data_t *);
3186 isc_result_t binding_scope_get_value (omapi_value_t **,
3187 struct binding_scope *,
3188 omapi_data_string_t *);
3189 isc_result_t binding_scope_stuff_values (omapi_object_t *,
3190 struct binding_scope *);
3192 void register_eventhandler(struct eventqueue **, void (*handler)(void *));
3193 void unregister_eventhandler(struct eventqueue **, void (*handler)(void *));
3194 void trigger_event(struct eventqueue **);
3198 extern struct subnet *subnets;
3199 extern struct shared_network *shared_networks;
3200 extern host_hash_t *host_hw_addr_hash;
3201 extern host_hash_t *host_uid_hash;
3202 extern host_hash_t *host_name_hash;
3203 extern lease_id_hash_t *lease_uid_hash;
3204 extern lease_ip_hash_t *lease_ip_addr_hash;
3205 extern lease_id_hash_t *lease_hw_addr_hash;
3207 extern omapi_object_type_t *dhcp_type_host;
3209 extern int numclasseswritten;
3212 isc_result_t enter_class (struct class *, int, int);
3213 isc_result_t delete_class (struct class *, int);
3214 isc_result_t enter_host (struct host_decl *, int, int);
3215 isc_result_t delete_host (struct host_decl *, int);
3216 void change_host_uid(struct host_decl *host, const char *data, int len);
3217 int find_hosts_by_haddr (struct host_decl **, int,
3218 const unsigned char *, unsigned,
3220 int find_hosts_by_uid (struct host_decl **, const unsigned char *,
3221 unsigned, const char *, int);
3222 int find_hosts_by_option(struct host_decl **, struct packet *,
3223 struct option_state *, const char *, int);
3224 int find_host_for_network (struct subnet **, struct host_decl **,
3225 struct iaddr *, struct shared_network *);
3226 void new_address_range (struct parse *, struct iaddr, struct iaddr,
3227 struct subnet *, struct pool *,
3229 isc_result_t dhcp_lease_free (omapi_object_t *, const char *, int);
3230 isc_result_t dhcp_lease_get (omapi_object_t **, const char *, int);
3231 int find_grouped_subnet (struct subnet **, struct shared_network *,
3232 struct iaddr, const char *, int);
3233 int find_subnet(struct subnet **, struct iaddr, const char *, int);
3234 void enter_shared_network (struct shared_network *);
3235 void new_shared_network_interface (struct parse *,
3236 struct shared_network *,
3238 int subnet_inner_than(const struct subnet *, const struct subnet *, int);
3239 void enter_subnet (struct subnet *);
3240 void enter_lease (struct lease *);
3241 int supersede_lease (struct lease *, struct lease *, int, int, int);
3242 void make_binding_state_transition (struct lease *);
3243 int lease_copy (struct lease **, struct lease *, const char *, int);
3244 void release_lease (struct lease *, struct packet *);
3245 void abandon_lease (struct lease *, const char *);
3246 void dissociate_lease (struct lease *);
3247 void pool_timer (void *);
3248 int find_lease_by_uid (struct lease **, const unsigned char *,
3249 unsigned, const char *, int);
3250 int find_lease_by_hw_addr (struct lease **, const unsigned char *,
3251 unsigned, const char *, int);
3252 int find_lease_by_ip_addr (struct lease **, struct iaddr,
3254 void uid_hash_add (struct lease *);
3255 void uid_hash_delete (struct lease *);
3256 void hw_hash_add (struct lease *);
3257 void hw_hash_delete (struct lease *);
3258 int write_leases (void);
3259 int write_leases6(void);
3260 int lease_enqueue (struct lease *);
3261 isc_result_t lease_instantiate(const void *, unsigned, void *);
3262 void expire_all_pools (void);
3263 void dump_subnets (void);
3264 #if defined (DEBUG_MEMORY_LEAKAGE) || \
3265 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
3266 void free_everything (void);
3270 char *ddns_rev_name (struct lease *, struct lease_state *, struct packet *);
3271 char *ddns_fwd_name (struct lease *, struct lease_state *, struct packet *);
3272 int nsupdateA (const char *, const unsigned char *, u_int32_t, int);
3273 int nsupdatePTR (const char *, const unsigned char *, u_int32_t, int);
3274 void nsupdate (struct lease *, struct lease_state *, struct packet *, int);
3275 int updateA (const struct data_string *, const struct data_string *,
3276 unsigned int, struct lease *);
3277 int updatePTR (const struct data_string *, const struct data_string *,
3278 unsigned int, struct lease *);
3279 int deleteA (const struct data_string *, const struct data_string *,
3281 int deletePTR (const struct data_string *, const struct data_string *,
3285 #if defined (FAILOVER_PROTOCOL)
3286 extern dhcp_failover_state_t *failover_states;
3287 void dhcp_failover_startup (void);
3288 int dhcp_failover_write_all_states (void);
3289 isc_result_t enter_failover_peer (dhcp_failover_state_t *);
3290 isc_result_t find_failover_peer (dhcp_failover_state_t **,
3291 const char *, const char *, int);
3292 isc_result_t dhcp_failover_link_initiate (omapi_object_t *);
3293 isc_result_t dhcp_failover_link_signal (omapi_object_t *,
3294 const char *, va_list);
3295 isc_result_t dhcp_failover_link_set_value (omapi_object_t *,
3297 omapi_data_string_t *,
3298 omapi_typed_data_t *);
3299 isc_result_t dhcp_failover_link_get_value (omapi_object_t *,
3301 omapi_data_string_t *,
3303 isc_result_t dhcp_failover_link_destroy (omapi_object_t *,
3305 isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *,
3308 isc_result_t dhcp_failover_listen (omapi_object_t *);
3310 isc_result_t dhcp_failover_listener_signal (omapi_object_t *,
3313 isc_result_t dhcp_failover_listener_set_value (omapi_object_t *,
3315 omapi_data_string_t *,
3316 omapi_typed_data_t *);
3317 isc_result_t dhcp_failover_listener_get_value (omapi_object_t *,
3319 omapi_data_string_t *,
3321 isc_result_t dhcp_failover_listener_destroy (omapi_object_t *,
3323 isc_result_t dhcp_failover_listener_stuff (omapi_object_t *,
3326 isc_result_t dhcp_failover_register (omapi_object_t *);
3327 isc_result_t dhcp_failover_state_signal (omapi_object_t *,
3328 const char *, va_list);
3329 isc_result_t dhcp_failover_state_transition (dhcp_failover_state_t *,
3331 isc_result_t dhcp_failover_set_service_state (dhcp_failover_state_t *state);
3332 isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *,
3333 enum failover_state);
3334 isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *,
3335 failover_message_t *);
3336 void dhcp_failover_pool_rebalance (void *);
3337 void dhcp_failover_pool_check (struct pool *);
3338 int dhcp_failover_state_pool_check (dhcp_failover_state_t *);
3339 void dhcp_failover_timeout (void *);
3340 void dhcp_failover_send_contact (void *);
3341 isc_result_t dhcp_failover_send_state (dhcp_failover_state_t *);
3342 isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *);
3343 int dhcp_failover_queue_update (struct lease *, int);
3344 int dhcp_failover_send_acks (dhcp_failover_state_t *);
3345 void dhcp_failover_toack_queue_timeout (void *);
3346 int dhcp_failover_queue_ack (dhcp_failover_state_t *, failover_message_t *msg);
3347 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *);
3348 isc_result_t dhcp_failover_state_set_value (omapi_object_t *,
3350 omapi_data_string_t *,
3351 omapi_typed_data_t *);
3352 void dhcp_failover_keepalive (void *);
3353 void dhcp_failover_reconnect (void *);
3354 void dhcp_failover_startup_timeout (void *);
3355 void dhcp_failover_link_startup_timeout (void *);
3356 void dhcp_failover_listener_restart (void *);
3357 void dhcp_failover_auto_partner_down(void *vs);
3358 isc_result_t dhcp_failover_state_get_value (omapi_object_t *,
3360 omapi_data_string_t *,
3362 isc_result_t dhcp_failover_state_destroy (omapi_object_t *,
3364 isc_result_t dhcp_failover_state_stuff (omapi_object_t *,
3367 isc_result_t dhcp_failover_state_lookup (omapi_object_t **,
3370 isc_result_t dhcp_failover_state_create (omapi_object_t **,
3372 isc_result_t dhcp_failover_state_remove (omapi_object_t *,
3374 int dhcp_failover_state_match (dhcp_failover_state_t *, u_int8_t *, unsigned);
3375 int dhcp_failover_state_match_by_name(dhcp_failover_state_t *,
3376 failover_option_t *);
3377 const char *dhcp_failover_reject_reason_print (int);
3378 const char *dhcp_failover_state_name_print (enum failover_state);
3379 const char *dhcp_failover_message_name (unsigned);
3380 const char *dhcp_failover_option_name (unsigned);
3381 failover_option_t *dhcp_failover_option_printf (unsigned, char *,
3385 __attribute__((__format__(__printf__,5,6)));
3386 failover_option_t *dhcp_failover_make_option (unsigned, char *,
3387 unsigned *, unsigned, ...);
3388 isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *,
3389 omapi_object_t *, int, u_int32_t, ...);
3390 isc_result_t dhcp_failover_send_connect (omapi_object_t *);
3391 isc_result_t dhcp_failover_send_connectack (omapi_object_t *,
3392 dhcp_failover_state_t *,
3394 isc_result_t dhcp_failover_send_disconnect (omapi_object_t *,
3396 isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *,
3398 isc_result_t dhcp_failover_send_bind_ack (dhcp_failover_state_t *,
3399 failover_message_t *,
3401 isc_result_t dhcp_failover_send_poolreq (dhcp_failover_state_t *);
3402 isc_result_t dhcp_failover_send_poolresp (dhcp_failover_state_t *, int);
3403 isc_result_t dhcp_failover_send_update_request (dhcp_failover_state_t *);
3404 isc_result_t dhcp_failover_send_update_request_all (dhcp_failover_state_t *);
3405 isc_result_t dhcp_failover_send_update_done (dhcp_failover_state_t *);
3406 isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *,
3407 failover_message_t *);
3408 isc_result_t dhcp_failover_process_bind_ack (dhcp_failover_state_t *,
3409 failover_message_t *);
3410 isc_result_t dhcp_failover_generate_update_queue (dhcp_failover_state_t *,
3412 isc_result_t dhcp_failover_process_update_request (dhcp_failover_state_t *,
3413 failover_message_t *);
3414 isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *,
3415 failover_message_t *);
3416 isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *,
3417 failover_message_t *);
3418 void ia_remove_all_lease(struct ia_xx *ia, const char *file, int line);
3419 void dhcp_failover_recover_done (void *);
3420 void failover_print (char *, unsigned *, unsigned, const char *);
3421 void update_partner (struct lease *);
3422 int load_balance_mine (struct packet *, dhcp_failover_state_t *);
3423 int peer_wants_lease (struct lease *);
3424 binding_state_t normal_binding_state_transition_check (struct lease *,
3425 dhcp_failover_state_t *,
3429 conflict_binding_state_transition_check (struct lease *,
3430 dhcp_failover_state_t *,
3431 binding_state_t, u_int32_t);
3432 int lease_mine_to_reallocate (struct lease *);
3434 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t,
3435 dhcp_type_failover_state)
3436 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener, dhcp_failover_listener_t,
3437 dhcp_type_failover_listener)
3438 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link, dhcp_failover_link_t,
3439 dhcp_type_failover_link)
3440 #endif /* FAILOVER_PROTOCOL */
3442 const char *binding_state_print (enum failover_state);
3445 #if defined(LDAP_CONFIGURATION)
3446 extern struct enumeration ldap_methods;
3447 #if defined (LDAP_USE_SSL)
3448 extern struct enumeration ldap_ssl_usage_enum;
3449 extern struct enumeration ldap_tls_reqcert_enum;
3450 extern struct enumeration ldap_tls_crlcheck_enum;
3452 isc_result_t ldap_read_config (void);
3453 int find_haddr_in_ldap (struct host_decl **, int, unsigned,
3454 const unsigned char *, const char *, int);
3455 int find_subclass_in_ldap (struct class *, struct class **,
3456 struct data_string *);
3460 HASH_FUNCTIONS_DECL(ia, unsigned char *, struct ia_xx, ia_hash_t)
3461 HASH_FUNCTIONS_DECL(iasubopt, struct in6_addr *, struct iasubopt,
3464 isc_result_t iasubopt_allocate(struct iasubopt **iasubopt,
3465 const char *file, int line);
3466 isc_result_t iasubopt_reference(struct iasubopt **iasubopt,
3467 struct iasubopt *src,
3468 const char *file, int line);
3469 isc_result_t iasubopt_dereference(struct iasubopt **iasubopt,
3470 const char *file, int line);
3472 isc_result_t ia_make_key(struct data_string *key, u_int32_t iaid,
3473 const char *duid, unsigned int duid_len,
3474 const char *file, int line);
3475 isc_result_t ia_allocate(struct ia_xx **ia, u_int32_t iaid,
3476 const char *duid, unsigned int duid_len,
3477 const char *file, int line);
3478 isc_result_t ia_reference(struct ia_xx **ia, struct ia_xx *src,
3479 const char *file, int line);
3480 isc_result_t ia_dereference(struct ia_xx **ia,
3481 const char *file, int line);
3482 isc_result_t ia_add_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt,
3483 const char *file, int line);
3484 void ia_remove_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt,
3485 const char *file, int line);
3486 isc_boolean_t ia_equal(const struct ia_xx *a, const struct ia_xx *b);
3488 isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
3489 const struct in6_addr *start_addr,
3490 int bits, int units,
3491 const char *file, int line);
3492 isc_result_t ipv6_pool_reference(struct ipv6_pool **pool,
3493 struct ipv6_pool *src,
3494 const char *file, int line);
3495 isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool,
3496 const char *file, int line);
3497 isc_result_t create_lease6(struct ipv6_pool *pool,
3498 struct iasubopt **addr,
3499 unsigned int *attempts,
3500 const struct data_string *uid,
3501 time_t soft_lifetime_end_time);
3502 isc_result_t add_lease6(struct ipv6_pool *pool,
3503 struct iasubopt *lease,
3504 time_t valid_lifetime_end_time);
3505 isc_result_t renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
3506 isc_result_t expire_lease6(struct iasubopt **leasep,
3507 struct ipv6_pool *pool, time_t now);
3508 isc_result_t release_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
3509 isc_result_t decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
3510 isc_boolean_t lease6_exists(const struct ipv6_pool *pool,
3511 const struct in6_addr *addr);
3512 isc_result_t mark_lease_unavailble(struct ipv6_pool *pool,
3513 const struct in6_addr *addr);
3515 isc_result_t create_prefix6(struct ipv6_pool *pool,
3516 struct iasubopt **pref,
3517 unsigned int *attempts,
3518 const struct data_string *uid,
3519 time_t soft_lifetime_end_time);
3520 isc_boolean_t prefix6_exists(const struct ipv6_pool *pool,
3521 const struct in6_addr *pref, u_int8_t plen);
3523 isc_result_t add_ipv6_pool(struct ipv6_pool *pool);
3524 isc_result_t find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type,
3525 const struct in6_addr *addr);
3526 isc_boolean_t ipv6_in_pool(const struct in6_addr *addr,
3527 const struct ipv6_pool *pool);
3529 isc_result_t renew_leases(struct ia_xx *ia);
3530 isc_result_t release_leases(struct ia_xx *ia);
3531 isc_result_t decline_leases(struct ia_xx *ia);
3532 void schedule_lease_timeout(struct ipv6_pool *pool);
3533 void schedule_all_ipv6_lease_timeouts();
3535 void mark_hosts_unavailable(void);
3536 void mark_phosts_unavailable(void);
3537 void mark_interfaces_unavailable(void);
3539 dhcp_ddns_cb_t *ddns_cb_alloc(const char *file, int line);
3540 void ddns_cb_free (dhcp_ddns_cb_t *ddns_cb, const char *file, int line);
3541 void ddns_cb_forget_zone (dhcp_ddns_cb_t *ddns_cb);
3543 //void *key_from_zone(struct dns_zone *zone);
3546 ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb);
3549 ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb);
3552 ddns_cancel(dhcp_ddns_cb_t *ddns_cb);
3554 #define MAX_ADDRESS_STRING_LEN \
3555 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))