/*
 * Copyright (c) 1982, 1986, 1989, 1993
 *	The Regents of the University of California.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by the University of
 *	California, Berkeley and its contributors.
 * 4. Neither the name of the University nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 *	@(#)if.h	8.1 (Berkeley) 6/10/93
 * $FreeBSD: src/sys/net/if.h,v 1.58.2.13 2004/12/12 21:08:33 brooks Exp $
 */


#ifndef _NET_IF_H_
#define	_NET_IF_H_


#include <sys/queue.h>
#include <sys/time.h>


struct ifnet;

/*
 * Length of interface external name, including terminating '\0'.
 * Note: this is the same size as a generic device's external name.
 */
#define		IFNAMSIZ	16
#define		IF_NAMESIZE	IFNAMSIZ


/*
 * Structure describing information about an interface
 * which may be of interest to management entities.
 */
struct if_data {
	/* generic interface information */
	u_char			ifi_type;		/* ethernet, tokenring, etc */
	u_char			ifi_physical;	/* e.g., AUI, Thinnet, 10base-T, etc */
	u_char			ifi_addrlen;	/* media address length */
	u_char			ifi_hdrlen;		/* media header length */
	u_char			ifi_recvquota;	/* polling quota for receive intrs */
	u_char			ifi_xmitquota;	/* polling quota for xmit intrs */
	u_char			ifi_do_not_use;	/* pad for ifi_datalen's position */
	u_char			ifi_datalen;	/* length of this data struct */
	u_long			ifi_mtu;		/* maximum transmission unit */
	u_long			ifi_metric;		/* routing metric (external only) */
	u_long			ifi_baudrate;	/* linespeed */
	/* volatile statistics */
	u_long			ifi_ipackets;	/* packets received on interface */
	u_long			ifi_ierrors;	/* input errors on interface */
	u_long			ifi_opackets;	/* packets sent on interface */
	u_long			ifi_oerrors;	/* output errors on interface */
	u_long			ifi_collisions;	/* collisions on csma interfaces */
	u_long			ifi_ibytes;		/* total number of octets received */
	u_long			ifi_obytes;		/* total number of octets sent */
	u_long			ifi_imcasts;	/* packets received via multicast */
	u_long			ifi_omcasts;	/* packets sent via multicast */
	u_long			ifi_iqdrops;	/* dropped on input, this interface */
	u_long			ifi_noproto;	/* destined for unsupported protocol */
	u_long			ifi_hwassist;	/* HW offload capabilities */
	u_long			ifi_unused;		/* XXX was ifi_xmittiming */
	struct timeval	ifi_lastchange;	/* time of last administrative change */
};

#define	IFF_UP			0x1			/* interface is up */
#define	IFF_BROADCAST	0x2			/* broadcast address valid */
#define	IFF_DEBUG		0x4			/* turn on debugging */
#define	IFF_LOOPBACK	0x8			/* is a loopback net */
#define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
#define	IFF_SMART		0x20		/* interface manages own routes */
#define	IFF_RUNNING		0x40		/* resources allocated */
#define	IFF_NOARP		0x80		/* no address resolution protocol */
#define	IFF_PROMISC		0x100		/* receive all packets */
#define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
#define	IFF_OACTIVE		0x400		/* transmission in progress */
#define	IFF_SIMPLEX		0x800		/* can't hear own transmissions */
#define	IFF_LINK0		0x1000		/* per link layer defined bit */
#define	IFF_LINK1		0x2000		/* per link layer defined bit */
#define	IFF_LINK2		0x4000		/* per link layer defined bit */
#define	IFF_ALTPHYS		IFF_LINK2	/* use alternate physical connection */
#define	IFF_MULTICAST	0x8000		/* supports multicast */

/*
 * The following flag(s) ought to go in if_flags, but we cannot change
 * struct ifnet because of binary compatibility, so we store them in
 * if_ipending, which is not used so far.
 * If possible, make sure the value is not conflicting with other
 * IFF flags, so we have an easier time when we want to merge them.
 */
#define	IFF_POLLING		0x10000		/* Interface is in polling mode. */
#define	IFF_PPROMISC	0x20000		/* user-requested promisc mode */
#define	IFF_STATICARP	0x80000		/* static ARP */

/* Capabilities that interfaces can advertise. */
#define IFCAP_RXCSUM		0x0001  /* can offload checksum on RX */
#define IFCAP_TXCSUM		0x0002  /* can offload checksum on TX */
#define IFCAP_NETCONS		0x0004  /* can be a network console */
#define	IFCAP_POLLING		0x0040	/* driver supports polling */

#define IFCAP_HWCSUM		(IFCAP_RXCSUM | IFCAP_TXCSUM)

#define	IFQ_MAXLEN		50
#define	IFNET_SLOWHZ	1		/* granularity is 1 second */


#endif /* !_NET_IF_H_ */
