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