00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00031 #include "config.h"
00032
00033 #ifndef __CYGWIN32__
00034 #include <sys/types.h>
00035 #include <netinet/in.h>
00036 #include <sys/socket.h>
00037 #include <sys/un.h>
00038 #include <arpa/inet.h>
00039 #include <errno.h>
00040
00041 #include <netdb.h>
00042 #else
00043 #define fd_set cygwin_fd_set
00044 #include <sys/types.h>
00045 #endif
00046 #include <stddef.h>
00047 #include <fcntl.h>
00048 #include <stdio.h>
00049 #include <unistd.h>
00050 #include <string.h>
00051 #include <stdlib.h>
00052 #include <sys/stat.h>
00053 #include <sys/mman.h>
00054 #include <ctype.h>
00055 #include <time.h>
00056
00057 #include <net/if.h>
00058 #undef FDDI
00059 #include <net/route.h>
00060 #include <net/if_arp.h>
00061 #if HAVE_NET_IF_DL_H
00062 # include <net/if_dl.h>
00063 #endif
00064
00065 #include <setjmp.h>
00066
00067 #include "cdefs.h"
00068 #include "osdep.h"
00069
00070 #include "arpa/nameser.h"
00071
00072 #include "minires.h"
00073
00074 struct hash_table;
00075 typedef struct hash_table group_hash_t;
00076 typedef struct hash_table universe_hash_t;
00077 typedef struct hash_table option_name_hash_t;
00078 typedef struct hash_table option_code_hash_t;
00079 typedef struct hash_table dns_zone_hash_t;
00080 typedef struct hash_table lease_ip_hash_t;
00081 typedef struct hash_table lease_id_hash_t;
00082 typedef struct hash_table host_hash_t;
00083 typedef struct hash_table class_hash_t;
00084
00085 typedef time_t TIME;
00086
00087 #ifndef EOL
00088 #define EOL '\n'
00089 #endif
00090
00091 #include <omapip/isclib.h>
00092 #include <omapip/result.h>
00093
00094 #include "dhcp.h"
00095 #include "dhcp6.h"
00096 #include "statement.h"
00097 #include "tree.h"
00098 #include "inet.h"
00099 #include "dhctoken.h"
00100
00101 #include <omapip/omapip_p.h>
00102
00103 #if defined(LDAP_CONFIGURATION)
00104 # include <ldap.h>
00105 # include <sys/utsname.h>
00106 #endif
00107
00108 #if !defined (BYTE_NAME_HASH_SIZE)
00109 # define BYTE_NAME_HASH_SIZE 401
00110 #endif
00111 #if !defined (BYTE_CODE_HASH_SIZE)
00112 # define BYTE_CODE_HASH_SIZE 254
00113 #endif
00114
00115
00116
00117
00118
00119
00120 #if !defined (WORD_NAME_HASH_SIZE)
00121 # define WORD_NAME_HASH_SIZE 20479
00122 #endif
00123 #if !defined (WORD_CODE_HASH_SIZE)
00124 # define WORD_CODE_HASH_SIZE 16384
00125 #endif
00126
00127
00128
00129
00130
00131
00132 #if !defined (QUAD_NAME_HASH_SIZE)
00133 # define QUAD_NAME_HASH_SIZE WORD_NAME_HASH_SIZE
00134 #endif
00135 #if !defined (QUAD_CODE_HASH_SIZE)
00136 # define QUAD_CODE_HASH_SIZE WORD_CODE_HASH_SIZE
00137 #endif
00138
00139 #if !defined (DNS_HASH_SIZE)
00140 # define DNS_HASH_SIZE 0
00141 #endif
00142
00143
00144 #if !defined (DEFAULT_SPACE_HASH_SIZE)
00145 # define DEFAULT_SPACE_HASH_SIZE 11
00146 #endif
00147
00148 #if !defined (NWIP_HASH_SIZE)
00149 # define NWIP_HASH_SIZE 17
00150 #endif
00151
00152 #if !defined (FQDN_HASH_SIZE)
00153 # define FQDN_HASH_SIZE 13
00154 #endif
00155
00156
00157
00158
00159 #if !defined (VIVCO_HASH_SIZE)
00160 # define VIVCO_HASH_SIZE 127
00161 #endif
00162
00163 #if !defined (VIVSO_HASH_SIZE)
00164 # define VIVSO_HASH_SIZE VIVCO_HASH_SIZE
00165 #endif
00166
00167 #if !defined (VSIO_HASH_SIZE)
00168 # define VSIO_HASH_SIZE VIVCO_HASH_SIZE
00169 #endif
00170
00171 #if !defined (VIV_ISC_HASH_SIZE)
00172 # define VIV_ISC_HASH_SIZE 3
00173 #endif
00174
00175 #if !defined (UNIVERSE_HASH_SIZE)
00176 # define UNIVERSE_HASH_SIZE 13
00177 #endif
00178
00179 #if !defined (GROUP_HASH_SIZE)
00180 # define GROUP_HASH_SIZE 0
00181 #endif
00182
00183
00184
00185 #if !defined (HOST_HASH_SIZE)
00186 # define HOST_HASH_SIZE 22501
00187 #endif
00188
00189
00190
00191
00192
00193
00194
00195 #if !defined (LEASE_HASH_SIZE)
00196 # define LEASE_HASH_SIZE 100003
00197 #endif
00198
00199
00200
00201
00202 #if !defined (SCLASS_HASH_SIZE)
00203 # define SCLASS_HASH_SIZE 12007
00204 #endif
00205
00206 #if !defined (AGENT_HASH_SIZE)
00207 # define AGENT_HASH_SIZE 11
00208 #endif
00209
00210
00211
00212
00213
00214
00215
00216 #if !defined (SERVER_HASH_SIZE)
00217 # define SERVER_HASH_SIZE (2*(sizeof(server_options) / sizeof(struct option)))
00218 #endif
00219
00220
00221
00222 #if !defined (OPTION_HASH_SIZE)
00223 # define OPTION_HASH_SIZE 17
00224 # define OPTION_HASH_PTWO 32
00225 # define OPTION_HASH_EXP 5
00226 #endif
00227
00228 #define compute_option_hash(x) \
00229 (((x) & (OPTION_HASH_PTWO - 1)) + \
00230 (((x) >> OPTION_HASH_EXP) & \
00231 (OPTION_HASH_PTWO - 1))) % OPTION_HASH_SIZE;
00232
00233 enum dhcp_shutdown_state {
00234 shutdown_listeners,
00235 shutdown_omapi_connections,
00236 shutdown_drop_omapi_connections,
00237 shutdown_dhcp,
00238 shutdown_done
00239 };
00240
00241
00242 typedef struct {
00243 u_int8_t codes [2];
00244 unsigned length;
00245 u_int8_t *data;
00246 } ddns_fqdn_t;
00247
00248 #include "failover.h"
00249
00250
00251
00252 struct parse {
00253 int lexline;
00254 int lexchar;
00255 char *token_line;
00256 char *prev_line;
00257 char *cur_line;
00258 const char *tlname;
00259 int eol_token;
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278 char line1 [81];
00279 char line2 [81];
00280 int lpos;
00281 int line;
00282 int tlpos;
00283 int tline;
00284 enum dhcp_token token;
00285 int ugflag;
00286 char *tval;
00287 int tlen;
00288 char tokbuf [1500];
00289
00290 int warnings_occurred;
00291 int file;
00292 char *inbuf;
00293 size_t bufix, buflen;
00294 size_t bufsiz;
00295
00296 struct parse *saved_state;
00297
00298 #if defined(LDAP_CONFIGURATION)
00299
00300
00301
00302
00303
00304
00305 int (*read_function)(struct parse *);
00306 #endif
00307 };
00308
00309
00310
00311 struct string_list {
00312 struct string_list *next;
00313 char string [1];
00314 };
00315
00316
00317 struct name_server {
00318 struct name_server *next;
00319 struct sockaddr_in addr;
00320 TIME rcdate;
00321 };
00322
00323
00324 struct domain_search_list {
00325 struct domain_search_list *next;
00326 char *domain;
00327 TIME rcdate;
00328 };
00329
00330
00331
00332
00333
00334 struct option_tag {
00335 struct option_tag *next;
00336 u_int8_t data [1];
00337 };
00338
00339
00340
00341
00342
00343 struct agent_options {
00344 struct agent_options *next;
00345 int length;
00346 struct option_tag *first;
00347 };
00348
00349 struct option_cache {
00350 int refcnt;
00351 struct option_cache *next;
00352 struct expression *expression;
00353 struct option *option;
00354 struct data_string data;
00355
00356 #define OPTION_HAD_NULLS 0x00000001
00357 u_int32_t flags;
00358 };
00359
00360 struct option_state {
00361 int refcnt;
00362 int universe_count;
00363 int site_universe;
00364 int site_code_min;
00365 void *universes [1];
00366 };
00367
00368
00369 struct packet {
00370 struct dhcp_packet *raw;
00371 int refcnt;
00372 unsigned packet_length;
00373 int packet_type;
00374
00375 unsigned char dhcpv6_msg_type;
00376
00377
00378 unsigned char dhcpv6_transaction_id[3];
00379
00380
00381 unsigned char dhcpv6_hop_count;
00382 struct in6_addr dhcpv6_link_address;
00383 struct in6_addr dhcpv6_peer_address;
00384
00385
00386 struct packet *dhcpv6_container_packet;
00387
00388 int options_valid;
00389 int client_port;
00390 struct iaddr client_addr;
00391 struct interface_info *interface;
00392
00393 struct hardware *haddr;
00394
00395
00396
00397
00398 u_int8_t *circuit_id;
00399 int circuit_id_len;
00400 u_int8_t *remote_id;
00401 int remote_id_len;
00402
00403 int got_requested_address;
00404
00405
00406 struct shared_network *shared_network;
00407 struct option_state *options;
00408
00409 #if !defined (PACKET_MAX_CLASSES)
00410 # define PACKET_MAX_CLASSES 5
00411 #endif
00412 int class_count;
00413 struct class *classes [PACKET_MAX_CLASSES];
00414
00415 int known;
00416 int authenticated;
00417
00418
00419
00420
00421
00422 isc_boolean_t agent_options_stashed;
00423
00424
00425
00426
00427
00428 isc_boolean_t unicast;
00429 };
00430
00431
00432
00433
00434
00435
00436
00437 #define HARDWARE_ADDR_LEN 20
00438
00439 struct hardware {
00440 u_int8_t hlen;
00441 u_int8_t hbuf[HARDWARE_ADDR_LEN + 1];
00442 };
00443
00444 #if defined(LDAP_CONFIGURATION)
00445 # define LDAP_BUFFER_SIZE 8192
00446 # define LDAP_METHOD_STATIC 0
00447 # define LDAP_METHOD_DYNAMIC 1
00448 #if defined (LDAP_USE_SSL)
00449 # define LDAP_SSL_OFF 0
00450 # define LDAP_SSL_ON 1
00451 # define LDAP_SSL_TLS 2
00452 # define LDAP_SSL_LDAPS 3
00453 #endif
00454
00455
00456 struct ldap_config_stack {
00457 LDAPMessage * res;
00458 LDAPMessage * ldent;
00459
00460 int close_brace;
00461
00462 int processed;
00463
00464
00465 struct ldap_config_stack *children;
00466 struct ldap_config_stack *next;
00467 };
00468 #endif
00469
00470 typedef enum {
00471 server_startup = 0,
00472 server_running = 1,
00473 server_shutdown = 2,
00474 server_hibernate = 3,
00475 server_awaken = 4
00476 } control_object_state_t;
00477
00478 typedef struct {
00479 OMAPI_OBJECT_PREAMBLE;
00480 control_object_state_t state;
00481 } dhcp_control_object_t;
00482
00483
00484 #define FTS_FREE 1
00485 #define FTS_ACTIVE 2
00486 #define FTS_EXPIRED 3
00487 #define FTS_RELEASED 4
00488 #define FTS_ABANDONED 5
00489 #define FTS_RESET 6
00490 #define FTS_BACKUP 7
00491 typedef u_int8_t binding_state_t;
00492
00493
00494 #define FTS_LAST FTS_BACKUP
00495
00496
00497
00498
00499
00500 struct on_star {
00501 struct executable_statement *on_expiry;
00502 struct executable_statement *on_commit;
00503 struct executable_statement *on_release;
00504 };
00505
00506
00507 struct lease {
00508 OMAPI_OBJECT_PREAMBLE;
00509 struct lease *next;
00510 struct lease *n_uid, *n_hw;
00511
00512 struct iaddr ip_addr;
00513 TIME starts, ends, sort_time;
00514 char *client_hostname;
00515 struct binding_scope *scope;
00516 struct host_decl *host;
00517 struct subnet *subnet;
00518 struct pool *pool;
00519 struct class *billing_class;
00520 struct option_chain_head *agent_options;
00521
00522
00523 struct on_star on_star;
00524
00525 unsigned char *uid;
00526 unsigned short uid_len;
00527 unsigned short uid_max;
00528 unsigned char uid_buf [7];
00529 struct hardware hardware_addr;
00530
00531 u_int8_t flags;
00532 # define STATIC_LEASE 1
00533 # define BOOTP_LEASE 2
00534 # define RESERVED_LEASE 4
00535 # define MS_NULL_TERMINATION 8
00536 # define ON_UPDATE_QUEUE 16
00537 # define ON_ACK_QUEUE 32
00538 # define ON_QUEUE (ON_UPDATE_QUEUE | ON_ACK_QUEUE)
00539 # define UNICAST_BROADCAST_HACK 64
00540 # define ON_DEFERRED_QUEUE 128
00541
00542
00543 # define PERSISTENT_FLAGS (ON_ACK_QUEUE | ON_UPDATE_QUEUE)
00544
00545 # define EPHEMERAL_FLAGS (MS_NULL_TERMINATION | \
00546 UNICAST_BROADCAST_HACK | \
00547 RESERVED_LEASE | \
00548 BOOTP_LEASE)
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563 binding_state_t binding_state;
00564 binding_state_t next_binding_state;
00565 binding_state_t desired_binding_state;
00566 binding_state_t rewind_binding_state;
00567
00568 struct lease_state *state;
00569
00570
00571
00572
00573
00574
00575
00576
00577 TIME tstp;
00578 TIME tsfp;
00579 TIME atsfp;
00580 TIME cltt;
00581 u_int32_t last_xid;
00582 struct lease *next_pending;
00583
00584
00585
00586
00587
00588
00589
00590 struct dhcp_ddns_cb *ddns_cb;
00591 };
00592
00593 struct lease_state {
00594 struct lease_state *next;
00595
00596 struct interface_info *ip;
00597
00598 struct packet *packet;
00599
00600 TIME offered_expiry;
00601
00602 struct option_state *options;
00603 struct data_string parameter_request_list;
00604 int max_message_size;
00605 unsigned char expiry[4], renewal[4], rebind[4];
00606 struct data_string filename, server_name;
00607 int got_requested_address;
00608 int got_server_identifier;
00609 struct shared_network *shared_network;
00610
00611
00612 u_int32_t xid;
00613 u_int16_t secs;
00614 u_int16_t bootp_flags;
00615 struct in_addr ciaddr;
00616 struct in_addr siaddr;
00617 struct in_addr giaddr;
00618 u_int8_t hops;
00619 u_int8_t offer;
00620 struct iaddr from;
00621 };
00622
00623 #define ROOT_GROUP 0
00624 #define HOST_DECL 1
00625 #define SHARED_NET_DECL 2
00626 #define SUBNET_DECL 3
00627 #define CLASS_DECL 4
00628 #define GROUP_DECL 5
00629 #define POOL_DECL 6
00630
00631
00632
00633 #define DISCOVER_RUNNING 0
00634 #define DISCOVER_SERVER 1
00635 #define DISCOVER_UNCONFIGURED 2
00636 #define DISCOVER_RELAY 3
00637 #define DISCOVER_REQUESTED 4
00638
00639
00640 #define DDNS_UPDATE_STYLE_NONE 0
00641 #define DDNS_UPDATE_STYLE_AD_HOC 1
00642 #define DDNS_UPDATE_STYLE_INTERIM 2
00643 #define DDNS_UPDATE_STYLE_STANDARD 3
00644
00645
00646
00647 #define SV_DEFAULT_LEASE_TIME 1
00648 #define SV_MAX_LEASE_TIME 2
00649 #define SV_MIN_LEASE_TIME 3
00650 #define SV_BOOTP_LEASE_CUTOFF 4
00651 #define SV_BOOTP_LEASE_LENGTH 5
00652 #define SV_BOOT_UNKNOWN_CLIENTS 6
00653 #define SV_DYNAMIC_BOOTP 7
00654 #define SV_ALLOW_BOOTP 8
00655 #define SV_ALLOW_BOOTING 9
00656 #define SV_ONE_LEASE_PER_CLIENT 10
00657 #define SV_GET_LEASE_HOSTNAMES 11
00658 #define SV_USE_HOST_DECL_NAMES 12
00659 #define SV_USE_LEASE_ADDR_FOR_DEFAULT_ROUTE 13
00660 #define SV_MIN_SECS 14
00661 #define SV_FILENAME 15
00662 #define SV_SERVER_NAME 16
00663 #define SV_NEXT_SERVER 17
00664 #define SV_AUTHORITATIVE 18
00665 #define SV_VENDOR_OPTION_SPACE 19
00666 #define SV_ALWAYS_REPLY_RFC1048 20
00667 #define SV_SITE_OPTION_SPACE 21
00668 #define SV_ALWAYS_BROADCAST 22
00669 #define SV_DDNS_DOMAIN_NAME 23
00670 #define SV_DDNS_HOST_NAME 24
00671 #define SV_DDNS_REV_DOMAIN_NAME 25
00672 #define SV_LEASE_FILE_NAME 26
00673 #define SV_PID_FILE_NAME 27
00674 #define SV_DUPLICATES 28
00675 #define SV_DECLINES 29
00676 #define SV_DDNS_UPDATES 30
00677 #define SV_OMAPI_PORT 31
00678 #define SV_LOCAL_PORT 32
00679 #define SV_LIMITED_BROADCAST_ADDRESS 33
00680 #define SV_REMOTE_PORT 34
00681 #define SV_LOCAL_ADDRESS 35
00682 #define SV_OMAPI_KEY 36
00683 #define SV_STASH_AGENT_OPTIONS 37
00684 #define SV_DDNS_TTL 38
00685 #define SV_DDNS_UPDATE_STYLE 39
00686 #define SV_CLIENT_UPDATES 40
00687 #define SV_UPDATE_OPTIMIZATION 41
00688 #define SV_PING_CHECKS 42
00689 #define SV_UPDATE_STATIC_LEASES 43
00690 #define SV_LOG_FACILITY 44
00691 #define SV_DO_FORWARD_UPDATES 45
00692 #define SV_PING_TIMEOUT 46
00693 #define SV_RESERVE_INFINITE 47
00694 #define SV_DDNS_CONFLICT_DETECT 48
00695 #define SV_LEASEQUERY 49
00696 #define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
00697 #define SV_DO_REVERSE_UPDATES 51
00698 #define SV_FQDN_REPLY 52
00699 #define SV_PREFER_LIFETIME 53
00700 #define SV_DHCPV6_LEASE_FILE_NAME 54
00701 #define SV_DHCPV6_PID_FILE_NAME 55
00702 #define SV_LIMIT_ADDRS_PER_IA 56
00703 #define SV_LIMIT_PREFS_PER_IA 57
00704 #define SV_DELAYED_ACK 58
00705 #define SV_MAX_ACK_DELAY 59
00706 #if defined(LDAP_CONFIGURATION)
00707 # define SV_LDAP_SERVER 60
00708 # define SV_LDAP_PORT 61
00709 # define SV_LDAP_USERNAME 62
00710 # define SV_LDAP_PASSWORD 63
00711 # define SV_LDAP_BASE_DN 64
00712 # define SV_LDAP_METHOD 65
00713 # define SV_LDAP_DEBUG_FILE 66
00714 # define SV_LDAP_DHCP_SERVER_CN 67
00715 # define SV_LDAP_REFERRALS 68
00716 #if defined (LDAP_USE_SSL)
00717 # define SV_LDAP_SSL 69
00718 # define SV_LDAP_TLS_REQCERT 70
00719 # define SV_LDAP_TLS_CA_FILE 71
00720 # define SV_LDAP_TLS_CA_DIR 72
00721 # define SV_LDAP_TLS_CERT 73
00722 # define SV_LDAP_TLS_KEY 74
00723 # define SV_LDAP_TLS_CRLCHECK 75
00724 # define SV_LDAP_TLS_CIPHERS 76
00725 # define SV_LDAP_TLS_RANDFILE 77
00726 #endif
00727 #endif
00728 #define SV_CACHE_THRESHOLD 78
00729 #define SV_DONT_USE_FSYNC 79
00730 #define SV_DDNS_LOCAL_ADDRESS4 80
00731 #define SV_DDNS_LOCAL_ADDRESS6 81
00732 #define SV_IGNORE_CLIENT_UIDS 82
00733
00734 #if !defined (DEFAULT_PING_TIMEOUT)
00735 # define DEFAULT_PING_TIMEOUT 1
00736 #endif
00737
00738 #if !defined (DEFAULT_DELAYED_ACK)
00739 # define DEFAULT_DELAYED_ACK 28
00740 #endif
00741
00742 #if !defined (DEFAULT_ACK_DELAY_SECS)
00743 # define DEFAULT_ACK_DELAY_SECS 0
00744 #endif
00745
00746 #if !defined (DEFAULT_ACK_DELAY_USECS)
00747 # define DEFAULT_ACK_DELAY_USECS 250000
00748 #endif
00749
00750 #if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
00751 # define DEFAULT_MIN_ACK_DELAY_USECS 10000
00752 #endif
00753
00754 #if !defined (DEFAULT_CACHE_THRESHOLD)
00755 # define DEFAULT_CACHE_THRESHOLD 25
00756 #endif
00757
00758 #if !defined (DEFAULT_DEFAULT_LEASE_TIME)
00759 # define DEFAULT_DEFAULT_LEASE_TIME 43200
00760 #endif
00761
00762 #if !defined (DEFAULT_MIN_LEASE_TIME)
00763 # define DEFAULT_MIN_LEASE_TIME 300
00764 #endif
00765
00766 #if !defined (DEFAULT_MAX_LEASE_TIME)
00767 # define DEFAULT_MAX_LEASE_TIME 86400
00768 #endif
00769
00770 #if !defined (DEFAULT_DDNS_TTL)
00771 # define DEFAULT_DDNS_TTL 3600
00772 #endif
00773 #if !defined (MAX_DEFAULT_DDNS_TTL)
00774 # define MAX_DEFAULT_DDNS_TTL 3600
00775 #endif
00776
00777 #if !defined (MIN_LEASE_WRITE)
00778 # define MIN_LEASE_WRITE 15
00779 #endif
00780
00781
00782
00783 #define CL_TIMEOUT 1
00784 #define CL_SELECT_INTERVAL 2
00785 #define CL_REBOOT_TIMEOUT 3
00786 #define CL_RETRY_INTERVAL 4
00787 #define CL_BACKOFF_CUTOFF 5
00788 #define CL_INITIAL_INTERVAL 6
00789 #define CL_BOOTP_POLICY 7
00790 #define CL_SCRIPT_NAME 8
00791 #define CL_REQUESTED_OPTIONS 9
00792 #define CL_REQUESTED_LEASE_TIME 10
00793 #define CL_SEND_OPTIONS 11
00794 #define CL_MEDIA 12
00795 #define CL_REJECT_LIST 13
00796
00797 #ifndef CL_DEFAULT_TIMEOUT
00798 # define CL_DEFAULT_TIMEOUT 60
00799 #endif
00800
00801 #ifndef CL_DEFAULT_SELECT_INTERVAL
00802 # define CL_DEFAULT_SELECT_INTERVAL 0
00803 #endif
00804
00805 #ifndef CL_DEFAULT_REBOOT_TIMEOUT
00806 # define CL_DEFAULT_REBOOT_TIMEOUT 10
00807 #endif
00808
00809 #ifndef CL_DEFAULT_RETRY_INTERVAL
00810 # define CL_DEFAULT_RETRY_INTERVAL 300
00811 #endif
00812
00813 #ifndef CL_DEFAULT_BACKOFF_CUTOFF
00814 # define CL_DEFAULT_BACKOFF_CUTOFF 120
00815 #endif
00816
00817 #ifndef CL_DEFAULT_INITIAL_INTERVAL
00818 # define CL_DEFAULT_INITIAL_INTERVAL 10
00819 #endif
00820
00821 #ifndef CL_DEFAULT_BOOTP_POLICY
00822 # define CL_DEFAULT_BOOTP_POLICY P_ACCEPT
00823 #endif
00824
00825 #ifndef CL_DEFAULT_REQUESTED_OPTIONS
00826 # define CL_DEFAULT_REQUESTED_OPTIONS \
00827 { DHO_SUBNET_MASK, \
00828 DHO_BROADCAST_ADDRESS, \
00829 DHO_TIME_OFFSET, \
00830 DHO_ROUTERS, \
00831 DHO_DOMAIN_NAME, \
00832 DHO_DOMAIN_NAME_SERVERS, \
00833 DHO_HOST_NAME }
00834 #endif
00835
00836 struct group_object {
00837 OMAPI_OBJECT_PREAMBLE;
00838
00839 struct group_object *n_dynamic;
00840 struct group *group;
00841 char *name;
00842 int flags;
00843 #define GROUP_OBJECT_DELETED 1
00844 #define GROUP_OBJECT_DYNAMIC 2
00845 #define GROUP_OBJECT_STATIC 4
00846 };
00847
00848
00849 struct group {
00850 struct group *next;
00851
00852 int refcnt;
00853 struct group_object *object;
00854 struct subnet *subnet;
00855 struct shared_network *shared_network;
00856 int authoritative;
00857 struct executable_statement *statements;
00858 };
00859
00860
00861 struct host_decl {
00862 OMAPI_OBJECT_PREAMBLE;
00863 struct host_decl *n_ipaddr;
00864 struct host_decl *n_dynamic;
00865 char *name;
00866 struct hardware interface;
00867 struct data_string client_identifier;
00868 struct option *host_id_option;
00869 struct data_string host_id;
00870
00871
00872
00873 struct option_cache *fixed_addr;
00874 struct iaddrcidrnetlist *fixed_prefix;
00875 struct group *group;
00876 struct group_object *named_group;
00877 struct data_string auth_key_id;
00878 int flags;
00879 #define HOST_DECL_DELETED 1
00880 #define HOST_DECL_DYNAMIC 2
00881 #define HOST_DECL_STATIC 4
00882
00883
00884
00885 int relays;
00886 };
00887
00888 struct permit {
00889 struct permit *next;
00890 enum {
00891 permit_unknown_clients,
00892 permit_known_clients,
00893 permit_authenticated_clients,
00894 permit_unauthenticated_clients,
00895 permit_all_clients,
00896 permit_dynamic_bootp_clients,
00897 permit_class,
00898 permit_after
00899 } type;
00900 struct class *class;
00901 TIME after;
00902 };
00903
00904 struct pool {
00905 OMAPI_OBJECT_PREAMBLE;
00906 struct pool *next;
00907 struct group *group;
00908 struct shared_network *shared_network;
00909 struct permit *permit_list;
00910 struct permit *prohibit_list;
00911 struct lease *active;
00912 struct lease *expired;
00913 struct lease *free;
00914 struct lease *backup;
00915 struct lease *abandoned;
00916 struct lease *reserved;
00917 TIME next_event_time;
00918 int lease_count;
00919 int free_leases;
00920 int backup_leases;
00921 int index;
00922 TIME valid_from;
00923 TIME valid_until;
00924
00925 #if defined (FAILOVER_PROTOCOL)
00926 dhcp_failover_state_t *failover_peer;
00927 #endif
00928 };
00929
00930 struct shared_network {
00931 OMAPI_OBJECT_PREAMBLE;
00932 struct shared_network *next;
00933 char *name;
00934
00935 #define SHARED_IMPLICIT 1
00936 int flags;
00937
00938 struct subnet *subnets;
00939 struct interface_info *interface;
00940 struct pool *pools;
00941 struct ipv6_pond *ipv6_pond;
00942 struct group *group;
00943 #if defined (FAILOVER_PROTOCOL)
00944 dhcp_failover_state_t *failover_peer;
00945 #endif
00946 };
00947
00948 struct subnet {
00949 OMAPI_OBJECT_PREAMBLE;
00950 struct subnet *next_subnet;
00951 struct subnet *next_sibling;
00952 struct shared_network *shared_network;
00953 struct interface_info *interface;
00954 struct iaddr interface_address;
00955 struct iaddr net;
00956 struct iaddr netmask;
00957 int prefix_len;
00958 struct group *group;
00959 };
00960
00961 struct collection {
00962 struct collection *next;
00963
00964 const char *name;
00965 struct class *classes;
00966 };
00967
00968
00969 #define CLASS_TYPE_VENDOR 0
00970 #define CLASS_TYPE_USER 1
00971 #define CLASS_TYPE_CLASS 2
00972 #define CLASS_TYPE_SUBCLASS 3
00973
00974
00975 struct class {
00976 OMAPI_OBJECT_PREAMBLE;
00977 struct class *nic;
00978 struct class *superclass;
00979 char *name;
00980
00981
00982 int lease_limit;
00983 int leases_consumed;
00984 struct lease **billed_leases;
00985
00986
00987
00988 int dirty;
00989
00990
00991 class_hash_t *hash;
00992 struct data_string hash_string;
00993
00994
00995 struct expression *expr;
00996
00997
00998
00999 struct expression *submatch;
01000 int spawning;
01001
01002 struct group *group;
01003
01004
01005 struct executable_statement *statements;
01006
01007 #define CLASS_DECL_DELETED 1
01008 #define CLASS_DECL_DYNAMIC 2
01009 #define CLASS_DECL_STATIC 4
01010 #define CLASS_DECL_SUBCLASS 8
01011
01012 int flags;
01013 };
01014
01015
01016 struct client_lease {
01017 struct client_lease *next;
01018 TIME expiry, renewal, rebind;
01019 struct iaddr address;
01020 char *server_name;
01021 char *filename;
01022 struct string_list *medium;
01023 struct auth_key *key;
01024
01025 unsigned int is_static : 1;
01026 unsigned int is_bootp: 1;
01027
01028 struct option_state *options;
01029 };
01030
01031
01032 struct dhc6_addr {
01033 struct dhc6_addr *next;
01034 struct iaddr address;
01035 u_int8_t plen;
01036
01037
01038 #define DHC6_ADDR_DEPREFFED 0x01
01039 #define DHC6_ADDR_EXPIRED 0x02
01040 u_int8_t flags;
01041
01042 TIME starts;
01043 u_int32_t preferred_life;
01044 u_int32_t max_life;
01045
01046 struct option_state *options;
01047 };
01048
01049 struct dhc6_ia {
01050 struct dhc6_ia *next;
01051 unsigned char iaid[4];
01052 u_int16_t ia_type;
01053
01054 TIME starts;
01055 u_int32_t renew;
01056 u_int32_t rebind;
01057 struct dhc6_addr *addrs;
01058
01059 struct option_state *options;
01060 };
01061
01062 struct dhc6_lease {
01063 struct dhc6_lease *next;
01064 struct data_string server_id;
01065
01066 isc_boolean_t released;
01067 int score;
01068 u_int8_t pref;
01069
01070 unsigned char dhcpv6_transaction_id[3];
01071 struct dhc6_ia *bindings;
01072
01073 struct option_state *options;
01074 };
01075
01076
01077 enum dhcp_state {
01078 S_REBOOTING = 1,
01079 S_INIT = 2,
01080 S_SELECTING = 3,
01081 S_REQUESTING = 4,
01082 S_BOUND = 5,
01083 S_RENEWING = 6,
01084 S_REBINDING = 7,
01085 S_STOPPED = 8,
01086 S_DECLINED = 9
01087 };
01088
01089
01090
01091 enum policy { P_IGNORE, P_ACCEPT, P_PREFER, P_REQUIRE, P_DONT };
01092
01093
01094 struct client_config {
01095
01096
01097
01098
01099 struct group *on_receipt;
01100
01101
01102
01103
01104 struct group *on_transmission;
01105
01106 struct option **required_options;
01107 struct option **requested_options;
01108
01109 TIME timeout;
01110
01111
01112 TIME initial_delay;
01113
01114 TIME initial_interval;
01115
01116 TIME retry_interval;
01117
01118
01119
01120 TIME select_interval;
01121
01122
01123 TIME reboot_timeout;
01124
01125
01126 TIME backoff_cutoff;
01127
01128
01129 u_int32_t requested_lease;
01130
01131 struct string_list *media;
01132 char *script_name;
01133 char *vendor_space_name;
01134 enum policy bootp_policy;
01135
01136
01137 enum policy auth_policy;
01138
01139
01140
01141 struct string_list *medium;
01142
01143 struct iaddrmatchlist *reject_list;
01144
01145 int omapi_port;
01146
01147
01148 int do_forward_update;
01149
01150
01151
01152 int bootp_broadcast_always;
01153
01154 };
01155
01156
01157
01158 struct client_state {
01159 struct client_state *next;
01160 struct interface_info *interface;
01161 char *name;
01162
01163
01164 struct client_config *config;
01165 struct string_list *env;
01166 int envc;
01167 struct option_state *sent_options;
01168 enum dhcp_state state;
01169 TIME last_write;
01170
01171
01172 struct client_lease *active;
01173 struct client_lease *new;
01174 struct client_lease *offered_leases;
01175 struct client_lease *leases;
01176 struct client_lease *alias;
01177
01178 struct iaddr destination;
01179 u_int32_t xid;
01180 u_int16_t secs;
01181 TIME first_sending;
01182 TIME interval;
01183 struct string_list *medium;
01184 struct dhcp_packet packet;
01185 unsigned packet_length;
01186
01187 struct iaddr requested_address;
01188
01189
01190 unsigned char dhcpv6_transaction_id[3];
01191 u_int8_t refresh_type;
01192
01193 struct dhc6_lease *active_lease;
01194 struct dhc6_lease *old_lease;
01195 struct dhc6_lease *advertised_leases;
01196 struct dhc6_lease *selected_lease;
01197 struct dhc6_lease *held_leases;
01198
01199 struct timeval start_time;
01200 u_int16_t elapsed;
01201 int txcount;
01202
01203
01204 TIME RT;
01205 TIME IRT;
01206 TIME MRC;
01207 TIME MRT;
01208 TIME MRD;
01209 TIME next_MRD;
01210
01211
01212
01213
01214
01215
01216 void (*v6_handler)(struct packet *, struct client_state *);
01217
01218
01219
01220
01221
01222
01223
01224 struct dhcp_ddns_cb *ddns_cb;
01225 };
01226
01227 struct envadd_state {
01228 struct client_state *client;
01229 const char *prefix;
01230 };
01231
01232 struct dns_update_state {
01233 struct client_state *client;
01234 struct iaddr address;
01235 int dns_update_timeout;
01236 };
01237
01238
01239
01240 struct interface_info {
01241 OMAPI_OBJECT_PREAMBLE;
01242 struct interface_info *next;
01243 struct shared_network *shared_network;
01244
01245 struct hardware hw_address;
01246 u_int8_t bcast_addr[20];
01247 struct in_addr *addresses;
01248
01249
01250 int address_count;
01251 int address_max;
01252 struct in6_addr *v6addresses;
01253
01254 int v6address_count;
01255
01256 int v6address_max;
01257
01258
01259 u_int8_t *circuit_id;
01260
01261 unsigned circuit_id_len;
01262
01263 u_int8_t *remote_id;
01264
01265 unsigned remote_id_len;
01266
01267 char name [IFNAMSIZ];
01268 int index;
01269 int rfdesc;
01270 int wfdesc;
01271
01272 unsigned char *rbuf;
01273 unsigned int rbuf_max;
01274 size_t rbuf_offset;
01275 size_t rbuf_len;
01276
01277 struct ifreq *ifp;
01278 int configured;
01279
01280
01281 u_int32_t flags;
01282 #define INTERFACE_REQUESTED 1
01283 #define INTERFACE_AUTOMATIC 2
01284 #define INTERFACE_RUNNING 4
01285 #define INTERFACE_DOWNSTREAM 8
01286 #define INTERFACE_UPSTREAM 16
01287 #define INTERFACE_STREAMS (INTERFACE_DOWNSTREAM | INTERFACE_UPSTREAM)
01288
01289
01290 struct client_state *client;
01291 # if defined(USE_DLPI_SEND) || defined(USE_DLPI_RECEIVE) || \
01292 defined(USE_DLPI_HWADDR)
01293 int dlpi_sap_length;
01294 struct hardware dlpi_broadcast_addr;
01295 # endif
01296 struct hardware anycast_mac_addr;
01297 };
01298
01299 struct hardware_link {
01300 struct hardware_link *next;
01301 char name [IFNAMSIZ];
01302 struct hardware address;
01303 };
01304
01305 struct leasequeue {
01306 struct leasequeue *prev;
01307 struct leasequeue *next;
01308 struct lease *lease;
01309 };
01310
01311 typedef void (*tvref_t)(void *, void *, const char *, int);
01312 typedef void (*tvunref_t)(void *, const char *, int);
01313 struct timeout {
01314 struct timeout *next;
01315 struct timeval when;
01316 void (*func) (void *);
01317 void *what;
01318 tvref_t ref;
01319 tvunref_t unref;
01320 isc_timer_t *isc_timeout;
01321 };
01322
01323 struct eventqueue {
01324 struct eventqueue *next;
01325 void (*handler)(void *);
01326 };
01327
01328 struct protocol {
01329 struct protocol *next;
01330 int fd;
01331 void (*handler) (struct protocol *);
01332 void *local;
01333 };
01334
01335 struct dns_query;
01336
01337 struct dns_wakeup {
01338 struct dns_wakeup *next;
01339 void (*func) (struct dns_query *);
01340 };
01341
01342 struct dns_question {
01343 u_int16_t type;
01344 u_int16_t class;
01345 unsigned char data [1];
01346 };
01347
01348 struct dns_answer {
01349 u_int16_t type;
01350 u_int16_t class;
01351 int count;
01352 unsigned char *answers[1];
01353 };
01354
01355 struct dns_query {
01356 struct dns_query *next;
01357 u_int32_t hash;
01358 TIME expiry;
01359
01360 u_int16_t id;
01361 caddr_t waiters;
01362
01363
01364 struct dns_question *question;
01365 struct dns_answer *answer;
01366
01367 unsigned char *query;
01368 unsigned len;
01369 int sent;
01370 struct dns_wakeup *wakeups;
01371
01372 struct name_server *next_server;
01373 int backoff;
01374 };
01375
01376 #define DNS_ZONE_ACTIVE 0
01377 #define DNS_ZONE_INACTIVE 1
01378 struct dns_zone {
01379 int refcnt;
01380 TIME timeout;
01381 char *name;
01382 struct option_cache *primary;
01383 struct option_cache *secondary;
01384 struct option_cache *primary6;
01385 struct option_cache *secondary6;
01386 struct auth_key *key;
01387 u_int16_t flags;
01388 };
01389
01390 struct icmp_state {
01391 OMAPI_OBJECT_PREAMBLE;
01392 int socket;
01393 void (*icmp_handler) (struct iaddr, u_int8_t *, int);
01394 };
01395
01396 #include "ctrace.h"
01397
01398
01399 typedef unsigned char option_mask [16];
01400
01401
01402 #define OPTION_ZERO(mask) (memset (mask, 0, 16))
01403 #define OPTION_SET(mask, bit) (mask [bit >> 8] |= (1 << (bit & 7)))
01404 #define OPTION_CLR(mask, bit) (mask [bit >> 8] &= ~(1 << (bit & 7)))
01405 #define OPTION_ISSET(mask, bit) (mask [bit >> 8] & (1 << (bit & 7)))
01406 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit))
01407
01408
01409
01410 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1))
01411
01412
01413 #ifdef DEBUG
01414 #undef _PATH_DHCPD_CONF
01415 #define _PATH_DHCPD_CONF "dhcpd.conf"
01416 #undef _PATH_DHCPD_DB
01417 #define _PATH_DHCPD_DB "dhcpd.leases"
01418 #undef _PATH_DHCPD6_DB
01419 #define _PATH_DHCPD6_DB "dhcpd6.leases"
01420 #undef _PATH_DHCPD_PID
01421 #define _PATH_DHCPD_PID "dhcpd.pid"
01422 #undef _PATH_DHCPD6_PID
01423 #define _PATH_DHCPD6_PID "dhcpd6.pid"
01424 #else
01425
01426 #ifndef _PATH_DHCPD_CONF
01427 #define _PATH_DHCPD_CONF "/etc/dhcp/dhcpd.conf"
01428 #endif
01429
01430 #ifndef _PATH_DHCPD_DB
01431 #define _PATH_DHCPD_DB LOCALSTATEDIR"/db/dhcpd.leases"
01432 #endif
01433
01434 #ifndef _PATH_DHCPD6_DB
01435 #define _PATH_DHCPD6_DB LOCALSTATEDIR"/db/dhcpd6.leases"
01436 #endif
01437
01438 #ifndef _PATH_DHCPD_PID
01439 #define _PATH_DHCPD_PID LOCALSTATEDIR"/run/dhcpd.pid"
01440 #endif
01441
01442 #ifndef _PATH_DHCPD6_PID
01443 #define _PATH_DHCPD6_PID LOCALSTATEDIR"/run/dhcpd6.pid"
01444 #endif
01445
01446 #endif
01447
01448 #ifndef _PATH_DHCLIENT_CONF
01449 #define _PATH_DHCLIENT_CONF "/etc/dhcp/dhclient.conf"
01450 #endif
01451
01452 #ifndef _PATH_DHCLIENT_SCRIPT
01453 #define _PATH_DHCLIENT_SCRIPT "/usr/sbin/dhclient-script"
01454 #endif
01455
01456 #ifndef _PATH_DHCLIENT_PID
01457 #define _PATH_DHCLIENT_PID LOCALSTATEDIR"/run/dhclient.pid"
01458 #endif
01459
01460 #ifndef _PATH_DHCLIENT6_PID
01461 #define _PATH_DHCLIENT6_PID LOCALSTATEDIR"/run/dhclient6.pid"
01462 #endif
01463
01464 #ifndef _PATH_DHCLIENT_DB
01465 #define _PATH_DHCLIENT_DB LOCALSTATEDIR"/db/dhclient.leases"
01466 #endif
01467
01468 #ifndef _PATH_DHCLIENT6_DB
01469 #define _PATH_DHCLIENT6_DB LOCALSTATEDIR"/db/dhclient6.leases"
01470 #endif
01471
01472 #ifndef _PATH_RESOLV_CONF
01473 #define _PATH_RESOLV_CONF "/etc/resolv.conf"
01474 #endif
01475
01476 #ifndef _PATH_DHCRELAY_PID
01477 #define _PATH_DHCRELAY_PID LOCALSTATEDIR"/run/dhcrelay.pid"
01478 #endif
01479
01480 #ifndef _PATH_DHCRELAY6_PID
01481 #define _PATH_DHCRELAY6_PID LOCALSTATEDIR"/run/dhcrelay6.pid"
01482 #endif
01483
01484 #ifndef DHCPD_LOG_FACILITY
01485 #define DHCPD_LOG_FACILITY LOG_DAEMON
01486 #endif
01487
01488 #define MAX_TIME 0x7fffffff
01489 #define MIN_TIME 0
01490
01491
01492 typedef struct hash_table ia_hash_t;
01493 typedef struct hash_table iasubopt_hash_t;
01494
01495
01496
01497 struct iasubopt {
01498 int refcnt;
01499 struct in6_addr addr;
01500 u_int8_t plen;
01501 binding_state_t state;
01502 struct binding_scope *scope;
01503 time_t hard_lifetime_end_time;
01504 time_t soft_lifetime_end_time;
01505 u_int32_t prefer;
01506 u_int32_t valid;
01507 struct ia_xx *ia;
01508 struct ipv6_pool *ipv6_pool;
01509
01510
01511
01512
01513 #define EXPIRED_IPV6_CLEANUP_TIME (60*60)
01514
01515 int heap_index;
01516
01517
01518
01519
01520
01521
01522
01523
01524 struct dhcp_ddns_cb *ddns_cb;
01525
01526
01527 struct on_star on_star;
01528 };
01529
01530 struct ia_xx {
01531 int refcnt;
01532 struct data_string iaid_duid;
01533 u_int16_t ia_type;
01534 int num_iasubopt;
01535 int max_iasubopt;
01536 time_t cltt;
01537 struct iasubopt **iasubopt;
01538 };
01539
01540 extern ia_hash_t *ia_na_active;
01541 extern ia_hash_t *ia_ta_active;
01542 extern ia_hash_t *ia_pd_active;
01543
01564 struct ipv6_pool {
01565 int refcnt;
01566 u_int16_t pool_type;
01567 struct in6_addr start_addr;
01568 int bits;
01569 int units;
01570 iasubopt_hash_t *leases;
01571 int num_active;
01572 isc_heap_t *active_timeouts;
01573 int num_inactive;
01574 isc_heap_t *inactive_timeouts;
01575
01576 struct shared_network *shared_network;
01577
01578 struct subnet *subnet;
01579 struct ipv6_pond *ipv6_pond;
01580 };
01581
01593 struct ipv6_pond {
01594 int refcnt;
01595 struct ipv6_pond *next;
01596 struct group *group;
01597 struct shared_network *shared_network;
01598
01599 struct permit *permit_list;
01600 struct permit *prohibit_list;
01601 TIME valid_from;
01602 TIME valid_until;
01603
01604 struct ipv6_pool **ipv6_pools;
01605 int last_ipv6_pool;
01606
01607 };
01608
01609
01610 #define DDNS_UPDATE_ADDR 0x01
01611 #define DDNS_UPDATE_PTR 0x02
01612 #define DDNS_INCLUDE_RRSET 0x04
01613 #define DDNS_CONFLICT_OVERRIDE 0x08
01614 #define DDNS_CLIENT_DID_UPDATE 0x10
01615 #define DDNS_EXECUTE_NEXT 0x20
01616 #define DDNS_ABORT 0x40
01617 #define DDNS_STATIC_LEASE 0x80
01618 #define DDNS_ACTIVE_LEASE 0x100
01619
01620
01621
01622
01623 #define DDNS_STATE_CLEANUP 0 // The previous step failed, cleanup
01624
01625 #define DDNS_STATE_ADD_FW_NXDOMAIN 1
01626 #define DDNS_STATE_ADD_FW_YXDHCID 2
01627 #define DDNS_STATE_ADD_PTR 3
01628
01629 #define DDNS_STATE_REM_FW_YXDHCID 17
01630 #define DDNS_STATE_REM_FW_NXRR 18
01631 #define DDNS_STATE_REM_PTR 19
01632
01633
01634
01635
01636 #define DDNS_PRINT_INBOUND 1
01637 #define DDNS_PRINT_OUTBOUND 0
01638
01639 struct dhcp_ddns_cb;
01640
01641 typedef void (*ddns_action_t)(struct dhcp_ddns_cb *ddns_cb,
01642 isc_result_t result);
01643
01644 typedef struct dhcp_ddns_cb {
01645 struct data_string fwd_name;
01646 struct data_string rev_name;
01647 struct data_string dhcid;
01648 struct iaddr address;
01649 int address_type;
01650
01651 unsigned long ttl;
01652
01653 unsigned char zone_name[DHCP_MAXDNS_WIRE];
01654 isc_sockaddrlist_t zone_server_list;
01655 isc_sockaddr_t zone_addrs[DHCP_MAXNS];
01656 int zone_addr_count;
01657 struct dns_zone *zone;
01658
01659 u_int16_t flags;
01660 TIME timeout;
01661 int state;
01662 ddns_action_t cur_func;
01663
01664 struct dhcp_ddns_cb * next_op;
01665
01666
01667 void *lease;
01668 struct binding_scope **scope;
01669
01670 void *transaction;
01671 void *dataspace;
01672
01673 dns_rdataclass_t dhcid_class;
01674 char *lease_tag;
01675 } dhcp_ddns_cb_t;
01676
01677 extern struct ipv6_pool **pools;
01678 extern int num_pools;
01679
01680
01681
01682 HASH_FUNCTIONS_DECL (group, const char *, struct group_object, group_hash_t)
01683 HASH_FUNCTIONS_DECL (universe, const char *, struct universe, universe_hash_t)
01684 HASH_FUNCTIONS_DECL (option_name, const char *, struct option,
01685 option_name_hash_t)
01686 HASH_FUNCTIONS_DECL (option_code, const unsigned *, struct option,
01687 option_code_hash_t)
01688 HASH_FUNCTIONS_DECL (dns_zone, const char *, struct dns_zone, dns_zone_hash_t)
01689 HASH_FUNCTIONS_DECL(lease_ip, const unsigned char *, struct lease,
01690 lease_ip_hash_t)
01691 HASH_FUNCTIONS_DECL(lease_id, const unsigned char *, struct lease,
01692 lease_id_hash_t)
01693 HASH_FUNCTIONS_DECL (host, const unsigned char *, struct host_decl, host_hash_t)
01694 HASH_FUNCTIONS_DECL (class, const char *, struct class, class_hash_t)
01695
01696
01697
01698 extern struct option *vendor_cfg_option;
01699 int parse_options (struct packet *);
01700 int parse_option_buffer (struct option_state *, const unsigned char *,
01701 unsigned, struct universe *);
01702 struct universe *find_option_universe (struct option *, const char *);
01703 int parse_encapsulated_suboptions (struct option_state *, struct option *,
01704 const unsigned char *, unsigned,
01705 struct universe *, const char *);
01706 int cons_options (struct packet *, struct dhcp_packet *, struct lease *,
01707 struct client_state *,
01708 int, struct option_state *, struct option_state *,
01709 struct binding_scope **,
01710 int, int, int, struct data_string *, const char *);
01711 int fqdn_universe_decode (struct option_state *,
01712 const unsigned char *, unsigned, struct universe *);
01713 struct option_cache *
01714 lookup_fqdn6_option(struct universe *universe, struct option_state *options,
01715 unsigned code);
01716 void
01717 save_fqdn6_option(struct universe *universe, struct option_state *options,
01718 struct option_cache *oc, isc_boolean_t appendp);
01719 void
01720 delete_fqdn6_option(struct universe *universe, struct option_state *options,
01721 int code);
01722 void
01723 fqdn6_option_space_foreach(struct packet *packet, struct lease *lease,
01724 struct client_state *client_state,
01725 struct option_state *in_options,
01726 struct option_state *cfg_options,
01727 struct binding_scope **scope,
01728 struct universe *u, void *stuff,
01729 void (*func)(struct option_cache *,
01730 struct packet *,
01731 struct lease *,
01732 struct client_state *,
01733 struct option_state *,
01734 struct option_state *,
01735 struct binding_scope **,
01736 struct universe *, void *));
01737 int
01738 fqdn6_option_space_encapsulate(struct data_string *result,
01739 struct packet *packet, struct lease *lease,
01740 struct client_state *client_state,
01741 struct option_state *in_options,
01742 struct option_state *cfg_options,
01743 struct binding_scope **scope,
01744 struct universe *universe);
01745 int
01746 fqdn6_universe_decode(struct option_state *options,
01747 const unsigned char *buffer, unsigned length,
01748 struct universe *u);
01749 int append_option(struct data_string *dst, struct universe *universe,
01750 struct option *option, struct data_string *src);
01751 int
01752 store_options(int *ocount,
01753 unsigned char *buffer, unsigned buflen, unsigned index,
01754 struct packet *packet, struct lease *lease,
01755 struct client_state *client_state,
01756 struct option_state *in_options,
01757 struct option_state *cfg_options,
01758 struct binding_scope **scope,
01759 unsigned *priority_list, int priority_len,
01760 unsigned first_cutoff, int second_cutoff, int terminate,
01761 const char *vuname);
01762 int store_options6(char *, int, struct option_state *, struct packet *,
01763 const int *, struct data_string *);
01764 int format_has_text(const char *);
01765 int format_min_length(const char *, struct option_cache *);
01766 const char *pretty_print_option (struct option *, const unsigned char *,
01767 unsigned, int, int);
01768 int pretty_escape(char **, char *, const unsigned char **,
01769 const unsigned char *);
01770 int get_option (struct data_string *, struct universe *,
01771 struct packet *, struct lease *, struct client_state *,
01772 struct option_state *, struct option_state *,
01773 struct option_state *, struct binding_scope **, unsigned,
01774 const char *, int);
01775 void set_option (struct universe *, struct option_state *,
01776 struct option_cache *, enum statement_op);
01777 struct option_cache *lookup_option (struct universe *,
01778 struct option_state *, unsigned);
01779 struct option_cache *lookup_hashed_option (struct universe *,
01780 struct option_state *,
01781 unsigned);
01782 struct option_cache *next_hashed_option(struct universe *,
01783 struct option_state *,
01784 struct option_cache *);
01785 int save_option_buffer (struct universe *, struct option_state *,
01786 struct buffer *, unsigned char *, unsigned,
01787 unsigned, int);
01788 int append_option_buffer(struct universe *, struct option_state *,
01789 struct buffer *, unsigned char *, unsigned,
01790 unsigned, int);
01791 void build_server_oro(struct data_string *, struct option_state *,
01792 const char *, int);
01793 void save_option(struct universe *, struct option_state *,
01794 struct option_cache *);
01795 void also_save_option(struct universe *, struct option_state *,
01796 struct option_cache *);
01797 void save_hashed_option(struct universe *, struct option_state *,
01798 struct option_cache *, isc_boolean_t appendp);
01799 void delete_option (struct universe *, struct option_state *, int);
01800 void delete_hashed_option (struct universe *,
01801 struct option_state *, int);
01802 int option_cache_dereference (struct option_cache **,
01803 const char *, int);
01804 int hashed_option_state_dereference (struct universe *,
01805 struct option_state *,
01806 const char *, int);
01807 int store_option (struct data_string *,
01808 struct universe *, struct packet *, struct lease *,
01809 struct client_state *,
01810 struct option_state *, struct option_state *,
01811 struct binding_scope **, struct option_cache *);
01812 int option_space_encapsulate (struct data_string *,
01813 struct packet *, struct lease *,
01814 struct client_state *,
01815 struct option_state *,
01816 struct option_state *,
01817 struct binding_scope **,
01818 struct data_string *);
01819 int hashed_option_space_encapsulate (struct data_string *,
01820 struct packet *, struct lease *,
01821 struct client_state *,
01822 struct option_state *,
01823 struct option_state *,
01824 struct binding_scope **,
01825 struct universe *);
01826 int nwip_option_space_encapsulate (struct data_string *,
01827 struct packet *, struct lease *,
01828 struct client_state *,
01829 struct option_state *,
01830 struct option_state *,
01831 struct binding_scope **,
01832 struct universe *);
01833 int fqdn_option_space_encapsulate (struct data_string *,
01834 struct packet *, struct lease *,
01835 struct client_state *,
01836 struct option_state *,
01837 struct option_state *,
01838 struct binding_scope **,
01839 struct universe *);
01840 void suboption_foreach (struct packet *, struct lease *, struct client_state *,
01841 struct option_state *, struct option_state *,
01842 struct binding_scope **, struct universe *, void *,
01843 void (*) (struct option_cache *, struct packet *,
01844 struct lease *, struct client_state *,
01845 struct option_state *, struct option_state *,
01846 struct binding_scope **,
01847 struct universe *, void *),
01848 struct option_cache *, const char *);
01849 void option_space_foreach (struct packet *, struct lease *,
01850 struct client_state *,
01851 struct option_state *,
01852 struct option_state *,
01853 struct binding_scope **,
01854 struct universe *, void *,
01855 void (*) (struct option_cache *,
01856 struct packet *,
01857 struct lease *, struct client_state *,
01858 struct option_state *,
01859 struct option_state *,
01860 struct binding_scope **,
01861 struct universe *, void *));
01862 void hashed_option_space_foreach (struct packet *, struct lease *,
01863 struct client_state *,
01864 struct option_state *,
01865 struct option_state *,
01866 struct binding_scope **,
01867 struct universe *, void *,
01868 void (*) (struct option_cache *,
01869 struct packet *,
01870 struct lease *,
01871 struct client_state *,
01872 struct option_state *,
01873 struct option_state *,
01874 struct binding_scope **,
01875 struct universe *, void *));
01876 int linked_option_get (struct data_string *, struct universe *,
01877 struct packet *, struct lease *,
01878 struct client_state *,
01879 struct option_state *, struct option_state *,
01880 struct option_state *, struct binding_scope **,
01881 unsigned);
01882 int linked_option_state_dereference (struct universe *,
01883 struct option_state *,
01884 const char *, int);
01885 void save_linked_option(struct universe *, struct option_state *,
01886 struct option_cache *, isc_boolean_t appendp);
01887 void linked_option_space_foreach (struct packet *, struct lease *,
01888 struct client_state *,
01889 struct option_state *,
01890 struct option_state *,
01891 struct binding_scope **,
01892 struct universe *, void *,
01893 void (*) (struct option_cache *,
01894 struct packet *,
01895 struct lease *,
01896 struct client_state *,
01897 struct option_state *,
01898 struct option_state *,
01899 struct binding_scope **,
01900 struct universe *, void *));
01901 int linked_option_space_encapsulate (struct data_string *, struct packet *,
01902 struct lease *, struct client_state *,
01903 struct option_state *,
01904 struct option_state *,
01905 struct binding_scope **,
01906 struct universe *);
01907 void delete_linked_option (struct universe *, struct option_state *, int);
01908 struct option_cache *lookup_linked_option (struct universe *,
01909 struct option_state *, unsigned);
01910 void do_packet (struct interface_info *,
01911 struct dhcp_packet *, unsigned,
01912 unsigned int, struct iaddr, struct hardware *);
01913 void do_packet6(struct interface_info *, const char *,
01914 int, int, const struct iaddr *, isc_boolean_t);
01915 int packet6_len_okay(const char *, int);
01916
01917 int validate_packet(struct packet *);
01918
01919 int add_option(struct option_state *options,
01920 unsigned int option_num,
01921 void *data,
01922 unsigned int data_len);
01923
01924
01925 extern struct timeval cur_tv;
01926 #define cur_time cur_tv.tv_sec
01927
01928 extern int ddns_update_style;
01929 extern int dont_use_fsync;
01930
01931 extern const char *path_dhcpd_conf;
01932 extern const char *path_dhcpd_db;
01933 extern const char *path_dhcpd_pid;
01934
01935 extern int dhcp_max_agent_option_packet_length;
01936 extern struct eventqueue *rw_queue_empty;
01937
01938 int main(int, char **);
01939 void postconf_initialization(int);
01940 void postdb_startup(void);
01941 void cleanup (void);
01942 void lease_pinged (struct iaddr, u_int8_t *, int);
01943 void lease_ping_timeout (void *);
01944 int dhcpd_interface_setup_hook (struct interface_info *ip, struct iaddr *ia);
01945 extern enum dhcp_shutdown_state shutdown_state;
01946 isc_result_t dhcp_io_shutdown (omapi_object_t *, void *);
01947 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
01948 control_object_state_t newstate);
01949 #if defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
01950 void relinquish_ackqueue(void);
01951 #endif
01952
01953
01954 isc_result_t new_parse (struct parse **, int,
01955 char *, unsigned, const char *, int);
01956 isc_result_t end_parse (struct parse **);
01957 isc_result_t save_parse_state(struct parse *cfile);
01958 isc_result_t restore_parse_state(struct parse *cfile);
01959 enum dhcp_token next_token (const char **, unsigned *, struct parse *);
01960 enum dhcp_token peek_token (const char **, unsigned *, struct parse *);
01961 enum dhcp_token next_raw_token(const char **rval, unsigned *rlen,
01962 struct parse *cfile);
01963 enum dhcp_token peek_raw_token(const char **rval, unsigned *rlen,
01964 struct parse *cfile);
01965
01966
01967
01968
01969 #define skip_token(a,b,c) ((void) next_token((a),(b),(c)))
01970
01971
01972
01973 void parse_trace_setup (void);
01974 isc_result_t readconf (void);
01975 isc_result_t read_conf_file (const char *, struct group *, int, int);
01976 #if defined (TRACING)
01977 void trace_conf_input (trace_type_t *, unsigned, char *);
01978 void trace_conf_stop (trace_type_t *ttype);
01979 #endif
01980 isc_result_t conf_file_subparse (struct parse *, struct group *, int);
01981 isc_result_t lease_file_subparse (struct parse *);
01982 int parse_statement (struct parse *, struct group *, int,
01983 struct host_decl *, int);
01984 #if defined (FAILOVER_PROTOCOL)
01985 void parse_failover_peer (struct parse *, struct group *, int);
01986 void parse_failover_state_declaration (struct parse *,
01987 dhcp_failover_state_t *);
01988 void parse_failover_state (struct parse *,
01989 enum failover_state *, TIME *);
01990 #endif
01991 int permit_list_match (struct permit *, struct permit *);
01992 void parse_pool_statement (struct parse *, struct group *, int);
01993 int parse_lbrace (struct parse *);
01994 void parse_host_declaration (struct parse *, struct group *);
01995 int parse_class_declaration (struct class **, struct parse *,
01996 struct group *, int);
01997 void parse_shared_net_declaration (struct parse *, struct group *);
01998 void parse_subnet_declaration (struct parse *,
01999 struct shared_network *);
02000 void parse_subnet6_declaration (struct parse *,
02001 struct shared_network *);
02002 void parse_group_declaration (struct parse *, struct group *);
02003 int parse_fixed_addr_param (struct option_cache **,
02004 struct parse *, enum dhcp_token);
02005 int parse_lease_declaration (struct lease **, struct parse *);
02006 int parse_ip6_addr(struct parse *, struct iaddr *);
02007 int parse_ip6_addr_expr(struct expression **, struct parse *);
02008 int parse_ip6_prefix(struct parse *, struct iaddr *, u_int8_t *);
02009 void parse_address_range (struct parse *, struct group *, int,
02010 struct pool *, struct lease **);
02011 void parse_address_range6(struct parse *cfile, struct group *group,
02012 struct ipv6_pond *);
02013 void parse_prefix6(struct parse *cfile, struct group *group,
02014 struct ipv6_pond *);
02015 void parse_fixed_prefix6(struct parse *cfile, struct host_decl *host_decl);
02016 void parse_ia_na_declaration(struct parse *);
02017 void parse_ia_ta_declaration(struct parse *);
02018 void parse_ia_pd_declaration(struct parse *);
02019 void parse_server_duid(struct parse *cfile);
02020 void parse_server_duid_conf(struct parse *cfile);
02021 void parse_pool6_statement (struct parse *, struct group *, int);
02022
02023
02024 int ddns_updates(struct packet *, struct lease *, struct lease *,
02025 struct iasubopt *, struct iasubopt *, struct option_state *);
02026 isc_result_t ddns_removals(struct lease *, struct iasubopt *,
02027 struct dhcp_ddns_cb *, isc_boolean_t);
02028 #if defined (TRACING)
02029 void trace_ddns_init(void);
02030 #endif
02031
02032
02033 void add_enumeration (struct enumeration *);
02034 struct enumeration *find_enumeration (const char *, int);
02035 struct enumeration_value *find_enumeration_value (const char *, int,
02036 unsigned *,
02037 const char *);
02038 void skip_to_semi (struct parse *);
02039 void skip_to_rbrace (struct parse *, int);
02040 int parse_semi (struct parse *);
02041 int parse_string (struct parse *, char **, unsigned *);
02042 char *parse_host_name (struct parse *);
02043 int parse_ip_addr_or_hostname (struct expression **,
02044 struct parse *, int);
02045 void parse_hardware_param (struct parse *, struct hardware *);
02046 void parse_lease_time (struct parse *, TIME *);
02047 unsigned char *parse_numeric_aggregate (struct parse *,
02048 unsigned char *, unsigned *,
02049 int, int, unsigned);
02050 void convert_num (struct parse *, unsigned char *, const char *,
02051 int, unsigned);
02052 TIME parse_date (struct parse *);
02053 TIME parse_date_core(struct parse *);
02054 isc_result_t parse_option_name (struct parse *, int, int *,
02055 struct option **);
02056 void parse_option_space_decl (struct parse *);
02057 int parse_option_code_definition (struct parse *, struct option *);
02058 int parse_base64 (struct data_string *, struct parse *);
02059 int parse_cshl (struct data_string *, struct parse *);
02060 int parse_executable_statement (struct executable_statement **,
02061 struct parse *, int *,
02062 enum expression_context);
02063 int parse_executable_statements (struct executable_statement **,
02064 struct parse *, int *,
02065 enum expression_context);
02066 int parse_zone (struct dns_zone *, struct parse *);
02067 int parse_key (struct parse *);
02068 int parse_on_statement (struct executable_statement **,
02069 struct parse *, int *);
02070 int parse_switch_statement (struct executable_statement **,
02071 struct parse *, int *);
02072 int parse_case_statement (struct executable_statement **,
02073 struct parse *, int *,
02074 enum expression_context);
02075 int parse_if_statement (struct executable_statement **,
02076 struct parse *, int *);
02077 int parse_boolean_expression (struct expression **,
02078 struct parse *, int *);
02079 int parse_boolean (struct parse *);
02080 int parse_data_expression (struct expression **,
02081 struct parse *, int *);
02082 int parse_numeric_expression (struct expression **,
02083 struct parse *, int *);
02084 int parse_dns_expression (struct expression **, struct parse *, int *);
02085 int parse_non_binary (struct expression **, struct parse *, int *,
02086 enum expression_context);
02087 int parse_expression (struct expression **, struct parse *, int *,
02088 enum expression_context,
02089 struct expression **, enum expr_op);
02090 int parse_option_data(struct expression **expr, struct parse *cfile,
02091 int lookups, struct option *option);
02092 int parse_option_statement (struct executable_statement **,
02093 struct parse *, int,
02094 struct option *, enum statement_op);
02095 int parse_option_token (struct expression **, struct parse *,
02096 const char **, struct expression *, int, int);
02097 int parse_allow_deny (struct option_cache **, struct parse *, int);
02098 int parse_auth_key (struct data_string *, struct parse *);
02099 int parse_warn (struct parse *, const char *, ...)
02100 __attribute__((__format__(__printf__,2,3)));
02101 struct expression *parse_domain_list(struct parse *cfile, int);
02102
02103
02104
02105 extern struct binding_scope *global_scope;
02106 pair cons (caddr_t, pair);
02107 int make_const_option_cache (struct option_cache **, struct buffer **,
02108 u_int8_t *, unsigned, struct option *,
02109 const char *, int);
02110 int make_host_lookup (struct expression **, const char *);
02111 int enter_dns_host (struct dns_host_entry **, const char *);
02112 int make_const_data (struct expression **,
02113 const unsigned char *, unsigned, int, int,
02114 const char *, int);
02115 int make_const_int (struct expression **, unsigned long);
02116 int make_concat (struct expression **,
02117 struct expression *, struct expression *);
02118 int make_encapsulation (struct expression **, struct data_string *);
02119 int make_substring (struct expression **, struct expression *,
02120 struct expression *, struct expression *);
02121 int make_limit (struct expression **, struct expression *, int);
02122 int make_let (struct executable_statement **, const char *);
02123 int option_cache (struct option_cache **, struct data_string *,
02124 struct expression *, struct option *,
02125 const char *, int);
02126 int evaluate_expression (struct binding_value **, struct packet *,
02127 struct lease *, struct client_state *,
02128 struct option_state *, struct option_state *,
02129 struct binding_scope **, struct expression *,
02130 const char *, int);
02131 int binding_value_dereference (struct binding_value **, const char *, int);
02132 int evaluate_boolean_expression (int *,
02133 struct packet *, struct lease *,
02134 struct client_state *,
02135 struct option_state *,
02136 struct option_state *,
02137 struct binding_scope **,
02138 struct expression *);
02139 int evaluate_data_expression (struct data_string *,
02140 struct packet *, struct lease *,
02141 struct client_state *,
02142 struct option_state *,
02143 struct option_state *,
02144 struct binding_scope **,
02145 struct expression *,
02146 const char *, int);
02147 int evaluate_numeric_expression (unsigned long *, struct packet *,
02148 struct lease *, struct client_state *,
02149 struct option_state *, struct option_state *,
02150 struct binding_scope **,
02151 struct expression *);
02152 int evaluate_option_cache (struct data_string *,
02153 struct packet *, struct lease *,
02154 struct client_state *,
02155 struct option_state *, struct option_state *,
02156 struct binding_scope **,
02157 struct option_cache *,
02158 const char *, int);
02159 int evaluate_boolean_option_cache (int *,
02160 struct packet *, struct lease *,
02161 struct client_state *,
02162 struct option_state *,
02163 struct option_state *,
02164 struct binding_scope **,
02165 struct option_cache *,
02166 const char *, int);
02167 int evaluate_boolean_expression_result (int *,
02168 struct packet *, struct lease *,
02169 struct client_state *,
02170 struct option_state *,
02171 struct option_state *,
02172 struct binding_scope **,
02173 struct expression *);
02174 void expression_dereference (struct expression **, const char *, int);
02175 int is_dns_expression (struct expression *);
02176 int is_boolean_expression (struct expression *);
02177 int is_data_expression (struct expression *);
02178 int is_numeric_expression (struct expression *);
02179 int is_compound_expression (struct expression *);
02180 int op_precedence (enum expr_op, enum expr_op);
02181 enum expression_context expression_context (struct expression *);
02182 enum expression_context op_context (enum expr_op);
02183 int write_expression (FILE *, struct expression *, int, int, int);
02184 struct binding *find_binding (struct binding_scope *, const char *);
02185 int free_bindings (struct binding_scope *, const char *, int);
02186 int binding_scope_dereference (struct binding_scope **,
02187 const char *, int);
02188 int fundef_dereference (struct fundef **, const char *, int);
02189 int data_subexpression_length (int *, struct expression *);
02190 int expr_valid_for_context (struct expression *, enum expression_context);
02191 struct binding *create_binding (struct binding_scope **, const char *);
02192 int bind_ds_value (struct binding_scope **,
02193 const char *, struct data_string *);
02194 int find_bound_string (struct data_string *,
02195 struct binding_scope *, const char *);
02196 int unset (struct binding_scope *, const char *);
02197 int data_string_sprintfa(struct data_string *ds, const char *fmt, ...);
02198
02199
02200 extern int outstanding_pings;
02201 extern int max_outstanding_acks;
02202 extern int max_ack_delay_secs;
02203 extern int max_ack_delay_usecs;
02204
02205 void dhcp (struct packet *);
02206 void dhcpdiscover (struct packet *, int);
02207 void dhcprequest (struct packet *, int, struct lease *);
02208 void dhcprelease (struct packet *, int);
02209 void dhcpdecline (struct packet *, int);
02210 void dhcpinform (struct packet *, int);
02211 void nak_lease (struct packet *, struct iaddr *cip);
02212 void ack_lease (struct packet *, struct lease *,
02213 unsigned int, TIME, char *, int, struct host_decl *);
02214 void delayed_ack_enqueue(struct lease *);
02215 void commit_leases_readerdry(void *);
02216 void flush_ackqueue(void *);
02217 void dhcp_reply (struct lease *);
02218 int find_lease (struct lease **, struct packet *,
02219 struct shared_network *, int *, int *, struct lease *,
02220 const char *, int);
02221 int mockup_lease (struct lease **, struct packet *,
02222 struct shared_network *,
02223 struct host_decl *);
02224 void static_lease_dereference (struct lease *, const char *, int);
02225
02226 int allocate_lease (struct lease **, struct packet *,
02227 struct pool *, int *);
02228 int permitted (struct packet *, struct permit *);
02229 int locate_network (struct packet *);
02230 int parse_agent_information_option (struct packet *, int, u_int8_t *);
02231 unsigned cons_agent_information_options (struct option_state *,
02232 struct dhcp_packet *,
02233 unsigned, unsigned);
02234 void get_server_source_address(struct in_addr *from,
02235 struct option_state *options,
02236 struct option_state *out_options,
02237 struct packet *packet);
02238 void setup_server_source_address(struct in_addr *from,
02239 struct option_state *options,
02240 struct packet *packet);
02241
02242
02243 void dhcpleasequery (struct packet *, int);
02244 void dhcpv6_leasequery (struct data_string *, struct packet *);
02245
02246
02247 isc_boolean_t server_duid_isset(void);
02248 void copy_server_duid(struct data_string *ds, const char *file, int line);
02249 void set_server_duid(struct data_string *new_duid);
02250 isc_result_t set_server_duid_from_option(void);
02251 void set_server_duid_type(int type);
02252 isc_result_t generate_new_server_duid(void);
02253 isc_result_t get_client_id(struct packet *, struct data_string *);
02254 void dhcpv6(struct packet *);
02255
02256
02257 void bootp (struct packet *);
02258
02259
02260 extern int (*group_write_hook) (struct group_object *);
02261 extern struct group *root_group;
02262 extern group_hash_t *group_name_hash;
02263 isc_result_t delete_group (struct group_object *, int);
02264 isc_result_t supersede_group (struct group_object *, int);
02265 int clone_group (struct group **, struct group *, const char *, int);
02266 int write_group (struct group_object *);
02267
02268
02269 void relinquish_lease_hunks (void);
02270 struct lease *new_leases (unsigned, const char *, int);
02271 #if defined (DEBUG_MEMORY_LEAKAGE) || \
02272 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
02273 void relinquish_free_lease_states (void);
02274 #endif
02275 OMAPI_OBJECT_ALLOC_DECL (lease, struct lease, dhcp_type_lease)
02276 OMAPI_OBJECT_ALLOC_DECL (class, struct class, dhcp_type_class)
02277 OMAPI_OBJECT_ALLOC_DECL (subclass, struct class, dhcp_type_subclass)
02278 OMAPI_OBJECT_ALLOC_DECL (pool, struct pool, dhcp_type_pool)
02279 OMAPI_OBJECT_ALLOC_DECL (host, struct host_decl, dhcp_type_host)
02280
02281
02282 OMAPI_OBJECT_ALLOC_DECL (subnet, struct subnet, dhcp_type_subnet)
02283 OMAPI_OBJECT_ALLOC_DECL (shared_network, struct shared_network,
02284 dhcp_type_shared_network)
02285 OMAPI_OBJECT_ALLOC_DECL (group_object, struct group_object, dhcp_type_group)
02286 OMAPI_OBJECT_ALLOC_DECL (dhcp_control,
02287 dhcp_control_object_t, dhcp_type_control)
02288
02289 #if defined (DEBUG_MEMORY_LEAKAGE) || \
02290 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
02291 void relinquish_free_pairs (void);
02292 void relinquish_free_expressions (void);
02293 void relinquish_free_binding_values (void);
02294 void relinquish_free_option_caches (void);
02295 void relinquish_free_packets (void);
02296 #endif
02297
02298 int option_chain_head_allocate (struct option_chain_head **,
02299 const char *, int);
02300 int option_chain_head_reference (struct option_chain_head **,
02301 struct option_chain_head *,
02302 const char *, int);
02303 int option_chain_head_dereference (struct option_chain_head **,
02304 const char *, int);
02305 int group_allocate (struct group **, const char *, int);
02306 int group_reference (struct group **, struct group *, const char *, int);
02307 int group_dereference (struct group **, const char *, int);
02308 struct dhcp_packet *new_dhcp_packet (const char *, int);
02309 struct protocol *new_protocol (const char *, int);
02310 struct lease_state *new_lease_state (const char *, int);
02311 struct domain_search_list *new_domain_search_list (const char *, int);
02312 struct name_server *new_name_server (const char *, int);
02313 void free_name_server (struct name_server *, const char *, int);
02314 struct option *new_option (const char *, const char *, int);
02315 int option_reference(struct option **dest, struct option *src,
02316 const char * file, int line);
02317 int option_dereference(struct option **dest, const char *file, int line);
02318 struct universe *new_universe (const char *, int);
02319 void free_universe (struct universe *, const char *, int);
02320 void free_domain_search_list (struct domain_search_list *,
02321 const char *, int);
02322 void free_lease_state (struct lease_state *, const char *, int);
02323 void free_protocol (struct protocol *, const char *, int);
02324 void free_dhcp_packet (struct dhcp_packet *, const char *, int);
02325 struct client_lease *new_client_lease (const char *, int);
02326 void free_client_lease (struct client_lease *, const char *, int);
02327 struct permit *new_permit (const char *, int);
02328 void free_permit (struct permit *, const char *, int);
02329 pair new_pair (const char *, int);
02330 void free_pair (pair, const char *, int);
02331 int expression_allocate (struct expression **, const char *, int);
02332 int expression_reference (struct expression **,
02333 struct expression *, const char *, int);
02334 void free_expression (struct expression *, const char *, int);
02335 int binding_value_allocate (struct binding_value **,
02336 const char *, int);
02337 int binding_value_reference (struct binding_value **,
02338 struct binding_value *,
02339 const char *, int);
02340 void free_binding_value (struct binding_value *, const char *, int);
02341 int fundef_allocate (struct fundef **, const char *, int);
02342 int fundef_reference (struct fundef **,
02343 struct fundef *, const char *, int);
02344 int option_cache_allocate (struct option_cache **, const char *, int);
02345 int option_cache_reference (struct option_cache **,
02346 struct option_cache *, const char *, int);
02347 int buffer_allocate (struct buffer **, unsigned, const char *, int);
02348 int buffer_reference (struct buffer **, struct buffer *,
02349 const char *, int);
02350 int buffer_dereference (struct buffer **, const char *, int);
02351 int dns_host_entry_allocate (struct dns_host_entry **,
02352 const char *, const char *, int);
02353 int dns_host_entry_reference (struct dns_host_entry **,
02354 struct dns_host_entry *,
02355 const char *, int);
02356 int dns_host_entry_dereference (struct dns_host_entry **,
02357 const char *, int);
02358 int option_state_allocate (struct option_state **, const char *, int);
02359 int option_state_reference (struct option_state **,
02360 struct option_state *, const char *, int);
02361 int option_state_dereference (struct option_state **,
02362 const char *, int);
02363 void data_string_copy(struct data_string *, const struct data_string *,
02364 const char *, int);
02365 void data_string_forget (struct data_string *, const char *, int);
02366 void data_string_truncate (struct data_string *, int);
02367 int executable_statement_allocate (struct executable_statement **,
02368 const char *, int);
02369 int executable_statement_reference (struct executable_statement **,
02370 struct executable_statement *,
02371 const char *, int);
02372 int packet_allocate (struct packet **, const char *, int);
02373 int packet_reference (struct packet **,
02374 struct packet *, const char *, int);
02375 int packet_dereference (struct packet **, const char *, int);
02376 int binding_scope_allocate (struct binding_scope **,
02377 const char *, int);
02378 int binding_scope_reference (struct binding_scope **,
02379 struct binding_scope *,
02380 const char *, int);
02381 int dns_zone_allocate (struct dns_zone **, const char *, int);
02382 int dns_zone_reference (struct dns_zone **,
02383 struct dns_zone *, const char *, int);
02384
02385
02386 #define DEFAULT_TIME_FORMAT 0
02387 #define LOCAL_TIME_FORMAT 1
02388 extern int db_time_format;
02389 char *quotify_string (const char *, const char *, int);
02390 char *quotify_buf (const unsigned char *, unsigned, const char *, int);
02391 char *print_base64 (const unsigned char *, unsigned, const char *, int);
02392 char *print_hw_addr (const int, const int, const unsigned char *);
02393 void print_lease (struct lease *);
02394 void dump_raw (const unsigned char *, unsigned);
02395 void dump_packet_option (struct option_cache *, struct packet *,
02396 struct lease *, struct client_state *,
02397 struct option_state *, struct option_state *,
02398 struct binding_scope **, struct universe *, void *);
02399 void dump_packet (struct packet *);
02400 void hash_dump (struct hash_table *);
02401 char *print_hex (unsigned, const u_int8_t *, unsigned, unsigned);
02402 void print_hex_only (unsigned, const u_int8_t *, unsigned, char *);
02403 void print_hex_or_string (unsigned, const u_int8_t *, unsigned, char *);
02404 #define print_hex_1(len, data, limit) print_hex(len, data, limit, 0)
02405 #define print_hex_2(len, data, limit) print_hex(len, data, limit, 1)
02406 #define print_hex_3(len, data, limit) print_hex(len, data, limit, 2)
02407 char *print_dotted_quads (unsigned, const u_int8_t *);
02408 char *print_dec_1 (unsigned long);
02409 char *print_dec_2 (unsigned long);
02410 void print_expression (const char *, struct expression *);
02411 int token_print_indent_concat (FILE *, int, int,
02412 const char *, const char *, ...);
02413 int token_indent_data_string (FILE *, int, int, const char *, const char *,
02414 struct data_string *);
02415 int token_print_indent (FILE *, int, int,
02416 const char *, const char *, const char *);
02417 void indent_spaces (FILE *, int);
02418 #if defined (NSUPDATE)
02419 void print_dns_status (int, struct dhcp_ddns_cb *, isc_result_t);
02420 #endif
02421 const char *print_time(TIME);
02422
02423 void get_hw_addr(struct interface_info *info);
02424
02425
02426 #if defined (USE_SOCKET_SEND) || defined (USE_SOCKET_RECEIVE) \
02427 || defined (USE_SOCKET_FALLBACK)
02428 int if_register_socket(struct interface_info *, int, int *, struct in6_addr *);
02429 #endif
02430
02431 #if defined (USE_SOCKET_FALLBACK) && !defined (USE_SOCKET_SEND)
02432 void if_reinitialize_fallback (struct interface_info *);
02433 void if_register_fallback (struct interface_info *);
02434 ssize_t send_fallback (struct interface_info *,
02435 struct packet *, struct dhcp_packet *, size_t,
02436 struct in_addr,
02437 struct sockaddr_in *, struct hardware *);
02438 ssize_t send_fallback6(struct interface_info *, struct packet *,
02439 struct dhcp_packet *, size_t, struct in6_addr *,
02440 struct sockaddr_in6 *, struct hardware *);
02441 #endif
02442
02443 #ifdef USE_SOCKET_SEND
02444 void if_reinitialize_send (struct interface_info *);
02445 void if_register_send (struct interface_info *);
02446 void if_deregister_send (struct interface_info *);
02447 ssize_t send_packet (struct interface_info *,
02448 struct packet *, struct dhcp_packet *, size_t,
02449 struct in_addr,
02450 struct sockaddr_in *, struct hardware *);
02451 #endif
02452 ssize_t send_packet6(struct interface_info *, const unsigned char *, size_t,
02453 struct sockaddr_in6 *);
02454 #ifdef USE_SOCKET_RECEIVE
02455 void if_reinitialize_receive (struct interface_info *);
02456 void if_register_receive (struct interface_info *);
02457 void if_deregister_receive (struct interface_info *);
02458 ssize_t receive_packet (struct interface_info *,
02459 unsigned char *, size_t,
02460 struct sockaddr_in *, struct hardware *);
02461 #endif
02462
02463 #if defined (USE_SOCKET_FALLBACK)
02464 isc_result_t fallback_discard (omapi_object_t *);
02465 #endif
02466
02467 #if defined (USE_SOCKET_SEND)
02468 int can_unicast_without_arp (struct interface_info *);
02469 int can_receive_unicast_unconfigured (struct interface_info *);
02470 int supports_multiple_interfaces (struct interface_info *);
02471 void maybe_setup_fallback (void);
02472 #endif
02473
02474 void if_register6(struct interface_info *info, int do_multicast);
02475 void if_register_linklocal6(struct interface_info *info);
02476 ssize_t receive_packet6(struct interface_info *interface,
02477 unsigned char *buf, size_t len,
02478 struct sockaddr_in6 *from, struct in6_addr *to_addr,
02479 unsigned int *if_index);
02480 void if_deregister6(struct interface_info *info);
02481
02482
02483
02484 #if defined (USE_BPF_SEND) || defined (USE_BPF_RECEIVE)
02485 int if_register_bpf (struct interface_info *);
02486 #endif
02487 #ifdef USE_BPF_SEND
02488 void if_reinitialize_send (struct interface_info *);
02489 void if_register_send (struct interface_info *);
02490 void if_deregister_send (struct interface_info *);
02491 ssize_t send_packet (struct interface_info *,
02492 struct packet *, struct dhcp_packet *, size_t,
02493 struct in_addr,
02494 struct sockaddr_in *, struct hardware *);
02495 #endif
02496 #ifdef USE_BPF_RECEIVE
02497 void if_reinitialize_receive (struct interface_info *);
02498 void if_register_receive (struct interface_info *);
02499 void if_deregister_receive (struct interface_info *);
02500 ssize_t receive_packet (struct interface_info *,
02501 unsigned char *, size_t,
02502 struct sockaddr_in *, struct hardware *);
02503 #endif
02504 #if defined (USE_BPF_SEND)
02505 int can_unicast_without_arp (struct interface_info *);
02506 int can_receive_unicast_unconfigured (struct interface_info *);
02507 int supports_multiple_interfaces (struct interface_info *);
02508 void maybe_setup_fallback (void);
02509 #endif
02510
02511
02512 #if defined (USE_LPF_SEND) || defined (USE_LPF_RECEIVE)
02513 int if_register_lpf (struct interface_info *);
02514 #endif
02515 #ifdef USE_LPF_SEND
02516 void if_reinitialize_send (struct interface_info *);
02517 void if_register_send (struct interface_info *);
02518 void if_deregister_send (struct interface_info *);
02519 ssize_t send_packet (struct interface_info *,
02520 struct packet *, struct dhcp_packet *, size_t,
02521 struct in_addr,
02522 struct sockaddr_in *, struct hardware *);
02523 #endif
02524 #ifdef USE_LPF_RECEIVE
02525 void if_reinitialize_receive (struct interface_info *);
02526 void if_register_receive (struct interface_info *);
02527 void if_deregister_receive (struct interface_info *);
02528 ssize_t receive_packet (struct interface_info *,
02529 unsigned char *, size_t,
02530 struct sockaddr_in *, struct hardware *);
02531 #endif
02532 #if defined (USE_LPF_SEND)
02533 int can_unicast_without_arp (struct interface_info *);
02534 int can_receive_unicast_unconfigured (struct interface_info *);
02535 int supports_multiple_interfaces (struct interface_info *);
02536 void maybe_setup_fallback (void);
02537 #endif
02538
02539
02540 #if defined (USE_NIT_SEND) || defined (USE_NIT_RECEIVE)
02541 int if_register_nit (struct interface_info *);
02542 #endif
02543
02544 #ifdef USE_NIT_SEND
02545 void if_reinitialize_send (struct interface_info *);
02546 void if_register_send (struct interface_info *);
02547 void if_deregister_send (struct interface_info *);
02548 ssize_t send_packet (struct interface_info *,
02549 struct packet *, struct dhcp_packet *, size_t,
02550 struct in_addr,
02551 struct sockaddr_in *, struct hardware *);
02552 #endif
02553 #ifdef USE_NIT_RECEIVE
02554 void if_reinitialize_receive (struct interface_info *);
02555 void if_register_receive (struct interface_info *);
02556 void if_deregister_receive (struct interface_info *);
02557 ssize_t receive_packet (struct interface_info *,
02558 unsigned char *, size_t,
02559 struct sockaddr_in *, struct hardware *);
02560 #endif
02561 #if defined (USE_NIT_SEND)
02562 int can_unicast_without_arp (struct interface_info *);
02563 int can_receive_unicast_unconfigured (struct interface_info *);
02564 int supports_multiple_interfaces (struct interface_info *);
02565 void maybe_setup_fallback (void);
02566 #endif
02567
02568
02569 #if defined (USE_DLPI_SEND) || defined (USE_DLPI_RECEIVE)
02570 int if_register_dlpi (struct interface_info *);
02571 #endif
02572
02573 #ifdef USE_DLPI_SEND
02574 int can_unicast_without_arp (struct interface_info *);
02575 int can_receive_unicast_unconfigured (struct interface_info *);
02576 void if_reinitialize_send (struct interface_info *);
02577 void if_register_send (struct interface_info *);
02578 void if_deregister_send (struct interface_info *);
02579 ssize_t send_packet (struct interface_info *,
02580 struct packet *, struct dhcp_packet *, size_t,
02581 struct in_addr,
02582 struct sockaddr_in *, struct hardware *);
02583 int supports_multiple_interfaces (struct interface_info *);
02584 void maybe_setup_fallback (void);
02585 #endif
02586 #ifdef USE_DLPI_RECEIVE
02587 void if_reinitialize_receive (struct interface_info *);
02588 void if_register_receive (struct interface_info *);
02589 void if_deregister_receive (struct interface_info *);
02590 ssize_t receive_packet (struct interface_info *,
02591 unsigned char *, size_t,
02592 struct sockaddr_in *, struct hardware *);
02593 #endif
02594
02595
02596
02597 #ifdef USE_RAW_SEND
02598 void if_reinitialize_send (struct interface_info *);
02599 void if_register_send (struct interface_info *);
02600 void if_deregister_send (struct interface_info *);
02601 ssize_t send_packet (struct interface_info *, struct packet *,
02602 struct dhcp_packet *, size_t, struct in_addr,
02603 struct sockaddr_in *, struct hardware *);
02604 int can_unicast_without_arp (struct interface_info *);
02605 int can_receive_unicast_unconfigured (struct interface_info *);
02606 int supports_multiple_interfaces (struct interface_info *);
02607 void maybe_setup_fallback (void);
02608 #endif
02609
02610
02611 extern struct interface_info *interfaces,
02612 *dummy_interfaces, *fallback_interface;
02613 extern struct protocol *protocols;
02614 extern int quiet_interface_discovery;
02615 isc_result_t interface_setup (void);
02616 void interface_trace_setup (void);
02617
02618 extern struct in_addr limited_broadcast;
02619 extern int local_family;
02620 extern struct in_addr local_address;
02621
02622 extern u_int16_t local_port;
02623 extern u_int16_t remote_port;
02624 extern int (*dhcp_interface_setup_hook) (struct interface_info *,
02625 struct iaddr *);
02626 extern int (*dhcp_interface_discovery_hook) (struct interface_info *);
02627 extern isc_result_t (*dhcp_interface_startup_hook) (struct interface_info *);
02628
02629 extern void (*bootp_packet_handler) (struct interface_info *,
02630 struct dhcp_packet *, unsigned,
02631 unsigned int,
02632 struct iaddr, struct hardware *);
02633 extern void (*dhcpv6_packet_handler)(struct interface_info *,
02634 const char *, int,
02635 int, const struct iaddr *, isc_boolean_t);
02636 extern struct timeout *timeouts;
02637 extern omapi_object_type_t *dhcp_type_interface;
02638 #if defined (TRACING)
02639 extern trace_type_t *interface_trace;
02640 extern trace_type_t *inpacket_trace;
02641 extern trace_type_t *outpacket_trace;
02642 #endif
02643 extern struct interface_info **interface_vector;
02644 extern int interface_count;
02645 extern int interface_max;
02646 isc_result_t interface_initialize(omapi_object_t *, const char *, int);
02647 void discover_interfaces(int);
02648 int setup_fallback (struct interface_info **, const char *, int);
02649 int if_readsocket (omapi_object_t *);
02650 void reinitialize_interfaces (void);
02651
02652
02653 void set_time(TIME);
02654 struct timeval *process_outstanding_timeouts (struct timeval *);
02655 void dispatch (void);
02656 isc_result_t got_one(omapi_object_t *);
02657 isc_result_t got_one_v6(omapi_object_t *);
02658 isc_result_t interface_set_value (omapi_object_t *, omapi_object_t *,
02659 omapi_data_string_t *, omapi_typed_data_t *);
02660 isc_result_t interface_get_value (omapi_object_t *, omapi_object_t *,
02661 omapi_data_string_t *, omapi_value_t **);
02662 isc_result_t interface_destroy (omapi_object_t *, const char *, int);
02663 isc_result_t interface_signal_handler (omapi_object_t *,
02664 const char *, va_list);
02665 isc_result_t interface_stuff_values (omapi_object_t *,
02666 omapi_object_t *,
02667 omapi_object_t *);
02668
02669 void add_timeout (struct timeval *, void (*) (void *), void *,
02670 tvref_t, tvunref_t);
02671 void cancel_timeout (void (*) (void *), void *);
02672 void cancel_all_timeouts (void);
02673 void relinquish_timeouts (void);
02674
02675 OMAPI_OBJECT_ALLOC_DECL (interface,
02676 struct interface_info, dhcp_type_interface)
02677
02678
02679 extern char *default_option_format;
02680 extern struct universe dhcp_universe;
02681 extern struct universe dhcpv6_universe;
02682 extern struct universe nwip_universe;
02683 extern struct universe fqdn_universe;
02684 extern struct universe vsio_universe;
02685 extern int dhcp_option_default_priority_list [];
02686 extern int dhcp_option_default_priority_list_count;
02687 extern const char *hardware_types [256];
02688 extern int universe_count, universe_max;
02689 extern struct universe **universes;
02690 extern universe_hash_t *universe_hash;
02691 void initialize_common_option_spaces (void);
02692 extern struct universe *config_universe;
02693
02694
02695 #if defined (FAILOVER_PROTOCOL)
02696 extern failover_option_t null_failover_option;
02697 extern failover_option_t skip_failover_option;
02698 extern struct failover_option_info ft_options [];
02699 extern u_int32_t fto_allowed [];
02700 extern int ft_sizes [];
02701 extern const char *dhcp_flink_state_names [];
02702 #endif
02703 extern const char *binding_state_names [];
02704
02705 extern struct universe agent_universe;
02706 extern struct universe server_universe;
02707
02708 extern struct enumeration ddns_styles;
02709 extern struct enumeration syslog_enum;
02710 void initialize_server_option_spaces (void);
02711
02712
02713 struct iaddr subnet_number (struct iaddr, struct iaddr);
02714 struct iaddr ip_addr (struct iaddr, struct iaddr, u_int32_t);
02715 struct iaddr broadcast_addr (struct iaddr, struct iaddr);
02716 u_int32_t host_addr (struct iaddr, struct iaddr);
02717 int addr_eq (struct iaddr, struct iaddr);
02718 int addr_match(struct iaddr *, struct iaddrmatch *);
02719 int addr_cmp(const struct iaddr *a1, const struct iaddr *a2);
02720 int addr_or(struct iaddr *result,
02721 const struct iaddr *a1, const struct iaddr *a2);
02722 int addr_and(struct iaddr *result,
02723 const struct iaddr *a1, const struct iaddr *a2);
02724 isc_boolean_t is_cidr_mask_valid(const struct iaddr *addr, int bits);
02725 isc_result_t range2cidr(struct iaddrcidrnetlist **result,
02726 const struct iaddr *lo, const struct iaddr *hi);
02727 isc_result_t free_iaddrcidrnetlist(struct iaddrcidrnetlist **result);
02728 const char *piaddr (struct iaddr);
02729 const char *pdestdesc (struct iaddr);
02730 char *piaddrmask(struct iaddr *, struct iaddr *);
02731 char *piaddrcidr(const struct iaddr *, unsigned int);
02732 u_int16_t validate_port(char *);
02733
02734
02735 extern int nowait;
02736
02737 extern int wanted_ia_na;
02738 extern int wanted_ia_ta;
02739 extern int wanted_ia_pd;
02740
02741 extern const char *path_dhclient_conf;
02742 extern const char *path_dhclient_db;
02743 extern const char *path_dhclient_pid;
02744 extern char *path_dhclient_script;
02745 extern int interfaces_requested;
02746 extern struct data_string default_duid;
02747 extern int duid_type;
02748
02749 extern struct client_config top_level_config;
02750
02751 void dhcpoffer (struct packet *);
02752 void dhcpack (struct packet *);
02753 void dhcpnak (struct packet *);
02754
02755 void send_discover (void *);
02756 void send_request (void *);
02757 void send_release (void *);
02758 void send_decline (void *);
02759
02760 void state_reboot (void *);
02761 void state_init (void *);
02762 void state_selecting (void *);
02763 void state_requesting (void *);
02764 void state_bound (void *);
02765 void state_stop (void *);
02766 void state_panic (void *);
02767
02768 void bind_lease (struct client_state *, struct in_addr *);
02769
02770 void make_client_options (struct client_state *,
02771 struct client_lease *, u_int8_t *,
02772 struct option_cache *, struct iaddr *,
02773 struct option **, struct option_state **);
02774 void make_discover (struct client_state *, struct client_lease *);
02775 void make_request (struct client_state *, struct client_lease *);
02776 void make_decline (struct client_state *, struct client_lease *);
02777 void make_release (struct client_state *, struct client_lease *);
02778
02779 void destroy_client_lease (struct client_lease *);
02780 void rewrite_client_leases (void);
02781 void write_lease_option (struct option_cache *, struct packet *,
02782 struct lease *, struct client_state *,
02783 struct option_state *, struct option_state *,
02784 struct binding_scope **, struct universe *, void *);
02785 int write_client_lease (struct client_state *, struct client_lease *, int, int);
02786 isc_result_t write_client6_lease(struct client_state *client,
02787 struct dhc6_lease *lease,
02788 int rewrite, int sync);
02789 int dhcp_option_ev_name (char *, size_t, struct option *);
02790
02791 void script_init (struct client_state *, const char *,
02792 struct string_list *);
02793 void client_option_envadd (struct option_cache *, struct packet *,
02794 struct lease *, struct client_state *,
02795 struct option_state *, struct option_state *,
02796 struct binding_scope **, struct universe *, void *);
02797 void script_write_params (struct client_state *, const char *,
02798 struct client_lease *);
02799 void script_write_requested (struct client_state *);
02800 int script_go (struct client_state *);
02801 void client_envadd (struct client_state *,
02802 const char *, const char *, const char *, ...)
02803 __attribute__((__format__(__printf__,4,5)));
02804
02805 struct client_lease *packet_to_lease (struct packet *, struct client_state *);
02806 void go_daemon (void);
02807 void write_client_pid_file (void);
02808 void client_location_changed (void);
02809 void do_release (struct client_state *);
02810 int dhclient_interface_shutdown_hook (struct interface_info *);
02811 int dhclient_interface_discovery_hook (struct interface_info *);
02812 isc_result_t dhclient_interface_startup_hook (struct interface_info *);
02813 void dhclient_schedule_updates(struct client_state *client,
02814 struct iaddr *addr, int offset);
02815 void client_dns_update_timeout (void *cp);
02816 isc_result_t client_dns_update(struct client_state *client,
02817 dhcp_ddns_cb_t *ddns_cb);
02818 void client_dns_remove(struct client_state *client, struct iaddr *addr);
02819
02820 void dhcpv4_client_assignments(void);
02821 void dhcpv6_client_assignments(void);
02822 isc_result_t form_duid(struct data_string *duid, const char *file, int line);
02823
02824
02825 void dhc6_lease_destroy(struct dhc6_lease **src, const char *file, int line);
02826 void start_init6(struct client_state *client);
02827 void start_info_request6(struct client_state *client);
02828 void start_confirm6(struct client_state *client);
02829 void start_release6(struct client_state *client);
02830 void start_selecting6(struct client_state *client);
02831 void unconfigure6(struct client_state *client, const char *reason);
02832
02833
02834 int write_lease (struct lease *);
02835 int write_host (struct host_decl *);
02836 int write_server_duid(void);
02837 #if defined (FAILOVER_PROTOCOL)
02838 int write_failover_state (dhcp_failover_state_t *);
02839 #endif
02840 int db_printable (const unsigned char *);
02841 int db_printable_len (const unsigned char *, unsigned);
02842 isc_result_t write_named_billing_class(const void *, unsigned, void *);
02843 void write_billing_classes (void);
02844 int write_billing_class (struct class *);
02845 void commit_leases_timeout (void *);
02846 void commit_leases_readerdry(void *);
02847 int commit_leases (void);
02848 int commit_leases_timed (void);
02849 #if defined (PARANOIA)
02850 void db_startup (int, uid_t, gid_t);
02851 #else
02852 void db_startup (int);
02853 #endif
02854 int new_lease_file (void);
02855 int group_writer (struct group_object *);
02856 int write_ia(const struct ia_xx *);
02857
02858
02859 u_int32_t checksum (unsigned char *, unsigned, u_int32_t);
02860 u_int32_t wrapsum (u_int32_t);
02861 void assemble_hw_header (struct interface_info *, unsigned char *,
02862 unsigned *, struct hardware *);
02863 void assemble_udp_ip_header (struct interface_info *, unsigned char *,
02864 unsigned *, u_int32_t, u_int32_t,
02865 u_int32_t, unsigned char *, unsigned);
02866 ssize_t decode_hw_header (struct interface_info *, unsigned char *,
02867 unsigned, struct hardware *);
02868 ssize_t decode_udp_ip_header (struct interface_info *, unsigned char *,
02869 unsigned, struct sockaddr_in *,
02870 unsigned, unsigned *, int);
02871
02872
02873 void assemble_ethernet_header (struct interface_info *, unsigned char *,
02874 unsigned *, struct hardware *);
02875 ssize_t decode_ethernet_header (struct interface_info *,
02876 unsigned char *,
02877 unsigned, struct hardware *);
02878
02879
02880 void assemble_tr_header (struct interface_info *, unsigned char *,
02881 unsigned *, struct hardware *);
02882 ssize_t decode_tr_header (struct interface_info *,
02883 unsigned char *,
02884 unsigned, struct hardware *);
02885
02886
02887 void convert_statement (struct parse *);
02888 void convert_host_statement (struct parse *, jrefproto);
02889 void convert_host_name (struct parse *, jrefproto);
02890 void convert_class_statement (struct parse *, jrefproto, int);
02891 void convert_class_decl (struct parse *, jrefproto);
02892 void convert_lease_time (struct parse *, jrefproto, char *);
02893 void convert_shared_net_statement (struct parse *, jrefproto);
02894 void convert_subnet_statement (struct parse *, jrefproto);
02895 void convert_subnet_decl (struct parse *, jrefproto);
02896 void convert_host_decl (struct parse *, jrefproto);
02897 void convert_hardware_decl (struct parse *, jrefproto);
02898 void convert_hardware_addr (struct parse *, jrefproto);
02899 void convert_filename_decl (struct parse *, jrefproto);
02900 void convert_servername_decl (struct parse *, jrefproto);
02901 void convert_ip_addr_or_hostname (struct parse *, jrefproto, int);
02902 void convert_fixed_addr_decl (struct parse *, jrefproto);
02903 void convert_option_decl (struct parse *, jrefproto);
02904 void convert_lease_statement (struct parse *, jrefproto);
02905 void convert_address_range (struct parse *, jrefproto);
02906 void convert_date (struct parse *, jrefproto, char *);
02907 void convert_numeric_aggregate (struct parse *, jrefproto, int, int, int, int);
02908 void indent (int);
02909
02910
02911 void add_route_direct (struct interface_info *, struct in_addr);
02912 void add_route_net (struct interface_info *, struct in_addr, struct in_addr);
02913 void add_route_default_gateway (struct interface_info *, struct in_addr);
02914 void remove_routes (struct in_addr);
02915 void remove_if_route (struct interface_info *, struct in_addr);
02916 void remove_all_if_routes (struct interface_info *);
02917 void set_netmask (struct interface_info *, struct in_addr);
02918 void set_broadcast_addr (struct interface_info *, struct in_addr);
02919 void set_ip_address (struct interface_info *, struct in_addr);
02920
02921
02922 isc_result_t read_client_conf (void);
02923 int read_client_conf_file (const char *,
02924 struct interface_info *, struct client_config *);
02925 void read_client_leases (void);
02926 void parse_client_statement (struct parse *, struct interface_info *,
02927 struct client_config *);
02928 int parse_X (struct parse *, u_int8_t *, unsigned);
02929 int parse_option_list (struct parse *, struct option ***);
02930 void parse_interface_declaration (struct parse *,
02931 struct client_config *, char *);
02932 int interface_or_dummy (struct interface_info **, const char *);
02933 void make_client_state (struct client_state **);
02934 void make_client_config (struct client_state *, struct client_config *);
02935 void parse_client_lease_statement (struct parse *, int);
02936 void parse_client_lease_declaration (struct parse *,
02937 struct client_lease *,
02938 struct interface_info **,
02939 struct client_state **);
02940 int parse_option_decl (struct option_cache **, struct parse *);
02941 void parse_string_list (struct parse *, struct string_list **, int);
02942 int parse_ip_addr (struct parse *, struct iaddr *);
02943 int parse_destination_descriptor (struct parse *, struct iaddr *);
02944 int parse_ip_addr_with_subnet(struct parse *, struct iaddrmatch *);
02945 void parse_reject_statement (struct parse *, struct client_config *);
02946
02947
02948 OMAPI_OBJECT_ALLOC_DECL (icmp_state, struct icmp_state, dhcp_type_icmp)
02949 extern struct icmp_state *icmp_state;
02950 void icmp_startup (int, void (*) (struct iaddr, u_int8_t *, int));
02951 int icmp_readsocket (omapi_object_t *);
02952 int icmp_echorequest (struct iaddr *);
02953 isc_result_t icmp_echoreply (omapi_object_t *);
02954
02955
02956 isc_result_t enter_dns_zone (struct dns_zone *);
02957 isc_result_t dns_zone_lookup (struct dns_zone **, const char *);
02958 int dns_zone_dereference (struct dns_zone **, const char *, int);
02959 #if defined (NSUPDATE)
02960 #define FIND_FORWARD 0
02961 #define FIND_REVERSE 1
02962 isc_result_t find_tsig_key (ns_tsig_key **, const char *, struct dns_zone *);
02963 void tkey_free (ns_tsig_key **);
02964 isc_result_t find_cached_zone (dhcp_ddns_cb_t *, int);
02965 void forget_zone (struct dns_zone **);
02966 void repudiate_zone (struct dns_zone **);
02967 int get_dhcid (dhcp_ddns_cb_t *, int, const u_int8_t *, unsigned);
02968 void dhcid_tolease (struct data_string *, struct data_string *);
02969 isc_result_t dhcid_fromlease (struct data_string *, struct data_string *);
02970 isc_result_t ddns_update_fwd(struct data_string *, struct iaddr,
02971 struct data_string *, unsigned long, unsigned,
02972 unsigned);
02973 isc_result_t ddns_remove_fwd(struct data_string *,
02974 struct iaddr, struct data_string *);
02975 #endif
02976
02977 dhcp_ddns_cb_t *ddns_cb_alloc(const char *file, int line);
02978 void ddns_cb_free (dhcp_ddns_cb_t *ddns_cb, const char *file, int line);
02979 void ddns_cb_forget_zone (dhcp_ddns_cb_t *ddns_cb);
02980 isc_result_t
02981 ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line);
02982 isc_result_t
02983 ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb, const char *file, int line);
02984 void
02985 ddns_cancel(dhcp_ddns_cb_t *ddns_cb, const char *file, int line);
02986
02987
02988 extern char path_resolv_conf [];
02989 extern struct name_server *name_servers;
02990 extern struct domain_search_list *domains;
02991
02992 void read_resolv_conf (TIME);
02993 struct name_server *first_name_server (void);
02994
02995
02996 #ifdef NEED_INET_ATON
02997 int inet_aton (const char *, struct in_addr *);
02998 #endif
02999
03000
03001 extern int have_billing_classes;
03002 struct class unknown_class;
03003 struct class known_class;
03004 struct collection default_collection;
03005 struct collection *collections;
03006 extern struct executable_statement *default_classification_rules;
03007
03008 void classification_setup (void);
03009 void classify_client (struct packet *);
03010 int check_collection (struct packet *, struct lease *, struct collection *);
03011 void classify (struct packet *, struct class *);
03012 isc_result_t unlink_class (struct class **class);
03013 isc_result_t find_class (struct class **, const char *,
03014 const char *, int);
03015 int unbill_class (struct lease *, struct class *);
03016 int bill_class (struct lease *, struct class *);
03017
03018
03019 int execute_statements (struct binding_value **result,
03020 struct packet *, struct lease *,
03021 struct client_state *,
03022 struct option_state *, struct option_state *,
03023 struct binding_scope **,
03024 struct executable_statement *,
03025 struct on_star *);
03026 void execute_statements_in_scope (struct binding_value **result,
03027 struct packet *, struct lease *,
03028 struct client_state *,
03029 struct option_state *,
03030 struct option_state *,
03031 struct binding_scope **,
03032 struct group *, struct group *,
03033 struct on_star *);
03034 int executable_statement_dereference (struct executable_statement **,
03035 const char *, int);
03036 void write_statements (FILE *, struct executable_statement *, int);
03037 int find_matching_case (struct executable_statement **,
03038 struct packet *, struct lease *, struct client_state *,
03039 struct option_state *, struct option_state *,
03040 struct binding_scope **,
03041 struct expression *, struct executable_statement *);
03042 int executable_statement_foreach (struct executable_statement *,
03043 int (*) (struct executable_statement *,
03044 void *, int), void *, int);
03045
03046
03047 extern omapi_object_type_t *dhcp_type_group;
03048 extern omapi_object_type_t *dhcp_type_shared_network;
03049 extern omapi_object_type_t *dhcp_type_subnet;
03050 extern omapi_object_type_t *dhcp_type_control;
03051 extern dhcp_control_object_t *dhcp_control_object;
03052
03053 void dhcp_common_objects_setup (void);
03054
03055 isc_result_t dhcp_group_set_value (omapi_object_t *, omapi_object_t *,
03056 omapi_data_string_t *,
03057 omapi_typed_data_t *);
03058 isc_result_t dhcp_group_get_value (omapi_object_t *, omapi_object_t *,
03059 omapi_data_string_t *,
03060 omapi_value_t **);
03061 isc_result_t dhcp_group_destroy (omapi_object_t *, const char *, int);
03062 isc_result_t dhcp_group_signal_handler (omapi_object_t *,
03063 const char *, va_list);
03064 isc_result_t dhcp_group_stuff_values (omapi_object_t *,
03065 omapi_object_t *,
03066 omapi_object_t *);
03067 isc_result_t dhcp_group_lookup (omapi_object_t **,
03068 omapi_object_t *, omapi_object_t *);
03069 isc_result_t dhcp_group_create (omapi_object_t **,
03070 omapi_object_t *);
03071 isc_result_t dhcp_group_remove (omapi_object_t *,
03072 omapi_object_t *);
03073
03074 isc_result_t dhcp_control_set_value (omapi_object_t *, omapi_object_t *,
03075 omapi_data_string_t *,
03076 omapi_typed_data_t *);
03077 isc_result_t dhcp_control_get_value (omapi_object_t *, omapi_object_t *,
03078 omapi_data_string_t *,
03079 omapi_value_t **);
03080 isc_result_t dhcp_control_destroy (omapi_object_t *, const char *, int);
03081 isc_result_t dhcp_control_signal_handler (omapi_object_t *,
03082 const char *, va_list);
03083 isc_result_t dhcp_control_stuff_values (omapi_object_t *,
03084 omapi_object_t *,
03085 omapi_object_t *);
03086 isc_result_t dhcp_control_lookup (omapi_object_t **,
03087 omapi_object_t *, omapi_object_t *);
03088 isc_result_t dhcp_control_create (omapi_object_t **,
03089 omapi_object_t *);
03090 isc_result_t dhcp_control_remove (omapi_object_t *,
03091 omapi_object_t *);
03092
03093 isc_result_t dhcp_subnet_set_value (omapi_object_t *, omapi_object_t *,
03094 omapi_data_string_t *,
03095 omapi_typed_data_t *);
03096 isc_result_t dhcp_subnet_get_value (omapi_object_t *, omapi_object_t *,
03097 omapi_data_string_t *,
03098 omapi_value_t **);
03099 isc_result_t dhcp_subnet_destroy (omapi_object_t *, const char *, int);
03100 isc_result_t dhcp_subnet_signal_handler (omapi_object_t *,
03101 const char *, va_list);
03102 isc_result_t dhcp_subnet_stuff_values (omapi_object_t *,
03103 omapi_object_t *,
03104 omapi_object_t *);
03105 isc_result_t dhcp_subnet_lookup (omapi_object_t **,
03106 omapi_object_t *, omapi_object_t *);
03107 isc_result_t dhcp_subnet_create (omapi_object_t **,
03108 omapi_object_t *);
03109 isc_result_t dhcp_subnet_remove (omapi_object_t *,
03110 omapi_object_t *);
03111
03112 isc_result_t dhcp_shared_network_set_value (omapi_object_t *,
03113 omapi_object_t *,
03114 omapi_data_string_t *,
03115 omapi_typed_data_t *);
03116 isc_result_t dhcp_shared_network_get_value (omapi_object_t *,
03117 omapi_object_t *,
03118 omapi_data_string_t *,
03119 omapi_value_t **);
03120 isc_result_t dhcp_shared_network_destroy (omapi_object_t *, const char *, int);
03121 isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *,
03122 const char *, va_list);
03123 isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *,
03124 omapi_object_t *,
03125 omapi_object_t *);
03126 isc_result_t dhcp_shared_network_lookup (omapi_object_t **,
03127 omapi_object_t *, omapi_object_t *);
03128 isc_result_t dhcp_shared_network_create (omapi_object_t **,
03129 omapi_object_t *);
03130 isc_result_t dhcp_shared_network_remove (omapi_object_t *,
03131 omapi_object_t *);
03132
03133
03134 extern int (*dhcp_interface_shutdown_hook) (struct interface_info *);
03135
03136 extern omapi_object_type_t *dhcp_type_lease;
03137 extern omapi_object_type_t *dhcp_type_pool;
03138 extern omapi_object_type_t *dhcp_type_class;
03139 extern omapi_object_type_t *dhcp_type_subclass;
03140
03141 #if defined (FAILOVER_PROTOCOL)
03142 extern omapi_object_type_t *dhcp_type_failover_state;
03143 extern omapi_object_type_t *dhcp_type_failover_link;
03144 extern omapi_object_type_t *dhcp_type_failover_listener;
03145 #endif
03146
03147 void dhcp_db_objects_setup (void);
03148
03149 isc_result_t dhcp_lease_set_value (omapi_object_t *, omapi_object_t *,
03150 omapi_data_string_t *,
03151 omapi_typed_data_t *);
03152 isc_result_t dhcp_lease_get_value (omapi_object_t *, omapi_object_t *,
03153 omapi_data_string_t *,
03154 omapi_value_t **);
03155 isc_result_t dhcp_lease_destroy (omapi_object_t *, const char *, int);
03156 isc_result_t dhcp_lease_signal_handler (omapi_object_t *,
03157 const char *, va_list);
03158 isc_result_t dhcp_lease_stuff_values (omapi_object_t *,
03159 omapi_object_t *,
03160 omapi_object_t *);
03161 isc_result_t dhcp_lease_lookup (omapi_object_t **,
03162 omapi_object_t *, omapi_object_t *);
03163 isc_result_t dhcp_lease_create (omapi_object_t **,
03164 omapi_object_t *);
03165 isc_result_t dhcp_lease_remove (omapi_object_t *,
03166 omapi_object_t *);
03167 isc_result_t dhcp_host_set_value (omapi_object_t *, omapi_object_t *,
03168 omapi_data_string_t *,
03169 omapi_typed_data_t *);
03170 isc_result_t dhcp_host_get_value (omapi_object_t *, omapi_object_t *,
03171 omapi_data_string_t *,
03172 omapi_value_t **);
03173 isc_result_t dhcp_host_destroy (omapi_object_t *, const char *, int);
03174 isc_result_t dhcp_host_signal_handler (omapi_object_t *,
03175 const char *, va_list);
03176 isc_result_t dhcp_host_stuff_values (omapi_object_t *,
03177 omapi_object_t *,
03178 omapi_object_t *);
03179 isc_result_t dhcp_host_lookup (omapi_object_t **,
03180 omapi_object_t *, omapi_object_t *);
03181 isc_result_t dhcp_host_create (omapi_object_t **,
03182 omapi_object_t *);
03183 isc_result_t dhcp_host_remove (omapi_object_t *,
03184 omapi_object_t *);
03185 isc_result_t dhcp_pool_set_value (omapi_object_t *, omapi_object_t *,
03186 omapi_data_string_t *,
03187 omapi_typed_data_t *);
03188 isc_result_t dhcp_pool_get_value (omapi_object_t *, omapi_object_t *,
03189 omapi_data_string_t *,
03190 omapi_value_t **);
03191 isc_result_t dhcp_pool_destroy (omapi_object_t *, const char *, int);
03192 isc_result_t dhcp_pool_signal_handler (omapi_object_t *,
03193 const char *, va_list);
03194 isc_result_t dhcp_pool_stuff_values (omapi_object_t *,
03195 omapi_object_t *,
03196 omapi_object_t *);
03197 isc_result_t dhcp_pool_lookup (omapi_object_t **,
03198 omapi_object_t *, omapi_object_t *);
03199 isc_result_t dhcp_pool_create (omapi_object_t **,
03200 omapi_object_t *);
03201 isc_result_t dhcp_pool_remove (omapi_object_t *,
03202 omapi_object_t *);
03203 isc_result_t dhcp_class_set_value (omapi_object_t *, omapi_object_t *,
03204 omapi_data_string_t *,
03205 omapi_typed_data_t *);
03206 isc_result_t dhcp_class_get_value (omapi_object_t *, omapi_object_t *,
03207 omapi_data_string_t *,
03208 omapi_value_t **);
03209 isc_result_t dhcp_class_destroy (omapi_object_t *, const char *, int);
03210 isc_result_t dhcp_class_signal_handler (omapi_object_t *,
03211 const char *, va_list);
03212 isc_result_t dhcp_class_stuff_values (omapi_object_t *,
03213 omapi_object_t *,
03214 omapi_object_t *);
03215 isc_result_t dhcp_class_lookup (omapi_object_t **,
03216 omapi_object_t *, omapi_object_t *);
03217 isc_result_t dhcp_class_create (omapi_object_t **,
03218 omapi_object_t *);
03219 isc_result_t dhcp_class_remove (omapi_object_t *,
03220 omapi_object_t *);
03221 isc_result_t dhcp_subclass_set_value (omapi_object_t *, omapi_object_t *,
03222 omapi_data_string_t *,
03223 omapi_typed_data_t *);
03224 isc_result_t dhcp_subclass_get_value (omapi_object_t *, omapi_object_t *,
03225 omapi_data_string_t *,
03226 omapi_value_t **);
03227 isc_result_t dhcp_subclass_destroy (omapi_object_t *, const char *, int);
03228 isc_result_t dhcp_subclass_signal_handler (omapi_object_t *,
03229 const char *, va_list);
03230 isc_result_t dhcp_subclass_stuff_values (omapi_object_t *,
03231 omapi_object_t *,
03232 omapi_object_t *);
03233 isc_result_t dhcp_subclass_lookup (omapi_object_t **,
03234 omapi_object_t *, omapi_object_t *);
03235 isc_result_t dhcp_subclass_create (omapi_object_t **,
03236 omapi_object_t *);
03237 isc_result_t dhcp_subclass_remove (omapi_object_t *,
03238 omapi_object_t *);
03239 isc_result_t dhcp_interface_set_value (omapi_object_t *,
03240 omapi_object_t *,
03241 omapi_data_string_t *,
03242 omapi_typed_data_t *);
03243 isc_result_t dhcp_interface_get_value (omapi_object_t *,
03244 omapi_object_t *,
03245 omapi_data_string_t *,
03246 omapi_value_t **);
03247 isc_result_t dhcp_interface_destroy (omapi_object_t *,
03248 const char *, int);
03249 isc_result_t dhcp_interface_signal_handler (omapi_object_t *,
03250 const char *,
03251 va_list ap);
03252 isc_result_t dhcp_interface_stuff_values (omapi_object_t *,
03253 omapi_object_t *,
03254 omapi_object_t *);
03255 isc_result_t dhcp_interface_lookup (omapi_object_t **,
03256 omapi_object_t *,
03257 omapi_object_t *);
03258 isc_result_t dhcp_interface_create (omapi_object_t **,
03259 omapi_object_t *);
03260 isc_result_t dhcp_interface_remove (omapi_object_t *,
03261 omapi_object_t *);
03262 void interface_stash (struct interface_info *);
03263 void interface_snorf (struct interface_info *, int);
03264
03265 isc_result_t binding_scope_set_value (struct binding_scope *, int,
03266 omapi_data_string_t *,
03267 omapi_typed_data_t *);
03268 isc_result_t binding_scope_get_value (omapi_value_t **,
03269 struct binding_scope *,
03270 omapi_data_string_t *);
03271 isc_result_t binding_scope_stuff_values (omapi_object_t *,
03272 struct binding_scope *);
03273
03274 void register_eventhandler(struct eventqueue **, void (*handler)(void *));
03275 void unregister_eventhandler(struct eventqueue **, void (*handler)(void *));
03276 void trigger_event(struct eventqueue **);
03277
03278
03279
03280 extern struct subnet *subnets;
03281 extern struct shared_network *shared_networks;
03282 extern host_hash_t *host_hw_addr_hash;
03283 extern host_hash_t *host_uid_hash;
03284 extern host_hash_t *host_name_hash;
03285 extern lease_id_hash_t *lease_uid_hash;
03286 extern lease_ip_hash_t *lease_ip_addr_hash;
03287 extern lease_id_hash_t *lease_hw_addr_hash;
03288
03289 extern omapi_object_type_t *dhcp_type_host;
03290
03291 extern int numclasseswritten;
03292
03293
03294 isc_result_t enter_class (struct class *, int, int);
03295 isc_result_t delete_class (struct class *, int);
03296 isc_result_t enter_host (struct host_decl *, int, int);
03297 isc_result_t delete_host (struct host_decl *, int);
03298 void change_host_uid(struct host_decl *host, const char *data, int len);
03299 int find_hosts_by_haddr (struct host_decl **, int,
03300 const unsigned char *, unsigned,
03301 const char *, int);
03302 int find_hosts_by_uid (struct host_decl **, const unsigned char *,
03303 unsigned, const char *, int);
03304 int find_hosts_by_option(struct host_decl **, struct packet *,
03305 struct option_state *, const char *, int);
03306 int find_host_for_network (struct subnet **, struct host_decl **,
03307 struct iaddr *, struct shared_network *);
03308 void new_address_range (struct parse *, struct iaddr, struct iaddr,
03309 struct subnet *, struct pool *,
03310 struct lease **);
03311 isc_result_t dhcp_lease_free (omapi_object_t *, const char *, int);
03312 isc_result_t dhcp_lease_get (omapi_object_t **, const char *, int);
03313 int find_grouped_subnet (struct subnet **, struct shared_network *,
03314 struct iaddr, const char *, int);
03315 int find_subnet(struct subnet **, struct iaddr, const char *, int);
03316 void enter_shared_network (struct shared_network *);
03317 void new_shared_network_interface (struct parse *,
03318 struct shared_network *,
03319 const char *);
03320 int subnet_inner_than(const struct subnet *, const struct subnet *, int);
03321 void enter_subnet (struct subnet *);
03322 void enter_lease (struct lease *);
03323 int supersede_lease (struct lease *, struct lease *, int, int, int);
03324 void make_binding_state_transition (struct lease *);
03325 int lease_copy (struct lease **, struct lease *, const char *, int);
03326 void release_lease (struct lease *, struct packet *);
03327 void abandon_lease (struct lease *, const char *);
03328 #if 0
03329
03330 void dissociate_lease (struct lease *);
03331 #endif
03332 void pool_timer (void *);
03333 int find_lease_by_uid (struct lease **, const unsigned char *,
03334 unsigned, const char *, int);
03335 int find_lease_by_hw_addr (struct lease **, const unsigned char *,
03336 unsigned, const char *, int);
03337 int find_lease_by_ip_addr (struct lease **, struct iaddr,
03338 const char *, int);
03339 void uid_hash_add (struct lease *);
03340 void uid_hash_delete (struct lease *);
03341 void hw_hash_add (struct lease *);
03342 void hw_hash_delete (struct lease *);
03343 int write_leases (void);
03344 int write_leases6(void);
03345 int lease_enqueue (struct lease *);
03346 isc_result_t lease_instantiate(const void *, unsigned, void *);
03347 void expire_all_pools (void);
03348 void dump_subnets (void);
03349 #if defined (DEBUG_MEMORY_LEAKAGE) || \
03350 defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
03351 void free_everything (void);
03352 #endif
03353
03354
03355 #if defined (FAILOVER_PROTOCOL)
03356 extern dhcp_failover_state_t *failover_states;
03357 void dhcp_failover_startup (void);
03358 int dhcp_failover_write_all_states (void);
03359 isc_result_t enter_failover_peer (dhcp_failover_state_t *);
03360 isc_result_t find_failover_peer (dhcp_failover_state_t **,
03361 const char *, const char *, int);
03362 isc_result_t dhcp_failover_link_initiate (omapi_object_t *);
03363 isc_result_t dhcp_failover_link_signal (omapi_object_t *,
03364 const char *, va_list);
03365 isc_result_t dhcp_failover_link_set_value (omapi_object_t *,
03366 omapi_object_t *,
03367 omapi_data_string_t *,
03368 omapi_typed_data_t *);
03369 isc_result_t dhcp_failover_link_get_value (omapi_object_t *,
03370 omapi_object_t *,
03371 omapi_data_string_t *,
03372 omapi_value_t **);
03373 isc_result_t dhcp_failover_link_destroy (omapi_object_t *,
03374 const char *, int);
03375 isc_result_t dhcp_failover_link_stuff_values (omapi_object_t *,
03376 omapi_object_t *,
03377 omapi_object_t *);
03378 isc_result_t dhcp_failover_listen (omapi_object_t *);
03379
03380 isc_result_t dhcp_failover_listener_signal (omapi_object_t *,
03381 const char *,
03382 va_list);
03383 isc_result_t dhcp_failover_listener_set_value (omapi_object_t *,
03384 omapi_object_t *,
03385 omapi_data_string_t *,
03386 omapi_typed_data_t *);
03387 isc_result_t dhcp_failover_listener_get_value (omapi_object_t *,
03388 omapi_object_t *,
03389 omapi_data_string_t *,
03390 omapi_value_t **);
03391 isc_result_t dhcp_failover_listener_destroy (omapi_object_t *,
03392 const char *, int);
03393 isc_result_t dhcp_failover_listener_stuff (omapi_object_t *,
03394 omapi_object_t *,
03395 omapi_object_t *);
03396 isc_result_t dhcp_failover_register (omapi_object_t *);
03397 isc_result_t dhcp_failover_state_signal (omapi_object_t *,
03398 const char *, va_list);
03399 isc_result_t dhcp_failover_state_transition (dhcp_failover_state_t *,
03400 const char *);
03401 isc_result_t dhcp_failover_set_service_state (dhcp_failover_state_t *state);
03402 isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *,
03403 enum failover_state);
03404 isc_result_t dhcp_failover_peer_state_changed (dhcp_failover_state_t *,
03405 failover_message_t *);
03406 void dhcp_failover_pool_rebalance (void *);
03407 void dhcp_failover_pool_check (struct pool *);
03408 int dhcp_failover_state_pool_check (dhcp_failover_state_t *);
03409 void dhcp_failover_timeout (void *);
03410 void dhcp_failover_send_contact (void *);
03411 isc_result_t dhcp_failover_send_state (dhcp_failover_state_t *);
03412 isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *);
03413 int dhcp_failover_queue_update (struct lease *, int);
03414 int dhcp_failover_send_acks (dhcp_failover_state_t *);
03415 void dhcp_failover_toack_queue_timeout (void *);
03416 int dhcp_failover_queue_ack (dhcp_failover_state_t *, failover_message_t *msg);
03417 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *);
03418 isc_result_t dhcp_failover_state_set_value (omapi_object_t *,
03419 omapi_object_t *,
03420 omapi_data_string_t *,
03421 omapi_typed_data_t *);
03422 void dhcp_failover_keepalive (void *);
03423 void dhcp_failover_reconnect (void *);
03424 void dhcp_failover_startup_timeout (void *);
03425 void dhcp_failover_link_startup_timeout (void *);
03426 void dhcp_failover_listener_restart (void *);
03427 void dhcp_failover_auto_partner_down(void *vs);
03428 isc_result_t dhcp_failover_state_get_value (omapi_object_t *,
03429 omapi_object_t *,
03430 omapi_data_string_t *,
03431 omapi_value_t **);
03432 isc_result_t dhcp_failover_state_destroy (omapi_object_t *,
03433 const char *, int);
03434 isc_result_t dhcp_failover_state_stuff (omapi_object_t *,
03435 omapi_object_t *,
03436 omapi_object_t *);
03437 isc_result_t dhcp_failover_state_lookup (omapi_object_t **,
03438 omapi_object_t *,
03439 omapi_object_t *);
03440 isc_result_t dhcp_failover_state_create (omapi_object_t **,
03441 omapi_object_t *);
03442 isc_result_t dhcp_failover_state_remove (omapi_object_t *,
03443 omapi_object_t *);
03444 int dhcp_failover_state_match (dhcp_failover_state_t *, u_int8_t *, unsigned);
03445 int dhcp_failover_state_match_by_name(dhcp_failover_state_t *,
03446 failover_option_t *);
03447 const char *dhcp_failover_reject_reason_print (int);
03448 const char *dhcp_failover_state_name_print (enum failover_state);
03449 const char *dhcp_failover_message_name (unsigned);
03450 const char *dhcp_failover_option_name (unsigned);
03451 failover_option_t *dhcp_failover_option_printf (unsigned, char *,
03452 unsigned *,
03453 unsigned,
03454 const char *, ...)
03455 __attribute__((__format__(__printf__,5,6)));
03456 failover_option_t *dhcp_failover_make_option (unsigned, char *,
03457 unsigned *, unsigned, ...);
03458 isc_result_t dhcp_failover_put_message (dhcp_failover_link_t *,
03459 omapi_object_t *, int, u_int32_t, ...);
03460 isc_result_t dhcp_failover_send_connect (omapi_object_t *);
03461 isc_result_t dhcp_failover_send_connectack (omapi_object_t *,
03462 dhcp_failover_state_t *,
03463 int, const char *);
03464 isc_result_t dhcp_failover_send_disconnect (omapi_object_t *,
03465 int, const char *);
03466 isc_result_t dhcp_failover_send_bind_update (dhcp_failover_state_t *,
03467 struct lease *);
03468 isc_result_t dhcp_failover_send_bind_ack (dhcp_failover_state_t *,
03469 failover_message_t *,
03470 int, const char *);
03471 isc_result_t dhcp_failover_send_poolreq (dhcp_failover_state_t *);
03472 isc_result_t dhcp_failover_send_poolresp (dhcp_failover_state_t *, int);
03473 isc_result_t dhcp_failover_send_update_request (dhcp_failover_state_t *);
03474 isc_result_t dhcp_failover_send_update_request_all (dhcp_failover_state_t *);
03475 isc_result_t dhcp_failover_send_update_done (dhcp_failover_state_t *);
03476 isc_result_t dhcp_failover_process_bind_update (dhcp_failover_state_t *,
03477 failover_message_t *);
03478 isc_result_t dhcp_failover_process_bind_ack (dhcp_failover_state_t *,
03479 failover_message_t *);
03480 isc_result_t dhcp_failover_generate_update_queue (dhcp_failover_state_t *,
03481 int);
03482 isc_result_t dhcp_failover_process_update_request (dhcp_failover_state_t *,
03483 failover_message_t *);
03484 isc_result_t dhcp_failover_process_update_request_all (dhcp_failover_state_t *,
03485 failover_message_t *);
03486 isc_result_t dhcp_failover_process_update_done (dhcp_failover_state_t *,
03487 failover_message_t *);
03488 void ia_remove_all_lease(struct ia_xx *ia, const char *file, int line);
03489 void dhcp_failover_recover_done (void *);
03490 void failover_print (char *, unsigned *, unsigned, const char *);
03491 void update_partner (struct lease *);
03492 int load_balance_mine (struct packet *, dhcp_failover_state_t *);
03493 int peer_wants_lease (struct lease *);
03494 binding_state_t normal_binding_state_transition_check (struct lease *,
03495 dhcp_failover_state_t *,
03496 binding_state_t,
03497 u_int32_t);
03498 binding_state_t
03499 conflict_binding_state_transition_check (struct lease *,
03500 dhcp_failover_state_t *,
03501 binding_state_t, u_int32_t);
03502 int lease_mine_to_reallocate (struct lease *);
03503
03504 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_state, dhcp_failover_state_t,
03505 dhcp_type_failover_state)
03506 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_listener, dhcp_failover_listener_t,
03507 dhcp_type_failover_listener)
03508 OMAPI_OBJECT_ALLOC_DECL (dhcp_failover_link, dhcp_failover_link_t,
03509 dhcp_type_failover_link)
03510 #endif
03511
03512 const char *binding_state_print (enum failover_state);
03513
03514
03515 #if defined(LDAP_CONFIGURATION)
03516 extern struct enumeration ldap_methods;
03517 #if defined (LDAP_USE_SSL)
03518 extern struct enumeration ldap_ssl_usage_enum;
03519 extern struct enumeration ldap_tls_reqcert_enum;
03520 extern struct enumeration ldap_tls_crlcheck_enum;
03521 #endif
03522 isc_result_t ldap_read_config (void);
03523 int find_haddr_in_ldap (struct host_decl **, int, unsigned,
03524 const unsigned char *, const char *, int);
03525 int find_subclass_in_ldap (struct class *, struct class **,
03526 struct data_string *);
03527 #endif
03528
03529
03530 HASH_FUNCTIONS_DECL(ia, unsigned char *, struct ia_xx, ia_hash_t)
03531 HASH_FUNCTIONS_DECL(iasubopt, struct in6_addr *, struct iasubopt,
03532 iasubopt_hash_t)
03533
03534 isc_result_t iasubopt_allocate(struct iasubopt **iasubopt,
03535 const char *file, int line);
03536 isc_result_t iasubopt_reference(struct iasubopt **iasubopt,
03537 struct iasubopt *src,
03538 const char *file, int line);
03539 isc_result_t iasubopt_dereference(struct iasubopt **iasubopt,
03540 const char *file, int line);
03541
03542 isc_result_t ia_make_key(struct data_string *key, u_int32_t iaid,
03543 const char *duid, unsigned int duid_len,
03544 const char *file, int line);
03545 isc_result_t ia_allocate(struct ia_xx **ia, u_int32_t iaid,
03546 const char *duid, unsigned int duid_len,
03547 const char *file, int line);
03548 isc_result_t ia_reference(struct ia_xx **ia, struct ia_xx *src,
03549 const char *file, int line);
03550 isc_result_t ia_dereference(struct ia_xx **ia,
03551 const char *file, int line);
03552 isc_result_t ia_add_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt,
03553 const char *file, int line);
03554 void ia_remove_iasubopt(struct ia_xx *ia, struct iasubopt *iasubopt,
03555 const char *file, int line);
03556 isc_boolean_t ia_equal(const struct ia_xx *a, const struct ia_xx *b);
03557
03558 isc_result_t ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
03559 const struct in6_addr *start_addr,
03560 int bits, int units,
03561 const char *file, int line);
03562 isc_result_t ipv6_pool_reference(struct ipv6_pool **pool,
03563 struct ipv6_pool *src,
03564 const char *file, int line);
03565 isc_result_t ipv6_pool_dereference(struct ipv6_pool **pool,
03566 const char *file, int line);
03567 isc_result_t create_lease6(struct ipv6_pool *pool,
03568 struct iasubopt **addr,
03569 unsigned int *attempts,
03570 const struct data_string *uid,
03571 time_t soft_lifetime_end_time);
03572 isc_result_t add_lease6(struct ipv6_pool *pool,
03573 struct iasubopt *lease,
03574 time_t valid_lifetime_end_time);
03575 isc_result_t renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
03576 isc_result_t expire_lease6(struct iasubopt **leasep,
03577 struct ipv6_pool *pool, time_t now);
03578 isc_result_t release_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
03579 isc_result_t decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease);
03580 isc_boolean_t lease6_exists(const struct ipv6_pool *pool,
03581 const struct in6_addr *addr);
03582 isc_boolean_t lease6_usable(struct iasubopt *lease);
03583 isc_result_t cleanup_lease6(ia_hash_t *ia_table,
03584 struct ipv6_pool *pool,
03585 struct iasubopt *lease,
03586 struct ia_xx *ia);
03587 isc_result_t mark_lease_unavailble(struct ipv6_pool *pool,
03588 const struct in6_addr *addr);
03589 isc_result_t create_prefix6(struct ipv6_pool *pool,
03590 struct iasubopt **pref,
03591 unsigned int *attempts,
03592 const struct data_string *uid,
03593 time_t soft_lifetime_end_time);
03594 isc_boolean_t prefix6_exists(const struct ipv6_pool *pool,
03595 const struct in6_addr *pref, u_int8_t plen);
03596
03597 isc_result_t add_ipv6_pool(struct ipv6_pool *pool);
03598 isc_result_t find_ipv6_pool(struct ipv6_pool **pool, u_int16_t type,
03599 const struct in6_addr *addr);
03600 isc_boolean_t ipv6_in_pool(const struct in6_addr *addr,
03601 const struct ipv6_pool *pool);
03602 isc_result_t ipv6_pond_allocate(struct ipv6_pond **pond,
03603 const char *file, int line);
03604 isc_result_t ipv6_pond_reference(struct ipv6_pond **pond,
03605 struct ipv6_pond *src,
03606 const char *file, int line);
03607 isc_result_t ipv6_pond_dereference(struct ipv6_pond **pond,
03608 const char *file, int line);
03609
03610 isc_result_t renew_leases(struct ia_xx *ia);
03611 isc_result_t release_leases(struct ia_xx *ia);
03612 isc_result_t decline_leases(struct ia_xx *ia);
03613 void schedule_lease_timeout(struct ipv6_pool *pool);
03614 void schedule_all_ipv6_lease_timeouts();
03615
03616 void mark_hosts_unavailable(void);
03617 void mark_phosts_unavailable(void);
03618 void mark_interfaces_unavailable(void);
03619
03620 #define MAX_ADDRESS_STRING_LEN \
03621 (sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"))