xref: /freebsd/sbin/dhclient/dhcpd.h (revision 76e0ffd9f8fd09f8790a4d96581782225d9019ea)
147c08596SBrooks Davis /*	$OpenBSD: dhcpd.h,v 1.33 2004/05/06 22:29:15 deraadt Exp $	*/
247c08596SBrooks Davis 
38a16b7a1SPedro F. Giffuni /*-
48a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
58a16b7a1SPedro F. Giffuni  *
647c08596SBrooks Davis  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
747c08596SBrooks Davis  * Copyright (c) 1995, 1996, 1997, 1998, 1999
847c08596SBrooks Davis  * The Internet Software Consortium.    All rights reserved.
947c08596SBrooks Davis  *
1047c08596SBrooks Davis  * Redistribution and use in source and binary forms, with or without
1147c08596SBrooks Davis  * modification, are permitted provided that the following conditions
1247c08596SBrooks Davis  * are met:
1347c08596SBrooks Davis  *
1447c08596SBrooks Davis  * 1. Redistributions of source code must retain the above copyright
1547c08596SBrooks Davis  *    notice, this list of conditions and the following disclaimer.
1647c08596SBrooks Davis  * 2. Redistributions in binary form must reproduce the above copyright
1747c08596SBrooks Davis  *    notice, this list of conditions and the following disclaimer in the
1847c08596SBrooks Davis  *    documentation and/or other materials provided with the distribution.
1947c08596SBrooks Davis  * 3. Neither the name of The Internet Software Consortium nor the names
2047c08596SBrooks Davis  *    of its contributors may be used to endorse or promote products derived
2147c08596SBrooks Davis  *    from this software without specific prior written permission.
2247c08596SBrooks Davis  *
2347c08596SBrooks Davis  * THIS SOFTWARE IS PROVIDED BY THE INTERNET SOFTWARE CONSORTIUM AND
2447c08596SBrooks Davis  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
2547c08596SBrooks Davis  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
2647c08596SBrooks Davis  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2747c08596SBrooks Davis  * DISCLAIMED.  IN NO EVENT SHALL THE INTERNET SOFTWARE CONSORTIUM OR
2847c08596SBrooks Davis  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2947c08596SBrooks Davis  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
3047c08596SBrooks Davis  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
3147c08596SBrooks Davis  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3247c08596SBrooks Davis  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
3347c08596SBrooks Davis  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
3447c08596SBrooks Davis  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3547c08596SBrooks Davis  * SUCH DAMAGE.
3647c08596SBrooks Davis  *
3747c08596SBrooks Davis  * This software has been written for the Internet Software Consortium
3847c08596SBrooks Davis  * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
3947c08596SBrooks Davis  * Enterprises.  To learn more about the Internet Software Consortium,
4047c08596SBrooks Davis  * see ``http://www.vix.com/isc''.  To learn more about Vixie
4147c08596SBrooks Davis  * Enterprises, see ``http://www.vix.com''.
4247c08596SBrooks Davis  */
4347c08596SBrooks Davis 
4423f39c90SDag-Erling Smørgrav #include <sys/param.h>
4547c08596SBrooks Davis 
4647c08596SBrooks Davis #include <sys/socket.h>
4747c08596SBrooks Davis #include <sys/sockio.h>
4847c08596SBrooks Davis #include <sys/stat.h>
4947c08596SBrooks Davis #include <sys/time.h>
5047c08596SBrooks Davis #include <sys/un.h>
5147c08596SBrooks Davis #include <sys/wait.h>
5247c08596SBrooks Davis 
5347c08596SBrooks Davis #include <net/if.h>
5447c08596SBrooks Davis #include <net/if_dl.h>
5547c08596SBrooks Davis #include <net/route.h>
5647c08596SBrooks Davis 
5747c08596SBrooks Davis #include <netinet/in.h>
5847c08596SBrooks Davis #include <arpa/inet.h>
5947c08596SBrooks Davis 
6047c08596SBrooks Davis #include <ctype.h>
6147c08596SBrooks Davis #include <errno.h>
6247c08596SBrooks Davis #include <fcntl.h>
6323f39c90SDag-Erling Smørgrav #include <libutil.h>
6447c08596SBrooks Davis #include <limits.h>
6547c08596SBrooks Davis #include <netdb.h>
6647c08596SBrooks Davis #include <paths.h>
6747c08596SBrooks Davis #include <unistd.h>
6847c08596SBrooks Davis #include <stdarg.h>
6947c08596SBrooks Davis #include <stdio.h>
7047c08596SBrooks Davis #include <stdlib.h>
7147c08596SBrooks Davis #include <string.h>
7247c08596SBrooks Davis #include <syslog.h>
7347c08596SBrooks Davis #include <time.h>
7447c08596SBrooks Davis #include <unistd.h>
7547c08596SBrooks Davis 
76cb003dd9SMariusz Zaborski #include <libcasper.h>
77cb003dd9SMariusz Zaborski #include <casper/cap_syslog.h>
78cb003dd9SMariusz Zaborski 
7947c08596SBrooks Davis #include "dhcp.h"
8047c08596SBrooks Davis #include "tree.h"
8147c08596SBrooks Davis 
8247c08596SBrooks Davis #define	LOCAL_PORT	68
8347c08596SBrooks Davis #define	REMOTE_PORT	67
8447c08596SBrooks Davis 
8547c08596SBrooks Davis struct option_data {
86afe6f835SAlan Somers 	size_t		 len;
8747c08596SBrooks Davis 	u_int8_t	*data;
8847c08596SBrooks Davis };
8947c08596SBrooks Davis 
9047c08596SBrooks Davis struct string_list {
9147c08596SBrooks Davis 	struct string_list	*next;
9247c08596SBrooks Davis 	char			*string;
9347c08596SBrooks Davis };
9447c08596SBrooks Davis 
9547c08596SBrooks Davis struct iaddr {
96afe6f835SAlan Somers 	size_t len;
9747c08596SBrooks Davis 	unsigned char iabuf[16];
9847c08596SBrooks Davis };
9947c08596SBrooks Davis 
10047c08596SBrooks Davis struct iaddrlist {
10147c08596SBrooks Davis 	struct iaddrlist *next;
10247c08596SBrooks Davis 	struct iaddr addr;
10347c08596SBrooks Davis };
10447c08596SBrooks Davis 
10547c08596SBrooks Davis struct packet {
10647c08596SBrooks Davis 	struct dhcp_packet	*raw;
10747c08596SBrooks Davis 	int			 packet_length;
10847c08596SBrooks Davis 	int			 packet_type;
10947c08596SBrooks Davis 	int			 options_valid;
11047c08596SBrooks Davis 	int			 client_port;
11147c08596SBrooks Davis 	struct iaddr		 client_addr;
11247c08596SBrooks Davis 	struct interface_info	*interface;
11347c08596SBrooks Davis 	struct hardware		*haddr;
11447c08596SBrooks Davis 	struct option_data	 options[256];
11547c08596SBrooks Davis };
11647c08596SBrooks Davis 
11747c08596SBrooks Davis struct hardware {
11847c08596SBrooks Davis 	u_int8_t htype;
11947c08596SBrooks Davis 	u_int8_t hlen;
12047c08596SBrooks Davis 	u_int8_t haddr[16];
12147c08596SBrooks Davis };
12247c08596SBrooks Davis 
12347c08596SBrooks Davis struct client_lease {
12447c08596SBrooks Davis 	struct client_lease	*next;
12547c08596SBrooks Davis 	time_t			 expiry, renewal, rebind;
12647c08596SBrooks Davis 	struct iaddr		 address;
127d32438c3SBruce M Simpson 	struct iaddr		 nextserver;
12847c08596SBrooks Davis 	char			*server_name;
12947c08596SBrooks Davis 	char			*filename;
13047c08596SBrooks Davis 	struct string_list	*medium;
13147c08596SBrooks Davis 	unsigned int		 is_static : 1;
13247c08596SBrooks Davis 	unsigned int		 is_bootp : 1;
13347c08596SBrooks Davis 	struct option_data	 options[256];
13447c08596SBrooks Davis };
13547c08596SBrooks Davis 
13647c08596SBrooks Davis /* Possible states in which the client can be. */
13747c08596SBrooks Davis enum dhcp_state {
13847c08596SBrooks Davis 	S_REBOOTING,
13947c08596SBrooks Davis 	S_INIT,
14047c08596SBrooks Davis 	S_SELECTING,
14147c08596SBrooks Davis 	S_REQUESTING,
14247c08596SBrooks Davis 	S_BOUND,
14347c08596SBrooks Davis 	S_RENEWING,
14447c08596SBrooks Davis 	S_REBINDING
14547c08596SBrooks Davis };
14647c08596SBrooks Davis 
14747c08596SBrooks Davis struct client_config {
14847c08596SBrooks Davis 	struct option_data	defaults[256];
14947c08596SBrooks Davis 	enum {
15047c08596SBrooks Davis 		ACTION_DEFAULT,
15147c08596SBrooks Davis 		ACTION_SUPERSEDE,
15247c08596SBrooks Davis 		ACTION_PREPEND,
15347c08596SBrooks Davis 		ACTION_APPEND
15447c08596SBrooks Davis 	} default_actions[256];
15547c08596SBrooks Davis 
15647c08596SBrooks Davis 	struct option_data	 send_options[256];
15747c08596SBrooks Davis 	u_int8_t		 required_options[256];
15847c08596SBrooks Davis 	u_int8_t		 requested_options[256];
15947c08596SBrooks Davis 	int			 requested_option_count;
160461ccb55SRob Norris 	u_int8_t		 ignored_options[256];
1611e7fe2fbSLuiz Otavio O Souza 	u_int			 vlan_pcp;
16247c08596SBrooks Davis 	time_t			 timeout;
16347c08596SBrooks Davis 	time_t			 initial_interval;
16447c08596SBrooks Davis 	time_t			 retry_interval;
16547c08596SBrooks Davis 	time_t			 select_interval;
16647c08596SBrooks Davis 	time_t			 reboot_timeout;
16747c08596SBrooks Davis 	time_t			 backoff_cutoff;
16847c08596SBrooks Davis 	struct string_list	*media;
16947c08596SBrooks Davis 	char			*script_name;
17047c08596SBrooks Davis 	enum { IGNORE, ACCEPT, PREFER }
17147c08596SBrooks Davis 				 bootp_policy;
17247c08596SBrooks Davis 	struct string_list	*medium;
17347c08596SBrooks Davis 	struct iaddrlist	*reject_list;
17447c08596SBrooks Davis };
17547c08596SBrooks Davis 
17647c08596SBrooks Davis struct client_state {
17747c08596SBrooks Davis 	struct client_lease	 *active;
17847c08596SBrooks Davis 	struct client_lease	 *new;
17947c08596SBrooks Davis 	struct client_lease	 *offered_leases;
18047c08596SBrooks Davis 	struct client_lease	 *leases;
18147c08596SBrooks Davis 	struct client_lease	 *alias;
18247c08596SBrooks Davis 	enum dhcp_state		  state;
18347c08596SBrooks Davis 	struct iaddr		  destination;
18447c08596SBrooks Davis 	u_int32_t		  xid;
18547c08596SBrooks Davis 	u_int16_t		  secs;
18647c08596SBrooks Davis 	time_t			  first_sending;
18747c08596SBrooks Davis 	time_t			  interval;
18847c08596SBrooks Davis 	struct string_list	 *medium;
18947c08596SBrooks Davis 	struct dhcp_packet	  packet;
19047c08596SBrooks Davis 	int			  packet_length;
19147c08596SBrooks Davis 	struct iaddr		  requested_address;
19247c08596SBrooks Davis 	struct client_config	 *config;
19347c08596SBrooks Davis 	char			**scriptEnv;
19447c08596SBrooks Davis 	int			  scriptEnvsize;
19547c08596SBrooks Davis 	struct string_list	 *env;
19647c08596SBrooks Davis 	int			  envc;
19747c08596SBrooks Davis };
19847c08596SBrooks Davis 
19947c08596SBrooks Davis struct interface_info {
20047c08596SBrooks Davis 	struct interface_info	*next;
20147c08596SBrooks Davis 	struct hardware		 hw_address;
20247c08596SBrooks Davis 	char			 name[IFNAMSIZ];
20347c08596SBrooks Davis 	int			 rfdesc;
20447c08596SBrooks Davis 	int			 wfdesc;
2059b683f8dSPhilip Paeps 	int			 ufdesc;
20647c08596SBrooks Davis 	unsigned char		*rbuf;
20747c08596SBrooks Davis 	size_t			 rbuf_max;
20847c08596SBrooks Davis 	size_t			 rbuf_offset;
20947c08596SBrooks Davis 	size_t			 rbuf_len;
21047c08596SBrooks Davis 	struct ifreq		*ifp;
21147c08596SBrooks Davis 	struct client_state	*client;
21247c08596SBrooks Davis 	int			 noifmedia;
21347c08596SBrooks Davis 	int			 errors;
21447c08596SBrooks Davis 	int			 dead;
21547c08596SBrooks Davis 	u_int16_t		 index;
2160a26f858SJohn Baldwin 	int			 linkstat;
21747c08596SBrooks Davis };
21847c08596SBrooks Davis 
21947c08596SBrooks Davis struct timeout {
22047c08596SBrooks Davis 	struct timeout	*next;
22116a235f2SIsaac Cilia Attard 	struct timespec	 when;
22247c08596SBrooks Davis 	void		 (*func)(void *);
22347c08596SBrooks Davis 	void		*what;
22447c08596SBrooks Davis };
22547c08596SBrooks Davis 
22647c08596SBrooks Davis struct protocol {
22747c08596SBrooks Davis 	struct protocol	*next;
22847c08596SBrooks Davis 	int fd;
22947c08596SBrooks Davis 	void (*handler)(struct protocol *);
23047c08596SBrooks Davis 	void *local;
23147c08596SBrooks Davis };
23247c08596SBrooks Davis 
23347c08596SBrooks Davis #define DEFAULT_HASH_SIZE 97
23447c08596SBrooks Davis 
23547c08596SBrooks Davis struct hash_bucket {
23647c08596SBrooks Davis 	struct hash_bucket *next;
23779a1d195SAlan Somers 	const unsigned char *name;
23847c08596SBrooks Davis 	int len;
23947c08596SBrooks Davis 	unsigned char *value;
24047c08596SBrooks Davis };
24147c08596SBrooks Davis 
24247c08596SBrooks Davis struct hash_table {
24347c08596SBrooks Davis 	int hash_count;
24447c08596SBrooks Davis 	struct hash_bucket *buckets[DEFAULT_HASH_SIZE];
24547c08596SBrooks Davis };
24647c08596SBrooks Davis 
24747c08596SBrooks Davis /* Default path to dhcpd config file. */
24847c08596SBrooks Davis #define	_PATH_DHCLIENT_CONF	"/etc/dhclient.conf"
24947c08596SBrooks Davis #define	_PATH_DHCLIENT_DB	"/var/db/dhclient.leases"
25047c08596SBrooks Davis #define	DHCPD_LOG_FACILITY	LOG_DAEMON
25147c08596SBrooks Davis 
25247c08596SBrooks Davis #define	MAX_TIME 0x7fffffff
25347c08596SBrooks Davis #define	MIN_TIME 0
25447c08596SBrooks Davis 
25547c08596SBrooks Davis /* External definitions... */
25647c08596SBrooks Davis 
25747c08596SBrooks Davis /* options.c */
25847c08596SBrooks Davis int cons_options(struct packet *, struct dhcp_packet *, int,
25947c08596SBrooks Davis     struct tree_cache **, int, int, int, u_int8_t *, int);
26079a1d195SAlan Somers const char *pretty_print_option(unsigned int,
26147c08596SBrooks Davis     unsigned char *, int, int, int);
26247c08596SBrooks Davis void do_packet(struct interface_info *, struct dhcp_packet *,
26347c08596SBrooks Davis     int, unsigned int, struct iaddr, struct hardware *);
26447c08596SBrooks Davis 
26547c08596SBrooks Davis /* errwarn.c */
26647c08596SBrooks Davis extern int warnings_occurred;
26771c6c44dSEitan Adler void error(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))) __dead2;
26879a1d195SAlan Somers int warning(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
26979a1d195SAlan Somers int note(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
27079a1d195SAlan Somers int debug(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
27179a1d195SAlan Somers int parse_warn(const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
27247c08596SBrooks Davis 
27347c08596SBrooks Davis /* conflex.c */
27447c08596SBrooks Davis extern int lexline, lexchar;
27579a1d195SAlan Somers extern char *token_line;
27679a1d195SAlan Somers extern const char *tlname;
27747c08596SBrooks Davis extern char comments[4096];
27847c08596SBrooks Davis extern int comment_index;
27947c08596SBrooks Davis extern int eol_token;
28079a1d195SAlan Somers void new_parse(const char *);
28147c08596SBrooks Davis int next_token(char **, FILE *);
28247c08596SBrooks Davis int peek_token(char **, FILE *);
28347c08596SBrooks Davis 
28447c08596SBrooks Davis /* parse.c */
28547c08596SBrooks Davis void skip_to_semi(FILE *);
28647c08596SBrooks Davis int parse_semi(FILE *);
28747c08596SBrooks Davis char *parse_string(FILE *);
28847c08596SBrooks Davis int parse_ip_addr(FILE *, struct iaddr *);
28947c08596SBrooks Davis void parse_hardware_param(FILE *, struct hardware *);
29047c08596SBrooks Davis void parse_lease_time(FILE *, time_t *);
291afe6f835SAlan Somers unsigned char *parse_numeric_aggregate(FILE *, unsigned char *, size_t *,
292afe6f835SAlan Somers     int, unsigned, int);
293afe6f835SAlan Somers void convert_num(unsigned char *, char *, unsigned, int);
29447c08596SBrooks Davis time_t parse_date(FILE *);
29547c08596SBrooks Davis 
29647c08596SBrooks Davis /* tree.c */
29747c08596SBrooks Davis pair cons(caddr_t, pair);
29847c08596SBrooks Davis 
29947c08596SBrooks Davis /* alloc.c */
30047c08596SBrooks Davis struct string_list	*new_string_list(size_t size);
30147c08596SBrooks Davis struct hash_table	*new_hash_table(int);
30247c08596SBrooks Davis struct hash_bucket	*new_hash_bucket(void);
30347c08596SBrooks Davis 
30447c08596SBrooks Davis /* bpf.c */
305b0f1b32aSPawel Jakub Dawidek int if_register_bpf(struct interface_info *, int);
30647c08596SBrooks Davis void if_register_send(struct interface_info *);
30747c08596SBrooks Davis void if_register_receive(struct interface_info *);
308235eb530SPawel Jakub Dawidek void send_packet_unpriv(int, struct dhcp_packet *, size_t, struct in_addr,
309235eb530SPawel Jakub Dawidek     struct in_addr);
310235eb530SPawel Jakub Dawidek struct imsg_hdr;
311235eb530SPawel Jakub Dawidek void send_packet_priv(struct interface_info *, struct imsg_hdr *, int);
31247c08596SBrooks Davis ssize_t receive_packet(struct interface_info *, unsigned char *, size_t,
31347c08596SBrooks Davis     struct sockaddr_in *, struct hardware *);
31447c08596SBrooks Davis 
31547c08596SBrooks Davis /* dispatch.c */
31647c08596SBrooks Davis extern void (*bootp_packet_handler)(struct interface_info *,
31747c08596SBrooks Davis     struct dhcp_packet *, int, unsigned int, struct iaddr, struct hardware *);
31847c08596SBrooks Davis void discover_interfaces(struct interface_info *);
31947c08596SBrooks Davis void reinitialize_interfaces(void);
32047c08596SBrooks Davis void dispatch(void);
32147c08596SBrooks Davis void got_one(struct protocol *);
32247c08596SBrooks Davis void add_timeout(time_t, void (*)(void *), void *);
32316a235f2SIsaac Cilia Attard void add_timeout_timespec(struct timespec, void (*)(void *), void *);
32447c08596SBrooks Davis void cancel_timeout(void (*)(void *), void *);
32579a1d195SAlan Somers void add_protocol(const char *, int, void (*)(struct protocol *), void *);
32647c08596SBrooks Davis void remove_protocol(struct protocol *);
32747c08596SBrooks Davis int interface_link_status(char *);
328387016a5SConrad Meyer void interface_set_mtu_unpriv(int, u_int16_t);
329387016a5SConrad Meyer void interface_set_mtu_priv(char *, u_int16_t);
33047c08596SBrooks Davis 
33147c08596SBrooks Davis /* hash.c */
33247c08596SBrooks Davis struct hash_table *new_hash(void);
33379a1d195SAlan Somers void add_hash(struct hash_table *, const unsigned char *, int, unsigned char *);
33479a1d195SAlan Somers void *hash_lookup(struct hash_table *, unsigned char *, int);
33547c08596SBrooks Davis 
33647c08596SBrooks Davis /* tables.c */
33747c08596SBrooks Davis extern struct option dhcp_options[256];
33847c08596SBrooks Davis extern unsigned char dhcp_option_default_priority_list[];
33947c08596SBrooks Davis extern int sizeof_dhcp_option_default_priority_list;
34047c08596SBrooks Davis extern struct hash_table universe_hash;
34147c08596SBrooks Davis extern struct universe dhcp_universe;
34247c08596SBrooks Davis void initialize_universes(void);
34347c08596SBrooks Davis 
34447c08596SBrooks Davis /* convert.c */
34547c08596SBrooks Davis u_int32_t getULong(unsigned char *);
34647c08596SBrooks Davis int32_t getLong(unsigned char *);
34747c08596SBrooks Davis u_int16_t getUShort(unsigned char *);
34847c08596SBrooks Davis int16_t getShort(unsigned char *);
34947c08596SBrooks Davis void putULong(unsigned char *, u_int32_t);
35047c08596SBrooks Davis void putLong(unsigned char *, int32_t);
35147c08596SBrooks Davis void putUShort(unsigned char *, unsigned int);
35247c08596SBrooks Davis void putShort(unsigned char *, int);
35347c08596SBrooks Davis 
35447c08596SBrooks Davis /* inet.c */
35547c08596SBrooks Davis struct iaddr subnet_number(struct iaddr, struct iaddr);
35647c08596SBrooks Davis struct iaddr broadcast_addr(struct iaddr, struct iaddr);
35747c08596SBrooks Davis int addr_eq(struct iaddr, struct iaddr);
35847c08596SBrooks Davis char *piaddr(struct iaddr);
35947c08596SBrooks Davis 
36047c08596SBrooks Davis /* dhclient.c */
361cb003dd9SMariusz Zaborski extern cap_channel_t *capsyslog;
36279a1d195SAlan Somers extern const char *path_dhclient_conf;
36347c08596SBrooks Davis extern char *path_dhclient_db;
364*76e0ffd9SIsaac Cilia Attard extern struct timespec time_now;
36547c08596SBrooks Davis extern time_t cur_time;
36647c08596SBrooks Davis extern int log_priority;
36747c08596SBrooks Davis extern int log_perror;
36847c08596SBrooks Davis 
36947c08596SBrooks Davis extern struct client_config top_level_config;
37047c08596SBrooks Davis 
37123f39c90SDag-Erling Smørgrav extern struct pidfh *pidfile;
37223f39c90SDag-Erling Smørgrav 
37371c6c44dSEitan Adler extern struct interface_info *ifi;
37471c6c44dSEitan Adler 
37547c08596SBrooks Davis void dhcpoffer(struct packet *);
37647c08596SBrooks Davis void dhcpack(struct packet *);
37747c08596SBrooks Davis void dhcpnak(struct packet *);
37847c08596SBrooks Davis 
37947c08596SBrooks Davis void send_discover(void *);
38047c08596SBrooks Davis void send_request(void *);
38147c08596SBrooks Davis void send_decline(void *);
38247c08596SBrooks Davis 
38347c08596SBrooks Davis void state_reboot(void *);
38447c08596SBrooks Davis void state_init(void *);
38547c08596SBrooks Davis void state_selecting(void *);
38647c08596SBrooks Davis void state_requesting(void *);
38747c08596SBrooks Davis void state_bound(void *);
38847c08596SBrooks Davis void state_panic(void *);
38947c08596SBrooks Davis 
39047c08596SBrooks Davis void bind_lease(struct interface_info *);
39147c08596SBrooks Davis 
39247c08596SBrooks Davis void make_discover(struct interface_info *, struct client_lease *);
39347c08596SBrooks Davis void make_request(struct interface_info *, struct client_lease *);
39447c08596SBrooks Davis void make_decline(struct interface_info *, struct client_lease *);
39547c08596SBrooks Davis 
39647c08596SBrooks Davis void free_client_lease(struct client_lease *);
39747c08596SBrooks Davis void rewrite_client_leases(void);
39847c08596SBrooks Davis void write_client_lease(struct interface_info *, struct client_lease *, int);
39947c08596SBrooks Davis 
40079a1d195SAlan Somers void	 priv_script_init(const char *, char *);
40179a1d195SAlan Somers void	 priv_script_write_params(const char *, struct client_lease *);
40247c08596SBrooks Davis int	 priv_script_go(void);
40347c08596SBrooks Davis 
40479a1d195SAlan Somers void script_init(const char *, struct string_list *);
40579a1d195SAlan Somers void script_write_params(const char *, struct client_lease *);
40647c08596SBrooks Davis int script_go(void);
40747c08596SBrooks Davis void client_envadd(struct client_state *,
40847c08596SBrooks Davis     const char *, const char *, const char *, ...);
40947c08596SBrooks Davis void script_set_env(struct client_state *, const char *, const char *,
41047c08596SBrooks Davis     const char *);
41147c08596SBrooks Davis void script_flush_env(struct client_state *);
41247c08596SBrooks Davis int dhcp_option_ev_name(char *, size_t, struct option *);
41347c08596SBrooks Davis 
41447c08596SBrooks Davis struct client_lease *packet_to_lease(struct packet *);
41547c08596SBrooks Davis void go_daemon(void);
41647c08596SBrooks Davis void client_location_changed(void);
41747c08596SBrooks Davis 
41847c08596SBrooks Davis void bootp(struct packet *);
41947c08596SBrooks Davis void dhcp(struct packet *);
42047c08596SBrooks Davis 
42147c08596SBrooks Davis /* packet.c */
422d1f4d854SPawel Jakub Dawidek void assemble_hw_header(struct interface_info *, unsigned char *, int *);
42347c08596SBrooks Davis void assemble_udp_ip_header(unsigned char *, int *, u_int32_t, u_int32_t,
42447c08596SBrooks Davis     unsigned int, unsigned char *, int);
42547c08596SBrooks Davis ssize_t decode_hw_header(unsigned char *, int, struct hardware *);
42647c08596SBrooks Davis ssize_t decode_udp_ip_header(unsigned char *, int, struct sockaddr_in *,
42747c08596SBrooks Davis     unsigned char *, int);
42847c08596SBrooks Davis 
42947c08596SBrooks Davis /* clparse.c */
43047c08596SBrooks Davis int read_client_conf(void);
43147c08596SBrooks Davis void read_client_leases(void);
43247c08596SBrooks Davis void parse_client_statement(FILE *, struct interface_info *,
43347c08596SBrooks Davis     struct client_config *);
434afe6f835SAlan Somers unsigned parse_X(FILE *, u_int8_t *, unsigned);
43547c08596SBrooks Davis int parse_option_list(FILE *, u_int8_t *);
43647c08596SBrooks Davis void parse_interface_declaration(FILE *, struct client_config *);
43747c08596SBrooks Davis struct interface_info *interface_or_dummy(char *);
43847c08596SBrooks Davis void make_client_state(struct interface_info *);
43947c08596SBrooks Davis void make_client_config(struct interface_info *, struct client_config *);
44047c08596SBrooks Davis void parse_client_lease_statement(FILE *, int);
44147c08596SBrooks Davis void parse_client_lease_declaration(FILE *, struct client_lease *,
44247c08596SBrooks Davis     struct interface_info **);
44347c08596SBrooks Davis struct option *parse_option_decl(FILE *, struct option_data *);
44447c08596SBrooks Davis void parse_string_list(FILE *, struct string_list **, int);
44547c08596SBrooks Davis void parse_reject_statement(FILE *, struct client_config *);
44647c08596SBrooks Davis 
44747c08596SBrooks Davis /* privsep.c */
44847c08596SBrooks Davis struct buf	*buf_open(size_t);
44979a1d195SAlan Somers int		 buf_add(struct buf *, const void *, size_t);
45047c08596SBrooks Davis int		 buf_close(int, struct buf *);
45147c08596SBrooks Davis ssize_t		 buf_read(int, void *, size_t);
452235eb530SPawel Jakub Dawidek void		 dispatch_imsg(struct interface_info *, int);
453