1 /*	$NetBSD: ndis_var.h,v 1.6 2011/05/14 12:44:16 rmind Exp $	*/
2 
3 /*-
4  * Copyright (c) 2003
5  *	Bill Paul <wpaul@windriver.com>.  All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. All advertising materials mentioning features or use of this software
16  *    must display the following acknowledgement:
17  *	This product includes software developed by Bill Paul.
18  * 4. Neither the name of the author nor the names of any co-contributors
19  *    may be used to endorse or promote products derived from this software
20  *    without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25  * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32  * THE POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $FreeBSD: src/sys/compat/ndis/ndis_var.h,v 1.29.2.3 2005/03/31 04:24:35 wpaul Exp $
35  */
36 
37 #ifndef _NDIS_VAR_H_
38 #define _NDIS_VAR_H_
39 
40 #include <sys/lock.h>
41 
42 /* Forward declarations */
43 struct ndis_miniport_block;
44 struct ndis_mdriver_block;
45 typedef struct ndis_miniport_block ndis_miniport_block;
46 typedef struct ndis_mdriver_block ndis_mdriver_block;
47 
48 /* Base types */
49 typedef uint32_t ndis_status;
50 typedef void *ndis_handle;
51 typedef uint32_t ndis_oid;
52 typedef uint32_t ndis_error_code;
53 typedef register_t ndis_kspin_lock;
54 typedef uint8_t ndis_kirql;
55 
56 /* Print out debugging information */
57 /* #define NDIS_DBG */
58 
59 /*
60  * NDIS status codes (there are lots of them). The ones that
61  * don't seem to fit the pattern are actually mapped to generic
62  * NT status codes.
63  */
64 
65 #define NDIS_STATUS_SUCCESS		0
66 #define NDIS_STATUS_PENDING		0x00000103
67 #define NDIS_STATUS_NOT_RECOGNIZED	0x00010001
68 #define NDIS_STATUS_NOT_COPIED		0x00010002
69 #define NDIS_STATUS_NOT_ACCEPTED	0x00010003
70 #define NDIS_STATUS_CALL_ACTIVE		0x00010007
71 #define NDIS_STATUS_ONLINE		0x40010003
72 #define NDIS_STATUS_RESET_START		0x40010004
73 #define NDIS_STATUS_RESET_END		0x40010005
74 #define NDIS_STATUS_RING_STATUS		0x40010006
75 #define NDIS_STATUS_CLOSED		0x40010007
76 #define NDIS_STATUS_WAN_LINE_UP		0x40010008
77 #define NDIS_STATUS_WAN_LINE_DOWN	0x40010009
78 #define NDIS_STATUS_WAN_FRAGMENT	0x4001000A
79 #define NDIS_STATUS_MEDIA_CONNECT	0x4001000B
80 #define NDIS_STATUS_MEDIA_DISCONNECT	0x4001000C
81 #define NDIS_STATUS_HARDWARE_LINE_UP	0x4001000D
82 #define NDIS_STATUS_HARDWARE_LINE_DOWN	0x4001000E
83 #define NDIS_STATUS_INTERFACE_UP	0x4001000F
84 #define NDIS_STATUS_INTERFACE_DOWN	0x40010010
85 #define NDIS_STATUS_MEDIA_BUSY		0x40010011
86 #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION	0x40010012
87 #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
88 #define NDIS_STATUS_LINK_SPEED_CHANGE	0x40010013
89 #define NDIS_STATUS_WAN_GET_STATS	0x40010014
90 #define NDIS_STATUS_WAN_CO_FRAGMENT	0x40010015
91 #define NDIS_STATUS_WAN_CO_LINKPARAMS	0x40010016
92 #define NDIS_STATUS_NOT_RESETTABLE	0x80010001
93 #define NDIS_STATUS_SOFT_ERRORS		0x80010003
94 #define NDIS_STATUS_HARD_ERRORS		0x80010004
95 #define NDIS_STATUS_BUFFER_OVERFLOW	0x80000005
96 #define NDIS_STATUS_FAILURE		0xC0000001
97 #define NDIS_STATUS_RESOURCES		0xC000009A
98 #define NDIS_STATUS_CLOSING		0xC0010002
99 #define NDIS_STATUS_BAD_VERSION		0xC0010004
100 #define NDIS_STATUS_BAD_CHARACTERISTICS	0xC0010005
101 #define NDIS_STATUS_ADAPTER_NOT_FOUND	0xC0010006
102 #define NDIS_STATUS_OPEN_FAILED		0xC0010007
103 #define NDIS_STATUS_DEVICE_FAILED	0xC0010008
104 #define NDIS_STATUS_MULTICAST_FULL	0xC0010009
105 #define NDIS_STATUS_MULTICAST_EXISTS	0xC001000A
106 #define NDIS_STATUS_MULTICAST_NOT_FOUND	0xC001000B
107 #define NDIS_STATUS_REQUEST_ABORTED	0xC001000C
108 #define NDIS_STATUS_RESET_IN_PROGRESS	0xC001000D
109 #define NDIS_STATUS_CLOSING_INDICATING	0xC001000E
110 #define NDIS_STATUS_NOT_SUPPORTED	0xC00000BB
111 #define NDIS_STATUS_INVALID_PACKET	0xC001000F
112 #define NDIS_STATUS_OPEN_LIST_FULL	0xC0010010
113 #define NDIS_STATUS_ADAPTER_NOT_READY	0xC0010011
114 #define NDIS_STATUS_ADAPTER_NOT_OPEN	0xC0010012
115 #define NDIS_STATUS_NOT_INDICATING	0xC0010013
116 #define NDIS_STATUS_INVALID_LENGTH	0xC0010014
117 #define NDIS_STATUS_INVALID_DATA	0xC0010015
118 #define NDIS_STATUS_BUFFER_TOO_SHORT	0xC0010016
119 #define NDIS_STATUS_INVALID_OID		0xC0010017
120 #define NDIS_STATUS_ADAPTER_REMOVED	0xC0010018
121 #define NDIS_STATUS_UNSUPPORTED_MEDIA	0xC0010019
122 #define NDIS_STATUS_GROUP_ADDRESS_IN_USE	0xC001001A
123 #define NDIS_STATUS_FILE_NOT_FOUND	0xC001001B
124 #define NDIS_STATUS_ERROR_READING_FILE	0xC001001C
125 #define NDIS_STATUS_ALREADY_MAPPED	0xC001001D
126 #define NDIS_STATUS_RESOURCE_CONFLICT	0xC001001E
127 #define NDIS_STATUS_NO_CABLE		0xC001001F
128 #define NDIS_STATUS_INVALID_SAP		0xC0010020
129 #define NDIS_STATUS_SAP_IN_USE		0xC0010021
130 #define NDIS_STATUS_INVALID_ADDRESS	0xC0010022
131 #define NDIS_STATUS_VC_NOT_ACTIVATED	0xC0010023
132 #define NDIS_STATUS_DEST_OUT_OF_ORDER	0xC0010024
133 #define NDIS_STATUS_VC_NOT_AVAILABLE	0xC0010025
134 #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE	0xC0010026
135 #define NDIS_STATUS_INCOMPATABLE_QOS	0xC0010027
136 #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED	0xC0010028
137 #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION	0xC0010029
138 #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR	0xC0011000
139 #define NDIS_STATUS_INVALID_DEVICE_REQUEST	0xC0000010
140 #define NDIS_STATUS_NETWORK_UNREACHABLE         0xC000023C
141 
142 /*
143  * NDIS event codes. They are usually reported to NdisWriteErrorLogEntry().
144  */
145 
146 #define EVENT_NDIS_RESOURCE_CONFLICT	0xC0001388
147 #define EVENT_NDIS_OUT_OF_RESOURCE	0xC0001389
148 #define EVENT_NDIS_HARDWARE_FAILURE	0xC000138A
149 #define EVENT_NDIS_ADAPTER_NOT_FOUND	0xC000138B
150 #define EVENT_NDIS_INTERRUPT_CONNECT	0xC000138C
151 #define EVENT_NDIS_DRIVER_FAILURE	0xC000138D
152 #define EVENT_NDIS_BAD_VERSION		0xC000138E
153 #define EVENT_NDIS_TIMEOUT		0x8000138F
154 #define EVENT_NDIS_NETWORK_ADDRESS	0xC0001390
155 #define EVENT_NDIS_UNSUPPORTED_CONFIGURATION	0xC0001391
156 #define EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER	0xC0001392
157 #define EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER	0xC0001393
158 #define EVENT_NDIS_BAD_IO_BASE_ADDRESS	0xC0001394
159 #define EVENT_NDIS_RECEIVE_SPACE_SMALL	0x40001395
160 #define EVENT_NDIS_ADAPTER_DISABLED	0x80001396
161 #define EVENT_NDIS_IO_PORT_CONFLICT	0x80001397
162 #define EVENT_NDIS_PORT_OR_DMA_CONFLICT	0x80001398
163 #define EVENT_NDIS_MEMORY_CONFLICT	0x80001399
164 #define EVENT_NDIS_INTERRUPT_CONFLICT	0x8000139A
165 #define EVENT_NDIS_DMA_CONFLICT		0x8000139B
166 #define EVENT_NDIS_INVALID_DOWNLOAD_FILE_ERROR	0xC000139C
167 #define EVENT_NDIS_MAXRECEIVES_ERROR	0x8000139D
168 #define EVENT_NDIS_MAXTRANSMITS_ERROR	0x8000139E
169 #define EVENT_NDIS_MAXFRAMESIZE_ERROR	0x8000139F
170 #define EVENT_NDIS_MAXINTERNALBUFS_ERROR	0x800013A0
171 #define EVENT_NDIS_MAXMULTICAST_ERROR	0x800013A1
172 #define EVENT_NDIS_PRODUCTID_ERROR	0x800013A2
173 #define EVENT_NDIS_LOBE_FAILUE_ERROR	0x800013A3
174 #define EVENT_NDIS_SIGNAL_LOSS_ERROR	0x800013A4
175 #define EVENT_NDIS_REMOVE_RECEIVED_ERROR	0x800013A5
176 #define EVENT_NDIS_TOKEN_RING_CORRECTION	0x400013A6
177 #define EVENT_NDIS_ADAPTER_CHECK_ERROR	0xC00013A7
178 #define EVENT_NDIS_RESET_FAILURE_ERROR	0x800013A8
179 #define EVENT_NDIS_CABLE_DISCONNECTED_ERROR	0x800013A9
180 #define EVENT_NDIS_RESET_FAILURE_CORRECTION	0x800013AA
181 
182 /*
183  * NDIS OIDs used by the queryinfo/setinfo routines.
184  * Some are required by all NDIS drivers, some are specific to
185  * a particular type of device, and some are purely optional.
186  * Unfortunately, one of the purely optional OIDs is the one
187  * that lets us set the MAC address of the device.
188  */
189 
190 /* Required OIDs */
191 #define OID_GEN_SUPPORTED_LIST			0x00010101
192 #define OID_GEN_HARDWARE_STATUS			0x00010102
193 #define OID_GEN_MEDIA_SUPPORTED			0x00010103
194 #define OID_GEN_MEDIA_IN_USE			0x00010104
195 #define OID_GEN_MAXIMUM_LOOKAHEAD		0x00010105
196 #define OID_GEN_MAXIMUM_FRAME_SIZE		0x00010106
197 #define OID_GEN_LINK_SPEED			0x00010107
198 #define OID_GEN_TRANSMIT_BUFFER_SPACE		0x00010108
199 #define OID_GEN_RECEIVE_BUFFER_SPACE		0x00010109
200 #define OID_GEN_TRANSMIT_BLOCK_SIZE		0x0001010A
201 #define OID_GEN_RECEIVE_BLOCK_SIZE		0x0001010B
202 #define OID_GEN_VENDOR_ID			0x0001010C
203 #define OID_GEN_VENDOR_DESCRIPTION		0x0001010D
204 #define OID_GEN_CURRENT_PACKET_FILTER		0x0001010E
205 #define OID_GEN_CURRENT_LOOKAHEAD		0x0001010F
206 #define OID_GEN_DRIVER_VERSION			0x00010110
207 #define OID_GEN_MAXIMUM_TOTAL_SIZE		0x00010111
208 #define OID_GEN_PROTOCOL_OPTIONS		0x00010112
209 #define OID_GEN_MAC_OPTIONS			0x00010113
210 #define OID_GEN_MEDIA_CONNECT_STATUS		0x00010114
211 #define OID_GEN_MAXIMUM_SEND_PACKETS		0x00010115
212 #define OID_GEN_VENDOR_DRIVER_VERSION		0x00010116
213 #define OID_GEN_SUPPORTED_GUIDS			0x00010117
214 #define OID_GEN_NETWORK_LAYER_ADDRESSES		0x00010118	/* Set only */
215 #define OID_GEN_TRANSPORT_HEADER_OFFSET		0x00010119	/* Set only */
216 #define OID_GEN_MACHINE_NAME			0x0001021A
217 #define OID_GEN_RNDIS_CONFIG_PARAMETER		0x0001021B	/* Set only */
218 #define OID_GEN_VLAN_ID				0x0001021C
219 
220 /* Optional OIDs. */
221 #define OID_GEN_MEDIA_CAPABILITIES		0x00010201
222 #define OID_GEN_PHYSICAL_MEDIUM			0x00010202
223 
224 /* Required statistics OIDs. */
225 #define OID_GEN_XMIT_OK				0x00020101
226 #define OID_GEN_RCV_OK				0x00020102
227 #define OID_GEN_XMIT_ERROR			0x00020103
228 #define OID_GEN_RCV_ERROR			0x00020104
229 #define OID_GEN_RCV_NO_BUFFER			0x00020105
230 
231 /* Optional OID statistics */
232 #define OID_GEN_DIRECTED_BYTES_XMIT		0x00020201
233 #define OID_GEN_DIRECTED_FRAMES_XMIT		0x00020202
234 #define OID_GEN_MULTICAST_BYTES_XMIT		0x00020203
235 #define OID_GEN_MULTICAST_FRAMES_XMIT		0x00020204
236 #define OID_GEN_BROADCAST_BYTES_XMIT		0x00020205
237 #define OID_GEN_BROADCAST_FRAMES_XMIT		0x00020206
238 #define OID_GEN_DIRECTED_BYTES_RCV		0x00020207
239 #define OID_GEN_DIRECTED_FRAMES_RCV		0x00020208
240 #define OID_GEN_MULTICAST_BYTES_RCV		0x00020209
241 #define OID_GEN_MULTICAST_FRAMES_RCV		0x0002020A
242 #define OID_GEN_BROADCAST_BYTES_RCV		0x0002020B
243 #define OID_GEN_BROADCAST_FRAMES_RCV		0x0002020C
244 #define OID_GEN_RCV_CRC_ERROR			0x0002020D
245 #define OID_GEN_TRANSMIT_QUEUE_LENGTH		0x0002020E
246 #define OID_GEN_GET_TIME_CAPS			0x0002020F
247 #define OID_GEN_GET_NETCARD_TIME		0x00020210
248 #define OID_GEN_NETCARD_LOAD			0x00020211
249 #define OID_GEN_DEVICE_PROFILE			0x00020212
250 
251 /* 802.3 (ethernet) OIDs */
252 #define OID_802_3_PERMANENT_ADDRESS		0x01010101
253 #define OID_802_3_CURRENT_ADDRESS		0x01010102
254 #define OID_802_3_MULTICAST_LIST		0x01010103
255 #define OID_802_3_MAXIMUM_LIST_SIZE		0x01010104
256 #define OID_802_3_MAC_OPTIONS			0x01010105
257 #define NDIS_802_3_MAC_OPTION_PRIORITY		0x00000001
258 #define OID_802_3_RCV_ERROR_ALIGNMENT		0x01020101
259 #define OID_802_3_XMIT_ONE_COLLISION		0x01020102
260 #define OID_802_3_XMIT_MORE_COLLISIONS		0x01020103
261 #define OID_802_3_XMIT_DEFERRED			0x01020201
262 #define OID_802_3_XMIT_MAX_COLLISIONS		0x01020202
263 #define OID_802_3_RCV_OVERRUN			0x01020203
264 #define OID_802_3_XMIT_UNDERRUN			0x01020204
265 #define OID_802_3_XMIT_HEARTBEAT_FAILURE	0x01020205
266 #define OID_802_3_XMIT_TIMES_CRS_LOST		0x01020206
267 #define OID_802_3_XMIT_LATE_COLLISIONS		0x01020207
268 
269 /* PnP and power management OIDs */
270 #define OID_PNP_CAPABILITIES			0xFD010100
271 #define OID_PNP_SET_POWER			0xFD010101
272 #define OID_PNP_QUERY_POWER			0xFD010102
273 #define OID_PNP_ADD_WAKE_UP_PATTERN		0xFD010103
274 #define OID_PNP_REMOVE_WAKE_UP_PATTERN		0xFD010104
275 #define OID_PNP_WAKE_UP_PATTERN_LIST		0xFD010105
276 #define OID_PNP_ENABLE_WAKE_UP			0xFD010106
277 
278 /* PnP/PM Statistics (Optional). */
279 #define OID_PNP_WAKE_UP_OK			0xFD020200
280 #define OID_PNP_WAKE_UP_ERROR			0xFD020201
281 
282 /* The following bits are defined for OID_PNP_ENABLE_WAKE_UP */
283 #define NDIS_PNP_WAKE_UP_MAGIC_PACKET		0x00000001
284 #define NDIS_PNP_WAKE_UP_PATTERN_MATCH		0x00000002
285 #define NDIS_PNP_WAKE_UP_LINK_CHANGE		0x00000004
286 
287 /* 802.11 OIDs */
288 #define OID_802_11_BSSID			0x0D010101
289 #define OID_802_11_SSID				0x0D010102
290 #define OID_802_11_NETWORK_TYPES_SUPPORTED	0x0D010203
291 #define OID_802_11_NETWORK_TYPE_IN_USE		0x0D010204
292 #define OID_802_11_TX_POWER_LEVEL		0x0D010205
293 #define OID_802_11_RSSI				0x0D010206
294 #define OID_802_11_RSSI_TRIGGER			0x0D010207
295 #define OID_802_11_INFRASTRUCTURE_MODE		0x0D010108
296 #define OID_802_11_FRAGMENTATION_THRESHOLD	0x0D010209
297 #define OID_802_11_RTS_THRESHOLD		0x0D01020A
298 #define OID_802_11_NUMBER_OF_ANTENNAS		0x0D01020B
299 #define OID_802_11_RX_ANTENNA_SELECTED		0x0D01020C
300 #define OID_802_11_TX_ANTENNA_SELECTED		0x0D01020D
301 #define OID_802_11_SUPPORTED_RATES		0x0D01020E
302 #define OID_802_11_DESIRED_RATES		0x0D010210
303 #define OID_802_11_CONFIGURATION		0x0D010211
304 #define OID_802_11_STATISTICS			0x0D020212
305 #define OID_802_11_ADD_WEP			0x0D010113
306 #define OID_802_11_REMOVE_WEP			0x0D010114
307 #define OID_802_11_DISASSOCIATE			0x0D010115
308 #define OID_802_11_POWER_MODE			0x0D010216
309 #define OID_802_11_BSSID_LIST			0x0D010217
310 #define OID_802_11_AUTHENTICATION_MODE		0x0D010118
311 #define OID_802_11_PRIVACY_FILTER		0x0D010119
312 #define OID_802_11_BSSID_LIST_SCAN		0x0D01011A
313 #define OID_802_11_WEP_STATUS			0x0D01011B
314 #define OID_802_11_ENCRYPTION_STATUS		OID_802_11_WEP_STATUS
315 #define OID_802_11_RELOAD_DEFAULTS		0x0D01011C
316 #define OID_802_11_ADD_KEY			0x0D01011D
317 #define OID_802_11_REMOVE_KEY			0x0D01011E
318 #define OID_802_11_ASSOCIATION_INFORMATION	0x0D01011F
319 #define OID_802_11_TEST				0x0D010120
320 
321 /* structures/definitions for 802.11 */
322 #define NDIS_80211_NETTYPE_11FH		0x00000000
323 #define NDIS_80211_NETTYPE_11DS		0x00000001
324 #define NDIS_80211_NETTYPE_11OFDM5	0x00000002
325 #define NDIS_80211_NETTYPE_11OFDM24	0x00000003
326 
327 struct ndis_80211_nettype_list {
328 	uint32_t		ntl_items;
329 	uint32_t		ntl_type[1];
330 };
331 
332 #define NDIS_80211_POWERMODE_CAM	0x00000000
333 #define NDIS_80211_POWERMODE_MAX_PSP	0x00000001
334 #define NDIS_80211_POWERMODE_FAST_PSP	0x00000002
335 
336 typedef uint32_t ndis_80211_power;	/* Power in milliwatts */
337 typedef uint32_t ndis_80211_rssi;	/* Signal strength in dBm */
338 
339 struct ndis_80211_config_fh {
340 	uint32_t		ncf_length;
341 	uint32_t		ncf_hoppatterh;
342 	uint32_t		ncf_hopset;
343 	uint32_t		ncf_dwelltime;
344 };
345 
346 typedef struct ndis_80211_config_fh ndis_80211_config_fh;
347 
348 struct ndis_80211_config {
349 	uint32_t		nc_length;
350 	uint32_t		nc_beaconperiod;
351 	uint32_t		nc_atimwin;
352 	uint32_t		nc_dsconfig;
353 	ndis_80211_config_fh	nc_fhconfig;
354 };
355 
356 typedef struct ndis_80211_config ndis_80211_config;
357 
358 struct ndis_80211_stats {
359 	uint32_t		ns_length;
360 	uint64_t		ns_txfragcnt;
361 	uint64_t		ns_txmcastcnt;
362 	uint64_t		ns_failedcnt;
363 	uint64_t		ns_retrycnt;
364 	uint64_t		ns_multiretrycnt;
365 	uint64_t		ns_rtssuccesscnt;
366 	uint64_t		ns_rtsfailcnt;
367 	uint64_t		ns_ackfailcnt;
368 	uint64_t		ns_dupeframecnt;
369 	uint64_t		ns_rxfragcnt;
370 	uint64_t		ns_rxmcastcnt;
371 	uint64_t		ns_fcserrcnt;
372 };
373 
374 typedef struct ndis_80211_stats ndis_80211_stats;
375 
376 typedef uint32_t ndis_80211_key_idx;
377 
378 struct ndis_80211_wep {
379 	uint32_t		nw_length;
380 	uint32_t		nw_keyidx;
381 	uint32_t		nw_keylen;
382 	uint8_t			nw_keydata[256];
383 };
384 
385 typedef struct ndis_80211_wep ndis_80211_wep;
386 
387 #define NDIS_80211_WEPKEY_TX		0x80000000
388 #define NDIS_80211_WEPKEY_PERCLIENT	0x40000000
389 
390 #define NDIS_80211_NET_INFRA_IBSS	0x00000000
391 #define NDIS_80211_NET_INFRA_BSS	0x00000001
392 #define NDIS_80211_NET_INFRA_AUTO	0x00000002
393 
394 #define NDIS_80211_AUTHMODE_OPEN	0x00000000
395 #define NDIS_80211_AUTHMODE_SHARED	0x00000001
396 #define NDIS_80211_AUTHMODE_AUTO	0x00000002
397 #define NDIS_80211_AUTHMODE_WPA		0x00000003
398 #define NDIS_80211_AUTHMODE_WPAPSK	0x00000004
399 #define NDIS_80211_AUTHMODE_WPANONE	0x00000005
400 
401 typedef uint8_t ndis_80211_rates[8];
402 typedef uint8_t ndis_80211_rates_ex[16];
403 typedef uint8_t ndis_80211_macaddr[6];
404 
405 struct ndis_80211_ssid {
406 	uint32_t		ns_ssidlen;
407 	uint8_t			ns_ssid[32];
408 };
409 
410 typedef struct ndis_80211_ssid ndis_80211_ssid;
411 
412 struct ndis_wlan_bssid {
413 	uint32_t		nwb_length;
414 	ndis_80211_macaddr	nwb_macaddr;
415 	uint8_t			nwb_rsvd[2];
416 	ndis_80211_ssid		nwb_ssid;
417 	uint32_t		nwb_privacy;
418 	ndis_80211_rssi		nwb_rssi;
419 	uint32_t		nwb_nettype;
420 	ndis_80211_config	nwb_config;
421 	uint32_t		nwb_netinfra;
422 	ndis_80211_rates	nwb_supportedrates;
423 };
424 
425 typedef struct ndis_wlan_bssid ndis_wlan_bssid;
426 
427 struct ndis_80211_bssid_list {
428 	uint32_t		nbl_items;
429 	ndis_wlan_bssid		nbl_bssid[1];
430 };
431 
432 typedef struct ndis_80211_bssid_list ndis_80211_bssid_list;
433 
434 struct ndis_wlan_bssid_ex {
435 	uint32_t		nwbx_len;
436 	ndis_80211_macaddr	nwbx_macaddr;
437 	uint8_t			nwbx_rsvd[2];
438 	ndis_80211_ssid		nwbx_ssid;
439 	uint32_t		nwbx_privacy;
440 	ndis_80211_rssi		nwbx_rssi;
441 	uint32_t		nwbx_nettype;
442 	ndis_80211_config	nwbx_config;
443 	uint32_t		nwbx_netinfra;
444 	ndis_80211_rates_ex	nwbx_supportedrates;
445 	uint32_t		nwbx_ielen;
446 	uint32_t		nwbx_ies[1];
447 };
448 
449 typedef struct ndis_wlan_bssid_ex ndis_wlan_bssid_ex;
450 
451 struct ndis_80211_bssid_list_ex {
452 	uint32_t		nblx_items;
453 	ndis_wlan_bssid_ex	nblx_bssid[1];
454 };
455 
456 typedef struct ndis_80211_bssid_list_ex ndis_80211_bssid_list_ex;
457 
458 struct ndis_80211_fixed_ies {
459 	uint8_t			nfi_tstamp[8];
460 	uint16_t		nfi_beaconint;
461 	uint16_t		nfi_caps;
462 };
463 
464 struct ndis_80211_variable_ies {
465 	uint8_t			nvi_elemid;
466 	uint8_t			nvi_len;
467 	uint8_t			nvi_data[1];
468 };
469 
470 typedef uint32_t ndis_80211_fragthresh;
471 typedef uint32_t ndis_80211_rtsthresh;
472 typedef uint32_t ndis_80211_antenna;
473 
474 #define NDIS_80211_PRIVFILT_ACCEPTALL	0x00000000
475 #define NDIS_80211_PRIVFILT_8021XWEP	0x00000001
476 
477 #define NDIS_80211_WEPSTAT_ENABLED	0x00000000
478 #define NDIS_80211_WEPSTAT_ENC1ENABLED	NDIS_80211_WEPSTAT_ENABLED
479 #define NDIS_80211_WEPSTAT_DISABLED	0x00000001
480 #define NDIS_80211_WEPSTAT_ENCDISABLED	NDIS_80211_WEPSTAT_DISABLED
481 #define NDIS_80211_WEPSTAT_KEYABSENT	0x00000002
482 #define NDIS_80211_WEPSTAT_ENC1KEYABSENT	NDIS_80211_WEPSTAT_KEYABSENT
483 #define NDIS_80211_WEPSTAT_NOTSUPPORTED	0x00000003
484 #define NDIS_80211_WEPSTAT_ENCNOTSUPPORTED	NDIS_80211_WEPSTAT_NOTSUPPORTED
485 #define NDIS_80211_WEPSTAT_ENC2ENABLED	0x00000004
486 #define NDIS_80211_WEPSTAT_ENC2KEYABSENT	0x00000005
487 #define NDIS_80211_WEPSTAT_ENC3ENABLED	0x00000006
488 #define NDIS_80211_WEPSTAT_ENC3KEYABSENT	0x00000007
489 
490 #define NDIS_80211_RELOADDEFAULT_WEP	0x00000000
491 
492 #define NDIS_80211_STATUSTYPE_AUTH	0x00000000
493 
494 struct ndis_80211_status_indication {
495 	uint32_t		nsi_type;
496 };
497 
498 typedef struct ndis_80211_status_indication ndis_80211_status_indication;
499 
500 struct ndis_80211_auth_request {
501 	uint32_t		nar_len;
502 	ndis_80211_macaddr	nar_bssid;
503 	uint32_t		nar_flags;
504 };
505 
506 typedef struct ndis_80211_auth_request ndis_80211_auth_request;
507 
508 struct ndis_80211_key {
509 	uint32_t		nk_len;
510 	uint32_t		nk_keyidx;
511 	uint32_t		nk_keylen;
512 	ndis_80211_macaddr	nk_bssid;
513 	uint64_t		nk_keyrsc;
514 	uint8_t			nk_keydata[256];
515 };
516 
517 typedef struct ndis_80211_key ndis_80211_key;
518 
519 struct ndis_80211_remove_key {
520 	uint32_t		nk_len;
521 	uint32_t		nk_keyidx;
522 	ndis_80211_macaddr	nk_bssid;
523 };
524 
525 typedef struct ndis_80211_remove_key ndis_80211_remove_key;
526 
527 #define NDIS_80211_AI_REQFI_CAPABILITIES	0x00000001
528 #define NDIS_80211_AI_REQFI_LISTENINTERVAL	0x00000002
529 #define NDIS_80211_AI_REQFI_CURRENTAPADDRESS	0x00000004
530 
531 #define NDIS_80211_AI_RESFI_CAPABILITIES	0x00000001
532 #define NDIS_80211_AI_RESFI_STATUSCODE		0x00000002
533 #define NDIS_80211_AI_RESFI_ASSOCIATIONID	0x00000004
534 
535 struct ndis_80211_ai_reqfi {
536 	uint16_t		naq_caps;
537 	uint16_t		naq_listentint;
538 	ndis_80211_macaddr	naq_currentapaddr;
539 };
540 
541 typedef struct ndis_80211_ai_reqfi ndis_80211_ai_reqfi;
542 
543 struct ndis_80211_ai_resfi {
544 	uint16_t		nas_caps;
545 	uint16_t		nas_statuscode;
546 	uint16_t		nas_associd;
547 };
548 
549 typedef struct ndis_80211_ai_resfi ndis_80211_ai_resfi;
550 
551 struct ndis_80211_assoc_info {
552 	uint32_t		nai_len;
553 	uint16_t		nai_avail_req_fixed_ies;
554 	ndis_80211_ai_reqfi	nai_req_fixed_ies;
555 	uint32_t		nai_req_ielen;
556 	uint32_t		nai_offset_req_ies;
557 	uint16_t		nai_avail_resp_fixed_ies;
558 	ndis_80211_ai_resfi	nai_resp_fixed_iex;
559 	uint32_t		nai_resp_ielen;
560 	uint32_t		nai_offset_resp_ies;
561 };
562 
563 typedef struct ndis_80211_assoc_info ndis_80211_assoc_info;
564 
565 struct ndis_80211_auth_event {
566 	ndis_80211_status_indication	nae_status;
567 	ndis_80211_auth_request		nae_request[1];
568 };
569 
570 typedef struct ndis_80211_auth_event ndis_80211_auth_event;
571 
572 struct ndis_80211_test {
573 	uint32_t		nt_len;
574 	uint32_t		nt_type;
575 	union {
576 		ndis_80211_auth_event	nt_authevent;
577 		uint32_t		nt_rssitrigger;
578 	} u;
579 };
580 
581 typedef struct ndis_80211_test ndis_80211_test;
582 
583 /* TCP OIDs. */
584 
585 #define OID_TCP_TASK_OFFLOAD			0xFC010201
586 #define OID_TCP_TASK_IPSEC_ADD_SA		0xFC010202
587 #define OID_TCP_TASK_IPSEC_DELETE_SA		0xFC010203
588 #define OID_TCP_SAN_SUPPORT			0xFC010204
589 
590 
591 #define NDIS_TASK_OFFLOAD_VERSION 1
592 
593 #define NDIS_TASK_TCPIP_CSUM			0x00000000
594 #define NDIS_TASK_IPSEC				0x00000001
595 #define NDIS_TASK_TCP_LARGESEND			0x00000002
596 
597 #define NDIS_ENCAP_UNSPEC			0x00000000
598 #define NDIS_ENCAP_NULL				0x00000001
599 #define NDIS_ENCAP_IEEE802_3			0x00000002
600 #define NDIS_ENCAP_IEEE802_5			0x00000003
601 #define NDIS_ENCAP_SNAP_ROUTED			0x00000004
602 #define NDIS_ENCAP_SNAP_BRIDGED			0x00000005
603 
604 #define NDIS_ENCAPFLAG_FIXEDHDRLEN		0x00000001
605 
606 struct ndis_encap_fmt {
607 	uint32_t		nef_encap;
608 	uint32_t		nef_flags;
609 	uint32_t		nef_encaphdrlen;
610 };
611 
612 typedef struct ndis_encap_fmt ndis_encap_fmt;
613 
614 struct ndis_task_offload_hdr {
615 	uint32_t		ntoh_vers;
616 	uint32_t		ntoh_len;
617 	uint32_t		ntoh_rsvd;
618 	uint32_t		ntoh_offset_firsttask;
619 	ndis_encap_fmt		ntoh_encapfmt;
620 };
621 
622 typedef struct ndis_task_offload_hdr ndis_task_offload_hdr;
623 
624 struct ndis_task_offload {
625 	uint32_t		nto_vers;
626 	uint32_t		nto_len;
627 	uint32_t		nto_task;
628 	uint32_t		nto_offset_nexttask;
629 	uint32_t		nto_taskbuflen;
630 	uint8_t			nto_taskbuf[1];
631 };
632 
633 typedef struct ndis_task_offload ndis_task_offload;
634 
635 #define NDIS_TCPSUM_FLAGS_IP_OPTS	0x00000001
636 #define NDIS_TCPSUM_FLAGS_TCP_OPTS	0x00000002
637 #define NDIS_TCPSUM_FLAGS_TCP_CSUM	0x00000004
638 #define NDIS_TCPSUM_FLAGS_UDP_CSUM	0x00000008
639 #define NDIS_TCPSUM_FLAGS_IP_CSUM	0x00000010
640 
641 struct ndis_task_tcpip_csum {
642 	uint32_t		nttc_v4tx;
643 	uint32_t		nttc_v4rx;
644 	uint32_t		nttc_v6tx;
645 	uint32_t		nttc_v6rx;
646 };
647 
648 typedef struct ndis_task_tcpip_csum ndis_task_tcpip_csum;
649 
650 struct ndis_task_tcp_largesend {
651 	uint32_t		nttl_vers;
652 	uint32_t		nttl_maxofflen;
653 	uint32_t		nttl_minsegcnt;
654 	uint8_t			nttl_tcpopt;
655 	uint8_t			nttl_ipopt;
656 };
657 
658 typedef struct ndis_task_tcp_largesend ndis_task_tcp_largesend;
659 
660 #define NDIS_IPSEC_AH_MD5		0x00000001
661 #define NDIS_IPSEC_AH_SHA1		0x00000002
662 #define NDIS_IPSEC_AH_TRANSPORT		0x00000004
663 #define NDIS_IPSEC_AH_TUNNEL		0x00000008
664 #define NDIS_IPSEC_AH_SEND		0x00000010
665 #define NDIS_IPSEC_AH_RECEIVE		0x00000020
666 
667 #define NDIS_IPSEC_ESP_DES		0x00000001
668 #define NDIS_IPSEC_ESP_RSVD		0x00000002
669 #define NDIS_IPSEC_ESP_3DES		0x00000004
670 #define NDIS_IPSEC_ESP_NULL		0x00000008
671 #define NDIS_IPSEC_ESP_TRANSPORT	0x00000010
672 #define NDIS_IPSEC_ESP_TUNNEL		0x00000020
673 #define NDIS_IPSEC_ESP_SEND		0x00000040
674 #define NDIS_IPSEC_ESP_RECEIVE		0x00000080
675 
676 struct ndis_task_ipsec {
677 	uint32_t		nti_ah_esp_combined;
678 	uint32_t		nti_ah_transport_tunnel_combined;
679 	uint32_t		nti_v4_options;
680 	uint32_t		nti_rsvd;
681 	uint32_t		nti_v4ah;
682 	uint32_t		nti_v4esp;
683 };
684 
685 typedef struct ndis_task_ipsec ndis_task_ipsec;
686 
687 /*
688  * Attribures of NDIS drivers. Not all drivers support
689  * all attributes.
690  */
691 
692 #define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT		0x00000002
693 #define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS		0x00000004
694 #define NDIS_ATTRIBUTE_BUS_MASTER			0x00000008
695 #define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER		0x00000010
696 #define NDIS_ATTRIBUTE_DESERIALIZE			0x00000020
697 #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND		0x00000040
698 #define NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK		0x00000080
699 #define NDIS_ATTRIBUTE_NOT_CO_NDIS			0x00000100
700 #define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS		0x00000200
701 
702 #define NDIS_SERIALIZED(block)		\
703 	(((block)->nmb_flags & NDIS_ATTRIBUTE_DESERIALIZE) == 0)
704 
705 enum ndis_media_state {
706 	nmc_connected,
707 	nmc_disconnected
708 };
709 
710 typedef enum ndis_media_state ndis_media_state;
711 
712 /* Ndis Packet Filter Bits (OID_GEN_CURRENT_PACKET_FILTER). */
713 
714 #define NDIS_PACKET_TYPE_DIRECTED               0x00000001
715 #define NDIS_PACKET_TYPE_MULTICAST              0x00000002
716 #define NDIS_PACKET_TYPE_ALL_MULTICAST          0x00000004
717 #define NDIS_PACKET_TYPE_BROADCAST              0x00000008
718 #define NDIS_PACKET_TYPE_SOURCE_ROUTING         0x00000010
719 #define NDIS_PACKET_TYPE_PROMISCUOUS            0x00000020
720 #define NDIS_PACKET_TYPE_SMT                    0x00000040
721 #define NDIS_PACKET_TYPE_ALL_LOCAL              0x00000080
722 #define NDIS_PACKET_TYPE_GROUP                  0x00001000
723 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL         0x00002000
724 #define NDIS_PACKET_TYPE_FUNCTIONAL             0x00004000
725 #define NDIS_PACKET_TYPE_MAC_FRAME              0x00008000
726 
727 
728 /* Ndis MAC option bits (OID_GEN_MAC_OPTIONS). */
729 
730 #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA             0x00000001
731 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED              0x00000002
732 #define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND              0x00000004
733 #define NDIS_MAC_OPTION_NO_LOOPBACK                     0x00000008
734 #define NDIS_MAC_OPTION_FULL_DUPLEX                     0x00000010
735 #define NDIS_MAC_OPTION_EOTX_INDICATION                 0x00000020
736 #define NDIS_MAC_OPTION_8021P_PRIORITY                  0x00000040
737 #define NDIS_MAC_OPTION_SUPPORTS_MAC_ADDRESS_OVERWRITE  0x00000080
738 #define NDIS_MAC_OPTION_RECEIVE_AT_DPC                  0x00000100
739 #define NDIS_MAC_OPTION_8021Q_VLAN                      0x00000200
740 #define NDIS_MAC_OPTION_RESERVED                        0x80000000
741 
742 #define NDIS_DMA_24BITS		0x00
743 #define NDIS_DMA_32BITS		0x01
744 #define NDIS_DMA_64BITS		0x02
745 
746 /*
747 struct ndis_physaddr {
748 #ifdef __i386__
749 	uint64_t		np_quad;
750 #endif
751 #ifdef __amd64__
752 	uint32_t		np_low;
753 	uint32_t		np_high;
754 #define np_quad np_low
755 #endif
756 #ifdef notdef
757 	uint32_t		np_low;
758 	uint32_t		np_high;
759 #endif
760 };
761 */
762 
763 typedef struct physaddr ndis_physaddr;
764 
765 struct ndis_ansi_string {
766 	uint16_t		nas_len;
767 	uint16_t		nas_maxlen;
768 	char			*nas_buf;
769 };
770 
771 typedef struct ndis_ansi_string ndis_ansi_string;
772 
773 #ifdef notdef
774 /*
775  * nus_buf is really a wchar_t *, but it's inconvenient to include
776  * all the necessary header goop needed to define it, and it's a
777  * pointer anyway, so for now, just make it a uint16_t *.
778  */
779 struct ndis_unicode_string {
780 	uint16_t		nus_len;
781 	uint16_t		nus_maxlen;
782 	uint16_t		*nus_buf;
783 };
784 typedef struct ndis_unicode_string ndis_unicode_string;
785 #endif
786 
787 typedef unicode_string ndis_unicode_string;
788 
789 enum ndis_parm_type {
790 	ndis_parm_int,
791 	ndis_parm_hexint,
792 	ndis_parm_string,
793 	ndis_parm_multistring,
794 	ndis_parm_binary
795 };
796 
797 typedef enum ndis_parm_type ndis_parm_type;
798 
799 struct ndis_binary_data {
800 	uint16_t		nbd_len;
801 	void			*nbd_buf;
802 };
803 
804 typedef struct ndis_binary_data ndis_binary_data;
805 
806 struct ndis_config_parm {
807 	ndis_parm_type		ncp_type;
808 	union {
809 		uint32_t		ncp_intdata;
810 		ndis_unicode_string	ncp_stringdata;
811 		ndis_binary_data	ncp_binarydata;
812 	} ncp_parmdata;
813 };
814 
815 typedef struct ndis_config_parm ndis_config_parm;
816 
817 #ifdef notdef
818 struct ndis_list_entry {
819 	struct ndis_list_entry *nle_flink;
820 	struct ndis_list_entry *nle_blink;
821 };
822 
823 typedef struct ndis_list_entry ndis_list_entry;
824 #endif
825 
826 struct ndis_bind_paths {
827 	uint32_t		nbp_number;
828 	ndis_unicode_string	nbp_paths[1];
829 };
830 
831 typedef struct ndis_bind_paths ndis_bind_paths;
832 
833 #ifdef notdef
834 struct dispatch_header {
835 	uint8_t			dh_type;
836 	uint8_t			dh_abs;
837 	uint8_t			dh_size;
838 	uint8_t			dh_inserted;
839 	uint32_t		dh_sigstate;
840 	list_entry		dh_waitlisthead;
841 };
842 #endif
843 
844 #define dispatch_header nt_dispatch_header
845 
846 struct ndis_ktimer {
847 	struct dispatch_header	nk_header;
848 	uint64_t		nk_duetime;
849 	list_entry		nk_timerlistentry;
850 	void			*nk_dpc;
851 	uint32_t		nk_period;
852 };
853 
854 struct ndis_kevent {
855 	struct dispatch_header	nk_header;
856 };
857 
858 struct ndis_event {
859 	struct nt_kevent	ne_event;
860 };
861 
862 typedef struct ndis_event ndis_event;
863 
864 /* Kernel defered procedure call (i.e. timer callback) */
865 
866 struct ndis_kdpc;
867 typedef void (*ndis_kdpc_func)(struct ndis_kdpc *, void *, void *, void *);
868 
869 struct ndis_kdpc {
870 	uint16_t		nk_type;
871 	uint8_t			nk_num;
872 	uint8_t			nk_importance;
873 	list_entry		nk_dpclistentry;
874 	ndis_kdpc_func		nk_deferedfunc;
875 	void			*nk_deferredctx;
876 	void			*nk_sysarg1;
877 	void			*nk_sysarg2;
878 	uint32_t		*nk_lock;
879 };
880 
881 struct ndis_timer {
882 	struct ktimer		nt_ktimer;
883 	struct kdpc		nt_kdpc;
884 };
885 
886 typedef struct ndis_timer ndis_timer;
887 
888 typedef __stdcall void (*ndis_timer_function)(void *, void *, void *, void *);
889 
890 struct ndis_miniport_timer {
891 	struct ktimer		nmt_ktimer;
892 	struct kdpc		nmt_kdpc;
893 	ndis_timer_function	nmt_timerfunc;
894 	void			*nmt_timerctx;
895 	ndis_miniport_block	*nmt_block;
896 	struct ndis_miniport_timer	*nmt_nexttimer;
897 };
898 
899 typedef struct ndis_miniport_timer ndis_miniport_timer;
900 
901 struct ndis_spin_lock {
902 	ndis_kspin_lock		nsl_spinlock;
903 	ndis_kirql		nsl_kirql;
904 };
905 
906 typedef struct ndis_spin_lock ndis_spin_lock;
907 
908 struct ndis_request {
909 	uint8_t			nr_macreserved[4*sizeof(void *)];
910 	uint32_t		nr_requesttype;
911 	union _ndis_data {
912 		struct _ndis_query_information {
913 			ndis_oid	nr_oid;
914 			void		*nr_infobuf;
915 			uint32_t	nr_infobuflen;
916 			uint32_t	nr_byteswritten;
917 			uint32_t	nr_bytesneeded;
918 		} ndis_query_information;
919 		struct _ndis_set_information {
920 			ndis_oid	nr_oid;
921 			void		*nr_infobuf;
922 			uint32_t	nr_infobuflen;
923 			uint32_t	nr_byteswritten;
924 			uint32_t	nr_bytesneeded;
925 		} ndis_set_information;
926 	} ndis_data;
927 	/* NDIS 5.0 extentions */
928 	uint8_t			nr_ndis_rsvd[9 * sizeof(void *)];
929 	union {
930 		uint8_t		nr_callmgr_rsvd[2 * sizeof(void *)];
931 		uint8_t		nr_protocol_rsvd[2 * sizeof(void *)];
932 	} u;
933 	uint8_t			nr_miniport_rsvd[2 * sizeof(void *)];
934 };
935 
936 typedef struct ndis_request ndis_request;
937 
938 /*
939  * Filler, not used.
940  */
941 struct ndis_miniport_interrupt {
942 	void			*ni_introbj;
943 	ndis_kspin_lock		ni_dpccountlock;
944 	void			*ni_rsvd;
945 	void			*ni_isrfunc;
946 	void			*ni_dpcfunc;
947 	struct ndis_kdpc	ni_dpc;
948 	ndis_miniport_block	*ni_block;
949 	uint8_t			ni_dpccnt;
950 	uint8_t			ni_filler1;
951 	struct ndis_kevent	ni_dpcsdoneevent;
952 	uint8_t			ni_shared;
953 	uint8_t			ni_isrreq;
954 };
955 
956 typedef struct ndis_miniport_interrupt ndis_miniport_interrupt;
957 
958 enum ndis_interrupt_mode {
959 	nim_level,
960 	nim_latched
961 };
962 
963 typedef enum ndis_interrupt_mode ndis_interrupt_mode;
964 
965 struct ndis_work_item;
966 
967 typedef void (*ndis_proc)(struct ndis_work_item *, void *);
968 
969 struct ndis_work_item {
970 	void			*nwi_ctx;
971 	void			*nwi_func;
972 	uint8_t			nwi_wraprsvd[sizeof(void *) * 8];
973 };
974 
975 typedef struct ndis_work_item ndis_work_item;
976 
977 #ifdef notdef
978 struct ndis_buffer {
979 	struct ndis_buffer	*nb_next;
980 	uint16_t		nb_size;
981 	uint16_t		nb_flags;
982 	void			*nb_process;
983 	void			*nb_mappedsystemva;
984 	void			*nb_startva;
985 	uint32_t		nb_bytecount;
986 	uint32_t		nb_byteoffset;
987 };
988 
989 typedef struct ndis_buffer ndis_buffer;
990 #endif
991 
992 struct ndis_sc_element {
993 	ndis_physaddr		nse_addr;
994 	uint32_t		nse_len;
995 	uint32_t		*nse_rsvd;
996 };
997 
998 typedef struct ndis_sc_element ndis_sc_element;
999 
1000 #define NDIS_MAXSEG		32
1001 #define NDIS_BUS_SPACE_SHARED_MAXADDR	0x3E7FFFFF
1002 
1003 struct ndis_sc_list {
1004 	uint32_t		nsl_frags;
1005 	uint32_t		*nsl_rsvd;
1006 	ndis_sc_element		nsl_elements[NDIS_MAXSEG];
1007 };
1008 
1009 typedef struct ndis_sc_list ndis_sc_list;
1010 
1011 struct ndis_tcpip_csum {
1012 	union {
1013 		uint32_t		ntc_txflags;
1014 		uint32_t		ntc_rxflags;
1015 		uint32_t		ntc_val;
1016 	} u;
1017 };
1018 
1019 typedef struct ndis_tcpip_csum ndis_tcpip_csum;
1020 
1021 #define NDIS_TXCSUM_DO_IPV4		0x00000001
1022 #define NDIS_TXCSUM_DO_IPV6		0x00000002
1023 #define NDIS_TXCSUM_DO_TCP		0x00000004
1024 #define NDIS_TXCSUM_DO_UDP		0x00000008
1025 #define NDIS_TXCSUM_DO_IP		0x00000010
1026 
1027 #define NDIS_RXCSUM_TCP_FAILED		0x00000001
1028 #define NDIS_RXCSUM_UDP_FAILED		0x00000002
1029 #define NDIS_RXCSUM_IP_FAILED		0x00000004
1030 #define NDIS_RXCSUM_TCP_PASSED		0x00000008
1031 #define NDIS_RXCSUM_UDP_PASSED		0x00000010
1032 #define NDIS_RXCSUM_IP_PASSED		0x00000020
1033 #define NDIS_RXCSUM_LOOPBACK		0x00000040
1034 
1035 struct ndis_vlan {
1036 	union {
1037 		struct {
1038 			uint32_t			nvt_userprio:3;
1039 			uint32_t			nvt_canformatid:1;
1040 			uint32_t			nvt_vlanid:12;
1041 			uint32_t			nvt_rsvd:16;
1042 		} nv_taghdr;
1043 	} u;
1044 };
1045 
1046 typedef struct ndis_vlan ndis_vlan;
1047 
1048 enum ndis_perpkt_info {
1049 	ndis_tcpipcsum_info,
1050 	ndis_ipsec_info,
1051 	ndis_largesend_info,
1052 	ndis_classhandle_info,
1053 	ndis_rsvd,
1054 	ndis_sclist_info,
1055 	ndis_ieee8021q_info,
1056 	ndis_originalpkt_info,
1057         ndis_packetcancelid,
1058 	ndis_maxpkt_info
1059 };
1060 
1061 typedef enum ndis_perpkt_info ndis_perpkt_info;
1062 
1063 struct ndis_packet_extension {
1064 	void			*npe_info[ndis_maxpkt_info];
1065 };
1066 
1067 typedef struct ndis_packet_extension ndis_packet_extension;
1068 
1069 struct ndis_packet_private {
1070 	uint32_t		npp_physcnt;
1071 	uint32_t		npp_totlen;
1072 	ndis_buffer		*npp_head;
1073 	ndis_buffer		*npp_tail;
1074 
1075 	void			*npp_pool;
1076 	uint32_t		npp_count;
1077 	uint32_t		npp_flags;
1078 	uint8_t			npp_validcounts;
1079 	uint8_t			npp_ndispktflags;
1080 	uint16_t		npp_packetooboffset;
1081 };
1082 
1083 #define NDIS_FLAGS_PROTOCOL_ID_MASK             0x0000000F
1084 #define NDIS_FLAGS_MULTICAST_PACKET             0x00000010
1085 #define NDIS_FLAGS_RESERVED2                    0x00000020
1086 #define NDIS_FLAGS_RESERVED3                    0x00000040
1087 #define NDIS_FLAGS_DONT_LOOPBACK                0x00000080
1088 #define NDIS_FLAGS_IS_LOOPBACK_PACKET           0x00000100
1089 #define NDIS_FLAGS_LOOPBACK_ONLY                0x00000200
1090 #define NDIS_FLAGS_RESERVED4                    0x00000400
1091 #define NDIS_FLAGS_DOUBLE_BUFFERED              0x00000800
1092 #define NDIS_FLAGS_SENT_AT_DPC                  0x00001000
1093 #define NDIS_FLAGS_USES_SG_BUFFER_LIST          0x00002000
1094 
1095 #define NDIS_PACKET_WRAPPER_RESERVED			0x3F
1096 #define NDIS_PACKET_CONTAINS_MEDIA_SPECIFIC_INFO	0x40
1097 #define NDIS_PACKET_ALLOCATED_BY_NDIS			0x80
1098 
1099 #define NDIS_PROTOCOL_ID_DEFAULT        0x00
1100 #define NDIS_PROTOCOL_ID_TCP_IP         0x02
1101 #define NDIS_PROTOCOL_ID_IPX            0x06
1102 #define NDIS_PROTOCOL_ID_NBF            0x07
1103 #define NDIS_PROTOCOL_ID_MAX            0x0F
1104 #define NDIS_PROTOCOL_ID_MASK           0x0F
1105 
1106 typedef struct ndis_packet_private ndis_packet_private;
1107 
1108 enum ndis_classid {
1109 	ndis_class_802_3prio,
1110 	ndis_class_wirelesswan_mbx,
1111 	ndis_class_irda_packetinfo,
1112 	ndis_class_atm_aainfo
1113 };
1114 
1115 typedef enum ndis_classid ndis_classid;
1116 
1117 struct ndis_mediaspecific_info {
1118 	uint32_t		nmi_nextentoffset;
1119 	ndis_classid		nmi_classid;
1120 	uint32_t		nmi_size;
1121 	uint8_t			nmi_classinfo[1];
1122 };
1123 
1124 typedef struct ndis_mediaspecific_info ndis_mediaspecific_info;
1125 
1126 struct ndis_packet_oob {
1127 	union {
1128 		uint64_t		npo_timetotx;
1129 		uint64_t		npo_timetxed;
1130 	} u;
1131 	uint64_t			npo_timerxed;
1132 	uint32_t			npo_hdrlen;
1133 	uint32_t			npo_mediaspecific_len;
1134 	void				*npo_mediaspecific;
1135 	ndis_status			npo_status;
1136 };
1137 
1138 typedef struct ndis_packet_oob ndis_packet_oob;
1139 
1140 struct ndis_packet {
1141 	ndis_packet_private	np_private;
1142 	union {
1143 		/* For connectionless miniports. */
1144 		struct {
1145 			uint8_t		np_miniport_rsvd[2 * sizeof(void *)];
1146 			uint8_t		np_wrapper_rsvd[2 * sizeof(void *)];
1147 		} np_clrsvd;
1148 		/* For de-serialized miniports */
1149 		struct {
1150 			uint8_t		np_miniport_rsvdex[3 * sizeof(void *)];
1151 			uint8_t		np_wrapper_rsvdex[sizeof(void *)];
1152 		} np_dsrsvd;
1153 		struct {
1154 			uint8_t		np_mac_rsvd[4 * sizeof(void *)];
1155 		} np_macrsvd;
1156 	} u;
1157 	uint32_t		*np_rsvd[2];
1158 	uint8_t			nm_protocolreserved[1];
1159 
1160 	/*
1161 	 * This next part is probably wrong, but we need some place
1162 	 * to put the out of band data structure...
1163 	 */
1164 	ndis_packet_oob		np_oob;
1165 	ndis_packet_extension	np_ext;
1166 	ndis_sc_list		np_sclist;
1167 
1168 	/* BSD-specific stuff which should be invisible to drivers. */
1169 
1170 	uint32_t		np_refcnt;
1171 	void			*np_softc;
1172 	void			*np_m0;
1173 	int			np_txidx;
1174 	kspin_lock		np_lock;
1175 };
1176 
1177 typedef struct ndis_packet ndis_packet;
1178 
1179 #define PROTOCOL_RESERVED_SIZE_IN_PACKET	(4 * sizeof(void *))
1180 
1181 /* mbuf ext type for NDIS */
1182 #define EXT_NDIS		0x999
1183 
1184 /* mtx type for NDIS */
1185 #define MTX_NDIS_LOCK "NDIS lock"
1186 
1187 struct ndis_filterdbs {
1188 	union {
1189 		void			*nf_ethdb;
1190 		void			*nf_nulldb;
1191 	} u;
1192 	void			*nf_trdb;
1193 	void			*nf_fddidb;
1194 	void			*nf_arcdb;
1195 };
1196 
1197 typedef struct ndis_filterdbs ndis_filterdbs;
1198 
1199 enum ndis_medium {
1200     NdisMedium802_3,
1201     NdisMedium802_5,
1202     NdisMediumFddi,
1203     NdisMediumWan,
1204     NdisMediumLocalTalk,
1205     NdisMediumDix,              /* defined for convenience, not a real medium */
1206     NdisMediumArcnetRaw,
1207     NdisMediumArcnet878_2,
1208     NdisMediumAtm,
1209     NdisMediumWirelessWan,
1210     NdisMediumIrda,
1211     NdisMediumBpc,
1212     NdisMediumCoWan,
1213     NdisMedium1394,
1214     NdisMediumMax
1215 };
1216 
1217 typedef enum ndis_medium ndis_medium;
1218 /*
1219 enum interface_type {
1220 	InterfaceTypeUndefined = -1,
1221 	Internal,
1222 	Isa,
1223 	Eisa,
1224 	MicroChannel,
1225 	TurboChannel,
1226 	PCIBus,
1227 	VMEBus,
1228 	NuBus,
1229 	PCMCIABus,
1230 	CBus,
1231 	MPIBus,
1232 	MPSABus,
1233 	ProcessorInternal,
1234 	InternalPowerBus,
1235 	PNPISABus,
1236 	PNPBus,
1237 	MaximumInterfaceType
1238 };
1239 */
1240 enum ndis_interface_type {
1241 	NdisInterfaceInternal = Internal,
1242 	NdisInterfaceIsa = Isa,
1243 	NdisInterfaceEisa = Eisa,
1244 	NdisInterfaceMca = MicroChannel,
1245 	NdisInterfaceTurboChannel = TurboChannel,
1246 	NdisInterfacePci = PCIBus,
1247 	NdisInterfacePcMcia = PCMCIABus
1248 };
1249 
1250 typedef enum ndis_interface_type ndis_interface_type;
1251 
1252 struct ndis_paddr_unit {
1253 	ndis_physaddr		npu_physaddr;
1254 	uint32_t		npu_len;
1255 };
1256 
1257 typedef struct ndis_paddr_unit ndis_paddr_unit;
1258 
1259 struct ndis_map_arg {
1260 	ndis_paddr_unit		*nma_fraglist;
1261 	int			nma_cnt;
1262 	int			nma_max;
1263 };
1264 
1265 /*
1266  * Miniport characteristics were originally defined in the NDIS 3.0
1267  * spec and then extended twice, in NDIS 4.0 and 5.0.
1268  */
1269 
1270 struct ndis_miniport_characteristics {
1271 
1272 	/* NDIS 3.0 */
1273 
1274 	uint8_t			nmc_version_major;
1275 	uint8_t			nmc_version_minor;
1276 	uint16_t		nmc_pad;
1277 	uint32_t		nmc_rsvd;
1278 	void *			nmc_checkhang_func;
1279 	void *			nmc_disable_interrupts_func;
1280 	void *			nmc_enable_interrupts_func;
1281 	void *			nmc_halt_func;
1282 	void *			nmc_interrupt_func;
1283 	void *			nmc_init_func;
1284 	void *			nmc_isr_func;
1285 	void *			nmc_queryinfo_func;
1286 	void *			nmc_reconfig_func;
1287 	void *			nmc_reset_func;
1288 	void *			nmc_sendsingle_func;
1289 	void *			nmc_setinfo_func;
1290 	void *			nmc_transferdata_func;
1291 
1292 	/* NDIS 4.0 extentions */
1293 
1294 	void *			nmc_return_packet_func;
1295 	void *			nmc_sendmulti_func;
1296 	void *			nmc_allocate_complete_func;
1297 
1298 	/* NDIS 5.0 extensions */
1299 
1300 	void *			nmc_cocreatevc_func;
1301 	void *			nmc_codeletevc_func;
1302 	void *			nmc_coactivatevc_func;
1303 	void *			nmc_codeactivatevc_func;
1304 	void *			nmc_comultisend_func;
1305 	void *			nmc_corequest_func;
1306 
1307 	/* NDIS 5.1 extentions */
1308 
1309 	void *			nmc_canceltxpkts_handler;
1310 	void *			nmc_pnpevent_handler;
1311 	void *			nmc_shutdown_handler;
1312 	void *			nmc_rsvd0;
1313 	void *			nmc_rsvd1;
1314 	void *			nmc_rsvd2;
1315 	void *			nmc_rsvd3;
1316 };
1317 
1318 typedef struct ndis_miniport_characteristics ndis_miniport_characteristics;
1319 
1320 struct ndis_driver_object {
1321 	char			*ndo_ifname;
1322 	void			*ndo_softc;
1323 	ndis_miniport_characteristics ndo_chars;
1324 };
1325 
1326 typedef struct ndis_driver_object ndis_driver_object;
1327 
1328 struct ndis_reference {
1329 	ndis_kspin_lock		nr_spinlock;
1330 	uint16_t		nr_refcnt;
1331 	uint8_t			nr_closing;
1332 };
1333 
1334 typedef struct ndis_reference ndis_reference;
1335 
1336 struct ndis_timer_entry {
1337 	struct callout		nte_ch;
1338 	ndis_miniport_timer	*nte_timer;
1339 	TAILQ_ENTRY(ndis_timer_entry)	link;
1340 };
1341 
1342 TAILQ_HEAD(nte_head, ndis_timer_entry);
1343 
1344 #define NDIS_FH_TYPE_VFS	0
1345 #define NDIS_FH_TYPE_MODULE	1
1346 
1347 struct ndis_fh {
1348 	int			nf_type;
1349 	void			*nf_vp;
1350 	void			*nf_map;
1351 	uint32_t		nf_maplen;
1352 };
1353 
1354 typedef struct ndis_fh ndis_fh;
1355 
1356 /*
1357  * The miniport block is basically the internal NDIS handle. We need
1358  * to define this because, unfortunately, it is not entirely opaque
1359  * to NDIS drivers. For one thing, it contains the function pointer
1360  * to the NDIS packet receive handler, which is invoked out of the
1361  * NDIS block via a macro rather than a function pointer. (The
1362  * NdisMIndicateReceivePacket() routine is a macro rather than
1363  * a function.) For another, the driver maintains a pointer to the
1364  * miniport block and passes it as a handle to various NDIS functions.
1365  * (The driver never really knows this because it's hidden behind
1366  * an ndis_handle though.)
1367  *
1368  * The miniport block has two parts: the first part contains fields
1369  * that must never change, since they are referenced by driver
1370  * binaries through macros. The second part is ignored by the driver,
1371  * but contains various things used internaly by NDIS.SYS. In our
1372  * case, we define the first 'immutable' part exactly as it appears
1373  * in Windows, but don't bother duplicating the Windows definitions
1374  * for the second part. Instead, we replace them with a few BSD-specific
1375  * things.
1376  */
1377 
1378 struct ndis_miniport_block {
1379 	/*
1380 	 * Windows-specific portion -- DO NOT MODIFY OR NDIS
1381 	 * DRIVERS WILL NOT WORK.
1382 	 */
1383 	void			*nmb_signature;	/* magic number */
1384 	ndis_miniport_block	*nmb_nextminiport;
1385 	ndis_mdriver_block	*nmb_driverhandle;
1386 	ndis_handle		nmb_miniportadapterctx;
1387 	ndis_unicode_string	nmb_name;
1388 	ndis_bind_paths		*nmb_bindpaths;
1389 	ndis_handle		nmb_openqueue;
1390 	ndis_reference		nmb_ref;
1391 	ndis_handle		nmb_devicectx;
1392 	uint8_t			nmb_padding;
1393 	uint8_t			nmb_lockacquired;
1394 	uint8_t			nmb_pmodeopens;
1395 	uint8_t			nmb_assignedcpu;
1396 	ndis_kspin_lock		nmb_lock;
1397 	ndis_request		*nmb_mediarequest;
1398 	ndis_miniport_interrupt	*nmb_interrupt;
1399 	uint32_t		nmb_flags;
1400 	uint32_t		nmb_pnpflags;
1401 	list_entry		nmb_packetlist;
1402 	ndis_packet		*nmb_firstpendingtxpacket;
1403 	ndis_packet		*nmb_returnpacketqueue;
1404 	uint32_t		nmb_requestbuffer;
1405 	void			*nmb_setmcastbuf;
1406 	ndis_miniport_block	*nmb_primaryminiport;
1407 	void			*nmb_wrapperctx;
1408 	void			*nmb_busdatactx;
1409 	uint32_t		nmb_pnpcaps;
1410 	cm_resource_list	*nmb_resources;
1411 	ndis_timer		nmb_wkupdpctimer;
1412 	ndis_unicode_string	nmb_basename;
1413 	ndis_unicode_string	nmb_symlinkname;
1414 	uint32_t		nmb_checkforhangsecs;
1415 	uint16_t		nmb_cfhticks;
1416 	uint16_t		nmb_cfhcurrticks;
1417 	ndis_status		nmb_resetstatus;
1418 	ndis_handle		nmb_resetopen;
1419 	ndis_filterdbs		nmb_filterdbs;
1420 	void			*nmb_pktind_func;
1421 	void			*nmb_senddone_func;
1422 	void			*nmb_sendrsrc_func;
1423 	void			*nmb_resetdone_func;
1424 	ndis_medium		nmb_medium;
1425 	uint32_t		nmb_busnum;
1426 	uint32_t		nmb_bustype;
1427 	uint32_t		nmb_adaptertype;
1428 	device_object		*nmb_deviceobj; /* Functional device */
1429 	device_object		*nmb_physdeviceobj; /* Physical device */
1430 	device_object		*nmb_nextdeviceobj; /* Next dev in stack */
1431 	void			*nmb_mapreg;
1432 	void			*nmb_callmgraflist;
1433 	void			*nmb_miniportthread;
1434 	void			*nmb_setinfobuf;
1435 	uint16_t		nmb_setinfobuflen;
1436 	uint16_t		nmb_maxsendpkts;
1437 	ndis_status		nmb_fakestatus;
1438 	void			*nmb_lockhandler;
1439 	ndis_unicode_string	*nmb_adapterinstancename;
1440 	void			*nmb_timerqueue;
1441 	uint32_t		nmb_mactoptions;
1442 	ndis_request		*nmb_pendingreq;
1443 	uint32_t		nmb_maxlongaddrs;
1444 	uint32_t		nmb_maxshortaddrs;
1445 	uint32_t		nmb_currlookahead;
1446 	uint32_t		nmb_maxlookahead;
1447 	void			*nmb_interrupt_func;
1448 	void			*nmb_disableintr_func;
1449 	void			*nmb_enableintr_func;
1450 	void			*nmb_sendpkts_func;
1451 	void			*nmb_deferredsend_func;
1452 	void			*nmb_ethrxindicate_func;
1453 	void			*nmb_txrxindicate_func;
1454 	void			*nmb_fddirxindicate_func;
1455 	void			*nmb_ethrxdone_func;
1456 	void			*nmb_txrxdone_func;
1457 	void			*nmb_fddirxcond_func;
1458 	void			*nmb_status_func;
1459 	void			*nmb_statusdone_func;
1460 	void			*nmb_tdcond_func;
1461 	void			*nmb_querydone_func;
1462 	void			*nmb_setdone_func;
1463 	void			*nmb_wantxdone_func;
1464 	void			*nmb_wanrx_func;
1465 	void			*nmb_wanrxdone_func;
1466 	/*
1467 	 * End of windows-specific portion of miniport block. Everything
1468 	 * below is BSD-specific.
1469 	 */
1470 	struct ifnet		*nmb_ifp;
1471 	uint8_t			nmb_dummybuf[128];
1472 	device_object		nmb_devobj;
1473 	ndis_config_parm	nmb_replyparm;
1474 	int			nmb_pciidx;
1475 	device_t		nmb_dev;
1476 	ndis_resource_list	*nmb_rlist;
1477 	ndis_status		nmb_getstat;
1478 	ndis_status		nmb_setstat;
1479 	vm_offset_t		nmb_img;
1480 	TAILQ_ENTRY(ndis_miniport_block)	link;
1481 };
1482 
1483 TAILQ_HEAD(nd_head, ndis_miniport_block);
1484 
1485 typedef ndis_status (*ndis_init_handler)(ndis_status *, uint32_t *,
1486 		ndis_medium *, uint32_t, ndis_handle, ndis_handle);
1487 typedef ndis_status (*ndis_queryinfo_handler)(ndis_handle, ndis_oid,
1488 		void *, uint32_t, uint32_t *, uint32_t *);
1489 typedef ndis_status (*ndis_setinfo_handler)(ndis_handle, ndis_oid,
1490 		void *, uint32_t, uint32_t *, uint32_t *);
1491 typedef ndis_status (*ndis_sendsingle_handler)(ndis_handle,
1492 		ndis_packet *, uint32_t);
1493 typedef ndis_status (*ndis_sendmulti_handler)(ndis_handle,
1494 		ndis_packet **, uint32_t);
1495 typedef void (*ndis_isr_handler)(uint8_t *, uint8_t *, ndis_handle);
1496 typedef void (*ndis_interrupt_handler)(ndis_handle);
1497 typedef int (*ndis_reset_handler)(uint8_t *, ndis_handle);
1498 typedef void (*ndis_halt_handler)(ndis_handle);
1499 typedef void (*ndis_return_handler)(ndis_handle, ndis_packet *);
1500 typedef void (*ndis_enable_interrupts_handler)(ndis_handle);
1501 typedef void (*ndis_disable_interrupts_handler)(ndis_handle);
1502 typedef void (*ndis_shutdown_handler)(void *);
1503 typedef void (*ndis_allocdone_handler)(ndis_handle, void *,
1504 		ndis_physaddr *, uint32_t, void *);
1505 typedef uint8_t (*ndis_checkforhang_handler)(ndis_handle);
1506 
1507 typedef __stdcall ndis_status (*driver_entry)(void *, unicode_string *);
1508 
1509 extern image_patch_table ndis_functbl[];
1510 
1511 #define NDIS_TASKQUEUE	1
1512 #define NDIS_SWI	2
1513 
1514 #define NDIS_PSTATE_RUNNING	1
1515 #define NDIS_PSTATE_SLEEPING	2
1516 
1517 #define NdisQueryPacket(p, pbufcnt, bufcnt, firstbuf, plen)		\
1518 	do {								\
1519 		if ((firstbuf) != NULL) {				\
1520 			ndis_buffer		**_first;		\
1521 			_first = firstbuf;				\
1522 			*(_first) = (p)->np_private.npp_head;		\
1523 		}							\
1524 		if ((plen) || (bufcnt) || (pbufcnt)) {			\
1525 			if ((p)->np_private.npp_validcounts == FALSE) {	\
1526 				ndis_buffer		*tmp;		\
1527 				unsigned int		tlen = 0, pcnt = 0; \
1528 				unsigned int		add = 0;	\
1529 				unsigned int		pktlen, off;	\
1530 									\
1531 				tmp = (p)->np_private.npp_head;		\
1532 				while (tmp != NULL) {			\
1533 					off = MmGetMdlByteOffset(tmp);	\
1534 					pktlen = MmGetMdlByteCount(tmp);\
1535 					tlen += pktlen;			\
1536 					pcnt +=				\
1537 					    NDIS_BUFFER_TO_SPAN_PAGES(tmp); \
1538 					add++;				\
1539 					tmp = tmp->mdl_next;		\
1540 				}					\
1541 				(p)->np_private.npp_count = add;	\
1542 				(p)->np_private.npp_totlen = tlen;	\
1543 				(p)->np_private.npp_physcnt = pcnt;	\
1544 				(p)->np_private.npp_validcounts = TRUE;	\
1545 			}						\
1546 			if (pbufcnt) {					\
1547 				unsigned int		*_pbufcnt;	\
1548 				_pbufcnt = (pbufcnt);			\
1549 				*(_pbufcnt) = (p)->np_private.npp_physcnt; \
1550 			}						\
1551 			if (bufcnt) {					\
1552 				unsigned int		*_bufcnt;	\
1553 				_bufcnt = (bufcnt);			\
1554 				*(_bufcnt) = (p)->np_private.npp_count;	\
1555 			}						\
1556 			if (plen) {					\
1557 				unsigned int		*_plen;		\
1558 				_plen = (plen);				\
1559 				*(_plen) = (p)->np_private.npp_totlen;	\
1560 			}						\
1561 		}							\
1562 	} while (0)
1563 
1564 __BEGIN_DECLS
1565 extern int ndis_libinit(void);
1566 extern int ndis_libfini(void);
1567 extern int ndis_ascii_to_unicode(const char *, uint16_t **);
1568 extern int ndis_unicode_to_ascii(uint16_t *, int, char **);
1569 extern int ndis_load_driver(vm_offset_t, void *);
1570 extern int ndis_unload_driver(void *);
1571 extern int ndis_mtop(struct mbuf *, ndis_packet **);
1572 extern int ndis_ptom(struct mbuf **, ndis_packet *);
1573 extern int ndis_get_info(void *, ndis_oid, void *, int *);
1574 extern int ndis_set_info(void *, ndis_oid, void *, int *);
1575 extern int ndis_get_supported_oids(void *, ndis_oid **, int *);
1576 extern int ndis_send_packets(void *, ndis_packet **, int);
1577 extern int ndis_send_packet(void *, ndis_packet *);
1578 extern int ndis_convert_res(void *);
1579 extern int ndis_alloc_amem(void *);
1580 extern void ndis_free_amem(void *);
1581 extern void ndis_free_packet(ndis_packet *);
1582 extern void ndis_free_bufs(ndis_buffer *);
1583 extern int ndis_reset_nic(void *);
1584 extern int ndis_halt_nic(void *);
1585 extern int ndis_shutdown_nic(void *);
1586 extern int ndis_init_nic(void *);
1587 extern int ndis_isr(void *, int *, int *);
1588 #ifdef __FreeBSD__
1589 extern void ndis_return_packet(void *, void *);
1590 #else
1591 extern void ndis_return_packet(struct mbuf *, void *, size_t, void *);
1592 #endif
1593 extern void ndis_enable_intr(void *);
1594 extern void ndis_disable_intr(void *);
1595 extern int ndis_init_dma(void *);
1596 extern int ndis_destroy_dma(void *);
1597 extern int ndis_create_sysctls(void *);
1598 extern int ndis_add_sysctl(void *, const char *, const char *, const char *, int);
1599 extern int ndis_flush_sysctls(void *);
1600 extern int ndis_sched(void (*)(void *), void *, int);
1601 extern int ndis_unsched(void (*)(void *), void *, int);
1602 #ifdef __FreeBSD__
1603 extern int ndis_thsuspend(struct proc *, struct mtx *, int);
1604 #else /* __NetBSD__ */
1605 extern int ndis_thsuspend(struct proc *, kmutex_t *, int);
1606 #endif
1607 extern void ndis_thresume(struct proc *);
1608 extern int ndis_strcasecmp(const char *, const char *);
1609 extern int ndis_strncasecmp(const char *, const char *, size_t);
1610 
1611 __stdcall extern uint32_t NdisAddDevice(driver_object *, device_object *);
1612 __stdcall extern void NdisAllocatePacketPool(ndis_status *,
1613         ndis_handle *, uint32_t, uint32_t);
1614 __stdcall extern void NdisAllocatePacketPoolEx(ndis_status *,
1615         ndis_handle *, uint32_t, uint32_t, uint32_t);
1616 __stdcall extern uint32_t NdisPacketPoolUsage(ndis_handle);
1617 __stdcall extern void NdisFreePacketPool(ndis_handle);
1618 __stdcall extern void NdisAllocatePacket(ndis_status *,
1619 	ndis_packet **, ndis_handle);
1620 __stdcall extern void NdisFreePacket(ndis_packet *);
1621 
1622 __END_DECLS
1623 
1624 #endif /* _NDIS_VAR_H_ */
1625