102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes/* 202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * Copyright (c) 1983, 1993 302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * The Regents of the University of California. All rights reserved. 402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * Redistribution and use in source and binary forms, with or without 602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * modification, are permitted provided that the following conditions 702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * are met: 802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 1. Redistributions of source code must retain the above copyright 902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * notice, this list of conditions and the following disclaimer. 1002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 2. Redistributions in binary form must reproduce the above copyright 1102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * notice, this list of conditions and the following disclaimer in the 1202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * documentation and/or other materials provided with the distribution. 1302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 3. Neither the name of the University nor the names of its contributors 1402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * may be used to endorse or promote products derived from this software 1502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * without specific prior written permission. 1602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 1702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * SUCH DAMAGE. 2802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * 2902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * @(#)tftp.h 8.1 (Berkeley) 6/2/93 3002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * $FreeBSD$ 3102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes */ 3202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 3302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#ifndef _ARPA_TFTP_H_ 3402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define _ARPA_TFTP_H_ 3502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 3602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#include <sys/cdefs.h> 3702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 3802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes/* 3902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * Trivial File Transfer Protocol (IEN-133) 4002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes */ 4102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define SEGSIZE 512 /* data segment size */ 4202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 4302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes/* 4402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * Packet types. 4502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes */ 4602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define RRQ 01 /* read request */ 4702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define WRQ 02 /* write request */ 4802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define DATA 03 /* data packet */ 4902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define ACK 04 /* acknowledgement */ 5002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define ERROR 05 /* error code */ 5102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define OACK 06 /* option acknowledgement */ 5202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 5302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughesstruct tftphdr { 5402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes unsigned short th_opcode; /* packet type */ 5502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes union { 5602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes unsigned short tu_block; /* block # */ 5702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes unsigned short tu_code; /* error code */ 5802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes char tu_stuff[1]; /* request packet stuff */ 5902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes } __packed th_u; 6002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes char th_data[1]; /* data or error string */ 6102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes} __packed; 6202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 6302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define th_block th_u.tu_block 6402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define th_code th_u.tu_code 6502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define th_stuff th_u.tu_stuff 6602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define th_msg th_data 6702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 6802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes/* 6902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes * Error codes. 7002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes */ 7102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EUNDEF 0 /* not defined */ 7202a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define ENOTFOUND 1 /* file not found */ 7302a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EACCESS 2 /* access violation */ 7402a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define ENOSPACE 3 /* disk full or allocation exceeded */ 7502a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EBADOP 4 /* illegal TFTP operation */ 7602a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EBADID 5 /* unknown transfer ID */ 7702a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EEXISTS 6 /* file already exists */ 7802a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define ENOUSER 7 /* no such user */ 7902a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#define EOPTNEG 8 /* option negotiation failed */ 8002a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes 8102a3fe9fc6b5197f5b57487f1f735fb7136347ecElliott Hughes#endif /* !_TFTP_H_ */ 82