Home | History | Annotate | Line # | Download | only in net
if.h revision 1.166
      1 /*	$NetBSD: if.h,v 1.166 2014/06/16 00:40:10 ozaki-r Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by William Studenmund and Jason R. Thorpe.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  * POSSIBILITY OF SUCH DAMAGE.
     30  */
     31 
     32 /*
     33  * Copyright (c) 1982, 1986, 1989, 1993
     34  *	The Regents of the University of California.  All rights reserved.
     35  *
     36  * Redistribution and use in source and binary forms, with or without
     37  * modification, are permitted provided that the following conditions
     38  * are met:
     39  * 1. Redistributions of source code must retain the above copyright
     40  *    notice, this list of conditions and the following disclaimer.
     41  * 2. Redistributions in binary form must reproduce the above copyright
     42  *    notice, this list of conditions and the following disclaimer in the
     43  *    documentation and/or other materials provided with the distribution.
     44  * 3. Neither the name of the University nor the names of its contributors
     45  *    may be used to endorse or promote products derived from this software
     46  *    without specific prior written permission.
     47  *
     48  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     49  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     50  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     51  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     52  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     53  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     54  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     55  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     56  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     57  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     58  * SUCH DAMAGE.
     59  *
     60  *	@(#)if.h	8.3 (Berkeley) 2/9/95
     61  */
     62 
     63 #ifndef _NET_IF_H_
     64 #define _NET_IF_H_
     65 
     66 #if !defined(_KERNEL) && !defined(_STANDALONE)
     67 #include <stdbool.h>
     68 #endif
     69 
     70 #include <sys/featuretest.h>
     71 
     72 /*
     73  * Length of interface external name, including terminating '\0'.
     74  * Note: this is the same size as a generic device's external name.
     75  */
     76 #define IF_NAMESIZE 16
     77 
     78 #if defined(_NETBSD_SOURCE)
     79 
     80 #include <sys/socket.h>
     81 #include <sys/queue.h>
     82 
     83 #include <net/dlt.h>
     84 #include <net/pfil.h>
     85 #include <net/pktqueue.h>
     86 
     87 /*
     88  * Always include ALTQ glue here -- we use the ALTQ interface queue
     89  * structure even when ALTQ is not configured into the kernel so that
     90  * the size of struct ifnet does not changed based on the option.  The
     91  * ALTQ queue structure is API-compatible with the legacy ifqueue.
     92  */
     93 #include <altq/if_altq.h>
     94 
     95 /*
     96  * Structures defining a network interface, providing a packet
     97  * transport mechanism (ala level 0 of the PUP protocols).
     98  *
     99  * Each interface accepts output datagrams of a specified maximum
    100  * length, and provides higher level routines with input datagrams
    101  * received from its medium.
    102  *
    103  * Output occurs when the routine if_output is called, with four parameters:
    104  *	(*ifp->if_output)(ifp, m, dst, rt)
    105  * Here m is the mbuf chain to be sent and dst is the destination address.
    106  * The output routine encapsulates the supplied datagram if necessary,
    107  * and then transmits it on its medium.
    108  *
    109  * On input, each interface unwraps the data received by it, and either
    110  * places it on the input queue of a internetwork datagram routine
    111  * and posts the associated software interrupt, or passes the datagram to a raw
    112  * packet input routine.
    113  *
    114  * Routines exist for locating interfaces by their addresses
    115  * or for locating a interface on a certain network, as well as more general
    116  * routing and gateway routines maintaining information used to locate
    117  * interfaces.  These routines live in the files if.c and route.c
    118  */
    119 #include <sys/time.h>
    120 
    121 #if defined(_KERNEL_OPT)
    122 #include "opt_compat_netbsd.h"
    123 #endif
    124 
    125 struct mbuf;
    126 struct proc;
    127 struct rtentry;
    128 struct socket;
    129 struct ether_header;
    130 struct ifaddr;
    131 struct ifnet;
    132 struct rt_addrinfo;
    133 
    134 #define	IFNAMSIZ	IF_NAMESIZE
    135 
    136 /*
    137  * Structure describing a `cloning' interface.
    138  */
    139 struct if_clone {
    140 	LIST_ENTRY(if_clone) ifc_list;	/* on list of cloners */
    141 	const char *ifc_name;		/* name of device, e.g. `gif' */
    142 	size_t ifc_namelen;		/* length of name */
    143 
    144 	int	(*ifc_create)(struct if_clone *, int);
    145 	int	(*ifc_destroy)(struct ifnet *);
    146 };
    147 
    148 #define	IF_CLONE_INITIALIZER(name, create, destroy)			\
    149 	{ { NULL, NULL }, name, sizeof(name) - 1, create, destroy }
    150 
    151 /*
    152  * Structure used to query names of interface cloners.
    153  */
    154 struct if_clonereq {
    155 	int	ifcr_total;		/* total cloners (out) */
    156 	int	ifcr_count;		/* room for this many in user buffer */
    157 	char	*ifcr_buffer;		/* buffer for cloner names */
    158 };
    159 
    160 /*
    161  * Structure defining statistics and other data kept regarding a network
    162  * interface.
    163  */
    164 struct if_data {
    165 	/* generic interface information */
    166 	u_char	ifi_type;		/* ethernet, tokenring, etc. */
    167 	u_char	ifi_addrlen;		/* media address length */
    168 	u_char	ifi_hdrlen;		/* media header length */
    169 	int	ifi_link_state;		/* current link state */
    170 	uint64_t ifi_mtu;		/* maximum transmission unit */
    171 	uint64_t ifi_metric;		/* routing metric (external only) */
    172 	uint64_t ifi_baudrate;		/* linespeed */
    173 	/* volatile statistics */
    174 	uint64_t ifi_ipackets;		/* packets received on interface */
    175 	uint64_t ifi_ierrors;		/* input errors on interface */
    176 	uint64_t ifi_opackets;		/* packets sent on interface */
    177 	uint64_t ifi_oerrors;		/* output errors on interface */
    178 	uint64_t ifi_collisions;	/* collisions on csma interfaces */
    179 	uint64_t ifi_ibytes;		/* total number of octets received */
    180 	uint64_t ifi_obytes;		/* total number of octets sent */
    181 	uint64_t ifi_imcasts;		/* packets received via multicast */
    182 	uint64_t ifi_omcasts;		/* packets sent via multicast */
    183 	uint64_t ifi_iqdrops;		/* dropped on input, this interface */
    184 	uint64_t ifi_noproto;		/* destined for unsupported protocol */
    185 	struct	timespec ifi_lastchange;/* last operational state change */
    186 };
    187 
    188 /*
    189  * Values for if_link_state.
    190  */
    191 #define	LINK_STATE_UNKNOWN	0	/* link invalid/unknown */
    192 #define	LINK_STATE_DOWN		1	/* link is down */
    193 #define	LINK_STATE_UP		2	/* link is up */
    194 
    195 /*
    196  * Structure defining a queue for a network interface.
    197  */
    198 struct ifqueue {
    199 	struct	mbuf *ifq_head;
    200 	struct	mbuf *ifq_tail;
    201 	int	ifq_len;
    202 	int	ifq_maxlen;
    203 	int	ifq_drops;
    204 };
    205 
    206 struct ifnet_lock;
    207 
    208 #ifdef _KERNEL
    209 #include <sys/mutex.h>
    210 #include <sys/condvar.h>
    211 #include <sys/percpu.h>
    212 
    213 struct ifnet_lock {
    214 	kmutex_t il_lock;	/* Protects the critical section. */
    215 	uint64_t il_nexit;	/* Counts threads across all CPUs who
    216 				 * have exited the critical section.
    217 				 * Access to il_nexit is synchronized
    218 				 * by il_lock.
    219 				 */
    220 	percpu_t *il_nenter;	/* Counts threads on each CPU who have
    221 				 * entered or who wait to enter the
    222 				 * critical section protected by il_lock.
    223 				 * Synchronization is not required.
    224 				 */
    225 	kcondvar_t il_emptied;	/* The ifnet_lock user must arrange for
    226 				 * the last threads in the critical
    227 				 * section to signal this condition variable
    228 				 * before they leave.
    229 				 */
    230 };
    231 #endif /* _KERNEL */
    232 
    233 /*
    234  * Structure defining a queue for a network interface.
    235  *
    236  * (Would like to call this struct ``if'', but C isn't PL/1.)
    237  */
    238 TAILQ_HEAD(ifnet_head, ifnet);		/* the actual queue head */
    239 
    240 typedef struct ifnet {
    241 	void	*if_softc;		/* lower-level data for this if */
    242 	TAILQ_ENTRY(ifnet) if_list;	/* all struct ifnets are chained */
    243 	TAILQ_HEAD(, ifaddr) if_addrlist; /* linked list of addresses per if */
    244 	char	if_xname[IFNAMSIZ];	/* external name (name + unit) */
    245 	int	if_pcount;		/* number of promiscuous listeners */
    246 	struct bpf_if *if_bpf;		/* packet filter structure */
    247 	u_short	if_index;		/* numeric abbreviation for this if */
    248 	short	if_timer;		/* time 'til if_watchdog called */
    249 	short	if_flags;		/* up/down, broadcast, etc. */
    250 	short	if__pad1;		/* be nice to m68k ports */
    251 	struct	if_data if_data;	/* statistics and other data about if */
    252 	/*
    253 	 * Procedure handles.  If you add more of these, don't forget the
    254 	 * corresponding NULL stub in if.c.
    255 	 */
    256 	int	(*if_output)		/* output routine (enqueue) */
    257 		    (struct ifnet *, struct mbuf *, const struct sockaddr *,
    258 		     struct rtentry *);
    259 	void	(*if_input)		/* input routine (from h/w driver) */
    260 		    (struct ifnet *, struct mbuf *);
    261 	void	(*if_start)		/* initiate output routine */
    262 		    (struct ifnet *);
    263 	int	(*if_ioctl)		/* ioctl routine */
    264 		    (struct ifnet *, u_long, void *);
    265 	int	(*if_init)		/* init routine */
    266 		    (struct ifnet *);
    267 	void	(*if_stop)		/* stop routine */
    268 		    (struct ifnet *, int);
    269 	void	(*if_watchdog)		/* timer routine */
    270 		    (struct ifnet *);
    271 	void	(*if_drain)		/* routine to release resources */
    272 		    (struct ifnet *);
    273 	struct ifaltq if_snd;		/* output queue (includes altq) */
    274 	struct ifaddr	*if_dl;		/* identity of this interface. */
    275 	const struct	sockaddr_dl *if_sadl;	/* pointer to sockaddr_dl
    276 						 * of if_dl
    277 						 */
    278 	/* if_hwdl: h/w identity
    279 	 *
    280 	 * May be NULL.  If not NULL, it is the address assigned
    281 	 * to the interface by the manufacturer, so it very likely
    282 	 * to be unique.  It MUST NOT be deleted.  It is highly
    283 	 * suitable for deriving the EUI64 for the interface.
    284 	 */
    285 	struct ifaddr	*if_hwdl;
    286 	const uint8_t *if_broadcastaddr;/* linklevel broadcast bytestring */
    287 	void	*if_bridge;		/* bridge glue */
    288 	int	if_dlt;			/* data link type (<net/dlt.h>) */
    289 	pfil_head_t *	if_pfil;	/* filtering point */
    290 	uint64_t if_capabilities;	/* interface capabilities */
    291 	uint64_t if_capenable;		/* capabilities enabled */
    292 	union {
    293 		void *		carp_s;	/* carp structure (used by !carp ifs) */
    294 		struct ifnet	*carp_d;/* ptr to carpdev (used by carp ifs) */
    295 	} if_carp_ptr;
    296 #define if_carp		if_carp_ptr.carp_s
    297 #define if_carpdev	if_carp_ptr.carp_d
    298 	/*
    299 	 * These are pre-computed based on an interfaces enabled
    300 	 * capabilities, for speed elsewhere.
    301 	 */
    302 	int	if_csum_flags_tx;	/* M_CSUM_* flags for Tx */
    303 	int	if_csum_flags_rx;	/* M_CSUM_* flags for Rx */
    304 
    305 	void	*if_afdata[AF_MAX];
    306 	struct	mowner *if_mowner;	/* who owns mbufs for this interface */
    307 
    308 	void	*if_agrprivate;		/* used only when #if NAGR > 0 */
    309 
    310 	/*
    311 	 * pf specific data, used only when #if NPF > 0.
    312 	 */
    313 	void	*if_pf_kif;		/* pf interface abstraction */
    314 	void	*if_pf_groups;		/* pf interface groups */
    315 	/*
    316 	 * During an ifnet's lifetime, it has only one if_index, but
    317 	 * and if_index is not sufficient to identify an ifnet
    318 	 * because during the lifetime of the system, many ifnets may occupy a
    319 	 * given if_index.  Let us tell different ifnets at the same
    320 	 * if_index apart by their if_index_gen, a unique number that each ifnet
    321 	 * is assigned when it if_attach()s.  Now, the kernel can use the
    322 	 * pair (if_index, if_index_gen) as a weak reference to an ifnet.
    323 	 */
    324 	uint64_t if_index_gen;		/* generation number for the ifnet
    325 					 * at if_index: if two ifnets' index
    326 					 * and generation number are both the
    327 					 * same, they are the same ifnet.
    328 					 */
    329 	struct sysctllog	*if_sysctl_log;
    330 	int (*if_initaddr)(struct ifnet *, struct ifaddr *, bool);
    331 	int (*if_mcastop)(struct ifnet *, const unsigned long,
    332 	    const struct sockaddr *);
    333 	int (*if_setflags)(struct ifnet *, const short);
    334 	struct ifnet_lock *if_ioctl_lock;
    335 } ifnet_t;
    336 
    337 #define	if_mtu		if_data.ifi_mtu
    338 #define	if_type		if_data.ifi_type
    339 #define	if_addrlen	if_data.ifi_addrlen
    340 #define	if_hdrlen	if_data.ifi_hdrlen
    341 #define	if_metric	if_data.ifi_metric
    342 #define	if_link_state	if_data.ifi_link_state
    343 #define	if_baudrate	if_data.ifi_baudrate
    344 #define	if_ipackets	if_data.ifi_ipackets
    345 #define	if_ierrors	if_data.ifi_ierrors
    346 #define	if_opackets	if_data.ifi_opackets
    347 #define	if_oerrors	if_data.ifi_oerrors
    348 #define	if_collisions	if_data.ifi_collisions
    349 #define	if_ibytes	if_data.ifi_ibytes
    350 #define	if_obytes	if_data.ifi_obytes
    351 #define	if_imcasts	if_data.ifi_imcasts
    352 #define	if_omcasts	if_data.ifi_omcasts
    353 #define	if_iqdrops	if_data.ifi_iqdrops
    354 #define	if_noproto	if_data.ifi_noproto
    355 #define	if_lastchange	if_data.ifi_lastchange
    356 
    357 #define	IFF_UP		0x0001		/* interface is up */
    358 #define	IFF_BROADCAST	0x0002		/* broadcast address valid */
    359 #define	IFF_DEBUG	0x0004		/* turn on debugging */
    360 #define	IFF_LOOPBACK	0x0008		/* is a loopback net */
    361 #define	IFF_POINTOPOINT	0x0010		/* interface is point-to-point link */
    362 #define	IFF_NOTRAILERS	0x0020		/* avoid use of trailers */
    363 #define	IFF_RUNNING	0x0040		/* resources allocated */
    364 #define	IFF_NOARP	0x0080		/* no address resolution protocol */
    365 #define	IFF_PROMISC	0x0100		/* receive all packets */
    366 #define	IFF_ALLMULTI	0x0200		/* receive all multicast packets */
    367 #define	IFF_OACTIVE	0x0400		/* transmission in progress */
    368 #define	IFF_SIMPLEX	0x0800		/* can't hear own transmissions */
    369 #define	IFF_LINK0	0x1000		/* per link layer defined bit */
    370 #define	IFF_LINK1	0x2000		/* per link layer defined bit */
    371 #define	IFF_LINK2	0x4000		/* per link layer defined bit */
    372 #define	IFF_MULTICAST	0x8000		/* supports multicast */
    373 
    374 #define	IFFBITS \
    375     "\020\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6NOTRAILERS" \
    376     "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \
    377     "\15LINK0\16LINK1\17LINK2\20MULTICAST"
    378 
    379 /* flags set internally only: */
    380 #define	IFF_CANTCHANGE \
    381 	(IFF_BROADCAST|IFF_POINTOPOINT|IFF_RUNNING|IFF_OACTIVE|\
    382 	    IFF_SIMPLEX|IFF_MULTICAST|IFF_ALLMULTI|IFF_PROMISC)
    383 
    384 /*
    385  * Some convenience macros used for setting ifi_baudrate.
    386  * XXX 1000 vs. 1024? --thorpej (at) NetBSD.org
    387  */
    388 #define	IF_Kbps(x)	((x) * 1000)		/* kilobits/sec. */
    389 #define	IF_Mbps(x)	(IF_Kbps((x) * 1000))	/* megabits/sec. */
    390 #define	IF_Gbps(x)	(IF_Mbps((x) * 1000))	/* gigabits/sec. */
    391 
    392 /* Capabilities that interfaces can advertise. */
    393 					/* 0x01 .. 0x40 were previously used */
    394 #define	IFCAP_TSOv4		0x00080	/* can do TCPv4 segmentation offload */
    395 #define	IFCAP_CSUM_IPv4_Rx	0x00100	/* can do IPv4 header checksums (Rx) */
    396 #define	IFCAP_CSUM_IPv4_Tx	0x00200	/* can do IPv4 header checksums (Tx) */
    397 #define	IFCAP_CSUM_TCPv4_Rx	0x00400	/* can do IPv4/TCP checksums (Rx) */
    398 #define	IFCAP_CSUM_TCPv4_Tx	0x00800	/* can do IPv4/TCP checksums (Tx) */
    399 #define	IFCAP_CSUM_UDPv4_Rx	0x01000	/* can do IPv4/UDP checksums (Rx) */
    400 #define	IFCAP_CSUM_UDPv4_Tx	0x02000	/* can do IPv4/UDP checksums (Tx) */
    401 #define	IFCAP_CSUM_TCPv6_Rx	0x04000	/* can do IPv6/TCP checksums (Rx) */
    402 #define	IFCAP_CSUM_TCPv6_Tx	0x08000	/* can do IPv6/TCP checksums (Tx) */
    403 #define	IFCAP_CSUM_UDPv6_Rx	0x10000	/* can do IPv6/UDP checksums (Rx) */
    404 #define	IFCAP_CSUM_UDPv6_Tx	0x20000	/* can do IPv6/UDP checksums (Tx) */
    405 #define	IFCAP_TSOv6		0x40000	/* can do TCPv6 segmentation offload */
    406 #define	IFCAP_LRO		0x80000	/* can do Large Receive Offload */
    407 #define	IFCAP_MASK		0xfff80 /* currently valid capabilities */
    408 
    409 #define	IFCAPBITS		\
    410 	"\020"			\
    411 	"\10TSO4"		\
    412 	"\11IP4CSUM_Rx"		\
    413 	"\12IP4CSUM_Tx"		\
    414 	"\13TCP4CSUM_Rx"	\
    415 	"\14TCP4CSUM_Tx"	\
    416 	"\15UDP4CSUM_Rx"	\
    417 	"\16UDP4CSUM_Tx"	\
    418 	"\17TCP6CSUM_Rx"	\
    419 	"\20TCP6CSUM_Tx"	\
    420 	"\21UDP6CSUM_Rx"	\
    421 	"\22UDP6CSUM_Tx"	\
    422 	"\23TSO6"		\
    423 	"\24LRO"		\
    424 
    425 /*
    426  * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
    427  * input routines have queues of messages stored on ifqueue structures
    428  * (defined above).  Entries are added to and deleted from these structures
    429  * by these macros, which should be called with ipl raised to splnet().
    430  */
    431 #define	IF_QFULL(ifq)		((ifq)->ifq_len >= (ifq)->ifq_maxlen)
    432 #define	IF_DROP(ifq)		((ifq)->ifq_drops++)
    433 #define	IF_ENQUEUE(ifq, m) do { \
    434 	(m)->m_nextpkt = 0; \
    435 	if ((ifq)->ifq_tail == 0) \
    436 		(ifq)->ifq_head = m; \
    437 	else \
    438 		(ifq)->ifq_tail->m_nextpkt = m; \
    439 	(ifq)->ifq_tail = m; \
    440 	(ifq)->ifq_len++; \
    441 } while (/*CONSTCOND*/0)
    442 #define	IF_PREPEND(ifq, m) do { \
    443 	(m)->m_nextpkt = (ifq)->ifq_head; \
    444 	if ((ifq)->ifq_tail == 0) \
    445 		(ifq)->ifq_tail = (m); \
    446 	(ifq)->ifq_head = (m); \
    447 	(ifq)->ifq_len++; \
    448 } while (/*CONSTCOND*/0)
    449 #define	IF_DEQUEUE(ifq, m) do { \
    450 	(m) = (ifq)->ifq_head; \
    451 	if (m) { \
    452 		if (((ifq)->ifq_head = (m)->m_nextpkt) == 0) \
    453 			(ifq)->ifq_tail = 0; \
    454 		(m)->m_nextpkt = 0; \
    455 		(ifq)->ifq_len--; \
    456 	} \
    457 } while (/*CONSTCOND*/0)
    458 #define	IF_POLL(ifq, m)		((m) = (ifq)->ifq_head)
    459 #define	IF_PURGE(ifq)							\
    460 do {									\
    461 	struct mbuf *__m0;						\
    462 									\
    463 	for (;;) {							\
    464 		IF_DEQUEUE((ifq), __m0);				\
    465 		if (__m0 == NULL)					\
    466 			break;						\
    467 		else							\
    468 			m_freem(__m0);					\
    469 	}								\
    470 } while (/*CONSTCOND*/ 0)
    471 #define	IF_IS_EMPTY(ifq)	((ifq)->ifq_len == 0)
    472 
    473 #ifndef IFQ_MAXLEN
    474 #define	IFQ_MAXLEN	256
    475 #endif
    476 #define	IFNET_SLOWHZ	1		/* granularity is 1 second */
    477 
    478 /*
    479  * Structure defining statistics and other data kept regarding an address
    480  * on a network interface.
    481  */
    482 struct ifaddr_data {
    483 	int64_t	ifad_inbytes;
    484 	int64_t	ifad_outbytes;
    485 };
    486 
    487 /*
    488  * The ifaddr structure contains information about one address
    489  * of an interface.  They are maintained by the different address families,
    490  * are allocated and attached when an address is set, and are linked
    491  * together so all addresses for an interface can be located.
    492  */
    493 struct ifaddr {
    494 	struct	sockaddr *ifa_addr;	/* address of interface */
    495 	struct	sockaddr *ifa_dstaddr;	/* other end of p-to-p link */
    496 #define	ifa_broadaddr	ifa_dstaddr	/* broadcast address interface */
    497 	struct	sockaddr *ifa_netmask;	/* used to determine subnet */
    498 	struct	ifnet *ifa_ifp;		/* back-pointer to interface */
    499 	TAILQ_ENTRY(ifaddr) ifa_list;	/* list of addresses for interface */
    500 	struct	ifaddr_data	ifa_data;	/* statistics on the address */
    501 	void	(*ifa_rtrequest)	/* check or clean routes (+ or -)'d */
    502 		        (int, struct rtentry *, const struct rt_addrinfo *);
    503 	u_int	ifa_flags;		/* mostly rt_flags for cloning */
    504 	int	ifa_refcnt;		/* count of references */
    505 	int	ifa_metric;		/* cost of going out this interface */
    506 	struct ifaddr	*(*ifa_getifa)(struct ifaddr *,
    507 			               const struct sockaddr *);
    508 	uint32_t	*ifa_seqno;
    509 	int16_t	ifa_preference;	/* preference level for this address */
    510 };
    511 #define	IFA_ROUTE	RTF_UP	/* (0x01) route installed */
    512 
    513 /*
    514  * Message format for use in obtaining information about interfaces from
    515  * sysctl and the routing socket.  We need to force 64-bit alignment if we
    516  * aren't using compatiblity definitons.
    517  */
    518 #if !defined(_KERNEL) || !defined(COMPAT_RTSOCK)
    519 #define	__align64	__aligned(sizeof(uint64_t))
    520 #else
    521 #define	__align64
    522 #endif
    523 struct if_msghdr {
    524 	u_short	ifm_msglen __align64;
    525 				/* to skip over non-understood messages */
    526 	u_char	ifm_version;	/* future binary compatibility */
    527 	u_char	ifm_type;	/* message type */
    528 	int	ifm_addrs;	/* like rtm_addrs */
    529 	int	ifm_flags;	/* value of if_flags */
    530 	u_short	ifm_index;	/* index for associated ifp */
    531 	struct	if_data ifm_data __align64;
    532 				/* statistics and other data about if */
    533 };
    534 
    535 /*
    536  * Message format for use in obtaining information about interface addresses
    537  * from sysctl and the routing socket.
    538  */
    539 struct ifa_msghdr {
    540 	u_short	ifam_msglen __align64;
    541 				/* to skip over non-understood messages */
    542 	u_char	ifam_version;	/* future binary compatibility */
    543 	u_char	ifam_type;	/* message type */
    544 	int	ifam_addrs;	/* like rtm_addrs */
    545 	int	ifam_flags;	/* value of ifa_flags */
    546 	int	ifam_metric;	/* value of ifa_metric */
    547 	u_short	ifam_index;	/* index for associated ifp */
    548 };
    549 
    550 /*
    551  * Message format announcing the arrival or departure of a network interface.
    552  */
    553 struct if_announcemsghdr {
    554 	u_short	ifan_msglen __align64;
    555 				/* to skip over non-understood messages */
    556 	u_char	ifan_version;	/* future binary compatibility */
    557 	u_char	ifan_type;	/* message type */
    558 	u_short	ifan_index;	/* index for associated ifp */
    559 	char	ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
    560 	u_short	ifan_what;	/* what type of announcement */
    561 };
    562 
    563 #define	IFAN_ARRIVAL	0	/* interface arrival */
    564 #define	IFAN_DEPARTURE	1	/* interface departure */
    565 
    566 #undef __align64
    567 
    568 /*
    569  * Interface request structure used for socket
    570  * ioctl's.  All interface ioctl's must have parameter
    571  * definitions which begin with ifr_name.  The
    572  * remainder may be interface specific.
    573  */
    574 struct	ifreq {
    575 	char	ifr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
    576 	union {
    577 		struct	sockaddr ifru_addr;
    578 		struct	sockaddr ifru_dstaddr;
    579 		struct	sockaddr ifru_broadaddr;
    580 		struct	sockaddr_storage ifru_space;
    581 		short	ifru_flags;
    582 		int	ifru_metric;
    583 		int	ifru_mtu;
    584 		int	ifru_dlt;
    585 		u_int	ifru_value;
    586 		void *	ifru_data;
    587 		struct {
    588 			uint32_t	b_buflen;
    589 			void		*b_buf;
    590 		} ifru_b;
    591 	} ifr_ifru;
    592 #define	ifr_addr	ifr_ifru.ifru_addr	/* address */
    593 #define	ifr_dstaddr	ifr_ifru.ifru_dstaddr	/* other end of p-to-p link */
    594 #define	ifr_broadaddr	ifr_ifru.ifru_broadaddr	/* broadcast address */
    595 #define	ifr_space	ifr_ifru.ifru_space	/* sockaddr_storage */
    596 #define	ifr_flags	ifr_ifru.ifru_flags	/* flags */
    597 #define	ifr_metric	ifr_ifru.ifru_metric	/* metric */
    598 #define	ifr_mtu		ifr_ifru.ifru_mtu	/* mtu */
    599 #define	ifr_dlt		ifr_ifru.ifru_dlt	/* data link type (DLT_*) */
    600 #define	ifr_value	ifr_ifru.ifru_value	/* generic value */
    601 #define	ifr_media	ifr_ifru.ifru_metric	/* media options (overload) */
    602 #define	ifr_data	ifr_ifru.ifru_data	/* for use by interface
    603 						 * XXX deprecated
    604 						 */
    605 #define	ifr_buf		ifr_ifru.ifru_b.b_buf	/* new interface ioctls */
    606 #define	ifr_buflen	ifr_ifru.ifru_b.b_buflen
    607 #define	ifr_index	ifr_ifru.ifru_value	/* interface index, BSD */
    608 #define	ifr_ifindex	ifr_index		/* interface index, linux */
    609 };
    610 
    611 #ifdef _KERNEL
    612 #define	ifreq_setdstaddr	ifreq_setaddr
    613 #define	ifreq_setbroadaddr	ifreq_setaddr
    614 #define	ifreq_getdstaddr	ifreq_getaddr
    615 #define	ifreq_getbroadaddr	ifreq_getaddr
    616 
    617 static inline const struct sockaddr *
    618 /*ARGSUSED*/
    619 ifreq_getaddr(u_long cmd, const struct ifreq *ifr)
    620 {
    621 	return &ifr->ifr_addr;
    622 }
    623 #endif /* _KERNEL */
    624 
    625 struct ifcapreq {
    626 	char		ifcr_name[IFNAMSIZ];	/* if name, e.g. "en0" */
    627 	uint64_t	ifcr_capabilities;	/* supported capabiliites */
    628 	uint64_t	ifcr_capenable;		/* capabilities enabled */
    629 };
    630 
    631 struct ifaliasreq {
    632 	char	ifra_name[IFNAMSIZ];		/* if name, e.g. "en0" */
    633 	struct	sockaddr ifra_addr;
    634 	struct	sockaddr ifra_dstaddr;
    635 #define	ifra_broadaddr	ifra_dstaddr
    636 	struct	sockaddr ifra_mask;
    637 };
    638 
    639 struct ifdatareq {
    640 	char	ifdr_name[IFNAMSIZ];		/* if name, e.g. "en0" */
    641 	struct	if_data ifdr_data;
    642 };
    643 
    644 struct ifmediareq {
    645 	char	ifm_name[IFNAMSIZ];		/* if name, e.g. "en0" */
    646 	int	ifm_current;			/* current media options */
    647 	int	ifm_mask;			/* don't care mask */
    648 	int	ifm_status;			/* media status */
    649 	int	ifm_active;			/* active options */
    650 	int	ifm_count;			/* # entries in ifm_ulist
    651 						   array */
    652 	int	*ifm_ulist;			/* media words */
    653 };
    654 
    655 
    656 struct  ifdrv {
    657 	char		ifd_name[IFNAMSIZ];	/* if name, e.g. "en0" */
    658 	unsigned long	ifd_cmd;
    659 	size_t		ifd_len;
    660 	void		*ifd_data;
    661 };
    662 #define IFLINKSTR_QUERYLEN	0x01
    663 #define IFLINKSTR_UNSET		0x02
    664 
    665 /*
    666  * Structure used in SIOCGIFCONF request.
    667  * Used to retrieve interface configuration
    668  * for machine (useful for programs which
    669  * must know all networks accessible).
    670  */
    671 struct	ifconf {
    672 	int	ifc_len;		/* size of associated buffer */
    673 	union {
    674 		void *	ifcu_buf;
    675 		struct	ifreq *ifcu_req;
    676 	} ifc_ifcu;
    677 #define	ifc_buf	ifc_ifcu.ifcu_buf	/* buffer address */
    678 #define	ifc_req	ifc_ifcu.ifcu_req	/* array of structures returned */
    679 };
    680 
    681 /*
    682  * Structure for SIOC[AGD]LIFADDR
    683  */
    684 struct if_laddrreq {
    685 	char iflr_name[IFNAMSIZ];
    686 	unsigned int flags;
    687 #define IFLR_PREFIX	0x8000	/* in: prefix given  out: kernel fills id */
    688 #define IFLR_ACTIVE	0x4000	/* in/out: link-layer address activation */
    689 #define IFLR_FACTORY	0x2000	/* in/out: factory link-layer address */
    690 	unsigned int prefixlen;		/* in/out */
    691 	struct sockaddr_storage addr;	/* in/out */
    692 	struct sockaddr_storage dstaddr; /* out */
    693 };
    694 
    695 /*
    696  * Structure for SIOC[SG]IFADDRPREF
    697  */
    698 struct if_addrprefreq {
    699 	char			ifap_name[IFNAMSIZ];
    700 	int16_t			ifap_preference;	/* in/out */
    701 	struct sockaddr_storage	ifap_addr;		/* in/out */
    702 };
    703 
    704 #include <net/if_arp.h>
    705 
    706 #endif /* _NETBSD_SOURCE */
    707 
    708 #ifdef _KERNEL
    709 #ifdef IFAREF_DEBUG
    710 #define	IFAREF(ifa)							\
    711 do {									\
    712 	printf("IFAREF: %s:%d %p -> %d\n", __FILE__, __LINE__,		\
    713 	    (ifa), ++(ifa)->ifa_refcnt);				\
    714 } while (/*CONSTCOND*/ 0)
    715 
    716 #define	IFAFREE(ifa)							\
    717 do {									\
    718 	if ((ifa)->ifa_refcnt <= 0)					\
    719 		panic("%s:%d: %p ifa_refcnt <= 0", __FILE__,		\
    720 		    __LINE__, (ifa));					\
    721 	printf("IFAFREE: %s:%d %p -> %d\n", __FILE__, __LINE__,		\
    722 	    (ifa), --(ifa)->ifa_refcnt);				\
    723 	if ((ifa)->ifa_refcnt == 0)					\
    724 		ifafree(ifa);						\
    725 } while (/*CONSTCOND*/ 0)
    726 #else
    727 #define	IFAREF(ifa)	(ifa)->ifa_refcnt++
    728 
    729 #ifdef DIAGNOSTIC
    730 #define	IFAFREE(ifa)							\
    731 do {									\
    732 	if ((ifa)->ifa_refcnt <= 0)					\
    733 		panic("%s:%d: %p ifa_refcnt <= 0", __FILE__,		\
    734 		    __LINE__, (ifa));					\
    735 	if (--(ifa)->ifa_refcnt == 0)					\
    736 		ifafree(ifa);						\
    737 } while (/*CONSTCOND*/ 0)
    738 #else
    739 #define	IFAFREE(ifa)							\
    740 do {									\
    741 	if (--(ifa)->ifa_refcnt == 0)					\
    742 		ifafree(ifa);						\
    743 } while (/*CONSTCOND*/ 0)
    744 #endif /* DIAGNOSTIC */
    745 #endif /* IFAREF_DEBUG */
    746 
    747 #ifdef ALTQ
    748 #define	ALTQ_DECL(x)		x
    749 #define ALTQ_COMMA		,
    750 
    751 #define IFQ_ENQUEUE(ifq, m, pattr, err)					\
    752 do {									\
    753 	if (ALTQ_IS_ENABLED((ifq)))					\
    754 		ALTQ_ENQUEUE((ifq), (m), (pattr), (err));		\
    755 	else {								\
    756 		if (IF_QFULL((ifq))) {					\
    757 			m_freem((m));					\
    758 			(err) = ENOBUFS;				\
    759 		} else {						\
    760 			IF_ENQUEUE((ifq), (m));				\
    761 			(err) = 0;					\
    762 		}							\
    763 	}								\
    764 	if ((err))							\
    765 		(ifq)->ifq_drops++;					\
    766 } while (/*CONSTCOND*/ 0)
    767 
    768 #define IFQ_DEQUEUE(ifq, m)						\
    769 do {									\
    770 	if (TBR_IS_ENABLED((ifq)))					\
    771 		(m) = tbr_dequeue((ifq), ALTDQ_REMOVE);			\
    772 	else if (ALTQ_IS_ENABLED((ifq)))				\
    773 		ALTQ_DEQUEUE((ifq), (m));				\
    774 	else								\
    775 		IF_DEQUEUE((ifq), (m));					\
    776 } while (/*CONSTCOND*/ 0)
    777 
    778 #define	IFQ_POLL(ifq, m)						\
    779 do {									\
    780 	if (TBR_IS_ENABLED((ifq)))					\
    781 		(m) = tbr_dequeue((ifq), ALTDQ_POLL);			\
    782 	else if (ALTQ_IS_ENABLED((ifq)))				\
    783 		ALTQ_POLL((ifq), (m));					\
    784 	else								\
    785 		IF_POLL((ifq), (m));					\
    786 } while (/*CONSTCOND*/ 0)
    787 
    788 #define	IFQ_PURGE(ifq)							\
    789 do {									\
    790 	if (ALTQ_IS_ENABLED((ifq)))					\
    791 		ALTQ_PURGE((ifq));					\
    792 	else								\
    793 		IF_PURGE((ifq));					\
    794 } while (/*CONSTCOND*/ 0)
    795 
    796 #define	IFQ_SET_READY(ifq)						\
    797 do {									\
    798 	(ifq)->altq_flags |= ALTQF_READY;				\
    799 } while (/*CONSTCOND*/ 0)
    800 
    801 #define	IFQ_CLASSIFY(ifq, m, af, pattr)					\
    802 do {									\
    803 	if (ALTQ_IS_ENABLED((ifq))) {					\
    804 		if (ALTQ_NEEDS_CLASSIFY((ifq)))				\
    805 			(pattr)->pattr_class = (*(ifq)->altq_classify)	\
    806 				((ifq)->altq_clfier, (m), (af));	\
    807 		(pattr)->pattr_af = (af);				\
    808 		(pattr)->pattr_hdr = mtod((m), void *);		\
    809 	}								\
    810 } while (/*CONSTCOND*/ 0)
    811 #else /* ! ALTQ */
    812 #define	ALTQ_DECL(x)		/* nothing */
    813 #define ALTQ_COMMA
    814 
    815 #define	IFQ_ENQUEUE(ifq, m, pattr, err)					\
    816 do {									\
    817 	if (IF_QFULL((ifq))) {						\
    818 		m_freem((m));						\
    819 		(err) = ENOBUFS;					\
    820 	} else {							\
    821 		IF_ENQUEUE((ifq), (m));					\
    822 		(err) = 0;						\
    823 	}								\
    824 	if ((err))							\
    825 		(ifq)->ifq_drops++;					\
    826 } while (/*CONSTCOND*/ 0)
    827 
    828 #define	IFQ_DEQUEUE(ifq, m)	IF_DEQUEUE((ifq), (m))
    829 
    830 #define	IFQ_POLL(ifq, m)	IF_POLL((ifq), (m))
    831 
    832 #define	IFQ_PURGE(ifq)		IF_PURGE((ifq))
    833 
    834 #define	IFQ_SET_READY(ifq)	/* nothing */
    835 
    836 #define	IFQ_CLASSIFY(ifq, m, af, pattr) /* nothing */
    837 
    838 #endif /* ALTQ */
    839 
    840 #define	IFQ_IS_EMPTY(ifq)		IF_IS_EMPTY((ifq))
    841 #define	IFQ_INC_LEN(ifq)		((ifq)->ifq_len++)
    842 #define	IFQ_DEC_LEN(ifq)		(--(ifq)->ifq_len)
    843 #define	IFQ_INC_DROPS(ifq)		((ifq)->ifq_drops++)
    844 #define	IFQ_SET_MAXLEN(ifq, len)	((ifq)->ifq_maxlen = (len))
    845 
    846 #include <sys/mallocvar.h>
    847 MALLOC_DECLARE(M_IFADDR);
    848 MALLOC_DECLARE(M_IFMADDR);
    849 
    850 int ifreq_setaddr(u_long, struct ifreq *, const struct sockaddr *);
    851 
    852 struct ifnet *if_alloc(u_char);
    853 void if_free(struct ifnet *);
    854 void if_initname(struct ifnet *, const char *, int);
    855 struct ifaddr *if_dl_create(const struct ifnet *, const struct sockaddr_dl **);
    856 void if_activate_sadl(struct ifnet *, struct ifaddr *,
    857     const struct sockaddr_dl *);
    858 void	if_set_sadl(struct ifnet *, const void *, u_char, bool);
    859 void	if_alloc_sadl(struct ifnet *);
    860 void	if_free_sadl(struct ifnet *);
    861 void	if_attach(struct ifnet *);
    862 void	if_attachdomain(void);
    863 void	if_attachdomain1(struct ifnet *);
    864 void	if_deactivate(struct ifnet *);
    865 void	if_purgeaddrs(struct ifnet *, int, void (*)(struct ifaddr *));
    866 void	if_detach(struct ifnet *);
    867 void	if_down(struct ifnet *);
    868 void	if_link_state_change(struct ifnet *, int);
    869 void	if_slowtimo(void *);
    870 void	if_up(struct ifnet *);
    871 int	ifconf(u_long, void *);
    872 void	ifinit(void);
    873 void	ifinit1(void);
    874 int	ifaddrpref_ioctl(struct socket *, u_long, void *, struct ifnet *,
    875     lwp_t *);
    876 extern int (*ifioctl)(struct socket *, u_long, void *, struct lwp *);
    877 int	ifioctl_common(struct ifnet *, u_long, void *);
    878 int	ifpromisc(struct ifnet *, int);
    879 struct	ifnet *ifunit(const char *);
    880 int	if_addr_init(ifnet_t *, struct ifaddr *, bool);
    881 int	if_mcast_op(ifnet_t *, const unsigned long, const struct sockaddr *);
    882 int	if_flags_set(struct ifnet *, const short);
    883 
    884 void ifa_insert(struct ifnet *, struct ifaddr *);
    885 void ifa_remove(struct ifnet *, struct ifaddr *);
    886 
    887 struct	ifaddr *ifa_ifwithaddr(const struct sockaddr *);
    888 struct	ifaddr *ifa_ifwithaf(int);
    889 struct	ifaddr *ifa_ifwithdstaddr(const struct sockaddr *);
    890 struct	ifaddr *ifa_ifwithnet(const struct sockaddr *);
    891 struct	ifaddr *ifa_ifwithladdr(const struct sockaddr *);
    892 struct	ifaddr *ifa_ifwithroute(int, const struct sockaddr *,
    893 					const struct sockaddr *);
    894 struct	ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *);
    895 void	ifafree(struct ifaddr *);
    896 void	link_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
    897 
    898 void	if_clone_attach(struct if_clone *);
    899 void	if_clone_detach(struct if_clone *);
    900 
    901 int	if_clone_create(const char *);
    902 int	if_clone_destroy(const char *);
    903 
    904 int	ifq_enqueue(struct ifnet *, struct mbuf * ALTQ_COMMA
    905     ALTQ_DECL(struct altq_pktattr *));
    906 int	ifq_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf * ALTQ_COMMA
    907     ALTQ_DECL(struct altq_pktattr *));
    908 
    909 int	loioctl(struct ifnet *, u_long, void *);
    910 void	loopattach(int);
    911 int	looutput(struct ifnet *,
    912 	   struct mbuf *, const struct sockaddr *, struct rtentry *);
    913 void	lortrequest(int, struct rtentry *, const struct rt_addrinfo *);
    914 
    915 /*
    916  * These are exported because they're an easy way to tell if
    917  * an interface is going away without having to burn a flag.
    918  */
    919 int	if_nulloutput(struct ifnet *, struct mbuf *,
    920 	    const struct sockaddr *, struct rtentry *);
    921 void	if_nullinput(struct ifnet *, struct mbuf *);
    922 void	if_nullstart(struct ifnet *);
    923 int	if_nullioctl(struct ifnet *, u_long, void *);
    924 int	if_nullinit(struct ifnet *);
    925 void	if_nullstop(struct ifnet *, int);
    926 void	if_nullwatchdog(struct ifnet *);
    927 void	if_nulldrain(struct ifnet *);
    928 #else
    929 struct if_nameindex {
    930 	unsigned int	if_index;	/* 1, 2, ... */
    931 	char		*if_name;	/* null terminated name: "le0", ... */
    932 };
    933 
    934 #include <sys/cdefs.h>
    935 __BEGIN_DECLS
    936 unsigned int if_nametoindex(const char *);
    937 char *	if_indextoname(unsigned int, char *);
    938 struct	if_nameindex * if_nameindex(void);
    939 void	if_freenameindex(struct if_nameindex *);
    940 __END_DECLS
    941 #endif /* _KERNEL */ /* XXX really ALTQ? */
    942 
    943 #ifdef _KERNEL
    944 
    945 #define	IFNET_FIRST()			TAILQ_FIRST(&ifnet_list)
    946 #define	IFNET_NEXT(__ifp)		TAILQ_NEXT((__ifp), if_list)
    947 #define	IFNET_FOREACH(__ifp)		TAILQ_FOREACH(__ifp, &ifnet_list, if_list)
    948 #define	IFADDR_FIRST(__ifp)		TAILQ_FIRST(&(__ifp)->if_addrlist)
    949 #define	IFADDR_NEXT(__ifa)		TAILQ_NEXT((__ifa), ifa_list)
    950 #define	IFADDR_FOREACH(__ifa, __ifp)	TAILQ_FOREACH(__ifa, \
    951 					    &(__ifp)->if_addrlist, ifa_list)
    952 #define	IFADDR_EMPTY(__ifp)		TAILQ_EMPTY(&(__ifp)->if_addrlist)
    953 
    954 extern struct ifnet_head ifnet_list;
    955 extern struct ifnet *lo0ifp;
    956 
    957 ifnet_t *	if_byindex(u_int);
    958 
    959 /*
    960  * ifq sysctl support
    961  */
    962 int	sysctl_ifq(int *name, u_int namelen, void *oldp,
    963 		       size_t *oldlenp, void *newp, size_t newlen,
    964 		       struct ifqueue *ifq);
    965 /* symbolic names for terminal (per-protocol) CTL_IFQ_ nodes */
    966 #define IFQCTL_LEN 1
    967 #define IFQCTL_MAXLEN 2
    968 #define IFQCTL_PEAK 3
    969 #define IFQCTL_DROPS 4
    970 #define IFQCTL_MAXID 5
    971 
    972 #endif /* _KERNEL */
    973 
    974 #ifdef _NETBSD_SOURCE
    975 /*
    976  * sysctl for ifq (per-protocol packet input queue variant of ifqueue)
    977  */
    978 #define CTL_IFQ_NAMES  { \
    979 	{ 0, 0 }, \
    980 	{ "len", CTLTYPE_INT }, \
    981 	{ "maxlen", CTLTYPE_INT }, \
    982 	{ "peak", CTLTYPE_INT }, \
    983 	{ "drops", CTLTYPE_INT }, \
    984 }
    985 #endif /* _NETBSD_SOURCE */
    986 #endif /* !_NET_IF_H_ */
    987