1 /*        $NetBSD: tftp.h,v 1.6 2005/12/11 12:24:46 christos Exp $    */
2 
3 /*
4  * Copyright (c) 1996
5  *        Matthias Drochner.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 /*        NetBSD: tftp.h,v 1.6 2000/10/18 01:35:46 dogcow Exp         */
30 
31 /*
32  * Copyright (c) 1983, 1993
33  *        The Regents of the University of California.  All rights reserved.
34  *
35  * Redistribution and use in source and binary forms, with or without
36  * modification, are permitted provided that the following conditions
37  * are met:
38  * 1. Redistributions of source code must retain the above copyright
39  *    notice, this list of conditions and the following disclaimer.
40  * 2. Redistributions in binary form must reproduce the above copyright
41  *    notice, this list of conditions and the following disclaimer in the
42  *    documentation and/or other materials provided with the distribution.
43  * 3. Neither the name of the University nor the names of its contributors
44  *    may be used to endorse or promote products derived from this software
45  *    without specific prior written permission.
46  *
47  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
48  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
50  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
51  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
53  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
55  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
56  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57  * SUCH DAMAGE.
58  *
59  *        @(#)tftp.h          8.1 (Berkeley) 6/2/93
60  */
61 /*
62  * Trivial File Transfer Protocol (IEN-133)
63  */
64 #define   SEGSIZE             512                 /* data segment size */
65 
66 /*
67  * Packet types.
68  */
69 #define   RRQ       01                            /* read request */
70 #define   WRQ       02                            /* write request */
71 #define   DATA      03                            /* data packet */
72 #define   ACK       04                            /* acknowledgement */
73 #define   ERROR     05                            /* error code */
74 
75 struct    tftphdr {
76           short     th_opcode;                    /* packet type */
77           union {
78                     unsigned short tu_block; /* block # */
79                     short     tu_code;  /* error code */
80                     char      tu_stuff[1];        /* request packet stuff */
81           } th_u;
82           char      th_data[1];                   /* data or error string */
83 };
84 
85 #define   th_block  th_u.tu_block
86 #define   th_code             th_u.tu_code
87 #define   th_stuff  th_u.tu_stuff
88 #define   th_msg              th_data
89 
90 /*
91  * Error codes.
92  */
93 #define   EUNDEF              0                   /* not defined */
94 #define   ENOTFOUND 1                   /* file not found */
95 #define   EACCESS             2                   /* access violation */
96 #define   ENOSPACE  3                   /* disk full or allocation exceeded */
97 #define   EBADOP              4                   /* illegal TFTP operation */
98 #define   EBADID              5                   /* unknown transfer ID */
99 #define   EEXISTS             6                   /* file already exists */
100 #define   ENOUSER             7                   /* no such user */
101 
102 FS_DEF(tftp);
103 
104 #define IPPORT_TFTP 69
105