]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
5d5c5d0d A |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. |
3 | * | |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * Copyright (c) 1999 Apple Computer, Inc. | |
30 | * | |
31 | * Data Link Inteface Layer | |
32 | * Author: Ted Walker | |
33 | */ | |
1c79356b A |
34 | #ifndef DLIL_H |
35 | #define DLIL_H | |
91447636 | 36 | #ifdef KERNEL |
2d21ac55 | 37 | |
91447636 A |
38 | #include <sys/kernel_types.h> |
39 | #include <net/kpi_interface.h> | |
1c79356b | 40 | |
1c79356b A |
41 | enum { |
42 | BPF_TAP_DISABLE, | |
43 | BPF_TAP_INPUT, | |
44 | BPF_TAP_OUTPUT, | |
45 | BPF_TAP_INPUT_OUTPUT | |
46 | }; | |
47 | ||
91447636 | 48 | /* Ethernet specific types */ |
7b1edb79 A |
49 | #define DLIL_DESC_ETYPE2 4 |
50 | #define DLIL_DESC_SAP 5 | |
51 | #define DLIL_DESC_SNAP 6 | |
52 | /* | |
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 | |
59 | * | |
60 | * All protocols must be in Network byte order. | |
61 | * | |
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. | |
66 | */ | |
1c79356b | 67 | |
91447636 | 68 | #ifdef KERNEL_PRIVATE |
1c79356b | 69 | |
2d21ac55 A |
70 | #include <net/if.h> |
71 | #include <net/if_var.h> | |
72 | #include <sys/kern_event.h> | |
73 | #include <kern/thread.h> | |
74 | #include <kern/locks.h> | |
1c79356b | 75 | |
2d21ac55 | 76 | #if __STDC__ |
1c79356b | 77 | |
2d21ac55 A |
78 | struct ifnet; |
79 | struct mbuf; | |
80 | struct ether_header; | |
81 | struct sockaddr_dl; | |
1c79356b | 82 | |
2d21ac55 | 83 | #endif |
91447636 | 84 | |
2d21ac55 | 85 | #ifdef BSD_KERNEL_PRIVATE |
91447636 | 86 | struct ifnet_stat_increment_param; |
2d21ac55 | 87 | struct iff_filter; |
91447636 | 88 | |
2d21ac55 A |
89 | struct dlil_threading_info { |
90 | mbuf_t mbuf_head; /* start of mbuf list from if */ | |
91 | mbuf_t mbuf_tail; | |
92 | u_int32_t mbuf_count; | |
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 */ | |
98 | lck_mtx_t *input_lck; | |
99 | lck_grp_t *lck_grp; /* lock group (for lock stats) */ | |
100 | char input_name[32]; | |
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 */ | |
104 | #endif | |
105 | }; | |
1c79356b | 106 | |
2d21ac55 A |
107 | /* |
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. | |
110 | */ | |
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 | |
1c79356b | 116 | |
2d21ac55 | 117 | void dlil_init(void); |
1c79356b | 118 | |
2d21ac55 A |
119 | errno_t dlil_set_bpf_tap(ifnet_t ifp, bpf_tap_mode mode, |
120 | bpf_packet_func callback); | |
91447636 A |
121 | |
122 | /* | |
123 | * Send arp internal bypasses the check for | |
124 | * IPv4LL. | |
125 | */ | |
126 | errno_t | |
127 | dlil_send_arp_internal( | |
128 | ifnet_t ifp, | |
129 | u_int16_t arpop, | |
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); | |
134 | ||
2d21ac55 A |
135 | int |
136 | dlil_output( | |
137 | ifnet_t ifp, | |
138 | protocol_family_t proto_family, | |
139 | mbuf_t packetlist, | |
140 | void *route, | |
141 | const struct sockaddr *dest, | |
142 | int raw); | |
143 | ||
144 | errno_t | |
145 | dlil_resolve_multi( | |
146 | struct ifnet *ifp, | |
147 | const struct sockaddr *proto_addr, | |
148 | struct sockaddr *ll_addr, | |
149 | size_t ll_len); | |
150 | ||
91447636 A |
151 | errno_t |
152 | dlil_send_arp( | |
153 | ifnet_t ifp, | |
154 | u_int16_t arpop, | |
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); | |
159 | ||
2d21ac55 A |
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_long protocol); | |
1c79356b | 164 | |
2d21ac55 | 165 | #endif /* BSD_KERNEL_PRIVATE */ |
1c79356b | 166 | |
91447636 A |
167 | void |
168 | dlil_post_msg(struct ifnet *ifp,u_long event_subclass, u_long event_code, | |
169 | struct net_event_data *event_data, u_long event_data_len); | |
9bccf70c A |
170 | |
171 | /* | |
2d21ac55 A |
172 | * dlil_if_acquire is obsolete. Use ifnet_allocate. |
173 | */ | |
9bccf70c | 174 | |
91447636 | 175 | int dlil_if_acquire(u_long family, const void *uniqueid, size_t uniqueid_len, |
9bccf70c A |
176 | struct ifnet **ifp); |
177 | ||
178 | ||
179 | /* | |
2d21ac55 A |
180 | * dlil_if_release is obsolete. The equivalent is called automatically when |
181 | * an interface is detached. | |
182 | */ | |
9bccf70c A |
183 | |
184 | void dlil_if_release(struct ifnet *ifp); | |
185 | ||
91447636 A |
186 | #endif /* KERNEL_PRIVATE */ |
187 | #endif /* KERNEL */ | |
1c79356b | 188 | #endif /* DLIL_H */ |