/* vim: set filetype=c:
 *
 **************************************************************************
 *
 * Boot-ROM-Code to load an operating system across a TCP/IP network.
 *
 * Module:  tftp.h86
 * Purpose: Definitions for implementing the TFTP protocol
 * Entries: none
 *
 **************************************************************************
 *
 * Copyright (C) 1995-2007 Gero Kuhlmann <gero@gkminix.han.de>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 * $Id: tftp.h86,v 1.7 2007/01/06 18:30:46 gkminix Exp $
 */

#ifndef KERNEL_ARPA_TFTP_H86
#define KERNEL_ARPA_TFTP_H86


/*
 **************************************************************************
 *
 * This file can only get included into target C source files
 */
#if defined(_ASSEMBLY_) || !defined(_TARGET_) || !defined(_BOOTROM_)
# error This file can only get included into target C source files
#endif



/*
 **************************************************************************
 *
 * We need some includes before we can include this file
 */
#include <common.h86>
#include <net/in.h86>



/*
 **************************************************************************
 *
 * TFTP packet types:
 */
#define	TFTP_RRQ	1		/* read request			*/
#define	TFTP_WRQ	2		/* write request		*/
#define	TFTP_DATA	3		/* data packet			*/
#define	TFTP_ACK	4		/* acknowledgement		*/
#define	TFTP_ERROR	5		/* error code			*/
#define TFTP_OACK	6		/* option acknowledgement	*/



/*
 **************************************************************************
 *
 * Error codes:
 */
#define	EUNDEF		0		/* not defined			*/
#define	ENOTFOUND	1		/* file not found		*/
#define	EACCESS		2		/* access violation		*/
#define	ENOSPACE	3		/* disk full			*/
#define	EBADOP		4		/* illegal TFTP operation	*/
#define	EBADID		5		/* unknown transfer ID		*/
#define	EEXISTS		6		/* file already exists		*/
#define	ENOUSER		7		/* no such user			*/
#define EBADOPT		8		/* invalid option		*/



/*
 **************************************************************************
 *
 * TFTP UDP port numbers:
 */
#define TFTP_S_PORT	IPPORT_TFTP	/* TFTP server port		*/
#define TFTP_C_PORT	IPPORT_USER	/* TFTP client port		*/



/*
 **************************************************************************
 *
 * TFTP header layout
 */
struct tftphdr {
	__u16  th_op;				/* TFTP op code		*/
	__u16  th_block;			/* block number		*/
	__u8   th_data[1];			/* data block		*/
};

#define th_error th_block			/* error code		*/



/*
 **************************************************************************
 *
 * TFTP buffer sizes
 */
#define DEFSEGSIZE	512		/* default TFTP segment size	*/
#define MAXSEGSIZE	1432		/* buffer size for ethernet MTU	*/
#define INPBUFSIZE	(sizeof(struct tftphdr) + MAXSEGSIZE)
#define ACKBUFSIZE	(sizeof(struct tftphdr) + 2)



/*
 **************************************************************************
 *
 * Option strings
 */
#define OCTET_STR	"octet"		/* define name of data format	*/
#define BLKSIZE_STR	"blksize"	/* block size option		*/
#define TSIZE_STR	"tsize"		/* transfer file size		*/
#define TOUT_STR	"timeout"	/* TFTP read timeout		*/
#define MCAST_STR	"multicast"	/* multicast option		*/



/*
 **************************************************************************
 *
 * Various definitions:
 */
#define TFTP_RETRY		10	/* Maximum number of retries	*/
#define TFTP_CLNT_TIMEOUT	15	/* 15 seconds client timeout	*/
#define TFTP_SRVR_TIMEOUT	3	/* 3 seconds server timeout	*/

#define MAX_CLNT_TIMEOUT	512	/* Maximum client timeout */
#define MAX_SRVR_TIMEOUT	256	/* Maximum server timeout */

#endif

