/* vim: set filetype=c:
 *
 **************************************************************************
 *
 * Boot-ROM-Code to load an operating system across a TCP/IP network.
 *
 * Module:  arpa.h86
 * Purpose: Header file for the higher internet protocols
 * 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: arpa.h86,v 1.6 2007/01/06 18:30:47 gkminix Exp $
 */

#ifndef HEADERS_ARPA_H86
#define HEADERS_ARPA_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 system include files here
 */
#include <common.h86>
#include <net/ethernet.h86>
#include <net/in.h86>
#include <net/bootp.h86>
#include <pxe/base.h86>
#include <pxe/tftp.h86>



/*
 **************************************************************************
 *
 * BOOTP/DHCP packet buffers
 */

/* BOOTP/DHCP packet types */
#define BOOTP_DISCOVER		(BASE_PACKET_DHCP_DISCOVER - 1)
#define BOOTP_ACK		(BASE_PACKET_DHCP_ACK - 1)
#define BOOTP_REPLY		(BASE_PACKET_BINL_REPLY - 1)
#define BOOTP_PACKET_NUM	3


/* BOOTP/DHCP buffer pointers and sizes */
extern struct bootp *bootp_bufs[BOOTP_PACKET_NUM];	/* BOOTP buffer ptrs */
extern size_t bootp_sizes[BOOTP_PACKET_NUM];		/* BOOTP buffer sizes */
extern short cur_bootp_buf;				/* ID of current buf */



/*
 **************************************************************************
 *
 * TFTP global variables
 */
extern __u8          *tftpbuf;			/* TFTP receive buffer	*/
extern size_t         tftpbuflen;		/* number of bytes	*/
extern size_t         tftpbufsize;		/* size of buffer	*/
extern unsigned long  filesize;			/* size of file to read	*/
extern unsigned short srvrtout;			/* server timeout	*/
extern unsigned short clnttout;			/* client timeout	*/
extern bool_t         tftpoflag;		/* open flag		*/



/*
 **************************************************************************
 *
 * Public routines of the internet protocols library:
 */

/* Get a BOOTP record from server */
extern short bootp(void);

/* Get a vendor tag from a BOOTP record */
extern __u8 *get_vend(short id);

/* Open a TFTP read connection */
extern short tftp_open(t_ipaddr server, t_ipaddr gateway,
				__u8 *fname, size_t fnamlen, short sport);

/* Get next block */
extern short tftp_get(void);

/* Close a TFTP connection */
extern short tftp_close(void);

/* Read a file via TFTP */
extern short tftp_read_file(t_tftp_read_file *params);


#endif

