1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// include/bootp.h
|
4 |
|
|
//
|
5 |
|
|
//==========================================================================
|
6 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
7 |
|
|
//
|
8 |
|
|
// -------------------------------------------
|
9 |
|
|
//
|
10 |
|
|
// Portions of this software may have been derived from OpenBSD,
|
11 |
|
|
// FreeBSD or other sources, and are covered by the appropriate
|
12 |
|
|
// copyright disclaimers included herein.
|
13 |
|
|
//
|
14 |
|
|
// Portions created by Red Hat are
|
15 |
|
|
// Copyright (C) 2002 Red Hat, Inc. All Rights Reserved.
|
16 |
|
|
//
|
17 |
|
|
// -------------------------------------------
|
18 |
|
|
//
|
19 |
|
|
//####BSDCOPYRIGHTEND####
|
20 |
|
|
//==========================================================================
|
21 |
|
|
|
22 |
|
|
/************************************************************************
|
23 |
|
|
Copyright 1988, 1991 by Carnegie Mellon University
|
24 |
|
|
|
25 |
|
|
All Rights Reserved
|
26 |
|
|
|
27 |
|
|
Permission to use, copy, modify, and distribute this software and its
|
28 |
|
|
documentation for any purpose and without fee is hereby granted, provided
|
29 |
|
|
that the above copyright notice appear in all copies and that both that
|
30 |
|
|
copyright notice and this permission notice appear in supporting
|
31 |
|
|
documentation, and that the name of Carnegie Mellon University not be used
|
32 |
|
|
in advertising or publicity pertaining to distribution of the software
|
33 |
|
|
without specific, written prior permission.
|
34 |
|
|
|
35 |
|
|
CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
|
36 |
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
|
37 |
|
|
IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
|
38 |
|
|
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
|
39 |
|
|
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
|
40 |
|
|
ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
41 |
|
|
SOFTWARE.
|
42 |
|
|
************************************************************************/
|
43 |
|
|
|
44 |
|
|
#ifndef _BOOTP_H_
|
45 |
|
|
#define _BOOTP_H_
|
46 |
|
|
|
47 |
|
|
/*
|
48 |
|
|
* Bootstrap Protocol (BOOTP). RFC951 and RFC1395.
|
49 |
|
|
*
|
50 |
|
|
* This file specifies the "implementation-independent" BOOTP protocol
|
51 |
|
|
* information which is common to both client and server.
|
52 |
|
|
*
|
53 |
|
|
*/
|
54 |
|
|
|
55 |
|
|
#ifdef __ECOS
|
56 |
|
|
|
57 |
|
|
#include <pkgconf/system.h>
|
58 |
|
|
#include <pkgconf/net.h>
|
59 |
|
|
|
60 |
|
|
#include <machine/types.h>
|
61 |
|
|
#else
|
62 |
|
|
#include "bptypes.h" /* for int32, u_int32 */
|
63 |
|
|
#endif
|
64 |
|
|
|
65 |
|
|
#define BP_CHADDR_LEN 16
|
66 |
|
|
#define BP_SNAME_LEN 64
|
67 |
|
|
#define BP_FILE_LEN 128
|
68 |
|
|
|
69 |
|
|
/* std min packet size to transmit for DHCP relays to work */
|
70 |
|
|
#define BP_STD_TX_MINPKTSZ (300)
|
71 |
|
|
|
72 |
|
|
#ifdef CYGPKG_NET_DHCP
|
73 |
|
|
// The standard requires only 312 bytes here
|
74 |
|
|
#define BP_VEND_LEN (312 + 32)
|
75 |
|
|
#define BP_MINPKTSZ 576
|
76 |
|
|
#else
|
77 |
|
|
#define BP_VEND_LEN 64
|
78 |
|
|
#define BP_MINPKTSZ 300 /* to check sizeof(struct bootp) */
|
79 |
|
|
#endif
|
80 |
|
|
|
81 |
|
|
#define BP_MAX_OPTION_LEN 256
|
82 |
|
|
|
83 |
|
|
struct bootp {
|
84 |
|
|
unsigned char bp_op; /* packet opcode type */
|
85 |
|
|
unsigned char bp_htype; /* hardware addr type */
|
86 |
|
|
unsigned char bp_hlen; /* hardware addr length */
|
87 |
|
|
unsigned char bp_hops; /* gateway hops */
|
88 |
|
|
#ifdef __ECOS
|
89 |
|
|
u_int32_t bp_xid; /* transaction ID */
|
90 |
|
|
#else
|
91 |
|
|
unsigned int bp_xid; /* transaction ID */
|
92 |
|
|
#endif
|
93 |
|
|
unsigned short bp_secs; /* seconds since boot began */
|
94 |
|
|
unsigned short bp_flags; /* RFC1532 broadcast, etc. */
|
95 |
|
|
struct in_addr bp_ciaddr; /* client IP address */
|
96 |
|
|
struct in_addr bp_yiaddr; /* 'your' IP address */
|
97 |
|
|
struct in_addr bp_siaddr; /* server IP address */
|
98 |
|
|
struct in_addr bp_giaddr; /* gateway IP address */
|
99 |
|
|
unsigned char bp_chaddr[BP_CHADDR_LEN]; /* client hardware address */
|
100 |
|
|
char bp_sname[BP_SNAME_LEN]; /* server host name */
|
101 |
|
|
char bp_file[BP_FILE_LEN]; /* boot file name */
|
102 |
|
|
unsigned char bp_vend[BP_VEND_LEN]; /* vendor-specific area */
|
103 |
|
|
/* note that bp_vend can be longer, extending to end of packet. */
|
104 |
|
|
};
|
105 |
|
|
|
106 |
|
|
/*
|
107 |
|
|
* UDP port numbers, server and client.
|
108 |
|
|
*/
|
109 |
|
|
#define IPPORT_BOOTPS 67
|
110 |
|
|
#define IPPORT_BOOTPC 68
|
111 |
|
|
|
112 |
|
|
#define BOOTREPLY 2
|
113 |
|
|
#define BOOTREQUEST 1
|
114 |
|
|
|
115 |
|
|
/*
|
116 |
|
|
* Hardware types from Assigned Numbers RFC.
|
117 |
|
|
*/
|
118 |
|
|
#define HTYPE_ETHERNET 1
|
119 |
|
|
#define HTYPE_EXP_ETHERNET 2
|
120 |
|
|
#define HTYPE_AX25 3
|
121 |
|
|
#define HTYPE_PRONET 4
|
122 |
|
|
#define HTYPE_CHAOS 5
|
123 |
|
|
#define HTYPE_IEEE802 6
|
124 |
|
|
#define HTYPE_ARCNET 7
|
125 |
|
|
|
126 |
|
|
/*
|
127 |
|
|
* Vendor magic cookie (v_magic) for CMU
|
128 |
|
|
*/
|
129 |
|
|
#define VM_CMU "CMU"
|
130 |
|
|
|
131 |
|
|
/*
|
132 |
|
|
* Vendor magic cookie (v_magic) for RFC1048
|
133 |
|
|
*/
|
134 |
|
|
#define VM_RFC1048 { 99, 130, 83, 99 }
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
/*
|
139 |
|
|
* Tag values used to specify what information is being supplied in
|
140 |
|
|
* the vendor (options) data area of the packet.
|
141 |
|
|
*/
|
142 |
|
|
/* RFC 1048 */
|
143 |
|
|
/* End of cookie */
|
144 |
|
|
#define TAG_END ((unsigned char) 255)
|
145 |
|
|
/* padding for alignment */
|
146 |
|
|
#define TAG_PAD ((unsigned char) 0)
|
147 |
|
|
/* Subnet mask */
|
148 |
|
|
#define TAG_SUBNET_MASK ((unsigned char) 1)
|
149 |
|
|
/* Time offset from UTC for this system */
|
150 |
|
|
#define TAG_TIME_OFFSET ((unsigned char) 2)
|
151 |
|
|
/* List of routers on this subnet */
|
152 |
|
|
#define TAG_GATEWAY ((unsigned char) 3)
|
153 |
|
|
/* List of rfc868 time servers available to client */
|
154 |
|
|
#define TAG_TIME_SERVER ((unsigned char) 4)
|
155 |
|
|
/* List of IEN 116 name servers */
|
156 |
|
|
#define TAG_NAME_SERVER ((unsigned char) 5)
|
157 |
|
|
/* List of DNS name servers */
|
158 |
|
|
#define TAG_DOMAIN_SERVER ((unsigned char) 6)
|
159 |
|
|
/* List of MIT-LCS UDL log servers */
|
160 |
|
|
#define TAG_LOG_SERVER ((unsigned char) 7)
|
161 |
|
|
/* List of rfc865 cookie servers */
|
162 |
|
|
#define TAG_COOKIE_SERVER ((unsigned char) 8)
|
163 |
|
|
/* List of rfc1179 printer servers (in order to try) */
|
164 |
|
|
#define TAG_LPR_SERVER ((unsigned char) 9)
|
165 |
|
|
/* List of Imagen Impress servers (in prefered order) */
|
166 |
|
|
#define TAG_IMPRESS_SERVER ((unsigned char) 10)
|
167 |
|
|
/* List of rfc887 Resourse Location servers */
|
168 |
|
|
#define TAG_RLP_SERVER ((unsigned char) 11)
|
169 |
|
|
/* Hostname of client */
|
170 |
|
|
#define TAG_HOST_NAME ((unsigned char) 12)
|
171 |
|
|
/* boot file size */
|
172 |
|
|
#define TAG_BOOT_SIZE ((unsigned char) 13)
|
173 |
|
|
/* RFC 1395 */
|
174 |
|
|
/* path to dump to in case of crash */
|
175 |
|
|
#define TAG_DUMP_FILE ((unsigned char) 14)
|
176 |
|
|
/* domain name for use with the DNS */
|
177 |
|
|
#define TAG_DOMAIN_NAME ((unsigned char) 15)
|
178 |
|
|
/* IP address of the swap server for this machine */
|
179 |
|
|
#define TAG_SWAP_SERVER ((unsigned char) 16)
|
180 |
|
|
/* The path name to the root filesystem for this machine */
|
181 |
|
|
#define TAG_ROOT_PATH ((unsigned char) 17)
|
182 |
|
|
/* RFC 1497 */
|
183 |
|
|
/* filename to tftp with more options in it */
|
184 |
|
|
#define TAG_EXTEN_FILE ((unsigned char) 18)
|
185 |
|
|
/* RFC 1533 */
|
186 |
|
|
/* The following are in rfc1533 and may be used by BOOTP/DHCP */
|
187 |
|
|
/* IP forwarding enable/disable */
|
188 |
|
|
#define TAG_IP_FORWARD ((unsigned char) 19)
|
189 |
|
|
/* Non-Local source routing enable/disable */
|
190 |
|
|
#define TAG_IP_NLSR ((unsigned char) 20)
|
191 |
|
|
/* List of pairs of addresses/masks to allow non-local source routing to */
|
192 |
|
|
#define TAG_IP_POLICY_FILTER ((unsigned char) 21)
|
193 |
|
|
/* Maximum size of datagrams client should be prepared to reassemble */
|
194 |
|
|
#define TAG_IP_MAX_DRS ((unsigned char) 22)
|
195 |
|
|
/* Default IP TTL */
|
196 |
|
|
#define TAG_IP_TTL ((unsigned char) 23)
|
197 |
|
|
/* Timeout in seconds to age path MTU values found with rfc1191 */
|
198 |
|
|
#define TAG_IP_MTU_AGE ((unsigned char) 24)
|
199 |
|
|
/* Table of MTU sizes to use when doing rfc1191 MTU discovery */
|
200 |
|
|
#define TAG_IP_MTU_PLAT ((unsigned char) 25)
|
201 |
|
|
/* MTU to use on this interface */
|
202 |
|
|
#define TAG_IP_MTU ((unsigned char) 26)
|
203 |
|
|
/* All subnets are local option */
|
204 |
|
|
#define TAG_IP_SNARL ((unsigned char) 27)
|
205 |
|
|
/* broadcast address */
|
206 |
|
|
#define TAG_IP_BROADCAST ((unsigned char) 28)
|
207 |
|
|
/* perform subnet mask discovery using ICMP */
|
208 |
|
|
#define TAG_IP_SMASKDISC ((unsigned char) 29)
|
209 |
|
|
/* act as a subnet mask server using ICMP */
|
210 |
|
|
#define TAG_IP_SMASKSUPP ((unsigned char) 30)
|
211 |
|
|
/* perform rfc1256 router discovery */
|
212 |
|
|
#define TAG_IP_ROUTERDISC ((unsigned char) 31)
|
213 |
|
|
/* address to send router solicitation requests */
|
214 |
|
|
#define TAG_IP_ROUTER_SOL_ADDR ((unsigned char) 32)
|
215 |
|
|
/* list of static routes to addresses (addr, router) pairs */
|
216 |
|
|
#define TAG_IP_STATIC_ROUTES ((unsigned char) 33)
|
217 |
|
|
/* use trailers (rfc893) when using ARP */
|
218 |
|
|
#define TAG_IP_TRAILER_ENC ((unsigned char) 34)
|
219 |
|
|
/* timeout in seconds for ARP cache entries */
|
220 |
|
|
#define TAG_ARP_TIMEOUT ((unsigned char) 35)
|
221 |
|
|
/* use either Ethernet version 2 (rfc894) or IEEE 802.3 (rfc1042) */
|
222 |
|
|
#define TAG_ETHER_IEEE ((unsigned char) 36)
|
223 |
|
|
/* default TCP TTL when sending TCP segments */
|
224 |
|
|
#define TAG_IP_TCP_TTL ((unsigned char) 37)
|
225 |
|
|
/* time for client to wait before sending a keepalive on a TCP connection */
|
226 |
|
|
#define TAG_IP_TCP_KA_INT ((unsigned char) 38)
|
227 |
|
|
/* don't send keepalive with an octet of garbage for compatability */
|
228 |
|
|
#define TAG_IP_TCP_KA_GARBAGE ((unsigned char) 39)
|
229 |
|
|
/* NIS domainname */
|
230 |
|
|
#define TAG_NIS_DOMAIN ((unsigned char) 40)
|
231 |
|
|
/* list of NIS servers */
|
232 |
|
|
#define TAG_NIS_SERVER ((unsigned char) 41)
|
233 |
|
|
/* list of NTP servers */
|
234 |
|
|
#define TAG_NTP_SERVER ((unsigned char) 42)
|
235 |
|
|
/* and stuff vendors may want to add */
|
236 |
|
|
#define TAG_VEND_SPECIFIC ((unsigned char) 43)
|
237 |
|
|
/* NetBios over TCP/IP name server */
|
238 |
|
|
#define TAG_NBNS_SERVER ((unsigned char) 44)
|
239 |
|
|
/* NetBios over TCP/IP NBDD servers (rfc1001/1002) */
|
240 |
|
|
#define TAG_NBDD_SERVER ((unsigned char) 45)
|
241 |
|
|
/* NetBios over TCP/IP node type option for use with above */
|
242 |
|
|
#define TAG_NBOTCP_OTPION ((unsigned char) 46)
|
243 |
|
|
/* NetBios over TCP/IP scopt option for use with above */
|
244 |
|
|
#define TAG_NB_SCOPE ((unsigned char) 47)
|
245 |
|
|
/* list of X Window system font servers */
|
246 |
|
|
#define TAG_XFONT_SERVER ((unsigned char) 48)
|
247 |
|
|
/* list of systems running X Display Manager (xdm) available to this client */
|
248 |
|
|
#define TAG_XDISPLAY_SERVER ((unsigned char) 49)
|
249 |
|
|
|
250 |
|
|
/* While the following are only allowed for DHCP */
|
251 |
|
|
/* DHCP requested IP address */
|
252 |
|
|
#define TAG_DHCP_REQ_IP ((unsigned char) 50)
|
253 |
|
|
/* DHCP time for lease of IP address */
|
254 |
|
|
#define TAG_DHCP_LEASE_TIME ((unsigned char) 51)
|
255 |
|
|
/* DHCP options overload */
|
256 |
|
|
#define TAG_DHCP_OPTOVER ((unsigned char) 52)
|
257 |
|
|
/* DHCP message type */
|
258 |
|
|
#define TAG_DHCP_MESS_TYPE ((unsigned char) 53)
|
259 |
|
|
/* DHCP server identification */
|
260 |
|
|
#define TAG_DHCP_SERVER_ID ((unsigned char) 54)
|
261 |
|
|
/* DHCP ordered list of requested parameters */
|
262 |
|
|
#define TAG_DHCP_PARM_REQ_LIST ((unsigned char) 55)
|
263 |
|
|
/* DHCP reply message */
|
264 |
|
|
#define TAG_DHCP_TEXT_MESSAGE ((unsigned char) 56)
|
265 |
|
|
/* DHCP maximum packet size willing to accept */
|
266 |
|
|
#define TAG_DHCP_MAX_MSGSZ ((unsigned char) 57)
|
267 |
|
|
/* DHCP time 'til client needs to renew */
|
268 |
|
|
#define TAG_DHCP_RENEWAL_TIME ((unsigned char) 58)
|
269 |
|
|
/* DHCP time 'til client needs to rebind */
|
270 |
|
|
#define TAG_DHCP_REBIND_TIME ((unsigned char) 59)
|
271 |
|
|
/* DHCP class identifier */
|
272 |
|
|
#define TAG_DHCP_CLASSID ((unsigned char) 60)
|
273 |
|
|
/* DHCP client unique identifier */
|
274 |
|
|
#define TAG_DHCP_CLIENTID ((unsigned char) 61)
|
275 |
|
|
|
276 |
|
|
/* XXX - Add new tags here */
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
/*
|
280 |
|
|
* "vendor" data permitted for CMU bootp clients.
|
281 |
|
|
*/
|
282 |
|
|
|
283 |
|
|
struct cmu_vend {
|
284 |
|
|
char v_magic[4]; /* magic number */
|
285 |
|
|
#ifdef __ECOS
|
286 |
|
|
u_int32_t v_flags; /* flags/opcodes, etc. */
|
287 |
|
|
#else
|
288 |
|
|
unsigned int32 v_flags; /* flags/opcodes, etc. */
|
289 |
|
|
#endif
|
290 |
|
|
struct in_addr v_smask; /* Subnet mask */
|
291 |
|
|
struct in_addr v_dgate; /* Default gateway */
|
292 |
|
|
struct in_addr v_dns1, v_dns2; /* Domain name servers */
|
293 |
|
|
struct in_addr v_ins1, v_ins2; /* IEN-116 name servers */
|
294 |
|
|
struct in_addr v_ts1, v_ts2; /* Time servers */
|
295 |
|
|
#ifdef __ECOS
|
296 |
|
|
int32_t v_unused[6]; /* currently unused */
|
297 |
|
|
#else
|
298 |
|
|
int32 v_unused[6]; /* currently unused */
|
299 |
|
|
#endif
|
300 |
|
|
};
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
/* v_flags values */
|
304 |
|
|
#define VF_SMASK 1 /* Subnet mask field contains valid data */
|
305 |
|
|
|
306 |
|
|
#ifdef __ECOS
|
307 |
|
|
#ifdef CYGHWR_NET_DRIVER_ETH0
|
308 |
|
|
extern struct bootp eth0_bootp_data;
|
309 |
|
|
extern cyg_bool_t eth0_up;
|
310 |
|
|
extern const char *eth0_name;
|
311 |
|
|
#endif
|
312 |
|
|
#ifdef CYGHWR_NET_DRIVER_ETH1
|
313 |
|
|
extern struct bootp eth1_bootp_data;
|
314 |
|
|
extern cyg_bool_t eth1_up;
|
315 |
|
|
extern const char *eth1_name;
|
316 |
|
|
#endif
|
317 |
|
|
|
318 |
|
|
// ------------------------------------------------------------------------
|
319 |
|
|
// Initialize your own bootp record however you like, as far as is needed
|
320 |
|
|
// to bring up an interface.
|
321 |
|
|
__externC void
|
322 |
|
|
build_bootp_record(struct bootp *bp,
|
323 |
|
|
const char *if_name,
|
324 |
|
|
const char *addrs_ip,
|
325 |
|
|
const char *addrs_netmask,
|
326 |
|
|
const char *addrs_broadcast,
|
327 |
|
|
const char *addrs_gateway,
|
328 |
|
|
const char *addrs_server);
|
329 |
|
|
|
330 |
|
|
// Do bootp to fill in the bootp record from the net (other interfaces must
|
331 |
|
|
// be down for this to work, because of the "half-up" state of the
|
332 |
|
|
// interface in use)
|
333 |
|
|
__externC cyg_bool_t do_bootp(const char *interface, struct bootp *res);
|
334 |
|
|
|
335 |
|
|
// Initialize an interface (which is down) according to a bootp structure
|
336 |
|
|
__externC cyg_bool_t init_net(const char *interface, struct bootp *res);
|
337 |
|
|
#ifdef CYGPKG_NET_INET6
|
338 |
|
|
__externC cyg_bool_t init_net_IPv6(const char *intf, struct bootp *bp, char *prefix);
|
339 |
|
|
#endif
|
340 |
|
|
|
341 |
|
|
// Dump contents to diag_printf
|
342 |
|
|
__externC void show_bootp(const char *interface, struct bootp *res);
|
343 |
|
|
|
344 |
|
|
// Interrogate a bootp record for a particular option
|
345 |
|
|
__externC cyg_bool_t get_bootp_option(struct bootp *bp, unsigned char tag, void *res, unsigned int * length);
|
346 |
|
|
|
347 |
|
|
// ------------------------------------------------------------------------
|
348 |
|
|
// This isn't exactly the right place for this since bootp is not involved
|
349 |
|
|
// BUT you will only be using this API if you are using bootp-style
|
350 |
|
|
// initialization of the other interfaces; it fits here in a documentation
|
351 |
|
|
// sense.
|
352 |
|
|
__externC cyg_bool_t init_loopback_interface(int lo);
|
353 |
|
|
|
354 |
|
|
// ------------------------------------------------------------------------
|
355 |
|
|
// Do all the above automatically according to the configuration. Do not
|
356 |
|
|
// mix using this and making the above calls yourself.
|
357 |
|
|
// (this is also declared in the much simpler API in network.h)
|
358 |
|
|
__externC void init_all_network_interfaces(void);
|
359 |
|
|
|
360 |
|
|
#endif
|
361 |
|
|
|
362 |
|
|
#endif // _BOOTP_H_
|