tftp.h revision 203965
11539Srgrimes/*
21539Srgrimes * Copyright (c) 1983, 1993
31539Srgrimes *	The Regents of the University of California.  All rights reserved.
41539Srgrimes *
51539Srgrimes * Redistribution and use in source and binary forms, with or without
61539Srgrimes * modification, are permitted provided that the following conditions
71539Srgrimes * are met:
81539Srgrimes * 1. Redistributions of source code must retain the above copyright
91539Srgrimes *    notice, this list of conditions and the following disclaimer.
101539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111539Srgrimes *    notice, this list of conditions and the following disclaimer in the
121539Srgrimes *    documentation and/or other materials provided with the distribution.
13203965Simp * 3. Neither the name of the University nor the names of its contributors
141539Srgrimes *    may be used to endorse or promote products derived from this software
151539Srgrimes *    without specific prior written permission.
161539Srgrimes *
171539Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201539Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211539Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231539Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241539Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251539Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261539Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271539Srgrimes * SUCH DAMAGE.
281539Srgrimes *
291539Srgrimes *	@(#)tftp.h	8.1 (Berkeley) 6/2/93
3083047Sobrien * $FreeBSD: head/include/arpa/tftp.h 203965 2010-02-16 19:46:46Z imp $
311539Srgrimes */
321539Srgrimes
332163Spaul#ifndef _ARPA_TFTP_H_
342163Spaul#define	_ARPA_TFTP_H_
351539Srgrimes
361539Srgrimes/*
371539Srgrimes * Trivial File Transfer Protocol (IEN-133)
381539Srgrimes */
391539Srgrimes#define	SEGSIZE		512		/* data segment size */
401539Srgrimes
411539Srgrimes/*
421539Srgrimes * Packet types.
431539Srgrimes */
441539Srgrimes#define	RRQ	01			/* read request */
451539Srgrimes#define	WRQ	02			/* write request */
461539Srgrimes#define	DATA	03			/* data packet */
471539Srgrimes#define	ACK	04			/* acknowledgement */
481539Srgrimes#define	ERROR	05			/* error code */
4984047Sobrien#define	OACK	06			/* option acknowledgement */
501539Srgrimes
5183047Sobrienstruct tftphdr {
5230583Sjoerg	unsigned short	th_opcode;		/* packet type */
531539Srgrimes	union {
5430583Sjoerg		unsigned short	tu_block;	/* block # */
5530583Sjoerg		unsigned short	tu_code;	/* error code */
561539Srgrimes		char	tu_stuff[1];	/* request packet stuff */
57171680Sticso	} __packed th_u;
581539Srgrimes	char	th_data[1];		/* data or error string */
59171680Sticso} __packed;
601539Srgrimes
611539Srgrimes#define	th_block	th_u.tu_block
621539Srgrimes#define	th_code		th_u.tu_code
631539Srgrimes#define	th_stuff	th_u.tu_stuff
641539Srgrimes#define	th_msg		th_data
651539Srgrimes
661539Srgrimes/*
671539Srgrimes * Error codes.
681539Srgrimes */
691539Srgrimes#define	EUNDEF		0		/* not defined */
701539Srgrimes#define	ENOTFOUND	1		/* file not found */
711539Srgrimes#define	EACCESS		2		/* access violation */
721539Srgrimes#define	ENOSPACE	3		/* disk full or allocation exceeded */
731539Srgrimes#define	EBADOP		4		/* illegal TFTP operation */
741539Srgrimes#define	EBADID		5		/* unknown transfer ID */
751539Srgrimes#define	EEXISTS		6		/* file already exists */
761539Srgrimes#define	ENOUSER		7		/* no such user */
7784047Sobrien#define	EOPTNEG		8		/* option negotiation failed */
781539Srgrimes
791539Srgrimes#endif /* !_TFTP_H_ */
80