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