if.h revision 1.212
164562Sgshapiro/*	$OpenBSD: if.h,v 1.212 2023/05/15 16:34:56 bluhm Exp $	*/
2261370Sgshapiro/*	$NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $	*/
364562Sgshapiro
464562Sgshapiro/*
564562Sgshapiro * Copyright (c) 1982, 1986, 1989, 1993
664562Sgshapiro *	The Regents of the University of California.  All rights reserved.
764562Sgshapiro *
864562Sgshapiro * Redistribution and use in source and binary forms, with or without
964562Sgshapiro * modification, are permitted provided that the following conditions
1064562Sgshapiro * are met:
1164562Sgshapiro * 1. Redistributions of source code must retain the above copyright
1264562Sgshapiro *    notice, this list of conditions and the following disclaimer.
13266711Sgshapiro * 2. Redistributions in binary form must reproduce the above copyright
1464562Sgshapiro *    notice, this list of conditions and the following disclaimer in the
1564562Sgshapiro *    documentation and/or other materials provided with the distribution.
1664562Sgshapiro * 3. Neither the name of the University nor the names of its contributors
1764562Sgshapiro *    may be used to endorse or promote products derived from this software
1864562Sgshapiro *    without specific prior written permission.
1964562Sgshapiro *
2090792Sgshapiro * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2190792Sgshapiro * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2290792Sgshapiro * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2390792Sgshapiro * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2464562Sgshapiro * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2564562Sgshapiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2664562Sgshapiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2764562Sgshapiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2864562Sgshapiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2964562Sgshapiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3064562Sgshapiro * SUCH DAMAGE.
3164562Sgshapiro *
3264562Sgshapiro *	@(#)if.h	8.1 (Berkeley) 6/10/93
3364562Sgshapiro */
3464562Sgshapiro
3564562Sgshapiro#ifndef _NET_IF_H_
3664562Sgshapiro#define _NET_IF_H_
3764562Sgshapiro
3864562Sgshapiro#include <sys/cdefs.h>
3964562Sgshapiro
4064562Sgshapiro/*
4164562Sgshapiro * Length of interface external name, including terminating '\0'.
4264562Sgshapiro * Note: this is the same size as a generic device's external name.
4364562Sgshapiro */
4490792Sgshapiro#define	IF_NAMESIZE	16
4564562Sgshapiro
4664562Sgshapirostruct if_nameindex {
4764562Sgshapiro	unsigned int	if_index;
4864562Sgshapiro	char		*if_name;
4964562Sgshapiro};
5064562Sgshapiro
5164562Sgshapiro#ifndef _KERNEL
5264562Sgshapiro__BEGIN_DECLS
5364562Sgshapirounsigned int if_nametoindex(const char *);
5464562Sgshapirochar	*if_indextoname(unsigned int, char *);
5564562Sgshapirostruct	if_nameindex *if_nameindex(void);
5664562Sgshapirovoid	if_freenameindex(struct if_nameindex *);
5764562Sgshapiro__END_DECLS
58132943Sgshapiro#endif
5964562Sgshapiro
6064562Sgshapiro#if __BSD_VISIBLE
6164562Sgshapiro
6264562Sgshapiro#include <sys/types.h>
6364562Sgshapiro#include <sys/time.h>
6464562Sgshapiro#include <sys/socket.h>
6564562Sgshapiro
6664562Sgshapiro/*
6764562Sgshapiro * Structure used to query names of interface cloners.
6890792Sgshapiro */
6964562Sgshapirostruct if_clonereq {
7064562Sgshapiro	int	ifcr_total;		/* total cloners (out) */
7164562Sgshapiro	int	ifcr_count;		/* room for this many in user buffer */
7264562Sgshapiro	char	*ifcr_buffer;		/* buffer for cloner names */
7364562Sgshapiro};
7464562Sgshapiro
7564562Sgshapiro#define MCLPOOLS	8		/* number of cluster pools */
7664562Sgshapiro
7790792Sgshapirostruct if_rxring {
7864562Sgshapiro	int     rxr_adjusted;
7964562Sgshapiro	u_int	rxr_alive;
8064562Sgshapiro	u_int	rxr_cwm;
8164562Sgshapiro	u_int	rxr_lwm;
8264562Sgshapiro	u_int	rxr_hwm;
8364562Sgshapiro};
8464562Sgshapiro
8564562Sgshapirostruct if_rxring_info {
8664562Sgshapiro	char	ifr_name[16];		/* name of the ring */
8764562Sgshapiro	u_int	ifr_size;		/* size of the packets on the ring */
8864562Sgshapiro	struct if_rxring ifr_info;
8964562Sgshapiro};
9064562Sgshapiro
9164562Sgshapiro/* Structure used in SIOCGIFRXR request. */
9264562Sgshapirostruct if_rxrinfo {
9364562Sgshapiro	u_int	ifri_total;
9464562Sgshapiro	struct if_rxring_info *ifri_entries;
9564562Sgshapiro};
9664562Sgshapiro
9764562Sgshapiro/*
9864562Sgshapiro * Structure defining statistics and other data kept regarding a network
9964562Sgshapiro * interface.
10064562Sgshapiro */
10164562Sgshapirostruct	if_data {
10264562Sgshapiro	/* generic interface information */
10364562Sgshapiro	u_char		ifi_type;		/* ethernet, tokenring, etc. */
10464562Sgshapiro	u_char		ifi_addrlen;		/* media address length */
10564562Sgshapiro	u_char		ifi_hdrlen;		/* media header length */
10690792Sgshapiro	u_char		ifi_link_state;		/* current link state */
10764562Sgshapiro	u_int32_t	ifi_mtu;		/* maximum transmission unit */
10864562Sgshapiro	u_int32_t	ifi_metric;		/* routing metric (external only) */
10964562Sgshapiro	u_int32_t	ifi_rdomain;		/* routing instance */
11064562Sgshapiro	u_int64_t	ifi_baudrate;		/* linespeed */
11164562Sgshapiro	/* volatile statistics */
11264562Sgshapiro	u_int64_t	ifi_ipackets;		/* packets received on interface */
11390792Sgshapiro	u_int64_t	ifi_ierrors;		/* input errors on interface */
11490792Sgshapiro	u_int64_t	ifi_opackets;		/* packets sent on interface */
11590792Sgshapiro	u_int64_t	ifi_oerrors;		/* output errors on interface */
11690792Sgshapiro	u_int64_t	ifi_collisions;		/* collisions on csma interfaces */
11790792Sgshapiro	u_int64_t	ifi_ibytes;		/* total number of octets received */
11890792Sgshapiro	u_int64_t	ifi_obytes;		/* total number of octets sent */
11990792Sgshapiro	u_int64_t	ifi_imcasts;		/* packets received via multicast */
12090792Sgshapiro	u_int64_t	ifi_omcasts;		/* packets sent via multicast */
12190792Sgshapiro	u_int64_t	ifi_iqdrops;		/* dropped on input, this interface */
12290792Sgshapiro	u_int64_t	ifi_oqdrops;		/* dropped on output, this interface */
12364562Sgshapiro	u_int64_t	ifi_noproto;		/* destined for unsupported protocol */
12464562Sgshapiro	u_int32_t	ifi_capabilities;	/* interface capabilities */
12564562Sgshapiro	struct	timeval ifi_lastchange;	/* last operational state change */
12664562Sgshapiro};
12790792Sgshapiro
12890792Sgshapiro#define IFQ_NQUEUES	8
12964562Sgshapiro#define IFQ_MINPRIO	0
13064562Sgshapiro#define IFQ_MAXPRIO	IFQ_NQUEUES - 1
13190792Sgshapiro#define IFQ_DEFPRIO	3
13290792Sgshapiro#define IFQ_PRIO2TOS(_p) ((_p) << 5)
13390792Sgshapiro#define IFQ_TOS2PRIO(_t) ((_t) >> 5)
13490792Sgshapiro
13564562Sgshapiro/*
136 * Values for if_link_state.
137 */
138#define LINK_STATE_UNKNOWN	0	/* link unknown */
139#define LINK_STATE_INVALID	1	/* link invalid */
140#define LINK_STATE_DOWN		2	/* link is down */
141#define LINK_STATE_KALIVE_DOWN	3	/* keepalive reports down */
142#define LINK_STATE_UP		4	/* link is up */
143#define LINK_STATE_HALF_DUPLEX	5	/* link is up and half duplex */
144#define LINK_STATE_FULL_DUPLEX	6	/* link is up and full duplex */
145
146#define LINK_STATE_IS_UP(_s)	\
147		((_s) >= LINK_STATE_UP || (_s) == LINK_STATE_UNKNOWN)
148
149/*
150 * Status bit descriptions for the various interface types.
151 */
152struct if_status_description {
153	u_char	ifs_type;
154	u_char	ifs_state;
155	const char *ifs_string;
156};
157
158#define LINK_STATE_DESC_MATCH(_ifs, _t, _s)				\
159	(((_ifs)->ifs_type == (_t) || (_ifs)->ifs_type == 0) &&		\
160	    (_ifs)->ifs_state == (_s))
161
162
163#define LINK_STATE_DESCRIPTIONS {					\
164	{ IFT_ETHER, LINK_STATE_DOWN, "no carrier" },			\
165									\
166	{ IFT_IEEE80211, LINK_STATE_DOWN, "no network" },		\
167									\
168	{ IFT_PPP, LINK_STATE_DOWN, "no carrier" },			\
169									\
170	{ IFT_CARP, LINK_STATE_DOWN, "backup" },			\
171	{ IFT_CARP, LINK_STATE_UP, "master" },				\
172	{ IFT_CARP, LINK_STATE_HALF_DUPLEX, "master" },			\
173	{ IFT_CARP, LINK_STATE_FULL_DUPLEX, "master" },			\
174									\
175	{ 0, LINK_STATE_UP, "active" },					\
176	{ 0, LINK_STATE_HALF_DUPLEX, "active" },			\
177	{ 0, LINK_STATE_FULL_DUPLEX, "active" },			\
178									\
179	{ 0, LINK_STATE_UNKNOWN, "unknown" },				\
180	{ 0, LINK_STATE_INVALID, "invalid" },				\
181	{ 0, LINK_STATE_DOWN, "down" },					\
182	{ 0, LINK_STATE_KALIVE_DOWN, "keepalive down" },		\
183	{ 0, 0, NULL }							\
184}
185
186/* Traditional BSD name for length of interface external name. */
187#define	IFNAMSIZ	IF_NAMESIZE
188
189/*
190 * Length of interface description, including terminating '\0'.
191 */
192#define	IFDESCRSIZE	64
193
194/*
195 * Interface flags can be either owned by the stack or the driver.  The
196 * symbols below document who is toggling which flag.
197 *
198 *	I	immutable after creation
199 *	N	written by the stack (upon user request)
200 *	d	written by the driver
201 *	c	for userland compatibility only
202 */
203#define	IFF_UP		0x1		/* [N] interface is up */
204#define	IFF_BROADCAST	0x2		/* [I] broadcast address valid */
205#define	IFF_DEBUG	0x4		/* [N] turn on debugging */
206#define	IFF_LOOPBACK	0x8		/* [I] is a loopback net */
207#define	IFF_POINTOPOINT	0x10		/* [I] is point-to-point link */
208#define	IFF_STATICARP	0x20		/* [N] only static ARP */
209#define	IFF_RUNNING	0x40		/* [d] resources allocated */
210#define	IFF_NOARP	0x80		/* [N] no address resolution protocol */
211#define	IFF_PROMISC	0x100		/* [N] receive all packets */
212#define	IFF_ALLMULTI	0x200		/* [d] receive all multicast packets */
213#define	IFF_OACTIVE	0x400		/* [c] transmission in progress */
214#define	IFF_SIMPLEX	0x800		/* [I] can't hear own transmissions */
215#define	IFF_LINK0	0x1000		/* [N] per link layer defined bit */
216#define	IFF_LINK1	0x2000		/* [N] per link layer defined bit */
217#define	IFF_LINK2	0x4000		/* [N] per link layer defined bit */
218#define	IFF_MULTICAST	0x8000		/* [I] supports multicast */
219
220/* flags set internally only: */
221#define	IFF_CANTCHANGE \
222	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
223	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI)
224
225#define	IFXF_MPSAFE		0x1	/* [I] if_start is mpsafe */
226#define	IFXF_CLONED		0x2	/* [I] pseudo interface */
227#define	IFXF_AUTOCONF6TEMP	0x4	/* [N] v6 temporary addrs enabled */
228#define	IFXF_MPLS		0x8	/* [N] supports MPLS */
229#define	IFXF_WOL		0x10	/* [N] wake on lan enabled */
230#define	IFXF_AUTOCONF6		0x20	/* [N] v6 autoconf enabled */
231#define IFXF_INET6_NOSOII	0x40	/* [N] don't do RFC 7217 */
232#define	IFXF_AUTOCONF4		0x80	/* [N] v4 autoconf (aka dhcp) enabled */
233#define	IFXF_MONITOR		0x100	/* [N] only used for bpf */
234#define	IFXF_TSO		0x200	/* [N] XXX missnamed, should be LRO */
235
236#define	IFXF_CANTCHANGE \
237	(IFXF_MPSAFE|IFXF_CLONED)
238
239/*
240 * Some convenience macros used for setting ifi_baudrate.
241 */
242#define	IF_Kbps(x)	((x) * 1000ULL)			/* kilobits/sec. */
243#define	IF_Mbps(x)	(IF_Kbps((x) * 1000ULL))	/* megabits/sec. */
244#define	IF_Gbps(x)	(IF_Mbps((x) * 1000ULL))	/* gigabits/sec. */
245
246/* Capabilities that interfaces can advertise. */
247#define	IFCAP_CSUM_IPv4		0x00000001	/* can do IPv4 header csum */
248#define	IFCAP_CSUM_TCPv4	0x00000002	/* can do IPv4/TCP csum */
249#define	IFCAP_CSUM_UDPv4	0x00000004	/* can do IPv4/UDP csum */
250#define	IFCAP_VLAN_MTU		0x00000010	/* VLAN-compatible MTU */
251#define	IFCAP_VLAN_HWTAGGING	0x00000020	/* hardware VLAN tag support */
252#define	IFCAP_CSUM_TCPv6	0x00000080	/* can do IPv6/TCP checksums */
253#define	IFCAP_CSUM_UDPv6	0x00000100	/* can do IPv6/UDP checksums */
254#define	IFCAP_TSOv4		0x00001000	/* IPv4/TCP segment offload */
255#define	IFCAP_TSOv6		0x00002000	/* IPv6/TCP segment offload */
256#define	IFCAP_TSO		0x00004000	/* XXX should be LRO */
257#define	IFCAP_WOL		0x00008000	/* can do wake on lan */
258
259#define IFCAP_CSUM_MASK		(IFCAP_CSUM_IPv4 | IFCAP_CSUM_TCPv4 | \
260    IFCAP_CSUM_UDPv4 | IFCAP_CSUM_TCPv6 | IFCAP_CSUM_UDPv6)
261
262/* symbolic names for terminal (per-protocol) CTL_IFQ_ nodes */
263#define IFQCTL_LEN 1
264#define IFQCTL_MAXLEN 2
265#define IFQCTL_DROPS 3
266#define IFQCTL_CONGESTION 4
267#define IFQCTL_MAXID 5
268
269/* sysctl for ifq (per-protocol packet input queue variant of ifqueue) */
270#define CTL_IFQ_NAMES  { \
271	{ 0, 0 }, \
272	{ "len", CTLTYPE_INT }, \
273	{ "maxlen", CTLTYPE_INT }, \
274	{ "drops", CTLTYPE_INT }, \
275	{ "congestion", CTLTYPE_INT }, \
276}
277
278/*
279 * Message format for use in obtaining information about interfaces
280 * from sysctl and the routing socket.
281 */
282struct if_msghdr {
283	u_short	ifm_msglen;	/* to skip over non-understood messages */
284	u_char	ifm_version;	/* future binary compatibility */
285	u_char	ifm_type;	/* message type */
286	u_short ifm_hdrlen;	/* sizeof(if_msghdr) to skip over the header */
287	u_short	ifm_index;	/* index for associated ifp */
288	u_short	ifm_tableid;	/* routing table id */
289	u_char	ifm_pad1;
290	u_char	ifm_pad2;
291	int	ifm_addrs;	/* like rtm_addrs */
292	int	ifm_flags;	/* value of if_flags */
293	int	ifm_xflags;
294	struct	if_data ifm_data;/* statistics and other data about if */
295};
296
297/*
298 * Message format for use in obtaining information about interface addresses
299 * from sysctl and the routing socket.
300 */
301struct ifa_msghdr {
302	u_short	ifam_msglen;	/* to skip over non-understood messages */
303	u_char	ifam_version;	/* future binary compatibility */
304	u_char	ifam_type;	/* message type */
305	u_short ifam_hdrlen;	/* sizeof(ifa_msghdr) to skip over the header */
306	u_short	ifam_index;	/* index for associated ifp */
307	u_short	ifam_tableid;	/* routing table id */
308	u_char	ifam_pad1;
309	u_char	ifam_pad2;
310	int	ifam_addrs;	/* like rtm_addrs */
311	int	ifam_flags;	/* value of ifa_flags */
312	int	ifam_metric;	/* value of ifa_metric */
313};
314
315/*
316 * Message format announcing the arrival or departure of a network interface.
317 */
318struct if_announcemsghdr {
319	u_short	ifan_msglen;	/* to skip over non-understood messages */
320	u_char	ifan_version;	/* future binary compatibility */
321	u_char	ifan_type;	/* message type */
322	u_short ifan_hdrlen;	/* sizeof(if_announcemsghdr) to skip header */
323	u_short	ifan_index;	/* index for associated ifp */
324	u_short	ifan_what;	/* what type of announcement */
325	char	ifan_name[IFNAMSIZ];	/* if name, e.g. "en0" */
326};
327
328#define IFAN_ARRIVAL	0	/* interface arrival */
329#define IFAN_DEPARTURE	1	/* interface departure */
330
331/* message format used to pass 80211 interface info */
332struct if_ieee80211_data {
333	uint8_t		ifie_channel;	/* IEEE80211_CHAN_MAX  == 255 */
334	uint8_t		ifie_nwid_len;
335	uint32_t	ifie_flags;	/* ieee80211com.ic_flags */
336	uint32_t	ifie_xflags;	/* ieee80211com.ic xflags */
337	uint8_t		ifie_nwid[32];	/* IEEE80211_NWID_LEN */
338	uint8_t		ifie_addr[6];	/* IEEE80211_ADDR_LEN */
339};
340
341struct if_ieee80211_msghdr {
342	uint16_t	ifim_msglen;
343	uint8_t		ifim_version;
344	uint8_t		ifim_type;
345	uint16_t	ifim_hdrlen;
346	uint16_t	ifim_index;
347	uint16_t	ifim_tableid;
348
349	struct if_ieee80211_data	ifim_ifie;
350};
351
352/* message format used to pass interface name to index mappings */
353struct if_nameindex_msg {
354	unsigned int	if_index;
355	char		if_name[IFNAMSIZ];
356};
357
358/*
359 * interface groups
360 */
361
362#define	IFG_ALL		"all"		/* group contains all interfaces */
363#define	IFG_EGRESS	"egress"	/* if(s) default route(s) point to */
364
365struct ifg_req {
366	union {
367		char			 ifgrqu_group[IFNAMSIZ];
368		char			 ifgrqu_member[IFNAMSIZ];
369	} ifgrq_ifgrqu;
370#define	ifgrq_group	ifgrq_ifgrqu.ifgrqu_group
371#define	ifgrq_member	ifgrq_ifgrqu.ifgrqu_member
372};
373
374struct ifg_attrib {
375	int	ifg_carp_demoted;
376};
377
378/*
379 * Used to lookup groups for an interface
380 */
381struct ifgroupreq {
382	char	ifgr_name[IFNAMSIZ];
383	u_int	ifgr_len;
384	union {
385		char			 ifgru_group[IFNAMSIZ];
386		struct	ifg_req		*ifgru_groups;
387		struct	ifg_attrib	 ifgru_attrib;
388	} ifgr_ifgru;
389#define ifgr_group	ifgr_ifgru.ifgru_group
390#define ifgr_groups	ifgr_ifgru.ifgru_groups
391#define ifgr_attrib	ifgr_ifgru.ifgru_attrib
392};
393
394/*
395 * Interface request structure used for socket
396 * ioctl's.  All interface ioctl's must have parameter
397 * definitions which begin with ifr_name.  The
398 * remainder may be interface specific.
399 */
400struct	ifreq {
401	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
402	union {
403		struct	sockaddr	ifru_addr;
404		struct	sockaddr	ifru_dstaddr;
405		struct	sockaddr	ifru_broadaddr;
406		short			ifru_flags;
407		int			ifru_metric;
408		int64_t			ifru_vnetid;
409		uint64_t		ifru_media;
410		caddr_t			ifru_data;
411		unsigned int		ifru_index;
412	} ifr_ifru;
413#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
414#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
415#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
416#define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
417#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
418#define	ifr_mtu		ifr_ifru.ifru_metric	/* mtu (overload) */
419#define	ifr_hardmtu	ifr_ifru.ifru_metric	/* hardmtu (overload) */
420#define	ifr_media	ifr_ifru.ifru_media	/* media options */
421#define	ifr_rdomainid	ifr_ifru.ifru_metric	/* VRF instance (overload) */
422#define ifr_vnetid	ifr_ifru.ifru_vnetid	/* Virtual Net Id */
423#define ifr_ttl		ifr_ifru.ifru_metric	/* tunnel TTL (overload) */
424#define ifr_df		ifr_ifru.ifru_metric	/* tunnel DF (overload) */
425#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
426#define ifr_index	ifr_ifru.ifru_index	/* interface index */
427#define ifr_llprio	ifr_ifru.ifru_metric	/* link layer priority */
428#define ifr_hdrprio	ifr_ifru.ifru_metric	/* header prio field config */
429#define ifr_pwe3	ifr_ifru.ifru_metric	/* PWE3 type */
430};
431
432#define IF_HDRPRIO_MIN		IFQ_MINPRIO
433#define IF_HDRPRIO_MAX		IFQ_MAXPRIO
434#define IF_HDRPRIO_PACKET	-1	/* use mbuf prio */
435#define IF_HDRPRIO_PAYLOAD	-2	/* copy payload prio */
436#define IF_HDRPRIO_OUTER	-3	/* use outer prio */
437
438#define IF_PWE3_ETHERNET	1	/* ethernet or ethernet tagged */
439#define IF_PWE3_IP		2	/* IP layer 2 */
440
441struct ifaliasreq {
442	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
443	union {
444		struct	sockaddr ifrau_addr;
445		int	ifrau_align;
446	 } ifra_ifrau;
447#ifndef ifra_addr
448#define ifra_addr	ifra_ifrau.ifrau_addr
449#endif
450	struct	sockaddr ifra_dstaddr;
451#define	ifra_broadaddr	ifra_dstaddr
452	struct	sockaddr ifra_mask;
453};
454
455struct ifmediareq {
456	char		ifm_name[IFNAMSIZ];	/* if name, e.g. "en0" */
457	uint64_t	ifm_current;		/* get/set current media options */
458	uint64_t	ifm_mask;		/* don't care mask */
459	uint64_t	ifm_status;		/* media status */
460	uint64_t	ifm_active;		/* active options */
461	int		ifm_count;		/* # entries in ifm_ulist array */
462	uint64_t	*ifm_ulist;		/* media words */
463};
464
465struct ifkalivereq {
466	char	ikar_name[IFNAMSIZ];		/* if name, e.g. "en0" */
467	int	ikar_timeo;
468	int	ikar_cnt;
469};
470
471/*
472 * Structure used in SIOCGIFCONF request.
473 * Used to retrieve interface configuration
474 * for machine (useful for programs which
475 * must know all networks accessible).
476 */
477struct	ifconf {
478	int	ifc_len;		/* size of associated buffer */
479	union {
480		caddr_t	ifcu_buf;
481		struct	ifreq *ifcu_req;
482	} ifc_ifcu;
483#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
484#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
485};
486
487/*
488 * Structure for SIOC[AGD]LIFADDR
489 */
490struct if_laddrreq {
491	char iflr_name[IFNAMSIZ];
492	unsigned int flags;
493#define IFLR_PREFIX	0x8000	/* in: prefix given  out: kernel fills id */
494	unsigned int prefixlen;		/* in/out */
495	struct sockaddr_storage addr;	/* in/out */
496	struct sockaddr_storage dstaddr; /* out */
497};
498
499/* SIOCIFAFDETACH */
500struct if_afreq {
501	char		ifar_name[IFNAMSIZ];
502	sa_family_t	ifar_af;
503};
504
505/* SIOC[SG]IFPARENT */
506struct if_parent {
507	char		ifp_name[IFNAMSIZ];
508	char		ifp_parent[IFNAMSIZ];
509};
510
511/* SIOCGIFSFFPAGE */
512
513#define IFSFF_ADDR_EEPROM	0xa0
514#define IFSFF_ADDR_DDM		0xa2
515
516#define IFSFF_DATA_LEN		256
517
518struct if_sffpage {
519	char		 sff_ifname[IFNAMSIZ];		/* u -> k */
520	uint8_t		 sff_addr;			/* u -> k */
521	uint8_t		 sff_page;			/* u -> k */
522	uint8_t		 sff_data[IFSFF_DATA_LEN];	/* k -> u */
523};
524
525#include <net/if_arp.h>
526
527#ifdef _KERNEL
528struct socket;
529struct ifnet;
530struct ifq_ops;
531
532void	if_alloc_sadl(struct ifnet *);
533void	if_free_sadl(struct ifnet *);
534void	if_attach(struct ifnet *);
535void	if_attach_queues(struct ifnet *, unsigned int);
536void	if_attach_iqueues(struct ifnet *, unsigned int);
537void	if_attach_ifq(struct ifnet *, const struct ifq_ops *, void *);
538void	if_attachhead(struct ifnet *);
539void	if_deactivate(struct ifnet *);
540void	if_detach(struct ifnet *);
541void	if_down(struct ifnet *);
542void	if_downall(void);
543void	if_link_state_change(struct ifnet *);
544void	if_up(struct ifnet *);
545void	if_getdata(struct ifnet *, struct if_data *);
546void	ifinit(void);
547int	ifioctl(struct socket *, u_long, caddr_t, struct proc *);
548int	ifpromisc(struct ifnet *, int);
549int	ifsettso(struct ifnet *, int);
550struct	ifg_group *if_creategroup(const char *);
551int	if_addgroup(struct ifnet *, const char *);
552int	if_delgroup(struct ifnet *, const char *);
553void	if_group_routechange(struct sockaddr *, struct sockaddr *);
554struct	ifnet *if_unit(const char *);
555struct	ifnet *if_get(unsigned int);
556void	if_put(struct ifnet *);
557void	ifnewlladdr(struct ifnet *);
558void	if_congestion(void);
559int	if_congested(void);
560__dead void	unhandled_af(int);
561int	if_setlladdr(struct ifnet *, const uint8_t *);
562struct taskq * net_tq(unsigned int);
563
564#endif /* _KERNEL */
565
566#endif /* __BSD_VISIBLE */
567
568#endif /* _NET_IF_H_ */
569