if.h revision 174628
1139823Simp/*-
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 * 4. Neither the name of the University nor the names of its contributors
141541Srgrimes *    may be used to endorse or promote products derived from this software
151541Srgrimes *    without specific prior written permission.
161541Srgrimes *
171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
201541Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
271541Srgrimes * SUCH DAMAGE.
281541Srgrimes *
291541Srgrimes *	@(#)if.h	8.1 (Berkeley) 6/10/93
3050477Speter * $FreeBSD: head/sys/net/if.h 174628 2007-12-15 22:06:23Z kmacy $
311541Srgrimes */
321541Srgrimes
332168Spaul#ifndef _NET_IF_H_
344507Sbde#define	_NET_IF_H_
352168Spaul
36104355Smike#include <sys/cdefs.h>
37104355Smike
3897024Siedowse#ifdef _KERNEL
3979103Sbrooks#include <sys/queue.h>
4097024Siedowse#endif
4179103Sbrooks
42104355Smike#if __BSD_VISIBLE
431541Srgrimes/*
4434750Speter * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
4572093Sasmodai * helps userland compatibility.  (struct timeval ifi_lastchange)
4634750Speter */
4755205Speter#ifndef _KERNEL
4834750Speter#include <sys/time.h>
4934750Speter#endif
5034750Speter
5179103Sbrooksstruct ifnet;
52104355Smike#endif
5379103Sbrooks
5434750Speter/*
5579103Sbrooks * Length of interface external name, including terminating '\0'.
5679103Sbrooks * Note: this is the same size as a generic device's external name.
5779103Sbrooks */
58104355Smike#define		IF_NAMESIZE	16
59104355Smike#if __BSD_VISIBLE
60104355Smike#define		IFNAMSIZ	IF_NAMESIZE
61121816Sbrooks#define		IF_MAXUNIT	0x7fff	/* historical value */
62104355Smike#endif
63104355Smike#if __BSD_VISIBLE
64104355Smike
6579103Sbrooks/*
6679103Sbrooks * Structure used to query names of interface cloners.
6779103Sbrooks */
6879103Sbrooks
6979103Sbrooksstruct if_clonereq {
7079103Sbrooks	int	ifcr_total;		/* total cloners (out) */
7179103Sbrooks	int	ifcr_count;		/* room for this many in user buffer */
7279103Sbrooks	char	*ifcr_buffer;		/* buffer for cloner names */
7379103Sbrooks};
7479103Sbrooks
7579103Sbrooks/*
7619079Sfenner * Structure describing information about an interface
7719079Sfenner * which may be of interest to management entities.
7819079Sfenner */
799457Sjoergstruct if_data {
809457Sjoerg	/* generic interface information */
819457Sjoerg	u_char	ifi_type;		/* ethernet, tokenring, etc */
829457Sjoerg	u_char	ifi_physical;		/* e.g., AUI, Thinnet, 10base-T, etc */
839457Sjoerg	u_char	ifi_addrlen;		/* media address length */
849457Sjoerg	u_char	ifi_hdrlen;		/* media header length */
85128871Sandre	u_char	ifi_link_state;		/* current link state */
86169614Sbrooks	u_char	ifi_spare_char1;	/* spare byte */
87169614Sbrooks	u_char	ifi_spare_char2;	/* spare byte */
88134609Sbrooks	u_char	ifi_datalen;		/* length of this data struct */
899457Sjoerg	u_long	ifi_mtu;		/* maximum transmission unit */
909457Sjoerg	u_long	ifi_metric;		/* routing metric (external only) */
919457Sjoerg	u_long	ifi_baudrate;		/* linespeed */
929457Sjoerg	/* volatile statistics */
939457Sjoerg	u_long	ifi_ipackets;		/* packets received on interface */
949457Sjoerg	u_long	ifi_ierrors;		/* input errors on interface */
959457Sjoerg	u_long	ifi_opackets;		/* packets sent on interface */
969457Sjoerg	u_long	ifi_oerrors;		/* output errors on interface */
979457Sjoerg	u_long	ifi_collisions;		/* collisions on csma interfaces */
989457Sjoerg	u_long	ifi_ibytes;		/* total number of octets received */
999457Sjoerg	u_long	ifi_obytes;		/* total number of octets sent */
1009457Sjoerg	u_long	ifi_imcasts;		/* packets received via multicast */
1019457Sjoerg	u_long	ifi_omcasts;		/* packets sent via multicast */
1029457Sjoerg	u_long	ifi_iqdrops;		/* dropped on input, this interface */
1039457Sjoerg	u_long	ifi_noproto;		/* destined for unsupported protocol */
104162070Sandre	u_long	ifi_hwassist;		/* HW offload capabilities, see IFCAP */
105142501Sbrooks	time_t	ifi_epoch;		/* uptime at attach or stat reset */
10616287Sgpalmer	struct	timeval ifi_lastchange;	/* time of last administrative change */
1079457Sjoerg};
1089457Sjoerg
109148894Srwatson/*-
110148886Srwatson * Interface flags are of two types: network stack owned flags, and driver
111148886Srwatson * owned flags.  Historically, these values were stored in the same ifnet
112148886Srwatson * flags field, but with the advent of fine-grained locking, they have been
113148886Srwatson * broken out such that the network stack is responsible for synchronizing
114148886Srwatson * the stack-owned fields, and the device driver the device-owned fields.
115148886Srwatson * Both halves can perform lockless reads of the other half's field, subject
116148886Srwatson * to accepting the involved races.
117148886Srwatson *
118148886Srwatson * Both sets of flags come from the same number space, and should not be
119148886Srwatson * permitted to conflict, as they are exposed to user space via a single
120148886Srwatson * field.
121148886Srwatson *
122148894Srwatson * The following symbols identify read and write requirements for fields:
123148894Srwatson *
124148894Srwatson * (i) if_flags field set by device driver before attach, read-only there
125148894Srwatson *     after.
126148894Srwatson * (n) if_flags field written only by the network stack, read by either the
127148894Srwatson *     stack or driver.
128148894Srwatson * (d) if_drv_flags field written only by the device driver, read by either
129148894Srwatson *     the stack or driver.
130148886Srwatson */
131148894Srwatson#define	IFF_UP		0x1		/* (n) interface is up */
132148894Srwatson#define	IFF_BROADCAST	0x2		/* (i) broadcast address valid */
133148894Srwatson#define	IFF_DEBUG	0x4		/* (n) turn on debugging */
134148894Srwatson#define	IFF_LOOPBACK	0x8		/* (i) is a loopback net */
135148894Srwatson#define	IFF_POINTOPOINT	0x10		/* (i) is a point-to-point link */
136148894Srwatson#define	IFF_SMART	0x20		/* (i) interface manages own routes */
137148894Srwatson#define	IFF_DRV_RUNNING	0x40		/* (d) resources allocated */
138148894Srwatson#define	IFF_NOARP	0x80		/* (n) no address resolution protocol */
139148894Srwatson#define	IFF_PROMISC	0x100		/* (n) receive all packets */
140148894Srwatson#define	IFF_ALLMULTI	0x200		/* (n) receive all multicast packets */
141148894Srwatson#define	IFF_DRV_OACTIVE	0x400		/* (d) tx hardware queue is full */
142148894Srwatson#define	IFF_SIMPLEX	0x800		/* (i) can't hear own transmissions */
1431541Srgrimes#define	IFF_LINK0	0x1000		/* per link layer defined bit */
1441541Srgrimes#define	IFF_LINK1	0x2000		/* per link layer defined bit */
1451541Srgrimes#define	IFF_LINK2	0x4000		/* per link layer defined bit */
1463274Swollman#define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
147148894Srwatson#define	IFF_MULTICAST	0x8000		/* (i) supports multicast */
148150789Sglebius/*			0x10000		*/
149148894Srwatson#define	IFF_PPROMISC	0x20000		/* (n) user-requested promisc mode */
150148894Srwatson#define	IFF_MONITOR	0x40000		/* (n) user-requested monitor mode */
151148894Srwatson#define	IFF_STATICARP	0x80000		/* (n) static ARP */
152148894Srwatson#define	IFF_NEEDSGIANT	0x100000	/* (i) hold Giant over if_start calls */
15387902Sluigi
154148886Srwatson/*
155148886Srwatson * Old names for driver flags so that user space tools can continue to use
156148894Srwatson * the old (portable) names.
157148886Srwatson */
158148886Srwatson#ifndef _KERNEL
159148886Srwatson#define	IFF_RUNNING	IFF_DRV_RUNNING
160148886Srwatson#define	IFF_OACTIVE	IFF_DRV_OACTIVE
161148886Srwatson#endif
162148886Srwatson
1631541Srgrimes/* flags set internally only: */
1641541Srgrimes#define	IFF_CANTCHANGE \
165148886Srwatson	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\
166150789Sglebius	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC)
1671541Srgrimes
168106925Ssam/*
169128871Sandre * Values for if_link_state.
170128871Sandre */
171128871Sandre#define	LINK_STATE_UNKNOWN	0	/* link invalid/unknown */
172128871Sandre#define	LINK_STATE_DOWN		1	/* link is down */
173128871Sandre#define	LINK_STATE_UP		2	/* link is up */
174128871Sandre
175128871Sandre/*
176106925Ssam * Some convenience macros used for setting ifi_baudrate.
177106925Ssam * XXX 1000 vs. 1024? --thorpej@netbsd.org
178106925Ssam */
179106925Ssam#define	IF_Kbps(x)	((x) * 1000)		/* kilobits/sec. */
180106925Ssam#define	IF_Mbps(x)	(IF_Kbps((x) * 1000))	/* megabits/sec. */
181106925Ssam#define	IF_Gbps(x)	(IF_Mbps((x) * 1000))	/* gigabits/sec. */
182106925Ssam
183162070Sandre/*
184162070Sandre * Capabilities that interfaces can advertise.
185162070Sandre *
186162070Sandre * struct ifnet.if_capabilities
187162070Sandre *   contains the optional features & capabilities a particular interface
188162070Sandre *   supports (not only the driver but also the detected hw revision).
189162070Sandre *   Capabilities are defined by IFCAP_* below.
190169207Syar * struct ifnet.if_capenable
191162070Sandre *   contains the enabled (either by default or through ifconfig) optional
192162070Sandre *   features & capabilities on this interface.
193162070Sandre *   Capabilities are defined by IFCAP_* below.
194162070Sandre * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above
195162070Sandre *   contains the enabled optional feature & capabilites that can be used
196162070Sandre *   individually per packet and are specified in the mbuf pkthdr.csum_flags
197162070Sandre *   field.  IFCAP_* and CSUM_* do not match one to one and CSUM_* may be
198169207Syar *   more detailed or differenciated than IFCAP_*.
199162070Sandre *   Hwassist features are defined CSUM_* in sys/mbuf.h
200162070Sandre */
20183636Sjlemon#define IFCAP_RXCSUM		0x0001  /* can offload checksum on RX */
20283636Sjlemon#define IFCAP_TXCSUM		0x0002  /* can offload checksum on TX */
20383636Sjlemon#define IFCAP_NETCONS		0x0004  /* can be a network console */
204106925Ssam#define	IFCAP_VLAN_MTU		0x0008	/* VLAN-compatible MTU */
205106925Ssam#define	IFCAP_VLAN_HWTAGGING	0x0010	/* hardware VLAN tag support */
206106925Ssam#define	IFCAP_JUMBO_MTU		0x0020	/* 9000 byte MTU supported */
207128113Sru#define	IFCAP_POLLING		0x0040	/* driver supports polling */
208155051Sglebius#define	IFCAP_VLAN_HWCSUM	0x0080	/* can do IFCAP_HWCSUM on VLANs */
209162084Sandre#define	IFCAP_TSO4		0x0100	/* can do TCP Segmentation Offload */
210162084Sandre#define	IFCAP_TSO6		0x0200	/* can do TCP6 Segmentation Offload */
211170576Sandre#define	IFCAP_LRO		0x0400	/* can do Large Receive Offload */
212174505Ssam#define	IFCAP_WOL_UCAST		0x0800	/* wake on any unicast frame */
213174505Ssam#define	IFCAP_WOL_MCAST		0x1000	/* wake on any multicast frame */
214174505Ssam#define	IFCAP_WOL_MAGIC		0x2000	/* wake on any Magic Packet */
215174625Skmacy#define	IFCAP_TOE4		0x4000	/* interface can offload TCP */
216174625Skmacy#define	IFCAP_TOE6		0x8000	/* interface can offload TCP6 */
21783624Sjlemon
218174505Ssam#define IFCAP_HWCSUM	(IFCAP_RXCSUM | IFCAP_TXCSUM)
219174505Ssam#define	IFCAP_TSO	(IFCAP_TSO4 | IFCAP_TSO6)
220174505Ssam#define	IFCAP_WOL	(IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
221174628Skmacy#define	IFCAP_TOE	(IFCAP_TOE4 | IFCAP_TOE6)
22283636Sjlemon
2231541Srgrimes#define	IFQ_MAXLEN	50
2241541Srgrimes#define	IFNET_SLOWHZ	1		/* granularity is 1 second */
2251541Srgrimes
2261541Srgrimes/*
2271541Srgrimes * Message format for use in obtaining information about interfaces
2281541Srgrimes * from getkerninfo and the routing socket
2291541Srgrimes */
2301541Srgrimesstruct if_msghdr {
2311541Srgrimes	u_short	ifm_msglen;	/* to skip over non-understood messages */
23272093Sasmodai	u_char	ifm_version;	/* future binary compatibility */
2331541Srgrimes	u_char	ifm_type;	/* message type */
2341541Srgrimes	int	ifm_addrs;	/* like rtm_addrs */
2351541Srgrimes	int	ifm_flags;	/* value of if_flags */
2361541Srgrimes	u_short	ifm_index;	/* index for associated ifp */
2371541Srgrimes	struct	if_data ifm_data;/* statistics and other data about if */
2381541Srgrimes};
2391541Srgrimes
2401541Srgrimes/*
2411541Srgrimes * Message format for use in obtaining information about interface addresses
2421541Srgrimes * from getkerninfo and the routing socket
2431541Srgrimes */
2441541Srgrimesstruct ifa_msghdr {
2451541Srgrimes	u_short	ifam_msglen;	/* to skip over non-understood messages */
24672093Sasmodai	u_char	ifam_version;	/* future binary compatibility */
2471541Srgrimes	u_char	ifam_type;	/* message type */
2481541Srgrimes	int	ifam_addrs;	/* like rtm_addrs */
2491541Srgrimes	int	ifam_flags;	/* value of ifa_flags */
2501541Srgrimes	u_short	ifam_index;	/* index for associated ifp */
2511541Srgrimes	int	ifam_metric;	/* value of ifa_metric */
2521541Srgrimes};
2531541Srgrimes
2541541Srgrimes/*
25521666Swollman * Message format for use in obtaining information about multicast addresses
25621666Swollman * from the routing socket
25721666Swollman */
25821666Swollmanstruct ifma_msghdr {
25921666Swollman	u_short	ifmam_msglen;	/* to skip over non-understood messages */
26072093Sasmodai	u_char	ifmam_version;	/* future binary compatibility */
26121666Swollman	u_char	ifmam_type;	/* message type */
26221666Swollman	int	ifmam_addrs;	/* like rtm_addrs */
26321666Swollman	int	ifmam_flags;	/* value of ifa_flags */
26421666Swollman	u_short	ifmam_index;	/* index for associated ifp */
26521666Swollman};
26621666Swollman
26721666Swollman/*
26889498Sru * Message format announcing the arrival or departure of a network interface.
26989498Sru */
27089498Srustruct if_announcemsghdr {
27189498Sru	u_short	ifan_msglen;	/* to skip over non-understood messages */
27289498Sru	u_char	ifan_version;	/* future binary compatibility */
27389498Sru	u_char	ifan_type;	/* message type */
27489498Sru	u_short	ifan_index;	/* index for associated ifp */
27589498Sru	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
27689498Sru	u_short	ifan_what;	/* what type of announcement */
27789498Sru};
27889498Sru
27989498Sru#define	IFAN_ARRIVAL	0	/* interface arrival */
28089498Sru#define	IFAN_DEPARTURE	1	/* interface departure */
28189498Sru
28289498Sru/*
2831541Srgrimes * Interface request structure used for socket
2841541Srgrimes * ioctl's.  All interface ioctl's must have parameter
2851541Srgrimes * definitions which begin with ifr_name.  The
2861541Srgrimes * remainder may be interface specific.
2871541Srgrimes */
2881541Srgrimesstruct	ifreq {
2891541Srgrimes	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
2901541Srgrimes	union {
2911541Srgrimes		struct	sockaddr ifru_addr;
2921541Srgrimes		struct	sockaddr ifru_dstaddr;
2931541Srgrimes		struct	sockaddr ifru_broadaddr;
29444144Sphk		short	ifru_flags[2];
29585079Sjlemon		short	ifru_index;
2961541Srgrimes		int	ifru_metric;
2971941Sdg		int	ifru_mtu;
2985184Swollman		int	ifru_phys;
29925434Speter		int	ifru_media;
3001541Srgrimes		caddr_t	ifru_data;
30183624Sjlemon		int	ifru_cap[2];
3021541Srgrimes	} ifr_ifru;
3031541Srgrimes#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
3041541Srgrimes#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
3051541Srgrimes#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
306102052Ssobomax#define	ifr_flags	ifr_ifru.ifru_flags[0]	/* flags (low 16 bits) */
307102052Ssobomax#define	ifr_flagshigh	ifr_ifru.ifru_flags[1]	/* flags (high 16 bits) */
3081541Srgrimes#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
3091941Sdg#define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
3105187Sdg#define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
31125434Speter#define ifr_media	ifr_ifru.ifru_media	/* physical media */
3121541Srgrimes#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
31383624Sjlemon#define	ifr_reqcap	ifr_ifru.ifru_cap[0]	/* requested capabilities */
31483624Sjlemon#define	ifr_curcap	ifr_ifru.ifru_cap[1]	/* current capabilities */
31585079Sjlemon#define	ifr_index	ifr_ifru.ifru_index	/* interface index */
3161541Srgrimes};
3171541Srgrimes
31832491Swollman#define	_SIZEOF_ADDR_IFREQ(ifr) \
31932491Swollman	((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
32032491Swollman	 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
32132491Swollman	  (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
32232491Swollman
3231541Srgrimesstruct ifaliasreq {
3241541Srgrimes	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
3251541Srgrimes	struct	sockaddr ifra_addr;
3261541Srgrimes	struct	sockaddr ifra_broadaddr;
3271541Srgrimes	struct	sockaddr ifra_mask;
3281541Srgrimes};
3291541Srgrimes
33025434Speterstruct ifmediareq {
33125434Speter	char	ifm_name[IFNAMSIZ];	/* if name, e.g. "en0" */
33225434Speter	int	ifm_current;		/* current media options */
33325434Speter	int	ifm_mask;		/* don't care mask */
33425434Speter	int	ifm_status;		/* media status */
33525434Speter	int	ifm_active;		/* active options */
33625434Speter	int	ifm_count;		/* # entries in ifm_ulist array */
33725434Speter	int	*ifm_ulist;		/* media words */
33825434Speter};
33948021Sphk
340146986Sthompsastruct  ifdrv {
341146986Sthompsa	char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
342146986Sthompsa	unsigned long   ifd_cmd;
343146986Sthompsa	size_t          ifd_len;
344146986Sthompsa	void            *ifd_data;
345146986Sthompsa};
346146986Sthompsa
34748021Sphk/*
34848021Sphk * Structure used to retrieve aux status data from interfaces.
34948589Sbde * Kernel suppliers to this interface should respect the formatting
35048021Sphk * needed by ifconfig(8): each line starts with a TAB and ends with
35148589Sbde * a newline.  The canonical example to copy and paste is in if_tun.c.
35248021Sphk */
35348021Sphk
35448589Sbde#define	IFSTATMAX	800		/* 10 lines of text */
35548021Sphkstruct ifstat {
35648589Sbde	char	ifs_name[IFNAMSIZ];	/* if name, e.g. "en0" */
35748589Sbde	char	ascii[IFSTATMAX + 1];
35848021Sphk};
35948021Sphk
3601541Srgrimes/*
3611541Srgrimes * Structure used in SIOCGIFCONF request.
3621541Srgrimes * Used to retrieve interface configuration
3631541Srgrimes * for machine (useful for programs which
3641541Srgrimes * must know all networks accessible).
3651541Srgrimes */
3661541Srgrimesstruct	ifconf {
3671541Srgrimes	int	ifc_len;		/* size of associated buffer */
3681541Srgrimes	union {
3691541Srgrimes		caddr_t	ifcu_buf;
3701541Srgrimes		struct	ifreq *ifcu_req;
3711541Srgrimes	} ifc_ifcu;
3721541Srgrimes#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
3731541Srgrimes#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
3741541Srgrimes};
3751541Srgrimes
376155224Sps#if defined (__amd64__) || defined (COMPAT_32BIT)
377155224Spsstruct ifconf32 {
378155224Sps	int	ifc_len;		/* size of associated buffer */
379155224Sps	union {
380155224Sps		u_int	ifcu_buf;
381155224Sps		u_int	ifcu_req;
382155224Sps	} ifc_ifcu;
383155224Sps};
384155224Sps#endif
38552904Sshin
38652904Sshin/*
387159781Smlaier * interface groups
388159781Smlaier */
389159781Smlaier
390159781Smlaier#define	IFG_ALL		"all"		/* group contains all interfaces */
391159781Smlaier/* XXX: will we implement this? */
392159781Smlaier#define	IFG_EGRESS	"egress"	/* if(s) default route(s) point to */
393159781Smlaier
394159781Smlaierstruct ifg_req {
395159781Smlaier	union {
396159781Smlaier		char			 ifgrqu_group[IFNAMSIZ];
397159781Smlaier		char			 ifgrqu_member[IFNAMSIZ];
398159781Smlaier	} ifgrq_ifgrqu;
399159781Smlaier#define	ifgrq_group	ifgrq_ifgrqu.ifgrqu_group
400159781Smlaier#define	ifgrq_member	ifgrq_ifgrqu.ifgrqu_member
401159781Smlaier};
402159781Smlaier
403159781Smlaier/*
404159781Smlaier * Used to lookup groups for an interface
405159781Smlaier */
406159781Smlaierstruct ifgroupreq {
407159781Smlaier	char	ifgr_name[IFNAMSIZ];
408159781Smlaier	u_int	ifgr_len;
409159781Smlaier	union {
410159781Smlaier		char	ifgru_group[IFNAMSIZ];
411159781Smlaier		struct	ifg_req *ifgru_groups;
412159781Smlaier	} ifgr_ifgru;
413159781Smlaier#define ifgr_group	ifgr_ifgru.ifgru_group
414159781Smlaier#define ifgr_groups	ifgr_ifgru.ifgru_groups
415159781Smlaier};
416159781Smlaier
417159781Smlaier/*
41852904Sshin * Structure for SIOC[AGD]LIFADDR
41952904Sshin */
42052904Sshinstruct if_laddrreq {
42152904Sshin	char	iflr_name[IFNAMSIZ];
42252904Sshin	u_int	flags;
42352904Sshin#define	IFLR_PREFIX	0x8000  /* in: prefix given  out: kernel fills id */
42452904Sshin	u_int	prefixlen;         /* in/out */
42552904Sshin	struct	sockaddr_storage addr;   /* in/out */
42652904Sshin	struct	sockaddr_storage dstaddr; /* out */
42752904Sshin};
42852904Sshin
429104355Smike#endif /* __BSD_VISIBLE */
430104355Smike
43155205Speter#ifdef _KERNEL
43230354Sphk#ifdef MALLOC_DECLARE
43330354SphkMALLOC_DECLARE(M_IFADDR);
43430354SphkMALLOC_DECLARE(M_IFMADDR);
43530354Sphk#endif
43630354Sphk#endif
43730354Sphk
43855205Speter#ifndef _KERNEL
43952904Sshinstruct if_nameindex {
440104355Smike	unsigned int	if_index;	/* 1, 2, ... */
441104360Smike	char		*if_name;	/* null terminated name: "le0", ... */
44252904Sshin};
44352904Sshin
44452904Sshin__BEGIN_DECLS
445104360Smikevoid			 if_freenameindex(struct if_nameindex *);
446104360Smikechar			*if_indextoname(unsigned int, char *);
447104360Smikestruct if_nameindex	*if_nameindex(void);
448104360Smikeunsigned int		 if_nametoindex(const char *);
44952904Sshin__END_DECLS
45052904Sshin#endif
45152904Sshin
45255205Speter#ifdef _KERNEL
45383366Sjulianstruct thread;
45448589Sbde
45548589Sbde/* XXX - this should go away soon. */
45621259Swollman#include <net/if_var.h>
4571541Srgrimes#endif
4581541Srgrimes
4594507Sbde#endif /* !_NET_IF_H_ */
460