xref: /freebsd/libexec/bootpd/bootpd.h (revision 40a8ac8f62b535d30349faf28cf47106b7041b83)
1 /************************************************************************
2           Copyright 1988, 1991 by Carnegie Mellon University
3 
4                           All Rights Reserved
5 
6 Permission to use, copy, modify, and distribute this software and its
7 documentation for any purpose and without fee is hereby granted, provided
8 that the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation, and that the name of Carnegie Mellon University not be used
11 in advertising or publicity pertaining to distribution of the software
12 without specific, written prior permission.
13 
14 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
15 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
16 IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
17 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
18 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 SOFTWARE.
21 ************************************************************************/
22 
23 
24 /*
25  * bootpd.h -- common header file for all the modules of the bootpd program.
26  *
27  * $FreeBSD$
28  */
29 
30 #include "bptypes.h"
31 #include "hash.h"
32 #include "hwaddr.h"
33 
34 #ifndef TRUE
35 #define TRUE	1
36 #endif
37 #ifndef FALSE
38 #define FALSE	0
39 #endif
40 
41 #ifndef PRIVATE
42 #define PRIVATE static
43 #endif
44 
45 #ifndef SIGUSR1
46 #define SIGUSR1			 30	/* From 4.3 <signal.h> */
47 #endif
48 
49 #define MAXSTRINGLEN		 80	/* Max string length */
50 
51 /* Local definitions: */
52 #define MAX_MSG_SIZE		(3*512) /* Maximum packet size */
53 
54 
55 /*
56  * Return pointer to static string which gives full network error message.
57  */
58 #define get_network_errmsg get_errmsg
59 
60 
61 /*
62  * Data structure used to hold an arbitrary-lengthed list of IP addresses.
63  * The list may be shared among multiple hosts by setting the linkcount
64  * appropriately.
65  */
66 
67 struct in_addr_list {
68     unsigned int	linkcount, addrcount;
69     struct in_addr	addr[1];		/* Dynamically extended */
70 };
71 
72 
73 /*
74  * Data structures used to hold shared strings and shared binary data.
75  * The linkcount must be set appropriately.
76  */
77 
78 struct shared_string {
79     unsigned int	linkcount;
80     char		string[1];		/* Dynamically extended */
81 };
82 
83 struct shared_bindata {
84     unsigned int	linkcount, length;
85     byte		data[1];		/* Dynamically extended */
86 };
87 
88 
89 /*
90  * Flag structure which indicates which symbols have been defined for a
91  * given host.  This information is used to determine which data should or
92  * should not be reported in the bootp packet vendor info field.
93  */
94 
95 struct flag {
96     unsigned	bootfile	:1,
97 		bootserver	:1,
98 		bootsize	:1,
99 		bootsize_auto	:1,
100 		cookie_server	:1,
101 		domain_server	:1,
102 		gateway		:1,
103 		generic		:1,
104 		haddr		:1,
105 		homedir		:1,
106 		htype		:1,
107 		impress_server	:1,
108 		iaddr		:1,
109 		log_server	:1,
110 		lpr_server	:1,
111 		name_server	:1,
112 		name_switch	:1,
113 		rlp_server	:1,
114 		send_name	:1,
115 		subnet_mask	:1,
116 		tftpdir		:1,
117 		time_offset	:1,
118 		time_server	:1,
119 		dump_file	:1,
120 		domain_name	:1,
121 		swap_server	:1,
122 		root_path	:1,
123 		exten_file	:1,
124 		reply_addr	:1,
125 		nis_domain	:1,
126 		nis_server	:1,
127 		ntp_server	:1,
128 		exec_file	:1,
129 		msg_size	:1,
130 		min_wait	:1,
131 		/* XXX - Add new tags here */
132 		vm_cookie	:1;
133 };
134 
135 
136 
137 /*
138  * The flags structure contains TRUE flags for all the fields which
139  * are considered valid, regardless of whether they were explicitly
140  * specified or indirectly inferred from another entry.
141  *
142  * The gateway and the various server fields all point to a shared list of
143  * IP addresses.
144  *
145  * The hostname, home directory, and bootfile are all shared strings.
146  *
147  * The generic data field is a shared binary data structure.  It is used to
148  * hold future RFC1048 vendor data until bootpd is updated to understand it.
149  *
150  * The vm_cookie field specifies the four-octet vendor magic cookie to use
151  * if it is desired to always send the same response to a given host.
152  *
153  * Hopefully, the rest is self-explanatory.
154  */
155 
156 struct host {
157     unsigned		    linkcount;		/* hash list inserts */
158     struct flag		    flags;		/* ALL valid fields */
159     struct in_addr_list	    *cookie_server,
160 			    *domain_server,
161 			    *gateway,
162 			    *impress_server,
163 			    *log_server,
164 			    *lpr_server,
165 			    *name_server,
166 			    *rlp_server,
167 			    *time_server,
168 			    *nis_server,
169 			    *ntp_server;
170     struct shared_string    *bootfile,
171 			    *hostname,
172 			    *domain_name,
173 			    *homedir,
174 			    *tftpdir,
175 			    *dump_file,
176 			    *exten_file,
177 			    *root_path,
178 			    *nis_domain,
179 			    *exec_file;
180     struct shared_bindata   *generic;
181     byte		    vm_cookie[4],
182 			    htype,  /* RFC826 says this should be 16-bits but
183 				       RFC951 only allocates 1 byte. . . */
184 			    haddr[MAXHADDRLEN];
185     int32		    time_offset;
186     u_int32		    bootsize,
187 			    msg_size,
188 			    min_wait;
189     struct in_addr	    bootserver,
190 			    iaddr,
191 			    swap_server,
192 			    reply_addr,
193 			    subnet_mask;
194     /* XXX - Add new tags here (or above as appropriate) */
195 };
196 
197 
198 
199 /*
200  * Variables shared among modules.
201  */
202 
203 extern int debug;
204 extern char *bootptab;
205 extern char *progname;
206 
207 extern u_char vm_cmu[4];
208 extern u_char vm_rfc1048[4];
209 
210 extern hash_tbl *hwhashtable;
211 extern hash_tbl *iphashtable;
212 extern hash_tbl *nmhashtable;
213 
214