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

#ifndef KERNEL_NET_IP_H86
#define KERNEL_NET_IP_H86


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



/*
 **************************************************************************
 *
 * IP protocols:
 */
#define IPPROTO_ICMP	1	/* Internet Control Message Protocol	*/
#define IPPROTO_IGMP	2	/* Internet Group Management Protocol	*/
#define IPPROTO_TCP	6	/* Transmission Control Protocol	*/
#define IPPROTO_EGP	8	/* Exterior Gateway Protocol		*/
#define IPPROTO_PUP	12	/* PUP protocol				*/
#define IPPROTO_UDP	17	/* User Datagram Protocol		*/

#define IPPROTO_NUM	18	/* Maximum number of IP protocols	*/



/*
 **************************************************************************
 *
 * Definitions to be used for packet fragmentation
 */
#define IP_FRAG_MORE	0x2000	/* More fragments following		*/
#define IP_FRAG_NONE	0x4000	/* Don't fragment packet		*/
#define IP_FRAG_MASK	0x1FFF	/* Fragment offset mask			*/



/*
 **************************************************************************
 *
 * IP header structure
 */
struct iphdr {
	__u8     ip_ihl_version;
	__u8     ip_tos;
	__u16    ip_tot_len;
	__u16    ip_id;
	__u16    ip_frag_off;
	__u8     ip_ttl;
	__u8     ip_protocol;
	__u16    ip_check;
	t_ipaddr ip_saddr;
	t_ipaddr ip_daddr;
};



/*
 **************************************************************************
 *
 * Miscellaneous defines. Note that the maximum receive packet size has
 * to be smaller or equal to the maximum transfer unit size of the
 * network driver.
 */
#define IP_TTL		255		/* 255 sec default TTL		*/
#define IP_VERSION	4		/* IP version number		*/
#define IP_MIN_HSIZE	20		/* Minimum size of IP header	*/
#define IP_STD_TOS	0		/* Standard type of service	*/



/*
 **************************************************************************
 * 
 * Global variables for use by the network layer
 */
extern unsigned short ippacketid;	/* IP packet id			*/



/*
 **************************************************************************
 * 
 * Assembler routines for IP processing
 */

/* Compute IP header checksum */
extern __u16 ipchksum(__u8 *buf, size_t len);

#endif

