1 |
27 |
unneback |
//==========================================================================
|
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 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 |
|
|
//####BSDCOPYRIGHTBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// -------------------------------------------
|
44 |
|
|
//
|
45 |
|
|
// Portions of this software may have been derived from OpenBSD or other sources,
|
46 |
|
|
// and are covered by the appropriate copyright disclaimers included herein.
|
47 |
|
|
//
|
48 |
|
|
// -------------------------------------------
|
49 |
|
|
//
|
50 |
|
|
//####BSDCOPYRIGHTEND####
|
51 |
|
|
//==========================================================================
|
52 |
|
|
//#####DESCRIPTIONBEGIN####
|
53 |
|
|
//
|
54 |
|
|
// Author(s): gthomas
|
55 |
|
|
// Contributors: gthomas
|
56 |
|
|
// Date: 2000-07-14
|
57 |
|
|
// Purpose:
|
58 |
|
|
// Description:
|
59 |
|
|
//
|
60 |
|
|
// This code is part of RedBoot (tm).
|
61 |
|
|
//
|
62 |
|
|
//####DESCRIPTIONEND####
|
63 |
|
|
//
|
64 |
|
|
//==========================================================================
|
65 |
|
|
|
66 |
|
|
/*
|
67 |
|
|
* Copyright (c) 1983 Regents of the University of California.
|
68 |
|
|
* All rights reserved.
|
69 |
|
|
*
|
70 |
|
|
* Redistribution and use in source and binary forms, with or without
|
71 |
|
|
* modification, are permitted provided that the following conditions
|
72 |
|
|
* are met:
|
73 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
74 |
|
|
* notice, this list of conditions and the following disclaimer.
|
75 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
76 |
|
|
* notice, this list of conditions and the following disclaimer in the
|
77 |
|
|
* documentation and/or other materials provided with the distribution.
|
78 |
|
|
* 3. All advertising materials mentioning features or use of this software
|
79 |
|
|
* must display the following acknowledgement:
|
80 |
|
|
* This product includes software developed by the University of
|
81 |
|
|
* California, Berkeley and its contributors.
|
82 |
|
|
* 4. Neither the name of the University nor the names of its contributors
|
83 |
|
|
* may be used to endorse or promote products derived from this software
|
84 |
|
|
* without specific prior written permission.
|
85 |
|
|
*
|
86 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
87 |
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
88 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
89 |
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
90 |
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
91 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
92 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
93 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
94 |
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
95 |
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
96 |
|
|
* SUCH DAMAGE.
|
97 |
|
|
*
|
98 |
|
|
* @(#)tftp.h 5.4 (Berkeley) 4/3/91
|
99 |
|
|
*/
|
100 |
|
|
|
101 |
|
|
#ifndef _ARPA_TFTP_H_
|
102 |
|
|
#define _ARPA_TFTP_H_
|
103 |
|
|
|
104 |
|
|
/*
|
105 |
|
|
* Trivial File Transfer Protocol (IEN-133)
|
106 |
|
|
* Now, rev 2 - RFC 1350
|
107 |
|
|
*/
|
108 |
|
|
#define SEGSIZE 512 /* data segment size */
|
109 |
|
|
|
110 |
|
|
/*
|
111 |
|
|
* Packet types.
|
112 |
|
|
*/
|
113 |
|
|
#define RRQ 01 /* read request */
|
114 |
|
|
#define WRQ 02 /* write request */
|
115 |
|
|
#define DATA 03 /* data packet */
|
116 |
|
|
#define ACK 04 /* acknowledgement */
|
117 |
|
|
#define ERROR 05 /* error code */
|
118 |
|
|
|
119 |
|
|
struct tftphdr {
|
120 |
|
|
short th_opcode; /* packet type */
|
121 |
|
|
union {
|
122 |
|
|
unsigned short tu_block; /* block # */
|
123 |
|
|
short tu_code; /* error code */
|
124 |
|
|
char tu_stuff[1]; /* request packet stuff */
|
125 |
|
|
} __attribute__ ((packed)) th_u;
|
126 |
|
|
char th_data[0]; /* data or error string */
|
127 |
|
|
} __attribute__ ((packed));
|
128 |
|
|
|
129 |
|
|
#define th_block th_u.tu_block
|
130 |
|
|
#define th_code th_u.tu_code
|
131 |
|
|
#define th_stuff th_u.tu_stuff
|
132 |
|
|
#define th_msg th_data
|
133 |
|
|
|
134 |
|
|
/*
|
135 |
|
|
* Error codes.
|
136 |
|
|
*/
|
137 |
|
|
#define EUNDEF 0 /* not defined */
|
138 |
|
|
#define ENOTFOUND 1 /* file not found */
|
139 |
|
|
#define EACCESS 2 /* access violation */
|
140 |
|
|
#define ENOSPACE 3 /* disk full or allocation exceeded */
|
141 |
|
|
#define EBADOP 4 /* illegal TFTP operation */
|
142 |
|
|
#define EBADID 5 /* unknown transfer ID */
|
143 |
|
|
#define EEXISTS 6 /* file already exists */
|
144 |
|
|
#define ENOUSER 7 /* no such user */
|
145 |
|
|
|
146 |
|
|
#endif /* !_ARPA_TFTP_H_ */
|