2 * Copyright (c) 2009 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) 1999 Apple Computer, Inc.
31 * Data Link Inteface Layer
38 #include <sys/kernel_types.h>
39 #include <net/kpi_interface.h>
48 /* Ethernet specific types */
49 #define DLIL_DESC_ETYPE2 4
50 #define DLIL_DESC_SAP 5
51 #define DLIL_DESC_SNAP 6
53 * DLIL_DESC_ETYPE2 - native_type must point to 2 byte ethernet raw protocol,
54 * variants.native_type_length must be set to 2
55 * DLIL_DESC_SAP - native_type must point to 3 byte SAP protocol
56 * variants.native_type_length must be set to 3
57 * DLIL_DESC_SNAP - native_type must point to 5 byte SNAP protocol
58 * variants.native_type_length must be set to 5
60 * All protocols must be in Network byte order.
62 * Future interface families may define more protocol types they know about.
63 * The type implies the offset and context of the protocol data at native_type.
64 * The length of the protocol data specified at native_type must be set in
65 * variants.native_type_length.
71 #include <net/if_var.h>
72 #include <sys/kern_event.h>
73 #include <kern/thread.h>
74 #include <kern/locks.h>
85 #ifdef BSD_KERNEL_PRIVATE
86 struct ifnet_stat_increment_param
;
89 struct dlil_threading_info
{
90 mbuf_t mbuf_head
; /* start of mbuf list from if */
93 boolean_t net_affinity
; /* affinity set is available */
94 u_int32_t input_waiting
; /* DLIL condition of thread */
95 struct thread
*input_thread
; /* thread data for this input */
96 struct thread
*workloop_thread
; /* current workloop thread */
97 u_int32_t tag
; /* current affinity tag */
99 lck_grp_t
*lck_grp
; /* lock group (for lock stats) */
101 #if IFNET_INPUT_SANITY_CHK
102 u_int32_t input_wake_cnt
; /* number of times the thread was awaken with packets to process */
103 u_long input_mbuf_cnt
; /* total number of mbuf packets processed by this thread */
108 The following are shared with kpi_protocol.c so that it may wakeup
109 the input thread to run through packets queued for protocol input.
111 #define DLIL_INPUT_RUNNING 0x80000000
112 #define DLIL_INPUT_WAITING 0x40000000
113 #define DLIL_PROTO_REGISTER 0x20000000
114 #define DLIL_PROTO_WAITING 0x10000000
115 #define DLIL_INPUT_TERMINATE 0x08000000
117 void dlil_init(void);
119 errno_t
dlil_set_bpf_tap(ifnet_t ifp
, bpf_tap_mode mode
,
120 bpf_packet_func callback
);
123 * Send arp internal bypasses the check for
127 dlil_send_arp_internal(
130 const struct sockaddr_dl
* sender_hw
,
131 const struct sockaddr
* sender_proto
,
132 const struct sockaddr_dl
* target_hw
,
133 const struct sockaddr
* target_proto
);
138 protocol_family_t proto_family
,
141 const struct sockaddr
*dest
,
147 const struct sockaddr
*proto_addr
,
148 struct sockaddr
*ll_addr
,
155 const struct sockaddr_dl
* sender_hw
,
156 const struct sockaddr
* sender_proto
,
157 const struct sockaddr_dl
* target_hw
,
158 const struct sockaddr
* target_proto
);
160 int dlil_attach_filter(ifnet_t ifp
, const struct iff_filter
*if_filter
,
161 interface_filter_t
*filter_ref
);
162 void dlil_detach_filter(interface_filter_t filter
);
163 int dlil_detach_protocol(ifnet_t ifp
, u_int32_t protocol
);
164 extern void dlil_proto_unplumb_all(ifnet_t
);
166 #endif /* BSD_KERNEL_PRIVATE */
169 dlil_post_msg(struct ifnet
*ifp
,u_int32_t event_subclass
, u_int32_t event_code
,
170 struct net_event_data
*event_data
, u_int32_t event_data_len
);
173 * dlil_if_acquire is obsolete. Use ifnet_allocate.
176 int dlil_if_acquire(u_int32_t family
, const void *uniqueid
, size_t uniqueid_len
,
181 * dlil_if_release is obsolete. The equivalent is called automatically when
182 * an interface is detached.
185 void dlil_if_release(struct ifnet
*ifp
);
187 #if IFNET_ROUTE_REFCNT
188 extern u_int32_t ifnet_aggressive_drainers
;
189 #endif /* IFNET_ROUTE_REFCNT */
191 #endif /* KERNEL_PRIVATE */