/* vim: set filetype=c:
 *
 * udp.h86  -  Definitions for UDP 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: udp.h86,v 1.9 2007/01/06 18:31:05 gkminix Exp $
 */

#ifndef PXE_UDP_H86
#define PXE_UDP_H86


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



/*
 **************************************************************************
 *
 * This file contains the UDP API definitions as per Intels PXE
 * specification version 2.1.
 *
 **************************************************************************
 *
 * UDP opcodes:
 */
#define UDP_OPEN		0x0030
#define UDP_CLOSE		0x0031
#define UDP_READ		0x0032
#define UDP_WRITE		0x0033

#define UDP_MINNUM		0x0030
#define UDP_MAXNUM		0x0033



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



/*
 **************************************************************************
 *
 * Definition of structure for UDP_OPEN function:
 */
#ifndef _USE_ASSEMBLER

typedef struct s_udp_open {
	__u16    status;		/* Out: function status */
	t_ipaddr src_ip;		/* In: IP address of this station */
} t_udp_open;

#else

			.struct	0
o_udpo_status:		.struct	.+2	/* Out: status */
o_udpo_src_ip:		.struct	.+4	/* In: IP address of this station */

#define udp_open_size		6	/* size of function structure */

#endif



/*
 **************************************************************************
 *
 * Definition of structure for UDP_CLOSE function:
 */
#ifndef _USE_ASSEMBLER

typedef struct s_udp_close {
	__u16 status;			/* Out: function status */
} t_udp_close;

#else

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

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

#endif



/*
 **************************************************************************
 *
 * Definition of structure for UDP_READ function:
 */
#ifndef _USE_ASSEMBLER

typedef struct s_udp_read {
	__u16    status;		/* Out: function status */
	t_ipaddr src_ip;		/* Out: IP address of sender */
	t_ipaddr dest_ip;		/* In: receive IP address */
	__u16    s_port;		/* Out: UDP source port of sender */
	__u16    d_port;		/* In: receive UDP port */
	__u16    bufsize;		/* In/Out: size of receive buffer */
	__fptr   buffer;		/* In: far pointer to receive buffer */
} t_udp_read;

#else

			.struct	0
o_udpr_status:		.struct	.+2	/* Out: status */
o_udpr_src_ip:		.struct	.+4	/* Out: IP address of sender */
o_udpr_dest_ip:		.struct	.+4	/* In: receive IP address */
o_udpr_s_port:		.struct	.+2	/* Out: UDP source port of sender */
o_udpr_d_port:		.struct	.+2	/* In: receive UDP port */
o_udpr_bufsize:		.struct	.+2	/* In/Out: size of receive buffer */
o_udpr_buffer:		.struct	.+4	/* In: far pointer to receive buffer */

#define udp_read_size		20	/* size of function structure */

#endif



/*
 **************************************************************************
 *
 * Definition of structure for UDP_WRITE function:
 */
#ifndef _USE_ASSEMBLER

#define PXE_UDP_DEF_PORT	2069	/* Default source port */

typedef struct s_udp_write {
	__u16    status;		/* Out: function status */
	t_ipaddr ip;			/* In: destination IP address */
	t_ipaddr gw;			/* In: gateway IP address */
	__u16    src_port;		/* In: source UDP port */
	__u16    dest_port;		/* In: destination UDP port */
	__u16    bufsize;		/* In: size of send buffer */
	__fptr   buffer;		/* In: far pointer to send buffer */
} t_udp_write;

#else

			.struct	0
o_udpw_status:		.struct	.+2	/* Out: status */
o_udpw_ip:		.struct	.+4	/* In: destination IP address */
o_udpw_gw:		.struct	.+4	/* In: gateway IP address */
o_udpw_src_port:	.struct	.+2	/* In: source UDP port */
o_udpw_dest_port:	.struct	.+2	/* In: destination UDP port */
o_udpw_bufsize:		.struct	.+2	/* In: size of send buffer */
o_udpw_buffer:		.struct	.+4	/* In: far pointer to send buffer */

#define udp_write_size		20	/* size of function structure */

#endif

#endif

