if.h revision 223735
1109864Sjeff/*-
2165762Sjeff * Copyright (c) 1982, 1986, 1989, 1993
3109864Sjeff *	The Regents of the University of California.  All rights reserved.
4109864Sjeff *
5109864Sjeff * Redistribution and use in source and binary forms, with or without
6109864Sjeff * modification, are permitted provided that the following conditions
7109864Sjeff * are met:
8109864Sjeff * 1. Redistributions of source code must retain the above copyright
9109864Sjeff *    notice, this list of conditions and the following disclaimer.
10109864Sjeff * 2. Redistributions in binary form must reproduce the above copyright
11109864Sjeff *    notice, this list of conditions and the following disclaimer in the
12109864Sjeff *    documentation and/or other materials provided with the distribution.
13109864Sjeff * 4. Neither the name of the University nor the names of its contributors
14109864Sjeff *    may be used to endorse or promote products derived from this software
15109864Sjeff *    without specific prior written permission.
16109864Sjeff *
17109864Sjeff * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18109864Sjeff * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19109864Sjeff * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20109864Sjeff * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21109864Sjeff * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22109864Sjeff * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23109864Sjeff * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24109864Sjeff * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25109864Sjeff * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26109864Sjeff * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27171482Sjeff * SUCH DAMAGE.
28171482Sjeff *
29171482Sjeff *	@(#)if.h	8.1 (Berkeley) 6/10/93
30171482Sjeff * $FreeBSD: head/sys/net/if.h 223735 2011-07-03 12:22:02Z bz $
31171482Sjeff */
32171482Sjeff
33172293Sjeff#ifndef _NET_IF_H_
34171482Sjeff#define	_NET_IF_H_
35171482Sjeff
36171482Sjeff#include <sys/cdefs.h>
37171482Sjeff
38116182Sobrien#ifdef _KERNEL
39191645Sjeff#include <sys/queue.h>
40116182Sobrien#endif
41147565Speter
42179297Sjb#if __BSD_VISIBLE
43147565Speter/*
44134649Sscottl * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
45109864Sjeff * helps userland compatibility.  (struct timeval ifi_lastchange)
46109864Sjeff */
47131929Smarcel#ifndef _KERNEL
48109864Sjeff#include <sys/time.h>
49109864Sjeff#endif
50109864Sjeff
51109864Sjeffstruct ifnet;
52109864Sjeff#endif
53112966Sjeff
54122038Sjeff/*
55109864Sjeff * Length of interface external name, including terminating '\0'.
56235459Srstone * Note: this is the same size as a generic device's external name.
57109864Sjeff */
58109864Sjeff#define		IF_NAMESIZE	16
59109864Sjeff#if __BSD_VISIBLE
60109864Sjeff#define		IFNAMSIZ	IF_NAMESIZE
61139453Sjhb#define		IF_MAXUNIT	0x7fff	/* historical value */
62161599Sdavidxu#endif
63109864Sjeff#if __BSD_VISIBLE
64176735Sjeff
65184439Sivoras/*
66109864Sjeff * Structure used to query names of interface cloners.
67145256Sjkoshy */
68145256Sjkoshy
69145256Sjkoshystruct if_clonereq {
70145256Sjkoshy	int	ifcr_total;		/* total cloners (out) */
71179297Sjb	int	ifcr_count;		/* room for this many in user buffer */
72179297Sjb	char	*ifcr_buffer;		/* buffer for cloner names */
73179297Sjb};
74179297Sjb
75179297Sjb/*
76179297Sjb * Structure describing information about an interface
77109864Sjeff * which may be of interest to management entities.
78121790Sjeff */
79109864Sjeffstruct if_data {
80171482Sjeff	/* generic interface information */
81166137Sjeff	u_char	ifi_type;		/* ethernet, tokenring, etc */
82187679Sjeff	u_char	ifi_physical;		/* e.g., AUI, Thinnet, 10base-T, etc */
83187679Sjeff	u_char	ifi_addrlen;		/* media address length */
84224221Sattilio	u_char	ifi_hdrlen;		/* media header length */
85187357Sjeff	u_char	ifi_link_state;		/* current link state */
86166137Sjeff	u_char	ifi_spare_char1;	/* spare byte */
87171482Sjeff	u_char	ifi_spare_char2;	/* spare byte */
88171482Sjeff	u_char	ifi_datalen;		/* length of this data struct */
89146954Sjeff	u_long	ifi_mtu;		/* maximum transmission unit */
90164936Sjulian	u_long	ifi_metric;		/* routing metric (external only) */
91171482Sjeff	u_long	ifi_baudrate;		/* linespeed */
92171482Sjeff	/* volatile statistics */
93164936Sjulian	u_long	ifi_ipackets;		/* packets received on interface */
94177009Sjeff	u_long	ifi_ierrors;		/* input errors on interface */
95171482Sjeff	u_long	ifi_opackets;		/* packets sent on interface */
96171482Sjeff	u_long	ifi_oerrors;		/* output errors on interface */
97171482Sjeff	u_long	ifi_collisions;		/* collisions on csma interfaces */
98164936Sjulian	u_long	ifi_ibytes;		/* total number of octets received */
99164936Sjulian	u_long	ifi_obytes;		/* total number of octets sent */
100164936Sjulian	u_long	ifi_imcasts;		/* packets received via multicast */
101187357Sjeff	u_long	ifi_omcasts;		/* packets sent via multicast */
102187357Sjeff	u_long	ifi_iqdrops;		/* dropped on input, this interface */
103187357Sjeff	u_long	ifi_noproto;		/* destined for unsupported protocol */
104134791Sjulian	u_long	ifi_hwassist;		/* HW offload capabilities, see IFCAP */
105164936Sjulian	time_t	ifi_epoch;		/* uptime at attach or stat reset */
106166108Sjeff	struct	timeval ifi_lastchange;	/* time of last administrative change */
107166108Sjeff};
108121790Sjeff
109164936Sjulian/*-
110109864Sjeff * Interface flags are of two types: network stack owned flags, and driver
111176735Sjeff * owned flags.  Historically, these values were stored in the same ifnet
112176735Sjeff * flags field, but with the advent of fine-grained locking, they have been
113176735Sjeff * broken out such that the network stack is responsible for synchronizing
114176735Sjeff * the stack-owned fields, and the device driver the device-owned fields.
115109864Sjeff * Both halves can perform lockless reads of the other half's field, subject
116217351Sjhb * to accepting the involved races.
117217410Sjhb *
118217410Sjhb * Both sets of flags come from the same number space, and should not be
119217410Sjhb * permitted to conflict, as they are exposed to user space via a single
120217410Sjhb * field.
121217351Sjhb *
122217410Sjhb * The following symbols identify read and write requirements for fields:
123217410Sjhb *
124228718Savg * (i) if_flags field set by device driver before attach, read-only there
125217410Sjhb *     after.
126217410Sjhb * (n) if_flags field written only by the network stack, read by either the
127217410Sjhb *     stack or driver.
128217410Sjhb * (d) if_drv_flags field written only by the device driver, read by either
129217351Sjhb *     the stack or driver.
130217351Sjhb */
131217351Sjhb#define	IFF_UP		0x1		/* (n) interface is up */
132165762Sjeff#define	IFF_BROADCAST	0x2		/* (i) broadcast address valid */
133111857Sjeff#define	IFF_DEBUG	0x4		/* (n) turn on debugging */
134165762Sjeff#define	IFF_LOOPBACK	0x8		/* (i) is a loopback net */
135165762Sjeff#define	IFF_POINTOPOINT	0x10		/* (i) is a point-to-point link */
136165796Sjeff#define	IFF_SMART	0x20		/* (i) interface manages own routes */
137165762Sjeff#define	IFF_DRV_RUNNING	0x40		/* (d) resources allocated */
138165762Sjeff#define	IFF_NOARP	0x80		/* (n) no address resolution protocol */
139165762Sjeff#define	IFF_PROMISC	0x100		/* (n) receive all packets */
140165762Sjeff#define	IFF_ALLMULTI	0x200		/* (n) receive all multicast packets */
141165762Sjeff#define	IFF_DRV_OACTIVE	0x400		/* (d) tx hardware queue is full */
142165762Sjeff#define	IFF_SIMPLEX	0x800		/* (i) can't hear own transmissions */
143165796Sjeff#define	IFF_LINK0	0x1000		/* per link layer defined bit */
144165762Sjeff#define	IFF_LINK1	0x2000		/* per link layer defined bit */
145165762Sjeff#define	IFF_LINK2	0x4000		/* per link layer defined bit */
146165830Sjeff#define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
147165762Sjeff#define	IFF_MULTICAST	0x8000		/* (i) supports multicast */
148165762Sjeff#define	IFF_CANTCONFIG	0x10000		/* (i) unconfigurable using ioctl(2) */
149165762Sjeff#define	IFF_PPROMISC	0x20000		/* (n) user-requested promisc mode */
150165762Sjeff#define	IFF_MONITOR	0x40000		/* (n) user-requested monitor mode */
151165762Sjeff#define	IFF_STATICARP	0x80000		/* (n) static ARP */
152165762Sjeff#define	IFF_DYING	0x200000	/* (n) interface is winding down */
153165762Sjeff#define	IFF_RENAMING	0x400000	/* (n) interface is being renamed */
154165762Sjeff
155165762Sjeff/*
156116642Sjeff * Old names for driver flags so that user space tools can continue to use
157165762Sjeff * the old (portable) names.
158165762Sjeff */
159109864Sjeff#ifndef _KERNEL
160165762Sjeff#define	IFF_RUNNING	IFF_DRV_RUNNING
161121869Sjeff#define	IFF_OACTIVE	IFF_DRV_OACTIVE
162217351Sjhb#endif
163217351Sjhb
164217237Sjhb/* flags set internally only: */
165165762Sjeff#define	IFF_CANTCHANGE \
166165762Sjeff	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\
167165827Sjeff	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
168165762Sjeff	    IFF_DYING|IFF_CANTCONFIG)
169109864Sjeff
170109864Sjeff/*
171165762Sjeff * Values for if_link_state.
172165762Sjeff */
173165762Sjeff#define	LINK_STATE_UNKNOWN	0	/* link invalid/unknown */
174165762Sjeff#define	LINK_STATE_DOWN		1	/* link is down */
175109864Sjeff#define	LINK_STATE_UP		2	/* link is up */
176110645Sjeff
177110645Sjeff/*
178121868Sjeff * Some convenience macros used for setting ifi_baudrate.
179116365Sjeff * XXX 1000 vs. 1024? --thorpej@netbsd.org
180215102Sattilio */
181109864Sjeff#define	IF_Kbps(x)	((x) * 1000)		/* kilobits/sec. */
182165762Sjeff#define	IF_Mbps(x)	(IF_Kbps((x) * 1000))	/* megabits/sec. */
183165762Sjeff#define	IF_Gbps(x)	(IF_Mbps((x) * 1000))	/* gigabits/sec. */
184116365Sjeff
185116365Sjeff/*
186121126Sjeff * Capabilities that interfaces can advertise.
187111857Sjeff *
188242736Sjeff * struct ifnet.if_capabilities
189242736Sjeff *   contains the optional features & capabilities a particular interface
190242736Sjeff *   supports (not only the driver but also the detected hw revision).
191242736Sjeff *   Capabilities are defined by IFCAP_* below.
192242736Sjeff * struct ifnet.if_capenable
193242736Sjeff *   contains the enabled (either by default or through ifconfig) optional
194239157Smav *   features & capabilities on this interface.
195239157Smav *   Capabilities are defined by IFCAP_* below.
196239157Smav * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above
197109864Sjeff *   contains the enabled optional feature & capabilites that can be used
198165762Sjeff *   individually per packet and are specified in the mbuf pkthdr.csum_flags
199165762Sjeff *   field.  IFCAP_* and CSUM_* do not match one to one and CSUM_* may be
200165762Sjeff *   more detailed or differenciated than IFCAP_*.
201165762Sjeff *   Hwassist features are defined CSUM_* in sys/mbuf.h
202165762Sjeff *
203171482Sjeff * Capabilities that cannot be arbitrarily changed with ifconfig/ioctl
204109864Sjeff * are listed in IFCAP_CANTCHANGE, similar to IFF_CANTCHANGE.
205165762Sjeff * This is not strictly necessary because the common code never
206241844Seadler * changes capabilities, and it is left to the individual driver
207242736Sjeff * to do the right thing. However, having the filter here
208242736Sjeff * avoids replication of the same code in all individual drivers.
209242736Sjeff */
210172345Sjeff#define	IFCAP_RXCSUM		0x00001  /* can offload checksum on RX */
211172345Sjeff#define	IFCAP_TXCSUM		0x00002  /* can offload checksum on TX */
212172345Sjeff#define	IFCAP_NETCONS		0x00004  /* can be a network console */
213172345Sjeff#define	IFCAP_VLAN_MTU		0x00008	/* VLAN-compatible MTU */
214171482Sjeff#define	IFCAP_VLAN_HWTAGGING	0x00010	/* hardware VLAN tag support */
215172345Sjeff#define	IFCAP_JUMBO_MTU		0x00020	/* 9000 byte MTU supported */
216172345Sjeff#define	IFCAP_POLLING		0x00040	/* driver supports polling */
217172345Sjeff#define	IFCAP_VLAN_HWCSUM	0x00080	/* can do IFCAP_HWCSUM on VLANs */
218172345Sjeff#define	IFCAP_TSO4		0x00100	/* can do TCP Segmentation Offload */
219217351Sjhb#define	IFCAP_TSO6		0x00200	/* can do TCP6 Segmentation Offload */
220178277Sjeff#define	IFCAP_LRO		0x00400	/* can do Large Receive Offload */
221232740Smav#define	IFCAP_WOL_UCAST		0x00800	/* wake on any unicast frame */
222109864Sjeff#define	IFCAP_WOL_MCAST		0x01000	/* wake on any multicast frame */
223109864Sjeff#define	IFCAP_WOL_MAGIC		0x02000	/* wake on any Magic Packet */
224171482Sjeff#define	IFCAP_TOE4		0x04000	/* interface can offload TCP */
225171482Sjeff#define	IFCAP_TOE6		0x08000	/* interface can offload TCP6 */
226171482Sjeff#define	IFCAP_VLAN_HWFILTER	0x10000 /* interface hw can filter vlan tag */
227109864Sjeff#define	IFCAP_POLLING_NOCOUNT	0x20000 /* polling ticks cannot be fragmented */
228164936Sjulian#define	IFCAP_VLAN_HWTSO	0x40000 /* can do IFCAP_TSO on VLANs */
229242014Sjimharris#define	IFCAP_LINKSTATE		0x80000 /* the runtime link state is dynamic */
230242014Sjimharris#define	IFCAP_NETMAP		0x100000 /* netmap mode supported/enabled */
231242014Sjimharris
232242014Sjimharris#define IFCAP_HWCSUM	(IFCAP_RXCSUM | IFCAP_TXCSUM)
233242014Sjimharris#define	IFCAP_TSO	(IFCAP_TSO4 | IFCAP_TSO6)
234242402Sattilio#define	IFCAP_WOL	(IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
235176735Sjeff#define	IFCAP_TOE	(IFCAP_TOE4 | IFCAP_TOE6)
236178277Sjeff
237212416Smav#define	IFCAP_CANTCHANGE	(IFCAP_NETMAP)
238176735Sjeff
239177009Sjeff#define	IFQ_MAXLEN	50
240178277Sjeff#define	IFNET_SLOWHZ	1		/* granularity is 1 second */
241178277Sjeff
242177009Sjeff/*
243177009Sjeff * Message format for use in obtaining information about interfaces
244166557Sjeff * from getkerninfo and the routing socket
245166557Sjeff */
246177009Sjeffstruct if_msghdr {
247177009Sjeff	u_short	ifm_msglen;	/* to skip over non-understood messages */
248177009Sjeff	u_char	ifm_version;	/* future binary compatibility */
249187357Sjeff	u_char	ifm_type;	/* message type */
250187357Sjeff	int	ifm_addrs;	/* like rtm_addrs */
251187357Sjeff	int	ifm_flags;	/* value of if_flags */
252187357Sjeff	u_short	ifm_index;	/* index for associated ifp */
253171482Sjeff	struct	if_data ifm_data;/* statistics and other data about if */
254109864Sjeff};
255178277Sjeff
256178277Sjeff/*
257178277Sjeff * Message format for use in obtaining information about interface addresses
258166108Sjeff * from getkerninfo and the routing socket
259123433Sjeff */
260184439Sivorasstruct ifa_msghdr {
261123433Sjeff	u_short	ifam_msglen;	/* to skip over non-understood messages */
262176735Sjeff	u_char	ifam_version;	/* future binary compatibility */
263176735Sjeff	u_char	ifam_type;	/* message type */
264166108Sjeff	int	ifam_addrs;	/* like rtm_addrs */
265123433Sjeff	int	ifam_flags;	/* value of ifa_flags */
266166108Sjeff	u_short	ifam_index;	/* index for associated ifp */
267166108Sjeff	int	ifam_metric;	/* value of ifa_metric */
268171506Sjeff};
269172409Sjeff
270166108Sjeff/*
271171506Sjeff * Message format for use in obtaining information about multicast addresses
272171506Sjeff * from the routing socket
273166108Sjeff */
274166108Sjeffstruct ifma_msghdr {
275165620Sjeff	u_short	ifmam_msglen;	/* to skip over non-understood messages */
276109864Sjeff	u_char	ifmam_version;	/* future binary compatibility */
277164936Sjulian	u_char	ifmam_type;	/* message type */
278172409Sjeff	int	ifmam_addrs;	/* like rtm_addrs */
279172409Sjeff	int	ifmam_flags;	/* value of ifa_flags */
280232207Smav	u_short	ifmam_index;	/* index for associated ifp */
281129982Sjeff};
282164936Sjulian
283164936Sjulian/*
284171713Sjeff * Message format announcing the arrival or departure of a network interface.
285123433Sjeff */
286164936Sjulianstruct if_announcemsghdr {
287129982Sjeff	u_short	ifan_msglen;	/* to skip over non-understood messages */
288170315Sjeff	u_char	ifan_version;	/* future binary compatibility */
289164936Sjulian	u_char	ifan_type;	/* message type */
290164936Sjulian	u_short	ifan_index;	/* index for associated ifp */
291110028Sjeff	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
292109864Sjeff	u_short	ifan_what;	/* what type of announcement */
293171482Sjeff};
294171482Sjeff
295171482Sjeff#define	IFAN_ARRIVAL	0	/* interface arrival */
296171482Sjeff#define	IFAN_DEPARTURE	1	/* interface departure */
297242402Sattilio
298171482Sjeff/*
299163709Sjb * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests
300146954Sjeff */
301163709Sjbstruct ifreq_buffer {
302163709Sjb	size_t	length;
303163709Sjb	void	*buffer;
304232917Smav};
305109864Sjeff
306110267Sjeff/*
307177435Sjeff * Interface request structure used for socket
308164936Sjulian * ioctl's.  All interface ioctl's must have parameter
309177435Sjeff * definitions which begin with ifr_name.  The
310177435Sjeff * remainder may be interface specific.
311177435Sjeff */
312177435Sjeffstruct	ifreq {
313177005Sjeff	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
314164936Sjulian	union {
315165762Sjeff		struct	sockaddr ifru_addr;
316171482Sjeff		struct	sockaddr ifru_dstaddr;
317110267Sjeff		struct	sockaddr ifru_broadaddr;
318176735Sjeff		struct	ifreq_buffer ifru_buffer;
319171482Sjeff		short	ifru_flags[2];
320177435Sjeff		short	ifru_index;
321177435Sjeff		int	ifru_jid;
322177435Sjeff		int	ifru_metric;
323177435Sjeff		int	ifru_mtu;
324172409Sjeff		int	ifru_phys;
325176735Sjeff		int	ifru_media;
326177435Sjeff		caddr_t	ifru_data;
327171482Sjeff		int	ifru_cap[2];
328171713Sjeff		u_int	ifru_fib;
329184439Sivoras	} ifr_ifru;
330184439Sivoras#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
331184439Sivoras#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
332121790Sjeff#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
333110028Sjeff#define	ifr_buffer	ifr_ifru.ifru_buffer	/* user supplied buffer with its length */
334165762Sjeff#define	ifr_flags	ifr_ifru.ifru_flags[0]	/* flags (low 16 bits) */
335177253Srwatson#define	ifr_flagshigh	ifr_ifru.ifru_flags[1]	/* flags (high 16 bits) */
336165762Sjeff#define	ifr_jid		ifr_ifru.ifru_jid	/* jail/vnet */
337165762Sjeff#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
338177253Srwatson#define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
339177253Srwatson#define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
340165762Sjeff#define ifr_media	ifr_ifru.ifru_media	/* physical media */
341235459Srstone#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
342235459Srstone#define	ifr_reqcap	ifr_ifru.ifru_cap[0]	/* requested capabilities */
343260817Savg#define	ifr_curcap	ifr_ifru.ifru_cap[1]	/* current capabilities */
344235459Srstone#define	ifr_index	ifr_ifru.ifru_index	/* interface index */
345260817Savg#define	ifr_fib		ifr_ifru.ifru_fib	/* interface fib */
346235459Srstone};
347260817Savg
348235459Srstone#define	_SIZEOF_ADDR_IFREQ(ifr) \
349260817Savg	((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
350235459Srstone	 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
351260817Savg	  (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
352260817Savg
353235459Srstonestruct ifaliasreq {
354260817Savg	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
355260817Savg	struct	sockaddr ifra_addr;
356260817Savg	struct	sockaddr ifra_broadaddr;
357235459Srstone	struct	sockaddr ifra_mask;
358235459Srstone};
359171482Sjeff
360171482Sjeffstruct ifmediareq {
361171482Sjeff	char	ifm_name[IFNAMSIZ];	/* if name, e.g. "en0" */
362165762Sjeff	int	ifm_current;		/* current media options */
363165762Sjeff	int	ifm_mask;		/* don't care mask */
364165762Sjeff	int	ifm_status;		/* media status */
365165762Sjeff	int	ifm_active;		/* active options */
366177435Sjeff	int	ifm_count;		/* # entries in ifm_ulist array */
367165762Sjeff	int	*ifm_ulist;		/* media words */
368165762Sjeff};
369165762Sjeff
370165762Sjeffstruct  ifdrv {
371165762Sjeff	char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
372165762Sjeff	unsigned long   ifd_cmd;
373165762Sjeff	size_t          ifd_len;
374165762Sjeff	void            *ifd_data;
375165762Sjeff};
376165762Sjeff
377165762Sjeff/*
378177435Sjeff * Structure used to retrieve aux status data from interfaces.
379165762Sjeff * Kernel suppliers to this interface should respect the formatting
380177435Sjeff * needed by ifconfig(8): each line starts with a TAB and ends with
381177435Sjeff * a newline.  The canonical example to copy and paste is in if_tun.c.
382165762Sjeff */
383165762Sjeff
384165762Sjeff#define	IFSTATMAX	800		/* 10 lines of text */
385165762Sjeffstruct ifstat {
386165762Sjeff	char	ifs_name[IFNAMSIZ];	/* if name, e.g. "en0" */
387171482Sjeff	char	ascii[IFSTATMAX + 1];
388171482Sjeff};
389171482Sjeff
390113357Sjeff/*
391164936Sjulian * Structure used in SIOCGIFCONF request.
392110267Sjeff * Used to retrieve interface configuration
393164936Sjulian * for machine (useful for programs which
394112994Sjeff * must know all networks accessible).
395164936Sjulian */
396112994Sjeffstruct	ifconf {
397171713Sjeff	int	ifc_len;		/* size of associated buffer */
398176735Sjeff	union {
399176735Sjeff		caddr_t	ifcu_buf;
400165620Sjeff		struct	ifreq *ifcu_req;
401178277Sjeff	} ifc_ifcu;
402178277Sjeff#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
403171482Sjeff#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
404165766Sjeff};
405178277Sjeff
406178277Sjeff/*
407165762Sjeff * interface groups
408165762Sjeff */
409165762Sjeff
410165762Sjeff#define	IFG_ALL		"all"		/* group contains all interfaces */
411165762Sjeff/* XXX: will we implement this? */
412165762Sjeff#define	IFG_EGRESS	"egress"	/* if(s) default route(s) point to */
413113357Sjeff
414112994Sjeffstruct ifg_req {
415177005Sjeff	union {
416177005Sjeff		char			 ifgrqu_group[IFNAMSIZ];
417177005Sjeff		char			 ifgrqu_member[IFNAMSIZ];
418177005Sjeff	} ifgrq_ifgrqu;
419177005Sjeff#define	ifgrq_group	ifgrq_ifgrqu.ifgrqu_group
420177005Sjeff#define	ifgrq_member	ifgrq_ifgrqu.ifgrqu_member
421177005Sjeff};
422177005Sjeff
423177005Sjeff/*
424177005Sjeff * Used to lookup groups for an interface
425177005Sjeff */
426177005Sjeffstruct ifgroupreq {
427177005Sjeff	char	ifgr_name[IFNAMSIZ];
428177005Sjeff	u_int	ifgr_len;
429177005Sjeff	union {
430177005Sjeff		char	ifgru_group[IFNAMSIZ];
431177005Sjeff		struct	ifg_req *ifgru_groups;
432177005Sjeff	} ifgr_ifgru;
433177005Sjeff#define ifgr_group	ifgr_ifgru.ifgru_group
434177005Sjeff#define ifgr_groups	ifgr_ifgru.ifgru_groups
435177005Sjeff};
436177005Sjeff
437177005Sjeff/*
438177005Sjeff * Structure for SIOC[AGD]LIFADDR
439177005Sjeff */
440217351Sjhbstruct if_laddrreq {
441217351Sjhb	char	iflr_name[IFNAMSIZ];
442177005Sjeff	u_int	flags;
443217351Sjhb#define	IFLR_PREFIX	0x8000  /* in: prefix given  out: kernel fills id */
444177005Sjeff	u_int	prefixlen;         /* in/out */
445177005Sjeff	struct	sockaddr_storage addr;   /* in/out */
446177005Sjeff	struct	sockaddr_storage dstaddr; /* out */
447177005Sjeff};
448171482Sjeff
449171482Sjeff#endif /* __BSD_VISIBLE */
450171482Sjeff
451171482Sjeff#ifdef _KERNEL
452171482Sjeff#ifdef MALLOC_DECLARE
453122744SjeffMALLOC_DECLARE(M_IFADDR);
454177435SjeffMALLOC_DECLARE(M_IFMADDR);
455122744Sjeff#endif
456177435Sjeff#endif
457177042Sjeff
458177042Sjeff#ifndef _KERNEL
459171482Sjeffstruct if_nameindex {
460177435Sjeff	unsigned int	if_index;	/* 1, 2, ... */
461177009Sjeff	char		*if_name;	/* null terminated name: "le0", ... */
462177435Sjeff};
463177435Sjeff
464177435Sjeff__BEGIN_DECLS
465177435Sjeffvoid			 if_freenameindex(struct if_nameindex *);
466165620Sjeffchar			*if_indextoname(unsigned int, char *);
467164936Sjulianstruct if_nameindex	*if_nameindex(void);
468123433Sjeffunsigned int		 if_nametoindex(const char *);
469217351Sjhb__END_DECLS
470177042Sjeff#endif
471217351Sjhb
472177042Sjeff#ifdef _KERNEL
473217351Sjhb/* XXX - this should go away soon. */
474165762Sjeff#include <net/if_var.h>
475165762Sjeff#endif
476165762Sjeff
477165762Sjeff#endif /* !_NET_IF_H_ */
478165762Sjeff