if.h revision 21259
11541Srgrimes/*
21541Srgrimes * Copyright (c) 1982, 1986, 1989, 1993
31541Srgrimes *	The Regents of the University of California.  All rights reserved.
41541Srgrimes *
51541Srgrimes * Redistribution and use in source and binary forms, with or without
61541Srgrimes * modification, are permitted provided that the following conditions
71541Srgrimes * are met:
81541Srgrimes * 1. Redistributions of source code must retain the above copyright
91541Srgrimes *    notice, this list of conditions and the following disclaimer.
101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111541Srgrimes *    notice, this list of conditions and the following disclaimer in the
121541Srgrimes *    documentation and/or other materials provided with the distribution.
131541Srgrimes * 3. All advertising materials mentioning features or use of this software
141541Srgrimes *    must display the following acknowledgement:
151541Srgrimes *	This product includes software developed by the University of
161541Srgrimes *	California, Berkeley and its contributors.
171541Srgrimes * 4. Neither the name of the University nor the names of its contributors
181541Srgrimes *    may be used to endorse or promote products derived from this software
191541Srgrimes *    without specific prior written permission.
201541Srgrimes *
211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
241541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
311541Srgrimes * SUCH DAMAGE.
321541Srgrimes *
331541Srgrimes *	@(#)if.h	8.1 (Berkeley) 6/10/93
3421259Swollman *	$Id: if.h,v 1.41 1996/12/13 21:28:37 wollman Exp $
351541Srgrimes */
361541Srgrimes
372168Spaul#ifndef _NET_IF_H_
384507Sbde#define	_NET_IF_H_
392168Spaul
401541Srgrimes/*
4119079Sfenner * Structure describing information about an interface
4219079Sfenner * which may be of interest to management entities.
4319079Sfenner */
449457Sjoergstruct if_data {
459457Sjoerg	/* generic interface information */
469457Sjoerg	u_char	ifi_type;		/* ethernet, tokenring, etc */
479457Sjoerg	u_char	ifi_physical;		/* e.g., AUI, Thinnet, 10base-T, etc */
489457Sjoerg	u_char	ifi_addrlen;		/* media address length */
499457Sjoerg	u_char	ifi_hdrlen;		/* media header length */
5017352Swollman	u_char	ifi_recvquota;		/* polling quota for receive intrs */
5117352Swollman	u_char	ifi_xmitquota;		/* polling quota for xmit intrs */
529457Sjoerg	u_long	ifi_mtu;		/* maximum transmission unit */
539457Sjoerg	u_long	ifi_metric;		/* routing metric (external only) */
549457Sjoerg	u_long	ifi_baudrate;		/* linespeed */
559457Sjoerg	/* volatile statistics */
569457Sjoerg	u_long	ifi_ipackets;		/* packets received on interface */
579457Sjoerg	u_long	ifi_ierrors;		/* input errors on interface */
589457Sjoerg	u_long	ifi_opackets;		/* packets sent on interface */
599457Sjoerg	u_long	ifi_oerrors;		/* output errors on interface */
609457Sjoerg	u_long	ifi_collisions;		/* collisions on csma interfaces */
619457Sjoerg	u_long	ifi_ibytes;		/* total number of octets received */
629457Sjoerg	u_long	ifi_obytes;		/* total number of octets sent */
639457Sjoerg	u_long	ifi_imcasts;		/* packets received via multicast */
649457Sjoerg	u_long	ifi_omcasts;		/* packets sent via multicast */
659457Sjoerg	u_long	ifi_iqdrops;		/* dropped on input, this interface */
669457Sjoerg	u_long	ifi_noproto;		/* destined for unsupported protocol */
6717352Swollman	u_long	ifi_recvtiming;		/* usec spent receiving when timing */
6817352Swollman	u_long	ifi_xmittiming;		/* usec spent xmitting when timing */
6916287Sgpalmer	struct	timeval ifi_lastchange;	/* time of last administrative change */
709457Sjoerg};
719457Sjoerg
721541Srgrimes#define	IFF_UP		0x1		/* interface is up */
731541Srgrimes#define	IFF_BROADCAST	0x2		/* broadcast address valid */
741541Srgrimes#define	IFF_DEBUG	0x4		/* turn on debugging */
751541Srgrimes#define	IFF_LOOPBACK	0x8		/* is a loopback net */
761541Srgrimes#define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
7711460Swollman/*#define IFF_NOTRAILERS 0x20		 * obsolete: avoid use of trailers */
781541Srgrimes#define	IFF_RUNNING	0x40		/* resources allocated */
791541Srgrimes#define	IFF_NOARP	0x80		/* no address resolution protocol */
801541Srgrimes#define	IFF_PROMISC	0x100		/* receive all packets */
811541Srgrimes#define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
821541Srgrimes#define	IFF_OACTIVE	0x400		/* transmission in progress */
831541Srgrimes#define	IFF_SIMPLEX	0x800		/* can't hear own transmissions */
841541Srgrimes#define	IFF_LINK0	0x1000		/* per link layer defined bit */
851541Srgrimes#define	IFF_LINK1	0x2000		/* per link layer defined bit */
861541Srgrimes#define	IFF_LINK2	0x4000		/* per link layer defined bit */
873274Swollman#define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
881541Srgrimes#define	IFF_MULTICAST	0x8000		/* supports multicast */
891541Srgrimes
901541Srgrimes/* flags set internally only: */
911541Srgrimes#define	IFF_CANTCHANGE \
921541Srgrimes	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
931541Srgrimes	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
941541Srgrimes
951541Srgrimes#define	IFQ_MAXLEN	50
961541Srgrimes#define	IFNET_SLOWHZ	1		/* granularity is 1 second */
971541Srgrimes
981541Srgrimes/*
991541Srgrimes * Message format for use in obtaining information about interfaces
1001541Srgrimes * from getkerninfo and the routing socket
1011541Srgrimes */
1021541Srgrimesstruct if_msghdr {
1031541Srgrimes	u_short	ifm_msglen;	/* to skip over non-understood messages */
1041541Srgrimes	u_char	ifm_version;	/* future binary compatability */
1051541Srgrimes	u_char	ifm_type;	/* message type */
1061541Srgrimes	int	ifm_addrs;	/* like rtm_addrs */
1071541Srgrimes	int	ifm_flags;	/* value of if_flags */
1081541Srgrimes	u_short	ifm_index;	/* index for associated ifp */
1091541Srgrimes	struct	if_data ifm_data;/* statistics and other data about if */
1101541Srgrimes};
1111541Srgrimes
1121541Srgrimes/*
1131541Srgrimes * Message format for use in obtaining information about interface addresses
1141541Srgrimes * from getkerninfo and the routing socket
1151541Srgrimes */
1161541Srgrimesstruct ifa_msghdr {
1171541Srgrimes	u_short	ifam_msglen;	/* to skip over non-understood messages */
1181541Srgrimes	u_char	ifam_version;	/* future binary compatability */
1191541Srgrimes	u_char	ifam_type;	/* message type */
1201541Srgrimes	int	ifam_addrs;	/* like rtm_addrs */
1211541Srgrimes	int	ifam_flags;	/* value of ifa_flags */
1221541Srgrimes	u_short	ifam_index;	/* index for associated ifp */
1231541Srgrimes	int	ifam_metric;	/* value of ifa_metric */
1241541Srgrimes};
1251541Srgrimes
1261541Srgrimes/*
1271541Srgrimes * Interface request structure used for socket
1281541Srgrimes * ioctl's.  All interface ioctl's must have parameter
1291541Srgrimes * definitions which begin with ifr_name.  The
1301541Srgrimes * remainder may be interface specific.
1311541Srgrimes */
1321541Srgrimesstruct	ifreq {
1331541Srgrimes#define	IFNAMSIZ	16
1341541Srgrimes	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
1351541Srgrimes	union {
1361541Srgrimes		struct	sockaddr ifru_addr;
1371541Srgrimes		struct	sockaddr ifru_dstaddr;
1381541Srgrimes		struct	sockaddr ifru_broadaddr;
1391541Srgrimes		short	ifru_flags;
1401541Srgrimes		int	ifru_metric;
1411941Sdg		int	ifru_mtu;
1425184Swollman		int	ifru_phys;
1431541Srgrimes		caddr_t	ifru_data;
1441541Srgrimes	} ifr_ifru;
1451541Srgrimes#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
1461541Srgrimes#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
1471541Srgrimes#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
1481541Srgrimes#define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
1491541Srgrimes#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
1501941Sdg#define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
1515187Sdg#define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
1521541Srgrimes#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
1531541Srgrimes};
1541541Srgrimes
1551541Srgrimesstruct ifaliasreq {
1561541Srgrimes	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
1571541Srgrimes	struct	sockaddr ifra_addr;
1581541Srgrimes	struct	sockaddr ifra_broadaddr;
1591541Srgrimes	struct	sockaddr ifra_mask;
1601541Srgrimes};
1611541Srgrimes
1621541Srgrimes/*
1631541Srgrimes * Structure used in SIOCGIFCONF request.
1641541Srgrimes * Used to retrieve interface configuration
1651541Srgrimes * for machine (useful for programs which
1661541Srgrimes * must know all networks accessible).
1671541Srgrimes */
1681541Srgrimesstruct	ifconf {
1691541Srgrimes	int	ifc_len;		/* size of associated buffer */
1701541Srgrimes	union {
1711541Srgrimes		caddr_t	ifcu_buf;
1721541Srgrimes		struct	ifreq *ifcu_req;
1731541Srgrimes	} ifc_ifcu;
1741541Srgrimes#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
1751541Srgrimes#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
1761541Srgrimes};
1771541Srgrimes
17821259Swollman/* XXX - this should go away soon */
1791541Srgrimes#ifdef KERNEL
18021259Swollman#include <net/if_var.h>
1811541Srgrimes#endif
1821541Srgrimes
1834507Sbde#endif /* !_NET_IF_H_ */
184