/* vim: set filetype=c:
 *
 * bootp.h86  -  BOOTP record include file
 *
 * 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: bootp.h86,v 1.7 2007/01/06 18:30:54 gkminix Exp $
 */

#ifndef NET_BOOTP_H86
#define NET_BOOTP_H86


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



/*
 **************************************************************************
 *
 * Layout and magic ID of BOOTP/DHCP record. Refer to RFC 951,
 * RFC 1048 and RFC 1533 for further information.  The BOOTP/DHCP
 * record can be longer than the standard length as the bootrom
 * might be able to load a vendor extension file via tftp.
 */

/* RFC2132 vendor tags */
#define VEND_RFC_NOP		0	/* NOP				*/
#define VEND_RFC_SUBNET		1	/* Subnet mask			*/
#define VEND_RFC_TOFFS		2	/* Time offset			*/
#define VEND_RFC_ROUTER		3	/* Router IP address list	*/
#define VEND_RFC_TIMES		4	/* Time server IP address	*/
#define VEND_RFC_NAMES		5	/* Name server IP address	*/
#define VEND_RFC_DNS		6	/* Domain name server IP addr	*/
#define VEND_RFC_LOGS		7	/* Log server IP address	*/
#define VEND_RFC_COOKIES	8	/* Cookie server IP address	*/
#define VEND_RFC_LPRS		9	/* LPR server IP address	*/
#define VEND_RFC_IMPRESS	10	/* IMPRESS server IP address	*/
#define VEND_RFC_RESOURCES	11	/* Resource location server IP	*/
#define VEND_RFC_HNAME		12	/* Client host name		*/
#define VEND_RFC_BFSIZE		13	/* Boot file size		*/
#define VEND_RFC_DUMPFILE	14	/* Merrit Dump file name	*/
#define VEND_RFC_DOMAIN		15	/* Client domain name		*/
#define VEND_RFC_SWAPS		16	/* Swap server IP address	*/
#define VEND_RFC_ROOTPATH	17	/* Root file system path name	*/
#define VEND_RFC_EXTFILE	18	/* Extensions file name		*/
#define VEND_RFC_BROADCAST	28	/* Broadcast address		*/
#define VEND_RFC_VENDOR		43	/* Vendor extensions		*/
#define VEND_RFC_REQIP		50	/* Requested client IP address	*/
#define VEND_RFC_IPLEASE	51	/* Lease time for IP address	*/
#define VEND_RFC_OVERLOAD	52	/* Option overload flags	*/
#define VEND_RFC_MSGTYPE	53	/* DHCP message type		*/
#define VEND_RFC_SERVER		54	/* Server IP address		*/
#define VEND_RFC_PARAMREQ	55	/* Parameter request list	*/
#define VEND_RFC_MESSAGE	56	/* DHCP error message		*/
#define VEND_RFC_DHCPSIZE	57	/* Max. DHCP message size	*/
#define VEND_RFC_RENEW		58	/* DHCP renewal time		*/
#define VEND_RFC_REBIND		59	/* DHCP rebind time		*/
#define VEND_RFC_CLASS		60	/* Vendor class identifier	*/
#define VEND_RFC_CLIENTID	61	/* Client ID			*/
#define VEND_RFC_TFTPNAME	66	/* TFTP server name		*/
#define VEND_RFC_BOOTFILE	67	/* Boot file name		*/
#define VEND_RFC_ARCH		93	/* Client architecture		*/
#define VEND_RFC_NETID		94	/* Client network interface ID	*/
#define VEND_RFC_UUID		97	/* Client UUID			*/
#define VEND_RFC_END		255	/* End of option list		*/

/* Option overload flags */
#define VEND_OVR_FILE		1	/* 'file' field used		*/
#define VEND_OVR_SNAME		2	/* 'sname' field used		*/
#define VEND_OVR_BOTH		3	/* both fields used		*/

/* DHCP message types */
#define VEND_DHCP_DISCOVER	1	/* DHCPDISCOVER message		*/
#define VEND_DHCP_OFFER		2	/* DHCPOFFER message		*/
#define VEND_DHCP_REQUEST	3	/* DHCPREQUEST message		*/
#define VEND_DHCP_DECLINE	4	/* DHCPDECLINE message		*/
#define VEND_DHCP_ACK		5	/* DHCPACK message		*/
#define VEND_DHCP_NAK		6	/* DHCPNAK message		*/
#define VEND_DHCP_RELEASE	7	/* DHCPRELEASE message		*/
#define VEND_DHCP_INFORM	8	/* DHCPINFORM message		*/

/* Client system architecture types */
#define VEND_CLIENT_IAx86PC	0	/* Intel x86 PC client		*/
#define VEND_CLIENT_PC98	1	/* NEC/Intel PC98 client	*/
#define VEND_CLIENT_IA64PC	2	/* Intel IA64 client		*/
#define VEND_CLIENT_ALPHA	3	/* DEC alpha client		*/
#define VEND_CLIENT_ARCx86	4	/* Intel x86 non-PC client	*/


/* BOOTP protocol opcodes */
#define	BOOTP_OP_REQUEST	1	/* BOOTP request		*/
#define	BOOTP_OP_REPLY		2	/* BOOTP reply			*/


/* BOOTP packet flags */
#define BOOTP_FLAG_BCAST	0x8000	/* Broadcast BOOTP/DHCP request	*/


/* Vendor magic ID */
#define BOOTP_VM_SIZE		4		/* Size of vendor magic	*/
#define BOOTP_VM_RFC1048	0x63538263	/* RFC 1048 vendor ID	*/


/*
 * BOOTP/DHCP packet.
 *
 * BOOTP_VENDOR_SIZE is calculated so that the whole BOOTP record is exactly
 * the size of an ethernet frame. However, RFC951 specifies a maximum size of
 * 64 bytes, while the vendor area can be as large as to fill up a full ether-
 * net frame with DHCP.
 *
 * BOOTP_MIN_SIZE is the minimum size a BOOTP record can have, e.g. the struc-
 * ture fields plus 64 bytes of vendor data area.
 *
 * BOOTP_MAX_SIZE is the upper limit a BOOTP/DHCP record can have. This arbi-
 * trarily set limit is to allow netboot clients to provide a predefined space
 * for storing a BOOTP/DHCP packet. The bootrom has to ensure that no BOOTP
 * buffer ever exceeds this limit. The only way to exceed this limit would be
 * to load an extra large BOOTP vendor extension file. The value has been
 * computed by adding 2048 (as a max. extension file size) to the size of a
 * RFC951 BOOTP record with a vendor data area size of 64 bytes. With DHCP
 * a vendor extension file is not supported, and therefore this limit can
 * never get exceeded with DHCP.
 */
#define BOOTP_CHADDR_SIZE	16	/* size of chaddr field		*/
#define BOOTP_SNAME_SIZE	64	/* size of sname field		*/
#define BOOTP_FILE_SIZE		128	/* size of filename field	*/
#define BOOTP_VENDOR_SIZE	1264	/* size of vendor area		*/

#define BOOTP_MIN_SIZE		300	/* min size of BOOTP record	*/
#define BOOTP_MAX_SIZE		2348	/* max size of BOOTP record	*/

#define BOOTP_RFC_MIN_SIZE	241	/* min size of BOOTP + RFC data	*/


#ifndef _ASSEMBLY_

/* We need the definition of IP addresses for defining the BOOTP record */
#include <common.h86>
#include <net/in.h86>

struct bootp {
	__u8      bp_op;		/* BOOTP op code		*/
	__u8      bp_hwtype;		/* hardware type		*/
	__u8      bp_hlen;		/* length of hardware address	*/
	__u8      bp_hops;		/* hop-number, only used by gw	*/
	__u32     bp_xid;		/* transaction ID		*/
	__u16     bp_secs;		/* time since client booted	*/
	__u16     bp_flags;		/* unused			*/
	t_ipaddr  bp_ciaddr;		/* client IP address		*/
	t_ipaddr  bp_yiaddr;		/* your (client) IP address	*/
	t_ipaddr  bp_siaddr;		/* server IP address		*/
	t_ipaddr  bp_giaddr;		/* BOOTP gateway IP address	*/
					/* client hardware address	*/
	__u8      bp_chaddr[BOOTP_CHADDR_SIZE];
					/* server host name		*/
	__u8      bp_sname[BOOTP_SNAME_SIZE];
					/* boot file name		*/
	__u8      bp_file[BOOTP_FILE_SIZE];
					/* optional vendor information	*/
	__u8      bp_vend[BOOTP_VENDOR_SIZE];
};

#else /* _ASSEMBLY_ */

		.struct	0
bootp_op:	.struct	.+1			# bootp OP-code
bootp_htype:	.struct	.+1			# hardware type
bootp_hlen:	.struct	.+1			# length of hardware addr
bootp_hops:	.struct	.+1			# hop-number
bootp_xid:	.struct	.+4			# transaction ID
bootp_secs:	.struct	.+2			# time since client booted
bootp_unused:	.struct	.+2	
bootp_ciaddr:	.struct	.+4			# client IP address
bootp_yiaddr:	.struct	.+4			# your (client) IP address
bootp_siaddr:	.struct	.+4			# server IP address
bootp_giaddr:	.struct	.+4			# BOOTP gateway IP address
bootp_chaddr:	.struct	.+BOOTP_CHADDR_SIZE	# client hardware address
bootp_sname:	.struct	.+BOOTP_SNAME_SIZE	# server host name
bootp_file:	.struct	.+BOOTP_FILE_SIZE	# boot file name
bootp_vend:	.struct	.+BOOTP_VENDOR_SIZE	# optional vendor information

#endif /* _ASSEMBLY_ */



/*
 **************************************************************************
 *
 * PXE vendor extension fields
 */

/* PXE vendor tags */
#define VEND_PXE_STRING		"PXEClient"
#define VEND_PXE_STRLEN		9

#define VEND_PXE_BASE		0x0100	/* Base of vendor tag numbers	*/
#define VEND_PXE_MTFTP_IP	0x0101	/* Multicast TFTP IP		*/
#define VEND_PXE_MTFTP_CPORT	0x0102	/* Multicast TFTP client port	*/
#define VEND_PXE_MTFTP_SPORT	0x0103	/* Multicast TFTP server port	*/
#define VEND_PXE_MTFTP_TMOUT	0x0104	/* Multicast TFTP timeout	*/
#define VEND_PXE_MTFTP_DELAY	0x0105	/* Multicast TFTP delay		*/
#define VEND_PXE_DISCOVER_CTL	0x0106	/* Discovery control		*/
#define VEND_PXE_DISCOVER_ADDR	0x0107	/* Discovery multicast IP addr	*/
#define VEND_PXE_SERVERS	0x0108	/* List of boot servers		*/
#define VEND_PXE_BOOT_MENU	0x0109	/* Boot menu specification	*/
#define VEND_PXE_MENU_PROMPT	0x010A	/* Boot menu prompt		*/
#define VEND_PXE_MCAST_ADDRS	0x010B	/* Multicast IP address range	*/
#define VEND_PXE_BOOT_ITEM	0x0147	/* Selected boot item		*/
#define VEND_PXE_END		0x01FF	/* End tag			*/

/* PXE boot server types */
#define VEND_PXE_SERV_PXE	0	/* PXE bootstrap server		*/
#define VEND_PXE_SERV_WINNT	1	/* Windows NT boot server	*/
#define VEND_PXE_SERV_LCM	2	/* Intel LCM boot server	*/
#define VEND_PXE_SERV_DOS	3	/* DOS/UNDI boot server		*/
#define VEND_PXE_SERV_ESMPRO	4	/* NEC ESMPRO boot server	*/
#define VEND_PXE_SERV_WSOD	5	/* IBM WSoD boot server		*/
#define VEND_PXE_SERV_LCCM	6	/* IBM LCCM boot server		*/

/* Discovery flags bit masks */
#define VEND_PXE_DISC_BCAST	0x01	/* Disable broadcast discovery	*/
#define VEND_PXE_DISC_MCAST	0x02	/* Disable multicast discovery	*/
#define VEND_PXE_DISC_SERVER	0x04	/* Only use PXE_SERVERS		*/



/*
 **************************************************************************
 *
 * Netboot vendor extension fields
 */

/* PXE vendor tags */
#define VEND_NB_STRING		"NBClient"
#define VEND_NB_STRLEN		8

#define VEND_NB_BASE		0x0200	/* Base of vendor tag numbers	*/
#define VEND_NB_TFTPSERVER	0x0201	/* IP address of TFTP server	*/
#define VEND_NB_TFTPSPORT	0x0202	/* Port number of TFTP server	*/
#define VEND_NB_BOOTFILE	0x0203	/* Name of boot image file	*/
#define VEND_NB_CLNTTOUT	0x0204	/* Client TFTP timeout		*/
#define VEND_NB_SRVRTOUT	0x0205	/* Server TFTP timeout		*/
#define VEND_NB_END		0x02FF	/* End tag			*/

#endif

