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