X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0c530ab8987f0ae6a1a3d9284f40182b88852816..b7266188b87f3620ec3f9f717e57194a7dd989fe:/bsd/net/if_var.h diff --git a/bsd/net/if_var.h b/bsd/net/if_var.h index 6feecc2b9..0601b7872 100644 --- a/bsd/net/if_var.h +++ b/bsd/net/if_var.h @@ -1,23 +1,29 @@ /* - * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2009 Apple Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * - * The contents of this file constitute Original Code as defined in and - * are subject to the Apple Public Source License Version 1.1 (the - * "License"). You may not use this file except in compliance with the - * License. Please obtain a copy of the License at - * http://www.apple.com/publicsource and read it before using this file. + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. * - * This Original Code and all software distributed under the License are - * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the - * License for the specific language governing rights and limitations - * under the License. + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -59,16 +65,20 @@ #define _NET_IF_VAR_H_ #include +#include #include #include #include /* get TAILQ macros */ #ifdef KERNEL_PRIVATE #include #endif /* KERNEL_PRIVATE */ +#ifdef PRIVATE +#include +#endif #ifdef KERNEL #include -#endif KERNEL +#endif /* KERNEL */ #ifdef __APPLE__ #define APPLE_IF_FAM_LOOPBACK 1 @@ -126,49 +136,57 @@ */ struct net_event_data { - unsigned long if_family; - unsigned long if_unit; - char if_name[IFNAMSIZ]; + u_int32_t if_family; + u_int32_t if_unit; + char if_name[IFNAMSIZ]; }; +#if defined(__LP64__) +#define __need_struct_timeval32 +#include +#define IF_DATA_TIMEVAL timeval32 +#else +#define IF_DATA_TIMEVAL timeval +#endif + +#pragma pack(4) + /* * Structure describing information about an interface * which may be of interest to management entities. */ struct if_data { /* generic interface information */ - unsigned char ifi_type; /* ethernet, tokenring, etc */ -#ifdef __APPLE__ - unsigned char ifi_typelen; /* Length of frame type id */ -#endif - unsigned char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ - unsigned char ifi_addrlen; /* media address length */ - unsigned char ifi_hdrlen; /* media header length */ - unsigned char ifi_recvquota; /* polling quota for receive intrs */ - unsigned char ifi_xmitquota; /* polling quota for xmit intrs */ - unsigned char ifi_unused1; /* for future use */ - unsigned long ifi_mtu; /* maximum transmission unit */ - unsigned long ifi_metric; /* routing metric (external only) */ - unsigned long ifi_baudrate; /* linespeed */ + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_typelen; /* Length of frame type id */ + u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + u_char ifi_recvquota; /* polling quota for receive intrs */ + u_char ifi_xmitquota; /* polling quota for xmit intrs */ + u_char ifi_unused1; /* for future use */ + u_int32_t ifi_mtu; /* maximum transmission unit */ + u_int32_t ifi_metric; /* routing metric (external only) */ + u_int32_t ifi_baudrate; /* linespeed */ /* volatile statistics */ - unsigned long ifi_ipackets; /* packets received on interface */ - unsigned long ifi_ierrors; /* input errors on interface */ - unsigned long ifi_opackets; /* packets sent on interface */ - unsigned long ifi_oerrors; /* output errors on interface */ - unsigned long ifi_collisions; /* collisions on csma interfaces */ - unsigned long ifi_ibytes; /* total number of octets received */ - unsigned long ifi_obytes; /* total number of octets sent */ - unsigned long ifi_imcasts; /* packets received via multicast */ - unsigned long ifi_omcasts; /* packets sent via multicast */ - unsigned long ifi_iqdrops; /* dropped on input, this interface */ - unsigned long ifi_noproto; /* destined for unsupported protocol */ - unsigned long ifi_recvtiming; /* usec spent receiving when timing */ - unsigned long ifi_xmittiming; /* usec spent xmitting when timing */ - struct timeval ifi_lastchange; /* time of last administrative change */ - unsigned long ifi_unused2; /* used to be the default_proto */ - unsigned long ifi_hwassist; /* HW offload capabilities */ - unsigned long ifi_reserved1; /* for future use */ - unsigned long ifi_reserved2; /* for future use */ + u_int32_t ifi_ipackets; /* packets received on interface */ + u_int32_t ifi_ierrors; /* input errors on interface */ + u_int32_t ifi_opackets; /* packets sent on interface */ + u_int32_t ifi_oerrors; /* output errors on interface */ + u_int32_t ifi_collisions; /* collisions on csma interfaces */ + u_int32_t ifi_ibytes; /* total number of octets received */ + u_int32_t ifi_obytes; /* total number of octets sent */ + u_int32_t ifi_imcasts; /* packets received via multicast */ + u_int32_t ifi_omcasts; /* packets sent via multicast */ + u_int32_t ifi_iqdrops; /* dropped on input, this interface */ + u_int32_t ifi_noproto; /* destined for unsupported protocol */ + u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ + u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ + struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ + u_int32_t ifi_unused2; /* used to be the default_proto */ + u_int32_t ifi_hwassist; /* HW offload capabilities */ + u_int32_t ifi_reserved1; /* for future use */ + u_int32_t ifi_reserved2; /* for future use */ }; /* @@ -177,18 +195,16 @@ struct if_data { */ struct if_data64 { /* generic interface information */ - u_char ifi_type; /* ethernet, tokenring, etc */ -#ifdef __APPLE__ - u_char ifi_typelen; /* Length of frame type id */ -#endif + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_typelen; /* Length of frame type id */ u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ u_char ifi_addrlen; /* media address length */ u_char ifi_hdrlen; /* media header length */ u_char ifi_recvquota; /* polling quota for receive intrs */ u_char ifi_xmitquota; /* polling quota for xmit intrs */ u_char ifi_unused1; /* for future use */ - u_long ifi_mtu; /* maximum transmission unit */ - u_long ifi_metric; /* routing metric (external only) */ + u_int32_t ifi_mtu; /* maximum transmission unit */ + u_int32_t ifi_metric; /* routing metric (external only) */ u_int64_t ifi_baudrate; /* linespeed */ /* volatile statistics */ u_int64_t ifi_ipackets; /* packets received on interface */ @@ -202,11 +218,13 @@ struct if_data64 { u_int64_t ifi_omcasts; /* packets sent via multicast */ u_int64_t ifi_iqdrops; /* dropped on input, this interface */ u_int64_t ifi_noproto; /* destined for unsupported protocol */ - u_long ifi_recvtiming; /* usec spent receiving when timing */ - u_long ifi_xmittiming; /* usec spent xmitting when timing */ - struct timeval ifi_lastchange; /* time of last administrative change */ + u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ + u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ + struct IF_DATA_TIMEVAL ifi_lastchange; /* time of last administrative change */ }; +#pragma pack() + #ifdef PRIVATE /* * Internal storage of if_data. This is bound to change. Various places in the @@ -215,34 +233,36 @@ struct if_data64 { */ struct if_data_internal { /* generic interface information */ - u_char ifi_type; /* ethernet, tokenring, etc */ - u_char ifi_typelen; /* Length of frame type id */ - u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ - u_char ifi_addrlen; /* media address length */ - u_char ifi_hdrlen; /* media header length */ - u_char ifi_recvquota; /* polling quota for receive intrs */ - u_char ifi_xmitquota; /* polling quota for xmit intrs */ - u_char ifi_unused1; /* for future use */ - u_long ifi_mtu; /* maximum transmission unit */ - u_long ifi_metric; /* routing metric (external only) */ - u_long ifi_baudrate; /* linespeed */ + u_char ifi_type; /* ethernet, tokenring, etc */ + u_char ifi_typelen; /* Length of frame type id */ + u_char ifi_physical; /* e.g., AUI, Thinnet, 10base-T, etc */ + u_char ifi_addrlen; /* media address length */ + u_char ifi_hdrlen; /* media header length */ + u_char ifi_recvquota; /* polling quota for receive intrs */ + u_char ifi_xmitquota; /* polling quota for xmit intrs */ + u_char ifi_unused1; /* for future use */ + u_int32_t ifi_mtu; /* maximum transmission unit */ + u_int32_t ifi_metric; /* routing metric (external only) */ + u_int32_t ifi_baudrate; /* linespeed */ /* volatile statistics */ u_int64_t ifi_ipackets; /* packets received on interface */ u_int64_t ifi_ierrors; /* input errors on interface */ u_int64_t ifi_opackets; /* packets sent on interface */ u_int64_t ifi_oerrors; /* output errors on interface */ u_int64_t ifi_collisions; /* collisions on csma interfaces */ - u_int64_t ifi_ibytes; /* total number of octets received */ - u_int64_t ifi_obytes; /* total number of octets sent */ + u_int64_t ifi_ibytes; /* total number of octets received */ + u_int64_t ifi_obytes; /* total number of octets sent */ u_int64_t ifi_imcasts; /* packets received via multicast */ u_int64_t ifi_omcasts; /* packets sent via multicast */ u_int64_t ifi_iqdrops; /* dropped on input, this interface */ u_int64_t ifi_noproto; /* destined for unsupported protocol */ - u_long ifi_recvtiming; /* usec spent receiving when timing */ - u_long ifi_xmittiming; /* usec spent xmitting when timing */ + u_int32_t ifi_recvtiming; /* usec spent receiving when timing */ + u_int32_t ifi_xmittiming; /* usec spent xmitting when timing */ #define IF_LASTCHANGEUPTIME 1 /* lastchange: 1-uptime 0-calendar time */ struct timeval ifi_lastchange; /* time of last administrative change */ - u_long ifi_hwassist; /* HW offload capabilities */ + u_int32_t ifi_hwassist; /* HW offload capabilities */ + u_int32_t ifi_tso_v4_mtu; /* TCP Segment Offload IPv4 maximum segment size */ + u_int32_t ifi_tso_v6_mtu; /* TCP Segment Offload IPv6 maximum segment size */ }; #define if_mtu if_data.ifi_mtu @@ -269,6 +289,8 @@ struct if_data_internal { #define if_recvquota if_data.ifi_recvquota #define if_xmitquota if_data.ifi_xmitquota #define if_iflags if_data.ifi_iflags +#define if_tso_v4_mtu if_data.ifi_tso_v4_mtu +#define if_tso_v6_mtu if_data.ifi_tso_v6_mtu struct mbuf; struct ifaddr; @@ -292,22 +314,37 @@ struct ifnet_filter; TAILQ_HEAD(ifnet_filter_head, ifnet_filter); TAILQ_HEAD(ddesc_head_name, dlil_demux_desc); -/* bottom 16 bits reserved for hardware checksum */ -#define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP */ -#define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP */ -#define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP */ -#define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments */ -#define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation */ -#define IF_HWASSIST_CSUM_TCP_SUM16 0x1000 /* simple TCP Sum16 computation */ +/* All of the following IF_HWASSIST_* flags are defined + * in kpi_inteface.h as IFNET_* flags. These are redefined + * here as constants to avoid failures to build user level + * programs that can not include kpi_interface.h. It is + * important to keep this in sync with the definitions in + * kpi_interface.h. The corresponding constant for each + * definition is mentioned in the comment. + * + * Bottom 16 bits reserved for hardware checksum + */ +#define IF_HWASSIST_CSUM_IP 0x0001 /* will csum IP, IFNET_CSUM_IP */ +#define IF_HWASSIST_CSUM_TCP 0x0002 /* will csum TCP, IFNET_CSUM_TCP */ +#define IF_HWASSIST_CSUM_UDP 0x0004 /* will csum UDP, IFNET_CSUM_UDP */ +#define IF_HWASSIST_CSUM_IP_FRAGS 0x0008 /* will csum IP fragments, IFNET_CSUM_FRAGMENT */ +#define IF_HWASSIST_CSUM_FRAGMENT 0x0010 /* will do IP fragmentation, IFNET_IP_FRAGMENT */ +#define IF_HWASSIST_CSUM_TCP_SUM16 0x1000 /* simple TCP Sum16 computation, IFNET_CSUM_SUM16 */ #define IF_HWASSIST_CSUM_MASK 0xffff #define IF_HWASSIST_CSUM_FLAGS(hwassist) ((hwassist) & IF_HWASSIST_CSUM_MASK) /* VLAN support */ -#define IF_HWASSIST_VLAN_TAGGING 0x10000 /* supports VLAN tagging */ -#define IF_HWASSIST_VLAN_MTU 0x20000 /* supports VLAN MTU-sized packet (for software VLAN) */ +#define IF_HWASSIST_VLAN_TAGGING 0x00010000 /* supports VLAN tagging, IFNET_VLAN_TAGGING */ +#define IF_HWASSIST_VLAN_MTU 0x00020000 /* supports VLAN MTU-sized packet (for software VLAN), IFNET_VLAN_MTU */ + +/* TCP Segment Offloading support */ + +#define IF_HWASSIST_TSO_V4 0x00200000 /* will do TCP Segment offload for IPv4, IFNET_TSO_IPV4 */ +#define IF_HWASSIST_TSO_V6 0x00400000 /* will do TCP Segment offload for IPv6, IFNET_TSO_IPV6 */ #define IFNET_RW_LOCK 1 +#endif /* PRIVATE */ /* * Structure defining a queue for a network interface. */ @@ -319,9 +356,15 @@ struct ifqueue { int ifq_drops; }; +#ifdef PRIVATE + struct ddesc_head_str; struct proto_hash_entry; struct kev_msg; +struct dlil_threading_info; +#if PF +struct pfi_kif; +#endif /* PF */ /* * Structure defining a network interface. @@ -333,12 +376,12 @@ struct ifnet { const char *if_name; /* name, e.g. ``en'' or ``lo'' */ TAILQ_ENTRY(ifnet) if_link; /* all struct ifnets are chained */ struct ifaddrhead if_addrhead; /* linked list of addresses per if */ - u_long if_refcnt; + u_int32_t if_refcnt; #ifdef __KPI_INTERFACE__ ifnet_check_multi if_check_multi; #else void* if_check_multi; -#endif __KPI_INTERFACE__ +#endif /* __KPI_INTERFACE__ */ int if_pcount; /* number of promiscuous listeners */ struct bpf_if *if_bpf; /* packet filter structure */ u_short if_index; /* numeric abbreviation for this if */ @@ -356,7 +399,6 @@ struct ifnet { #else int refcnt; #endif - int offercnt; #ifdef __KPI_INTERFACE__ ifnet_output_func if_output; ifnet_ioctl_func if_ioctl; @@ -365,7 +407,7 @@ struct ifnet { ifnet_demux_func if_demux; ifnet_event_func if_event; ifnet_framer_func if_framer; - ifnet_family_t if_family; /* ulong assigned by Apple */ + ifnet_family_t if_family; /* value assigned by Apple */ #else void* if_output; void* if_ioctl; @@ -374,14 +416,14 @@ struct ifnet { void* if_demux; void* if_event; void* if_framer; - u_long if_family; /* ulong assigned by Apple */ + u_int32_t if_family; /* value assigned by Apple */ #endif struct ifnet_filter_head if_flt_head; /* End DLIL specific */ - u_long if_delayed_detach; /* need to perform delayed detach */ + u_int32_t if_delayed_detach; /* need to perform delayed detach */ void *if_private; /* private to interface */ long if_eflags; /* autoaddr, autoaddr done, etc. */ @@ -389,26 +431,25 @@ struct ifnet { int if_amcount; /* number of all-multicast requests */ /* procedure handles */ #ifdef __KPI_INTERFACE__ - union { - int (*original)(struct ifnet *ifp, u_long protocol_family, - struct ddesc_head_str *demux_desc_head); - ifnet_add_proto_func kpi; - } if_add_proto_u; + ifnet_add_proto_func if_add_proto; ifnet_del_proto_func if_del_proto; -#else __KPI_INTERFACE__ +#else /* !__KPI_INTERFACE__ */ void* if_add_proto; void* if_del_proto; -#endif __KPI_INTERFACE__ +#endif /* !__KPI_INTERFACE__ */ struct proto_hash_entry *if_proto_hash; void *if_kpi_storage; - +#if 0 void *unused_was_init; +#else + struct dlil_threading_info *if_input_thread; +#endif void *unused_was_resolvemulti; struct ifqueue if_snd; - u_long unused_2[1]; + u_int32_t unused_2[1]; #ifdef __APPLE__ - u_long family_cookie; + uintptr_t family_cookie; struct ifprefixhead if_prefixhead; /* list of prefixes per if */ #ifdef _KERN_LOCKS_H_ @@ -425,21 +466,35 @@ struct ifnet { struct ifprefixhead if_prefixhead; /* list of prefixes per if */ #endif /* __APPLE__ */ struct { - u_long length; + u_int32_t length; union { u_char buffer[8]; u_char *ptr; } u; } if_broadcast; -}; +#if CONFIG_MACF_NET + struct label *if_label; /* interface MAC label */ +#endif -#define if_add_proto if_add_proto_u.original + u_int32_t if_wake_properties; +#if PF + struct thread *if_pf_curthread; + struct pfi_kif *if_pf_kif; +#endif /* PF */ +#ifdef _KERN_LOCKS_H_ + lck_mtx_t *if_fwd_route_lock; +#else + void *if_fwd_route_lock; +#endif + struct route if_fwd_route; /* cached IPv4 forwarding route */ + void *if_bridge; /* bridge glue */ +}; #ifndef __APPLE__ /* for compatibility with other BSDs */ #define if_addrlist if_addrhead #define if_list if_link -#endif !__APPLE__ +#endif /* !__APPLE__ */ #endif /* PRIVATE */ @@ -462,7 +517,7 @@ struct if_clone { }; #define IF_CLONE_INITIALIZER(name, create, destroy, minifs, maxunit) \ - { { 0, 0 }, name, sizeof(name) - 1, minifs, maxunit, NULL, 0, create, destroy } + { { NULL, NULL }, name, sizeof(name) - 1, minifs, maxunit, NULL, 0, create, destroy } /* * Bit values in if_ipending @@ -527,9 +582,9 @@ if_enq_drop(struct ifqueue *ifq, struct mbuf *m) #ifdef MT_HEADER int if_enq_drop(struct ifqueue *, struct mbuf *); -#endif MT_HEADER +#endif /* MT_HEADER */ -#endif defined(__GNUC__) && defined(MT_HEADER) +#endif /* defined(__GNUC__) && defined(MT_HEADER) */ #endif /* KERNEL_PRIVATE */ @@ -548,21 +603,29 @@ struct ifaddr { struct sockaddr *ifa_netmask; /* used to determine subnet */ struct ifnet *ifa_ifp; /* back-pointer to interface */ TAILQ_ENTRY(ifaddr) ifa_link; /* queue macro glue */ - void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ - (int, struct rtentry *, struct sockaddr *); - u_short ifa_flags; /* mostly rt_flags for cloning */ - int ifa_refcnt;/* 32bit ref count, use ifaref, ifafree */ - int ifa_metric; /* cost of going out this interface */ -#ifdef notdef - struct rtentry *ifa_rt; /* XXXX for ROUTETOIF ????? */ -#endif - int (*ifa_claim_addr) /* check if an addr goes to this if */ - (struct ifaddr *, const struct sockaddr *); - u_long ifa_debug; /* debug flags */ + void (*ifa_rtrequest) /* check or clean routes (+ or -)'d */ + (int, struct rtentry *, struct sockaddr *); + uint32_t ifa_flags; /* mostly rt_flags for cloning */ + int32_t ifa_refcnt; /* ref count, use ifaref, ifafree */ + int32_t ifa_metric; /* cost of going out this interface */ + void (*ifa_free)(struct ifaddr *); /* callback fn for freeing */ + void (*ifa_trace) /* callback fn for tracing refs */ + (struct ifaddr *, int); + uint32_t ifa_debug; /* debug flags */ }; + +/* + * Valid values for ifa_flags + */ #define IFA_ROUTE RTF_UP /* route installed (0x1) */ #define IFA_CLONING RTF_CLONING /* (0x100) */ -#define IFA_ATTACHED 0x1 /* ifa_debug: IFA is attached to an interface */ + +/* + * Valid values for ifa_debug + */ +#define IFD_ATTACHED 0x1 /* attached to an interface */ +#define IFD_ALLOC 0x2 /* dynamically allocated */ +#define IFD_DEBUG 0x4 /* has debugging info */ #endif /* PRIVATE */ @@ -615,10 +678,9 @@ struct ifmultiaddr { extern struct ifnethead ifnet_head; extern struct ifnet **ifindex2ifnet; extern int ifqmaxlen; -extern struct ifnet loif[]; +extern ifnet_t lo_ifp; extern int if_index; extern struct ifaddr **ifnet_addrs; -extern struct ifnet *lo_ifp; int if_addmulti(struct ifnet *, const struct sockaddr *, struct ifmultiaddr **); int if_allmulti(struct ifnet *, int); @@ -626,6 +688,7 @@ void if_attach(struct ifnet *); int if_delmultiaddr(struct ifmultiaddr *ifma, int locked); int if_delmulti(struct ifnet *, const struct sockaddr *); void if_down(struct ifnet *); +int if_down_all(void); void if_route(struct ifnet *, int flag, int fam); void if_unroute(struct ifnet *, int flag, int fam); void if_up(struct ifnet *); @@ -636,7 +699,7 @@ int ifioctllocked(struct socket *, u_long, caddr_t, struct proc *); struct ifnet *ifunit(const char *); struct ifnet *if_withname(struct sockaddr *); -void if_clone_attach(struct if_clone *); +int if_clone_attach(struct if_clone *); void if_clone_detach(struct if_clone *); void ifnet_lock_assert(struct ifnet *ifp, int what); @@ -655,19 +718,37 @@ void ifma_reference(struct ifmultiaddr *ifma); void ifma_release(struct ifmultiaddr *ifma); struct ifaddr *ifa_ifwithaddr(const struct sockaddr *); +struct ifaddr *ifa_ifwithaddr_scoped(const struct sockaddr *, unsigned int); struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *); struct ifaddr *ifa_ifwithnet(const struct sockaddr *); +struct ifaddr *ifa_ifwithnet_scoped(const struct sockaddr *, unsigned int); struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *, const struct sockaddr *); +struct ifaddr *ifa_ifwithroute_locked(int, const struct sockaddr *, const struct sockaddr *); +struct ifaddr *ifa_ifwithroute_scoped_locked(int, const struct sockaddr *, + const struct sockaddr *, unsigned int); struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *); +struct ifaddr *ifa_ifpgetprimary(struct ifnet *, int); void ifafree(struct ifaddr *); void ifaref(struct ifaddr *); struct ifmultiaddr *ifmaof_ifpforaddr(const struct sockaddr *, struct ifnet *); +extern struct in_ifaddr *ifa_foraddr(unsigned int); +extern struct in_ifaddr *ifa_foraddr_scoped(unsigned int, unsigned int); + #ifdef BSD_KERNEL_PRIVATE -void if_data_internal_to_if_data(const struct if_data_internal *if_data_int, - struct if_data *if_data); -void if_data_internal_to_if_data64(const struct if_data_internal *if_data_int, +enum { + kIfNetUseCount_MayBeZero = 0, + kIfNetUseCount_MustNotBeZero = 1 +}; + +int ifp_use(struct ifnet *ifp, int handle_zero); +int ifp_unuse(struct ifnet *ifp); +void ifp_use_reached_zero(struct ifnet *ifp); + +void if_data_internal_to_if_data(struct ifnet *ifp, const struct if_data_internal *if_data_int, + struct if_data *if_data); +void if_data_internal_to_if_data64(struct ifnet *ifp, const struct if_data_internal *if_data_int, struct if_data64 *if_data64); #endif /* BSD_KERNEL_PRIVATE */ #endif /* KERNEL_PRIVATE */