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