]> git.karo-electronics.de Git - karo-tx-redboot.git/blob - packages/redboot/v2_0/include/net/bootp.h
Initial revision
[karo-tx-redboot.git] / packages / redboot / v2_0 / include / net / bootp.h
1 //==========================================================================
2 //
3 //      net/bootp.h
4 //
5 //      Stand-alone BOOTP support for RedBoot
6 //
7 //==========================================================================
8 //####ECOSGPLCOPYRIGHTBEGIN####
9 // -------------------------------------------
10 // This file is part of eCos, the Embedded Configurable Operating System.
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
12 // Copyright (C) 2002 Gary Thomas
13 //
14 // eCos is free software; you can redistribute it and/or modify it under
15 // the terms of the GNU General Public License as published by the Free
16 // Software Foundation; either version 2 or (at your option) any later version.
17 //
18 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
19 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21 // for more details.
22 //
23 // You should have received a copy of the GNU General Public License along
24 // with eCos; if not, write to the Free Software Foundation, Inc.,
25 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 //
27 // As a special exception, if other files instantiate templates or use macros
28 // or inline functions from this file, or you compile this file and link it
29 // with other works to produce a work based on this file, this file does not
30 // by itself cause the resulting work to be covered by the GNU General Public
31 // License. However the source code for this file must still be made available
32 // in accordance with section (3) of the GNU General Public License.
33 //
34 // This exception does not invalidate any other reasons why a work based on
35 // this file might be covered by the GNU General Public License.
36 //
37 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
38 // at http://sources.redhat.com/ecos/ecos-license/
39 // -------------------------------------------
40 //####ECOSGPLCOPYRIGHTEND####
41 //==========================================================================
42 //#####DESCRIPTIONBEGIN####
43 //
44 // Author(s):    gthomas
45 // Contributors: gthomas
46 // Date:         2000-07-14
47 // Purpose:      
48 // Description:  
49 //              
50 // This code is part of RedBoot (tm).
51 //
52 //####DESCRIPTIONEND####
53 //
54 //==========================================================================
55
56 /************************************************************************
57           Copyright 1988, 1991 by Carnegie Mellon University
58
59                           All Rights Reserved
60
61 Permission to use, copy, modify, and distribute this software and its
62 documentation for any purpose and without fee is hereby granted, provided
63 that the above copyright notice appear in all copies and that both that
64 copyright notice and this permission notice appear in supporting
65 documentation, and that the name of Carnegie Mellon University not be used
66 in advertising or publicity pertaining to distribution of the software
67 without specific, written prior permission.
68
69 CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
70 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
71 IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
72 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
73 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
74 ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
75 SOFTWARE.
76 ************************************************************************/
77
78 #ifndef _BOOTP_H_
79 #define _BOOTP_H_
80
81 /*
82  * Bootstrap Protocol (BOOTP).  RFC951 and RFC1395.
83  *
84  * This file specifies the "implementation-independent" BOOTP protocol
85  * information which is common to both client and server.
86  *
87  */
88
89 #define BP_CHADDR_LEN    16
90 #define BP_SNAME_LEN     64
91 #define BP_FILE_LEN     128
92 #define BP_VEND_LEN     312
93 #define BP_MINPKTSZ     300     /* to check sizeof(struct bootp) */
94 #define BP_MIN_VEND_SIZE 64     /* minimum actual vendor area */
95
96 typedef struct bootp {
97     unsigned char    bp_op;                     /* packet opcode type */
98     unsigned char    bp_htype;                  /* hardware addr type */
99     unsigned char    bp_hlen;                   /* hardware addr length */
100     unsigned char    bp_hops;                   /* gateway hops */
101     unsigned int     bp_xid;                    /* transaction ID */
102     unsigned short   bp_secs;                   /* seconds since boot began */
103     unsigned short   bp_flags;                  /* RFC1532 broadcast, etc. */
104     struct in_addr   bp_ciaddr;                 /* client IP address */
105     struct in_addr   bp_yiaddr;                 /* 'your' IP address */
106     struct in_addr   bp_siaddr;                 /* server IP address */
107     struct in_addr   bp_giaddr;                 /* gateway IP address */
108     unsigned char    bp_chaddr[BP_CHADDR_LEN];  /* client hardware address */
109     char             bp_sname[BP_SNAME_LEN];    /* server host name */
110     char             bp_file[BP_FILE_LEN];      /* boot file name */
111     unsigned char    bp_vend[BP_VEND_LEN];      /* vendor-specific area */
112     /* note that bp_vend can be longer, extending to end of packet. */
113 } bootp_header_t;
114
115 /*
116  * UDP port numbers, server and client.
117  */
118 #define IPPORT_BOOTPS           67
119 #define IPPORT_BOOTPC           68
120
121 #define BOOTREPLY               2
122 #define BOOTREQUEST             1
123
124 /*
125  * Hardware types from Assigned Numbers RFC.
126  */
127 #define HTYPE_ETHERNET            1
128 #define HTYPE_EXP_ETHERNET        2
129 #define HTYPE_AX25                3
130 #define HTYPE_PRONET              4
131 #define HTYPE_CHAOS               5
132 #define HTYPE_IEEE802             6
133 #define HTYPE_ARCNET              7
134
135 /*
136  * Vendor magic cookie (v_magic) for CMU
137  */
138 #define VM_CMU          "CMU"
139
140 /*
141  * Vendor magic cookie (v_magic) for RFC1048
142  */
143 #define VM_RFC1048      { 99, 130, 83, 99 }
144
145 \f
146
147 /*
148  * Tag values used to specify what information is being supplied in
149  * the vendor (options) data area of the packet.
150  */
151 /* RFC 1048 */
152 /* End of cookie */
153 #define TAG_END                 ((unsigned char) 255)
154 /* padding for alignment */
155 #define TAG_PAD                 ((unsigned char)   0)
156 /* Subnet mask */
157 #define TAG_SUBNET_MASK         ((unsigned char)   1)
158 /* Time offset from UTC for this system */
159 #define TAG_TIME_OFFSET         ((unsigned char)   2)
160 /* List of routers on this subnet */
161 #define TAG_GATEWAY             ((unsigned char)   3)
162 /* List of rfc868 time servers available to client */
163 #define TAG_TIME_SERVER         ((unsigned char)   4)
164 /* List of IEN 116 name servers */
165 #define TAG_NAME_SERVER         ((unsigned char)   5)
166 /* List of DNS name servers */
167 #define TAG_DOMAIN_SERVER       ((unsigned char)   6)
168 /* List of MIT-LCS UDL log servers */
169 #define TAG_LOG_SERVER          ((unsigned char)   7)
170 /* List of rfc865 cookie servers */
171 #define TAG_COOKIE_SERVER       ((unsigned char)   8)
172 /* List of rfc1179 printer servers (in order to try) */
173 #define TAG_LPR_SERVER          ((unsigned char)   9)
174 /* List of Imagen Impress servers (in prefered order) */
175 #define TAG_IMPRESS_SERVER      ((unsigned char)  10)
176 /* List of rfc887 Resourse Location servers */
177 #define TAG_RLP_SERVER          ((unsigned char)  11)
178 /* Hostname of client */
179 #define TAG_HOST_NAME           ((unsigned char)  12)
180 /* boot file size */
181 #define TAG_BOOT_SIZE           ((unsigned char)  13)
182 /* RFC 1395 */
183 /* path to dump to in case of crash */
184 #define TAG_DUMP_FILE           ((unsigned char)  14)
185 /* domain name for use with the DNS */
186 #define TAG_DOMAIN_NAME         ((unsigned char)  15)
187 /* IP address of the swap server for this machine */
188 #define TAG_SWAP_SERVER         ((unsigned char)  16)
189 /* The path name to the root filesystem for this machine */
190 #define TAG_ROOT_PATH           ((unsigned char)  17)
191 /* RFC 1497 */
192 /* filename to tftp with more options in it */
193 #define TAG_EXTEN_FILE          ((unsigned char)  18)
194 /* RFC 1533 */
195 /* The following are in rfc1533 and may be used by BOOTP/DHCP */
196 /* IP forwarding enable/disable */
197 #define TAG_IP_FORWARD          ((unsigned char)  19)
198 /* Non-Local source routing enable/disable */
199 #define TAG_IP_NLSR             ((unsigned char)  20)
200 /* List of pairs of addresses/masks to allow non-local source routing to */
201 #define TAG_IP_POLICY_FILTER    ((unsigned char)  21)
202 /* Maximum size of datagrams client should be prepared to reassemble */
203 #define TAG_IP_MAX_DRS          ((unsigned char)  22)
204 /* Default IP TTL */
205 #define TAG_IP_TTL              ((unsigned char)  23)
206 /* Timeout in seconds to age path MTU values found with rfc1191 */
207 #define TAG_IP_MTU_AGE          ((unsigned char)  24)
208 /* Table of MTU sizes to use when doing rfc1191 MTU discovery */
209 #define TAG_IP_MTU_PLAT         ((unsigned char)  25)
210 /* MTU to use on this interface */
211 #define TAG_IP_MTU              ((unsigned char)  26)
212 /* All subnets are local option */
213 #define TAG_IP_SNARL            ((unsigned char)  27)
214 /* broadcast address */
215 #define TAG_IP_BROADCAST        ((unsigned char)  28)
216 /* perform subnet mask discovery using ICMP */
217 #define TAG_IP_SMASKDISC        ((unsigned char)  29)
218 /* act as a subnet mask server using ICMP */
219 #define TAG_IP_SMASKSUPP        ((unsigned char)  30)
220 /* perform rfc1256 router discovery */
221 #define TAG_IP_ROUTERDISC       ((unsigned char)  31)
222 /* address to send router solicitation requests */
223 #define TAG_IP_ROUTER_SOL_ADDR  ((unsigned char)  32)
224 /* list of static routes to addresses (addr, router) pairs */
225 #define TAG_IP_STATIC_ROUTES    ((unsigned char)  33)
226 /* use trailers (rfc893) when using ARP */
227 #define TAG_IP_TRAILER_ENC      ((unsigned char)  34)
228 /* timeout in seconds for ARP cache entries */
229 #define TAG_ARP_TIMEOUT         ((unsigned char)  35)
230 /* use either Ethernet version 2 (rfc894) or IEEE 802.3 (rfc1042) */
231 #define TAG_ETHER_IEEE          ((unsigned char)  36)
232 /* default TCP TTL when sending TCP segments */
233 #define TAG_IP_TCP_TTL          ((unsigned char)  37)
234 /* time for client to wait before sending a keepalive on a TCP connection */
235 #define TAG_IP_TCP_KA_INT       ((unsigned char)  38)
236 /* don't send keepalive with an octet of garbage for compatability */
237 #define TAG_IP_TCP_KA_GARBAGE   ((unsigned char)  39)
238 /* NIS domainname */
239 #define TAG_NIS_DOMAIN          ((unsigned char)  40)
240 /* list of NIS servers */
241 #define TAG_NIS_SERVER          ((unsigned char)  41)
242 /* list of NTP servers */
243 #define TAG_NTP_SERVER          ((unsigned char)  42)
244 /* and stuff vendors may want to add */
245 #define TAG_VEND_SPECIFIC       ((unsigned char)  43)
246 /* NetBios over TCP/IP name server */
247 #define TAG_NBNS_SERVER         ((unsigned char)  44)
248 /* NetBios over TCP/IP NBDD servers (rfc1001/1002) */
249 #define TAG_NBDD_SERVER         ((unsigned char)  45)
250 /* NetBios over TCP/IP node type option for use with above */
251 #define TAG_NBOTCP_OTPION       ((unsigned char)  46)
252 /* NetBios over TCP/IP scopt option for use with above */
253 #define TAG_NB_SCOPE            ((unsigned char)  47)
254 /* list of X Window system font servers */
255 #define TAG_XFONT_SERVER        ((unsigned char)  48)
256 /* list of systems running X Display Manager (xdm) available to this client */
257 #define TAG_XDISPLAY_SERVER     ((unsigned char)  49)
258
259 /* While the following are only allowed for DHCP */
260 /* DHCP requested IP address */
261 #define TAG_DHCP_REQ_IP         ((unsigned char)  50)
262 /* DHCP time for lease of IP address */
263 #define TAG_DHCP_LEASE_TIME     ((unsigned char)  51)
264 /* DHCP options overload */
265 #define TAG_DHCP_OPTOVER        ((unsigned char)  52)
266 /* DHCP message type */
267 #define TAG_DHCP_MESS_TYPE      ((unsigned char)  53)
268 /* DHCP server identification */
269 #define TAG_DHCP_SERVER_ID      ((unsigned char)  54)
270 /* DHCP ordered list of requested parameters */
271 #define TAG_DHCP_PARM_REQ_LIST  ((unsigned char)  55)
272 /* DHCP reply message */
273 #define TAG_DHCP_TEXT_MESSAGE   ((unsigned char)  56)
274 /* DHCP maximum packet size willing to accept */
275 #define TAG_DHCP_MAX_MSGSZ      ((unsigned char)  57)
276 /* DHCP time 'til client needs to renew */
277 #define TAG_DHCP_RENEWAL_TIME   ((unsigned char)  58)
278 /* DHCP  time 'til client needs to rebind */
279 #define TAG_DHCP_REBIND_TIME    ((unsigned char)  59)
280 /* DHCP class identifier */
281 #define TAG_DHCP_CLASSID        ((unsigned char)  60)
282 /* DHCP client unique identifier */
283 #define TAG_DHCP_CLIENTID       ((unsigned char)  61)
284
285 /* XXX - Add new tags here */
286
287 /* DHCP Message Types */
288 #define DHCP_MESS_TYPE_DISCOVER  ((unsigned char) 1)
289 #define DHCP_MESS_TYPE_OFFER     ((unsigned char) 2)
290 #define DHCP_MESS_TYPE_REQUEST   ((unsigned char) 3)
291 #define DHCP_MESS_TYPE_DECLINE   ((unsigned char) 4)
292 #define DHCP_MESS_TYPE_ACK       ((unsigned char) 5)
293 #define DHCP_MESS_TYPE_NAK       ((unsigned char) 6)
294 #define DHCP_MESS_TYPE_RELEASE   ((unsigned char) 7)
295
296 /*
297  * "vendor" data permitted for CMU bootp clients.
298  */
299
300 struct cmu_vend {
301         char            v_magic[4];     /* magic number */
302         unsigned int    v_flags;        /* flags/opcodes, etc. */
303         struct in_addr  v_smask;        /* Subnet mask */
304         struct in_addr  v_dgate;        /* Default gateway */
305         struct in_addr  v_dns1, v_dns2; /* Domain name servers */
306         struct in_addr  v_ins1, v_ins2; /* IEN-116 name servers */
307         struct in_addr  v_ts1, v_ts2;   /* Time servers */
308         int             v_unused[6];    /* currently unused */
309 };
310
311
312 /* v_flags values */
313 #define VF_SMASK        1       /* Subnet mask field contains valid data */
314
315 #define IPPORT_BOOTPS           67
316 #define IPPORT_BOOTPC           68
317
318 #endif // _BOOTP_H_