1/* 2 * Copyright (c) 2000-2012 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28/* 29 * Copyright (c) 1982, 1986, 1989, 1993 30 * The Regents of the University of California. All rights reserved. 31 * 32 * Redistribution and use in source and binary forms, with or without 33 * modification, are permitted provided that the following conditions 34 * are met: 35 * 1. Redistributions of source code must retain the above copyright 36 * notice, this list of conditions and the following disclaimer. 37 * 2. Redistributions in binary form must reproduce the above copyright 38 * notice, this list of conditions and the following disclaimer in the 39 * documentation and/or other materials provided with the distribution. 40 * 3. All advertising materials mentioning features or use of this software 41 * must display the following acknowledgement: 42 * This product includes software developed by the University of 43 * California, Berkeley and its contributors. 44 * 4. 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 * From: @(#)if.h 8.1 (Berkeley) 6/10/93 61 * $FreeBSD: src/sys/net/if_var.h,v 1.18.2.7 2001/07/24 19:10:18 brooks Exp $ 62 */ 63 64#ifndef _NET_IF_VAR_H_ 65#define _NET_IF_VAR_H_ 66 67#include <sys/appleapiopts.h> 68#include <stdint.h> 69#include <sys/types.h> 70#include <sys/time.h> 71#include <sys/queue.h> /* get TAILQ macros */ 72#ifdef KERNEL_PRIVATE 73#include <kern/locks.h> 74#endif /* KERNEL_PRIVATE */ 75#ifdef PRIVATE 76#include <net/route.h> 77#endif 78 79#ifdef KERNEL 80#include <net/kpi_interface.h> 81#endif /* KERNEL */ 82 83#ifdef __APPLE__ 84#define APPLE_IF_FAM_LOOPBACK 1 85#define APPLE_IF_FAM_ETHERNET 2 86#define APPLE_IF_FAM_SLIP 3 87#define APPLE_IF_FAM_TUN 4 88#define APPLE_IF_FAM_VLAN 5 89#define APPLE_IF_FAM_PPP 6 90#define APPLE_IF_FAM_PVC 7 91#define APPLE_IF_FAM_DISC 8 92#define APPLE_IF_FAM_MDECAP 9 93#define APPLE_IF_FAM_GIF 10 94#define APPLE_IF_FAM_FAITH 11 /* deprecated */ 95#define APPLE_IF_FAM_STF 12 96#define APPLE_IF_FAM_FIREWIRE 13 97#define APPLE_IF_FAM_BOND 14 98#endif /* __APPLE__ */ 99 100/* 101 * 72 was chosen below because it is the size of a TCP/IP 102 * header (40) + the minimum mss (32). 103 */ 104#define IF_MINMTU 72 105#define IF_MAXMTU 65535 106 107/* 108 * Structures defining a network interface, providing a packet 109 * transport mechanism (ala level 0 of the PUP protocols). 110 * 111 * Each interface accepts output datagrams of a specified maximum 112 * length, and provides higher level routines with input datagrams 113 * received from its medium. 114 * 115 * Output occurs when the routine if_output is called, with three parameters: 116 * (*ifp->if_output)(ifp, m, dst, rt) 117 * Here m is the mbuf chain to be sent and dst is the destination address. 118 * The output routine encapsulates the supplied datagram if necessary, 119 * and then transmits it on its medium. 120 * 121 * On input, each interface unwraps the data received by it, and either 122 * places it on the input queue of a internetwork datagram routine 123 * and posts the associated software interrupt, or passes the datagram to a raw 124 * packet input routine. 125 * 126 * Routines exist for locating interfaces by their addresses 127 * or for locating a interface on a certain network, as well as more general 128 * routing and gateway routines maintaining information used to locate 129 * interfaces. These routines live in the files if.c and route.c 130 */ 131 132#define IFNAMSIZ 16 133 134/* This belongs up in socket.h or socketvar.h, depending on how far the 135 * event bubbles up. 136 */ 137 138struct net_event_data { 139 u_int32_t if_family; 140 u_int32_t if_unit; 141 char if_name[IFNAMSIZ]; 142}; 143 144#if defined(__LP64__) 145#define __need_struct_timeval32 146#include <sys/_structs.h> 147#define IF_DATA_TIMEVAL timeval32 148#else 149#define IF_DATA_TIMEVAL timeval 150#endif 151 152#pragma pack(4) 153 154/* 155 * Structure describing information about an interface 156 * which may be of interest to management entities. 157 */ 158struct if_data { 159 /* generic interface information */ 160 u_char ifi_type; /* ethernet, tokenring, etc */ 161 u_char ifi_typelen; /* Length of frame type id */ 162 u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 163 u_char ifi_addrlen; /* media address length */ 164 u_char ifi_hdrlen; /* media header length */ 165 u_char ifi_recvquota; /* polling quota for receive intrs */ 166 u_char ifi_xmitquota; /* polling quota for xmit intrs */ 167 u_char ifi_unused1; /* for future use */ 168 u_int32_t ifi_mtu; /* maximum transmission unit */ 169 u_int32_t ifi_metric; /* routing metric (external only) */ 170 u_int32_t ifi_baudrate; /* linespeed */ 171 /* volatile statistics */ 172 u_int32_t ifi_ipackets; /* packets received on interface */ 173 u_int32_t ifi_ierrors; /* input errors on interface */ 174 u_int32_t ifi_opackets; /* packets sent on interface */ 175 u_int32_t ifi_oerrors; /* output errors on interface */ 176 u_int32_t ifi_collisions; /* collisions on csma interfaces */ 177 u_int32_t ifi_ibytes; /* total number of octets received */ 178 u_int32_t ifi_obytes; /* total number of octets sent */ 179 u_int32_t ifi_imcasts; /* packets received via multicast */ 180 u_int32_t ifi_omcasts; /* packets sent via multicast */ 181 u_int32_t ifi_iqdrops; /* dropped on input, this interface */ 182 u_int32_t ifi_noproto; /* destined for unsupported protocol */ 183 u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ 184 u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ 185 struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ 186 u_int32_t ifi_unused2; /* used to be the default_proto */ 187 u_int32_t ifi_hwassist; /* HW offload capabilities */ 188 u_int32_t ifi_reserved1; /* for future use */ 189 u_int32_t ifi_reserved2; /* for future use */ 190}; 191 192/* 193 * Structure describing information about an interface 194 * which may be of interest to management entities. 195 */ 196struct if_data64 { 197 /* generic interface information */ 198 u_char ifi_type; /* ethernet, tokenring, etc */ 199 u_char ifi_typelen; /* Length of frame type id */ 200 u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 201 u_char ifi_addrlen; /* media address length */ 202 u_char ifi_hdrlen; /* media header length */ 203 u_char ifi_recvquota; /* polling quota for receive intrs */ 204 u_char ifi_xmitquota; /* polling quota for xmit intrs */ 205 u_char ifi_unused1; /* for future use */ 206 u_int32_t ifi_mtu; /* maximum transmission unit */ 207 u_int32_t ifi_metric; /* routing metric (external only) */ 208 u_int64_t ifi_baudrate; /* linespeed */ 209 /* volatile statistics */ 210 u_int64_t ifi_ipackets; /* packets received on interface */ 211 u_int64_t ifi_ierrors; /* input errors on interface */ 212 u_int64_t ifi_opackets; /* packets sent on interface */ 213 u_int64_t ifi_oerrors; /* output errors on interface */ 214 u_int64_t ifi_collisions; /* collisions on csma interfaces */ 215 u_int64_t ifi_ibytes; /* total number of octets received */ 216 u_int64_t ifi_obytes; /* total number of octets sent */ 217 u_int64_t ifi_imcasts; /* packets received via multicast */ 218 u_int64_t ifi_omcasts; /* packets sent via multicast */ 219 u_int64_t ifi_iqdrops; /* dropped on input, this interface */ 220 u_int64_t ifi_noproto; /* destined for unsupported protocol */ 221 u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ 222 u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ 223 struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ 224}; 225 226#ifdef PRIVATE 227struct if_traffic_class { 228 u_int64_t ifi_ibepackets; /* TC_BE packets received on interface */ 229 u_int64_t ifi_ibebytes; /* TC_BE bytes received on interface */ 230 u_int64_t ifi_obepackets; /* TC_BE packet sent on interface */ 231 u_int64_t ifi_obebytes; /* TC_BE bytes sent on interface */ 232 u_int64_t ifi_ibkpackets; /* TC_BK packets received on interface */ 233 u_int64_t ifi_ibkbytes; /* TC_BK bytes received on interface */ 234 u_int64_t ifi_obkpackets; /* TC_BK packet sent on interface */ 235 u_int64_t ifi_obkbytes; /* TC_BK bytes sent on interface */ 236 u_int64_t ifi_ivipackets; /* TC_VI packets received on interface */ 237 u_int64_t ifi_ivibytes; /* TC_VI bytes received on interface */ 238 u_int64_t ifi_ovipackets; /* TC_VI packets sent on interface */ 239 u_int64_t ifi_ovibytes; /* TC_VI bytes sent on interface */ 240 u_int64_t ifi_ivopackets; /* TC_VO packets received on interface */ 241 u_int64_t ifi_ivobytes; /* TC_VO bytes received on interface */ 242 u_int64_t ifi_ovopackets; /* TC_VO packets sent on interface */ 243 u_int64_t ifi_ovobytes; /* TC_VO bytes sent on interface */ 244 u_int64_t ifi_ipvpackets; /* TC priv packets received on interface */ 245 u_int64_t ifi_ipvbytes; /* TC priv bytes received on interface */ 246 u_int64_t ifi_opvpackets; /* TC priv packets sent on interface */ 247 u_int64_t ifi_opvbytes; /* TC priv bytes sent on interface */ 248}; 249 250struct if_data_extended { 251 u_int64_t ifi_alignerrs; /* unaligned (32-bit) input pkts */ 252}; 253 254struct if_packet_stats { 255 /* TCP */ 256 u_int64_t ifi_tcp_badformat; 257 u_int64_t ifi_tcp_unspecv6; 258 u_int64_t ifi_tcp_synfin; 259 u_int64_t ifi_tcp_badformatipsec; 260 u_int64_t ifi_tcp_noconnnolist; 261 u_int64_t ifi_tcp_noconnlist; 262 u_int64_t ifi_tcp_listbadsyn; 263 u_int64_t ifi_tcp_icmp6unreach; 264 u_int64_t ifi_tcp_deprecate6; 265 u_int64_t ifi_tcp_rstinsynrcv; 266 u_int64_t ifi_tcp_ooopacket; 267 u_int64_t ifi_tcp_dospacket; 268 u_int64_t ifi_tcp_cleanup; 269 u_int64_t ifi_tcp_synwindow; 270 /* UDP */ 271 u_int64_t ifi_udp_port_unreach; 272 u_int64_t ifi_udp_faithprefix; 273 u_int64_t ifi_udp_port0; 274 u_int64_t ifi_udp_badlength; 275 u_int64_t ifi_udp_badchksum; 276 u_int64_t ifi_udp_badmcast; 277 u_int64_t ifi_udp_cleanup; 278 u_int64_t ifi_udp_badipsec; 279}; 280 281struct if_description { 282 u_int32_t ifd_maxlen; /* must be IF_DESCSIZE */ 283 u_int32_t ifd_len; /* actual ifd_desc length */ 284 u_int8_t *ifd_desc; /* ptr to desc buffer */ 285}; 286 287struct if_bandwidths { 288 u_int64_t eff_bw; /* effective bandwidth */ 289 u_int64_t max_bw; /* maximum theoretical bandwidth */ 290}; 291 292struct if_rxpoll_stats { 293 u_int32_t ifi_poll_off_req; /* total # of POLL_OFF reqs */ 294 u_int32_t ifi_poll_off_err; /* total # of POLL_OFF errors */ 295 u_int32_t ifi_poll_on_req; /* total # of POLL_ON reqs */ 296 u_int32_t ifi_poll_on_err; /* total # of POLL_ON errors */ 297 298 u_int32_t ifi_poll_wakeups_avg; /* avg # of wakeup reqs */ 299 u_int32_t ifi_poll_wakeups_lowat; /* wakeups low watermark */ 300 u_int32_t ifi_poll_wakeups_hiwat; /* wakeups high watermark */ 301 302 u_int64_t ifi_poll_packets; /* total # of polled packets */ 303 u_int32_t ifi_poll_packets_avg; /* average polled packets */ 304 u_int32_t ifi_poll_packets_min; /* smallest polled packets */ 305 u_int32_t ifi_poll_packets_max; /* largest polled packets */ 306 u_int32_t ifi_poll_packets_lowat; /* packets low watermark */ 307 u_int32_t ifi_poll_packets_hiwat; /* packets high watermark */ 308 309 u_int64_t ifi_poll_bytes; /* total # of polled bytes */ 310 u_int32_t ifi_poll_bytes_avg; /* average polled bytes */ 311 u_int32_t ifi_poll_bytes_min; /* smallest polled bytes */ 312 u_int32_t ifi_poll_bytes_max; /* largest polled bytes */ 313 u_int32_t ifi_poll_bytes_lowat; /* bytes low watermark */ 314 u_int32_t ifi_poll_bytes_hiwat; /* bytes high watermark */ 315}; 316#endif /* PRIVATE */ 317 318#pragma pack() 319 320/* 321 * Structure defining a queue for a network interface. 322 */ 323struct ifqueue { 324 void *ifq_head; 325 void *ifq_tail; 326 int ifq_len; 327 int ifq_maxlen; 328 int ifq_drops; 329}; 330 331#ifdef BSD_KERNEL_PRIVATE 332/* 333 * Internal storage of if_data. This is bound to change. Various places in the 334 * stack will translate this data structure in to the externally visible 335 * if_data structure above. Note that during interface attach time, the 336 * embedded if_data structure in ifnet is cleared, with the exception of 337 * some non-statistics related fields. 338 */ 339struct if_data_internal { 340 /* generic interface information */ 341 u_char ifi_type; /* ethernet, tokenring, etc */ 342 u_char ifi_typelen; /* Length of frame type id */ 343 u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ 344 u_char ifi_addrlen; /* media address length */ 345 u_char ifi_hdrlen; /* media header length */ 346 u_char ifi_recvquota; /* polling quota for receive intrs */ 347 u_char ifi_xmitquota; /* polling quota for xmit intrs */ 348 u_char ifi_unused1; /* for future use */ 349 u_int32_t ifi_mtu; /* maximum transmission unit */ 350 u_int32_t ifi_metric; /* routing metric (external only) */ 351 u_int32_t ifi_baudrate; /* linespeed */ 352 u_int32_t _pad; 353 /* volatile statistics */ 354 u_int64_t ifi_ipackets; /* packets received on interface */ 355 u_int64_t ifi_ierrors; /* input errors on interface */ 356 u_int64_t ifi_opackets; /* packets sent on interface */ 357 u_int64_t ifi_oerrors; /* output errors on interface */ 358 u_int64_t ifi_collisions; /* collisions on csma interfaces */ 359 u_int64_t ifi_ibytes; /* total number of octets received */ 360 u_int64_t ifi_obytes; /* total number of octets sent */ 361 u_int64_t ifi_imcasts; /* packets received via multicast */ 362 u_int64_t ifi_omcasts; /* packets sent via multicast */ 363 u_int64_t ifi_iqdrops; /* dropped on input, this interface */ 364 u_int64_t ifi_noproto; /* destined for unsupported protocol */ 365 u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ 366 u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ 367 u_int64_t ifi_alignerrs; /* unaligned (32-bit) input pkts */ 368#define IF_LASTCHANGEUPTIME 1 /* lastchange: 1-uptime 0-calendar time */ 369 struct timeval ifi_lastchange; /* time of last administrative change */ 370 u_int32_t ifi_hwassist; /* HW offload capabilities */ 371 u_int32_t ifi_tso_v4_mtu; /* TCP Segment Offload IPv4 maximum segment size */ 372 u_int32_t ifi_tso_v6_mtu; /* TCP Segment Offload IPv6 maximum segment size */ 373}; 374 375/* 376 * Fields per interface to measure perceived bandwidth. 377 */ 378 379struct if_measured_bw { 380 u_int64_t bw; /* measured bandwidth in bytes per ms */ 381 u_int64_t bytes; /* XXX not needed */ 382 u_int64_t ts; /* XXX not needed */ 383 u_int64_t cur_seq __attribute((aligned(8))); /* current sequence for marking a packet */ 384 u_int64_t start_ts; /* time at which a measurement started */ 385 u_int64_t start_seq; /* sequence at which a measurement should start */ 386 u_int64_t last_seq; /* last recorded seq */ 387 u_int64_t last_ts; /* last recorded ts */ 388 u_int32_t flags __attribute__((aligned(4))); /* flags */ 389#define IF_MEASURED_BW_INPROGRESS 0x1 390#define IF_MEASURED_BW_CALCULATION 0x2 391}; 392 393#endif /* BSD_KERNEL_PRIVATE */ 394 395#ifdef PRIVATE 396#define if_mtu if_data.ifi_mtu 397#define if_type if_data.ifi_type 398#define if_typelen if_data.ifi_typelen 399#define if_physical if_data.ifi_physical 400#define if_addrlen if_data.ifi_addrlen 401#define if_hdrlen if_data.ifi_hdrlen 402#define if_metric if_data.ifi_metric 403#define if_baudrate if_data.ifi_baudrate 404#define if_hwassist if_data.ifi_hwassist 405#define if_ipackets if_data.ifi_ipackets 406#define if_ierrors if_data.ifi_ierrors 407#define if_opackets if_data.ifi_opackets 408#define if_oerrors if_data.ifi_oerrors 409#define if_collisions if_data.ifi_collisions 410#define if_ibytes if_data.ifi_ibytes 411#define if_obytes if_data.ifi_obytes 412#define if_imcasts if_data.ifi_imcasts 413#define if_omcasts if_data.ifi_omcasts 414#define if_iqdrops if_data.ifi_iqdrops 415#define if_noproto if_data.ifi_noproto 416#define if_lastchange if_data.ifi_lastchange 417#define if_recvquota if_data.ifi_recvquota 418#define if_xmitquota if_data.ifi_xmitquota 419#endif /* PRIVATE */ 420#ifdef BSD_KERNEL_PRIVATE 421#define if_tso_v4_mtu if_data.ifi_tso_v4_mtu 422#define if_tso_v6_mtu if_data.ifi_tso_v6_mtu 423#define if_alignerrs if_data.ifi_alignerrs 424#endif /* BSD_KERNEL_PRIVATE */ 425 426#ifdef BSD_KERNEL_PRIVATE 427/* 428 * Forward structure declarations for function prototypes [sic]. 429 */ 430struct proc; 431struct rtentry; 432struct socket; 433struct ifnet_filter; 434struct mbuf; 435struct ifaddr; 436struct tqdummy; 437struct proto_hash_entry; 438struct dlil_threading_info; 439struct tcpstat_local; 440struct udpstat_local; 441#if PF 442struct pfi_kif; 443#endif /* PF */ 444 445/* we use TAILQs so that the order of instantiation is preserved in the list */ 446TAILQ_HEAD(ifnethead, ifnet); 447TAILQ_HEAD(ifaddrhead, ifaddr); 448TAILQ_HEAD(ifprefixhead, ifprefix); 449LIST_HEAD(ifmultihead, ifmultiaddr); 450TAILQ_HEAD(tailq_head, tqdummy); 451TAILQ_HEAD(ifnet_filter_head, ifnet_filter); 452TAILQ_HEAD(ddesc_head_name, dlil_demux_desc); 453#endif /* BSD_KERNEL_PRIVATE */ 454 455#ifdef PRIVATE 456/* 457 * All of the following IF_HWASSIST_* flags are defined in kpi_inteface.h as 458 * IFNET_* flags. These are redefined here as constants to avoid failures to 459 * build user level programs that can not include kpi_interface.h. It is 460 * important to keep this in sync with the definitions in kpi_interface.h. 461 * The corresponding constant for each definition is mentioned in the comment. 462 * 463 * Bottom 16 bits reserved for hardware checksum 464 */ 465#define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP, IFNET_CSUM_IP */ 466#define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP, IFNET_CSUM_TCP */ 467#define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP, IFNET_CSUM_UDP */ 468#define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments, IFNET_CSUM_FRAGMENT */ 469#define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation, IFNET_IP_FRAGMENT */ 470#define IF_HWASSIST_CSUM_TCPIPV6 0x0020 /* will csum TCPv6, IFNET_CSUM_TCPIPV6 */ 471#define IF_HWASSIST_CSUM_UDPIPV6 0x0040 /* will csum UDPv6, IFNET_CSUM_UDP */ 472#define IF_HWASSIST_CSUM_FRAGMENT_IPV6 0x0080 /* will do IPv6 fragmentation, IFNET_IPV6_FRAGMENT */ 473#define IF_HWASSIST_CSUM_TCP_SUM16 0x1000 /* simple TCP Sum16 computation, IFNET_CSUM_SUM16 */ 474#define IF_HWASSIST_CSUM_MASK 0xffff 475#define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK) 476 477/* VLAN support */ 478#define IF_HWASSIST_VLAN_TAGGING 0x00010000 /* supports VLAN tagging, IFNET_VLAN_TAGGING */ 479#define IF_HWASSIST_VLAN_MTU 0x00020000 /* supports VLAN MTU-sized packet (for software VLAN), IFNET_VLAN_MTU */ 480 481/* TCP Segment Offloading support */ 482 483#define IF_HWASSIST_TSO_V4 0x00200000 /* will do TCP Segment offload for IPv4, IFNET_TSO_IPV4 */ 484#define IF_HWASSIST_TSO_V6 0x00400000 /* will do TCP Segment offload for IPv6, IFNET_TSO_IPV6 */ 485#endif /* PRIVATE */ 486 487#ifdef BSD_KERNEL_PRIVATE 488/* 489 * ifnet is private to BSD portion of kernel 490 */ 491#include <sys/tree.h> 492#include <netinet/in.h> 493#include <net/classq/if_classq.h> 494 495RB_HEAD(ll_reach_tree, if_llreach); /* define struct ll_reach_tree */ 496 497/* 498 * Structure defining a network interface. 499 * 500 * (Would like to call this struct ``if'', but C isn't PL/1.) 501 */ 502struct ifnet { 503 /* 504 * Lock (RW or mutex) to protect this data structure (static storage.) 505 */ 506 decl_lck_rw_data(, if_lock); 507 void *if_softc; /* pointer to driver state */ 508 const char *if_name; /* name, e.g. ``en'' or ``lo'' */ 509 struct if_description if_desc; /* extended description */ 510 TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ 511 TAILQ_ENTRY(ifnet) if_detaching_link; /* list of detaching ifnets */ 512 513 decl_lck_mtx_data(, if_ref_lock) 514 u_int32_t if_refflags; 515 u_int32_t if_refio; /* number of io ops to the underlying driver */ 516 517#define if_list if_link 518 struct ifaddrhead if_addrhead; /* linked list of addresses per if */ 519#define if_addrlist if_addrhead 520 struct ifaddr *if_lladdr; /* link address (first/permanent) */ 521 522 int if_pcount; /* number of promiscuous listeners */ 523 struct bpf_if *if_bpf; /* packet filter structure */ 524 u_short if_index; /* numeric abbreviation for this if */ 525 short if_unit; /* sub-unit for lower level driver */ 526 short if_timer; /* time 'til if_watchdog called */ 527 short if_flags; /* up/down, broadcast, etc. */ 528 u_int32_t if_eflags; /* see <net/if.h> */ 529 530 int if_capabilities; /* interface features & capabilities */ 531 int if_capenable; /* enabled features & capabilities */ 532 533 void *if_linkmib; /* link-type-specific MIB data */ 534 size_t if_linkmiblen; /* length of above data */ 535 536 struct if_data_internal if_data __attribute__((aligned(8))); 537 538 ifnet_family_t if_family; /* value assigned by Apple */ 539 uintptr_t if_family_cookie; 540 ifnet_output_func if_output; 541 ifnet_pre_enqueue_func if_pre_enqueue; 542 ifnet_start_func if_start; 543 ifnet_ctl_func if_output_ctl; 544 ifnet_input_poll_func if_input_poll; 545 ifnet_ctl_func if_input_ctl; 546 ifnet_ioctl_func if_ioctl; 547 ifnet_set_bpf_tap if_set_bpf_tap; 548 ifnet_detached_func if_free; 549 ifnet_demux_func if_demux; 550 ifnet_event_func if_event; 551 ifnet_framer_func if_framer; 552 ifnet_add_proto_func if_add_proto; 553 ifnet_del_proto_func if_del_proto; 554 ifnet_check_multi if_check_multi; 555 struct proto_hash_entry *if_proto_hash; 556 void *if_kpi_storage; 557 558 decl_lck_mtx_data(, if_start_lock); 559 u_int32_t if_start_req; 560 u_int32_t if_start_active; /* output is active */ 561 struct timespec if_start_cycle; /* restart interval */ 562 struct thread *if_start_thread; 563 564 struct ifclassq if_snd; /* transmit queue */ 565 u_int32_t if_output_sched_model; /* tx sched model */ 566 567 struct if_bandwidths if_output_bw; 568 struct if_bandwidths if_input_bw; 569 570 decl_lck_mtx_data(, if_flt_lock) 571 u_int32_t if_flt_busy; 572 u_int32_t if_flt_waiters; 573 struct ifnet_filter_head if_flt_head; 574 575 struct ifmultihead if_multiaddrs; /* multicast addresses */ 576 u_int32_t if_updatemcasts; /* mcast addrs need updating */ 577 int if_amcount; /* # of all-multicast reqs */ 578 decl_lck_mtx_data(, if_addrconfig_lock); /* for serializing addr config */ 579 struct in_multi *if_allhostsinm; /* store all-hosts inm for this ifp */ 580 581 decl_lck_mtx_data(, if_poll_lock); 582 u_int16_t if_poll_req; 583 u_int16_t if_poll_update; /* link update */ 584 u_int32_t if_poll_active; /* polling is active */ 585 struct timespec if_poll_cycle; /* poll interval */ 586 struct thread *if_poll_thread; 587 588 struct dlil_threading_info *if_inp; 589 590 struct ifprefixhead if_prefixhead; /* list of prefixes per if */ 591 struct { 592 u_int32_t length; 593 union { 594 u_char buffer[8]; 595 u_char *ptr; 596 } u; 597 } if_broadcast; 598#if CONFIG_MACF_NET 599 struct label *if_label; /* interface MAC label */ 600#endif 601 602 u_int32_t if_wake_properties; 603#if PF 604 struct pfi_kif *if_pf_kif; 605#endif /* PF */ 606 607 decl_lck_mtx_data(, if_cached_route_lock); 608 u_int32_t if_fwd_cacheok; 609 struct route if_fwd_route; /* cached forwarding route */ 610 struct route if_src_route; /* cached ipv4 source route */ 611 struct route_in6 if_src_route6; /* cached ipv6 source route */ 612 613 decl_lck_rw_data(, if_llreach_lock); 614 struct ll_reach_tree if_ll_srcs; /* source link-layer tree */ 615 616 void *if_bridge; /* bridge glue */ 617 618 u_int32_t if_want_aggressive_drain; 619 u_int32_t if_idle_flags; /* idle flags */ 620 u_int32_t if_idle_new_flags; /* temporary idle flags */ 621 u_int32_t if_idle_new_flags_mask; /* temporary mask */ 622 u_int32_t if_route_refcnt; /* idle: route ref count */ 623 624 struct if_traffic_class if_tc __attribute__((aligned(8))); 625#if INET 626 struct igmp_ifinfo *if_igi; /* for IGMPv3 */ 627#endif /* INET */ 628#if INET6 629 struct mld_ifinfo *if_mli; /* for MLDv2 */ 630#endif /* INET6 */ 631 632 int if_lqm; /* link quality metric */ 633 struct if_measured_bw if_bw; 634 struct tcpstat_local *if_tcp_stat; /* TCP specific stats */ 635 struct udpstat_local *if_udp_stat; /* UDP specific stats */ 636}; 637 638/* 639 * Valid values for if_useflags 640 */ 641#define IFRF_ATTACHED 0x1 /* ifnet attach is completely done */ 642#define IFRF_DETACHING 0x2 /* detach has been requested */ 643 644/* 645 * Structure describing a `cloning' interface. 646 */ 647struct if_clone { 648 LIST_ENTRY(if_clone) ifc_list; /* on list of cloners */ 649 const char *ifc_name; /* name of device, e.g. `vlan' */ 650 size_t ifc_namelen; /* length of name */ 651 u_int32_t ifc_minifs; /* minimum number of interfaces */ 652 u_int32_t ifc_maxunit; /* maximum unit number */ 653 unsigned char *ifc_units; /* bitmap to handle units */ 654 u_int32_t ifc_bmlen; /* bitmap length */ 655 656 int (*ifc_create)(struct if_clone *, u_int32_t, void *); 657 int (*ifc_destroy)(struct ifnet *); 658}; 659 660#define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit) { \ 661 { NULL, NULL }, name, (sizeof (name) - 1), minifs, maxunit, NULL, 0, \ 662 create, destroy \ 663} 664 665#define M_CLONE M_IFADDR 666 667/* 668 * Macros to manipulate ifqueue. Users of these macros are responsible 669 * for serialization, by holding whatever lock is appropriate for the 670 * corresponding structure that is referring the ifqueue. 671 */ 672#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen) 673#define IF_DROP(ifq) ((ifq)->ifq_drops++) 674 675#define IF_ENQUEUE(ifq, m) do { \ 676 (m)->m_nextpkt = NULL; \ 677 if ((ifq)->ifq_tail == NULL) \ 678 (ifq)->ifq_head = m; \ 679 else \ 680 ((struct mbuf*)(ifq)->ifq_tail)->m_nextpkt = m; \ 681 (ifq)->ifq_tail = m; \ 682 (ifq)->ifq_len++; \ 683} while (0) 684 685#define IF_PREPEND(ifq, m) do { \ 686 (m)->m_nextpkt = (ifq)->ifq_head; \ 687 if ((ifq)->ifq_tail == NULL) \ 688 (ifq)->ifq_tail = (m); \ 689 (ifq)->ifq_head = (m); \ 690 (ifq)->ifq_len++; \ 691} while (0) 692 693#define IF_DEQUEUE(ifq, m) do { \ 694 (m) = (ifq)->ifq_head; \ 695 if (m != NULL) { \ 696 if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \ 697 (ifq)->ifq_tail = NULL; \ 698 (m)->m_nextpkt = NULL; \ 699 (ifq)->ifq_len--; \ 700 } \ 701} while (0) 702 703#define IF_REMQUEUE(ifq, m) do { \ 704 struct mbuf *_p = (ifq)->ifq_head; \ 705 struct mbuf *_n = (m)->m_nextpkt; \ 706 if ((m) == _p) \ 707 _p = NULL; \ 708 while (_p != NULL) { \ 709 if (_p->m_nextpkt == (m)) \ 710 break; \ 711 _p = _p->m_nextpkt; \ 712 } \ 713 VERIFY(_p != NULL || ((m) == (ifq)->ifq_head)); \ 714 if ((m) == (ifq)->ifq_head) \ 715 (ifq)->ifq_head = _n; \ 716 if ((m) == (ifq)->ifq_tail) \ 717 (ifq)->ifq_tail = _p; \ 718 VERIFY((ifq)->ifq_tail != NULL || (ifq)->ifq_head == NULL); \ 719 VERIFY((ifq)->ifq_len != 0); \ 720 --(ifq)->ifq_len; \ 721 if (_p != NULL) \ 722 _p->m_nextpkt = _n; \ 723 (m)->m_nextpkt = NULL; \ 724} while (0) 725 726#define IF_DRAIN(ifq) do { \ 727 struct mbuf *_m; \ 728 for (;;) { \ 729 IF_DEQUEUE(ifq, _m); \ 730 if (_m == NULL) \ 731 break; \ 732 m_freem(_m); \ 733 } \ 734} while (0) 735 736/* 737 * The ifaddr structure contains information about one address 738 * of an interface. They are maintained by the different address families, 739 * are allocated and attached when an address is set, and are linked 740 * together so all addresses for an interface can be located. 741 */ 742struct ifaddr { 743 decl_lck_mtx_data(, ifa_lock); /* lock for ifaddr */ 744 uint32_t ifa_refcnt; /* ref count, use IFA_{ADD,REM}REF */ 745 uint32_t ifa_debug; /* debug flags */ 746 struct sockaddr *ifa_addr; /* address of interface */ 747 struct sockaddr *ifa_dstaddr; /* other end of p-to-p link */ 748#define ifa_broadaddr ifa_dstaddr /* broadcast address interface */ 749 struct sockaddr *ifa_netmask; /* used to determine subnet */ 750 struct ifnet *ifa_ifp; /* back-pointer to interface */ 751 TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ 752 void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ 753 (int, struct rtentry *, struct sockaddr *); 754 uint32_t ifa_flags; /* mostly rt_flags for cloning */ 755 int32_t ifa_metric; /* cost of going out this interface */ 756 void (*ifa_free)(struct ifaddr *); /* callback fn for freeing */ 757 void (*ifa_trace) /* callback fn for tracing refs */ 758 (struct ifaddr *, int); 759 void (*ifa_attached)(struct ifaddr *); /* callback fn for attaching */ 760 void (*ifa_detached)(struct ifaddr *); /* callback fn for detaching */ 761}; 762 763/* 764 * Valid values for ifa_flags 765 */ 766#define IFA_ROUTE RTF_UP /* route installed (0x1) */ 767#define IFA_CLONING RTF_CLONING /* (0x100) */ 768 769/* 770 * Valid values for ifa_debug 771 */ 772#define IFD_ATTACHED 0x1 /* attached to list */ 773#define IFD_ALLOC 0x2 /* dynamically allocated */ 774#define IFD_DEBUG 0x4 /* has debugging info */ 775#define IFD_LINK 0x8 /* link address */ 776#define IFD_TRASHED 0x10 /* in trash list */ 777#define IFD_SKIP 0x20 /* skip this entry */ 778#define IFD_NOTREADY 0x40 /* embryonic; not yet ready */ 779 780#define IFA_LOCK_ASSERT_HELD(_ifa) \ 781 lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_OWNED) 782 783#define IFA_LOCK_ASSERT_NOTHELD(_ifa) \ 784 lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_NOTOWNED) 785 786#define IFA_LOCK(_ifa) \ 787 lck_mtx_lock(&(_ifa)->ifa_lock) 788 789#define IFA_LOCK_SPIN(_ifa) \ 790 lck_mtx_lock_spin(&(_ifa)->ifa_lock) 791 792#define IFA_CONVERT_LOCK(_ifa) do { \ 793 IFA_LOCK_ASSERT_HELD(_ifa); \ 794 lck_mtx_convert_spin(&(_ifa)->ifa_lock); \ 795} while (0) 796 797#define IFA_UNLOCK(_ifa) \ 798 lck_mtx_unlock(&(_ifa)->ifa_lock) 799 800#define IFA_ADDREF(_ifa) \ 801 ifa_addref(_ifa, 0) 802 803#define IFA_ADDREF_LOCKED(_ifa) \ 804 ifa_addref(_ifa, 1) 805 806#define IFA_REMREF(_ifa) do { \ 807 (void) ifa_remref(_ifa, 0); \ 808} while (0) 809 810#define IFA_REMREF_LOCKED(_ifa) \ 811 ifa_remref(_ifa, 1) 812 813/* 814 * The prefix structure contains information about one prefix 815 * of an interface. They are maintained by the different address families, 816 * are allocated and attached when an prefix or an address is set, 817 * and are linked together so all prefixes for an interface can be located. 818 */ 819struct ifprefix { 820 struct sockaddr *ifpr_prefix; /* prefix of interface */ 821 struct ifnet *ifpr_ifp; /* back-pointer to interface */ 822 TAILQ_ENTRY(ifprefix) ifpr_list; /* queue macro glue */ 823 u_char ifpr_plen; /* prefix length in bits */ 824 u_char ifpr_type; /* protocol dependent prefix type */ 825}; 826 827/* 828 * Multicast address structure. This is analogous to the ifaddr 829 * structure except that it keeps track of multicast addresses. 830 * Also, the request count here is a count of requests for this 831 * address, not a count of pointers to this structure; anonymous 832 * membership(s) holds one outstanding request count. 833 */ 834struct ifmultiaddr { 835 decl_lck_mtx_data(, ifma_lock); 836 u_int32_t ifma_refcount; /* reference count */ 837 u_int32_t ifma_anoncnt; /* # of anonymous requests */ 838 u_int32_t ifma_reqcnt; /* total requests for this address */ 839 u_int32_t ifma_debug; /* see ifa_debug flags */ 840 u_int32_t ifma_flags; /* see below */ 841 LIST_ENTRY(ifmultiaddr) ifma_link; /* queue macro glue */ 842 struct sockaddr *ifma_addr; /* address this membership is for */ 843 struct ifmultiaddr *ifma_ll; /* link-layer translation, if any */ 844 struct ifnet *ifma_ifp; /* back-pointer to interface */ 845 void *ifma_protospec; /* protocol-specific state, if any */ 846 void (*ifma_trace) /* callback fn for tracing refs */ 847 (struct ifmultiaddr *, int); 848}; 849 850/* 851 * Values for ifma_flags 852 */ 853#define IFMAF_ANONYMOUS 0x1 /* has anonymous request ref(s) held */ 854 855#define IFMA_LOCK_ASSERT_HELD(_ifma) \ 856 lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_OWNED) 857 858#define IFMA_LOCK_ASSERT_NOTHELD(_ifma) \ 859 lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_NOTOWNED) 860 861#define IFMA_LOCK(_ifma) \ 862 lck_mtx_lock(&(_ifma)->ifma_lock) 863 864#define IFMA_LOCK_SPIN(_ifma) \ 865 lck_mtx_lock_spin(&(_ifma)->ifma_lock) 866 867#define IFMA_CONVERT_LOCK(_ifma) do { \ 868 IFMA_LOCK_ASSERT_HELD(_ifma); \ 869 lck_mtx_convert_spin(&(_ifma)->ifma_lock); \ 870} while (0) 871 872#define IFMA_UNLOCK(_ifma) \ 873 lck_mtx_unlock(&(_ifma)->ifma_lock) 874 875#define IFMA_ADDREF(_ifma) \ 876 ifma_addref(_ifma, 0) 877 878#define IFMA_ADDREF_LOCKED(_ifma) \ 879 ifma_addref(_ifma, 1) 880 881#define IFMA_REMREF(_ifma) \ 882 ifma_remref(_ifma) 883 884__private_extern__ struct ifnethead ifnet_head; 885__private_extern__ struct ifnet **ifindex2ifnet; 886__private_extern__ u_int32_t if_sndq_maxlen; 887__private_extern__ u_int32_t if_rcvq_maxlen; 888__private_extern__ int if_index; 889__private_extern__ struct ifaddr **ifnet_addrs; 890__private_extern__ lck_attr_t *ifa_mtx_attr; 891__private_extern__ lck_grp_t *ifa_mtx_grp; 892__private_extern__ lck_grp_t *ifnet_lock_group; 893__private_extern__ lck_attr_t *ifnet_lock_attr; 894extern ifnet_t lo_ifp; 895extern uint32_t if_bw_measure_size; 896extern u_int32_t if_bw_smoothing_val; 897 898extern int if_addmulti(struct ifnet *, const struct sockaddr *, 899 struct ifmultiaddr **); 900extern int if_addmulti_anon(struct ifnet *, const struct sockaddr *, 901 struct ifmultiaddr **); 902extern int if_allmulti(struct ifnet *, int); 903extern int if_delmulti(struct ifnet *, const struct sockaddr *); 904extern int if_delmulti_ifma(struct ifmultiaddr *); 905extern int if_delmulti_anon(struct ifnet *, const struct sockaddr *); 906extern void if_down(struct ifnet *); 907extern int if_down_all(void); 908extern void if_up(struct ifnet *); 909__private_extern__ void if_updown(struct ifnet *ifp, int up); 910extern int ifioctl(struct socket *, u_long, caddr_t, struct proc *); 911extern int ifioctllocked(struct socket *, u_long, caddr_t, struct proc *); 912extern struct ifnet *ifunit(const char *); 913extern struct ifnet *if_withname(struct sockaddr *); 914extern void if_qflush(struct ifnet *, int); 915extern void if_qflush_sc(struct ifnet *, mbuf_svc_class_t, u_int32_t, 916 u_int32_t *, u_int32_t *, int); 917 918extern struct if_clone *if_clone_lookup(const char *, u_int32_t *); 919extern int if_clone_attach(struct if_clone *); 920extern void if_clone_detach(struct if_clone *); 921 922extern errno_t if_mcasts_update(struct ifnet *); 923 924typedef enum { 925 IFNET_LCK_ASSERT_EXCLUSIVE, /* RW: held as writer */ 926 IFNET_LCK_ASSERT_SHARED, /* RW: held as reader */ 927 IFNET_LCK_ASSERT_OWNED, /* RW: writer/reader, MTX: held */ 928 IFNET_LCK_ASSERT_NOTOWNED /* not held */ 929} ifnet_lock_assert_t; 930 931__private_extern__ void ifnet_lock_assert(struct ifnet *, ifnet_lock_assert_t); 932__private_extern__ void ifnet_lock_shared(struct ifnet *ifp); 933__private_extern__ void ifnet_lock_exclusive(struct ifnet *ifp); 934__private_extern__ void ifnet_lock_done(struct ifnet *ifp); 935 936__private_extern__ void ifnet_head_lock_shared(void); 937__private_extern__ void ifnet_head_lock_exclusive(void); 938__private_extern__ void ifnet_head_done(void); 939 940__private_extern__ errno_t ifnet_set_idle_flags_locked(ifnet_t, u_int32_t, 941 u_int32_t); 942__private_extern__ int ifnet_is_attached(struct ifnet *, int refio); 943__private_extern__ void ifnet_decr_iorefcnt(struct ifnet *); 944__private_extern__ void ifnet_set_start_cycle(struct ifnet *, 945 struct timespec *); 946__private_extern__ void ifnet_set_poll_cycle(struct ifnet *, 947 struct timespec *); 948 949__private_extern__ void if_attach_ifa(struct ifnet *, struct ifaddr *); 950__private_extern__ void if_attach_link_ifa(struct ifnet *, struct ifaddr *); 951__private_extern__ void if_detach_ifa(struct ifnet *, struct ifaddr *); 952__private_extern__ void if_detach_link_ifa(struct ifnet *, struct ifaddr *); 953 954__private_extern__ void dlil_if_lock(void); 955__private_extern__ void dlil_if_unlock(void); 956__private_extern__ void dlil_if_lock_assert(void); 957 958extern struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); 959extern struct ifaddr *ifa_ifwithaddr_scoped(const struct sockaddr *, 960 unsigned int); 961extern struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); 962extern struct ifaddr *ifa_ifwithnet(const struct sockaddr *); 963extern struct ifaddr *ifa_ifwithnet_scoped(const struct sockaddr *, 964 unsigned int); 965extern struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *, 966 const struct sockaddr *); 967extern struct ifaddr *ifa_ifwithroute_locked(int, const struct sockaddr *, 968 const struct sockaddr *); 969extern struct ifaddr *ifa_ifwithroute_scoped_locked(int, 970 const struct sockaddr *, const struct sockaddr *, unsigned int); 971extern struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); 972__private_extern__ struct ifaddr *ifa_ifpgetprimary(struct ifnet *, int); 973extern void ifa_addref(struct ifaddr *, int); 974extern struct ifaddr *ifa_remref(struct ifaddr *, int); 975extern void ifa_lock_init(struct ifaddr *); 976extern void ifa_lock_destroy(struct ifaddr *); 977extern void ifma_addref(struct ifmultiaddr *, int); 978extern void ifma_remref(struct ifmultiaddr *); 979 980extern void ifa_init(void); 981 982__private_extern__ struct in_ifaddr *ifa_foraddr(unsigned int); 983__private_extern__ struct in_ifaddr *ifa_foraddr_scoped(unsigned int, 984 unsigned int); 985 986extern void ifnet_fclist_append(struct sfb *sp, struct sfb_fc_list *fcl); 987extern struct sfb_bin_fcentry* ifnet_fce_alloc(int how); 988extern void ifnet_fce_free(struct sfb_bin_fcentry *); 989 990struct ifreq; 991extern errno_t ifnet_getset_opportunistic(struct ifnet *, u_long, 992 struct ifreq *, struct proc *); 993extern int ifnet_get_throttle(struct ifnet *, u_int32_t *); 994extern int ifnet_set_throttle(struct ifnet *, u_int32_t); 995 996#if INET6 997struct in6_addr; 998__private_extern__ struct in6_ifaddr *ifa_foraddr6(struct in6_addr *); 999__private_extern__ struct in6_ifaddr *ifa_foraddr6_scoped(struct in6_addr *, 1000 unsigned int); 1001#endif /* INET6 */ 1002 1003__private_extern__ void if_data_internal_to_if_data(struct ifnet *ifp, 1004 const struct if_data_internal *if_data_int, struct if_data *if_data); 1005__private_extern__ void if_data_internal_to_if_data64(struct ifnet *ifp, 1006 const struct if_data_internal *if_data_int, struct if_data64 *if_data64); 1007__private_extern__ void if_copy_traffic_class(struct ifnet *ifp, 1008 struct if_traffic_class *if_tc); 1009__private_extern__ void if_copy_data_extended(struct ifnet *ifp, 1010 struct if_data_extended *if_de); 1011__private_extern__ void if_copy_packet_stats(struct ifnet *ifp, 1012 struct if_packet_stats *if_ps); 1013__private_extern__ void if_copy_rxpoll_stats(struct ifnet *ifp, 1014 struct if_rxpoll_stats *if_rs); 1015 1016__private_extern__ struct rtentry *ifnet_cached_rtlookup_inet(struct ifnet *, 1017 struct in_addr); 1018#if INET6 1019__private_extern__ struct rtentry *ifnet_cached_rtlookup_inet6(struct ifnet *, 1020 struct in6_addr *); 1021#endif /* INET6 */ 1022 1023__private_extern__ void if_lqm_update(struct ifnet *, int32_t); 1024__private_extern__ void ifnet_update_sndq(struct ifclassq *, cqev_t); 1025__private_extern__ void ifnet_update_rcv(struct ifnet *, cqev_t); 1026 1027__private_extern__ errno_t ifnet_set_input_bandwidths(struct ifnet *, 1028 struct if_bandwidths *); 1029__private_extern__ errno_t ifnet_set_output_bandwidths(struct ifnet *, 1030 struct if_bandwidths *, boolean_t); 1031__private_extern__ u_int64_t ifnet_output_linkrate(struct ifnet *); 1032__private_extern__ u_int64_t ifnet_input_linkrate(struct ifnet *); 1033#endif /* BSD_KERNEL_PRIVATE */ 1034#ifdef XNU_KERNEL_PRIVATE 1035/* for uuid.c */ 1036__private_extern__ int uuid_get_ethernet(u_int8_t *); 1037#endif /* XNU_KERNEL_PRIVATE */ 1038#endif /* !_NET_IF_VAR_H_ */ 1039