1 /* $OpenBSD: dhcpd.h,v 1.36 2008/05/07 12:19:20 beck Exp $ */ 2 3 /* 4 * Copyright (c) 1995, 1996, 1997, 1998, 1999 5 * The Internet Software Consortium. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of The Internet Software Consortium nor the names 17 * of its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND 21 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 22 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR 25 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 28 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * This software has been written for the Internet Software Consortium 35 * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie 36 * Enterprises. To learn more about the Internet Software Consortium, 37 * see ``http://www.vix.com/isc''. To learn more about Vixie 38 * Enterprises, see ``http://www.vix.com''. 39 */ 40 41 #include <sys/types.h> 42 #include <sys/socket.h> 43 #include <sys/stat.h> 44 #include <sys/wait.h> 45 #include <sys/sockio.h> 46 #include <sys/time.h> 47 48 #include <net/if.h> 49 #include <net/if_dl.h> 50 #include <net/route.h> 51 52 #include <netinet/in.h> 53 #include <arpa/inet.h> 54 55 #include <ctype.h> 56 #include <errno.h> 57 #include <fcntl.h> 58 #include <limits.h> 59 #include <netdb.h> 60 #include <paths.h> 61 #include <stdarg.h> 62 #include <stdio.h> 63 #include <stdlib.h> 64 #include <string.h> 65 #include <syslog.h> 66 #include <time.h> 67 #include <unistd.h> 68 69 #define ifr_netmask ifr_addr 70 71 #define HAVE_SA_LEN 72 #define HAVE_MKSTEMP 73 74 #include "dhcp.h" 75 #include "tree.h" 76 77 #define SERVER_PORT 67 78 #define CLIENT_PORT 68 79 80 struct iaddr { 81 int len; 82 unsigned char iabuf[16]; 83 }; 84 85 struct iaddrlist { 86 struct iaddrlist *next; 87 struct iaddr addr; 88 }; 89 90 #define DEFAULT_HASH_SIZE 97 91 92 struct hash_bucket { 93 struct hash_bucket *next; 94 unsigned char *name; 95 int len; 96 unsigned char *value; 97 }; 98 99 struct hash_table { 100 int hash_count; 101 struct hash_bucket *buckets[DEFAULT_HASH_SIZE]; 102 }; 103 104 struct option_data { 105 int len; 106 u_int8_t *data; 107 }; 108 109 struct string_list { 110 struct string_list *next; 111 char *string; 112 }; 113 114 /* A name server, from /etc/resolv.conf. */ 115 struct name_server { 116 struct name_server *next; 117 struct sockaddr_in addr; 118 time_t rcdate; 119 }; 120 121 /* A domain search list element. */ 122 struct domain_search_list { 123 struct domain_search_list *next; 124 char *domain; 125 time_t rcdate; 126 }; 127 128 /* A dhcp packet and the pointers to its option values. */ 129 struct packet { 130 struct dhcp_packet *raw; 131 int packet_length; 132 int packet_type; 133 int options_valid; 134 int client_port; 135 struct iaddr client_addr; 136 struct interface_info *interface; /* Interface on which packet 137 was received. */ 138 struct hardware *haddr; /* Physical link address 139 of local sender (maybe gateway). */ 140 struct shared_network *shared_network; 141 struct option_data options[256]; 142 int got_requested_address; /* True if client sent the 143 dhcp-requested-address option. */ 144 }; 145 146 struct hardware { 147 u_int8_t htype; 148 u_int8_t hlen; 149 u_int8_t haddr[16]; 150 }; 151 152 /* A dhcp lease declaration structure. */ 153 struct lease { 154 struct lease *next; 155 struct lease *prev; 156 struct lease *n_uid, *n_hw; 157 struct lease *waitq_next; 158 159 struct iaddr ip_addr; 160 time_t starts, ends, timestamp; 161 unsigned char *uid; 162 int uid_len; 163 int uid_max; 164 unsigned char uid_buf[32]; 165 char *hostname; 166 char *client_hostname; 167 struct host_decl *host; 168 struct subnet *subnet; 169 struct shared_network *shared_network; 170 struct hardware hardware_addr; 171 172 int flags; 173 #define STATIC_LEASE 1 174 #define BOOTP_LEASE 2 175 #define DYNAMIC_BOOTP_OK 4 176 #define PERSISTENT_FLAGS (DYNAMIC_BOOTP_OK) 177 #define EPHEMERAL_FLAGS (BOOTP_LEASE) 178 #define MS_NULL_TERMINATION 8 179 #define ABANDONED_LEASE 16 180 181 struct lease_state *state; 182 u_int8_t releasing; 183 }; 184 185 struct lease_state { 186 struct lease_state *next; 187 188 struct interface_info *ip; 189 190 time_t offered_expiry; 191 192 struct tree_cache *options[256]; 193 u_int32_t expiry, renewal, rebind; 194 char filename[DHCP_FILE_LEN]; 195 char *server_name; 196 197 struct iaddr from; 198 199 int max_message_size; 200 u_int8_t *prl; 201 int prl_len; 202 int got_requested_address; /* True if client sent the 203 dhcp-requested-address option. */ 204 int got_server_identifier; /* True if client sent the 205 dhcp-server-identifier option. */ 206 struct shared_network *shared_network; /* Shared network of interface 207 on which request arrived. */ 208 209 u_int32_t xid; 210 u_int16_t secs; 211 u_int16_t bootp_flags; 212 struct in_addr ciaddr; 213 struct in_addr giaddr; 214 u_int8_t hops; 215 u_int8_t offer; 216 struct hardware haddr; 217 }; 218 219 #define ROOT_GROUP 0 220 #define HOST_DECL 1 221 #define SHARED_NET_DECL 2 222 #define SUBNET_DECL 3 223 #define CLASS_DECL 4 224 #define GROUP_DECL 5 225 226 /* Group of declarations that share common parameters. */ 227 struct group { 228 struct group *next; 229 230 struct subnet *subnet; 231 struct shared_network *shared_network; 232 233 time_t default_lease_time; 234 time_t max_lease_time; 235 time_t bootp_lease_cutoff; 236 time_t bootp_lease_length; 237 238 char *filename; 239 char *server_name; 240 struct iaddr next_server; 241 242 int boot_unknown_clients; 243 int dynamic_bootp; 244 int allow_bootp; 245 int allow_booting; 246 int get_lease_hostnames; 247 int use_host_decl_names; 248 int use_lease_addr_for_default_route; 249 int authoritative; 250 int always_reply_rfc1048; 251 252 struct tree_cache *options[256]; 253 }; 254 255 /* A dhcp host declaration structure. */ 256 struct host_decl { 257 struct host_decl *n_ipaddr; 258 char *name; 259 struct hardware interface; 260 struct tree_cache *fixed_addr; 261 struct group *group; 262 }; 263 264 struct shared_network { 265 struct shared_network *next; 266 char *name; 267 struct subnet *subnets; 268 struct interface_info *interface; 269 struct lease *leases; 270 struct lease *insertion_point; 271 struct lease *last_lease; 272 273 struct group *group; 274 }; 275 276 struct subnet { 277 struct subnet *next_subnet; 278 struct subnet *next_sibling; 279 struct shared_network *shared_network; 280 struct interface_info *interface; 281 struct iaddr interface_address; 282 struct iaddr net; 283 struct iaddr netmask; 284 285 struct group *group; 286 }; 287 288 struct class { 289 char *name; 290 291 struct group *group; 292 }; 293 294 /* DHCP client lease structure... */ 295 struct client_lease { 296 struct client_lease *next; /* Next lease in list. */ 297 time_t expiry, renewal, rebind; /* Lease timeouts. */ 298 struct iaddr address; /* Address being leased. */ 299 char *server_name; /* Name of boot server. */ 300 char *filename; /* File to boot. */ 301 struct string_list *medium; /* Network medium. */ 302 303 unsigned int is_static : 1; /* If set, lease is from config file. */ 304 unsigned int is_bootp: 1; /* If set, lease was aquired with BOOTP. */ 305 306 struct option_data options[256]; /* Options supplied with lease. */ 307 }; 308 309 /* privsep message. fixed length for easy parsing */ 310 struct pf_cmd { 311 struct in_addr ip; 312 u_int32_t type; 313 }; 314 315 /* Possible states in which the client can be. */ 316 enum dhcp_state { 317 S_REBOOTING, 318 S_INIT, 319 S_SELECTING, 320 S_REQUESTING, 321 S_BOUND, 322 S_RENEWING, 323 S_REBINDING 324 }; 325 326 /* Configuration information from the config file... */ 327 struct client_config { 328 struct option_data defaults[256]; /* Default values for options. */ 329 enum { 330 ACTION_DEFAULT, /* Use server value if present, 331 otherwise default. */ 332 ACTION_SUPERSEDE, /* Always use default. */ 333 ACTION_PREPEND, /* Prepend default to server. */ 334 ACTION_APPEND /* Append default to server. */ 335 } default_actions[256]; 336 337 struct option_data send_options[256]; /* Send these to server. */ 338 u_int8_t required_options[256]; /* Options server must supply. */ 339 u_int8_t requested_options[256]; /* Options to request from server. */ 340 int requested_option_count; /* Number of requested options. */ 341 time_t timeout; /* Start to panic if we don't get a 342 lease in this time period when 343 SELECTING. */ 344 time_t initial_interval; /* All exponential backoff intervals 345 start here. */ 346 time_t retry_interval; /* If the protocol failed to produce 347 an address before the timeout, 348 try the protocol again after this 349 many seconds. */ 350 time_t select_interval; /* Wait this many seconds from the 351 first DHCPDISCOVER before 352 picking an offered lease. */ 353 time_t reboot_timeout; /* When in INIT-REBOOT, wait this 354 long before giving up and going 355 to INIT. */ 356 time_t backoff_cutoff; /* When doing exponential backoff, 357 never back off to an interval 358 longer than this amount. */ 359 struct string_list *media; /* Possible network media values. */ 360 char *script_name; /* Name of config script. */ 361 enum { IGNORE, ACCEPT, PREFER } bootp_policy; 362 /* Ignore, accept or prefer BOOTP 363 responses. */ 364 struct string_list *medium; /* Current network medium. */ 365 366 struct iaddrlist *reject_list; /* Servers to reject. */ 367 }; 368 369 /* Per-interface state used in the dhcp client... */ 370 struct client_state { 371 struct client_lease *active; /* Currently active lease. */ 372 struct client_lease *new; /* New lease. */ 373 struct client_lease *offered_leases; /* Leases offered to us. */ 374 struct client_lease *leases; /* Leases we currently hold. */ 375 struct client_lease *alias; /* Alias lease. */ 376 377 enum dhcp_state state; /* Current state for this interface. */ 378 struct iaddr destination; /* Where to send packet. */ 379 u_int32_t xid; /* Transaction ID. */ 380 u_int16_t secs; /* secs value from DHCPDISCOVER. */ 381 time_t first_sending; /* When was first copy sent? */ 382 time_t interval; /* What's the current resend interval? */ 383 struct string_list *medium; /* Last media type tried. */ 384 385 struct dhcp_packet packet; /* Outgoing DHCP packet. */ 386 int packet_length; /* Actual length of generated packet. */ 387 388 struct iaddr requested_address; /* Address we would like to get. */ 389 390 struct client_config *config; /* Information from config file. */ 391 392 char **scriptEnv; /* Client script env */ 393 int scriptEnvsize; /* size of the env table */ 394 395 struct string_list *env; /* Client script environment. */ 396 int envc; /* Number of entries in environment. */ 397 }; 398 399 /* Information about each network interface. */ 400 401 struct interface_info { 402 struct interface_info *next; /* Next interface in list... */ 403 struct shared_network *shared_network; 404 /* Networks connected to this interface. */ 405 struct hardware hw_address; /* Its physical address. */ 406 struct in_addr primary_address; /* Primary interface address. */ 407 char name[IFNAMSIZ]; /* Its name... */ 408 int rfdesc; /* Its read file descriptor. */ 409 int wfdesc; /* Its write file descriptor, if 410 different. */ 411 unsigned char *rbuf; /* Read buffer, if required. */ 412 size_t rbuf_max; /* Size of read buffer. */ 413 size_t rbuf_offset; /* Current offset into buffer. */ 414 size_t rbuf_len; /* Length of data in buffer. */ 415 416 struct ifreq *ifp; /* Pointer to ifreq struct. */ 417 418 /* Only used by DHCP client code. */ 419 struct client_state *client; 420 int noifmedia; 421 int errors; 422 int dead; 423 u_int16_t index; 424 }; 425 426 struct hardware_link { 427 struct hardware_link *next; 428 char name[IFNAMSIZ]; 429 struct hardware address; 430 }; 431 432 struct dhcpd_timeout { 433 struct dhcpd_timeout *next; 434 time_t when; 435 void (*func)(void *); 436 void *what; 437 }; 438 439 struct protocol { 440 struct protocol *next; 441 int fd; 442 void (*handler)(struct protocol *); 443 void *local; 444 }; 445 446 /* Bitmask of dhcp option codes. */ 447 typedef unsigned char option_mask[16]; 448 449 /* DHCP Option mask manipulation macros... */ 450 #define OPTION_ZERO(mask) (memset (mask, 0, 16)) 451 #define OPTION_SET(mask, bit) (mask[bit >> 8] |= (1 << (bit & 7))) 452 #define OPTION_CLR(mask, bit) (mask[bit >> 8] &= ~(1 << (bit & 7))) 453 #define OPTION_ISSET(mask, bit) (mask[bit >> 8] & (1 << (bit & 7))) 454 #define OPTION_ISCLR(mask, bit) (!OPTION_ISSET (mask, bit)) 455 456 /* An option occupies its length plus two header bytes (code and 457 length) for every 255 bytes that must be stored. */ 458 #define OPTION_SPACE(x) ((x) + 2 * ((x) / 255 + 1)) 459 460 #define _PATH_DHCPD_CONF "/etc/dhcpd.conf" 461 #define _PATH_DHCPD_DB "/var/db/dhcpd.leases" 462 #define _PATH_DEV_PF "/dev/pf" 463 #define DHCPD_LOG_FACILITY LOG_DAEMON 464 465 #define MAX_TIME 0x7fffffff 466 #define MIN_TIME 0 467 468 /* External definitions... */ 469 470 /* options.c */ 471 void parse_options(struct packet *); 472 void parse_option_buffer(struct packet *, unsigned char *, int); 473 int cons_options(struct packet *, struct dhcp_packet *, int, 474 struct tree_cache **, int, int, int, u_int8_t *, int); 475 char *pretty_print_option(unsigned int, unsigned char *, int, int, int); 476 void do_packet(struct interface_info *, struct dhcp_packet *, int, 477 unsigned int, struct iaddr, struct hardware *); 478 479 /* errwarn.c */ 480 extern int warnings_occurred; 481 void error(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 482 int warning(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 483 int note(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 484 int debug(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 485 int parse_warn(char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); 486 487 /* dhcpd.c */ 488 extern time_t cur_time; 489 extern struct group root_group; 490 491 extern u_int16_t server_port; 492 extern u_int16_t client_port; 493 extern int log_priority; 494 extern int log_perror; 495 496 extern char *path_dhcpd_conf; 497 extern char *path_dhcpd_db; 498 499 int main(int, char *[]); 500 void cleanup(void); 501 void lease_pinged(struct iaddr, u_int8_t *, int); 502 void lease_ping_timeout(void *); 503 void periodic_scan(void *); 504 505 /* conflex.c */ 506 extern int lexline, lexchar; 507 extern char *token_line, *tlname; 508 extern char comments[4096]; 509 extern int comment_index; 510 extern int eol_token; 511 512 void new_parse(char *); 513 int next_token(char **, FILE *); 514 int peek_token(char **, FILE *); 515 516 /* confpars.c */ 517 int readconf(void); 518 void read_leases(void); 519 int parse_statement(FILE *, struct group *, int, struct host_decl *, int); 520 void parse_allow_deny(FILE *, struct group *, int); 521 void skip_to_semi(FILE *); 522 int parse_boolean(FILE *); 523 int parse_semi(FILE *); 524 int parse_lbrace(FILE *); 525 void parse_host_declaration(FILE *, struct group *); 526 char *parse_host_name(FILE *); 527 void parse_class_declaration(FILE *, struct group *, int); 528 void parse_lease_time(FILE *, time_t *); 529 void parse_shared_net_declaration(FILE *, struct group *); 530 void parse_subnet_declaration(FILE *, struct shared_network *); 531 void parse_group_declaration(FILE *, struct group *); 532 void parse_hardware_param(FILE *, struct hardware *); 533 char *parse_string(FILE *); 534 535 struct tree *parse_ip_addr_or_hostname(FILE *, int); 536 struct tree_cache *parse_fixed_addr_param(FILE *); 537 void parse_option_param(FILE *, struct group *); 538 time_t parse_timestamp(FILE *); 539 struct lease *parse_lease_declaration(FILE *); 540 void parse_address_range(FILE *, struct subnet *); 541 time_t parse_date(FILE *); 542 unsigned char *parse_numeric_aggregate(FILE *, unsigned char *, int *, 543 int, int, int); 544 void convert_num(unsigned char *, char *, int, int); 545 546 /* tree.c */ 547 pair cons(caddr_t, pair); 548 struct tree_cache *tree_cache(struct tree *); 549 struct tree *tree_host_lookup(char *); 550 struct dns_host_entry *enter_dns_host(char *); 551 struct tree *tree_const(unsigned char *, int); 552 struct tree *tree_concat(struct tree *, struct tree *); 553 struct tree *tree_limit(struct tree *, int); 554 int tree_evaluate(struct tree_cache *); 555 556 /* dhcp.c */ 557 extern int outstanding_pings; 558 559 void dhcp(struct packet *); 560 void dhcpdiscover(struct packet *); 561 void dhcprequest(struct packet *); 562 void dhcprelease(struct packet *); 563 void dhcpdecline(struct packet *); 564 void dhcpinform(struct packet *); 565 void nak_lease(struct packet *, struct iaddr *cip); 566 void ack_lease(struct packet *, struct lease *, unsigned int, time_t); 567 void dhcp_reply(struct lease *); 568 struct lease *find_lease(struct packet *, struct shared_network *, int *); 569 struct lease *mockup_lease(struct packet *, struct shared_network *, 570 struct host_decl *); 571 572 /* bootp.c */ 573 void bootp(struct packet *); 574 575 /* memory.c */ 576 void enter_host(struct host_decl *); 577 struct host_decl *find_hosts_by_haddr(int, unsigned char *, int); 578 struct host_decl *find_hosts_by_uid(unsigned char *, int); 579 struct subnet *find_host_for_network(struct host_decl **, struct iaddr *, 580 struct shared_network *); 581 void new_address_range(struct iaddr, struct iaddr, struct subnet *, int); 582 extern struct subnet *find_grouped_subnet(struct shared_network *, 583 struct iaddr); 584 extern struct subnet *find_subnet(struct iaddr); 585 void enter_shared_network(struct shared_network *); 586 int subnet_inner_than(struct subnet *, struct subnet *, int); 587 void enter_subnet(struct subnet *); 588 void enter_lease(struct lease *); 589 int supersede_lease(struct lease *, struct lease *, int); 590 void release_lease(struct lease *); 591 void abandon_lease(struct lease *, char *); 592 struct lease *find_lease_by_uid(unsigned char *, int); 593 struct lease *find_lease_by_hw_addr(unsigned char *, int); 594 struct lease *find_lease_by_ip_addr(struct iaddr); 595 void uid_hash_add(struct lease *); 596 void uid_hash_delete(struct lease *); 597 void hw_hash_add(struct lease *); 598 void hw_hash_delete(struct lease *); 599 struct class *add_class(int, char *); 600 struct class *find_class(int, unsigned char *, int); 601 struct group *clone_group(struct group *, char *); 602 void write_leases(void); 603 604 /* alloc.c */ 605 void * dmalloc(int, char *); 606 void dfree(void *, char *); 607 struct packet *new_packet(char *); 608 struct dhcp_packet *new_dhcp_packet(char *); 609 struct tree *new_tree(char *); 610 struct tree_cache *new_tree_cache(char *); 611 struct hash_table *new_hash_table(int, char *); 612 struct hash_bucket *new_hash_bucket(char *); 613 struct lease *new_lease(char *); 614 struct lease *new_leases(int, char *); 615 struct subnet *new_subnet(char *); 616 struct class *new_class(char *); 617 struct shared_network *new_shared_network(char *); 618 struct group *new_group(char *); 619 struct protocol *new_protocol(char *); 620 struct lease_state *new_lease_state(char *); 621 struct domain_search_list *new_domain_search_list(char *); 622 struct name_server *new_name_server(char *); 623 void free_name_server(struct name_server *, char *); 624 void free_domain_search_list(struct domain_search_list *, char *); 625 void free_lease_state(struct lease_state *, char *); 626 void free_protocol(struct protocol *, char *); 627 void free_group(struct group *, char *); 628 void free_shared_network(struct shared_network *, char *); 629 void free_class(struct class *, char *); 630 void free_subnet(struct subnet *, char *); 631 void free_lease(struct lease *, char *); 632 void free_hash_bucket(struct hash_bucket *, char *); 633 void free_tree_cache(struct tree_cache *); 634 void free_tree(struct tree *, char *); 635 636 /* print.c */ 637 char *print_hw_addr(int, int, unsigned char *); 638 639 /* bpf.c */ 640 int if_register_bpf(struct interface_info *); 641 void if_register_send(struct interface_info *); 642 ssize_t send_packet(struct interface_info *, struct dhcp_packet *, size_t, 643 struct in_addr, struct sockaddr_in *, struct hardware *); 644 void if_register_receive(struct interface_info *); 645 ssize_t receive_packet(struct interface_info *, unsigned char *, size_t, 646 struct sockaddr_in *, struct hardware *); 647 648 /* dispatch.c */ 649 extern struct interface_info *interfaces; 650 extern struct protocol *protocols; 651 extern void (*bootp_packet_handler)(struct interface_info *, 652 struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *); 653 extern struct dhcpd_timeout *timeouts; 654 void discover_interfaces(void); 655 void dispatch(void); 656 int locate_network(struct packet *); 657 void got_one(struct protocol *); 658 void add_timeout(time_t, void (*)(void *), void *); 659 void cancel_timeout(void (*)(void *), void *); 660 void add_protocol (char *, int, void (*)(struct protocol *), void *); 661 void remove_protocol(struct protocol *); 662 663 /* hash.c */ 664 struct hash_table *new_hash(void); 665 void add_hash(struct hash_table *, unsigned char *, int, unsigned char *); 666 void delete_hash_entry(struct hash_table *, unsigned char *, int); 667 unsigned char *hash_lookup(struct hash_table *, unsigned char *, int); 668 669 /* tables.c */ 670 extern struct option dhcp_options[256]; 671 extern unsigned char dhcp_option_default_priority_list[256]; 672 extern char *hardware_types[256]; 673 extern struct hash_table universe_hash; 674 extern struct universe dhcp_universe; 675 void initialize_universes(void); 676 677 /* convert.c */ 678 u_int32_t getULong(unsigned char *); 679 int32_t getLong(unsigned char *); 680 u_int16_t getUShort(unsigned char *); 681 int16_t getShort(unsigned char *); 682 void putULong(unsigned char *, u_int32_t); 683 void putLong(unsigned char *, int32_t); 684 void putUShort(unsigned char *, unsigned int); 685 void putShort(unsigned char *, int); 686 687 /* inet.c */ 688 struct iaddr subnet_number(struct iaddr, struct iaddr); 689 struct iaddr ip_addr(struct iaddr, struct iaddr, u_int32_t); 690 u_int32_t host_addr(struct iaddr, struct iaddr); 691 int addr_eq(struct iaddr, struct iaddr); 692 char *piaddr(struct iaddr); 693 694 /* db.c */ 695 int write_lease(struct lease *); 696 int commit_leases(void); 697 void db_startup(void); 698 void new_lease_file(void); 699 700 /* packet.c */ 701 void assemble_hw_header(struct interface_info *, unsigned char *, 702 int *, struct hardware *); 703 void assemble_udp_ip_header(struct interface_info *, unsigned char *, 704 int *, u_int32_t, u_int32_t, unsigned int, unsigned char *, int); 705 ssize_t decode_hw_header(struct interface_info *, unsigned char *, 706 int, struct hardware *); 707 ssize_t decode_udp_ip_header(struct interface_info *, unsigned char *, 708 int, struct sockaddr_in *, unsigned char *, int); 709 u_int32_t checksum(unsigned char *, unsigned, u_int32_t); 710 u_int32_t wrapsum(u_int32_t); 711 712 /* icmp.c */ 713 void icmp_startup(int, void (*)(struct iaddr, u_int8_t *, int)); 714 int icmp_echorequest(struct iaddr *); 715 void icmp_echoreply(struct protocol *); 716 717 /* pfutils.c */ 718 __dead void pftable_handler(void); 719 void pf_change_table(int, int, struct in_addr, char *); 720 void pf_kill_state(int, struct in_addr); 721 size_t atomicio(ssize_t (*)(int, void *, size_t), int, void *, size_t); 722 #define vwrite (ssize_t (*)(int, void *, size_t))write 723 void pfmsg(char, struct lease *); 724 extern struct syslog_data sdata; 725