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