xref: /titanic_51/usr/src/grub/grub-0.97/netboot/bootp.h (revision 613a2f6ba31e891e3d947a356daf5e563d43c1ce)
1 #ifndef	_BOOTP_H
2 #define	_BOOTP_H
3 
4 #include "if_ether.h"
5 #include "ip.h"
6 #include "udp.h"
7 
8 #ifndef	MAX_BOOTP_RETRIES
9 #define MAX_BOOTP_RETRIES	20
10 #endif
11 
12 #ifdef	ALTERNATE_DHCP_PORTS_1067_1068
13 #undef	NON_STANDARD_BOOTP_SERVER
14 #define	NON_STANDARD_BOOTP_SERVER	1067
15 #undef	NON_STANDARD_BOOTP_CLIENT
16 #define	NON_STANDARD_BOOTP_CLIENT	1068
17 #endif
18 
19 #ifdef	NON_STANDARD_BOOTP_SERVER
20 #define	BOOTP_SERVER	NON_STANDARD_BOOTP_SERVER
21 #else
22 #define BOOTP_SERVER	67
23 #endif
24 #ifdef	NON_STANDARD_BOOTP_CLIENT
25 #define	BOOTP_CLIENT	NON_STANDARD_BOOTP_CLIENT
26 #else
27 #define BOOTP_CLIENT	68
28 #endif
29 
30 #define BOOTP_REQUEST	1
31 #define BOOTP_REPLY	2
32 
33 #define TAG_LEN(p)		(*((p)+1))
34 #define RFC1533_COOKIE		99, 130, 83, 99
35 #define RFC1533_PAD		0
36 #define RFC1533_NETMASK		1
37 #define RFC1533_TIMEOFFSET	2
38 #define RFC1533_GATEWAY		3
39 #define RFC1533_TIMESERVER	4
40 #define RFC1533_IEN116NS	5
41 #define RFC1533_DNS		6
42 #define RFC1533_LOGSERVER	7
43 #define RFC1533_COOKIESERVER	8
44 #define RFC1533_LPRSERVER	9
45 #define RFC1533_IMPRESSSERVER	10
46 #define RFC1533_RESOURCESERVER	11
47 #define RFC1533_HOSTNAME	12
48 #define RFC1533_BOOTFILESIZE	13
49 #define RFC1533_MERITDUMPFILE	14
50 #define RFC1533_DOMAINNAME	15
51 #define RFC1533_SWAPSERVER	16
52 #define RFC1533_ROOTPATH	17
53 #define RFC1533_EXTENSIONPATH	18
54 #define RFC1533_IPFORWARDING	19
55 #define RFC1533_IPSOURCEROUTING	20
56 #define RFC1533_IPPOLICYFILTER	21
57 #define RFC1533_IPMAXREASSEMBLY	22
58 #define RFC1533_IPTTL		23
59 #define RFC1533_IPMTU		24
60 #define RFC1533_IPMTUPLATEAU	25
61 #define RFC1533_INTMTU		26
62 #define RFC1533_INTLOCALSUBNETS	27
63 #define RFC1533_INTBROADCAST	28
64 #define RFC1533_INTICMPDISCOVER	29
65 #define RFC1533_INTICMPRESPOND	30
66 #define RFC1533_INTROUTEDISCOVER 31
67 #define RFC1533_INTROUTESOLICIT	32
68 #define RFC1533_INTSTATICROUTES	33
69 #define RFC1533_LLTRAILERENCAP	34
70 #define RFC1533_LLARPCACHETMO	35
71 #define RFC1533_LLETHERNETENCAP	36
72 #define RFC1533_TCPTTL		37
73 #define RFC1533_TCPKEEPALIVETMO	38
74 #define RFC1533_TCPKEEPALIVEGB	39
75 #define RFC1533_NISDOMAIN	40
76 #define RFC1533_NISSERVER	41
77 #define RFC1533_NTPSERVER	42
78 #define RFC1533_VENDOR		43
79 #define RFC1533_NBNS		44
80 #define RFC1533_NBDD		45
81 #define RFC1533_NBNT		46
82 #define RFC1533_NBSCOPE		47
83 #define RFC1533_XFS		48
84 #define RFC1533_XDM		49
85 #ifndef	NO_DHCP_SUPPORT
86 #define RFC2132_REQ_ADDR	50
87 #define RFC2132_MSG_TYPE	53
88 #define RFC2132_SRV_ID		54
89 #define RFC2132_PARAM_LIST	55
90 #define RFC2132_MAX_SIZE	57
91 #define	RFC2132_VENDOR_CLASS_ID	60
92 
93 #define DHCPDISCOVER		1
94 #define DHCPOFFER		2
95 #define DHCPREQUEST		3
96 #define DHCPACK			5
97 #endif	/* NO_DHCP_SUPPORT */
98 
99 #define RFC1533_VENDOR_MAJOR	0
100 #define RFC1533_VENDOR_MINOR	0
101 
102 #define RFC1533_VENDOR_MAGIC	128
103 #define RFC1533_VENDOR_ADDPARM	129
104 #define	RFC1533_VENDOR_ETHDEV	130
105 #ifdef	IMAGE_FREEBSD
106 #define RFC1533_VENDOR_HOWTO    132
107 #define RFC1533_VENDOR_KERNEL_ENV    133
108 #endif
109 #define RFC1533_VENDOR_ETHERBOOT_ENCAP 150
110 #define RFC1533_VENDOR_MNUOPTS	160
111 #define RFC1533_VENDOR_NIC_DEV_ID 175
112 #define RFC1533_VENDOR_SELECTION 176
113 #define RFC1533_VENDOR_ARCH     177
114 #define RFC1533_VENDOR_MOTD	184
115 #define RFC1533_VENDOR_NUMOFMOTD 8
116 #define RFC1533_VENDOR_IMG	192
117 #define RFC1533_VENDOR_NUMOFIMG	16
118 
119 #define RFC1533_VENDOR_CONFIGFILE 150
120 
121 #define RFC1533_END		255
122 
123 #define BOOTP_VENDOR_LEN	64
124 
125 #define DHCP_OPT_LEN		312
126 
127 /* Format of a bootp packet */
128 struct bootp_t {
129 	uint8_t  bp_op;
130 	uint8_t  bp_htype;
131 	uint8_t  bp_hlen;
132 	uint8_t  bp_hops;
133 	uint32_t bp_xid;
134 	uint16_t bp_secs;
135 	uint16_t unused;
136 	in_addr bp_ciaddr;
137 	in_addr bp_yiaddr;
138 	in_addr bp_siaddr;
139 	in_addr bp_giaddr;
140 	uint8_t  bp_hwaddr[16];
141 	uint8_t  bp_sname[64];
142 	char     bp_file[128];
143 	uint8_t  bp_vend[BOOTP_VENDOR_LEN];
144 };
145 
146 struct dhcp_t {
147 	uint8_t  bp_op;
148 	uint8_t  bp_htype;
149 	uint8_t  bp_hlen;
150 	uint8_t  bp_hops;
151 	uint32_t bp_xid;
152 	uint16_t bp_secs;
153 	uint16_t bp_flag;
154 	in_addr bp_ciaddr;
155 	in_addr bp_yiaddr;
156 	in_addr bp_siaddr;
157 	in_addr bp_giaddr;
158 	uint8_t  bp_hwaddr[16];
159 	uint8_t  bp_sname[64];
160 	char     bp_file[128];
161 	uint8_t  bp_vend[DHCP_OPT_LEN];
162 };
163 
164 /* Format of a bootp IP packet */
165 struct bootpip_t
166 {
167 	struct iphdr ip;
168 	struct udphdr udp;
169 	struct bootp_t bp;
170 };
171 struct dhcpip_t
172 {
173 	struct iphdr ip;
174 	struct udphdr udp;
175 	struct dhcp_t bp;
176 };
177 
178 #define MAX_RFC1533_VENDLEN (ETH_MAX_MTU - sizeof(struct bootpip_t) + BOOTP_VENDOR_LEN)
179 
180 #define BOOTP_DATA_ADDR (&bootp_data)
181 
182 #endif	/* _BOOTP_H */
183