1168054Sflz/*-
2168054Sflz * SPDX-License-Identifier: BSD-3-Clause
3168266Sgabor *
4168266Sgabor * Copyright (c) 1983, 1993
5168266Sgabor *	The Regents of the University of California.  All rights reserved.
6168266Sgabor *
7168266Sgabor * Redistribution and use in source and binary forms, with or without
8168266Sgabor * modification, are permitted provided that the following conditions
9168266Sgabor * are met:
10168266Sgabor * 1. Redistributions of source code must retain the above copyright
11168054Sflz *    notice, this list of conditions and the following disclaimer.
12168054Sflz * 2. Redistributions in binary form must reproduce the above copyright
13168064Sflz *    notice, this list of conditions and the following disclaimer in the
14168064Sflz *    documentation and/or other materials provided with the distribution.
15168064Sflz * 3. Neither the name of the University nor the names of its contributors
16168064Sflz *    may be used to endorse or promote products derived from this software
17168064Sflz *    without specific prior written permission.
18168064Sflz *
19168064Sflz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20168064Sflz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21168064Sflz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22168064Sflz * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23168064Sflz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24168064Sflz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25168064Sflz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26168064Sflz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27168054Sflz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28168054Sflz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29168064Sflz * SUCH DAMAGE.
30168054Sflz */
31168064Sflz
32171129Sobrien#ifndef _ARPA_TFTP_H_
33168939Stmclaugh#define	_ARPA_TFTP_H_
34168131Sbmah
35168113Smarcus#include <sys/cdefs.h>
36168123Snetchild
37168939Stmclaugh/*
38168064Sflz * Trivial File Transfer Protocol (IEN-133)
39168054Sflz */
40168054Sflz#define	SEGSIZE		512		/* data segment size */
41168054Sflz
42168054Sflz/*
43168261Sache * Packet types.
44168077Sflz */
45168077Sflz#define	RRQ	01			/* read request */
46168126Sale#define	WRQ	02			/* write request */
47168069Sgarga#define	DATA	03			/* data packet */
48168472Snovel#define	ACK	04			/* acknowledgement */
49168274Ssem#define	ERROR	05			/* error code */
50169073Saraujo#define	OACK	06			/* option acknowledgement */
51168667Sstefan
52168274Ssemstruct tftphdr {
53170471Sbeech	unsigned short	th_opcode;		/* packet type */
54168113Smarcus	union {
55168098Skrion		unsigned short	tu_block;	/* block # */
56168123Snetchild		unsigned short	tu_code;	/* error code */
57170601Schinsan		char	tu_stuff[1];	/* request packet stuff */
58168082Sgarga	} __packed th_u;
59168116Sclsung	char	th_data[1];		/* data or error string */
60168937Scperciva} __packed;
61168177Sgabor
62168354Sdanfe#define	th_block	th_u.tu_block
63168072Sehaupt#define	th_code		th_u.tu_code
64168108Srafan#define	th_stuff	th_u.tu_stuff
65168186Smat#define	th_msg		th_data
66168210Sitetcu
67168068Serwin/*
68168072Sehaupt * Error codes.
69168113Smarcus */
70168059Sgabor#define	EUNDEF		0		/* not defined */
71168542Smiwi#define	ENOTFOUND	1		/* file not found */
72168098Skrion#define	EACCESS		2		/* access violation */
73168054Sflz#define	ENOSPACE	3		/* disk full or allocation exceeded */
74168059Sgabor#define	EBADOP		4		/* illegal TFTP operation */
75168054Sflz#define	EBADID		5		/* unknown transfer ID */
76171129Sobrien#define	EEXISTS		6		/* file already exists */
77172158Sjkim#define	ENOUSER		7		/* no such user */
78172158Sjkim#define	EOPTNEG		8		/* option negotiation failed */
79168256Sijliao
80168209Sitetcu#endif /* !_TFTP_H_ */
81172158Sjkim