+/*
+ * Indicate whether or not the immediate interface, or the interface delegated
+ * by it, is a Wired interface (several families). Delegated interface
+ * family is set/cleared along with the delegated ifp; we cache the family
+ * for performance to avoid dereferencing delegated ifp each time.
+ *
+ * Note that this is meant to be used only for accounting and policy purposes;
+ * certain places need to explicitly know the immediate interface type, and
+ * this macro should not be used there.
+ */
+#define IFNET_IS_WIRED(_ifp) \
+ ((_ifp)->if_family == IFNET_FAMILY_ETHERNET || \
+ (_ifp)->if_delegated.family == IFNET_FAMILY_ETHERNET || \
+ (_ifp)->if_family == IFNET_FAMILY_FIREWIRE || \
+ (_ifp)->if_delegated.family == IFNET_FAMILY_FIREWIRE)
+
+/*
+ * Indicate whether or not the immediate interface, or the interface delegated
+ * by it, is marked as expensive. The delegated interface is set/cleared
+ * along with the delegated ifp; we cache the flag for performance to avoid
+ * dereferencing delegated ifp each time.
+ *
+ * Note that this is meant to be used only for policy purposes.
+ */
+#define IFNET_IS_EXPENSIVE(_ifp) \
+ ((_ifp)->if_eflags & IFEF_EXPENSIVE || \
+ (_ifp)->if_delegated.expensive)
+
+/*
+ * We don't support AWDL interface delegation.
+ */
+#define IFNET_IS_AWDL_RESTRICTED(_ifp) \
+ (((_ifp)->if_eflags & (IFEF_AWDL|IFEF_AWDL_RESTRICTED)) == \
+ (IFEF_AWDL|IFEF_AWDL_RESTRICTED))
+
+
+extern struct ifnethead ifnet_head;
+extern struct ifnet **ifindex2ifnet;
+extern u_int32_t if_sndq_maxlen;
+extern u_int32_t if_rcvq_maxlen;
+extern int if_index;
+extern struct ifaddr **ifnet_addrs;
+extern lck_attr_t *ifa_mtx_attr;
+extern lck_grp_t *ifa_mtx_grp;
+extern lck_grp_t *ifnet_lock_group;
+extern lck_attr_t *ifnet_lock_attr;
+extern ifnet_t lo_ifp;
+extern uint32_t if_bw_measure_size;
+extern u_int32_t if_bw_smoothing_val;
+
+extern int if_addmulti(struct ifnet *, const struct sockaddr *,
+ struct ifmultiaddr **);
+extern int if_addmulti_anon(struct ifnet *, const struct sockaddr *,
+ struct ifmultiaddr **);
+extern int if_allmulti(struct ifnet *, int);
+extern int if_delmulti(struct ifnet *, const struct sockaddr *);
+extern int if_delmulti_ifma(struct ifmultiaddr *);
+extern int if_delmulti_anon(struct ifnet *, const struct sockaddr *);
+extern void if_down(struct ifnet *);
+extern int if_down_all(void);
+extern void if_up(struct ifnet *);
+__private_extern__ void if_updown(struct ifnet *ifp, int up);
+extern int ifioctl(struct socket *, u_long, caddr_t, struct proc *);
+extern int ifioctllocked(struct socket *, u_long, caddr_t, struct proc *);
+extern struct ifnet *ifunit(const char *);
+extern struct ifnet *if_withname(struct sockaddr *);
+extern void if_qflush(struct ifnet *, int);
+extern void if_qflush_sc(struct ifnet *, mbuf_svc_class_t, u_int32_t,
+ u_int32_t *, u_int32_t *, int);
+
+extern struct if_clone *if_clone_lookup(const char *, u_int32_t *);
+extern int if_clone_attach(struct if_clone *);
+extern void if_clone_detach(struct if_clone *);
+
+extern errno_t if_mcasts_update(struct ifnet *);
+
+typedef enum {
+ IFNET_LCK_ASSERT_EXCLUSIVE, /* RW: held as writer */
+ IFNET_LCK_ASSERT_SHARED, /* RW: held as reader */
+ IFNET_LCK_ASSERT_OWNED, /* RW: writer/reader, MTX: held */
+ IFNET_LCK_ASSERT_NOTOWNED /* not held */
+} ifnet_lock_assert_t;
+
+#define IF_LLADDR(_ifp) \
+ (LLADDR(SDL(((_ifp)->if_lladdr)->ifa_addr)))
+
+__private_extern__ void ifnet_lock_assert(struct ifnet *, ifnet_lock_assert_t);
+__private_extern__ void ifnet_lock_shared(struct ifnet *ifp);
+__private_extern__ void ifnet_lock_exclusive(struct ifnet *ifp);
+__private_extern__ void ifnet_lock_done(struct ifnet *ifp);
+
+#if INET6
+__private_extern__ void if_inet6data_lock_shared(struct ifnet *ifp);
+__private_extern__ void if_inet6data_lock_exclusive(struct ifnet *ifp);
+__private_extern__ void if_inet6data_lock_done(struct ifnet *ifp);
+#endif
+
+__private_extern__ void ifnet_head_lock_shared(void);
+__private_extern__ void ifnet_head_lock_exclusive(void);
+__private_extern__ void ifnet_head_done(void);
+
+__private_extern__ errno_t ifnet_set_idle_flags_locked(ifnet_t, u_int32_t,
+ u_int32_t);
+__private_extern__ int ifnet_is_attached(struct ifnet *, int refio);
+__private_extern__ void ifnet_decr_iorefcnt(struct ifnet *);
+__private_extern__ void ifnet_set_start_cycle(struct ifnet *,
+ struct timespec *);
+__private_extern__ void ifnet_set_poll_cycle(struct ifnet *,
+ struct timespec *);
+
+__private_extern__ void if_attach_ifa(struct ifnet *, struct ifaddr *);
+__private_extern__ void if_attach_link_ifa(struct ifnet *, struct ifaddr *);
+__private_extern__ void if_detach_ifa(struct ifnet *, struct ifaddr *);
+__private_extern__ void if_detach_link_ifa(struct ifnet *, struct ifaddr *);
+
+__private_extern__ void dlil_if_lock(void);
+__private_extern__ void dlil_if_unlock(void);
+__private_extern__ void dlil_if_lock_assert(void);
+
+extern struct ifaddr *ifa_ifwithaddr(const struct sockaddr *);
+extern struct ifaddr *ifa_ifwithaddr_scoped(const struct sockaddr *,
+ unsigned int);
+extern struct ifaddr *ifa_ifwithdstaddr(const struct sockaddr *);
+extern struct ifaddr *ifa_ifwithnet(const struct sockaddr *);
+extern struct ifaddr *ifa_ifwithnet_scoped(const struct sockaddr *,
+ unsigned int);
+extern struct ifaddr *ifa_ifwithroute(int, const struct sockaddr *,
+ const struct sockaddr *);
+extern struct ifaddr *ifa_ifwithroute_locked(int, const struct sockaddr *,
+ const struct sockaddr *);
+extern struct ifaddr *ifa_ifwithroute_scoped_locked(int,
+ const struct sockaddr *, const struct sockaddr *, unsigned int);
+extern struct ifaddr *ifaof_ifpforaddr(const struct sockaddr *, struct ifnet *);
+__private_extern__ struct ifaddr *ifa_ifpgetprimary(struct ifnet *, int);
+extern void ifa_addref(struct ifaddr *, int);
+extern struct ifaddr *ifa_remref(struct ifaddr *, int);
+extern void ifa_lock_init(struct ifaddr *);
+extern void ifa_lock_destroy(struct ifaddr *);
+extern void ifma_addref(struct ifmultiaddr *, int);
+extern void ifma_remref(struct ifmultiaddr *);
+
+extern void ifa_init(void);
+
+__private_extern__ struct in_ifaddr *ifa_foraddr(unsigned int);
+__private_extern__ struct in_ifaddr *ifa_foraddr_scoped(unsigned int,
+ unsigned int);
+
+struct ifreq;
+extern errno_t ifnet_getset_opportunistic(struct ifnet *, u_long,
+ struct ifreq *, struct proc *);
+extern int ifnet_get_throttle(struct ifnet *, u_int32_t *);
+extern int ifnet_set_throttle(struct ifnet *, u_int32_t);
+extern errno_t ifnet_getset_log(struct ifnet *, u_long,
+ struct ifreq *, struct proc *);
+extern int ifnet_set_log(struct ifnet *, int32_t, uint32_t, int32_t, int32_t);
+extern int ifnet_get_log(struct ifnet *, int32_t *, uint32_t *, int32_t *,
+ int32_t *);
+extern int ifnet_notify_address(struct ifnet *, int);
+
+#if INET6
+struct in6_addr;
+__private_extern__ struct in6_ifaddr *ifa_foraddr6(struct in6_addr *);
+__private_extern__ struct in6_ifaddr *ifa_foraddr6_scoped(struct in6_addr *,
+ unsigned int);
+#endif /* INET6 */
+
+__private_extern__ void if_data_internal_to_if_data(struct ifnet *ifp,
+ const struct if_data_internal *if_data_int, struct if_data *if_data);
+__private_extern__ void if_data_internal_to_if_data64(struct ifnet *ifp,
+ const struct if_data_internal *if_data_int, struct if_data64 *if_data64);
+__private_extern__ void if_copy_traffic_class(struct ifnet *ifp,
+ struct if_traffic_class *if_tc);
+__private_extern__ void if_copy_data_extended(struct ifnet *ifp,
+ struct if_data_extended *if_de);
+__private_extern__ void if_copy_packet_stats(struct ifnet *ifp,
+ struct if_packet_stats *if_ps);
+__private_extern__ void if_copy_rxpoll_stats(struct ifnet *ifp,
+ struct if_rxpoll_stats *if_rs);
+
+__private_extern__ struct rtentry *ifnet_cached_rtlookup_inet(struct ifnet *,
+ struct in_addr);
+#if INET6
+__private_extern__ struct rtentry *ifnet_cached_rtlookup_inet6(struct ifnet *,
+ struct in6_addr *);
+#endif /* INET6 */
+
+__private_extern__ void if_lqm_update(struct ifnet *, int32_t);
+__private_extern__ void ifnet_update_sndq(struct ifclassq *, cqev_t);
+__private_extern__ void ifnet_update_rcv(struct ifnet *, cqev_t);
+
+__private_extern__ void ifnet_flowadv(uint32_t);
+
+__private_extern__ errno_t ifnet_set_input_bandwidths(struct ifnet *,
+ struct if_bandwidths *);
+__private_extern__ errno_t ifnet_set_output_bandwidths(struct ifnet *,
+ struct if_bandwidths *, boolean_t);
+__private_extern__ u_int64_t ifnet_output_linkrate(struct ifnet *);
+__private_extern__ u_int64_t ifnet_input_linkrate(struct ifnet *);
+
+__private_extern__ errno_t ifnet_set_input_latencies(struct ifnet *,
+ struct if_latencies *);
+__private_extern__ errno_t ifnet_set_output_latencies(struct ifnet *,
+ struct if_latencies *, boolean_t);
+
+__private_extern__ errno_t ifnet_framer_stub(struct ifnet *, struct mbuf **,
+ const struct sockaddr *, const char *, const char *, u_int32_t *,
+ u_int32_t *);