xref: /freebsd/sys/net/if.h (revision 9bf40ede4a299f315bc4b0ae5329631b8c7dc271)
1df8bae1dSRodney W. Grimes /*
2df8bae1dSRodney W. Grimes  * Copyright (c) 1982, 1986, 1989, 1993
3df8bae1dSRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
4df8bae1dSRodney W. Grimes  *
5df8bae1dSRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
6df8bae1dSRodney W. Grimes  * modification, are permitted provided that the following conditions
7df8bae1dSRodney W. Grimes  * are met:
8df8bae1dSRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
9df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
10df8bae1dSRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
11df8bae1dSRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
12df8bae1dSRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
13df8bae1dSRodney W. Grimes  * 3. All advertising materials mentioning features or use of this software
14df8bae1dSRodney W. Grimes  *    must display the following acknowledgement:
15df8bae1dSRodney W. Grimes  *	This product includes software developed by the University of
16df8bae1dSRodney W. Grimes  *	California, Berkeley and its contributors.
17df8bae1dSRodney W. Grimes  * 4. Neither the name of the University nor the names of its contributors
18df8bae1dSRodney W. Grimes  *    may be used to endorse or promote products derived from this software
19df8bae1dSRodney W. Grimes  *    without specific prior written permission.
20df8bae1dSRodney W. Grimes  *
21df8bae1dSRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22df8bae1dSRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23df8bae1dSRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24df8bae1dSRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25df8bae1dSRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26df8bae1dSRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27df8bae1dSRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28df8bae1dSRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29df8bae1dSRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30df8bae1dSRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31df8bae1dSRodney W. Grimes  * SUCH DAMAGE.
32df8bae1dSRodney W. Grimes  *
33df8bae1dSRodney W. Grimes  *	@(#)if.h	8.1 (Berkeley) 6/10/93
34c3aac50fSPeter Wemm  * $FreeBSD$
35df8bae1dSRodney W. Grimes  */
36df8bae1dSRodney W. Grimes 
37cea1da3bSPaul Richards #ifndef _NET_IF_H_
38cea1da3bSPaul Richards #define	_NET_IF_H_
39cea1da3bSPaul Richards 
40f2ba8326SMike Barcroft #include <sys/cdefs.h>
41f2ba8326SMike Barcroft 
42d497e878SIan Dowse #ifdef _KERNEL
4330aad87dSBrooks Davis #include <sys/queue.h>
44d497e878SIan Dowse #endif
4530aad87dSBrooks Davis 
46f2ba8326SMike Barcroft #if __BSD_VISIBLE
47df8bae1dSRodney W. Grimes /*
4809410d0fSPeter Wemm  * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
492fa72ea7SJeroen Ruigrok van der Werven  * helps userland compatibility.  (struct timeval ifi_lastchange)
5009410d0fSPeter Wemm  */
51664a31e4SPeter Wemm #ifndef _KERNEL
5209410d0fSPeter Wemm #include <sys/time.h>
5309410d0fSPeter Wemm #endif
5409410d0fSPeter Wemm 
5530aad87dSBrooks Davis struct ifnet;
56f2ba8326SMike Barcroft #endif
5730aad87dSBrooks Davis 
5830aad87dSBrooks Davis /*
5930aad87dSBrooks Davis  * Length of interface external name, including terminating '\0'.
6030aad87dSBrooks Davis  * Note: this is the same size as a generic device's external name.
6130aad87dSBrooks Davis  */
62f2ba8326SMike Barcroft #define		IF_NAMESIZE	16
63f2ba8326SMike Barcroft #if __BSD_VISIBLE
64f2ba8326SMike Barcroft #define		IFNAMSIZ	IF_NAMESIZE
659bf40edeSBrooks Davis #define		IF_MAXUNIT	0x7fff	/* historical value */
66f2ba8326SMike Barcroft #endif
6730aad87dSBrooks Davis 
68d497e878SIan Dowse #ifdef _KERNEL
6930aad87dSBrooks Davis /*
7030aad87dSBrooks Davis  * Structure describing a `cloning' interface.
7130aad87dSBrooks Davis  */
7230aad87dSBrooks Davis struct if_clone {
7330aad87dSBrooks Davis 	LIST_ENTRY(if_clone) ifc_list;	/* on list of cloners */
7430aad87dSBrooks Davis 	const char *ifc_name;		/* name of device, e.g. `gif' */
7530aad87dSBrooks Davis 	size_t ifc_namelen;		/* length of name */
76ae5a19beSBrooks Davis 	int ifc_minifs;			/* minimum number of interfaces */
773b16e7b2SMaxime Henrion 	int ifc_maxunit;		/* maximum unit number */
783b16e7b2SMaxime Henrion 	unsigned char *ifc_units;	/* bitmap to handle units */
793b16e7b2SMaxime Henrion 	int ifc_bmlen;			/* bitmap length */
8030aad87dSBrooks Davis 
813b16e7b2SMaxime Henrion 	int	(*ifc_create)(struct if_clone *, int);
82ae5a19beSBrooks Davis 	void	(*ifc_destroy)(struct ifnet *);
8330aad87dSBrooks Davis };
8430aad87dSBrooks Davis 
85ae5a19beSBrooks Davis #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit)	\
86ae5a19beSBrooks Davis     { { 0 }, name, sizeof(name) - 1, minifs, maxunit, NULL, 0, create, destroy }
87d497e878SIan Dowse #endif
8830aad87dSBrooks Davis 
89f2ba8326SMike Barcroft #if __BSD_VISIBLE
90f2ba8326SMike Barcroft 
9130aad87dSBrooks Davis /*
9230aad87dSBrooks Davis  * Structure used to query names of interface cloners.
9330aad87dSBrooks Davis  */
9430aad87dSBrooks Davis 
9530aad87dSBrooks Davis struct if_clonereq {
9630aad87dSBrooks Davis 	int	ifcr_total;		/* total cloners (out) */
9730aad87dSBrooks Davis 	int	ifcr_count;		/* room for this many in user buffer */
9830aad87dSBrooks Davis 	char	*ifcr_buffer;		/* buffer for cloner names */
9930aad87dSBrooks Davis };
10030aad87dSBrooks Davis 
10109410d0fSPeter Wemm /*
102a73356a1SBill Fenner  * Structure describing information about an interface
103a73356a1SBill Fenner  * which may be of interest to management entities.
104a73356a1SBill Fenner  */
105df8bae1dSRodney W. Grimes struct if_data {
106df8bae1dSRodney W. Grimes 	/* generic interface information */
107df8bae1dSRodney W. Grimes 	u_char	ifi_type;		/* ethernet, tokenring, etc */
108995add1aSGarrett Wollman 	u_char	ifi_physical;		/* e.g., AUI, Thinnet, 10base-T, etc */
109df8bae1dSRodney W. Grimes 	u_char	ifi_addrlen;		/* media address length */
110df8bae1dSRodney W. Grimes 	u_char	ifi_hdrlen;		/* media header length */
111bbd17bf8SGarrett Wollman 	u_char	ifi_recvquota;		/* polling quota for receive intrs */
112bbd17bf8SGarrett Wollman 	u_char	ifi_xmitquota;		/* polling quota for xmit intrs */
113df8bae1dSRodney W. Grimes 	u_long	ifi_mtu;		/* maximum transmission unit */
114df8bae1dSRodney W. Grimes 	u_long	ifi_metric;		/* routing metric (external only) */
115df8bae1dSRodney W. Grimes 	u_long	ifi_baudrate;		/* linespeed */
116df8bae1dSRodney W. Grimes 	/* volatile statistics */
117df8bae1dSRodney W. Grimes 	u_long	ifi_ipackets;		/* packets received on interface */
118df8bae1dSRodney W. Grimes 	u_long	ifi_ierrors;		/* input errors on interface */
119df8bae1dSRodney W. Grimes 	u_long	ifi_opackets;		/* packets sent on interface */
120df8bae1dSRodney W. Grimes 	u_long	ifi_oerrors;		/* output errors on interface */
121df8bae1dSRodney W. Grimes 	u_long	ifi_collisions;		/* collisions on csma interfaces */
122df8bae1dSRodney W. Grimes 	u_long	ifi_ibytes;		/* total number of octets received */
123df8bae1dSRodney W. Grimes 	u_long	ifi_obytes;		/* total number of octets sent */
124df8bae1dSRodney W. Grimes 	u_long	ifi_imcasts;		/* packets received via multicast */
125df8bae1dSRodney W. Grimes 	u_long	ifi_omcasts;		/* packets sent via multicast */
126df8bae1dSRodney W. Grimes 	u_long	ifi_iqdrops;		/* dropped on input, this interface */
127df8bae1dSRodney W. Grimes 	u_long	ifi_noproto;		/* destined for unsupported protocol */
128db4f9cc7SJonathan Lemon 	u_long	ifi_hwassist;		/* HW offload capabilities */
129db4f9cc7SJonathan Lemon 	u_long	ifi_unused;		/* XXX was ifi_xmittiming */
130e39a0280SGary Palmer 	struct	timeval ifi_lastchange;	/* time of last administrative change */
1316f64074eSJoerg Wunsch };
1326f64074eSJoerg Wunsch 
133df8bae1dSRodney W. Grimes #define	IFF_UP		0x1		/* interface is up */
134df8bae1dSRodney W. Grimes #define	IFF_BROADCAST	0x2		/* broadcast address valid */
135df8bae1dSRodney W. Grimes #define	IFF_DEBUG	0x4		/* turn on debugging */
136df8bae1dSRodney W. Grimes #define	IFF_LOOPBACK	0x8		/* is a loopback net */
137df8bae1dSRodney W. Grimes #define	IFF_POINTOPOINT	0x10		/* interface is point-to-point link */
138cf4b9371SPoul-Henning Kamp #define	IFF_SMART	0x20		/* interface manages own routes */
139df8bae1dSRodney W. Grimes #define	IFF_RUNNING	0x40		/* resources allocated */
140df8bae1dSRodney W. Grimes #define	IFF_NOARP	0x80		/* no address resolution protocol */
141df8bae1dSRodney W. Grimes #define	IFF_PROMISC	0x100		/* receive all packets */
142df8bae1dSRodney W. Grimes #define	IFF_ALLMULTI	0x200		/* receive all multicast packets */
143df8bae1dSRodney W. Grimes #define	IFF_OACTIVE	0x400		/* transmission in progress */
144df8bae1dSRodney W. Grimes #define	IFF_SIMPLEX	0x800		/* can't hear own transmissions */
145df8bae1dSRodney W. Grimes #define	IFF_LINK0	0x1000		/* per link layer defined bit */
146df8bae1dSRodney W. Grimes #define	IFF_LINK1	0x2000		/* per link layer defined bit */
147df8bae1dSRodney W. Grimes #define	IFF_LINK2	0x4000		/* per link layer defined bit */
14837be1da8SGarrett Wollman #define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
149df8bae1dSRodney W. Grimes #define	IFF_MULTICAST	0x8000		/* supports multicast */
150e4fc250cSLuigi Rizzo #define	IFF_POLLING	0x10000		/* Interface is in polling mode. */
151ffb079beSMaxim Sobolev #define	IFF_PPROMISC	0x20000		/* user-requested promisc mode */
152afbe3a0fSPoul-Henning Kamp #define	IFF_MONITOR	0x40000		/* user-requested monitor mode */
153deb62e28SRuslan Ermilov #define	IFF_STATICARP	0x80000		/* static ARP */
154e4fc250cSLuigi Rizzo 
155df8bae1dSRodney W. Grimes /* flags set internally only: */
156df8bae1dSRodney W. Grimes #define	IFF_CANTCHANGE \
157df8bae1dSRodney W. Grimes 	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
1589717c34cSMaxim Sobolev 	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_SMART|IFF_PROMISC|\
1599717c34cSMaxim Sobolev 	    IFF_POLLING)
160df8bae1dSRodney W. Grimes 
161bb68f0afSSam Leffler /*
162bb68f0afSSam Leffler  * Some convenience macros used for setting ifi_baudrate.
163bb68f0afSSam Leffler  * XXX 1000 vs. 1024? --thorpej@netbsd.org
164bb68f0afSSam Leffler  */
165bb68f0afSSam Leffler #define	IF_Kbps(x)	((x) * 1000)		/* kilobits/sec. */
166bb68f0afSSam Leffler #define	IF_Mbps(x)	(IF_Kbps((x) * 1000))	/* megabits/sec. */
167bb68f0afSSam Leffler #define	IF_Gbps(x)	(IF_Mbps((x) * 1000))	/* gigabits/sec. */
168bb68f0afSSam Leffler 
169016da741SJonathan Lemon /* Capabilities that interfaces can advertise. */
170f7d86692SJonathan Lemon #define IFCAP_RXCSUM		0x0001  /* can offload checksum on RX */
171f7d86692SJonathan Lemon #define IFCAP_TXCSUM		0x0002  /* can offload checksum on TX */
172f7d86692SJonathan Lemon #define IFCAP_NETCONS		0x0004  /* can be a network console */
173bb68f0afSSam Leffler #define	IFCAP_VLAN_MTU		0x0008	/* VLAN-compatible MTU */
174bb68f0afSSam Leffler #define	IFCAP_VLAN_HWTAGGING	0x0010	/* hardware VLAN tag support */
175bb68f0afSSam Leffler #define	IFCAP_JUMBO_MTU		0x0020	/* 9000 byte MTU supported */
176f7d86692SJonathan Lemon 
177f7d86692SJonathan Lemon #define IFCAP_HWCSUM		(IFCAP_RXCSUM | IFCAP_TXCSUM)
178016da741SJonathan Lemon 
179df8bae1dSRodney W. Grimes #define	IFQ_MAXLEN	50
180df8bae1dSRodney W. Grimes #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
181df8bae1dSRodney W. Grimes 
182df8bae1dSRodney W. Grimes /*
183df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interfaces
184df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
185df8bae1dSRodney W. Grimes  */
186df8bae1dSRodney W. Grimes struct if_msghdr {
187df8bae1dSRodney W. Grimes 	u_short	ifm_msglen;	/* to skip over non-understood messages */
1882fa72ea7SJeroen Ruigrok van der Werven 	u_char	ifm_version;	/* future binary compatibility */
189df8bae1dSRodney W. Grimes 	u_char	ifm_type;	/* message type */
190df8bae1dSRodney W. Grimes 	int	ifm_addrs;	/* like rtm_addrs */
191df8bae1dSRodney W. Grimes 	int	ifm_flags;	/* value of if_flags */
192df8bae1dSRodney W. Grimes 	u_short	ifm_index;	/* index for associated ifp */
193df8bae1dSRodney W. Grimes 	struct	if_data ifm_data;/* statistics and other data about if */
194df8bae1dSRodney W. Grimes };
195df8bae1dSRodney W. Grimes 
196df8bae1dSRodney W. Grimes /*
197df8bae1dSRodney W. Grimes  * Message format for use in obtaining information about interface addresses
198df8bae1dSRodney W. Grimes  * from getkerninfo and the routing socket
199df8bae1dSRodney W. Grimes  */
200df8bae1dSRodney W. Grimes struct ifa_msghdr {
201df8bae1dSRodney W. Grimes 	u_short	ifam_msglen;	/* to skip over non-understood messages */
2022fa72ea7SJeroen Ruigrok van der Werven 	u_char	ifam_version;	/* future binary compatibility */
203df8bae1dSRodney W. Grimes 	u_char	ifam_type;	/* message type */
204df8bae1dSRodney W. Grimes 	int	ifam_addrs;	/* like rtm_addrs */
205df8bae1dSRodney W. Grimes 	int	ifam_flags;	/* value of ifa_flags */
206df8bae1dSRodney W. Grimes 	u_short	ifam_index;	/* index for associated ifp */
207df8bae1dSRodney W. Grimes 	int	ifam_metric;	/* value of ifa_metric */
208df8bae1dSRodney W. Grimes };
209df8bae1dSRodney W. Grimes 
210df8bae1dSRodney W. Grimes /*
211477180fbSGarrett Wollman  * Message format for use in obtaining information about multicast addresses
212477180fbSGarrett Wollman  * from the routing socket
213477180fbSGarrett Wollman  */
214477180fbSGarrett Wollman struct ifma_msghdr {
215477180fbSGarrett Wollman 	u_short	ifmam_msglen;	/* to skip over non-understood messages */
2162fa72ea7SJeroen Ruigrok van der Werven 	u_char	ifmam_version;	/* future binary compatibility */
217477180fbSGarrett Wollman 	u_char	ifmam_type;	/* message type */
218477180fbSGarrett Wollman 	int	ifmam_addrs;	/* like rtm_addrs */
219477180fbSGarrett Wollman 	int	ifmam_flags;	/* value of ifa_flags */
220477180fbSGarrett Wollman 	u_short	ifmam_index;	/* index for associated ifp */
221477180fbSGarrett Wollman };
222477180fbSGarrett Wollman 
223477180fbSGarrett Wollman /*
2247b6edd04SRuslan Ermilov  * Message format announcing the arrival or departure of a network interface.
2257b6edd04SRuslan Ermilov  */
2267b6edd04SRuslan Ermilov struct if_announcemsghdr {
2277b6edd04SRuslan Ermilov 	u_short	ifan_msglen;	/* to skip over non-understood messages */
2287b6edd04SRuslan Ermilov 	u_char	ifan_version;	/* future binary compatibility */
2297b6edd04SRuslan Ermilov 	u_char	ifan_type;	/* message type */
2307b6edd04SRuslan Ermilov 	u_short	ifan_index;	/* index for associated ifp */
2317b6edd04SRuslan Ermilov 	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
2327b6edd04SRuslan Ermilov 	u_short	ifan_what;	/* what type of announcement */
2337b6edd04SRuslan Ermilov };
2347b6edd04SRuslan Ermilov 
2357b6edd04SRuslan Ermilov #define	IFAN_ARRIVAL	0	/* interface arrival */
2367b6edd04SRuslan Ermilov #define	IFAN_DEPARTURE	1	/* interface departure */
2377b6edd04SRuslan Ermilov 
2387b6edd04SRuslan Ermilov /*
239df8bae1dSRodney W. Grimes  * Interface request structure used for socket
240df8bae1dSRodney W. Grimes  * ioctl's.  All interface ioctl's must have parameter
241df8bae1dSRodney W. Grimes  * definitions which begin with ifr_name.  The
242df8bae1dSRodney W. Grimes  * remainder may be interface specific.
243df8bae1dSRodney W. Grimes  */
244df8bae1dSRodney W. Grimes struct	ifreq {
245df8bae1dSRodney W. Grimes 	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
246df8bae1dSRodney W. Grimes 	union {
247df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_addr;
248df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_dstaddr;
249df8bae1dSRodney W. Grimes 		struct	sockaddr ifru_broadaddr;
2504add131eSPoul-Henning Kamp 		short	ifru_flags[2];
251de593450SJonathan Lemon 		short	ifru_index;
252df8bae1dSRodney W. Grimes 		int	ifru_metric;
253a7028af7SDavid Greenman 		int	ifru_mtu;
254074c4a4eSGarrett Wollman 		int	ifru_phys;
255a912e453SPeter Wemm 		int	ifru_media;
256df8bae1dSRodney W. Grimes 		caddr_t	ifru_data;
257016da741SJonathan Lemon 		int	ifru_cap[2];
258df8bae1dSRodney W. Grimes 	} ifr_ifru;
259df8bae1dSRodney W. Grimes #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
260df8bae1dSRodney W. Grimes #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
261df8bae1dSRodney W. Grimes #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
26262f76486SMaxim Sobolev #define	ifr_flags	ifr_ifru.ifru_flags[0]	/* flags (low 16 bits) */
26362f76486SMaxim Sobolev #define	ifr_flagshigh	ifr_ifru.ifru_flags[1]	/* flags (high 16 bits) */
264df8bae1dSRodney W. Grimes #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
265a7028af7SDavid Greenman #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
266511cdd16SDavid Greenman #define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
267a912e453SPeter Wemm #define ifr_media	ifr_ifru.ifru_media	/* physical media */
268df8bae1dSRodney W. Grimes #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
269016da741SJonathan Lemon #define	ifr_reqcap	ifr_ifru.ifru_cap[0]	/* requested capabilities */
270016da741SJonathan Lemon #define	ifr_curcap	ifr_ifru.ifru_cap[1]	/* current capabilities */
271de593450SJonathan Lemon #define	ifr_index	ifr_ifru.ifru_index	/* interface index */
272df8bae1dSRodney W. Grimes };
273df8bae1dSRodney W. Grimes 
274906f09bcSGarrett Wollman #define	_SIZEOF_ADDR_IFREQ(ifr) \
275906f09bcSGarrett Wollman 	((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
276906f09bcSGarrett Wollman 	 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
277906f09bcSGarrett Wollman 	  (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
278906f09bcSGarrett Wollman 
279df8bae1dSRodney W. Grimes struct ifaliasreq {
280df8bae1dSRodney W. Grimes 	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
281df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_addr;
282df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_broadaddr;
283df8bae1dSRodney W. Grimes 	struct	sockaddr ifra_mask;
284df8bae1dSRodney W. Grimes };
285df8bae1dSRodney W. Grimes 
286a912e453SPeter Wemm struct ifmediareq {
287a912e453SPeter Wemm 	char	ifm_name[IFNAMSIZ];	/* if name, e.g. "en0" */
288a912e453SPeter Wemm 	int	ifm_current;		/* current media options */
289a912e453SPeter Wemm 	int	ifm_mask;		/* don't care mask */
290a912e453SPeter Wemm 	int	ifm_status;		/* media status */
291a912e453SPeter Wemm 	int	ifm_active;		/* active options */
292a912e453SPeter Wemm 	int	ifm_count;		/* # entries in ifm_ulist array */
293a912e453SPeter Wemm 	int	*ifm_ulist;		/* media words */
294a912e453SPeter Wemm };
295413dd0baSPoul-Henning Kamp 
296413dd0baSPoul-Henning Kamp /*
297413dd0baSPoul-Henning Kamp  * Structure used to retrieve aux status data from interfaces.
298712020a1SBruce Evans  * Kernel suppliers to this interface should respect the formatting
299413dd0baSPoul-Henning Kamp  * needed by ifconfig(8): each line starts with a TAB and ends with
300712020a1SBruce Evans  * a newline.  The canonical example to copy and paste is in if_tun.c.
301413dd0baSPoul-Henning Kamp  */
302413dd0baSPoul-Henning Kamp 
303413dd0baSPoul-Henning Kamp #define	IFSTATMAX	800		/* 10 lines of text */
304413dd0baSPoul-Henning Kamp struct ifstat {
305413dd0baSPoul-Henning Kamp 	char	ifs_name[IFNAMSIZ];	/* if name, e.g. "en0" */
306413dd0baSPoul-Henning Kamp 	char	ascii[IFSTATMAX + 1];
307413dd0baSPoul-Henning Kamp };
308413dd0baSPoul-Henning Kamp 
309df8bae1dSRodney W. Grimes /*
310df8bae1dSRodney W. Grimes  * Structure used in SIOCGIFCONF request.
311df8bae1dSRodney W. Grimes  * Used to retrieve interface configuration
312df8bae1dSRodney W. Grimes  * for machine (useful for programs which
313df8bae1dSRodney W. Grimes  * must know all networks accessible).
314df8bae1dSRodney W. Grimes  */
315df8bae1dSRodney W. Grimes struct	ifconf {
316df8bae1dSRodney W. Grimes 	int	ifc_len;		/* size of associated buffer */
317df8bae1dSRodney W. Grimes 	union {
318df8bae1dSRodney W. Grimes 		caddr_t	ifcu_buf;
319df8bae1dSRodney W. Grimes 		struct	ifreq *ifcu_req;
320df8bae1dSRodney W. Grimes 	} ifc_ifcu;
321df8bae1dSRodney W. Grimes #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
322df8bae1dSRodney W. Grimes #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
323df8bae1dSRodney W. Grimes };
324df8bae1dSRodney W. Grimes 
32576429de4SYoshinobu Inoue 
32676429de4SYoshinobu Inoue /*
32776429de4SYoshinobu Inoue  * Structure for SIOC[AGD]LIFADDR
32876429de4SYoshinobu Inoue  */
32976429de4SYoshinobu Inoue struct if_laddrreq {
33076429de4SYoshinobu Inoue 	char	iflr_name[IFNAMSIZ];
33176429de4SYoshinobu Inoue 	u_int	flags;
33276429de4SYoshinobu Inoue #define	IFLR_PREFIX	0x8000  /* in: prefix given  out: kernel fills id */
33376429de4SYoshinobu Inoue 	u_int	prefixlen;         /* in/out */
33476429de4SYoshinobu Inoue 	struct	sockaddr_storage addr;   /* in/out */
33576429de4SYoshinobu Inoue 	struct	sockaddr_storage dstaddr; /* out */
33676429de4SYoshinobu Inoue };
33776429de4SYoshinobu Inoue 
338f2ba8326SMike Barcroft #endif /* __BSD_VISIBLE */
339f2ba8326SMike Barcroft 
340664a31e4SPeter Wemm #ifdef _KERNEL
341a1c995b6SPoul-Henning Kamp #ifdef MALLOC_DECLARE
342a1c995b6SPoul-Henning Kamp MALLOC_DECLARE(M_IFADDR);
343a1c995b6SPoul-Henning Kamp MALLOC_DECLARE(M_IFMADDR);
344a1c995b6SPoul-Henning Kamp #endif
345a1c995b6SPoul-Henning Kamp #endif
346a1c995b6SPoul-Henning Kamp 
347664a31e4SPeter Wemm #ifndef _KERNEL
34876429de4SYoshinobu Inoue struct if_nameindex {
349f2ba8326SMike Barcroft 	unsigned int	if_index;	/* 1, 2, ... */
35076429de4SYoshinobu Inoue 	char		*if_name;	/* null terminated name: "le0", ... */
35176429de4SYoshinobu Inoue };
35276429de4SYoshinobu Inoue 
35376429de4SYoshinobu Inoue __BEGIN_DECLS
354edfcad95SMike Barcroft void			 if_freenameindex(struct if_nameindex *);
355f2ba8326SMike Barcroft char			*if_indextoname(unsigned int, char *);
356929ddbbbSAlfred Perlstein struct if_nameindex	*if_nameindex(void);
357edfcad95SMike Barcroft unsigned int		 if_nametoindex(const char *);
35876429de4SYoshinobu Inoue __END_DECLS
35976429de4SYoshinobu Inoue #endif
36076429de4SYoshinobu Inoue 
361664a31e4SPeter Wemm #ifdef _KERNEL
362b40ce416SJulian Elischer struct thread;
363712020a1SBruce Evans 
364712020a1SBruce Evans /* XXX - this should go away soon. */
36519ff91c6SGarrett Wollman #include <net/if_var.h>
366df8bae1dSRodney W. Grimes #endif
367cea1da3bSPaul Richards 
368df708ff1SBruce Evans #endif /* !_NET_IF_H_ */
369