1a50ffc2imp/*-
24736ccfpfg * SPDX-License-Identifier: BSD-3-Clause
34736ccfpfg *
48fb65cergrimes * Copyright (c) 1982, 1986, 1989, 1993
58fb65cergrimes *	The Regents of the University of California.  All rights reserved.
68fb65cergrimes *
78fb65cergrimes * Redistribution and use in source and binary forms, with or without
88fb65cergrimes * modification, are permitted provided that the following conditions
98fb65cergrimes * are met:
108fb65cergrimes * 1. Redistributions of source code must retain the above copyright
118fb65cergrimes *    notice, this list of conditions and the following disclaimer.
128fb65cergrimes * 2. Redistributions in binary form must reproduce the above copyright
138fb65cergrimes *    notice, this list of conditions and the following disclaimer in the
148fb65cergrimes *    documentation and/or other materials provided with the distribution.
157e6cabdimp * 3. Neither the name of the University nor the names of its contributors
168fb65cergrimes *    may be used to endorse or promote products derived from this software
178fb65cergrimes *    without specific prior written permission.
188fb65cergrimes *
198fb65cergrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
208fb65cergrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
218fb65cergrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
228fb65cergrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
238fb65cergrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
248fb65cergrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
258fb65cergrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
268fb65cergrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
278fb65cergrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
288fb65cergrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
298fb65cergrimes * SUCH DAMAGE.
308fb65cergrimes *
318fb65cergrimes *	@(#)if.h	8.1 (Berkeley) 6/10/93
323b842d3peter * $FreeBSD$
338fb65cergrimes */
348fb65cergrimes
35be1bed5paul#ifndef _NET_IF_H_
36480097cbde#define	_NET_IF_H_
37be1bed5paul
387849239mike#include <sys/cdefs.h>
397849239mike
407849239mike#if __BSD_VISIBLE
418fb65cergrimes/*
42e4c65b8peter * <net/if.h> does not depend on <sys/time.h> on most other systems.  This
437d76aceasmodai * helps userland compatibility.  (struct timeval ifi_lastchange)
44b18bd11ed * The same holds for <sys/socket.h>.  (struct sockaddr ifru_addr)
45e4c65b8peter */
4615b9bcbpeter#ifndef _KERNEL
47e4c65b8peter#include <sys/time.h>
48b18bd11ed#include <sys/socket.h>
49e4c65b8peter#endif
507849239mike#endif
515da97d8brooks
525da97d8brooks/*
535da97d8brooks * Length of interface external name, including terminating '\0'.
545da97d8brooks * Note: this is the same size as a generic device's external name.
555da97d8brooks */
567849239mike#define		IF_NAMESIZE	16
577849239mike#if __BSD_VISIBLE
587849239mike#define		IFNAMSIZ	IF_NAMESIZE
59f1e94c6brooks#define		IF_MAXUNIT	0x7fff	/* historical value */
607849239mike#endif
617849239mike#if __BSD_VISIBLE
627849239mike
635da97d8brooks/*
645da97d8brooks * Structure used to query names of interface cloners.
655da97d8brooks */
665da97d8brooks
675da97d8brooksstruct if_clonereq {
685da97d8brooks	int	ifcr_total;		/* total cloners (out) */
695da97d8brooks	int	ifcr_count;		/* room for this many in user buffer */
705da97d8brooks	char	*ifcr_buffer;		/* buffer for cloner names */
715da97d8brooks};
725da97d8brooks
73e4c65b8peter/*
74e6dd1aafenner * Structure describing information about an interface
75e6dd1aafenner * which may be of interest to management entities.
76e6dd1aafenner */
7714671cejoergstruct if_data {
7814671cejoerg	/* generic interface information */
79b38edcdglebius	uint8_t	ifi_type;		/* ethernet, tokenring, etc */
80b38edcdglebius	uint8_t	ifi_physical;		/* e.g., AUI, Thinnet, 10base-T, etc */
81b38edcdglebius	uint8_t	ifi_addrlen;		/* media address length */
82b38edcdglebius	uint8_t	ifi_hdrlen;		/* media header length */
83b38edcdglebius	uint8_t	ifi_link_state;		/* current link state */
84b38edcdglebius	uint8_t	ifi_vhid;		/* carp vhid */
85b38edcdglebius	uint16_t	ifi_datalen;	/* length of this data struct */
86b38edcdglebius	uint32_t	ifi_mtu;	/* maximum transmission unit */
87b38edcdglebius	uint32_t	ifi_metric;	/* routing metric (external only) */
88b38edcdglebius	uint64_t	ifi_baudrate;	/* linespeed */
8914671cejoerg	/* volatile statistics */
90b38edcdglebius	uint64_t	ifi_ipackets;	/* packets received on interface */
91b38edcdglebius	uint64_t	ifi_ierrors;	/* input errors on interface */
92b38edcdglebius	uint64_t	ifi_opackets;	/* packets sent on interface */
93b38edcdglebius	uint64_t	ifi_oerrors;	/* output errors on interface */
94b38edcdglebius	uint64_t	ifi_collisions;	/* collisions on csma interfaces */
95b38edcdglebius	uint64_t	ifi_ibytes;	/* total number of octets received */
96b38edcdglebius	uint64_t	ifi_obytes;	/* total number of octets sent */
97b38edcdglebius	uint64_t	ifi_imcasts;	/* packets received via multicast */
98b38edcdglebius	uint64_t	ifi_omcasts;	/* packets sent via multicast */
99b38edcdglebius	uint64_t	ifi_iqdrops;	/* dropped on input */
100b38edcdglebius	uint64_t	ifi_oqdrops;	/* dropped on output */
101b38edcdglebius	uint64_t	ifi_noproto;	/* destined for unsupported protocol */
102b38edcdglebius	uint64_t	ifi_hwassist;	/* HW offload capabilities, see IFCAP */
103b38edcdglebius
104b38edcdglebius	/* Unions are here to make sizes MI. */
105b38edcdglebius	union {				/* uptime at attach or stat reset */
106b38edcdglebius		time_t		tt;
107b38edcdglebius		uint64_t	ph;
108b38edcdglebius	} __ifi_epoch;
109b38edcdglebius#define	ifi_epoch	__ifi_epoch.tt
110b38edcdglebius	union {				/* time of last administrative change */
111b38edcdglebius		struct timeval	tv;
112b38edcdglebius		struct {
113b38edcdglebius			uint64_t ph1;
114b38edcdglebius			uint64_t ph2;
115b38edcdglebius		} ph;
116b38edcdglebius	} __ifi_lastchange;
117b38edcdglebius#define	ifi_lastchange	__ifi_lastchange.tv
11814671cejoerg};
11914671cejoerg
12076ad033rwatson/*-
12174759aarwatson * Interface flags are of two types: network stack owned flags, and driver
12274759aarwatson * owned flags.  Historically, these values were stored in the same ifnet
12374759aarwatson * flags field, but with the advent of fine-grained locking, they have been
12474759aarwatson * broken out such that the network stack is responsible for synchronizing
12574759aarwatson * the stack-owned fields, and the device driver the device-owned fields.
12674759aarwatson * Both halves can perform lockless reads of the other half's field, subject
12774759aarwatson * to accepting the involved races.
12874759aarwatson *
12974759aarwatson * Both sets of flags come from the same number space, and should not be
13074759aarwatson * permitted to conflict, as they are exposed to user space via a single
13174759aarwatson * field.
13274759aarwatson *
13376ad033rwatson * The following symbols identify read and write requirements for fields:
13476ad033rwatson *
13576ad033rwatson * (i) if_flags field set by device driver before attach, read-only there
13676ad033rwatson *     after.
13776ad033rwatson * (n) if_flags field written only by the network stack, read by either the
13876ad033rwatson *     stack or driver.
13976ad033rwatson * (d) if_drv_flags field written only by the device driver, read by either
14076ad033rwatson *     the stack or driver.
14174759aarwatson */
14276ad033rwatson#define	IFF_UP		0x1		/* (n) interface is up */
14376ad033rwatson#define	IFF_BROADCAST	0x2		/* (i) broadcast address valid */
14476ad033rwatson#define	IFF_DEBUG	0x4		/* (n) turn on debugging */
14576ad033rwatson#define	IFF_LOOPBACK	0x8		/* (i) is a loopback net */
14676ad033rwatson#define	IFF_POINTOPOINT	0x10		/* (i) is a point-to-point link */
147cb6df3fglebius/*			0x20		   was IFF_SMART */
14876ad033rwatson#define	IFF_DRV_RUNNING	0x40		/* (d) resources allocated */
14976ad033rwatson#define	IFF_NOARP	0x80		/* (n) no address resolution protocol */
15076ad033rwatson#define	IFF_PROMISC	0x100		/* (n) receive all packets */
15176ad033rwatson#define	IFF_ALLMULTI	0x200		/* (n) receive all multicast packets */
15276ad033rwatson#define	IFF_DRV_OACTIVE	0x400		/* (d) tx hardware queue is full */
15376ad033rwatson#define	IFF_SIMPLEX	0x800		/* (i) can't hear own transmissions */
1548fb65cergrimes#define	IFF_LINK0	0x1000		/* per link layer defined bit */
1558fb65cergrimes#define	IFF_LINK1	0x2000		/* per link layer defined bit */
1568fb65cergrimes#define	IFF_LINK2	0x4000		/* per link layer defined bit */
1577eee0c2wollman#define	IFF_ALTPHYS	IFF_LINK2	/* use alternate physical connection */
15876ad033rwatson#define	IFF_MULTICAST	0x8000		/* (i) supports multicast */
1593341787weongyo#define	IFF_CANTCONFIG	0x10000		/* (i) unconfigurable using ioctl(2) */
16076ad033rwatson#define	IFF_PPROMISC	0x20000		/* (n) user-requested promisc mode */
16176ad033rwatson#define	IFF_MONITOR	0x40000		/* (n) user-requested monitor mode */
16276ad033rwatson#define	IFF_STATICARP	0x80000		/* (n) static ARP */
163c797841rwatson#define	IFF_DYING	0x200000	/* (n) interface is winding down */
1643ce93dcjhb#define	IFF_RENAMING	0x400000	/* (n) interface is being renamed */
1650a7aab5mmacy#define	IFF_NOGROUP	0x800000	/* (n) interface is not part of any groups */
1660a7aab5mmacy
1670a7aab5mmacy
16874759aarwatson/*
16974759aarwatson * Old names for driver flags so that user space tools can continue to use
17076ad033rwatson * the old (portable) names.
17174759aarwatson */
17274759aarwatson#ifndef _KERNEL
17374759aarwatson#define	IFF_RUNNING	IFF_DRV_RUNNING
17474759aarwatson#define	IFF_OACTIVE	IFF_DRV_OACTIVE
17574759aarwatson#endif
17674759aarwatson
1778fb65cergrimes/* flags set internally only: */
1788fb65cergrimes#define	IFF_CANTCHANGE \
17974759aarwatson	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_DRV_RUNNING|IFF_DRV_OACTIVE|\
180cb6df3fglebius	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC|\
1816dc48cbweongyo	    IFF_DYING|IFF_CANTCONFIG)
1828fb65cergrimes
1837092aeasam/*
18425ae331andre * Values for if_link_state.
18525ae331andre */
18625ae331andre#define	LINK_STATE_UNKNOWN	0	/* link invalid/unknown */
18725ae331andre#define	LINK_STATE_DOWN		1	/* link is down */
18825ae331andre#define	LINK_STATE_UP		2	/* link is up */
18925ae331andre
19025ae331andre/*
1917092aeasam * Some convenience macros used for setting ifi_baudrate.
1927092aeasam * XXX 1000 vs. 1024? --thorpej@netbsd.org
1937092aeasam */
1940dfb309emax#define	IF_Kbps(x)	((uintmax_t)(x) * 1000)	/* kilobits/sec. */
1957092aeasam#define	IF_Mbps(x)	(IF_Kbps((x) * 1000))	/* megabits/sec. */
1967092aeasam#define	IF_Gbps(x)	(IF_Mbps((x) * 1000))	/* gigabits/sec. */
1977092aeasam
198ae59650andre/*
199ae59650andre * Capabilities that interfaces can advertise.
200ae59650andre *
201ae59650andre * struct ifnet.if_capabilities
202ae59650andre *   contains the optional features & capabilities a particular interface
203ae59650andre *   supports (not only the driver but also the detected hw revision).
204ae59650andre *   Capabilities are defined by IFCAP_* below.
20578898eayar * struct ifnet.if_capenable
206ae59650andre *   contains the enabled (either by default or through ifconfig) optional
207ae59650andre *   features & capabilities on this interface.
208ae59650andre *   Capabilities are defined by IFCAP_* below.
209ae59650andre * struct if_data.ifi_hwassist in mbuf CSUM_ flag form, controlled by above
210ae59650andre *   contains the enabled optional feature & capabilites that can be used
211ae59650andre *   individually per packet and are specified in the mbuf pkthdr.csum_flags
212ae59650andre *   field.  IFCAP_* and CSUM_* do not match one to one and CSUM_* may be
21378898eayar *   more detailed or differenciated than IFCAP_*.
214ae59650andre *   Hwassist features are defined CSUM_* in sys/mbuf.h
2157cd78b9luigi *
2167cd78b9luigi * Capabilities that cannot be arbitrarily changed with ifconfig/ioctl
2177cd78b9luigi * are listed in IFCAP_CANTCHANGE, similar to IFF_CANTCHANGE.
2187cd78b9luigi * This is not strictly necessary because the common code never
2197cd78b9luigi * changes capabilities, and it is left to the individual driver
2207cd78b9luigi * to do the right thing. However, having the filter here
2217cd78b9luigi * avoids replication of the same code in all individual drivers.
222ae59650andre */
223e4ffb4bjfv#define	IFCAP_RXCSUM		0x00001  /* can offload checksum on RX */
224e4ffb4bjfv#define	IFCAP_TXCSUM		0x00002  /* can offload checksum on TX */
225e4ffb4bjfv#define	IFCAP_NETCONS		0x00004  /* can be a network console */
226e4ffb4bjfv#define	IFCAP_VLAN_MTU		0x00008	/* VLAN-compatible MTU */
227e4ffb4bjfv#define	IFCAP_VLAN_HWTAGGING	0x00010	/* hardware VLAN tag support */
228e4ffb4bjfv#define	IFCAP_JUMBO_MTU		0x00020	/* 9000 byte MTU supported */
229e4ffb4bjfv#define	IFCAP_POLLING		0x00040	/* driver supports polling */
230e4ffb4bjfv#define	IFCAP_VLAN_HWCSUM	0x00080	/* can do IFCAP_HWCSUM on VLANs */
231e4ffb4bjfv#define	IFCAP_TSO4		0x00100	/* can do TCP Segmentation Offload */
232e4ffb4bjfv#define	IFCAP_TSO6		0x00200	/* can do TCP6 Segmentation Offload */
233e4ffb4bjfv#define	IFCAP_LRO		0x00400	/* can do Large Receive Offload */
234e4ffb4bjfv#define	IFCAP_WOL_UCAST		0x00800	/* wake on any unicast frame */
235e4ffb4bjfv#define	IFCAP_WOL_MCAST		0x01000	/* wake on any multicast frame */
236e4ffb4bjfv#define	IFCAP_WOL_MAGIC		0x02000	/* wake on any Magic Packet */
237e4ffb4bjfv#define	IFCAP_TOE4		0x04000	/* interface can offload TCP */
238e4ffb4bjfv#define	IFCAP_TOE6		0x08000	/* interface can offload TCP6 */
239e4ffb4bjfv#define	IFCAP_VLAN_HWFILTER	0x10000 /* interface hw can filter vlan tag */
2409c54c9cglebius/* 	available		0x20000 */
241453676ayongari#define	IFCAP_VLAN_HWTSO	0x40000 /* can do IFCAP_TSO on VLANs */
2424ff4954qingli#define	IFCAP_LINKSTATE		0x80000 /* the runtime link state is dynamic */
2437cd78b9luigi#define	IFCAP_NETMAP		0x100000 /* netmap mode supported/enabled */
244ac429c7bz#define	IFCAP_RXCSUM_IPV6	0x200000  /* can offload checksum on IPv6 RX */
245ac429c7bz#define	IFCAP_TXCSUM_IPV6	0x400000  /* can offload checksum on IPv6 TX */
24675528d8glebius#define	IFCAP_HWSTATS		0x800000 /* manages counters internally */
247efa6326hselasky#define	IFCAP_TXRTLMT		0x1000000 /* hardware supports TX rate limiting */
248ce9362dkib#define	IFCAP_HWRXTSTMP		0x2000000 /* hardware rx timestamping */
249520aafejhb#define	IFCAP_NOMAP		0x4000000 /* can TX unmapped mbufs */
2501cf3162jhb#define	IFCAP_TXTLS4		0x8000000 /* can do TLS encryption and segmentation for TCP */
2511cf3162jhb#define	IFCAP_TXTLS6		0x10000000 /* can do TLS encryption and segmentation for TCP6 */
252ac429c7bz
253ac429c7bz#define IFCAP_HWCSUM_IPV6	(IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6)
25428193b2jlemon
2550895454sam#define IFCAP_HWCSUM	(IFCAP_RXCSUM | IFCAP_TXCSUM)
2560895454sam#define	IFCAP_TSO	(IFCAP_TSO4 | IFCAP_TSO6)
2570895454sam#define	IFCAP_WOL	(IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC)
25896bf4f5kmacy#define	IFCAP_TOE	(IFCAP_TOE4 | IFCAP_TOE6)
2591cf3162jhb#define	IFCAP_TXTLS	(IFCAP_TXTLS4 | IFCAP_TXTLS6)
260131e3adjlemon
2617cd78b9luigi#define	IFCAP_CANTCHANGE	(IFCAP_NETMAP)
2627cd78b9luigi
2638fb65cergrimes#define	IFQ_MAXLEN	50
2648fb65cergrimes#define	IFNET_SLOWHZ	1		/* granularity is 1 second */
2658fb65cergrimes
2668fb65cergrimes/*
2678fb65cergrimes * Message format for use in obtaining information about interfaces
2688fb65cergrimes * from getkerninfo and the routing socket
269d05091dbz * For the new, extensible interface see struct if_msghdrl below.
2708fb65cergrimes */
2718fb65cergrimesstruct if_msghdr {
2728fb65cergrimes	u_short	ifm_msglen;	/* to skip over non-understood messages */
2737d76aceasmodai	u_char	ifm_version;	/* future binary compatibility */
2748fb65cergrimes	u_char	ifm_type;	/* message type */
2758fb65cergrimes	int	ifm_addrs;	/* like rtm_addrs */
2768fb65cergrimes	int	ifm_flags;	/* value of if_flags */
2778fb65cergrimes	u_short	ifm_index;	/* index for associated ifp */
2784bb7057markj	u_short	_ifm_spare1;
2798fb65cergrimes	struct	if_data ifm_data;/* statistics and other data about if */
2808fb65cergrimes};
2818fb65cergrimes
2828fb65cergrimes/*
283d05091dbz * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL.  It is
284d05091dbz * extensible after ifm_data_off or within ifm_data.  Both the if_msghdr and
285d05091dbz * if_data now have a member field detailing the struct length in addition to
286d05091dbz * the routing message length.  Macros are provided to find the start of
287d05091dbz * ifm_data and the start of the socket address strucutres immediately following
288d05091dbz * struct if_msghdrl given a pointer to struct if_msghdrl.
289d05091dbz */
290d05091dbz#define	IF_MSGHDRL_IFM_DATA(_l) \
291d05091dbz    (struct if_data *)((char *)(_l) + (_l)->ifm_data_off)
292d05091dbz#define	IF_MSGHDRL_RTA(_l) \
293d05091dbz    (void *)((uintptr_t)(_l) + (_l)->ifm_len)
294d05091dbzstruct if_msghdrl {
295d05091dbz	u_short	ifm_msglen;	/* to skip over non-understood messages */
296d05091dbz	u_char	ifm_version;	/* future binary compatibility */
297d05091dbz	u_char	ifm_type;	/* message type */
298d05091dbz	int	ifm_addrs;	/* like rtm_addrs */
299d05091dbz	int	ifm_flags;	/* value of if_flags */
300d05091dbz	u_short	ifm_index;	/* index for associated ifp */
301d05091dbz	u_short _ifm_spare1;	/* spare space to grow if_index, see if_var.h */
302d05091dbz	u_short	ifm_len;	/* length of if_msghdrl incl. if_data */
303d05091dbz	u_short	ifm_data_off;	/* offset of if_data from beginning */
3044bb7057markj	int	_ifm_spare2;
305d05091dbz	struct	if_data ifm_data;/* statistics and other data about if */
306d05091dbz};
307d05091dbz
308d05091dbz/*
3098fb65cergrimes * Message format for use in obtaining information about interface addresses
3108fb65cergrimes * from getkerninfo and the routing socket
311d05091dbz * For the new, extensible interface see struct ifa_msghdrl below.
3128fb65cergrimes */
3138fb65cergrimesstruct ifa_msghdr {
3148fb65cergrimes	u_short	ifam_msglen;	/* to skip over non-understood messages */
3157d76aceasmodai	u_char	ifam_version;	/* future binary compatibility */
3168fb65cergrimes	u_char	ifam_type;	/* message type */
3178fb65cergrimes	int	ifam_addrs;	/* like rtm_addrs */
3188fb65cergrimes	int	ifam_flags;	/* value of ifa_flags */
3198fb65cergrimes	u_short	ifam_index;	/* index for associated ifp */
3204bb7057markj	u_short	_ifam_spare1;
321d32e428glebius	int	ifam_metric;	/* value of ifa_ifp->if_metric */
3228fb65cergrimes};
3238fb65cergrimes
3248fb65cergrimes/*
325d05091dbz * The 'l' version shall be used by new interfaces, like NET_RT_IFLISTL.  It is
326d05091dbz * extensible after ifam_metric or within ifam_data.  Both the ifa_msghdrl and
327d05091dbz * if_data now have a member field detailing the struct length in addition to
328d05091dbz * the routing message length.  Macros are provided to find the start of
329d05091dbz * ifm_data and the start of the socket address strucutres immediately following
330d05091dbz * struct ifa_msghdrl given a pointer to struct ifa_msghdrl.
331d05091dbz */
332d05091dbz#define	IFA_MSGHDRL_IFAM_DATA(_l) \
333d05091dbz    (struct if_data *)((char *)(_l) + (_l)->ifam_data_off)
334d05091dbz#define	IFA_MSGHDRL_RTA(_l) \
335d05091dbz    (void *)((uintptr_t)(_l) + (_l)->ifam_len)
336d05091dbzstruct ifa_msghdrl {
337d05091dbz	u_short	ifam_msglen;	/* to skip over non-understood messages */
338d05091dbz	u_char	ifam_version;	/* future binary compatibility */
339d05091dbz	u_char	ifam_type;	/* message type */
340d05091dbz	int	ifam_addrs;	/* like rtm_addrs */
341d05091dbz	int	ifam_flags;	/* value of ifa_flags */
342d05091dbz	u_short	ifam_index;	/* index for associated ifp */
343d05091dbz	u_short _ifam_spare1;	/* spare space to grow if_index, see if_var.h */
344d05091dbz	u_short	ifam_len;	/* length of ifa_msghdrl incl. if_data */
345d05091dbz	u_short	ifam_data_off;	/* offset of if_data from beginning */
346d32e428glebius	int	ifam_metric;	/* value of ifa_ifp->if_metric */
347d05091dbz	struct	if_data ifam_data;/* statistics and other data about if or
348d05091dbz				 * address */
349d05091dbz};
350d05091dbz
351d05091dbz/*
35219e2ac9wollman * Message format for use in obtaining information about multicast addresses
35319e2ac9wollman * from the routing socket
35419e2ac9wollman */
35519e2ac9wollmanstruct ifma_msghdr {
35619e2ac9wollman	u_short	ifmam_msglen;	/* to skip over non-understood messages */
3577d76aceasmodai	u_char	ifmam_version;	/* future binary compatibility */
35819e2ac9wollman	u_char	ifmam_type;	/* message type */
35919e2ac9wollman	int	ifmam_addrs;	/* like rtm_addrs */
36019e2ac9wollman	int	ifmam_flags;	/* value of ifa_flags */
36119e2ac9wollman	u_short	ifmam_index;	/* index for associated ifp */
3624bb7057markj	u_short	_ifmam_spare1;
36319e2ac9wollman};
36419e2ac9wollman
36519e2ac9wollman/*
3667bbde3fru * Message format announcing the arrival or departure of a network interface.
3677bbde3fru */
3687bbde3frustruct if_announcemsghdr {
3697bbde3fru	u_short	ifan_msglen;	/* to skip over non-understood messages */
3707bbde3fru	u_char	ifan_version;	/* future binary compatibility */
3717bbde3fru	u_char	ifan_type;	/* message type */
3727bbde3fru	u_short	ifan_index;	/* index for associated ifp */
3737bbde3fru	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
3747bbde3fru	u_short	ifan_what;	/* what type of announcement */
3757bbde3fru};
3767bbde3fru
3777bbde3fru#define	IFAN_ARRIVAL	0	/* interface arrival */
3787bbde3fru#define	IFAN_DEPARTURE	1	/* interface departure */
3797bbde3fru
3807bbde3fru/*
381d9a0cd0delphij * Buffer with length to be used in SIOCGIFDESCR/SIOCSIFDESCR requests
382d9a0cd0delphij */
383d9a0cd0delphijstruct ifreq_buffer {
384d9a0cd0delphij	size_t	length;
385d9a0cd0delphij	void	*buffer;
386d9a0cd0delphij};
387d9a0cd0delphij
388d9a0cd0delphij/*
3898fb65cergrimes * Interface request structure used for socket
3908fb65cergrimes * ioctl's.  All interface ioctl's must have parameter
3918fb65cergrimes * definitions which begin with ifr_name.  The
3928fb65cergrimes * remainder may be interface specific.
3938fb65cergrimes */
3948fb65cergrimesstruct	ifreq {
3958fb65cergrimes	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
3968fb65cergrimes	union {
3978fb65cergrimes		struct	sockaddr ifru_addr;
3988fb65cergrimes		struct	sockaddr ifru_dstaddr;
3998fb65cergrimes		struct	sockaddr ifru_broadaddr;
400d9a0cd0delphij		struct	ifreq_buffer ifru_buffer;
40179b9e4ephk		short	ifru_flags[2];
40285e1c08jlemon		short	ifru_index;
4035675a54jamie		int	ifru_jid;
4048fb65cergrimes		int	ifru_metric;
40577ebe22dg		int	ifru_mtu;
4067d587b9wollman		int	ifru_phys;
40797edcdfpeter		int	ifru_media;
4088fb65cergrimes		caddr_t	ifru_data;
409131e3adjlemon		int	ifru_cap[2];
4109cad5bfbz		u_int	ifru_fib;
411af4ff98araujo		u_char	ifru_vlan_pcp;
4128fb65cergrimes	} ifr_ifru;
4138fb65cergrimes#define	ifr_addr	ifr_ifru.ifru_addr	/* address */
4148fb65cergrimes#define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
4158fb65cergrimes#define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
4160754c52brooks#ifndef _KERNEL
417d9a0cd0delphij#define	ifr_buffer	ifr_ifru.ifru_buffer	/* user supplied buffer with its length */
4180754c52brooks#endif
419f6cebc0sobomax#define	ifr_flags	ifr_ifru.ifru_flags[0]	/* flags (low 16 bits) */
420f6cebc0sobomax#define	ifr_flagshigh	ifr_ifru.ifru_flags[1]	/* flags (high 16 bits) */
4215675a54jamie#define	ifr_jid		ifr_ifru.ifru_jid	/* jail/vnet */
4228fb65cergrimes#define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
42377ebe22dg#define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
4244022b9ddg#define ifr_phys	ifr_ifru.ifru_phys	/* physical wire */
42597edcdfpeter#define ifr_media	ifr_ifru.ifru_media	/* physical media */
426ac0325bbrooks#ifndef _KERNEL
4278fb65cergrimes#define	ifr_data	ifr_ifru.ifru_data	/* for use by interface */
428ac0325bbrooks#endif
429131e3adjlemon#define	ifr_reqcap	ifr_ifru.ifru_cap[0]	/* requested capabilities */
430131e3adjlemon#define	ifr_curcap	ifr_ifru.ifru_cap[1]	/* current capabilities */
43185e1c08jlemon#define	ifr_index	ifr_ifru.ifru_index	/* interface index */
4329cad5bfbz#define	ifr_fib		ifr_ifru.ifru_fib	/* interface fib */
433af4ff98araujo#define	ifr_vlan_pcp	ifr_ifru.ifru_vlan_pcp	/* VLAN priority */
4349de2156kib#define	ifr_lan_pcp	ifr_ifru.ifru_vlan_pcp	/* VLAN priority */
4358fb65cergrimes};
4368fb65cergrimes
4376ce595awollman#define	_SIZEOF_ADDR_IFREQ(ifr) \
4386ce595awollman	((ifr).ifr_addr.sa_len > sizeof(struct sockaddr) ? \
4396ce595awollman	 (sizeof(struct ifreq) - sizeof(struct sockaddr) + \
4406ce595awollman	  (ifr).ifr_addr.sa_len) : sizeof(struct ifreq))
4416ce595awollman
4428fb65cergrimesstruct ifaliasreq {
4438fb65cergrimes	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
4448fb65cergrimes	struct	sockaddr ifra_addr;
4458fb65cergrimes	struct	sockaddr ifra_broadaddr;
4468fb65cergrimes	struct	sockaddr ifra_mask;
44727a36f6glebius	int	ifra_vhid;
4488fb65cergrimes};
4498fb65cergrimes
4501dbe949glebius/* 9.x compat */
4511dbe949glebiusstruct oifaliasreq {
4521dbe949glebius	char	ifra_name[IFNAMSIZ];
4531dbe949glebius	struct	sockaddr ifra_addr;
4541dbe949glebius	struct	sockaddr ifra_broadaddr;
4551dbe949glebius	struct	sockaddr ifra_mask;
4561dbe949glebius};
4571dbe949glebius
45897edcdfpeterstruct ifmediareq {
45997edcdfpeter	char	ifm_name[IFNAMSIZ];	/* if name, e.g. "en0" */
46097edcdfpeter	int	ifm_current;		/* current media options */
46197edcdfpeter	int	ifm_mask;		/* don't care mask */
46297edcdfpeter	int	ifm_status;		/* media status */
46397edcdfpeter	int	ifm_active;		/* active options */
46497edcdfpeter	int	ifm_count;		/* # entries in ifm_ulist array */
46597edcdfpeter	int	*ifm_ulist;		/* media words */
46697edcdfpeter};
4671048fa7phk
4686c5bddathompsastruct  ifdrv {
4696c5bddathompsa	char            ifd_name[IFNAMSIZ];     /* if name, e.g. "en0" */
4706c5bddathompsa	unsigned long   ifd_cmd;
4716c5bddathompsa	size_t          ifd_len;
4726c5bddathompsa	void            *ifd_data;
4736c5bddathompsa};
4746c5bddathompsa
4751048fa7phk/*
4761048fa7phk * Structure used to retrieve aux status data from interfaces.
477d20b3b0bde * Kernel suppliers to this interface should respect the formatting
4781048fa7phk * needed by ifconfig(8): each line starts with a TAB and ends with
479d20b3b0bde * a newline.  The canonical example to copy and paste is in if_tun.c.
4801048fa7phk */
4811048fa7phk
482d20b3b0bde#define	IFSTATMAX	800		/* 10 lines of text */
4831048fa7phkstruct ifstat {
484d20b3b0bde	char	ifs_name[IFNAMSIZ];	/* if name, e.g. "en0" */
485d20b3b0bde	char	ascii[IFSTATMAX + 1];
4861048fa7phk};
4871048fa7phk
4888fb65cergrimes/*
4898fb65cergrimes * Structure used in SIOCGIFCONF request.
4908fb65cergrimes * Used to retrieve interface configuration
4918fb65cergrimes * for machine (useful for programs which
4928fb65cergrimes * must know all networks accessible).
4938fb65cergrimes */
4948fb65cergrimesstruct	ifconf {
4958fb65cergrimes	int	ifc_len;		/* size of associated buffer */
4968fb65cergrimes	union {
4978fb65cergrimes		caddr_t	ifcu_buf;
4988fb65cergrimes		struct	ifreq *ifcu_req;
4998fb65cergrimes	} ifc_ifcu;
5008fb65cergrimes#define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
5018fb65cergrimes#define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
5028fb65cergrimes};
5038fb65cergrimes
5047efc91cshin/*
505f5cde28mlaier * interface groups
506f5cde28mlaier */
507f5cde28mlaier
508f5cde28mlaier#define	IFG_ALL		"all"		/* group contains all interfaces */
509f5cde28mlaier/* XXX: will we implement this? */
510f5cde28mlaier#define	IFG_EGRESS	"egress"	/* if(s) default route(s) point to */
511f5cde28mlaier
512f5cde28mlaierstruct ifg_req {
513f5cde28mlaier	union {
514f5cde28mlaier		char			 ifgrqu_group[IFNAMSIZ];
515f5cde28mlaier		char			 ifgrqu_member[IFNAMSIZ];
516f5cde28mlaier	} ifgrq_ifgrqu;
517f5cde28mlaier#define	ifgrq_group	ifgrq_ifgrqu.ifgrqu_group
518f5cde28mlaier#define	ifgrq_member	ifgrq_ifgrqu.ifgrqu_member
519f5cde28mlaier};
520f5cde28mlaier
521f5cde28mlaier/*
522f5cde28mlaier * Used to lookup groups for an interface
523f5cde28mlaier */
524f5cde28mlaierstruct ifgroupreq {
525f5cde28mlaier	char	ifgr_name[IFNAMSIZ];
526f5cde28mlaier	u_int	ifgr_len;
527f5cde28mlaier	union {
528f5cde28mlaier		char	ifgru_group[IFNAMSIZ];
529f5cde28mlaier		struct	ifg_req *ifgru_groups;
530f5cde28mlaier	} ifgr_ifgru;
5310080e81brooks#ifndef _KERNEL
532f5cde28mlaier#define ifgr_group	ifgr_ifgru.ifgru_group
533f5cde28mlaier#define ifgr_groups	ifgr_ifgru.ifgru_groups
5340080e81brooks#endif
535f5cde28mlaier};
536f5cde28mlaier
53769a7deamelifaro/*
53869a7deamelifaro * Structure used to request i2c data
53969a7deamelifaro * from interface transceivers.
54069a7deamelifaro */
54169a7deamelifarostruct ifi2creq {
54269a7deamelifaro	uint8_t dev_addr;	/* i2c address (0xA0, 0xA2) */
54369a7deamelifaro	uint8_t offset;		/* read offset */
54469a7deamelifaro	uint8_t len;		/* read length */
54569a7deamelifaro	uint8_t spare0;
54669a7deamelifaro	uint32_t spare1;
54769a7deamelifaro	uint8_t data[8];	/* read buffer */
54869a7deamelifaro};
54969a7deamelifaro
5507d1e282sephe/*
5517d1e282sephe * RSS hash.
5527d1e282sephe */
5537d1e282sephe
5547d1e282sephe#define	RSS_FUNC_NONE		0		/* RSS disabled */
5557d1e282sephe#define	RSS_FUNC_PRIVATE	1		/* non-standard */
5567d1e282sephe#define	RSS_FUNC_TOEPLITZ	2
5577d1e282sephe
5587d1e282sephe#define	RSS_TYPE_IPV4		0x00000001
5597d1e282sephe#define	RSS_TYPE_TCP_IPV4	0x00000002
5607d1e282sephe#define	RSS_TYPE_IPV6		0x00000004
5617d1e282sephe#define	RSS_TYPE_IPV6_EX	0x00000008
5627d1e282sephe#define	RSS_TYPE_TCP_IPV6	0x00000010
5637d1e282sephe#define	RSS_TYPE_TCP_IPV6_EX	0x00000020
5647d1e282sephe#define	RSS_TYPE_UDP_IPV4	0x00000040
5657d1e282sephe#define	RSS_TYPE_UDP_IPV6	0x00000080
5667d1e282sephe#define	RSS_TYPE_UDP_IPV6_EX	0x00000100
5677d1e282sephe
5687d1e282sephe#define	RSS_KEYLEN		128
5697d1e282sephe
5707d1e282sephestruct ifrsskey {
5717d1e282sephe	char		ifrk_name[IFNAMSIZ];	/* if name, e.g. "en0" */
5727d1e282sephe	uint8_t		ifrk_func;		/* RSS_FUNC_ */
5737d1e282sephe	uint8_t		ifrk_spare0;
5747d1e282sephe	uint16_t	ifrk_keylen;
5757d1e282sephe	uint8_t		ifrk_key[RSS_KEYLEN];
5767d1e282sephe};
5777d1e282sephe
5787d1e282sephestruct ifrsshash {
5797d1e282sephe	char		ifrh_name[IFNAMSIZ];	/* if name, e.g. "en0" */
5807d1e282sephe	uint8_t		ifrh_func;		/* RSS_FUNC_ */
5817d1e282sephe	uint8_t		ifrh_spare0;
5827d1e282sephe	uint16_t	ifrh_spare1;
5837d1e282sephe	uint32_t	ifrh_types;		/* RSS_TYPE_ */
5847d1e282sephe};
5857d1e282sephe
5869de2156kib#define	IFNET_PCP_NONE	0xff	/* PCP disabled */
5879de2156kib
588465bfaekib#define	IFDR_MSG_SIZE		64
589465bfaekib#define	IFDR_REASON_MSG		1
590465bfaekib#define	IFDR_REASON_VENDOR	2
591465bfaekibstruct ifdownreason {
592465bfaekib	char		ifdr_name[IFNAMSIZ];
593465bfaekib	uint32_t	ifdr_reason;
594465bfaekib	uint32_t	ifdr_vendor;
595465bfaekib	char		ifdr_msg[IFDR_MSG_SIZE];
596465bfaekib};
597465bfaekib
5987849239mike#endif /* __BSD_VISIBLE */
5997849239mike
60015b9bcbpeter#ifdef _KERNEL
60136e7a51phk#ifdef MALLOC_DECLARE
60236e7a51phkMALLOC_DECLARE(M_IFADDR);
60336e7a51phkMALLOC_DECLARE(M_IFMADDR);
60436e7a51phk#endif
60536e7a51phk#endif
60636e7a51phk
60715b9bcbpeter#ifndef _KERNEL
6087efc91cshinstruct if_nameindex {
6097849239mike	unsigned int	if_index;	/* 1, 2, ... */
61073d2354mike	char		*if_name;	/* null terminated name: "le0", ... */
6117efc91cshin};
6127efc91cshin
6137efc91cshin__BEGIN_DECLS
61473d2354mikevoid			 if_freenameindex(struct if_nameindex *);
61573d2354mikechar			*if_indextoname(unsigned int, char *);
61673d2354mikestruct if_nameindex	*if_nameindex(void);
61773d2354mikeunsigned int		 if_nametoindex(const char *);
6187efc91cshin__END_DECLS
6197efc91cshin#endif
620480097cbde#endif /* !_NET_IF_H_ */
621