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