2 * Copyright (c) 2000-2013 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1982, 1986, 1989, 1993
30 * The Regents of the University of California. All rights reserved.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
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.
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
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 $
64 #ifndef _NET_IF_VAR_H_
65 #define _NET_IF_VAR_H_
67 #include <sys/appleapiopts.h>
69 #include <sys/types.h>
71 #include <sys/queue.h> /* get TAILQ macros */
73 #include <kern/locks.h>
74 #endif /* KERNEL_PRIVATE */
76 #include <net/route.h>
80 #include <net/kpi_interface.h>
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__ */
101 * 72 was chosen below because it is the size of a TCP/IP
102 * header (40) + the minimum mss (32).
105 #define IF_MAXMTU 65535
108 * Structures defining a network interface, providing a packet
109 * transport mechanism (ala level 0 of the PUP protocols).
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.
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.
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.
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
134 /* This belongs up in socket.h or socketvar.h, depending on how far the
138 struct net_event_data
{
141 char if_name
[IFNAMSIZ
];
144 #if defined(__LP64__)
145 #include <sys/_types/_timeval32.h>
146 #define IF_DATA_TIMEVAL timeval32
148 #define IF_DATA_TIMEVAL timeval
154 * Structure describing information about an interface
155 * which may be of interest to management entities.
158 /* generic interface information */
159 u_char ifi_type
; /* ethernet, tokenring, etc */
160 u_char ifi_typelen
; /* Length of frame type id */
161 u_char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
162 u_char ifi_addrlen
; /* media address length */
163 u_char ifi_hdrlen
; /* media header length */
164 u_char ifi_recvquota
; /* polling quota for receive intrs */
165 u_char ifi_xmitquota
; /* polling quota for xmit intrs */
166 u_char ifi_unused1
; /* for future use */
167 u_int32_t ifi_mtu
; /* maximum transmission unit */
168 u_int32_t ifi_metric
; /* routing metric (external only) */
169 u_int32_t ifi_baudrate
; /* linespeed */
170 /* volatile statistics */
171 u_int32_t ifi_ipackets
; /* packets received on interface */
172 u_int32_t ifi_ierrors
; /* input errors on interface */
173 u_int32_t ifi_opackets
; /* packets sent on interface */
174 u_int32_t ifi_oerrors
; /* output errors on interface */
175 u_int32_t ifi_collisions
; /* collisions on csma interfaces */
176 u_int32_t ifi_ibytes
; /* total number of octets received */
177 u_int32_t ifi_obytes
; /* total number of octets sent */
178 u_int32_t ifi_imcasts
; /* packets received via multicast */
179 u_int32_t ifi_omcasts
; /* packets sent via multicast */
180 u_int32_t ifi_iqdrops
; /* dropped on input, this interface */
181 u_int32_t ifi_noproto
; /* destined for unsupported protocol */
182 u_int32_t ifi_recvtiming
; /* usec spent receiving when timing */
183 u_int32_t ifi_xmittiming
; /* usec spent xmitting when timing */
184 struct IF_DATA_TIMEVAL ifi_lastchange
; /* time of last administrative change */
185 u_int32_t ifi_unused2
; /* used to be the default_proto */
186 u_int32_t ifi_hwassist
; /* HW offload capabilities */
187 u_int32_t ifi_reserved1
; /* for future use */
188 u_int32_t ifi_reserved2
; /* for future use */
192 * Structure describing information about an interface
193 * which may be of interest to management entities.
196 /* generic interface information */
197 u_char ifi_type
; /* ethernet, tokenring, etc */
198 u_char ifi_typelen
; /* Length of frame type id */
199 u_char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
200 u_char ifi_addrlen
; /* media address length */
201 u_char ifi_hdrlen
; /* media header length */
202 u_char ifi_recvquota
; /* polling quota for receive intrs */
203 u_char ifi_xmitquota
; /* polling quota for xmit intrs */
204 u_char ifi_unused1
; /* for future use */
205 u_int32_t ifi_mtu
; /* maximum transmission unit */
206 u_int32_t ifi_metric
; /* routing metric (external only) */
207 u_int64_t ifi_baudrate
; /* linespeed */
208 /* volatile statistics */
209 u_int64_t ifi_ipackets
; /* packets received on interface */
210 u_int64_t ifi_ierrors
; /* input errors on interface */
211 u_int64_t ifi_opackets
; /* packets sent on interface */
212 u_int64_t ifi_oerrors
; /* output errors on interface */
213 u_int64_t ifi_collisions
; /* collisions on csma interfaces */
214 u_int64_t ifi_ibytes
; /* total number of octets received */
215 u_int64_t ifi_obytes
; /* total number of octets sent */
216 u_int64_t ifi_imcasts
; /* packets received via multicast */
217 u_int64_t ifi_omcasts
; /* packets sent via multicast */
218 u_int64_t ifi_iqdrops
; /* dropped on input, this interface */
219 u_int64_t ifi_noproto
; /* destined for unsupported protocol */
220 u_int32_t ifi_recvtiming
; /* usec spent receiving when timing */
221 u_int32_t ifi_xmittiming
; /* usec spent xmitting when timing */
222 struct IF_DATA_TIMEVAL ifi_lastchange
; /* time of last administrative change */
226 struct if_traffic_class
{
227 u_int64_t ifi_ibepackets
; /* TC_BE packets received on interface */
228 u_int64_t ifi_ibebytes
; /* TC_BE bytes received on interface */
229 u_int64_t ifi_obepackets
; /* TC_BE packet sent on interface */
230 u_int64_t ifi_obebytes
; /* TC_BE bytes sent on interface */
231 u_int64_t ifi_ibkpackets
; /* TC_BK packets received on interface */
232 u_int64_t ifi_ibkbytes
; /* TC_BK bytes received on interface */
233 u_int64_t ifi_obkpackets
; /* TC_BK packet sent on interface */
234 u_int64_t ifi_obkbytes
; /* TC_BK bytes sent on interface */
235 u_int64_t ifi_ivipackets
; /* TC_VI packets received on interface */
236 u_int64_t ifi_ivibytes
; /* TC_VI bytes received on interface */
237 u_int64_t ifi_ovipackets
; /* TC_VI packets sent on interface */
238 u_int64_t ifi_ovibytes
; /* TC_VI bytes sent on interface */
239 u_int64_t ifi_ivopackets
; /* TC_VO packets received on interface */
240 u_int64_t ifi_ivobytes
; /* TC_VO bytes received on interface */
241 u_int64_t ifi_ovopackets
; /* TC_VO packets sent on interface */
242 u_int64_t ifi_ovobytes
; /* TC_VO bytes sent on interface */
243 u_int64_t ifi_ipvpackets
; /* TC priv packets received on interface */
244 u_int64_t ifi_ipvbytes
; /* TC priv bytes received on interface */
245 u_int64_t ifi_opvpackets
; /* TC priv packets sent on interface */
246 u_int64_t ifi_opvbytes
; /* TC priv bytes sent on interface */
249 struct if_data_extended
{
250 u_int64_t ifi_alignerrs
; /* unaligned (32-bit) input pkts */
251 u_int64_t ifi_dt_bytes
; /* Data threshold counter */
252 u_int64_t ifi_fpackets
; /* forwarded packets on interface */
253 u_int64_t ifi_fbytes
; /* forwarded bytes on interface */
254 u_int64_t reserved
[12]; /* for future */
257 struct if_packet_stats
{
259 u_int64_t ifi_tcp_badformat
;
260 u_int64_t ifi_tcp_unspecv6
;
261 u_int64_t ifi_tcp_synfin
;
262 u_int64_t ifi_tcp_badformatipsec
;
263 u_int64_t ifi_tcp_noconnnolist
;
264 u_int64_t ifi_tcp_noconnlist
;
265 u_int64_t ifi_tcp_listbadsyn
;
266 u_int64_t ifi_tcp_icmp6unreach
;
267 u_int64_t ifi_tcp_deprecate6
;
268 u_int64_t ifi_tcp_rstinsynrcv
;
269 u_int64_t ifi_tcp_ooopacket
;
270 u_int64_t ifi_tcp_dospacket
;
271 u_int64_t ifi_tcp_cleanup
;
272 u_int64_t ifi_tcp_synwindow
;
273 u_int64_t reserved
[6];
275 u_int64_t ifi_udp_port_unreach
;
276 u_int64_t ifi_udp_faithprefix
;
277 u_int64_t ifi_udp_port0
;
278 u_int64_t ifi_udp_badlength
;
279 u_int64_t ifi_udp_badchksum
;
280 u_int64_t ifi_udp_badmcast
;
281 u_int64_t ifi_udp_cleanup
;
282 u_int64_t ifi_udp_badipsec
;
283 u_int64_t _reserved
[4];
286 struct if_description
{
287 u_int32_t ifd_maxlen
; /* must be IF_DESCSIZE */
288 u_int32_t ifd_len
; /* actual ifd_desc length */
289 u_int8_t
*ifd_desc
; /* ptr to desc buffer */
292 struct if_bandwidths
{
293 u_int64_t eff_bw
; /* effective bandwidth */
294 u_int64_t max_bw
; /* maximum theoretical bandwidth */
297 struct if_latencies
{
298 u_int64_t eff_lt
; /* effective latency */
299 u_int64_t max_lt
; /* maximum theoretical latency */
302 struct if_rxpoll_stats
{
303 u_int32_t ifi_poll_off_req
; /* total # of POLL_OFF reqs */
304 u_int32_t ifi_poll_off_err
; /* total # of POLL_OFF errors */
305 u_int32_t ifi_poll_on_req
; /* total # of POLL_ON reqs */
306 u_int32_t ifi_poll_on_err
; /* total # of POLL_ON errors */
308 u_int32_t ifi_poll_wakeups_avg
; /* avg # of wakeup reqs */
309 u_int32_t ifi_poll_wakeups_lowat
; /* wakeups low watermark */
310 u_int32_t ifi_poll_wakeups_hiwat
; /* wakeups high watermark */
312 u_int64_t ifi_poll_packets
; /* total # of polled packets */
313 u_int32_t ifi_poll_packets_avg
; /* average polled packets */
314 u_int32_t ifi_poll_packets_min
; /* smallest polled packets */
315 u_int32_t ifi_poll_packets_max
; /* largest polled packets */
316 u_int32_t ifi_poll_packets_lowat
; /* packets low watermark */
317 u_int32_t ifi_poll_packets_hiwat
; /* packets high watermark */
319 u_int64_t ifi_poll_bytes
; /* total # of polled bytes */
320 u_int32_t ifi_poll_bytes_avg
; /* average polled bytes */
321 u_int32_t ifi_poll_bytes_min
; /* smallest polled bytes */
322 u_int32_t ifi_poll_bytes_max
; /* largest polled bytes */
323 u_int32_t ifi_poll_bytes_lowat
; /* bytes low watermark */
324 u_int32_t ifi_poll_bytes_hiwat
; /* bytes high watermark */
326 u_int32_t ifi_poll_packets_limit
; /* max packets per poll call */
327 u_int64_t ifi_poll_interval_time
; /* poll interval (nsec) */
334 * Structure defining a queue for a network interface.
344 #ifdef BSD_KERNEL_PRIVATE
346 * Internal storage of if_data. This is bound to change. Various places in the
347 * stack will translate this data structure in to the externally visible
348 * if_data structure above. Note that during interface attach time, the
349 * embedded if_data structure in ifnet is cleared, with the exception of
350 * some non-statistics related fields.
352 struct if_data_internal
{
353 /* generic interface information */
354 u_char ifi_type
; /* ethernet, tokenring, etc */
355 u_char ifi_typelen
; /* Length of frame type id */
356 u_char ifi_physical
; /* e.g., AUI, Thinnet, 10base-T, etc */
357 u_char ifi_addrlen
; /* media address length */
358 u_char ifi_hdrlen
; /* media header length */
359 u_char ifi_recvquota
; /* polling quota for receive intrs */
360 u_char ifi_xmitquota
; /* polling quota for xmit intrs */
361 u_char ifi_unused1
; /* for future use */
362 u_int32_t ifi_mtu
; /* maximum transmission unit */
363 u_int32_t ifi_metric
; /* routing metric (external only) */
364 u_int32_t ifi_baudrate
; /* linespeed */
366 /* volatile statistics */
367 u_int64_t ifi_ipackets
; /* packets received on interface */
368 u_int64_t ifi_ierrors
; /* input errors on interface */
369 u_int64_t ifi_opackets
; /* packets sent on interface */
370 u_int64_t ifi_oerrors
; /* output errors on interface */
371 u_int64_t ifi_collisions
; /* collisions on csma interfaces */
372 u_int64_t ifi_ibytes
; /* total number of octets received */
373 u_int64_t ifi_obytes
; /* total number of octets sent */
374 u_int64_t ifi_imcasts
; /* packets received via multicast */
375 u_int64_t ifi_omcasts
; /* packets sent via multicast */
376 u_int64_t ifi_iqdrops
; /* dropped on input, this interface */
377 u_int64_t ifi_noproto
; /* destined for unsupported protocol */
378 u_int32_t ifi_recvtiming
; /* usec spent receiving when timing */
379 u_int32_t ifi_xmittiming
; /* usec spent xmitting when timing */
380 u_int64_t ifi_alignerrs
; /* unaligned (32-bit) input pkts */
381 u_int64_t ifi_dt_bytes
; /* Data threshold counter */
382 u_int64_t ifi_fpackets
; /* forwarded packets on interface */
383 u_int64_t ifi_fbytes
; /* forwarded bytes on interface */
384 struct timeval ifi_lastchange
; /* time of last administrative change */
385 u_int32_t ifi_hwassist
; /* HW offload capabilities */
386 u_int32_t ifi_tso_v4_mtu
; /* TCP Segment Offload IPv4 maximum segment size */
387 u_int32_t ifi_tso_v6_mtu
; /* TCP Segment Offload IPv6 maximum segment size */
392 * Fields per interface to measure perceived bandwidth.
394 struct if_measured_bw
{
395 u_int64_t bw
; /* measured bandwidth in bytes per ms */
396 u_int64_t bytes
; /* XXX not needed */
397 u_int64_t ts
; /* XXX not needed */
398 u_int64_t cur_seq
__attribute((aligned(8))); /* current sequence for marking a packet */
399 u_int64_t start_ts
; /* time at which a measurement started */
400 u_int64_t start_seq
; /* sequence at which a measurement should start */
401 u_int64_t last_seq
; /* last recorded seq */
402 u_int64_t last_ts
; /* last recorded ts */
403 u_int32_t flags
__attribute__((aligned(4))); /* flags */
404 #define IF_MEASURED_BW_INPROGRESS 0x1
405 #define IF_MEASURED_BW_CALCULATION 0x2
407 #endif /* MEASURE_BW */
408 #endif /* BSD_KERNEL_PRIVATE */
411 #define if_mtu if_data.ifi_mtu
412 #define if_type if_data.ifi_type
413 #define if_typelen if_data.ifi_typelen
414 #define if_physical if_data.ifi_physical
415 #define if_addrlen if_data.ifi_addrlen
416 #define if_hdrlen if_data.ifi_hdrlen
417 #define if_metric if_data.ifi_metric
418 #define if_baudrate if_data.ifi_baudrate
419 #define if_hwassist if_data.ifi_hwassist
420 #define if_ipackets if_data.ifi_ipackets
421 #define if_ierrors if_data.ifi_ierrors
422 #define if_opackets if_data.ifi_opackets
423 #define if_oerrors if_data.ifi_oerrors
424 #define if_collisions if_data.ifi_collisions
425 #define if_ibytes if_data.ifi_ibytes
426 #define if_obytes if_data.ifi_obytes
427 #define if_imcasts if_data.ifi_imcasts
428 #define if_omcasts if_data.ifi_omcasts
429 #define if_iqdrops if_data.ifi_iqdrops
430 #define if_noproto if_data.ifi_noproto
431 #define if_lastchange if_data.ifi_lastchange
432 #define if_recvquota if_data.ifi_recvquota
433 #define if_xmitquota if_data.ifi_xmitquota
435 #ifdef BSD_KERNEL_PRIVATE
436 #define if_tso_v4_mtu if_data.ifi_tso_v4_mtu
437 #define if_tso_v6_mtu if_data.ifi_tso_v6_mtu
438 #define if_alignerrs if_data.ifi_alignerrs
439 #define if_dt_bytes if_data.ifi_dt_bytes
440 #define if_fpackets if_data.ifi_fpackets
441 #define if_fbytes if_data.ifi_fbytes
442 #endif /* BSD_KERNEL_PRIVATE */
444 #ifdef BSD_KERNEL_PRIVATE
446 * Forward structure declarations for function prototypes [sic].
455 struct proto_hash_entry
;
456 struct dlil_threading_info
;
457 struct tcpstat_local
;
458 struct udpstat_local
;
463 /* we use TAILQs so that the order of instantiation is preserved in the list */
464 TAILQ_HEAD(ifnethead
, ifnet
);
465 TAILQ_HEAD(ifaddrhead
, ifaddr
);
466 TAILQ_HEAD(ifprefixhead
, ifprefix
);
467 LIST_HEAD(ifmultihead
, ifmultiaddr
);
468 TAILQ_HEAD(tailq_head
, tqdummy
);
469 TAILQ_HEAD(ifnet_filter_head
, ifnet_filter
);
470 TAILQ_HEAD(ddesc_head_name
, dlil_demux_desc
);
471 #endif /* BSD_KERNEL_PRIVATE */
475 * All of the following IF_HWASSIST_* flags are defined in kpi_inteface.h as
476 * IFNET_* flags. These are redefined here as constants to avoid failures to
477 * build user level programs that can not include kpi_interface.h. It is
478 * important to keep this in sync with the definitions in kpi_interface.h.
479 * The corresponding constant for each definition is mentioned in the comment.
481 * Bottom 16 bits reserved for hardware checksum
483 #define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP, IFNET_CSUM_IP */
484 #define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP, IFNET_CSUM_TCP */
485 #define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP, IFNET_CSUM_UDP */
486 #define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments, IFNET_CSUM_FRAGMENT */
487 #define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation, IFNET_IP_FRAGMENT */
488 #define IF_HWASSIST_CSUM_TCPIPV6 0x0020 /* will csum TCPv6, IFNET_CSUM_TCPIPV6 */
489 #define IF_HWASSIST_CSUM_UDPIPV6 0x0040 /* will csum UDPv6, IFNET_CSUM_UDP */
490 #define IF_HWASSIST_CSUM_FRAGMENT_IPV6 0x0080 /* will do IPv6 fragmentation, IFNET_IPV6_FRAGMENT */
491 #define IF_HWASSIST_CSUM_PARTIAL 0x1000 /* simple Sum16 computation, IFNET_CSUM_PARTIAL */
492 #define IF_HWASSIST_CSUM_MASK 0xffff
493 #define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK)
496 #define IF_HWASSIST_VLAN_TAGGING 0x00010000 /* supports VLAN tagging, IFNET_VLAN_TAGGING */
497 #define IF_HWASSIST_VLAN_MTU 0x00020000 /* supports VLAN MTU-sized packet (for software VLAN), IFNET_VLAN_MTU */
499 /* TCP Segment Offloading support */
501 #define IF_HWASSIST_TSO_V4 0x00200000 /* will do TCP Segment offload for IPv4, IFNET_TSO_IPV4 */
502 #define IF_HWASSIST_TSO_V6 0x00400000 /* will do TCP Segment offload for IPv6, IFNET_TSO_IPV6 */
506 #define IFXNAMSIZ (IFNAMSIZ + 8) /* external name (name + unit) */
509 #ifdef BSD_KERNEL_PRIVATE
511 * ifnet is private to BSD portion of kernel
513 #include <sys/mcache.h>
514 #include <sys/tree.h>
515 #include <netinet/in.h>
516 #include <net/if_dl.h>
517 #include <net/classq/if_classq.h>
518 #include <net/if_types.h>
520 RB_HEAD(ll_reach_tree
, if_llreach
); /* define struct ll_reach_tree */
522 #define if_name(ifp) ifp->if_xname
524 * Structure defining a network interface.
526 * (Would like to call this struct ``if'', but C isn't PL/1.)
530 * Lock (RW or mutex) to protect this data structure (static storage.)
532 decl_lck_rw_data(, if_lock
);
533 void *if_softc
; /* pointer to driver state */
534 const char *if_name
; /* name, e.g. ``en'' or ``lo'' */
535 const char *if_xname
; /* external name (name + unit) */
536 struct if_description if_desc
; /* extended description */
537 TAILQ_ENTRY(ifnet
) if_link
; /* all struct ifnets are chained */
538 TAILQ_ENTRY(ifnet
) if_detaching_link
; /* list of detaching ifnets */
540 decl_lck_mtx_data(, if_ref_lock
)
541 u_int32_t if_refflags
; /* see IFRF flags below */
542 u_int32_t if_refio
; /* number of io ops to the underlying driver */
544 #define if_list if_link
545 struct ifaddrhead if_addrhead
; /* linked list of addresses per if */
546 #define if_addrlist if_addrhead
547 struct ifaddr
*if_lladdr
; /* link address (first/permanent) */
549 int if_pcount
; /* number of promiscuous listeners */
550 struct bpf_if
*if_bpf
; /* packet filter structure */
551 u_short if_index
; /* numeric abbreviation for this if */
552 short if_unit
; /* sub-unit for lower level driver */
553 short if_timer
; /* time 'til if_watchdog called */
554 short if_flags
; /* up/down, broadcast, etc. */
555 u_int32_t if_eflags
; /* see <net/if.h> */
557 int if_capabilities
; /* interface features & capabilities */
558 int if_capenable
; /* enabled features & capabilities */
560 void *if_linkmib
; /* link-type-specific MIB data */
561 size_t if_linkmiblen
; /* length of above data */
563 struct if_data_internal if_data
__attribute__((aligned(8)));
565 ifnet_family_t if_family
; /* value assigned by Apple */
566 ifnet_subfamily_t if_subfamily
; /* value assigned by Apple */
567 uintptr_t if_family_cookie
;
568 ifnet_output_func if_output
;
569 ifnet_pre_enqueue_func if_pre_enqueue
;
570 ifnet_start_func if_start
;
571 ifnet_ctl_func if_output_ctl
;
572 ifnet_input_poll_func if_input_poll
;
573 ifnet_ctl_func if_input_ctl
;
574 ifnet_ioctl_func if_ioctl
;
575 ifnet_set_bpf_tap if_set_bpf_tap
;
576 ifnet_detached_func if_free
;
577 ifnet_demux_func if_demux
;
578 ifnet_event_func if_event
;
579 ifnet_framer_func if_framer_legacy
;
580 ifnet_framer_extended_func if_framer
;
581 ifnet_add_proto_func if_add_proto
;
582 ifnet_del_proto_func if_del_proto
;
583 ifnet_check_multi if_check_multi
;
584 struct proto_hash_entry
*if_proto_hash
;
585 void *if_kpi_storage
;
587 u_int32_t if_flowhash
; /* interface flow control ID */
589 decl_lck_mtx_data(, if_start_lock
);
590 u_int32_t if_start_flags
; /* see IFSF flags below */
591 u_int32_t if_start_req
;
592 u_int32_t if_start_active
; /* output is active */
593 struct timespec if_start_cycle
; /* restart interval */
594 struct thread
*if_start_thread
;
596 struct ifclassq if_snd
; /* transmit queue */
597 u_int32_t if_output_sched_model
; /* tx sched model */
599 struct if_bandwidths if_output_bw
;
600 struct if_bandwidths if_input_bw
;
602 struct if_latencies if_output_lt
;
603 struct if_latencies if_input_lt
;
605 decl_lck_mtx_data(, if_flt_lock
)
606 u_int32_t if_flt_busy
;
607 u_int32_t if_flt_waiters
;
608 struct ifnet_filter_head if_flt_head
;
610 struct ifmultihead if_multiaddrs
; /* multicast addresses */
611 u_int32_t if_updatemcasts
; /* mcast addrs need updating */
612 int if_amcount
; /* # of all-multicast reqs */
613 decl_lck_mtx_data(, if_addrconfig_lock
); /* for serializing addr config */
614 struct in_multi
*if_allhostsinm
; /* store all-hosts inm for this ifp */
616 decl_lck_mtx_data(, if_poll_lock
);
617 u_int16_t if_poll_req
;
618 u_int16_t if_poll_update
; /* link update */
619 u_int32_t if_poll_active
; /* polling is active */
620 struct timespec if_poll_cycle
; /* poll interval */
621 struct thread
*if_poll_thread
;
623 struct dlil_threading_info
*if_inp
;
625 struct ifprefixhead if_prefixhead
; /* list of prefixes per if */
634 struct label
*if_label
; /* interface MAC label */
637 u_int32_t if_wake_properties
;
639 struct pfi_kif
*if_pf_kif
;
642 decl_lck_mtx_data(, if_cached_route_lock
);
643 u_int32_t if_fwd_cacheok
;
644 struct route if_fwd_route
; /* cached forwarding route */
645 struct route if_src_route
; /* cached ipv4 source route */
646 struct route_in6 if_src_route6
; /* cached ipv6 source route */
648 decl_lck_rw_data(, if_llreach_lock
);
649 struct ll_reach_tree if_ll_srcs
; /* source link-layer tree */
651 void *if_bridge
; /* bridge glue */
653 u_int32_t if_want_aggressive_drain
;
654 u_int32_t if_idle_flags
; /* idle flags */
655 u_int32_t if_idle_new_flags
; /* temporary idle flags */
656 u_int32_t if_idle_new_flags_mask
; /* temporary mask */
657 u_int32_t if_route_refcnt
; /* idle: route ref count */
659 struct if_traffic_class if_tc
__attribute__((aligned(8)));
661 struct igmp_ifinfo
*if_igi
; /* for IGMPv3 */
664 struct mld_ifinfo
*if_mli
; /* for MLDv2 */
667 int if_lqm
; /* link quality metric */
669 struct if_measured_bw if_bw
;
670 #endif /* MEASURE_BW */
671 struct tcpstat_local
*if_tcp_stat
; /* TCP specific stats */
672 struct udpstat_local
*if_udp_stat
; /* UDP specific stats */
675 int32_t level
; /* cached logging level */
676 u_int32_t flags
; /* cached logging flags */
677 int32_t category
; /* cached category */
678 int32_t subcategory
; /* cached subcategory */
682 struct ifnet
*ifp
; /* delegated ifp */
683 u_int32_t type
; /* delegated i/f type */
684 u_int32_t family
; /* delegated i/f family */
685 u_int32_t subfamily
; /* delegated i/f sub-family */
688 u_int64_t if_data_threshold
;
689 u_int32_t if_fg_sendts
; /* last send on a fg socket in seconds */
692 decl_lck_rw_data(, if_inet6data_lock
);
697 #define IF_TCP_STATINC(_ifp, _s) do { \
698 if ((_ifp)->if_tcp_stat != NULL) \
699 atomic_add_64(&(_ifp)->if_tcp_stat->_s, 1); \
702 #define IF_UDP_STATINC(_ifp, _s) do { \
703 if ((_ifp)->if_udp_stat != NULL) \
704 atomic_add_64(&(_ifp)->if_udp_stat->_s, 1); \
708 * Valid values for if_refflags
710 #define IFRF_ATTACHED 0x1 /* ifnet attach is completely done */
711 #define IFRF_DETACHING 0x2 /* detach has been requested */
714 * Valid values for if_start_flags
716 #define IFSF_FLOW_CONTROLLED 0x1 /* flow controlled */
719 * Structure describing a `cloning' interface.
722 LIST_ENTRY(if_clone
) ifc_list
; /* on list of cloners */
723 const char *ifc_name
; /* name of device, e.g. `vlan' */
724 size_t ifc_namelen
; /* length of name */
725 u_int32_t ifc_minifs
; /* minimum number of interfaces */
726 u_int32_t ifc_maxunit
; /* maximum unit number */
727 unsigned char *ifc_units
; /* bitmap to handle units */
728 u_int32_t ifc_bmlen
; /* bitmap length */
730 int (*ifc_create
)(struct if_clone
*, u_int32_t
, void *);
731 int (*ifc_destroy
)(struct ifnet
*);
734 #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit) { \
735 { NULL, NULL }, name, (sizeof (name) - 1), minifs, maxunit, NULL, 0, \
739 #define M_CLONE M_IFADDR
742 * Macros to manipulate ifqueue. Users of these macros are responsible
743 * for serialization, by holding whatever lock is appropriate for the
744 * corresponding structure that is referring the ifqueue.
746 #define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
747 #define IF_DROP(ifq) ((ifq)->ifq_drops++)
749 #define IF_ENQUEUE(ifq, m) do { \
750 (m)->m_nextpkt = NULL; \
751 if ((ifq)->ifq_tail == NULL) \
752 (ifq)->ifq_head = m; \
754 ((struct mbuf*)(ifq)->ifq_tail)->m_nextpkt = m; \
755 (ifq)->ifq_tail = m; \
759 #define IF_PREPEND(ifq, m) do { \
760 (m)->m_nextpkt = (ifq)->ifq_head; \
761 if ((ifq)->ifq_tail == NULL) \
762 (ifq)->ifq_tail = (m); \
763 (ifq)->ifq_head = (m); \
767 #define IF_DEQUEUE(ifq, m) do { \
768 (m) = (ifq)->ifq_head; \
770 if (((ifq)->ifq_head = (m)->m_nextpkt) == NULL) \
771 (ifq)->ifq_tail = NULL; \
772 (m)->m_nextpkt = NULL; \
777 #define IF_REMQUEUE(ifq, m) do { \
778 struct mbuf *_p = (ifq)->ifq_head; \
779 struct mbuf *_n = (m)->m_nextpkt; \
782 while (_p != NULL) { \
783 if (_p->m_nextpkt == (m)) \
785 _p = _p->m_nextpkt; \
787 VERIFY(_p != NULL || ((m) == (ifq)->ifq_head)); \
788 if ((m) == (ifq)->ifq_head) \
789 (ifq)->ifq_head = _n; \
790 if ((m) == (ifq)->ifq_tail) \
791 (ifq)->ifq_tail = _p; \
792 VERIFY((ifq)->ifq_tail != NULL || (ifq)->ifq_head == NULL); \
793 VERIFY((ifq)->ifq_len != 0); \
796 _p->m_nextpkt = _n; \
797 (m)->m_nextpkt = NULL; \
800 #define IF_DRAIN(ifq) do { \
803 IF_DEQUEUE(ifq, _m); \
811 * The ifaddr structure contains information about one address
812 * of an interface. They are maintained by the different address families,
813 * are allocated and attached when an address is set, and are linked
814 * together so all addresses for an interface can be located.
817 decl_lck_mtx_data(, ifa_lock
); /* lock for ifaddr */
818 uint32_t ifa_refcnt
; /* ref count, use IFA_{ADD,REM}REF */
819 uint32_t ifa_debug
; /* debug flags */
820 struct sockaddr
*ifa_addr
; /* address of interface */
821 struct sockaddr
*ifa_dstaddr
; /* other end of p-to-p link */
822 #define ifa_broadaddr ifa_dstaddr /* broadcast address interface */
823 struct sockaddr
*ifa_netmask
; /* used to determine subnet */
824 struct ifnet
*ifa_ifp
; /* back-pointer to interface */
825 TAILQ_ENTRY(ifaddr
) ifa_link
; /* queue macro glue */
826 void (*ifa_rtrequest
) /* check or clean routes (+ or -)'d */
827 (int, struct rtentry
*, struct sockaddr
*);
828 uint32_t ifa_flags
; /* mostly rt_flags for cloning */
829 int32_t ifa_metric
; /* cost of going out this interface */
830 void (*ifa_free
)(struct ifaddr
*); /* callback fn for freeing */
831 void (*ifa_trace
) /* callback fn for tracing refs */
832 (struct ifaddr
*, int);
833 void (*ifa_attached
)(struct ifaddr
*); /* callback fn for attaching */
834 void (*ifa_detached
)(struct ifaddr
*); /* callback fn for detaching */
838 * Valid values for ifa_flags
840 #define IFA_ROUTE RTF_UP /* route installed (0x1) */
841 #define IFA_CLONING RTF_CLONING /* (0x100) */
844 * Valid values for ifa_debug
846 #define IFD_ATTACHED 0x1 /* attached to list */
847 #define IFD_ALLOC 0x2 /* dynamically allocated */
848 #define IFD_DEBUG 0x4 /* has debugging info */
849 #define IFD_LINK 0x8 /* link address */
850 #define IFD_TRASHED 0x10 /* in trash list */
851 #define IFD_SKIP 0x20 /* skip this entry */
852 #define IFD_NOTREADY 0x40 /* embryonic; not yet ready */
854 #define IFA_LOCK_ASSERT_HELD(_ifa) \
855 lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_OWNED)
857 #define IFA_LOCK_ASSERT_NOTHELD(_ifa) \
858 lck_mtx_assert(&(_ifa)->ifa_lock, LCK_MTX_ASSERT_NOTOWNED)
860 #define IFA_LOCK(_ifa) \
861 lck_mtx_lock(&(_ifa)->ifa_lock)
863 #define IFA_LOCK_SPIN(_ifa) \
864 lck_mtx_lock_spin(&(_ifa)->ifa_lock)
866 #define IFA_CONVERT_LOCK(_ifa) do { \
867 IFA_LOCK_ASSERT_HELD(_ifa); \
868 lck_mtx_convert_spin(&(_ifa)->ifa_lock); \
871 #define IFA_UNLOCK(_ifa) \
872 lck_mtx_unlock(&(_ifa)->ifa_lock)
874 #define IFA_ADDREF(_ifa) \
877 #define IFA_ADDREF_LOCKED(_ifa) \
880 #define IFA_REMREF(_ifa) do { \
881 (void) ifa_remref(_ifa, 0); \
884 #define IFA_REMREF_LOCKED(_ifa) \
888 * The prefix structure contains information about one prefix
889 * of an interface. They are maintained by the different address families,
890 * are allocated and attached when an prefix or an address is set,
891 * and are linked together so all prefixes for an interface can be located.
894 struct sockaddr
*ifpr_prefix
; /* prefix of interface */
895 struct ifnet
*ifpr_ifp
; /* back-pointer to interface */
896 TAILQ_ENTRY(ifprefix
) ifpr_list
; /* queue macro glue */
897 u_char ifpr_plen
; /* prefix length in bits */
898 u_char ifpr_type
; /* protocol dependent prefix type */
902 * Multicast address structure. This is analogous to the ifaddr
903 * structure except that it keeps track of multicast addresses.
904 * Also, the request count here is a count of requests for this
905 * address, not a count of pointers to this structure; anonymous
906 * membership(s) holds one outstanding request count.
909 decl_lck_mtx_data(, ifma_lock
);
910 u_int32_t ifma_refcount
; /* reference count */
911 u_int32_t ifma_anoncnt
; /* # of anonymous requests */
912 u_int32_t ifma_reqcnt
; /* total requests for this address */
913 u_int32_t ifma_debug
; /* see ifa_debug flags */
914 u_int32_t ifma_flags
; /* see below */
915 LIST_ENTRY(ifmultiaddr
) ifma_link
; /* queue macro glue */
916 struct sockaddr
*ifma_addr
; /* address this membership is for */
917 struct ifmultiaddr
*ifma_ll
; /* link-layer translation, if any */
918 struct ifnet
*ifma_ifp
; /* back-pointer to interface */
919 void *ifma_protospec
; /* protocol-specific state, if any */
920 void (*ifma_trace
) /* callback fn for tracing refs */
921 (struct ifmultiaddr
*, int);
925 * Values for ifma_flags
927 #define IFMAF_ANONYMOUS 0x1 /* has anonymous request ref(s) held */
929 #define IFMA_LOCK_ASSERT_HELD(_ifma) \
930 lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_OWNED)
932 #define IFMA_LOCK_ASSERT_NOTHELD(_ifma) \
933 lck_mtx_assert(&(_ifma)->ifma_lock, LCK_MTX_ASSERT_NOTOWNED)
935 #define IFMA_LOCK(_ifma) \
936 lck_mtx_lock(&(_ifma)->ifma_lock)
938 #define IFMA_LOCK_SPIN(_ifma) \
939 lck_mtx_lock_spin(&(_ifma)->ifma_lock)
941 #define IFMA_CONVERT_LOCK(_ifma) do { \
942 IFMA_LOCK_ASSERT_HELD(_ifma); \
943 lck_mtx_convert_spin(&(_ifma)->ifma_lock); \
946 #define IFMA_UNLOCK(_ifma) \
947 lck_mtx_unlock(&(_ifma)->ifma_lock)
949 #define IFMA_ADDREF(_ifma) \
950 ifma_addref(_ifma, 0)
952 #define IFMA_ADDREF_LOCKED(_ifma) \
953 ifma_addref(_ifma, 1)
955 #define IFMA_REMREF(_ifma) \
959 * Indicate whether or not the immediate interface, or the interface delegated
960 * by it, is a cellular interface (IFT_CELLULAR). Delegated interface type is
961 * set/cleared along with the delegated ifp; we cache the type for performance
962 * to avoid dereferencing delegated ifp each time.
964 * Note that this is meant to be used only for accounting and policy purposes;
965 * certain places need to explicitly know the immediate interface type, and
966 * this macro should not be used there.
968 * The test is done against IFT_CELLULAR instead of IFNET_FAMILY_CELLULAR to
969 * handle certain cases where the family isn't set to the latter.
971 #define IFNET_IS_CELLULAR(_ifp) \
972 ((_ifp)->if_type == IFT_CELLULAR || \
973 (_ifp)->if_delegated.type == IFT_CELLULAR)
976 * Indicate whether or not the immediate interface, or the interface delegated
977 * by it, is a Wi-Fi interface (IFNET_SUBFAMILY_WIFI). Delegated interface
978 * subfamily is set/cleared along with the delegated ifp; we cache the subfamily
979 * for performance to avoid dereferencing delegated ifp each time.
981 * Note that this is meant to be used only for accounting and policy purposes;
982 * certain places need to explicitly know the immediate interface type, and
983 * this macro should not be used there.
985 * The test is done against IFNET_SUBFAMILY_WIFI as the family may be set to
986 * IFNET_FAMILY_ETHERNET (as well as type to IFT_ETHER) which is too generic.
988 #define IFNET_IS_WIFI(_ifp) \
989 ((_ifp)->if_subfamily == IFNET_SUBFAMILY_WIFI || \
990 (_ifp)->if_delegated.subfamily == IFNET_SUBFAMILY_WIFI)
992 extern struct ifnethead ifnet_head
;
993 extern struct ifnet
**ifindex2ifnet
;
994 extern u_int32_t if_sndq_maxlen
;
995 extern u_int32_t if_rcvq_maxlen
;
997 extern struct ifaddr
**ifnet_addrs
;
998 extern lck_attr_t
*ifa_mtx_attr
;
999 extern lck_grp_t
*ifa_mtx_grp
;
1000 extern lck_grp_t
*ifnet_lock_group
;
1001 extern lck_attr_t
*ifnet_lock_attr
;
1002 extern ifnet_t lo_ifp
;
1003 extern uint32_t if_bw_measure_size
;
1004 extern u_int32_t if_bw_smoothing_val
;
1006 extern int if_addmulti(struct ifnet
*, const struct sockaddr
*,
1007 struct ifmultiaddr
**);
1008 extern int if_addmulti_anon(struct ifnet
*, const struct sockaddr
*,
1009 struct ifmultiaddr
**);
1010 extern int if_allmulti(struct ifnet
*, int);
1011 extern int if_delmulti(struct ifnet
*, const struct sockaddr
*);
1012 extern int if_delmulti_ifma(struct ifmultiaddr
*);
1013 extern int if_delmulti_anon(struct ifnet
*, const struct sockaddr
*);
1014 extern void if_down(struct ifnet
*);
1015 extern int if_down_all(void);
1016 extern void if_up(struct ifnet
*);
1017 __private_extern__
void if_updown(struct ifnet
*ifp
, int up
);
1018 extern int ifioctl(struct socket
*, u_long
, caddr_t
, struct proc
*);
1019 extern int ifioctllocked(struct socket
*, u_long
, caddr_t
, struct proc
*);
1020 extern struct ifnet
*ifunit(const char *);
1021 extern struct ifnet
*if_withname(struct sockaddr
*);
1022 extern void if_qflush(struct ifnet
*, int);
1023 extern void if_qflush_sc(struct ifnet
*, mbuf_svc_class_t
, u_int32_t
,
1024 u_int32_t
*, u_int32_t
*, int);
1026 extern struct if_clone
*if_clone_lookup(const char *, u_int32_t
*);
1027 extern int if_clone_attach(struct if_clone
*);
1028 extern void if_clone_detach(struct if_clone
*);
1030 extern errno_t
if_mcasts_update(struct ifnet
*);
1033 IFNET_LCK_ASSERT_EXCLUSIVE
, /* RW: held as writer */
1034 IFNET_LCK_ASSERT_SHARED
, /* RW: held as reader */
1035 IFNET_LCK_ASSERT_OWNED
, /* RW: writer/reader, MTX: held */
1036 IFNET_LCK_ASSERT_NOTOWNED
/* not held */
1037 } ifnet_lock_assert_t
;
1039 #define IF_LLADDR(_ifp) \
1040 (LLADDR(SDL(((_ifp)->if_lladdr)->ifa_addr)))
1042 __private_extern__
void ifnet_lock_assert(struct ifnet
*, ifnet_lock_assert_t
);
1043 __private_extern__
void ifnet_lock_shared(struct ifnet
*ifp
);
1044 __private_extern__
void ifnet_lock_exclusive(struct ifnet
*ifp
);
1045 __private_extern__
void ifnet_lock_done(struct ifnet
*ifp
);
1048 __private_extern__
void if_inet6data_lock_shared(struct ifnet
*ifp
);
1049 __private_extern__
void if_inet6data_lock_exclusive(struct ifnet
*ifp
);
1050 __private_extern__
void if_inet6data_lock_done(struct ifnet
*ifp
);
1053 __private_extern__
void ifnet_head_lock_shared(void);
1054 __private_extern__
void ifnet_head_lock_exclusive(void);
1055 __private_extern__
void ifnet_head_done(void);
1057 __private_extern__ errno_t
ifnet_set_idle_flags_locked(ifnet_t
, u_int32_t
,
1059 __private_extern__
int ifnet_is_attached(struct ifnet
*, int refio
);
1060 __private_extern__
void ifnet_decr_iorefcnt(struct ifnet
*);
1061 __private_extern__
void ifnet_set_start_cycle(struct ifnet
*,
1063 __private_extern__
void ifnet_set_poll_cycle(struct ifnet
*,
1066 __private_extern__
void if_attach_ifa(struct ifnet
*, struct ifaddr
*);
1067 __private_extern__
void if_attach_link_ifa(struct ifnet
*, struct ifaddr
*);
1068 __private_extern__
void if_detach_ifa(struct ifnet
*, struct ifaddr
*);
1069 __private_extern__
void if_detach_link_ifa(struct ifnet
*, struct ifaddr
*);
1071 __private_extern__
void dlil_if_lock(void);
1072 __private_extern__
void dlil_if_unlock(void);
1073 __private_extern__
void dlil_if_lock_assert(void);
1075 extern struct ifaddr
*ifa_ifwithaddr(const struct sockaddr
*);
1076 extern struct ifaddr
*ifa_ifwithaddr_scoped(const struct sockaddr
*,
1078 extern struct ifaddr
*ifa_ifwithdstaddr(const struct sockaddr
*);
1079 extern struct ifaddr
*ifa_ifwithnet(const struct sockaddr
*);
1080 extern struct ifaddr
*ifa_ifwithnet_scoped(const struct sockaddr
*,
1082 extern struct ifaddr
*ifa_ifwithroute(int, const struct sockaddr
*,
1083 const struct sockaddr
*);
1084 extern struct ifaddr
*ifa_ifwithroute_locked(int, const struct sockaddr
*,
1085 const struct sockaddr
*);
1086 extern struct ifaddr
*ifa_ifwithroute_scoped_locked(int,
1087 const struct sockaddr
*, const struct sockaddr
*, unsigned int);
1088 extern struct ifaddr
*ifaof_ifpforaddr(const struct sockaddr
*, struct ifnet
*);
1089 __private_extern__
struct ifaddr
*ifa_ifpgetprimary(struct ifnet
*, int);
1090 extern void ifa_addref(struct ifaddr
*, int);
1091 extern struct ifaddr
*ifa_remref(struct ifaddr
*, int);
1092 extern void ifa_lock_init(struct ifaddr
*);
1093 extern void ifa_lock_destroy(struct ifaddr
*);
1094 extern void ifma_addref(struct ifmultiaddr
*, int);
1095 extern void ifma_remref(struct ifmultiaddr
*);
1097 extern void ifa_init(void);
1099 __private_extern__
struct in_ifaddr
*ifa_foraddr(unsigned int);
1100 __private_extern__
struct in_ifaddr
*ifa_foraddr_scoped(unsigned int,
1104 extern errno_t
ifnet_getset_opportunistic(struct ifnet
*, u_long
,
1105 struct ifreq
*, struct proc
*);
1106 extern int ifnet_get_throttle(struct ifnet
*, u_int32_t
*);
1107 extern int ifnet_set_throttle(struct ifnet
*, u_int32_t
);
1108 extern errno_t
ifnet_getset_log(struct ifnet
*, u_long
,
1109 struct ifreq
*, struct proc
*);
1110 extern int ifnet_set_log(struct ifnet
*, int32_t, uint32_t, int32_t, int32_t);
1111 extern int ifnet_get_log(struct ifnet
*, int32_t *, uint32_t *, int32_t *,
1113 extern int ifnet_notify_address(struct ifnet
*, int);
1117 __private_extern__
struct in6_ifaddr
*ifa_foraddr6(struct in6_addr
*);
1118 __private_extern__
struct in6_ifaddr
*ifa_foraddr6_scoped(struct in6_addr
*,
1122 __private_extern__
void if_data_internal_to_if_data(struct ifnet
*ifp
,
1123 const struct if_data_internal
*if_data_int
, struct if_data
*if_data
);
1124 __private_extern__
void if_data_internal_to_if_data64(struct ifnet
*ifp
,
1125 const struct if_data_internal
*if_data_int
, struct if_data64
*if_data64
);
1126 __private_extern__
void if_copy_traffic_class(struct ifnet
*ifp
,
1127 struct if_traffic_class
*if_tc
);
1128 __private_extern__
void if_copy_data_extended(struct ifnet
*ifp
,
1129 struct if_data_extended
*if_de
);
1130 __private_extern__
void if_copy_packet_stats(struct ifnet
*ifp
,
1131 struct if_packet_stats
*if_ps
);
1132 __private_extern__
void if_copy_rxpoll_stats(struct ifnet
*ifp
,
1133 struct if_rxpoll_stats
*if_rs
);
1135 __private_extern__
struct rtentry
*ifnet_cached_rtlookup_inet(struct ifnet
*,
1138 __private_extern__
struct rtentry
*ifnet_cached_rtlookup_inet6(struct ifnet
*,
1142 __private_extern__
void if_lqm_update(struct ifnet
*, int32_t);
1143 __private_extern__
void ifnet_update_sndq(struct ifclassq
*, cqev_t
);
1144 __private_extern__
void ifnet_update_rcv(struct ifnet
*, cqev_t
);
1146 __private_extern__
void ifnet_flowadv(uint32_t);
1148 __private_extern__ errno_t
ifnet_set_input_bandwidths(struct ifnet
*,
1149 struct if_bandwidths
*);
1150 __private_extern__ errno_t
ifnet_set_output_bandwidths(struct ifnet
*,
1151 struct if_bandwidths
*, boolean_t
);
1152 __private_extern__ u_int64_t
ifnet_output_linkrate(struct ifnet
*);
1153 __private_extern__ u_int64_t
ifnet_input_linkrate(struct ifnet
*);
1155 __private_extern__ errno_t
ifnet_set_input_latencies(struct ifnet
*,
1156 struct if_latencies
*);
1157 __private_extern__ errno_t
ifnet_set_output_latencies(struct ifnet
*,
1158 struct if_latencies
*, boolean_t
);
1160 __private_extern__ errno_t
ifnet_framer_stub(struct ifnet
*, struct mbuf
**,
1161 const struct sockaddr
*, const char *, const char *, u_int32_t
*,
1163 #endif /* BSD_KERNEL_PRIVATE */
1164 #ifdef XNU_KERNEL_PRIVATE
1166 __private_extern__
int uuid_get_ethernet(u_int8_t
*);
1167 #endif /* XNU_KERNEL_PRIVATE */
1168 #endif /* !_NET_IF_VAR_H_ */