1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// net/tftp.h
|
4 |
|
|
//
|
5 |
|
|
// Stand-alone TFTP 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 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY 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
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
// ####BSDALTCOPYRIGHTBEGIN####
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// Portions of this software may have been derived from FreeBSD, OpenBSD,
|
42 |
|
|
// or other sources, and if so are covered by the appropriate copyright
|
43 |
|
|
// and license included herein.
|
44 |
|
|
// -------------------------------------------
|
45 |
|
|
// ####BSDALTCOPYRIGHTEND####
|
46 |
|
|
//==========================================================================
|
47 |
|
|
//#####DESCRIPTIONBEGIN####
|
48 |
|
|
//
|
49 |
|
|
// Author(s): gthomas
|
50 |
|
|
// Contributors: gthomas
|
51 |
|
|
// Date: 2000-07-14
|
52 |
|
|
// Purpose:
|
53 |
|
|
// Description:
|
54 |
|
|
//
|
55 |
|
|
// This code is part of RedBoot (tm).
|
56 |
|
|
//
|
57 |
|
|
//####DESCRIPTIONEND####
|
58 |
|
|
//
|
59 |
|
|
//==========================================================================
|
60 |
|
|
|
61 |
|
|
/*
|
62 |
|
|
* Copyright (c) 1983 Regents of the University of California.
|
63 |
|
|
* All rights reserved.
|
64 |
|
|
*
|
65 |
|
|
* Redistribution and use in source and binary forms, with or without
|
66 |
|
|
* modification, are permitted provided that the following conditions
|
67 |
|
|
* are met:
|
68 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
69 |
|
|
* notice, this list of conditions and the following disclaimer.
|
70 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
71 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
72 |
|
|
* documentation and/or other materials provided with the distribution.
|
73 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
74 |
|
|
* must display the following acknowledgement:
|
75 |
|
|
* This product includes software developed by the University of
|
76 |
|
|
* California, Berkeley and its contributors.
|
77 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
78 |
|
|
* may be used to endorse or promote products derived from this software
|
79 |
|
|
* without specific prior written permission.
|
80 |
|
|
*
|
81 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
82 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
83 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
84 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
85 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
86 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
87 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
88 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
89 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
90 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
91 |
|
|
* SUCH DAMAGE.
|
92 |
|
|
*
|
93 |
|
|
* @(#)tftp.h 5.4 (Berkeley) 4/3/91
|
94 |
|
|
*/
|
95 |
|
|
|
96 |
|
|
#ifndef _ARPA_TFTP_H_
|
97 |
|
|
#define _ARPA_TFTP_H_
|
98 |
|
|
|
99 |
|
|
/*
|
100 |
|
|
* Trivial File Transfer Protocol (IEN-133)
|
101 |
|
|
* Now, rev 2 - RFC 1350
|
102 |
|
|
*/
|
103 |
|
|
#define SEGSIZE 512 /* data segment size */
|
104 |
|
|
|
105 |
|
|
/*
|
106 |
|
|
* Packet types.
|
107 |
|
|
*/
|
108 |
|
|
#define RRQ 01 /* read request */
|
109 |
|
|
#define WRQ 02 /* write request */
|
110 |
|
|
#define DATA 03 /* data packet */
|
111 |
|
|
#define ACK 04 /* acknowledgement */
|
112 |
|
|
#define ERROR 05 /* error code */
|
113 |
|
|
|
114 |
|
|
struct tftphdr {
|
115 |
|
|
short th_opcode; /* packet type */
|
116 |
|
|
union {
|
117 |
|
|
unsigned short tu_block; /* block # */
|
118 |
|
|
short tu_code; /* error code */
|
119 |
|
|
char tu_stuff[1]; /* request packet stuff */
|
120 |
|
|
} __attribute__ ((packed)) th_u;
|
121 |
|
|
char th_data[0]; /* data or error string */
|
122 |
|
|
} __attribute__ ((packed));
|
123 |
|
|
|
124 |
|
|
#define th_block th_u.tu_block
|
125 |
|
|
#define th_code th_u.tu_code
|
126 |
|
|
#define th_stuff th_u.tu_stuff
|
127 |
|
|
#define th_msg th_data
|
128 |
|
|
|
129 |
|
|
/*
|
130 |
|
|
* Error codes.
|
131 |
|
|
*/
|
132 |
|
|
#define EUNDEF 0 /* not defined */
|
133 |
|
|
#define ENOTFOUND 1 /* file not found */
|
134 |
|
|
#define EACCESS 2 /* access violation */
|
135 |
|
|
#define ENOSPACE 3 /* disk full or allocation exceeded */
|
136 |
|
|
#define EBADOP 4 /* illegal TFTP operation */
|
137 |
|
|
#define EBADID 5 /* unknown transfer ID */
|
138 |
|
|
#define EEXISTS 6 /* file already exists */
|
139 |
|
|
#define ENOUSER 7 /* no such user */
|
140 |
|
|
|
141 |
|
|
#endif /* !_ARPA_TFTP_H_ */
|