OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [common/] [current/] [include/] [bootp.h] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.