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