/* vim: set filetype=c:
 *
 * tftp.h86  -  Definitions for TFTP PXE API services
 *
 * Copyright (C) 2003-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.9 2007/01/06 18:31:04 gkminix Exp $
 */

#ifndef PXE_TFTP_H86
#define PXE_TFTP_H86


/*
 * This file can only get included into target C or assembler source files.
 */
#define GCC_INCLUDE
#include <compiler.h>



/*
 **************************************************************************
 *
 * This file contains the TFTP API definitions as per Intels PXE
 * specification version 2.1.
 *
 **************************************************************************
 *
 * TFTP opcodes:
 */
#define TFTP_OPEN		0x0020
#define TFTP_CLOSE		0x0021
#define TFTP_READ_DATA		0x0022
#define TFTP_READ_FILE		0x0023
#define TFTP_GET_FILE_SIZE	0x0025

#define TFTP_MINNUM		0x0020
#define TFTP_MAXNUM		0x0025



/*
 **************************************************************************
 *
 * We need the definition of the IP address type
 */
#ifndef _ASSEMBLY_
# include <common.h86>
# include <net/in.h86>
#endif



/*
 **************************************************************************
 *
 * Definition of structure for TFTP_OPEN function:
 */
#ifndef _ASSEMBLY_

typedef struct s_tftp_open {
	__u16    status;		/* Out: function status */
	t_ipaddr server;		/* In: server IP address */
	t_ipaddr gateway;		/* In: gateway IP address */
	__u8     filename[128];		/* In: name of file */
	__u16    port;			/* In: port number */
	__u16    pktsize;		/* In/Out: packet size */
} t_tftp_open;

#else

			.struct	0
o_to_status:		.struct	.+2	/* Out: status */
o_to_server:		.struct	.+4	/* In: server IP address */
o_to_gateway:		.struct	.+4	/* In: gateway IP address */
o_to_filename:		.struct	.+128	/* In: name of file */
o_to_port:		.struct	.+2	/* In: port number */
o_to_pktsize:		.struct	.+2	/* In/Out: packet size */

#define tftp_open_size		142	/* size of function structure */

#endif



/*
 **************************************************************************
 *
 * Definition of structure for TFTP_CLOSE function:
 */
#ifndef _ASSEMBLY_

typedef struct s_tftp_close {
	__u16 status;			/* Out: function status */
} t_tftp_close;

#else

			.struct	0
o_tc_status:		.struct	.+2	/* Out: status */

#define tftp_close_size		2	/* size of function structure */

#endif



/*
 **************************************************************************
 *
 * Definition of structure for TFTP_READ_DATA function:
 */
#ifndef _ASSEMBLY_

typedef struct s_tftp_read_data {
	__u16  status;			/* Out: function status */
	__u16  packetno;		/* Out: packet number */
	__u16  bufsize;			/* In/Out: size of receive buffer */
	__fptr buffer;			/* In: far pointer to receive buffer */
} t_tftp_read_data;

#else

			.struct
o_trd_status:		.struct	.+2	/* Out: status */
o_trd_packetno:		.struct	.+2	/* Out: packet number */
o_trd_bufsize:		.struct	.+2	/* In/Out: size of receive buffer */
o_trd_buffer:		.struct	.+4	/* In: far pointer to receive buffer */

#define tftp_read_data_size	10	/* size of function structure */

#endif



/*
 **************************************************************************
 *
 * Definition of structure for TFTP_READ_FILE function:
 */
#ifndef _ASSEMBLY_

typedef struct s_tftp_read_file {
	__u16    status;		/* Out: function status */
	__u8     filename[128];		/* In: file name */
	__u32    bufsize;		/* In/Out: size of receive buffer */
	__lptr   buffer;		/* In: linear address of buffer */
	t_ipaddr server;		/* In: server IP address */
	t_ipaddr gateway;		/* In: gateway IP address */
	t_ipaddr mcast;			/* In: file multicast IP address */
	__u16    clntport;		/* In: client multicast port */
	__u16    srvport;		/* In: server multicast port */
	__u16    opentimeout;		/* In: open/ack timeout */
	__u16    reopendelay;		/* In: MTFTP reopen delay */
} t_tftp_read_file;

#else

			.struct	0
o_trf_status:		.struct	.+2	/* Out: status */
o_trf_filename:		.struct	.+128	/* In: file name */
o_trf_bufsize:		.struct	.+4	/* In/Out: size of receive buffer */
o_trf_buffer:		.struct	.+4	/* In: linear address of buffer */
o_trf_server:		.struct	.+4	/* In: server IP address */
o_trf_gateway:		.struct	.+4	/* In: gateway IP address */
o_trf_mcast:		.struct	.+4	/* In: file multicast IP address */
o_trf_clntport:		.struct	.+2	/* In: client multicast port */
o_trf_srvport:		.struct	.+2	/* In: server multicast port */
o_trf_opentimeout:	.struct	.+2	/* In: open/ack timeout */
o_trf_reopendelay:	.struct	.+2	/* In: MTFTP reopen delay */

#define tftp_read_file_size	158	/* size of function structure */

#endif

#define DEFAULT_OPENTIMEOUT	3	/* default open/ack timeout */
#define DEFAULT_REOPENDELAY	5	/* default MTFTP reopen delay */



/*
 **************************************************************************
 *
 * Definition of structure for TFTP_GET_FILE_SIZE function:
 */
#ifndef _ASSEMBLY_

typedef struct s_tftp_get_file_size {
	__u16    status;		/* Out: function status */
	t_ipaddr server;		/* In: server IP address */
	t_ipaddr gateway;		/* In: gateway IP address */
	__u8     filename[128];		/* In: file name */
	__u32    filesize;		/* Out: size of file in bytes */
} t_tftp_get_file_size;

#else

			.struct	0
o_trfs_status:		.struct	.+2	/* Out: status */
o_trfs_server:		.struct	.+4	/* In: server IP address */
o_trfs_gateway:		.struct	.+4	/* In: gateway IP address */
o_trfs_filename:	.struct	.+128	/* In: file name */
o_trfs_filesize:	.struct	.+4	/* Out: size of file in bytes */

#define tftp_get_file_size_size	142	/* size of function structure */

#endif

#endif

