ReactOS  r76032
ndis.h
Go to the documentation of this file.
1 /*
2  * ndis.h
3  *
4  * Network Device Interface Specification definitions
5  *
6  * This file is part of the ReactOS DDK package.
7  *
8  * Contributors:
9  * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAIMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * DEFINES: i386 - Target platform is i386
22  * NDIS_WRAPPER - Define only for NDIS library
23  * NDIS_MINIPORT_DRIVER - Define only for NDIS miniport drivers
24  * NDIS40 - Use NDIS 4.0 structures by default
25  * NDIS50 - Use NDIS 5.0 structures by default
26  * NDIS51 - Use NDIS 5.1 structures by default
27  * NDIS40_MINIPORT - Building NDIS 4.0 miniport driver
28  * NDIS50_MINIPORT - Building NDIS 5.0 miniport driver
29  * NDIS51_MINIPORT - Building NDIS 5.1 miniport driver
30  */
31 
32 #ifndef _NDIS_
33 #define _NDIS_
34 
35 #ifndef NDIS_WDM
36 #define NDIS_WDM 0
37 #endif
38 
39 #include "ntddk.h"
40 #include "netpnp.h"
41 #include "ntstatus.h"
42 #include "netevent.h"
43 #include <qos.h>
44 
46 
47 #include "ntddndis.h"
48 
49 #if !defined(_WINDEF_H)
50 typedef unsigned int UINT, *PUINT;
51 #endif
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 __drv_Mode_impl(NDIS_INCLUDED)
58 
59 #ifndef __NET_PNP__
60 #define __NET_PNP__
61 
62 typedef enum _NET_DEVICE_POWER_STATE {
70 
71 typedef enum _NET_PNP_EVENT_CODE {
87 
88 typedef struct _NET_PNP_EVENT {
90  PVOID Buffer;
97 
98 #endif /* __NET_PNP__ */
99 
100 #if !defined(NDIS_WRAPPER)
101 
102 #if (defined(NDIS_MINIPORT_MAJOR_VERSION) || \
103  (defined(NDIS_MINIPORT_MINOR_VERSION)) || \
104  (defined(NDIS_PROTOCOL_MAJOR_VERSION)) || \
105  (defined(NDIS_PROTOCOL_MINOR_VERSION)) || \
106  (defined(NDIS_FILTER_MAJOR_VERSION)) || \
107  (defined(NDIS_FILTER_MINOR_VERSION)))
108 #error "Driver should not redefine NDIS reserved macros"
109 #endif
110 
111 #if defined(NDIS_MINIPORT_DRIVER)
112 
113 #if defined(NDIS620_MINIPORT)
114 #define NDIS_MINIPORT_MAJOR_VERSION 6
115 #define NDIS_MINIPORT_MINOR_VERSION 20
116 #elif defined(NDIS61_MINIPORT)
117 #define NDIS_MINIPORT_MAJOR_VERSION 6
118 #define NDIS_MINIPORT_MINOR_VERSION 1
119 #elif defined(NDIS60_MINIPORT)
120 #define NDIS_MINIPORT_MAJOR_VERSION 6
121 #define NDIS_MINIPORT_MINOR_VERSION 0
122 #elif defined(NDIS51_MINIPORT)
123 #define NDIS_MINIPORT_MAJOR_VERSION 5
124 #define NDIS_MINIPORT_MINOR_VERSION 1
125 #elif defined(NDIS50_MINIPORT)
126 #define NDIS_MINIPORT_MAJOR_VERSION 5
127 #define NDIS_MINIPORT_MINOR_VERSION 0
128 #else
129 #error "Only NDIS miniport drivers with version >= 5 are supported"
130 #endif
131 
132 #if ((NDIS_MINIPORT_MAJOR_VERSION == 6) && \
133  (NDIS_MINIPORT_MINOR_VERSION != 20) && \
134  (NDIS_MINIPORT_MINOR_VERSION != 1) && \
135  (NDIS_MINIPORT_MINOR_VERSION != 0))
136 #error "Invalid miniport major/minor version combination"
137 #elif ((NDIS_MINIPORT_MAJOR_VERSION == 5) && \
138  (NDIS_MINIPORT_MINOR_VERSION != 1) && \
139  (NDIS_MINIPORT_MINOR_VERSION != 0))
140 #error "Invalid miniport major/minor version combination"
141 #endif
142 
143 #if (NDIS_MINIPORT_MAJOR_VERSION == 6) && \
144  ((NDIS_MINIPORT_MINOR_VERSION == 20 && NTDDI_VERSION < NTDDI_WIN7) || \
145  (NDIS_MINIPORT_MINOR_VERSION == 1 && NTDDI_VERSION < NTDDI_VISTA) || \
146  (NDIS_MINIPORT_MINOR_VERSION == 0 && NTDDI_VERSION < NTDDI_VISTA))
147 #error "Wrong NDIS/DDI version"
148 #elif ((NDIS_MINIPORT_MAJOR_VERSION == 5) && \
149  (((NDIS_MINIPORT_MINOR_VERSION == 1) && (NTDDI_VERSION < NTDDI_WINXP)) || \
150  ((NDIS_MINIPORT_MINOR_VERSION == 0) && (NTDDI_VERSION < NTDDI_WIN2K))))
151 #error "Wrong NDIS/DDI version"
152 #endif
153 
154 
155 #endif /* defined(NDIS_MINIPORT_DRIVER) */
156 
157 #if defined(NDIS30)
158 #error "Only NDIS Protocol drivers version 4 or later are supported"
159 #endif
160 
161 #if defined(NDIS620)
162 #define NDIS_PROTOCOL_MAJOR_VERSION 6
163 #define NDIS_PROTOCOL_MINOR_VERSION 20
164 #define NDIS_FILTER_MAJOR_VERSION 6
165 #define NDIS_FILTER_MINOR_VERSION 20
166 #elif defined(NDIS61)
167 #define NDIS_PROTOCOL_MAJOR_VERSION 6
168 #define NDIS_PROTOCOL_MINOR_VERSION 1
169 #define NDIS_FILTER_MAJOR_VERSION 6
170 #define NDIS_FILTER_MINOR_VERSION 1
171 #elif defined(NDIS60)
172 #define NDIS_PROTOCOL_MAJOR_VERSION 6
173 #define NDIS_PROTOCOL_MINOR_VERSION 0
174 #define NDIS_FILTER_MAJOR_VERSION 6
175 #define NDIS_FILTER_MINOR_VERSION 0
176 #elif defined(NDIS51)
177 #define NDIS_PROTOCOL_MAJOR_VERSION 5
178 #define NDIS_PROTOCOL_MINOR_VERSION 1
179 #elif defined(NDIS50)
180 #define NDIS_PROTOCOL_MAJOR_VERSION 5
181 #define NDIS_PROTOCOL_MINOR_VERSION 0
182 #elif defined(NDIS40)
183 #define NDIS_PROTOCOL_MAJOR_VERSION 4
184 #define NDIS_PROTOCOL_MINOR_VERSION 0
185 #endif
186 
187 #if !defined(NDIS_MINIPORT_DRIVER) && !defined(NDIS_PROTOCOL_MAJOR_VERSION)
188 #define NDIS40
189 #define NDIS_PROTOCOL_MAJOR_VERSION 4
190 #define NDIS_PROTOCOL_MINOR_VERSION 0
191 #endif
192 
193 #if defined(NDIS_FILTER_MAJOR_VERSION)
194 
195 #if ((NDIS_FILTER_MAJOR_VERSION == 6) && \
196  (NDIS_FILTER_MINOR_VERSION != 20) && \
197  (NDIS_FILTER_MINOR_VERSION != 1) && \
198  (NDIS_FILTER_MINOR_VERSION != 0))
199 #error "Invalid Filter version"
200 #endif
201 
202 #endif /* defined(NDIS_FILTER_MAJOR_VERSION) */
203 
204 
205 #if defined(NDIS_PROTOCOL_MAJOR_VERSION)
206 
207 #if ((NDIS_PROTOCOL_MAJOR_VERSION == 6) && \
208  (NDIS_PROTOCOL_MINOR_VERSION != 20) && \
209  (NDIS_PROTOCOL_MINOR_VERSION != 1) && \
210  (NDIS_PROTOCOL_MINOR_VERSION != 0))
211 #error "Invalid Protocol version"
212 #elif ((NDIS_PROTOCOL_MAJOR_VERSION == 5) && \
213  (NDIS_PROTOCOL_MINOR_VERSION != 1) && (NDIS_PROTOCOL_MINOR_VERSION != 0))
214 #error "Invalid Protocol version"
215 #elif ((NDIS_PROTOCOL_MAJOR_VERSION == 4) && (NDIS_PROTOCOL_MINOR_VERSION != 0))
216 #error "Invalid Protocol major/minor version"
217 #endif
218 
219 #if ((NDIS_PROTOCOL_MAJOR_VERSION == 6) && (NTDDI_VERSION < NTDDI_VISTA))
220 #error "Wrong NDIS/DDI version"
221 #endif
222 
223 #endif /* defined(NDIS_PROTOCOL_MAJOR_VERSION) */
224 
225 #endif /* !defined(NDIS_WRAPPER) */
226 
227 #if !defined(NDIS_LEGACY_MINIPORT)
228 
229 #if ((defined(NDIS_MINIPORT_DRIVER) && (NDIS_MINIPORT_MAJOR_VERSION < 6)) || NDIS_WRAPPER)
230 #define NDIS_LEGACY_MINIPORT 1
231 #else
232 #define NDIS_LEGACY_MINIPORT 0
233 #endif
234 
235 #endif /* !defined(NDIS_LEGACY_MINIPORT) */
236 
237 #if !defined(NDIS_LEGACY_PROTOCOL)
238 
239 #if ((defined(NDIS_PROTOCOL_MAJOR_VERSION) && (NDIS_PROTOCOL_MAJOR_VERSION < 6)) || NDIS_WRAPPER)
240 #define NDIS_LEGACY_PROTOCOL 1
241 #else
242 #define NDIS_LEGACY_PROTOCOL 0
243 #endif
244 
245 #endif /* !defined(NDIS_LEGACY_PROTOCOL) */
246 
247 #if !defined(NDIS_LEGACY_DRIVER)
248 
249 #if (NDIS_LEGACY_MINIPORT || NDIS_LEGACY_PROTOCOL || NDIS_WRAPPER)
250 #define NDIS_LEGACY_DRIVER 1
251 #else
252 #define NDIS_LEGACY_DRIVER 0
253 #endif
254 
255 #endif /* !defined(NDIS_LEGACY_DRIVER) */
256 
257 #if !defined(NDIS_SUPPORT_NDIS6)
258 
259 #if ((defined (NDIS_MINIPORT_MAJOR_VERSION) && (NDIS_MINIPORT_MAJOR_VERSION >= 6)) || \
260  (defined (NDIS60)) || NDIS_WRAPPER)
261 #define NDIS_SUPPORT_NDIS6 1
262 #else
263 #define NDIS_SUPPORT_NDIS6 0
264 #endif
265 
266 #endif /* !defined(NDIS_SUPPORT_NDIS6) */
267 
268 #if !defined(NDIS_SUPPORT_NDIS61)
269 #if (((defined (NDIS_MINIPORT_MAJOR_VERSION) && (NDIS_MINIPORT_MAJOR_VERSION >= 6)) && \
270  (defined (NDIS_MINIPORT_MINOR_VERSION) && (NDIS_MINIPORT_MINOR_VERSION >= 1))) || \
271  (defined (NDIS61)) || NDIS_WRAPPER)
272 #define NDIS_SUPPORT_NDIS61 1
273 #else
274 #define NDIS_SUPPORT_NDIS61 0
275 #endif
276 #endif /* !defined(NDIS_SUPPORT_NDIS61) */
277 
278 #if !defined(NDIS_SUPPORT_NDIS620)
279 
280 #if (((defined (NDIS_MINIPORT_MAJOR_VERSION) && (NDIS_MINIPORT_MAJOR_VERSION >= 6)) && \
281  (defined (NDIS_MINIPORT_MINOR_VERSION) && (NDIS_MINIPORT_MINOR_VERSION >= 20))) || \
282  (defined (NDIS620)) || NDIS_WRAPPER)
283 #define NDIS_SUPPORT_NDIS620 1
284 #else
285 #define NDIS_SUPPORT_NDIS620 0
286 #endif
287 
288 #endif /* !defined(NDIS_SUPPORT_NDIS620) */
289 
290 #if (NDIS_SUPPORT_NDIS620)
291 #undef NDIS_SUPPORT_NDIS61
292 #define NDIS_SUPPORT_NDIS61 1
293 #endif
294 
295 #if (NDIS_SUPPORT_NDIS61)
296 #undef NDIS_SUPPORT_NDIS6
297 #define NDIS_SUPPORT_NDIS6 1
298 #endif
299 
300 #if defined(NDIS61_MINIPORT) || defined(NDIS60_MINIPORT) || defined(NDIS61) || \
301  defined(NDIS60) || defined(NDIS_WRAPPER) || defined(NDIS_LEGACY_DRIVER)
302 #define NDIS_SUPPORT_60_COMPATIBLE_API 1
303 #else
304 #define NDIS_SUPPORT_60_COMPATIBLE_API 0
305 #endif
306 
307 #if defined(NDIS_WRAPPER)
308 #define NDISAPI
309 #else
310 #define NDISAPI DECLSPEC_IMPORT
311 #endif
312 
313 typedef PVOID QUEUED_CLOSE; //FIXME : Doesn't exist in public headers
314 
315 typedef struct _X_FILTER FDDI_FILTER, *PFDDI_FILTER;
316 typedef struct _X_FILTER TR_FILTER, *PTR_FILTER;
317 typedef struct _X_FILTER NULL_FILTER, *PNULL_FILTER;
318 
320 
321 typedef struct _REFERENCE {
326 
327 /* NDIS base types */
328 
329 typedef struct _NDIS_SPIN_LOCK {
333 
334 typedef struct _NDIS_EVENT {
337 
339 
342 
344 
345 /* NDIS_STATUS constants */
346 #define NDIS_STATUS_SUCCESS ((NDIS_STATUS)STATUS_SUCCESS)
347 #define NDIS_STATUS_PENDING ((NDIS_STATUS)STATUS_PENDING)
348 #define NDIS_STATUS_NOT_RECOGNIZED ((NDIS_STATUS)0x00010001L)
349 #define NDIS_STATUS_NOT_COPIED ((NDIS_STATUS)0x00010002L)
350 #define NDIS_STATUS_NOT_ACCEPTED ((NDIS_STATUS)0x00010003L)
351 #define NDIS_STATUS_CALL_ACTIVE ((NDIS_STATUS)0x00010007L)
352 #define NDIS_STATUS_INDICATION_REQUIRED ((NDIS_STATUS)STATUS_NDIS_INDICATION_REQUIRED)
353 #define NDIS_STATUS_ONLINE ((NDIS_STATUS)0x40010003L)
354 #define NDIS_STATUS_RESET_START ((NDIS_STATUS)0x40010004L)
355 #define NDIS_STATUS_RESET_END ((NDIS_STATUS)0x40010005L)
356 #define NDIS_STATUS_RING_STATUS ((NDIS_STATUS)0x40010006L)
357 #define NDIS_STATUS_CLOSED ((NDIS_STATUS)0x40010007L)
358 #define NDIS_STATUS_WAN_LINE_UP ((NDIS_STATUS)0x40010008L)
359 #define NDIS_STATUS_WAN_LINE_DOWN ((NDIS_STATUS)0x40010009L)
360 #define NDIS_STATUS_WAN_FRAGMENT ((NDIS_STATUS)0x4001000AL)
361 #define NDIS_STATUS_MEDIA_CONNECT ((NDIS_STATUS)0x4001000BL)
362 #define NDIS_STATUS_MEDIA_DISCONNECT ((NDIS_STATUS)0x4001000CL)
363 #define NDIS_STATUS_HARDWARE_LINE_UP ((NDIS_STATUS)0x4001000DL)
364 #define NDIS_STATUS_HARDWARE_LINE_DOWN ((NDIS_STATUS)0x4001000EL)
365 #define NDIS_STATUS_INTERFACE_UP ((NDIS_STATUS)0x4001000FL)
366 #define NDIS_STATUS_INTERFACE_DOWN ((NDIS_STATUS)0x40010010L)
367 #define NDIS_STATUS_MEDIA_BUSY ((NDIS_STATUS)0x40010011L)
368 #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION ((NDIS_STATUS)0x40010012L)
369 #define NDIS_STATUS_WW_INDICATION NDIS_STATUS_MEDIA_SPECIFIC_INDICATION
370 #define NDIS_STATUS_LINK_SPEED_CHANGE ((NDIS_STATUS)0x40010013L)
371 #define NDIS_STATUS_WAN_GET_STATS ((NDIS_STATUS)0x40010014L)
372 #define NDIS_STATUS_WAN_CO_FRAGMENT ((NDIS_STATUS)0x40010015L)
373 #define NDIS_STATUS_WAN_CO_LINKPARAMS ((NDIS_STATUS)0x40010016L)
374 #if NDIS_SUPPORT_NDIS6
375 #define NDIS_STATUS_LINK_STATE ((NDIS_STATUS)0x40010017L)
376 #define NDIS_STATUS_NETWORK_CHANGE ((NDIS_STATUS)0x40010018L)
377 #define NDIS_STATUS_MEDIA_SPECIFIC_INDICATION_EX ((NDIS_STATUS)0x40010019L)
378 #define NDIS_STATUS_PORT_STATE ((NDIS_STATUS)0x40010022L)
379 #define NDIS_STATUS_OPER_STATUS ((NDIS_STATUS)0x40010023L)
380 #define NDIS_STATUS_PACKET_FILTER ((NDIS_STATUS)0x40010024L)
381 #endif /* NDIS_SUPPORT_NDIS6 */
382 #define NDIS_STATUS_WAN_CO_MTULINKPARAMS ((NDIS_STATUS)0x40010025L)
383 
384 #if NDIS_SUPPORT_NDIS6
385 
386 #define NDIS_STATUS_IP_OPER_STATUS ((NDIS_STATUS)0x40010026L)
387 
388 #define NDIS_STATUS_OFFLOAD_PAUSE ((NDIS_STATUS)0x40020001L)
389 #define NDIS_STATUS_UPLOAD_ALL ((NDIS_STATUS)0x40020002L)
390 #define NDIS_STATUS_OFFLOAD_RESUME ((NDIS_STATUS)0x40020003L)
391 #define NDIS_STATUS_OFFLOAD_PARTIAL_SUCCESS ((NDIS_STATUS)0x40020004L)
392 #define NDIS_STATUS_OFFLOAD_STATE_INVALID ((NDIS_STATUS)0x40020005L)
393 #define NDIS_STATUS_TASK_OFFLOAD_CURRENT_CONFIG ((NDIS_STATUS)0x40020006L)
394 #define NDIS_STATUS_TASK_OFFLOAD_HARDWARE_CAPABILITIES ((NDIS_STATUS)0x40020007L)
395 #define NDIS_STATUS_OFFLOAD_ENCASPULATION_CHANGE ((NDIS_STATUS)0x40020008L)
396 #define NDIS_STATUS_TCP_CONNECTION_OFFLOAD_HARDWARE_CAPABILITIES ((NDIS_STATUS)0x4002000BL)
397 
398 #if (NDIS_SUPPORT_NDIS61)
399 #define NDIS_STATUS_HD_SPLIT_CURRENT_CONFIG ((NDIS_STATUS)0x4002000CL)
400 #endif
401 
402 #if (NDIS_SUPPORT_NDIS620)
403 #define NDIS_STATUS_RECEIVE_QUEUE_STATE ((NDIS_STATUS)0x4002000DL)
404 #endif
405 
406 #define NDIS_STATUS_OFFLOAD_IM_RESERVED1 ((NDIS_STATUS)0x40020100L)
407 #define NDIS_STATUS_OFFLOAD_IM_RESERVED2 ((NDIS_STATUS)0x40020101L)
408 #define NDIS_STATUS_OFFLOAD_IM_RESERVED3 ((NDIS_STATUS)0x40020102L)
409 
410 #define NDIS_STATUS_DOT11_SCAN_CONFIRM ((NDIS_STATUS)0x40030000L)
411 #define NDIS_STATUS_DOT11_MPDU_MAX_LENGTH_CHANGED ((NDIS_STATUS)0x40030001L)
412 #define NDIS_STATUS_DOT11_ASSOCIATION_START ((NDIS_STATUS)0x40030002L)
413 #define NDIS_STATUS_DOT11_ASSOCIATION_COMPLETION ((NDIS_STATUS)0x40030003L)
414 #define NDIS_STATUS_DOT11_CONNECTION_START ((NDIS_STATUS)0x40030004L)
415 #define NDIS_STATUS_DOT11_CONNECTION_COMPLETION ((NDIS_STATUS)0x40030005L)
416 #define NDIS_STATUS_DOT11_ROAMING_START ((NDIS_STATUS)0x40030006L)
417 #define NDIS_STATUS_DOT11_ROAMING_COMPLETION ((NDIS_STATUS)0x40030007L)
418 #define NDIS_STATUS_DOT11_DISASSOCIATION ((NDIS_STATUS)0x40030008L)
419 #define NDIS_STATUS_DOT11_TKIPMIC_FAILURE ((NDIS_STATUS)0x40030009L)
420 #define NDIS_STATUS_DOT11_PMKID_CANDIDATE_LIST ((NDIS_STATUS)0x4003000AL)
421 #define NDIS_STATUS_DOT11_PHY_STATE_CHANGED ((NDIS_STATUS)0x4003000BL)
422 #define NDIS_STATUS_DOT11_LINK_QUALITY ((NDIS_STATUS)0x4003000CL)
423 #define NDIS_STATUS_DOT11_INCOMING_ASSOC_STARTED ((NDIS_STATUS)0x4003000DL)
424 #define NDIS_STATUS_DOT11_INCOMING_ASSOC_REQUEST_RECEIVED ((NDIS_STATUS)0x4003000EL)
425 #define NDIS_STATUS_DOT11_INCOMING_ASSOC_COMPLETION ((NDIS_STATUS)0x4003000FL)
426 #define NDIS_STATUS_DOT11_STOP_AP ((NDIS_STATUS)0x40030010L)
427 #define NDIS_STATUS_DOT11_PHY_FREQUENCY_ADOPTED ((NDIS_STATUS)0x40030011L)
428 #define NDIS_STATUS_DOT11_CAN_SUSTAIN_AP ((NDIS_STATUS)0x40030012L)
429 
430 #define NDIS_STATUS_WWAN_DEVICE_CAPS ((NDIS_STATUS)0x40041000)
431 #define NDIS_STATUS_WWAN_READY_INFO ((NDIS_STATUS)0x40041001)
432 #define NDIS_STATUS_WWAN_RADIO_STATE ((NDIS_STATUS)0x40041002)
433 #define NDIS_STATUS_WWAN_PIN_INFO ((NDIS_STATUS)0x40041003)
434 #define NDIS_STATUS_WWAN_PIN_LIST ((NDIS_STATUS)0x40041004)
435 #define NDIS_STATUS_WWAN_HOME_PROVIDER ((NDIS_STATUS)0x40041005)
436 #define NDIS_STATUS_WWAN_PREFERRED_PROVIDERS ((NDIS_STATUS)0x40041006)
437 #define NDIS_STATUS_WWAN_VISIBLE_PROVIDERS ((NDIS_STATUS)0x40041007)
438 #define NDIS_STATUS_WWAN_REGISTER_STATE ((NDIS_STATUS)0x40041008)
439 #define NDIS_STATUS_WWAN_PACKET_SERVICE ((NDIS_STATUS)0x40041009)
440 #define NDIS_STATUS_WWAN_SIGNAL_STATE ((NDIS_STATUS)0x4004100a)
441 #define NDIS_STATUS_WWAN_CONTEXT_STATE ((NDIS_STATUS)0x4004100b)
442 #define NDIS_STATUS_WWAN_PROVISIONED_CONTEXTS ((NDIS_STATUS)0x4004100c)
443 #define NDIS_STATUS_WWAN_SERVICE_ACTIVATION ((NDIS_STATUS)0x4004100d)
444 #define NDIS_STATUS_WWAN_SMS_CONFIGURATION ((NDIS_STATUS)0x4004100e)
445 #define NDIS_STATUS_WWAN_SMS_RECEIVE ((NDIS_STATUS)0x4004100f)
446 #define NDIS_STATUS_WWAN_SMS_SEND ((NDIS_STATUS)0x40041010)
447 #define NDIS_STATUS_WWAN_SMS_DELETE ((NDIS_STATUS)0x40041011)
448 #define NDIS_STATUS_WWAN_SMS_STATUS ((NDIS_STATUS)0x40041012)
449 #define NDIS_STATUS_WWAN_DNS_ADDRESS ((NDIS_STATUS)0x40041013)
450 
451 #define NDIS_STATUS_WWAN_VENDOR_SPECIFIC ((NDIS_STATUS)0x40043000)
452 
453 #endif /* NDIS_SUPPORT_NDIS6 */
454 
455 #if (NDIS_SUPPORT_NDIS620)
456 #define NDIS_STATUS_PM_WOL_PATTERN_REJECTED ((NDIS_STATUS)0x40030051L)
457 #define NDIS_STATUS_PM_OFFLOAD_REJECTED ((NDIS_STATUS)0x40030052L)
458 #define NDIS_STATUS_PM_CAPABILITIES_CHANGE ((NDIS_STATUS)0x40030053L)
459 #endif
460 
461 #define NDIS_STATUS_NOT_RESETTABLE ((NDIS_STATUS)0x80010001L)
462 #define NDIS_STATUS_SOFT_ERRORS ((NDIS_STATUS)0x80010003L)
463 #define NDIS_STATUS_HARD_ERRORS ((NDIS_STATUS)0x80010004L)
464 #define NDIS_STATUS_BUFFER_OVERFLOW ((NDIS_STATUS)STATUS_BUFFER_OVERFLOW)
465 #define NDIS_STATUS_FAILURE ((NDIS_STATUS)STATUS_UNSUCCESSFUL)
466 #define NDIS_STATUS_RESOURCES ((NDIS_STATUS)STATUS_INSUFFICIENT_RESOURCES)
467 #define NDIS_STATUS_CLOSING ((NDIS_STATUS)0xC0010002L)
468 #define NDIS_STATUS_BAD_VERSION ((NDIS_STATUS)0xC0010004L)
469 #define NDIS_STATUS_BAD_CHARACTERISTICS ((NDIS_STATUS)0xC0010005L)
470 #define NDIS_STATUS_ADAPTER_NOT_FOUND ((NDIS_STATUS)0xC0010006L)
471 #define NDIS_STATUS_OPEN_FAILED ((NDIS_STATUS)0xC0010007L)
472 #define NDIS_STATUS_DEVICE_FAILED ((NDIS_STATUS)0xC0010008L)
473 #define NDIS_STATUS_MULTICAST_FULL ((NDIS_STATUS)0xC0010009L)
474 #define NDIS_STATUS_MULTICAST_EXISTS ((NDIS_STATUS)0xC001000AL)
475 #define NDIS_STATUS_MULTICAST_NOT_FOUND ((NDIS_STATUS)0xC001000BL)
476 #define NDIS_STATUS_REQUEST_ABORTED ((NDIS_STATUS)0xC001000CL)
477 #define NDIS_STATUS_RESET_IN_PROGRESS ((NDIS_STATUS)0xC001000DL)
478 #define NDIS_STATUS_CLOSING_INDICATING ((NDIS_STATUS)0xC001000EL)
479 #define NDIS_STATUS_NOT_SUPPORTED ((NDIS_STATUS)STATUS_NOT_SUPPORTED)
480 #define NDIS_STATUS_INVALID_PACKET ((NDIS_STATUS)0xC001000FL)
481 #define NDIS_STATUS_OPEN_LIST_FULL ((NDIS_STATUS)0xC0010010L)
482 #define NDIS_STATUS_ADAPTER_NOT_READY ((NDIS_STATUS)0xC0010011L)
483 #define NDIS_STATUS_ADAPTER_NOT_OPEN ((NDIS_STATUS)0xC0010012L)
484 #define NDIS_STATUS_NOT_INDICATING ((NDIS_STATUS)0xC0010013L)
485 #define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L)
486 #define NDIS_STATUS_INVALID_DATA ((NDIS_STATUS)0xC0010015L)
487 #define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L)
488 #define NDIS_STATUS_INVALID_OID ((NDIS_STATUS)0xC0010017L)
489 #define NDIS_STATUS_ADAPTER_REMOVED ((NDIS_STATUS)0xC0010018L)
490 #define NDIS_STATUS_UNSUPPORTED_MEDIA ((NDIS_STATUS)0xC0010019L)
491 #define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((NDIS_STATUS)0xC001001AL)
492 #define NDIS_STATUS_FILE_NOT_FOUND ((NDIS_STATUS)0xC001001BL)
493 #define NDIS_STATUS_ERROR_READING_FILE ((NDIS_STATUS)0xC001001CL)
494 #define NDIS_STATUS_ALREADY_MAPPED ((NDIS_STATUS)0xC001001DL)
495 #define NDIS_STATUS_RESOURCE_CONFLICT ((NDIS_STATUS)0xC001001EL)
496 #define NDIS_STATUS_NO_CABLE ((NDIS_STATUS)0xC001001FL)
497 
498 #define NDIS_STATUS_INVALID_SAP ((NDIS_STATUS)0xC0010020L)
499 #define NDIS_STATUS_SAP_IN_USE ((NDIS_STATUS)0xC0010021L)
500 #define NDIS_STATUS_INVALID_ADDRESS ((NDIS_STATUS)0xC0010022L)
501 #define NDIS_STATUS_VC_NOT_ACTIVATED ((NDIS_STATUS)0xC0010023L)
502 #define NDIS_STATUS_DEST_OUT_OF_ORDER ((NDIS_STATUS)0xC0010024L)
503 #define NDIS_STATUS_VC_NOT_AVAILABLE ((NDIS_STATUS)0xC0010025L)
504 #define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((NDIS_STATUS)0xC0010026L)
505 #define NDIS_STATUS_INCOMPATABLE_QOS ((NDIS_STATUS)0xC0010027L)
506 #define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((NDIS_STATUS)0xC0010028L)
507 #define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((NDIS_STATUS)0xC0010029L)
508 
509 #define NDIS_STATUS_TOKEN_RING_OPEN_ERROR ((NDIS_STATUS)0xC0011000L)
510 #define NDIS_STATUS_INVALID_DEVICE_REQUEST ((NDIS_STATUS)STATUS_INVALID_DEVICE_REQUEST)
511 #define NDIS_STATUS_NETWORK_UNREACHABLE ((NDIS_STATUS)STATUS_NETWORK_UNREACHABLE)
512 
513 #if NDIS_SUPPORT_NDIS6
514 
515 #define NDIS_STATUS_SEND_ABORTED ((NDIS_STATUS)STATUS_NDIS_REQUEST_ABORTED)
516 #define NDIS_STATUS_PAUSED ((NDIS_STATUS)STATUS_NDIS_PAUSED)
517 #define NDIS_STATUS_INTERFACE_NOT_FOUND ((NDIS_STATUS)STATUS_NDIS_INTERFACE_NOT_FOUND)
518 #define NDIS_STATUS_INVALID_PARAMETER ((NDIS_STATUS)STATUS_INVALID_PARAMETER)
519 #define NDIS_STATUS_UNSUPPORTED_REVISION ((NDIS_STATUS)STATUS_NDIS_UNSUPPORTED_REVISION)
520 #define NDIS_STATUS_INVALID_PORT ((NDIS_STATUS)STATUS_NDIS_INVALID_PORT)
521 #define NDIS_STATUS_INVALID_PORT_STATE ((NDIS_STATUS)STATUS_NDIS_INVALID_PORT_STATE)
522 #define NDIS_STATUS_INVALID_STATE ((NDIS_STATUS)STATUS_INVALID_DEVICE_STATE)
523 #define NDIS_STATUS_MEDIA_DISCONNECTED ((NDIS_STATUS)STATUS_NDIS_MEDIA_DISCONNECTED)
524 #define NDIS_STATUS_LOW_POWER_STATE ((NDIS_STATUS)STATUS_NDIS_LOW_POWER_STATE)
525 #define NDIS_STATUS_DOT11_AUTO_CONFIG_ENABLED ((NDIS_STATUS)STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED)
526 #define NDIS_STATUS_DOT11_MEDIA_IN_USE ((NDIS_STATUS)STATUS_NDIS_DOT11_MEDIA_IN_USE)
527 #define NDIS_STATUS_DOT11_POWER_STATE_INVALID ((NDIS_STATUS)STATUS_NDIS_DOT11_POWER_STATE_INVALID)
528 #define NDIS_STATUS_UPLOAD_IN_PROGRESS ((NDIS_STATUS)0xC0231001L)
529 #define NDIS_STATUS_REQUEST_UPLOAD ((NDIS_STATUS)0xC0231002L)
530 #define NDIS_STATUS_UPLOAD_REQUESTED ((NDIS_STATUS)0xC0231003L)
531 #define NDIS_STATUS_OFFLOAD_TCP_ENTRIES ((NDIS_STATUS)0xC0231004L)
532 #define NDIS_STATUS_OFFLOAD_PATH_ENTRIES ((NDIS_STATUS)0xC0231005L)
533 #define NDIS_STATUS_OFFLOAD_NEIGHBOR_ENTRIES ((NDIS_STATUS)0xC0231006L)
534 #define NDIS_STATUS_OFFLOAD_IP_ADDRESS_ENTRIES ((NDIS_STATUS)0xC0231007L)
535 #define NDIS_STATUS_OFFLOAD_HW_ADDRESS_ENTRIES ((NDIS_STATUS)0xC0231008L)
536 #define NDIS_STATUS_OFFLOAD_VLAN_ENTRIES ((NDIS_STATUS)0xC0231009L)
537 #define NDIS_STATUS_OFFLOAD_TCP_XMIT_BUFFER ((NDIS_STATUS)0xC023100AL)
538 #define NDIS_STATUS_OFFLOAD_TCP_RCV_BUFFER ((NDIS_STATUS)0xC023100BL)
539 #define NDIS_STATUS_OFFLOAD_TCP_RCV_WINDOW ((NDIS_STATUS)0xC023100CL)
540 #define NDIS_STATUS_OFFLOAD_VLAN_MISMATCH ((NDIS_STATUS)0xC023100DL)
541 #define NDIS_STATUS_OFFLOAD_DATA_NOT_ACCEPTED ((NDIS_STATUS)0xC023100EL)
542 #define NDIS_STATUS_OFFLOAD_POLICY ((NDIS_STATUS)0xC023100FL)
543 #define NDIS_STATUS_OFFLOAD_DATA_PARTIALLY_ACCEPTED ((NDIS_STATUS)0xC0231010L)
544 #define NDIS_STATUS_OFFLOAD_REQUEST_RESET ((NDIS_STATUS)0xC0231011L)
545 
546 #if NDIS_SUPPORT_NDIS620
547 #define NDIS_STATUS_PM_WOL_PATTERN_LIST_FULL ((NDIS_STATUS)STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL)
548 #define NDIS_STATUS_PM_PROTOCOL_OFFLOAD_LIST_FULL ((NDIS_STATUS)STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL)
549 #endif
550 
551 #endif /* NDIS_SUPPORT_NDIS6 */
552 
553 #if (NDIS_SUPPORT_NDIS620)
554 #define NDIS_STATUS_OFFLOAD_CONNECTION_REJECTED ((NDIS_STATUS)STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED)
555 #endif
556 
557 /* NDIS error codes for error logging */
558 
559 #define NDIS_ERROR_CODE ULONG
560 
561 #define NDIS_ERROR_CODE_RESOURCE_CONFLICT EVENT_NDIS_RESOURCE_CONFLICT
562 #define NDIS_ERROR_CODE_OUT_OF_RESOURCES EVENT_NDIS_OUT_OF_RESOURCE
563 #define NDIS_ERROR_CODE_HARDWARE_FAILURE EVENT_NDIS_HARDWARE_FAILURE
564 #define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND EVENT_NDIS_ADAPTER_NOT_FOUND
565 #define NDIS_ERROR_CODE_INTERRUPT_CONNECT EVENT_NDIS_INTERRUPT_CONNECT
566 #define NDIS_ERROR_CODE_DRIVER_FAILURE EVENT_NDIS_DRIVER_FAILURE
567 #define NDIS_ERROR_CODE_BAD_VERSION EVENT_NDIS_BAD_VERSION
568 #define NDIS_ERROR_CODE_TIMEOUT EVENT_NDIS_TIMEOUT
569 #define NDIS_ERROR_CODE_NETWORK_ADDRESS EVENT_NDIS_NETWORK_ADDRESS
570 #define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION EVENT_NDIS_UNSUPPORTED_CONFIGURATION
571 #define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER
572 #define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER
573 #define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS EVENT_NDIS_BAD_IO_BASE_ADDRESS
574 #define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL EVENT_NDIS_RECEIVE_SPACE_SMALL
575 #define NDIS_ERROR_CODE_ADAPTER_DISABLED EVENT_NDIS_ADAPTER_DISABLED
576 
577 /* Memory allocation flags. Used by Ndis[Allocate|Free]Memory */
578 #define NDIS_MEMORY_CONTIGUOUS 0x00000001
579 #define NDIS_MEMORY_NONCACHED 0x00000002
580 
581 /* NIC attribute flags. Used by NdisMSetAttributes(Ex) */
582 #define NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT 0x00000001
583 #define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT 0x00000002
584 #define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS 0x00000004
585 #define NDIS_ATTRIBUTE_BUS_MASTER 0x00000008
586 #define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER 0x00000010
587 #define NDIS_ATTRIBUTE_DESERIALIZE 0x00000020
588 #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND 0x00000040
589 #define NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK 0x00000080
590 #define NDIS_ATTRIBUTE_NOT_CO_NDIS 0x00000100
591 #define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS 0x00000200
592 
593 /* Lock */
594 
595 #if NDIS_SUPPORT_60_COMPATIBLE_API
596 
597 typedef union _NDIS_RW_LOCK_REFCOUNT {
598  UINT RefCount;
599  UCHAR cacheLine[16];
601 
602 typedef struct _NDIS_RW_LOCK {
603  __MINGW_EXTENSION union {
604  __MINGW_EXTENSION struct {
606  PVOID Context;
607  };
608  UCHAR Reserved[16];
609  };
610  __MINGW_EXTENSION union {
613  __MINGW_EXTENSION struct {
617  };
618  };
620 
621 typedef struct _LOCK_STATE {
623  KIRQL OldIrql;
625 
626 #endif /* NDIS_SUPPORT_60_COMPATIBLE_API */
627 
628 /* Timer */
629 
632 _Function_class_(NDIS_TIMER_FUNCTION)
633 typedef VOID
634 (NTAPI NDIS_TIMER_FUNCTION)(
635  _In_ PVOID SystemSpecific1,
639 typedef NDIS_TIMER_FUNCTION *PNDIS_TIMER_FUNCTION;
640 
645 
646 /* Hardware */
647 
652 
653 /* Flag bits */
654 #define READABLE_LOCAL_CLOCK 0x00000001
655 #define CLOCK_NETWORK_DERIVED 0x00000002
656 #define CLOCK_PRECISION 0x00000004
657 #define RECEIVE_TIME_INDICATION_CAPABLE 0x00000008
658 #define TIMED_SEND_CAPABLE 0x00000010
659 #define TIME_STAMP_CAPABLE 0x00000020
660 
661 /* NDIS packet filter bits (OID_GEN_CURRENT_PACKET_FILTER) */
662 #define NDIS_PACKET_TYPE_DIRECTED 0x00000001
663 #define NDIS_PACKET_TYPE_MULTICAST 0x00000002
664 #define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004
665 #define NDIS_PACKET_TYPE_BROADCAST 0x00000008
666 #define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010
667 #define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020
668 #define NDIS_PACKET_TYPE_SMT 0x00000040
669 #define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080
670 #define NDIS_PACKET_TYPE_GROUP 0x00001000
671 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000
672 #define NDIS_PACKET_TYPE_FUNCTIONAL 0x00004000
673 #define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000
674 
675 /* NDIS protocol option bits (OID_GEN_PROTOCOL_OPTIONS) */
676 #define NDIS_PROT_OPTION_ESTIMATED_LENGTH 0x00000001
677 #define NDIS_PROT_OPTION_NO_LOOPBACK 0x00000002
678 #define NDIS_PROT_OPTION_NO_RSVD_ON_RCVPKT 0x00000004
679 
680 /* NDIS MAC option bits (OID_GEN_MAC_OPTIONS) */
681 #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001
682 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002
683 #define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004
684 #define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008
685 #define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010
686 #define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020
687 #define NDIS_MAC_OPTION_8021P_PRIORITY 0x00000040
688 #define NDIS_MAC_OPTION_RESERVED 0x80000000
689 
690 #define NDIS_GUID_TO_OID 0x00000001
691 #define NDIS_GUID_TO_STATUS 0x00000002
692 #define NDIS_GUID_ANSI_STRING 0x00000004
693 #define NDIS_GUID_UNICODE_STRING 0x00000008
694 #define NDIS_GUID_ARRAY 0x00000010
695 
696 #if NDIS_LEGACY_DRIVER
697 
698 /* NDIS_PACKET_PRIVATE.Flags constants */
699 #define fPACKET_WRAPPER_RESERVED 0x3f
700 #define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40
701 #define fPACKET_ALLOCATED_BY_NDIS 0x80
702 
703 #define NDIS_FLAGS_PROTOCOL_ID_MASK 0x0000000f
704 #define NDIS_FLAGS_MULTICAST_PACKET 0x00000010
705 #define NDIS_FLAGS_RESERVED2 0x00000020
706 #define NDIS_FLAGS_RESERVED3 0x00000040
707 #define NDIS_FLAGS_DONT_LOOPBACK 0x00000080
708 #define NDIS_FLAGS_IS_LOOPBACK_PACKET 0x00000100
709 #define NDIS_FLAGS_LOOPBACK_ONLY 0x00000200
710 #define NDIS_FLAGS_RESERVED4 0x00000400
711 #define NDIS_FLAGS_DOUBLE_BUFFERED 0x00000800
712 #define NDIS_FLAGS_SENT_AT_DPC 0x00001000
713 #define NDIS_FLAGS_USES_SG_BUFFER_LIST 0x00002000
714 #define NDIS_FLAGS_USES_ORIGINAL_PACKET 0x00004000
715 #define NDIS_FLAGS_PADDED 0x00010000
716 #define NDIS_FLAGS_XLATE_AT_TOP 0x00020000
717 
718 typedef NDIS_HANDLE PNDIS_PACKET_POOL;
719 
720 typedef struct _NDIS_PACKET_PRIVATE {
723  PNDIS_BUFFER Head;
724  PNDIS_BUFFER Tail;
725  PNDIS_PACKET_POOL Pool;
726  UINT Count;
732 
733 typedef struct _NDIS_PACKET {
735  __MINGW_EXTENSION union {
736  __MINGW_EXTENSION struct {
739  };
740  __MINGW_EXTENSION struct {
743  };
744  __MINGW_EXTENSION struct {
745  UCHAR MacReserved[4 * sizeof(PVOID)];
746  };
747  };
751 
752 typedef struct _NDIS_PACKET_STACK {
756 
757 #endif /* NDIS_LEGACY_DRIVER */
758 
759 typedef enum _NDIS_CLASS_ID {
764 } NDIS_CLASS_ID;
765 
769  UINT Size;
772 
773 #if NDIS_LEGACY_DRIVER
774 typedef struct _NDIS_PACKET_OOB_DATA {
775  __MINGW_EXTENSION union {
778  };
783  NDIS_STATUS Status;
785 #endif
786 
787 /* Request types used by NdisRequest */
788 typedef enum _NDIS_REQUEST_TYPE {
801 #if NDIS_SUPPORT_NDIS6
802  NdisRequestMethod,
803 #endif
805 
806 #if NDIS_LEGACY_DRIVER
807 typedef struct _NDIS_REQUEST {
808  UCHAR MacReserved[4 * sizeof(PVOID)];
810  union _DATA {
822  UINT BytesRead;
824  } SET_INFORMATION;
825  } DATA;
826 #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
827  UCHAR NdisReserved[9 * sizeof(PVOID)];
828  __MINGW_EXTENSION union {
829  UCHAR CallMgrReserved[2 * sizeof(PVOID)];
830  UCHAR ProtocolReserved[2 * sizeof(PVOID)];
831  };
832  UCHAR MiniportReserved[2 * sizeof(PVOID)];
833 #endif
835 #endif /* NDIS_LEGACY_DRIVER */
836 
837 /* Wide Area Networks definitions */
838 
839 #if NDIS_LEGACY_DRIVER
840 typedef struct _NDIS_WAN_PACKET {
855 #endif
856 
857 /* DMA channel information */
858 
859 typedef struct _NDIS_DMA_DESCRIPTION {
868 
869 typedef struct _NDIS_DMA_BLOCK {
876 
878 
879 #define NDIS_DMA_24BITS ((NDIS_DMA_SIZE)0)
880 #define NDIS_DMA_32BITS ((NDIS_DMA_SIZE)1)
881 #define NDIS_DMA_64BITS ((NDIS_DMA_SIZE)2)
882 
883 typedef enum _NDIS_PROCESSOR_TYPE {
891 
896 
897 /* Possible hardware architecture */
898 typedef enum _NDIS_INTERFACE_TYPE {
918 
919 #define NdisInterruptLevelSensitive LevelSensitive
920 #define NdisInterruptLatched Latched
921 
923 
924 typedef enum _NDIS_PARAMETER_TYPE {
931 
932 typedef struct _BINARY_DATA {
935 } BINARY_DATA;
936 
939  union {
941  NDIS_STRING StringData;
943  } ParameterData;
945 
947 
950  UINT Length;
952 
953 typedef struct _NDIS_WAN_LINE_DOWN {
957 
958 typedef struct _NDIS_WAN_LINE_UP {
968  NDIS_STRING DeviceName;
970 
971 typedef NTSTATUS
974  _Out_ HANDLE *TdiHandle);
975 
976 typedef NTSTATUS
978  _In_ PUNICODE_STRING UpperComponent,
979  _In_ PUNICODE_STRING LowerComponent,
980  _In_ PUNICODE_STRING BindList,
981  _In_ PVOID ReconfigBuffer,
982  _In_ UINT ReconfigBufferSize,
983  _In_ UINT Operation);
984 
985 typedef struct _OID_LIST OID_LIST, *POID_LIST;
986 
987 /* PnP state */
988 
998 
999 #define NDIS_DEVICE_NOT_STOPPABLE 0x00000001
1000 #define NDIS_DEVICE_NOT_REMOVEABLE 0x00000002
1001 #define NDIS_DEVICE_NOT_SUSPENDABLE 0x00000004
1002 #define NDIS_DEVICE_DISABLE_PM 0x00000008
1003 #define NDIS_DEVICE_DISABLE_WAKE_UP 0x00000010
1004 #define NDIS_DEVICE_DISABLE_WAKE_ON_RECONNECT 0x00000020
1005 #define NDIS_DEVICE_RESERVED 0x00000040
1006 #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET 0x00000080
1007 #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100
1008 
1009 /* Protocol types supported by NDIS */
1010 #define NDIS_PROTOCOL_ID_DEFAULT 0x00
1011 #define NDIS_PROTOCOL_ID_TCP_IP 0x02
1012 #define NDIS_PROTOCOL_ID_IPX 0x06
1013 #define NDIS_PROTOCOL_ID_NBF 0x07
1014 #define NDIS_PROTOCOL_ID_MAX 0x0F
1015 #define NDIS_PROTOCOL_ID_MASK 0x0F
1016 
1018 
1019 #define CO_ADDRESS_FAMILY_Q2931 ((NDIS_AF)0x1)
1020 #define CO_ADDRESS_FAMILY_PSCHED ((NDIS_AF)0x2)
1021 #define CO_ADDRESS_FAMILY_L2TP ((NDIS_AF)0x3)
1022 #define CO_ADDRESS_FAMILY_IRDA ((NDIS_AF)0x4)
1023 #define CO_ADDRESS_FAMILY_1394 ((NDIS_AF)0x5)
1024 #define CO_ADDRESS_FAMILY_PPP ((NDIS_AF)0x6)
1025 #define CO_ADDRESS_FAMILY_INFINIBAND ((NDIS_AF)0x7)
1026 #define CO_ADDRESS_FAMILY_TAPI ((NDIS_AF)0x800)
1027 #define CO_ADDRESS_FAMILY_TAPI_PROXY ((NDIS_AF)0x801)
1028 
1029 #define CO_ADDRESS_FAMILY_PROXY 0x80000000
1030 
1031 typedef struct _CO_ADDRESS_FAMILY {
1036 
1037 typedef struct _CO_SPECIFIC_PARAMETERS {
1042 
1048 
1049 /* CO_MEDIA_PARAMETERS.Flags constants */
1050 #define RECEIVE_TIME_INDICATION 0x00000001
1051 #define USE_TIME_STAMPS 0x00000002
1052 #define TRANSMIT_VC 0x00000004
1053 #define RECEIVE_VC 0x00000008
1054 #define INDICATE_ERRED_PACKETS 0x00000010
1055 #define INDICATE_END_OF_TX 0x00000020
1056 #define RESERVE_RESOURCES_VC 0x00000040
1057 #define ROUND_DOWN_FLOW 0x00000080
1058 #define ROUND_UP_FLOW 0x00000100
1059 
1060 typedef struct _CO_MEDIA_PARAMETERS {
1066 
1067 /* CO_CALL_PARAMETERS.Flags constants */
1068 #define PERMANENT_VC 0x00000001
1069 #define CALL_PARAMETERS_CHANGED 0x00000002
1070 #define QUERY_CALL_PARAMETERS 0x00000004
1071 #define BROADCAST_VC 0x00000008
1072 #define MULTIPOINT_VC 0x00000010
1073 
1074 typedef struct _CO_CALL_PARAMETERS {
1079 
1080 typedef struct _CO_SAP {
1084 } CO_SAP, *PCO_SAP;
1085 
1086 #if NDIS_LEGACY_DRIVER
1087 typedef struct _NDIS_IPSEC_PACKET_INFO {
1088  __MINGW_EXTENSION union {
1089  struct {
1090  NDIS_HANDLE OffloadHandle;
1091  NDIS_HANDLE NextOffloadHandle;
1092  } Transmit;
1093  struct {
1094  ULONG SA_DELETE_REQ:1;
1095  ULONG CRYPTO_DONE:1;
1096  ULONG NEXT_CRYPTO_DONE:1;
1098  } Receive;
1099  };
1101 #endif
1102 
1103 #if (NDIS_SUPPORT_NDIS6 || NDIS60)
1104 typedef struct _NDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO {
1105  __MINGW_EXTENSION union {
1106  struct {
1107  NDIS_HANDLE OffloadHandle;
1108  } Transmit;
1109  struct {
1110  USHORT SaDeleteReq:1;
1111  USHORT CryptoDone:1;
1112  USHORT NextCryptoDone:1;
1113  USHORT Pad:13;
1114  USHORT CryptoStatus;
1115  } Receive;
1116  };
1117 } NDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO, *PNDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO;
1118 #endif
1119 
1120 /* NDIS_MAC_FRAGMENT.Errors constants */
1121 #define WAN_ERROR_CRC 0x00000001
1122 #define WAN_ERROR_FRAMING 0x00000002
1123 #define WAN_ERROR_HARDWAREOVERRUN 0x00000004
1124 #define WAN_ERROR_BUFFEROVERRUN 0x00000008
1125 #define WAN_ERROR_TIMEOUT 0x00000010
1126 #define WAN_ERROR_ALIGNMENT 0x00000020
1127 
1128 typedef struct _NDIS_MAC_FRAGMENT {
1129  NDIS_HANDLE NdisLinkContext;
1132 
1133 typedef struct _NDIS_MAC_LINE_DOWN {
1134  NDIS_HANDLE NdisLinkContext;
1136 
1137 typedef struct _NDIS_MAC_LINE_UP {
1141  NDIS_HANDLE ConnectionWrapperID;
1142  NDIS_HANDLE NdisLinkHandle;
1143  NDIS_HANDLE NdisLinkContext;
1145 
1146 typedef struct _NDIS_PACKET_8021Q_INFO {
1147  __MINGW_EXTENSION union {
1148  struct {
1149  UINT32 UserPriority:3;
1150  UINT32 CanonicalFormatId:1;
1151  UINT32 VlanId:12;
1153  } TagHeader;
1155  };
1157 
1173 
1174 #if NDIS_LEGACY_DRIVER
1175 
1176 typedef struct _NDIS_PACKET_EXTENSION {
1177  PVOID NdisPacketInfo[MaxPerPacketInfo];
1179 
1180 typedef enum _NDIS_TASK {
1185 } NDIS_TASK, *PNDIS_TASK;
1186 
1187 typedef enum _NDIS_ENCAPSULATION {
1195 
1198  struct {
1199  ULONG FixedHeaderSize:1;
1201  } Flags;
1204 
1212 
1213 typedef struct _NDIS_TASK_OFFLOAD {
1219  UCHAR TaskBuffer[1];
1221 
1223  struct {
1224  ULONG IpOptionsSupported:1;
1225  ULONG TcpOptionsSupported:1;
1226  ULONG TcpChecksum:1;
1227  ULONG UdpChecksum:1;
1228  ULONG IpChecksum:1;
1229  } V4Transmit;
1230  struct {
1231  ULONG IpOptionsSupported:1;
1232  ULONG TcpOptionsSupported:1;
1233  ULONG TcpChecksum:1;
1234  ULONG UdpChecksum:1;
1235  ULONG IpChecksum:1;
1236  } V4Receive;
1237  struct {
1238  ULONG IpOptionsSupported:1;
1239  ULONG TcpOptionsSupported:1;
1240  ULONG TcpChecksum:1;
1241  ULONG UdpChecksum:1;
1242  } V6Transmit;
1243  struct {
1244  ULONG IpOptionsSupported:1;
1245  ULONG TcpOptionsSupported:1;
1246  ULONG TcpChecksum:1;
1247  ULONG UdpChecksum:1;
1248  } V6Receive;
1250 
1251 #define NDIS_TASK_TCP_LARGE_SEND_V0 0
1252 
1260 
1261 typedef struct _NDIS_TASK_IPSEC {
1262  struct {
1267  } Supported;
1268  struct {
1269  ULONG MD5:1;
1270  ULONG SHA_1:1;
1271  ULONG Transport:1;
1272  ULONG Tunnel:1;
1273  ULONG Send:1;
1274  ULONG Receive:1;
1275  } V4AH;
1276  struct {
1277  ULONG DES:1;
1278  ULONG RESERVED:1;
1279  ULONG TRIPLE_DES:1;
1280  ULONG NULL_ESP:1;
1281  ULONG Transport:1;
1282  ULONG Tunnel:1;
1283  ULONG Send:1;
1284  ULONG Receive:1;
1285  } V4ESP;
1287 
1288 #endif /* NDIS_LEGACY_DRIVER */
1289 
1290 #define IPSEC_TPT_UDPESP_ENCAPTYPE_IKE 0x00000001
1291 #define IPSEC_TUN_UDPESP_ENCAPTYPE_IKE 0x00000002
1292 #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_IKE 0x00000004
1293 #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_IKE 0x00000008
1294 #define IPSEC_TPT_UDPESP_ENCAPTYPE_OTHER 0x00000010
1295 #define IPSEC_TUN_UDPESP_ENCAPTYPE_OTHER 0x00000020
1296 #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_OTHER 0x00000040
1297 #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_OTHER 0x00000080
1298 
1299 #if NDIS_LEGACY_DRIVER
1300 
1301 /*
1302  * PNDIS_PACKET
1303  * NDIS_GET_ORIGINAL_PACKET(
1304  * IN PNDIS_PACKET Packet);
1305  */
1306 #define NDIS_GET_ORIGINAL_PACKET(Packet) \
1307  NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, OriginalPacketInfo)
1308 
1309 /*
1310  * PVOID
1311  * NDIS_GET_PACKET_CANCEL_ID(
1312  * IN PNDIS_PACKET Packet);
1313  */
1314 #define NDIS_GET_PACKET_CANCEL_ID(Packet) \
1315  NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, PacketCancelId)
1316 
1317 /*
1318  * PNDIS_PACKET_EXTENSION
1319  * NDIS_PACKET_EXTENSION_FROM_PACKET(
1320  * IN PNDIS_PACKET Packet);
1321  */
1322 #define NDIS_PACKET_EXTENSION_FROM_PACKET(Packet) \
1323  ((PNDIS_PACKET_EXTENSION)((PUCHAR)(Packet) \
1324  + (Packet)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))
1325 
1326 /*
1327  * PVOID
1328  * NDIS_PER_PACKET_INFO_FROM_PACKET(
1329  * IN OUT PNDIS_PACKET Packet,
1330  * IN NDIS_PER_PACKET_INFO InfoType);
1331  */
1332 #define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType) \
1333  ((PNDIS_PACKET_EXTENSION)((PUCHAR)(Packet) + (Packet)->Private.NdisPacketOobOffset \
1334  + sizeof(NDIS_PACKET_OOB_DATA)))->NdisPacketInfo[(InfoType)]
1335 
1336 /*
1337  * VOID
1338  * NDIS_SET_ORIGINAL_PACKET(
1339  * IN OUT PNDIS_PACKET Packet,
1340  * IN PNDIS_PACKET OriginalPacket);
1341  */
1342 #define NDIS_SET_ORIGINAL_PACKET(Packet, OriginalPacket) \
1343  NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, OriginalPacketInfo) = (OriginalPacket)
1344 
1345 /*
1346  * VOID
1347  * NDIS_SET_PACKET_CANCEL_ID(
1348  * IN PNDIS_PACKET Packet
1349  * IN ULONG_PTR CancelId);
1350  */
1351 #define NDIS_SET_PACKET_CANCEL_ID(Packet, CancelId) \
1352  NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, PacketCancelId) = (CancelId)
1353 
1354 #define NdisSetPacketCancelId(_Packet, _CancelId) NDIS_SET_PACKET_CANCEL_ID(_Packet, _CancelId)
1355 #define NdisGetPacketCancelId(_Packet) NDIS_GET_PACKET_CANCEL_ID(_Packet)
1356 
1357 #endif /* NDIS_LEGACY_DRIVER */
1358 
1359 #if NDIS_SUPPORT_NDIS6
1360 typedef struct _NDIS_GENERIC_OBJECT {
1362  PVOID Caller;
1363  PVOID CallersCaller;
1365 } NDIS_GENERIC_OBJECT, *PNDIS_GENERIC_OBJECT;
1366 #endif
1367 
1368 /* NDIS_TASK_OFFLOAD_HEADER.Version constants */
1369 #define NDIS_TASK_OFFLOAD_VERSION 1
1370 
1371 #define MAX_HASHES 4
1372 #define TRUNCATED_HASH_LEN 12
1373 
1374 #define CRYPTO_SUCCESS 0
1375 #define CRYPTO_GENERIC_ERROR 1
1376 #define CRYPTO_TRANSPORT_AH_AUTH_FAILED 2
1377 #define CRYPTO_TRANSPORT_ESP_AUTH_FAILED 3
1378 #define CRYPTO_TUNNEL_AH_AUTH_FAILED 4
1379 #define CRYPTO_TUNNEL_ESP_AUTH_FAILED 5
1380 #define CRYPTO_INVALID_PACKET_SYNTAX 6
1381 #define CRYPTO_INVALID_PROTOCOL 7
1382 
1384  __MINGW_EXTENSION union {
1385  struct {
1386  ULONG NdisPacketChecksumV4:1;
1387  ULONG NdisPacketChecksumV6:1;
1388  ULONG NdisPacketTcpChecksum:1;
1389  ULONG NdisPacketUdpChecksum:1;
1390  ULONG NdisPacketIpChecksum:1;
1391  } Transmit;
1392  struct {
1393  ULONG NdisPacketTcpChecksumFailed:1;
1394  ULONG NdisPacketUdpChecksumFailed:1;
1395  ULONG NdisPacketIpChecksumFailed:1;
1396  ULONG NdisPacketTcpChecksumSucceeded:1;
1397  ULONG NdisPacketUdpChecksumSucceeded:1;
1398  ULONG NdisPacketIpChecksumSucceeded:1;
1399  ULONG NdisPacketLoopback:1;
1400  } Receive;
1402  };
1404 
1405 typedef struct _NDIS_WAN_CO_FRAGMENT {
1408 
1409 typedef struct _NDIS_WAN_FRAGMENT {
1413 
1414 typedef struct _WAN_CO_LINKPARAMS {
1419 
1420 typedef struct _NDIS_WAN_GET_STATS {
1437 
1438 /* Call Manager */
1439 
1440 typedef VOID
1442  IN NDIS_STATUS Status,
1443  IN NDIS_HANDLE CallMgrVcContext,
1445 
1446 typedef NDIS_STATUS
1448  IN NDIS_HANDLE CallMgrVcContext,
1450  IN NDIS_HANDLE NdisPartyHandle,
1451  OUT PNDIS_HANDLE CallMgrPartyContext);
1452 
1453 typedef NDIS_STATUS
1455  IN NDIS_HANDLE CallMgrAfContext);
1456 
1457 typedef NDIS_STATUS
1459  IN NDIS_HANDLE CallMgrVcContext,
1460  IN NDIS_HANDLE CallMgrPartyContext OPTIONAL,
1461  IN PVOID CloseData OPTIONAL,
1462  IN UINT Size OPTIONAL);
1463 
1464 typedef NDIS_STATUS
1466  IN NDIS_HANDLE CallMgrSapContext);
1467 
1468 typedef VOID
1470  IN NDIS_STATUS Status,
1471  IN NDIS_HANDLE CallMgrVcContext);
1472 
1473 typedef NDIS_STATUS
1475  IN NDIS_HANDLE CallMgrPartyContext,
1476  IN PVOID CloseData OPTIONAL,
1477  IN UINT Size OPTIONAL);
1478 
1479 typedef VOID
1481  IN NDIS_STATUS Status,
1482  IN NDIS_HANDLE CallMgrVcContext,
1484 
1485 typedef NDIS_STATUS
1487  IN NDIS_HANDLE CallMgrVcContext,
1489  IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
1490  OUT PNDIS_HANDLE CallMgrPartyContext OPTIONAL);
1491 
1492 typedef NDIS_STATUS
1494  IN NDIS_HANDLE CallMgrVcContext,
1496 
1497 typedef NDIS_STATUS
1499  IN NDIS_HANDLE CallMgrBindingContext,
1501  IN NDIS_HANDLE NdisAfHandle,
1502  OUT PNDIS_HANDLE CallMgrAfContext);
1503 
1504 typedef NDIS_STATUS
1506  IN NDIS_HANDLE CallMgrAfContext,
1507  IN PCO_SAP Sap,
1508  IN NDIS_HANDLE NdisSapHandle,
1509  OUT PNDIS_HANDLE CallMgrSapContext);
1510 
1511 typedef NDIS_STATUS
1513  IN NDIS_HANDLE ProtocolAfContext,
1514  IN NDIS_HANDLE NdisVcHandle,
1515  OUT PNDIS_HANDLE ProtocolVcContext);
1516 
1517 typedef NDIS_STATUS
1519  IN NDIS_HANDLE ProtocolVcContext);
1520 
1521 #define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(PVOID))
1522 
1523 /* Prototypes for NDIS 5.0 protocol characteristics */
1524 
1526 typedef VOID
1527 (NTAPI *CO_SEND_COMPLETE_HANDLER)(
1528  _In_ NDIS_STATUS Status,
1530  _In_ PNDIS_PACKET Packet);
1531 
1533 typedef VOID
1534 (NTAPI *CO_STATUS_HANDLER)(
1535  _In_ NDIS_HANDLE ProtocolBindingContext,
1536  _In_opt_ NDIS_HANDLE ProtocolVcContext,
1537  _In_ NDIS_STATUS GeneralStatus,
1539  _In_ UINT StatusBufferSize);
1540 
1542 typedef UINT
1543 (NTAPI *CO_RECEIVE_PACKET_HANDLER)(
1544  _In_ NDIS_HANDLE ProtocolBindingContext,
1545  _In_ NDIS_HANDLE ProtocolVcContext,
1546  _In_ PNDIS_PACKET Packet);
1547 
1549 typedef NDIS_STATUS
1550 (NTAPI *CO_REQUEST_HANDLER)(
1551  _In_ NDIS_HANDLE ProtocolAfContext,
1552  _In_opt_ NDIS_HANDLE ProtocolVcContext,
1553  _In_opt_ NDIS_HANDLE ProtocolPartyContext,
1554  _Inout_ PNDIS_REQUEST NdisRequest);
1555 
1557 typedef VOID
1558 (NTAPI *CO_REQUEST_COMPLETE_HANDLER)(
1559  _In_ NDIS_STATUS Status,
1560  _In_opt_ NDIS_HANDLE ProtocolAfContext,
1561  _In_opt_ NDIS_HANDLE ProtocolVcContext,
1562  _In_opt_ NDIS_HANDLE ProtocolPartyContext,
1563  _In_ PNDIS_REQUEST NdisRequest);
1564 
1569  UINT Reserved;
1570  CO_CREATE_VC_HANDLER CmCreateVcHandler;
1571  CO_DELETE_VC_HANDLER CmDeleteVcHandler;
1572  CM_OPEN_AF_HANDLER CmOpenAfHandler;
1573  CM_CLOSE_AF_HANDLER CmCloseAfHandler;
1574  CM_REG_SAP_HANDLER CmRegisterSapHandler;
1575  CM_DEREG_SAP_HANDLER CmDeregisterSapHandler;
1576  CM_MAKE_CALL_HANDLER CmMakeCallHandler;
1577  CM_CLOSE_CALL_HANDLER CmCloseCallHandler;
1578  CM_INCOMING_CALL_COMPLETE_HANDLER CmIncomingCallCompleteHandler;
1579  CM_ADD_PARTY_HANDLER CmAddPartyHandler;
1580  CM_DROP_PARTY_HANDLER CmDropPartyHandler;
1581  CM_ACTIVATE_VC_COMPLETE_HANDLER CmActivateVcCompleteHandler;
1582  CM_DEACTIVATE_VC_COMPLETE_HANDLER CmDeactivateVcCompleteHandler;
1583  CM_MODIFY_CALL_QOS_HANDLER CmModifyCallQoSHandler;
1584  CO_REQUEST_HANDLER CmRequestHandler;
1585  CO_REQUEST_COMPLETE_HANDLER CmRequestCompleteHandler;
1587 
1588 
1589 
1590 /* Call Manager clients */
1591 
1593  IN NDIS_STATUS Status,
1594  IN NDIS_HANDLE ProtocolAfContext,
1595  IN NDIS_HANDLE NdisAfHandle);
1596 
1597 typedef VOID
1599  IN NDIS_STATUS Status,
1600  IN NDIS_HANDLE ProtocolAfContext);
1601 
1602 typedef VOID
1604  IN NDIS_STATUS Status,
1605  IN NDIS_HANDLE ProtocolSapContext,
1606  IN PCO_SAP Sap,
1607  IN NDIS_HANDLE NdisSapHandle);
1608 
1609 typedef VOID
1611  IN NDIS_STATUS Status,
1612  IN NDIS_HANDLE ProtocolSapContext);
1613 
1614 typedef VOID
1616  IN NDIS_STATUS Status,
1617  IN NDIS_HANDLE ProtocolVcContext,
1618  IN NDIS_HANDLE NdisPartyHandle OPTIONAL,
1620 
1621 typedef VOID
1623  IN NDIS_STATUS Status,
1624  IN NDIS_HANDLE ProtocolVcContext,
1626 
1627 typedef VOID
1629  IN NDIS_STATUS Status,
1630  IN NDIS_HANDLE ProtocolVcContext,
1631  IN NDIS_HANDLE ProtocolPartyContext OPTIONAL);
1632 
1633 typedef VOID
1635  IN NDIS_STATUS Status,
1636  IN NDIS_HANDLE ProtocolPartyContext,
1637  IN NDIS_HANDLE NdisPartyHandle,
1639 
1640 typedef VOID
1642  IN NDIS_STATUS Status,
1643  IN NDIS_HANDLE ProtocolPartyContext);
1644 
1645 typedef NDIS_STATUS
1647  IN NDIS_HANDLE ProtocolSapContext,
1648  IN NDIS_HANDLE ProtocolVcContext,
1650 
1651 typedef VOID
1653  IN NDIS_HANDLE ProtocolVcContext,
1655 
1656 typedef VOID
1658  IN NDIS_STATUS CloseStatus,
1659  IN NDIS_HANDLE ProtocolVcContext,
1660  IN PVOID CloseData OPTIONAL,
1661  IN UINT Size OPTIONAL);
1662 
1663 typedef VOID
1665  IN NDIS_STATUS DropStatus,
1666  IN NDIS_HANDLE ProtocolPartyContext,
1667  IN PVOID CloseData OPTIONAL,
1668  IN UINT Size OPTIONAL);
1669 
1670 typedef VOID
1672  IN NDIS_HANDLE ProtocolVcContext);
1673 
1674 
1679  UINT Reserved;
1680  CO_CREATE_VC_HANDLER ClCreateVcHandler;
1681  CO_DELETE_VC_HANDLER ClDeleteVcHandler;
1682  CO_REQUEST_HANDLER ClRequestHandler;
1683  CO_REQUEST_COMPLETE_HANDLER ClRequestCompleteHandler;
1685  CL_CLOSE_AF_COMPLETE_HANDLER ClCloseAfCompleteHandler;
1686  CL_REG_SAP_COMPLETE_HANDLER ClRegisterSapCompleteHandler;
1687  CL_DEREG_SAP_COMPLETE_HANDLER ClDeregisterSapCompleteHandler;
1688  CL_MAKE_CALL_COMPLETE_HANDLER ClMakeCallCompleteHandler;
1689  CL_MODIFY_CALL_QOS_COMPLETE_HANDLER ClModifyCallQoSCompleteHandler;
1690  CL_CLOSE_CALL_COMPLETE_HANDLER ClCloseCallCompleteHandler;
1691  CL_ADD_PARTY_COMPLETE_HANDLER ClAddPartyCompleteHandler;
1692  CL_DROP_PARTY_COMPLETE_HANDLER ClDropPartyCompleteHandler;
1693  CL_INCOMING_CALL_HANDLER ClIncomingCallHandler;
1694  CL_INCOMING_CALL_QOS_CHANGE_HANDLER ClIncomingCallQoSChangeHandler;
1695  CL_INCOMING_CLOSE_CALL_HANDLER ClIncomingCloseCallHandler;
1696  CL_INCOMING_DROP_PARTY_HANDLER ClIncomingDropPartyHandler;
1697  CL_CALL_CONNECTED_HANDLER ClCallConnectedHandler;
1699 
1700 
1701 /* NDIS protocol structures */
1702 
1703 /* Prototypes for NDIS 3.0 protocol characteristics */
1704 
1705 typedef VOID
1707  _In_ NDIS_HANDLE ProtocolBindingContext,
1708  _In_ NDIS_STATUS Status,
1709  _In_ NDIS_STATUS OpenErrorStatus);
1710 
1711 typedef VOID
1713  _In_ NDIS_HANDLE ProtocolBindingContext,
1714  _In_ NDIS_STATUS Status);
1715 
1716 typedef VOID
1718  _In_ NDIS_HANDLE ProtocolBindingContext,
1719  _In_ NDIS_STATUS Status);
1720 
1721 typedef VOID
1723  _In_ NDIS_HANDLE ProtocolBindingContext,
1724  _In_ PNDIS_REQUEST NdisRequest,
1725  _In_ NDIS_STATUS Status);
1726 
1727 typedef VOID
1729  _In_ NDIS_HANDLE ProtocolBindingContext,
1730  _In_ NDIS_STATUS GeneralStatus,
1732  _In_ UINT StatusBufferSize);
1733 
1734 typedef VOID
1736  _In_ NDIS_HANDLE ProtocolBindingContext);
1737 
1738 typedef VOID
1740  _In_ NDIS_HANDLE ProtocolBindingContext,
1741  _In_ PNDIS_PACKET Packet,
1742  _In_ NDIS_STATUS Status);
1743 
1744 typedef VOID
1746  _In_ NDIS_HANDLE ProtocolBindingContext,
1747  _In_ PNDIS_WAN_PACKET Packet,
1748  _In_ NDIS_STATUS Status);
1749 
1750 typedef VOID
1752  _In_ NDIS_HANDLE ProtocolBindingContext,
1753  _In_ PNDIS_PACKET Packet,
1754  _In_ NDIS_STATUS Status,
1755  _In_ UINT BytesTransferred);
1756 
1757 typedef VOID
1759  VOID);
1760 
1761 typedef NDIS_STATUS
1763  _In_ NDIS_HANDLE ProtocolBindingContext,
1764  _In_ NDIS_HANDLE MacReceiveContext,
1765  _In_ PVOID HeaderBuffer,
1766  _In_ UINT HeaderBufferSize,
1767  _In_ PVOID LookAheadBuffer,
1768  _In_ UINT LookaheadBufferSize,
1769  _In_ UINT PacketSize);
1770 
1771 typedef NDIS_STATUS
1773  _In_ NDIS_HANDLE NdisLinkHandle,
1774  _In_ PUCHAR Packet,
1776 
1777 typedef VOID
1779  _In_ NDIS_HANDLE ProtocolBindingContext);
1780 
1781 /* Protocol characteristics for NDIS 3.0 protocols */
1782 
1783 #define NDIS30_PROTOCOL_CHARACTERISTICS_S \
1784  UCHAR MajorNdisVersion; \
1785  UCHAR MinorNdisVersion; \
1786  USHORT Filler; \
1787  _ANONYMOUS_UNION union { \
1788  UINT Reserved; \
1789  UINT Flags; \
1790  } DUMMYUNIONNAME; \
1791  OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler; \
1792  CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler; \
1793  _ANONYMOUS_UNION union { \
1794  SEND_COMPLETE_HANDLER SendCompleteHandler; \
1795  WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler; \
1796  } DUMMYUNIONNAME2; \
1797  _ANONYMOUS_UNION union { \
1798  TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler; \
1799  WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler; \
1800  } DUMMYUNIONNAME3; \
1801  RESET_COMPLETE_HANDLER ResetCompleteHandler; \
1802  REQUEST_COMPLETE_HANDLER RequestCompleteHandler; \
1803  _ANONYMOUS_UNION union { \
1804  RECEIVE_HANDLER ReceiveHandler; \
1805  WAN_RECEIVE_HANDLER WanReceiveHandler; \
1806  } DUMMYUNIONNAME4; \
1807  RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler; \
1808  STATUS_HANDLER StatusHandler; \
1809  STATUS_COMPLETE_HANDLER StatusCompleteHandler; \
1810  NDIS_STRING Name;
1811 
1815 
1816 
1817 /* Prototypes for NDIS 4.0 protocol characteristics */
1818 
1819 typedef INT
1821  IN NDIS_HANDLE ProtocolBindingContext,
1822  IN PNDIS_PACKET Packet);
1823 
1824 typedef VOID
1826  OUT PNDIS_STATUS Status,
1827  IN NDIS_HANDLE BindContext,
1828  IN PNDIS_STRING DeviceName,
1829  IN PVOID SystemSpecific1,
1831 
1832 typedef VOID
1834  OUT PNDIS_STATUS Status,
1835  IN NDIS_HANDLE ProtocolBindingContext,
1836  IN NDIS_HANDLE UnbindContext);
1837 
1838 typedef NDIS_STATUS
1840  IN NDIS_HANDLE ProtocolBindingContext,
1841  IN PNET_PNP_EVENT NetPnPEvent);
1842 
1843 typedef VOID
1845  VOID);
1846 
1847 /* Protocol characteristics for NDIS 4.0 protocols */
1848 
1853  __MINGW_EXTENSION union {
1854  UINT Reserved;
1855  UINT Flags;
1856  };
1857  OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler;
1858  CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler;
1859  __MINGW_EXTENSION union {
1860  SEND_COMPLETE_HANDLER SendCompleteHandler;
1861  WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler;
1862  };
1863  __MINGW_EXTENSION union {
1864  TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler;
1865  WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler;
1866  };
1867  RESET_COMPLETE_HANDLER ResetCompleteHandler;
1868  REQUEST_COMPLETE_HANDLER RequestCompleteHandler;
1869  __MINGW_EXTENSION union {
1870  RECEIVE_HANDLER ReceiveHandler;
1871  WAN_RECEIVE_HANDLER WanReceiveHandler;
1872  };
1873  RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler;
1874  STATUS_HANDLER StatusHandler;
1875  STATUS_COMPLETE_HANDLER StatusCompleteHandler;
1876  NDIS_STRING Name;
1877  RECEIVE_PACKET_HANDLER ReceivePacketHandler;
1878  BIND_HANDLER BindAdapterHandler;
1879  UNBIND_HANDLER UnbindAdapterHandler;
1880  PNP_EVENT_HANDLER PnPEventHandler;
1881  UNLOAD_PROTOCOL_HANDLER UnloadHandler;
1883 
1884 typedef VOID
1885 (NTAPI PROTCOL_CO_AF_REGISTER_NOTIFY)(
1886  IN NDIS_HANDLE ProtocolBindingContext,
1888 typedef PROTCOL_CO_AF_REGISTER_NOTIFY *CO_AF_REGISTER_NOTIFY_HANDLER;
1889 
1890 #if NDIS_LEGACY_PROTOCOL
1891 
1893 #ifdef __cplusplus
1894  NDIS40_PROTOCOL_CHARACTERISTICS Ndis40Chars;
1895 #else
1897 #endif
1898  PVOID ReservedHandlers[4];
1899  CO_SEND_COMPLETE_HANDLER CoSendCompleteHandler;
1900  CO_STATUS_HANDLER CoStatusHandler;
1901  CO_RECEIVE_PACKET_HANDLER CoReceivePacketHandler;
1904 
1905 #if (defined(NDIS50) || defined(NDIS51))
1907 #else
1909 #endif
1910 
1912 
1913 #endif /* NDIS_LEGACY_PROTOCOL */
1914 
1915 /* Prototypes for NDIS_MINIPORT_CHARACTERISTICS */
1916 
1917 typedef BOOLEAN
1919  _In_ NDIS_HANDLE MiniportAdapterContext);
1920 
1921 typedef VOID
1923  _In_ NDIS_HANDLE MiniportAdapterContext);
1924 
1925 typedef VOID
1927  _In_ NDIS_HANDLE MiniportAdapterContext);
1928 
1929 typedef VOID
1931  _In_ NDIS_HANDLE MiniportAdapterContext);
1932 
1933 typedef VOID
1935  _In_ NDIS_HANDLE MiniportAdapterContext);
1936 
1937 typedef NDIS_STATUS
1939  _Out_ PNDIS_STATUS OpenErrorStatus,
1940  _Out_ PUINT SelectedMediumIndex,
1941  _In_ PNDIS_MEDIUM MediumArray,
1942  _In_ UINT MediumArraySize,
1943  _In_ NDIS_HANDLE MiniportAdapterContext,
1944  _In_ NDIS_HANDLE WrapperConfigurationContext);
1945 
1946 typedef VOID
1948  _Out_ PBOOLEAN InterruptRecognized,
1949  _Out_ PBOOLEAN QueueMiniportHandleInterrupt,
1950  _In_ NDIS_HANDLE MiniportAdapterContext);
1951 
1952 typedef NDIS_STATUS
1954  _In_ NDIS_HANDLE MiniportAdapterContext,
1955  _In_ NDIS_OID Oid,
1956  _In_ PVOID InformationBuffer,
1957  _In_ ULONG InformationBufferLength,
1959  _Out_ PULONG BytesNeeded);
1960 
1961 typedef NDIS_STATUS
1963  _Out_ PNDIS_STATUS OpenErrorStatus,
1964  _In_ NDIS_HANDLE MiniportAdapterContext,
1965  _In_ NDIS_HANDLE WrapperConfigurationContext);
1966 
1967 typedef NDIS_STATUS
1969  _Out_ PBOOLEAN AddressingReset,
1970  _In_ NDIS_HANDLE MiniportAdapterContext);
1971 
1972 typedef NDIS_STATUS
1974  _In_ NDIS_HANDLE MiniportAdapterContext,
1975  _In_ PNDIS_PACKET Packet,
1976  _In_ UINT Flags);
1977 
1978 typedef NDIS_STATUS
1980  _In_ NDIS_HANDLE MiniportAdapterContext,
1981  _In_ NDIS_HANDLE NdisLinkHandle,
1982  _In_ PNDIS_WAN_PACKET Packet);
1983 
1984 typedef NDIS_STATUS
1986  _In_ NDIS_HANDLE MiniportAdapterContext,
1987  _In_ NDIS_OID Oid,
1988  _In_ PVOID InformationBuffer,
1989  _In_ ULONG InformationBufferLength,
1991  _Out_ PULONG BytesNeeded);
1992 
1993 typedef NDIS_STATUS
1995  _Out_ PNDIS_PACKET Packet,
1996  _Out_ PUINT BytesTransferred,
1997  _In_ NDIS_HANDLE MiniportAdapterContext,
1998  _In_ NDIS_HANDLE MiniportReceiveContext,
1999  _In_ UINT ByteOffset,
2000  _In_ UINT BytesToTransfer);
2001 
2002 typedef NDIS_STATUS
2004 
2005 typedef VOID
2007  _In_ PVOID ShutdownContext);
2008 
2009 typedef VOID
2011  _In_ NDIS_HANDLE MiniportAdapterContext,
2012  _In_ PNDIS_PACKET Packet);
2013 
2014 typedef VOID
2016  _In_ NDIS_HANDLE MiniportAdapterContext,
2017  _In_ PPNDIS_PACKET PacketArray,
2018  _In_ UINT NumberOfPackets);
2019 
2020 typedef VOID
2022  _In_ NDIS_HANDLE MiniportAdapterContext,
2025  _In_ ULONG Length,
2026  _In_ PVOID Context);
2027 
2028 /* NDIS structures available only to miniport drivers */
2029 
2030 #define NDIS30_MINIPORT_CHARACTERISTICS_S \
2031  UCHAR MajorNdisVersion; \
2032  UCHAR MinorNdisVersion; \
2033  UINT Reserved; \
2034  W_CHECK_FOR_HANG_HANDLER CheckForHangHandler; \
2035  W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler; \
2036  W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler; \
2037  W_HALT_HANDLER HaltHandler; \
2038  W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler; \
2039  W_INITIALIZE_HANDLER InitializeHandler; \
2040  W_ISR_HANDLER ISRHandler; \
2041  W_QUERY_INFORMATION_HANDLER QueryInformationHandler; \
2042  W_RECONFIGURE_HANDLER ReconfigureHandler; \
2043  W_RESET_HANDLER ResetHandler; \
2044  W_SEND_HANDLER SendHandler; \
2045  W_SET_INFORMATION_HANDLER SetInformationHandler; \
2046  W_TRANSFER_DATA_HANDLER TransferDataHandler;
2047 
2051 
2052 #ifdef __cplusplus
2053 
2054 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
2055  NDIS30_MINIPORT_CHARACTERISTICS Ndis30Chars; \
2056  W_RETURN_PACKET_HANDLER ReturnPacketHandler; \
2057  W_SEND_PACKETS_HANDLER SendPacketsHandler; \
2058  W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
2059 
2060 #else /* !__cplusplus */
2061 
2062 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
2063  NDIS30_MINIPORT_CHARACTERISTICS_S \
2064  W_RETURN_PACKET_HANDLER ReturnPacketHandler; \
2065  W_SEND_PACKETS_HANDLER SendPacketsHandler; \
2066  W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler;
2067 
2068 #endif /* !__cplusplus */
2069 
2073 
2074 /* Extensions for NDIS 5.0 miniports */
2075 
2077 _Function_class_(MINIPORT_CO_CREATE_VC)
2078 typedef NDIS_STATUS
2079 (NTAPI MINIPORT_CO_CREATE_VC)(
2080  _In_ NDIS_HANDLE MiniportAdapterContext,
2081  _In_ NDIS_HANDLE NdisVcHandle,
2082  _Out_ PNDIS_HANDLE MiniportVcContext);
2083 typedef MINIPORT_CO_CREATE_VC *W_CO_CREATE_VC_HANDLER;
2084 
2086 _Function_class_(MINIPORT_CO_DELETE_VC)
2087 typedef NDIS_STATUS
2088 (NTAPI MINIPORT_CO_DELETE_VC)(
2089  _In_ NDIS_HANDLE MiniportVcContext);
2090 typedef MINIPORT_CO_DELETE_VC *W_CO_DELETE_VC_HANDLER;
2091 
2093 _Function_class_(MINIPORT_CO_ACTIVATE_VC)
2094 typedef NDIS_STATUS
2095 (NTAPI MINIPORT_CO_ACTIVATE_VC)(
2096  _In_ NDIS_HANDLE MiniportVcContext,
2098 typedef MINIPORT_CO_ACTIVATE_VC *W_CO_ACTIVATE_VC_HANDLER;
2099 
2101 _Function_class_(MINIPORT_CO_DEACTIVATE_VC)
2102 typedef NDIS_STATUS
2103 (NTAPI MINIPORT_CO_DEACTIVATE_VC)(
2104  _In_ NDIS_HANDLE MiniportVcContext);
2105 typedef MINIPORT_CO_DEACTIVATE_VC *W_CO_DEACTIVATE_VC_HANDLER;
2106 
2107 typedef VOID
2109  _In_ NDIS_HANDLE MiniportVcContext,
2110  _In_ PPNDIS_PACKET PacketArray,
2111  _In_ UINT NumberOfPackets);
2112 
2113 typedef NDIS_STATUS
2115  _In_ NDIS_HANDLE MiniportAdapterContext,
2116  _In_opt_ NDIS_HANDLE MiniportVcContext,
2117  _Inout_ PNDIS_REQUEST NdisRequest);
2118 
2119 #ifdef __cplusplus
2120 
2121 #define NDIS50_MINIPORT_CHARACTERISTICS_S \
2122  NDIS40_MINIPORT_CHARACTERISTICS Ndis40Chars; \
2123  W_CO_CREATE_VC_HANDLER CoCreateVcHandler; \
2124  W_CO_DELETE_VC_HANDLER CoDeleteVcHandler; \
2125  W_CO_ACTIVATE_VC_HANDLER CoActivateVcHandler; \
2126  W_CO_DEACTIVATE_VC_HANDLER CoDeactivateVcHandler; \
2127  W_CO_SEND_PACKETS_HANDLER CoSendPacketsHandler; \
2128  W_CO_REQUEST_HANDLER CoRequestHandler;
2129 
2130 #else /* !__cplusplus */
2131 
2132 #define NDIS50_MINIPORT_CHARACTERISTICS_S \
2133  NDIS40_MINIPORT_CHARACTERISTICS_S \
2134  W_CO_CREATE_VC_HANDLER CoCreateVcHandler; \
2135  W_CO_DELETE_VC_HANDLER CoDeleteVcHandler; \
2136  W_CO_ACTIVATE_VC_HANDLER CoActivateVcHandler; \
2137  W_CO_DEACTIVATE_VC_HANDLER CoDeactivateVcHandler; \
2138  W_CO_SEND_PACKETS_HANDLER CoSendPacketsHandler; \
2139  W_CO_REQUEST_HANDLER CoRequestHandler;
2140 
2141 #endif /* !__cplusplus */
2142 
2146 
2147 /* Extensions for NDIS 5.1 miniports */
2148 
2149 typedef VOID
2151  _In_ NDIS_HANDLE MiniportAdapterContext,
2152  _In_ PVOID CancelId);
2153 
2154 typedef VOID
2156  _In_ NDIS_HANDLE MiniportAdapterContext,
2157  _In_ NDIS_DEVICE_PNP_EVENT PnPEvent,
2158  _In_ PVOID InformationBuffer,
2159  _In_ ULONG InformationBufferLength);
2160 
2161 typedef VOID
2163  _In_ PVOID ShutdownContext);
2164 
2165 #ifdef __cplusplus
2166 
2167 #define NDIS51_MINIPORT_CHARACTERISTICS_S \
2168  NDIS50_MINIPORT_CHARACTERISTICS Ndis50Chars; \
2169  W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler; \
2170  W_PNP_EVENT_NOTIFY_HANDLER PnPEventNotifyHandler; \
2171  W_MINIPORT_SHUTDOWN_HANDLER AdapterShutdownHandler; \
2172  PVOID Reserved1; \
2173  PVOID Reserved2; \
2174  PVOID Reserved3; \
2175  PVOID Reserved4;
2176 
2177 #else
2178 
2179 #define NDIS51_MINIPORT_CHARACTERISTICS_S \
2180  NDIS50_MINIPORT_CHARACTERISTICS_S \
2181  W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler; \
2182  W_PNP_EVENT_NOTIFY_HANDLER PnPEventNotifyHandler; \
2183  W_MINIPORT_SHUTDOWN_HANDLER AdapterShutdownHandler; \
2184  PVOID Reserved1; \
2185  PVOID Reserved2; \
2186  PVOID Reserved3; \
2187  PVOID Reserved4;
2188 
2189 #endif
2190 
2194 
2195 #if defined(NDIS51_MINIPORT)
2196 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2199 #elif defined(NDIS50_MINIPORT)
2200 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2203 #elif defined(NDIS40_MINIPORT)
2204 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2207 #else /* NDIS30 */
2211 #endif
2212 
2217  W_ISR_HANDLER MiniportIsr;
2218  W_HANDLE_INTERRUPT_HANDLER MiniportDpc;
2220  PNDIS_MINIPORT_BLOCK Miniport;
2227 
2228 /* Structures available only to full MAC drivers */
2229 
2230 typedef BOOLEAN
2232  IN PVOID InterruptContext);
2233 
2234 typedef VOID
2236  IN PVOID SystemSpecific1,
2237  IN PVOID InterruptContext,
2240 
2241 typedef struct _NDIS_WRAPPER_HANDLE NDIS_WRAPPER_HANDLE, *PNDIS_WRAPPER_HANDLE;
2242 typedef struct _NDIS_PROTOCOL_BLOCK NDIS_PROTOCOL_BLOCK, *PNDIS_PROTOCOL_BLOCK;
2245 typedef struct _NDIS_OFFLOAD NDIS_OFFLOAD, *PNDIS_OFFLOAD;
2246 typedef struct _NDIS_AF_LIST NDIS_AF_LIST, *PNDIS_AF_LIST;
2247 typedef struct _X_FILTER ETH_FILTER, *PETH_FILTER;
2248 #if NDIS_SUPPORT_NDIS6
2249 typedef USHORT NET_FRAME_TYPE, *PNET_FRAME_TYPE;
2250 #endif
2251 
2252 typedef struct _NDIS_MINIPORT_TIMER {
2257  PNDIS_MINIPORT_BLOCK Miniport;
2260 
2261 typedef struct _NDIS_INTERRUPT {
2264  PNDIS_INTERRUPT_SERVICE MacIsr;
2265  PNDIS_DEFERRED_PROCESSING MacDpc;
2272 
2273 
2274 typedef enum _NDIS_WORK_ITEM_TYPE {
2285 
2286 #define NUMBER_OF_WORK_ITEM_TYPES NdisMaxWorkItems
2287 #define NUMBER_OF_SINGLE_WORK_ITEMS 6
2288 
2294 
2295 struct _NDIS_WORK_ITEM;
2296 typedef VOID (NTAPI *NDIS_PROC)(struct _NDIS_WORK_ITEM *, PVOID);
2297 
2298 typedef struct _NDIS_WORK_ITEM {
2300  NDIS_PROC Routine;
2301  UCHAR WrapperReserved[8*sizeof(PVOID)];
2303 
2304 typedef struct _NDIS_BIND_PATHS {
2305  UINT Number;
2306  NDIS_STRING Paths[1];
2308 
2309 
2310 typedef VOID
2313 
2314 typedef VOID
2317  _In_ NDIS_HANDLE MacReceiveContext,
2318  _In_ PCHAR Address,
2319  _In_ PVOID HeaderBuffer,
2320  _In_ UINT HeaderBufferSize,
2321  _In_ PVOID LookaheadBuffer,
2322  _In_ UINT LookaheadBufferSize,
2323  _In_ UINT PacketSize);
2324 
2325 typedef VOID
2327  IN PFDDI_FILTER Filter);
2328 
2329 typedef VOID
2331  IN PFDDI_FILTER Filter,
2332  IN NDIS_HANDLE MacReceiveContext,
2333  IN PCHAR Address,
2334  IN UINT AddressLength,
2335  IN PVOID HeaderBuffer,
2336  IN UINT HeaderBufferSize,
2337  IN PVOID LookaheadBuffer,
2338  IN UINT LookaheadBufferSize,
2339  IN UINT PacketSize);
2340 
2341 typedef VOID
2343  _In_ NDIS_HANDLE Miniport,
2344  _In_ PPNDIS_PACKET PacketArray,
2345  _In_ UINT NumberOfPackets);
2346 
2347 typedef VOID
2349  _In_ PTR_FILTER Filter);
2350 
2351 typedef VOID
2353  _In_ PTR_FILTER Filter,
2354  _In_ NDIS_HANDLE MacReceiveContext,
2355  _In_ PVOID HeaderBuffer,
2356  _In_ UINT HeaderBufferSize,
2357  _In_ PVOID LookaheadBuffer,
2358  _In_ UINT LookaheadBufferSize,
2359  _In_ UINT PacketSize);
2360 
2361 typedef VOID
2363  _In_ NDIS_HANDLE MiniportAdapterHandle,
2364  _In_ NDIS_HANDLE NdisLinkContext);
2365 
2366 typedef VOID
2368  _Out_ PNDIS_STATUS Status,
2369  _In_ NDIS_HANDLE MiniportAdapterHandle,
2370  _In_ NDIS_HANDLE NdisLinkContext,
2371  _In_ PUCHAR Packet,
2373 
2374 typedef VOID
2376  IN PNDIS_MINIPORT_BLOCK Miniport,
2377  IN NDIS_WORK_ITEM_TYPE WorkItemType,
2378  OUT PVOID *WorkItemContext);
2379 
2380 typedef NDIS_STATUS
2382  IN PNDIS_MINIPORT_BLOCK Miniport,
2383  IN NDIS_WORK_ITEM_TYPE WorkItemType,
2384  IN PVOID WorkItemContext);
2385 
2386 typedef NDIS_STATUS
2388  IN PNDIS_MINIPORT_BLOCK Miniport,
2389  IN NDIS_WORK_ITEM_TYPE WorkItemType,
2390  IN PVOID WorkItemContext);
2391 
2392 typedef VOID
2394  _In_ NDIS_HANDLE MiniportAdapterHandle,
2395  _In_ NDIS_STATUS Status);
2396 
2397 typedef VOID
2399  _In_ NDIS_HANDLE MiniportAdapterHandle,
2400  _In_ NDIS_STATUS Status,
2401  _In_ BOOLEAN AddressingReset);
2402 
2403 typedef VOID
2405  _In_ NDIS_HANDLE MiniportAdapterHandle,
2406  _In_ PNDIS_PACKET Packet,
2407  _In_ NDIS_STATUS Status);
2408 
2409 typedef VOID
2411  _In_ NDIS_HANDLE MiniportAdapterHandle);
2412 
2413 typedef BOOLEAN
2415  _In_ PNDIS_MINIPORT_BLOCK Miniport);
2416 
2417 typedef VOID
2419  _In_ NDIS_HANDLE MiniportHandle,
2420  _In_ NDIS_STATUS GeneralStatus,
2422  _In_ UINT StatusBufferSize);
2423 
2424 typedef VOID
2426  _In_ NDIS_HANDLE MiniportAdapterHandle);
2427 
2428 typedef VOID
2430  _In_ NDIS_HANDLE MiniportAdapterHandle,
2431  _In_ PNDIS_PACKET Packet,
2432  _In_ NDIS_STATUS Status,
2433  _In_ UINT BytesTransferred);
2434 
2436  _In_ NDIS_HANDLE MiniportAdapterHandle,
2437  _In_ PVOID Packet,
2438  _In_ NDIS_STATUS Status);
2439 
2440 
2441 #if ARCNET
2442 
2443 #define ARC_SEND_BUFFERS 8
2444 #define ARC_HEADER_SIZE 4
2445 
2446 typedef struct _NDIS_ARC_BUF {
2447  NDIS_HANDLE ArcnetBufferPool;
2448  PUCHAR ArcnetLookaheadBuffer;
2449  UINT NumFree;
2450  ARC_BUFFER_LIST ArcnetBuffers[ARC_SEND_BUFFERS];
2451 } NDIS_ARC_BUF, *PNDIS_ARC_BUF;
2452 
2453 #endif /* ARCNET */
2454 
2455 typedef struct _NDIS_LOG {
2456  PNDIS_MINIPORT_BLOCK Miniport;
2461  UINT InPtr;
2462  UINT OutPtr;
2463  UCHAR LogBuf[1];
2464 } NDIS_LOG, *PNDIS_LOG;
2465 
2466 #if ARCNET
2467 #define FILTERDBS_ARCNET_S \
2468  PARC_FILTER ArcDB;
2469 #else /* !ARCNET */
2470 #define FILTERDBS_ARCNET_S \
2471  PVOID XXXDB;
2472 #endif /* !ARCNET */
2473 
2474 #define FILTERDBS_S \
2475  _ANONYMOUS_UNION union { \
2476  PETH_FILTER EthDB; \
2477  PNULL_FILTER NullDB; \
2478  } DUMMYUNIONNAME; \
2479  PTR_FILTER TrDB; \
2480  PFDDI_FILTER FddiDB; \
2481  FILTERDBS_ARCNET_S
2482 
2483 typedef struct _FILTERDBS {
2484  FILTERDBS_S
2485 } FILTERDBS, *PFILTERDBS;
2486 
2489  PNDIS_MINIPORT_BLOCK NextMiniport;
2494  NDIS_HANDLE OpenQueue;
2496  NDIS_HANDLE DeviceContext;
2502  PNDIS_REQUEST MediaRequest;
2507  PNDIS_PACKET FirstPendingPacket;
2508  PNDIS_PACKET ReturnPacketsQueue;
2511  PNDIS_MINIPORT_BLOCK PrimaryMiniport;
2522  NDIS_STATUS ResetStatus;
2523  NDIS_HANDLE ResetOpen;
2524  FILTERDBS_S
2525  FILTER_PACKET_INDICATION_HANDLER PacketIndicateHandler;
2526  NDIS_M_SEND_COMPLETE_HANDLER SendCompleteHandler;
2527  NDIS_M_SEND_RESOURCES_HANDLER SendResourcesHandler;
2528  NDIS_M_RESET_COMPLETE_HANDLER ResetCompleteHandler;
2542  NDIS_STATUS FakeStatus;
2547  PNDIS_REQUEST PendingRequest;
2552  W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler;
2553  W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler;
2554  W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler;
2555  W_SEND_PACKETS_HANDLER SendPacketsHandler;
2556  NDIS_M_START_SENDS DeferredSendHandler;
2557  ETH_RCV_INDICATE_HANDLER EthRxIndicateHandler;
2558  TR_RCV_INDICATE_HANDLER TrRxIndicateHandler;
2559  FDDI_RCV_INDICATE_HANDLER FddiRxIndicateHandler;
2560  ETH_RCV_COMPLETE_HANDLER EthRxCompleteHandler;
2561  TR_RCV_COMPLETE_HANDLER TrRxCompleteHandler;
2562  FDDI_RCV_COMPLETE_HANDLER FddiRxCompleteHandler;
2563  NDIS_M_STATUS_HANDLER StatusHandler;
2564  NDIS_M_STS_COMPLETE_HANDLER StatusCompleteHandler;
2565  NDIS_M_TD_COMPLETE_HANDLER TDCompleteHandler;
2566  NDIS_M_REQ_COMPLETE_HANDLER QueryCompleteHandler;
2567  NDIS_M_REQ_COMPLETE_HANDLER SetCompleteHandler;
2569  WAN_RCV_HANDLER WanRcvHandler;
2570  WAN_RCV_COMPLETE_HANDLER WanRcvCompleteHandler;
2571 #if defined(NDIS_WRAPPER)
2572  PNDIS_MINIPORT_BLOCK NextGlobalMiniport;
2575  UCHAR SendFlags;
2576  UCHAR TrResetRing;
2577  UCHAR ArcnetAddress;
2578  UCHAR XState;
2579  _ANONYMOUS_UNION union {
2580 #if ARCNET
2581  PNDIS_ARC_BUF ArcBuf;
2582 #endif
2583  PVOID BusInterface;
2584  } DUMMYUNIONNAME;
2585  PNDIS_LOG Log;
2586  ULONG SlotNumber;
2589  SINGLE_LIST_ENTRY PatternList;
2590  NDIS_PNP_CAPABILITIES PMCapabilities;
2591  DEVICE_CAPABILITIES DeviceCaps;
2592  ULONG WakeUpEnable;
2593  DEVICE_POWER_STATE CurrentDevicePowerState;
2594  PIRP pIrpWaitWake;
2595  SYSTEM_POWER_STATE WaitWakeSystemState;
2596  LARGE_INTEGER VcIndex;
2597  KSPIN_LOCK VcCountLock;
2598  LIST_ENTRY WmiEnabledVcs;
2599  PNDIS_GUID pNdisGuidMap;
2600  PNDIS_GUID pCustomGuidMap;
2601  USHORT VcCount;
2602  USHORT cNdisGuidMap;
2603  USHORT cCustomGuidMap;
2604  USHORT CurrentMapRegister;
2605  PKEVENT AllocationEvent;
2606  USHORT BaseMapRegistersNeeded;
2607  USHORT SGMapRegistersNeeded;
2609  NDIS_TIMER MediaDisconnectTimer;
2610  USHORT MediaDisconnectTimeOut;
2611  USHORT InstanceNumber;
2612  NDIS_EVENT OpenReadyEvent;
2613  NDIS_PNP_DEVICE_STATE PnPDeviceState;
2614  NDIS_PNP_DEVICE_STATE OldPnPDeviceState;
2615  PGET_SET_DEVICE_DATA SetBusData;
2616  PGET_SET_DEVICE_DATA GetBusData;
2617  KDPC DeferredDpc;
2618 #if 0
2619  /* FIXME: */
2620  NDIS_STATS NdisStats;
2621 #else
2622  ULONG NdisStats;
2623 #endif
2624  PNDIS_PACKET IndicatedPacket[MAXIMUM_PROCESSORS];
2625  PKEVENT RemoveReadyEvent;
2626  PKEVENT AllOpensClosedEvent;
2627  PKEVENT AllRequestsCompletedEvent;
2628  ULONG InitTimeMs;
2630  PDMA_ADAPTER SystemAdapterObject;
2631  ULONG DriverVerifyFlags;
2632  POID_LIST OidList;
2633  USHORT InternalResetCount;
2634  USHORT MiniportResetCount;
2635  USHORT MediaSenseConnectCount;
2636  USHORT MediaSenseDisconnectCount;
2637  PNDIS_PACKET *xPackets;
2638  ULONG UserModeOpenReferences;
2639  _ANONYMOUS_UNION union {
2640  PVOID SavedSendHandler;
2641  PVOID SavedWanSendHandler;
2642  } DUMMYUNIONNAME2;
2643  PVOID SavedSendPacketsHandler;
2644  PVOID SavedCancelSendPacketsHandler;
2645  W_SEND_PACKETS_HANDLER WSendPacketsHandler;
2646  ULONG MiniportAttributes;
2647  PDMA_ADAPTER SavedSystemAdapterObject;
2648  USHORT NumOpens;
2649  USHORT CFHangXTicks;
2650  ULONG RequestCount;
2651  ULONG IndicatedPacketsCount;
2652  ULONG PhysicalMediumType;
2653  PNDIS_REQUEST LastRequest;
2654  LONG DmaAdapterRefCount;
2655  PVOID FakeMac;
2656  ULONG LockDbg;
2657  ULONG LockDbgX;
2658  PVOID LockThread;
2659  ULONG InfoFlags;
2660  KSPIN_LOCK TimerQueueLock;
2661  PKEVENT ResetCompletedEvent;
2662  PKEVENT QueuedBindingCompletedEvent;
2663  PKEVENT DmaResourcesReleasedEvent;
2664  FILTER_PACKET_INDICATION_HANDLER SavedPacketIndicateHandler;
2665  ULONG RegisteredInterrupts;
2666  PNPAGED_LOOKASIDE_LIST SGListLookasideList;
2667  ULONG ScatterGatherListSize;
2668 #endif /* _NDIS_ */
2669 };
2670 
2671 #if NDIS_LEGACY_DRIVER
2672 
2673 typedef NDIS_STATUS
2675  _In_ NDIS_HANDLE MacBindingHandle,
2676  _In_ NDIS_HANDLE LinkHandle,
2677  _In_ PVOID Packet);
2678 
2679 typedef VOID
2681  _In_ NDIS_HANDLE MiniportAdapterContext,
2682  _In_ PPNDIS_PACKET PacketArray,
2683  _In_ UINT NumberOfPackets);
2684 
2685 typedef NDIS_STATUS
2687  _In_ NDIS_HANDLE NdisBindingHandle,
2688  _In_ PNDIS_PACKET Packet);
2689 
2690 typedef NDIS_STATUS
2692  _In_ NDIS_HANDLE NdisBindingHandle,
2693  _In_ NDIS_HANDLE MacReceiveContext,
2694  _In_ UINT ByteOffset,
2695  _In_ UINT BytesToTransfer,
2696  _Out_ PNDIS_PACKET Packet,
2697  _Out_ PUINT BytesTransferred);
2698 
2699 typedef NDIS_STATUS
2701  _In_ NDIS_HANDLE NdisBindingHandle);
2702 
2703 typedef NDIS_STATUS
2705  _In_ NDIS_HANDLE NdisBindingHandle,
2706  _In_ PNDIS_REQUEST NdisRequest);
2707 
2708 #endif /* NDIS_LEGACY_DRIVER */
2709 
2710 #if defined(NDIS_WRAPPER)
2711 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S \
2712  ULONG Flags; \
2713  ULONG References; \
2714  KSPIN_LOCK SpinLock; \
2715  NDIS_HANDLE FilterHandle; \
2716  ULONG ProtocolOptions; \
2717  USHORT CurrentLookahead; \
2718  USHORT ConnectDampTicks; \
2719  USHORT DisconnectDampTicks; \
2720  W_SEND_HANDLER WSendHandler; \
2721  W_TRANSFER_DATA_HANDLER WTransferDataHandler; \
2722  W_SEND_PACKETS_HANDLER WSendPacketsHandler; \
2723  W_CANCEL_SEND_PACKETS_HANDLER CancelSendPacketsHandler; \
2724  ULONG WakeUpEnable; \
2725  PKEVENT CloseCompleteEvent; \
2726  QUEUED_CLOSE QC; \
2727  ULONG AfReferences; \
2728  PNDIS_OPEN_BLOCK NextGlobalOpen;
2729 #else
2730 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
2731 #endif
2732 
2733 #define NDIS_COMMON_OPEN_BLOCK_S \
2734  PVOID MacHandle; \
2735  NDIS_HANDLE BindingHandle; \
2736  PNDIS_MINIPORT_BLOCK MiniportHandle; \
2737  PNDIS_PROTOCOL_BLOCK ProtocolHandle; \
2738  NDIS_HANDLE ProtocolBindingContext; \
2739  PNDIS_OPEN_BLOCK MiniportNextOpen; \
2740  PNDIS_OPEN_BLOCK ProtocolNextOpen; \
2741  NDIS_HANDLE MiniportAdapterContext; \
2742  BOOLEAN Reserved1; \
2743  BOOLEAN Reserved2; \
2744  BOOLEAN Reserved3; \
2745  BOOLEAN Reserved4; \
2746  PNDIS_STRING BindDeviceName; \
2747  KSPIN_LOCK Reserved5; \
2748  PNDIS_STRING RootDeviceName; \
2749  _ANONYMOUS_UNION union { \
2750  SEND_HANDLER SendHandler; \
2751  WAN_SEND_HANDLER WanSendHandler; \
2752  } DUMMYUNIONNAME; \
2753  TRANSFER_DATA_HANDLER TransferDataHandler; \
2754  SEND_COMPLETE_HANDLER SendCompleteHandler; \
2755  TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler; \
2756  RECEIVE_HANDLER ReceiveHandler; \
2757  RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler; \
2758  WAN_RECEIVE_HANDLER WanReceiveHandler; \
2759  REQUEST_COMPLETE_HANDLER RequestCompleteHandler; \
2760  RECEIVE_PACKET_HANDLER ReceivePacketHandler; \
2761  SEND_PACKETS_HANDLER SendPacketsHandler; \
2762  RESET_HANDLER ResetHandler; \
2763  REQUEST_HANDLER RequestHandler; \
2764  RESET_COMPLETE_HANDLER ResetCompleteHandler; \
2765  STATUS_HANDLER StatusHandler; \
2766  STATUS_COMPLETE_HANDLER StatusCompleteHandler; \
2767  NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
2768 
2769 typedef struct _NDIS_COMMON_OPEN_BLOCK {
2772 
2774 {
2775 #ifdef __cplusplus
2776  NDIS_COMMON_OPEN_BLOCK NdisCommonOpenBlock;
2777 #else
2779 #endif
2780 };
2781 
2782 #include <xfilter.h>
2783 
2784 #define NDIS_M_MAX_LOOKAHEAD 526
2785 
2787 NDISAPI
2788 VOID
2789 NTAPI
2791  _Inout_ PNDIS_TIMER Timer,
2794 
2796 NDISAPI
2797 VOID
2798 NTAPI
2800  _In_ PNDIS_TIMER Timer,
2802 
2804 NDISAPI
2805 VOID
2806 NTAPI
2807 NdisSetTimer(
2808  _In_ PNDIS_TIMER Timer,
2810 
2811 NDISAPI
2812 VOID
2813 NTAPI
2815  _In_ PNDIS_TIMER NdisTimer,
2816  _In_ UINT MillisecondsPeriod);
2817 
2819 NDISAPI
2820 VOID
2821 NTAPI
2823  _In_ PNDIS_TIMER NdisTimer,
2824  _In_ UINT MillisecondsToDelay,
2825  _In_ PVOID FunctionContext);
2826 
2828 NDISAPI
2829 PVOID
2830 NTAPI
2832  _In_ PNDIS_STRING NdisRoutineName);
2833 
2835 NDISAPI
2836 UINT
2837 NTAPI
2839 
2840 #if NDIS_LEGACY_DRIVER
2841 
2843 NDISAPI
2844 VOID
2845 NTAPI
2847  _Out_ PNDIS_STATUS Status,
2848  _Out_ PNDIS_BUFFER *Buffer,
2849  _In_opt_ NDIS_HANDLE PoolHandle,
2851  _In_ UINT Length);
2852 
2854 NDISAPI
2855 VOID
2856 NTAPI
2858  _Out_ PNDIS_STATUS Status,
2859  _Out_ PNDIS_HANDLE PoolHandle,
2860  _In_ UINT NumberOfDescriptors);
2861 
2863 NDISAPI
2864 VOID
2865 NTAPI
2867  _In_ NDIS_HANDLE PoolHandle);
2868 
2869 /*
2870 NDISAPI
2871 VOID
2872 NTAPI
2873 NdisFreeBuffer(
2874  IN PNDIS_BUFFER Buffer);
2875 */
2876 #define NdisFreeBuffer IoFreeMdl
2877 
2879 NDISAPI
2880 VOID
2881 NTAPI
2883  _Out_ PNDIS_STATUS Status,
2884  _Out_ PNDIS_HANDLE PoolHandle,
2885  _In_ UINT NumberOfDescriptors,
2887 
2889 NDISAPI
2890 VOID
2891 NTAPI
2893  _Out_ PNDIS_STATUS Status,
2894  _Out_ PNDIS_HANDLE PoolHandle,
2895  _In_ UINT NumberOfDescriptors,
2897  _In_ UINT ProtocolReservedLength);
2898 
2900 NDISAPI
2901 VOID
2902 NTAPI
2904  _In_ NDIS_HANDLE PacketPoolHandle,
2906 
2908 NDISAPI
2909 UINT
2910 NTAPI
2912  _In_ NDIS_HANDLE PoolHandle);
2913 
2915 NDISAPI
2916 UINT
2917 NTAPI
2919  _In_ UINT ProtocolReservedSize);
2920 
2922 NDISAPI
2923 NDIS_HANDLE
2924 NTAPI
2926  _In_ PNDIS_PACKET Packet);
2927 
2929 NDISAPI
2930 PNDIS_PACKET_STACK
2931 NTAPI
2933  _In_ PNDIS_PACKET Packet,
2935 
2937 NDISAPI
2938 VOID
2939 NTAPI
2941  _In_ NDIS_HANDLE PoolHandle);
2942 
2944 NDISAPI
2945 VOID
2946 NTAPI
2948  _In_ PNDIS_PACKET Packet);
2949 
2951 NDISAPI
2952 VOID
2953 NTAPI
2955  _In_ PNDIS_PACKET Packet);
2956 
2958 NDISAPI
2959 VOID
2960 NTAPI
2962  _In_ PNDIS_PACKET Packet);
2963 
2965 NDISAPI
2966 VOID
2967 NTAPI
2969  _Out_ PNDIS_STATUS Status,
2970  _Out_ PNDIS_PACKET *Packet,
2971  _In_ NDIS_HANDLE PoolHandle);
2972 
2974 NDISAPI
2975 VOID
2976 NTAPI
2978  _Out_ PNDIS_STATUS Status,
2979  _Out_ PNDIS_PACKET *Packet,
2980  _In_ NDIS_HANDLE PoolHandle);
2981 
2983 NDISAPI
2984 VOID
2985 NTAPI
2987  _Out_ PNDIS_STATUS Status,
2988  _Out_ PNDIS_PACKET *Packet,
2989  _In_ NDIS_HANDLE PoolHandle);
2990 
2991 /*
2992  * VOID
2993  * NdisReinitializePacket(
2994  * IN OUT PNDIS_PACKET Packet);
2995  */
2996 #define NdisReinitializePacket(Packet) { \
2997  (Packet)->Private.Head = (PNDIS_BUFFER)NULL; \
2998  (Packet)->Private.ValidCounts = FALSE; \
2999 }
3000 
3001 /*
3002 NDISAPI
3003 VOID
3004 NTAPI
3005 NdisQueryBuffer(
3006  IN PNDIS_BUFFER Buffer,
3007  OUT PVOID *VirtualAddress OPTIONAL,
3008  OUT PUINT Length);
3009 */
3010 #define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length) { \
3011  if (ARGUMENT_PRESENT(_VirtualAddress)) { \
3012  *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdl(_Buffer); \
3013  } \
3014  *(_Length) = MmGetMdlByteCount(_Buffer); \
3015 }
3016 
3017 NDISAPI
3018 VOID
3019 NTAPI
3021  IN PNDIS_PACKET _Packet,
3022  OUT PNDIS_BUFFER *_FirstBuffer,
3023  OUT PVOID *_FirstBufferVA,
3024  OUT PUINT _FirstBufferLength,
3025  OUT PUINT _TotalBufferLength);
3026 
3027 /*
3028  * VOID
3029  * NdisGetFirstBufferFromPacketSafe(
3030  * IN PNDIS_PACKET _Packet,
3031  * OUT PNDIS_BUFFER * _FirstBuffer,
3032  * OUT PVOID * _FirstBufferVA,
3033  * OUT PUINT _FirstBufferLength,
3034  * OUT PUINT _TotalBufferLength),
3035  * IN MM_PAGE_PRIORITY _Priority)
3036  */
3037 #define NdisGetFirstBufferFromPacketSafe(_Packet, \
3038  _FirstBuffer, \
3039  _FirstBufferVA, \
3040  _FirstBufferLength, \
3041  _TotalBufferLength, \
3042  _Priority) \
3043 { \
3044  PNDIS_BUFFER _Buffer; \
3045  \
3046  _Buffer = (_Packet)->Private.Head; \
3047  *(_FirstBuffer) = _Buffer; \
3048  if (_Buffer != NULL) { \
3049  *(_FirstBufferVA) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
3050  *(_FirstBufferLength) = MmGetMdlByteCount(_Buffer); \
3051  _Buffer = _Buffer->Next; \
3052  *(_TotalBufferLength) = *(_FirstBufferLength); \
3053  while (_Buffer != NULL) { \
3054  *(_TotalBufferLength) += MmGetMdlByteCount(_Buffer); \
3055  _Buffer = _Buffer->Next; \
3056  } \
3057  } \
3058  else { \
3059  *(_FirstBufferVA) = 0; \
3060  *(_FirstBufferLength) = 0; \
3061  *(_TotalBufferLength) = 0; \
3062  } \
3063 }
3064 
3065 /*
3066  * VOID
3067  * NdisRecalculatePacketCounts(
3068  * IN OUT PNDIS_PACKET Packet);
3069  */
3070 #define NdisRecalculatePacketCounts(Packet) { \
3071  PNDIS_BUFFER _Buffer = (Packet)->Private.Head; \
3072  if (_Buffer != NULL) { \
3073  while (_Buffer->Next != NULL) { \
3074  _Buffer = _Buffer->Next; \
3075  } \
3076  (Packet)->Private.Tail = _Buffer; \
3077  } \
3078  (Packet)->Private.ValidCounts = FALSE; \
3079 }
3080 
3081 /*
3082  * VOID
3083  * NdisChainBufferAtFront(
3084  * IN OUT PNDIS_PACKET Packet,
3085  * IN OUT PNDIS_BUFFER Buffer)
3086  */
3087 #define NdisChainBufferAtFront(Packet, \
3088  Buffer) \
3089 { \
3090  PNDIS_BUFFER _NdisBuffer = (Buffer); \
3091  \
3092  while (_NdisBuffer->Next != NULL) \
3093  _NdisBuffer = _NdisBuffer->Next; \
3094  \
3095  if ((Packet)->Private.Head == NULL) \
3096  (Packet)->Private.Tail = _NdisBuffer; \
3097  \
3098  _NdisBuffer->Next = (Packet)->Private.Head; \
3099  (Packet)->Private.Head = (Buffer); \
3100  (Packet)->Private.ValidCounts = FALSE; \
3101 }
3102 
3103 /*
3104  * VOID
3105  * NdisChainBufferAtBack(
3106  * IN OUT PNDIS_PACKET Packet,
3107  * IN OUT PNDIS_BUFFER Buffer)
3108  */
3109 #define NdisChainBufferAtBack(Packet, \
3110  Buffer) \
3111 { \
3112  PNDIS_BUFFER _NdisBuffer = (Buffer); \
3113  \
3114  while (_NdisBuffer->Next != NULL) \
3115  _NdisBuffer = _NdisBuffer->Next; \
3116  \
3117  _NdisBuffer->Next = NULL; \
3118  \
3119  if ((Packet)->Private.Head != NULL) \
3120  (Packet)->Private.Tail->Next = (Buffer); \
3121  else \
3122  (Packet)->Private.Head = (Buffer); \
3123  \
3124  (Packet)->Private.Tail = _NdisBuffer; \
3125  (Packet)->Private.ValidCounts = FALSE; \
3126 }
3127 
3128 NDISAPI
3129 VOID
3130 NTAPI
3132  IN OUT PNDIS_PACKET Packet,
3133  OUT PNDIS_BUFFER *Buffer);
3134 
3135 NDISAPI
3136 VOID
3137 NTAPI
3139  IN OUT PNDIS_PACKET Packet,
3140  OUT PNDIS_BUFFER *Buffer);
3141 
3143 NDISAPI
3144 VOID
3145 NTAPI
3147  _In_ PNDIS_PACKET Destination,
3149  _In_ UINT BytesToCopy,
3150  _In_ PNDIS_PACKET Source,
3151  _In_ UINT SourceOffset,
3152  _Out_ PUINT BytesCopied);
3153 
3154 NDISAPI
3155 VOID
3156 NTAPI
3158  IN PNDIS_PACKET Destination,
3159  IN UINT DestinationOffset,
3160  IN UINT BytesToCopy,
3161  IN PNDIS_PACKET Source,
3162  IN UINT SourceOffset,
3163  OUT PUINT BytesCopied,
3165 
3168 NDISAPI
3169 NDIS_STATUS
3170 NTAPI
3172  _At_(*VirtualAddress, __drv_allocatesMem(Mem)) _Outptr_result_bytebuffer_(Length)
3173  PVOID *VirtualAddress,
3174  _In_ UINT Length,
3175  _In_ UINT MemoryFlags,
3177 
3178 #define NdisInitializeWorkItem(_WI_, _R_, _C_) { \
3179  (_WI_)->Context = _C_; \
3180  (_WI_)->Routine = _R_; \
3181 }
3182 
3184 NDISAPI
3185 NDIS_STATUS
3186 NTAPI
3189 
3191 NDISAPI
3192 VOID
3193 NTAPI
3195  _In_ PNDIS_PACKET Packet,
3196  _In_ NDIS_STATUS Status,
3197  _In_ NDIS_HANDLE Handle,
3198  _In_ ULONG Code);
3199 
3200 #endif /* NDIS_LEGACY_DRIVER */
3201 
3203 NDISAPI
3204 VOID
3205 NTAPI
3206 NdisOpenFile(
3207  _Out_ PNDIS_STATUS Status,
3208  _Out_ PNDIS_HANDLE FileHandle,
3209  _Out_ PUINT FileLength,
3210  _In_ PNDIS_STRING FileName,
3211  _In_ NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress);
3212 
3214 NDISAPI
3215 VOID
3216 NTAPI
3218  _In_ NDIS_HANDLE FileHandle);
3219 
3221 NDISAPI
3222 VOID
3223 NTAPI
3224 NdisMapFile(
3225  _Out_ PNDIS_STATUS Status,
3227  _In_ NDIS_HANDLE FileHandle);
3228 
3230 NDISAPI
3231 VOID
3232 NTAPI
3234  _In_ NDIS_HANDLE FileHandle);
3235 
3237 NDISAPI
3238 ULONG
3239 NTAPI
3241 
3242 #define NdisFlushBuffer(Buffer,WriteToDevice) \
3243  KeFlushIoBuffers((Buffer),!(WriteToDevice), TRUE)
3244 
3246 NDISAPI
3247 VOID
3248 NTAPI
3250  _Out_ PNDIS_STATUS Status,
3251  _Out_ PNDIS_BUFFER *Buffer,
3252  _In_ NDIS_HANDLE PoolHandle,
3254  _In_ UINT Offset,
3255  _In_ UINT Length);
3256 
3257 /*
3258  * VOID
3259  * NdisCopyLookaheadData(
3260  * IN PVOID Destination,
3261  * IN PVOID Source,
3262  * IN ULONG Length,
3263  * IN ULONG ReceiveFlags);
3264  */
3265 
3266 #if defined(_M_IX86) || defined(_M_AMD64)
3267 #define NdisCopyLookaheadData(Destination, Source, Length, MacOptions) \
3268  RtlCopyMemory(Destination, Source, Length)
3269 #else
3270 #define NdisCopyLookaheadData(Destination, Source, Length, MacOptions) \
3271  { \
3272  if ((MacOptions) & NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA) \
3273  { \
3274  RtlCopyMemory(Destination, Source, Length); \
3275  } \
3276  else \
3277  { \
3278  PUCHAR _Src = (PUCHAR)(Source); \
3279  PUCHAR _Dest = (PUCHAR)(Destination); \
3280  PUCHAR _End = _Dest + (Length); \
3281  while (_Dest < _End) \
3282  *_Dest++ = *_Src++; \
3283  } \
3284  }
3285 #endif
3286 
3287 /*
3288 NDISAPI
3289 VOID
3290 NTAPI
3291 NdisAdjustBufferLength(
3292  IN PNDIS_BUFFER Buffer,
3293  IN UINT Length);
3294 */
3295 #define NdisAdjustBufferLength(Buffer, Length) \
3296  (((Buffer)->ByteCount) = (Length))
3297 
3298 #if NDIS_SUPPORT_NDIS6
3299 #define NdisAdjustMdlLength(_Mdl, _Length) \
3300  (((_Mdl)->ByteCount) = (_Length))
3301 #endif
3302 
3303 /*
3304 NDISAPI
3305 ULONG
3306 NTAPI
3307 NdisBufferLength(
3308  IN PNDIS_BUFFER Buffer);
3309 */
3310 #define NdisBufferLength MmGetMdlByteCount
3311 
3312 /*
3313 NDISAPI
3314 PVOID
3315 NTAPI
3316 NdisBufferVirtualAddress(
3317  IN PNDIS_BUFFER Buffer);
3318 */
3319 #define NdisBufferVirtualAddress MmGetSystemAddressForMdl
3320 
3321 #define NdisBufferVirtualAddressSafe MmGetSystemAddressForMdlSafe
3322 
3323 NDISAPI
3324 ULONG
3325 NTAPI
3327  IN PNDIS_BUFFER Buffer);
3328 
3329 /*
3330 NDISAPI
3331 VOID
3332 NTAPI
3333 NdisGetBufferPhysicalArraySize(
3334  IN PNDIS_BUFFER Buffer,
3335  OUT PUINT ArraySize);
3336 */
3337 #define NdisGetBufferPhysicalArraySize(Buffer, ArraySize) \
3338  (*(ArraySize) = NDIS_BUFFER_TO_SPAN_PAGES(Buffer))
3339 
3340 /*
3341 NDISAPI
3342 VOID
3343 NTAPI
3344 NdisQueryBufferOffset(
3345  IN PNDIS_BUFFER Buffer,
3346  OUT PUINT Offset,
3347  OUT PUINT Length);
3348 */
3349 #define NdisQueryBufferOffset(_Buffer, _Offset, _Length) { \
3350  *(_Offset) = MmGetMdlByteOffset(_Buffer); \
3351  *(_Length) = MmGetMdlByteCount(_Buffer); \
3352 }
3353 
3354 /*
3355  * PVOID
3356  * NDIS_BUFFER_LINKAGE(
3357  * IN PNDIS_BUFFER Buffer);
3358  */
3359 #define NDIS_BUFFER_LINKAGE(Buffer) (Buffer)->Next
3360 
3361 /*
3362  * VOID
3363  * NdisGetNextBuffer(
3364  * IN PNDIS_BUFFER CurrentBuffer,
3365  * OUT PNDIS_BUFFER * NextBuffer)
3366  */
3367 #define NdisGetNextBuffer(CurrentBuffer, \
3368  NextBuffer) \
3369 { \
3370  *(NextBuffer) = (CurrentBuffer)->Next; \
3371 }
3372 
3373 #if NDIS_LEGACY_DRIVER
3374 
3375 #define NDIS_PACKET_FIRST_NDIS_BUFFER(_Packet) ((_Packet)->Private.Head)
3376 #define NDIS_PACKET_LAST_NDIS_BUFFER(_Packet) ((_Packet)->Private.Tail)
3377 #define NDIS_PACKET_VALID_COUNTS(_Packet) ((_Packet)->Private.ValidCounts)
3378 
3379 /*
3380  * UINT
3381  * NdisGetPacketFlags(
3382  * IN PNDIS_PACKET Packet);
3383  */
3384 #define NdisGetPacketFlags(Packet) (Packet)->Private.Flags
3385 
3386 /*
3387  * ULONG
3388  * NDIS_GET_PACKET_PROTOCOL_TYPE(
3389  * IN PNDIS_PACKET Packet);
3390  */
3391 #define NDIS_GET_PACKET_PROTOCOL_TYPE(_Packet) \
3392  ((_Packet)->Private.Flags & NDIS_PROTOCOL_ID_MASK)
3393 
3394 /*
3395  * PNDIS_PACKET_OOB_DATA
3396  * NDIS_OOB_DATA_FROM_PACKET(
3397  * IN PNDIS_PACKET Packet);
3398  */
3399 #define NDIS_OOB_DATA_FROM_PACKET(_Packet) \
3400  (PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3401  (_Packet)->Private.NdisPacketOobOffset)
3402 
3403 /*
3404  * ULONG
3405  * NDIS_GET_PACKET_HEADER_SIZE(
3406  * IN PNDIS_PACKET Packet);
3407  */
3408 #define NDIS_GET_PACKET_HEADER_SIZE(_Packet) \
3409  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3410  (_Packet)->Private.NdisPacketOobOffset))->HeaderSize
3411 
3412 /*
3413  * NDIS_STATUS
3414  * NDIS_GET_PACKET_STATUS(
3415  * IN PNDIS_PACKET Packet);
3416  */
3417 #define NDIS_GET_PACKET_STATUS(_Packet) \
3418  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3419  (_Packet)->Private.NdisPacketOobOffset))->Status
3420 
3421 /*
3422  * ULONGLONG
3423  * NDIS_GET_PACKET_TIME_TO_SEND(
3424  * IN PNDIS_PACKET Packet);
3425  */
3426 #define NDIS_GET_PACKET_TIME_TO_SEND(_Packet) \
3427  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3428  (_Packet)->Private.NdisPacketOobOffset))->TimeToSend
3429 
3430 /*
3431  * ULONGLONG
3432  * NDIS_GET_PACKET_TIME_SENT(
3433  * IN PNDIS_PACKET Packet);
3434  */
3435 #define NDIS_GET_PACKET_TIME_SENT(_Packet) \
3436  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3437  (_Packet)->Private.NdisPacketOobOffset))->TimeSent
3438 
3439 /*
3440  * ULONGLONG
3441  * NDIS_GET_PACKET_TIME_RECEIVED(
3442  * IN PNDIS_PACKET Packet);
3443  */
3444 #define NDIS_GET_PACKET_TIME_RECEIVED(_Packet) \
3445  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3446  (_Packet)->Private.NdisPacketOobOffset))->TimeReceived
3447 
3448 /*
3449  * VOID
3450  * NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(
3451  * IN PNDIS_PACKET Packet,
3452  * IN PPVOID pMediaSpecificInfo,
3453  * IN PUINT pSizeMediaSpecificInfo);
3454  */
3455 #define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
3456  _pMediaSpecificInfo, \
3457  _pSizeMediaSpecificInfo) \
3458 { \
3459  if (!((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) || \
3460  !((_Packet)->Private.NdisPacketFlags & fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO)) \
3461  { \
3462  *(_pMediaSpecificInfo) = NULL; \
3463  *(_pSizeMediaSpecificInfo) = 0; \
3464  } \
3465  else \
3466  { \
3467  *(_pMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3468  (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation; \
3469  *(_pSizeMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3470  (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo; \
3471  } \
3472 }
3473 
3474 /*
3475  * VOID
3476  * NDIS_SET_PACKET_HEADER_SIZE(
3477  * IN PNDIS_PACKET Packet,
3478  * IN UINT HdrSize);
3479  */
3480 #define NDIS_SET_PACKET_HEADER_SIZE(_Packet, _HdrSize) \
3481  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3482  (_Packet)->Private.NdisPacketOobOffset))->HeaderSize = (_HdrSize)
3483 
3484 /*
3485  * VOID
3486  * NDIS_SET_PACKET_STATUS(
3487  * IN PNDIS_PACKET Packet,
3488  * IN NDIS_STATUS Status);
3489  */
3490 #define NDIS_SET_PACKET_STATUS(_Packet, _Status) \
3491  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3492  (_Packet)->Private.NdisPacketOobOffset))->Status = (_Status)
3493 
3494 /*
3495  * VOID
3496  * NDIS_SET_PACKET_TIME_TO_SEND(
3497  * IN PNDIS_PACKET Packet,
3498  * IN ULONGLONG TimeToSend);
3499  */
3500 #define NDIS_SET_PACKET_TIME_TO_SEND(_Packet, _TimeToSend) \
3501  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3502  (_Packet)->Private.NdisPacketOobOffset))->TimeToSend = (_TimeToSend)
3503 
3504 /*
3505  * VOID
3506  * NDIS_SET_PACKET_TIME_SENT(
3507  * IN PNDIS_PACKET Packet,
3508  * IN ULONGLONG TimeSent);
3509  */
3510 #define NDIS_SET_PACKET_TIME_SENT(_Packet, _TimeSent) \
3511  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3512  (_Packet)->Private.NdisPacketOobOffset))->TimeSent = (_TimeSent)
3513 
3514 /*
3515  * VOID
3516  * NDIS_SET_PACKET_TIME_RECEIVED(
3517  * IN PNDIS_PACKET Packet,
3518  * IN ULONGLONG TimeReceived);
3519  */
3520 #define NDIS_SET_PACKET_TIME_RECEIVED(_Packet, _TimeReceived) \
3521  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3522  (_Packet)->Private.NdisPacketOobOffset))->TimeReceived = (_TimeReceived)
3523 
3524 /*
3525  * VOID
3526  * NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(
3527  * IN PNDIS_PACKET Packet,
3528  * IN PVOID MediaSpecificInfo,
3529  * IN UINT SizeMediaSpecificInfo);
3530  */
3531 #define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(_Packet, \
3532  _MediaSpecificInfo, \
3533  _SizeMediaSpecificInfo) \
3534 { \
3535  if ((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) \
3536  { \
3537  (_Packet)->Private.NdisPacketFlags |= fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO; \
3538  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3539  (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation = \
3540  (_MediaSpecificInfo); \
3541  ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3542  (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo = \
3543  (_SizeMediaSpecificInfo); \
3544  } \
3545 }
3546 
3547 /*
3548  * VOID
3549  * NdisSetPacketFlags(
3550  * IN PNDIS_PACKET Packet,
3551  * IN UINT Flags);
3552  */
3553 #define NdisSetPacketFlags(Packet, Flags) (Packet)->Private.Flags |= (Flags)
3554 
3555 /*
3556  * VOID
3557  * NdisClearPacketFlags(
3558  * IN PNDIS_PACKET Packet,
3559  * IN UINT Flags);
3560  */
3561 #define NdisClearPacketFlags(Packet, Flags) (Packet)->Private.Flags &= ~(Flags)
3562 
3563 /*
3564  * VOID
3565  * NdisQueryPacket(
3566  * IN PNDIS_PACKET Packet,
3567  * OUT PUINT PhysicalBufferCount OPTIONAL,
3568  * OUT PUINT BufferCount OPTIONAL,
3569  * OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3570  * OUT PUINT TotalPacketLength OPTIONAL);
3571  */
3572 static __inline
3573 VOID
3575  IN PNDIS_PACKET Packet,
3576  OUT PUINT PhysicalBufferCount OPTIONAL,
3577  OUT PUINT BufferCount OPTIONAL,
3578  OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3579  OUT PUINT TotalPacketLength OPTIONAL)
3580 {
3581  if (FirstBuffer)
3582  *FirstBuffer = Packet->Private.Head;
3583  if (TotalPacketLength || BufferCount || PhysicalBufferCount) {
3584  if (!Packet->Private.ValidCounts) {
3585  UINT Offset;
3586  UINT PacketLength;
3587  PNDIS_BUFFER NdisBuffer;
3588  UINT _PhysicalBufferCount = 0;
3589  UINT _TotalPacketLength = 0;
3590  UINT Count = 0;
3591 
3592  for (NdisBuffer = Packet->Private.Head;
3593  NdisBuffer != (PNDIS_BUFFER)NULL;
3594  NdisBuffer = NdisBuffer->Next) {
3595  _PhysicalBufferCount += NDIS_BUFFER_TO_SPAN_PAGES(NdisBuffer);
3596  NdisQueryBufferOffset(NdisBuffer, &Offset, &PacketLength);
3597  _TotalPacketLength += PacketLength;
3598  Count++;
3599  }
3600  Packet->Private.PhysicalCount = _PhysicalBufferCount;
3601  Packet->Private.TotalLength = _TotalPacketLength;
3602  Packet->Private.Count = Count;
3603  Packet->Private.ValidCounts = TRUE;
3604  }
3605 
3606  if (PhysicalBufferCount)
3607  *PhysicalBufferCount = Packet->Private.PhysicalCount;
3608 
3609  if (BufferCount)
3610  *BufferCount = Packet->Private.Count;
3611 
3612  if (TotalPacketLength)
3613  *TotalPacketLength = Packet->Private.TotalLength;
3614  }
3615 }
3616 
3617 /*
3618  * VOID
3619  * NdisQueryPacketLength(
3620  * IN PNDIS_PACKET Packet,
3621  * OUT PUINT PhysicalBufferCount OPTIONAL,
3622  * OUT PUINT BufferCount OPTIONAL,
3623  * OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3624  * OUT PUINT TotalPacketLength OPTIONAL);
3625  */
3626 #define NdisQueryPacketLength(_Packet, \
3627  _TotalPacketLength) \
3628 { \
3629  if (!(_Packet)->Private.ValidCounts) { \
3630  NdisQueryPacket(_Packet, NULL, NULL, NULL, _TotalPacketLength); \
3631  } \
3632  else *(_TotalPacketLength) = (_Packet)->Private.TotalLength; \
3633 }
3634 
3635 #endif /* NDIS_LEGACY_DRIVER */
3636 
3637 /* Memory management routines */
3638 
3639 /*
3640 NDISAPI
3641 VOID
3642 NTAPI
3643 NdisCreateLookaheadBufferFromSharedMemory(
3644  IN PVOID pSharedMemory,
3645  IN UINT LookaheadLength,
3646  OUT PVOID *pLookaheadBuffer);
3647 */
3648 #define NdisCreateLookaheadBufferFromSharedMemory(_S, _L, _B) ((*(_B)) = (_S))
3649 
3650 NDISAPI
3651 VOID
3652 NTAPI
3654  IN PVOID pLookaheadBuffer);
3655 
3656 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_PPC)
3657 
3658 /*
3659  * VOID
3660  * NdisMoveMappedMemory(
3661  * OUT PVOID Destination,
3662  * IN PVOID Source,
3663  * IN ULONG Length);
3664  */
3665 #define NdisMoveMappedMemory(Destination, Source, Length) \
3666  RtlCopyMemory(Destination, Source, Length)
3667 
3668 /*
3669  * VOID
3670  * NdisZeroMappedMemory(
3671  * IN PVOID Destination,
3672  * IN ULONG Length);
3673  */
3674 #define NdisZeroMappedMemory(Destination, Length) \
3675  RtlZeroMemory(Destination, Length)
3676 
3677 #else
3678 
3679 #define NdisMoveMappedMemory(Destination, Source, Length) \
3680 { \
3681  PUCHAR _Dest = Destination, _Src = Source, _End = _Dest + Length; \
3682  while (_Dest < _End) \
3683  *_Dest++ = _Src++; \
3684 }
3685 
3686 #define NdisZeroMappedMemory(Destination, Length) \
3687 { \
3688  PUCHAR _Dest = Destination, _End = _Dest + Length; \
3689  while (_Dest < _End) \
3690  *_Dest++ = 0; \
3691 }
3692 
3693 #endif /* _M_IX86 or _M_AMD64 */
3694 
3695 /*
3696  * VOID
3697  * NdisMoveFromMappedMemory(
3698  * OUT PVOID Destination,
3699  * IN PVOID Source,
3700  * IN ULONG Length);
3701  */
3702 #define NdisMoveFromMappedMemory(Destination, Source, Length) \
3703  NdisMoveMappedMemory(Destination, Source, Length)
3704 
3705 /*
3706  * VOID
3707  * NdisMoveToMappedMemory(
3708  * OUT PVOID Destination,
3709  * IN PVOID Source,
3710  * IN ULONG Length);
3711  */
3712 #define NdisMoveToMappedMemory(Destination, Source, Length) \
3713  NdisMoveMappedMemory(Destination, Source, Length)
3714 
3715 /*
3716  * VOID
3717  * NdisMUpdateSharedMemory(
3718  * IN NDIS_HANDLE MiniportAdapterHandle,
3719  * IN ULONG Length,
3720  * IN PVOID VirtualAddress,
3721  * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
3722  */
3723 #define NdisMUpdateSharedMemory(_H, _L, _V, _P) \
3724  NdisUpdateSharedMemory(_H, _L, _V, _P)
3725 
3726 _When_(MemoryFlags==0, _IRQL_requires_max_(DISPATCH_LEVEL))
3729 NDISAPI
3730 VOID
3731 NTAPI
3733  _In_reads_bytes_(Length) __drv_freesMem(Mem) PVOID VirtualAddress,
3734  _In_ UINT Length,
3735  _In_ _Pre_satisfies_(MemoryFlags == 0 || MemoryFlags == NDIS_MEMORY_NONCACHED || MemoryFlags == NDIS_MEMORY_CONTIGUOUS)
3736  UINT MemoryFlags);
3737 
3738 NDISAPI
3739 VOID
3740 NTAPI
3742  IN PVOID VirtualAddress,
3743  IN ULONG Tag);
3744 
3745 NDISAPI
3746 VOID
3747 NTAPI
3749  IN NDIS_HANDLE WrapperConfigurationContext,
3750  IN ULONG SharedMemoryAddress,
3751  OUT PUCHAR Buffer,
3752  IN ULONG Length);
3753 
3754 NDISAPI
3755 VOID
3756 NTAPI
3758  IN NDIS_HANDLE WrapperConfigurationContext,
3759  IN ULONG SharedMemoryAddress,
3760  IN PUCHAR Buffer,
3761  IN ULONG Length);
3762 
3764 NDISAPI
3765 VOID
3766 NTAPI
3768  _In_ NDIS_HANDLE MiniportAdapterHandle,
3769  _In_ ULONG Length,
3771  _Outptr_result_bytebuffer_(Length) _At_(*VirtualAddress, _Must_inspect_result_)
3772  PVOID *VirtualAddress,
3774  PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
3775 
3777 NDISAPI
3778 NDIS_STATUS
3779 NTAPI
3781  _In_ NDIS_HANDLE MiniportAdapterHandle,
3782  _In_ ULONG Length,
3783  _In_ BOOLEAN Cached,
3784  _In_ PVOID Context);
3785 
3786 #if defined(NDIS50)
3787 
3788 #define NdisUpdateSharedMemory(NdisAdapterHandle, \
3789  Length, \
3790  VirtualAddress, \
3791  PhysicalAddress)
3792 
3793 #else
3794 
3795 NDISAPI
3796 VOID
3797 NTAPI
3799  IN NDIS_HANDLE NdisAdapterHandle,
3800  IN ULONG Length,
3801  IN PVOID VirtualAddress,
3802  IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
3803 
3804 #endif /* defined(NDIS50) */
3805 
3806 /*
3807  * ULONG
3808  * NdisGetPhysicalAddressHigh(
3809  * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
3810  */
3811 #define NdisGetPhysicalAddressHigh(PhysicalAddress) \
3812  ((PhysicalAddress).HighPart)
3813 
3814 /*
3815  * VOID
3816  * NdisSetPhysicalAddressHigh(
3817  * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
3818  * IN ULONG Value);
3819  */
3820 #define NdisSetPhysicalAddressHigh(PhysicalAddress, Value) \
3821  ((PhysicalAddress).HighPart) = (Value)
3822 
3823 /*
3824  * ULONG
3825  * NdisGetPhysicalAddressLow(
3826  * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress);
3827  */
3828 #define NdisGetPhysicalAddressLow(PhysicalAddress) \
3829  ((PhysicalAddress).LowPart)
3830 
3831 
3832 /*
3833  * VOID
3834  * NdisSetPhysicalAddressLow(
3835  * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress,
3836  * IN ULONG Value);
3837  */
3838 #define NdisSetPhysicalAddressLow(PhysicalAddress, Value) \
3839  ((PhysicalAddress).LowPart) = (Value)
3840 
3841 /*
3842  * VOID
3843  * NDIS_PHYSICAL_ADDRESS_CONST(
3844  * IN ULONG Low,
3845  * IN LONG High);
3846  */
3847 #define NDIS_PHYSICAL_ADDRESS_CONST(Low, High) \
3848  { {(ULONG)(Low), (LONG)(High)} }
3849 
3850 /*
3851  * ULONG
3852  * NdisEqualMemory(
3853  * IN CONST VOID *Source1,
3854  * IN CONST VOID *Source2,
3855  * IN ULONG Length);
3856  */
3857 #define NdisEqualMemory(Source1, Source2, Length) \
3858  RtlEqualMemory(Source1, Source2, Length)
3859 
3860 /*
3861  * VOID
3862  * NdisFillMemory(
3863  * IN PVOID Destination,
3864  * IN ULONG Length,
3865  * IN UCHAR Fill);
3866  */
3867 #define NdisFillMemory(Destination, Length, Fill) \
3868  RtlFillMemory(Destination, Length, Fill)
3869 
3870 /*
3871  * VOID
3872  * NdisMoveMemory(
3873  * OUT PVOID Destination,
3874  * IN PVOID Source,
3875  * IN ULONG Length);
3876  */
3877 #define NdisMoveMemory(Destination, Source, Length) \
3878  RtlCopyMemory(Destination, Source, Length)
3879 
3880 
3881 /*
3882  * VOID
3883  * NdisRetrieveUlong(
3884  * IN PULONG DestinationAddress,
3885  * IN PULONG SourceAddress);
3886  */
3887 #define NdisRetrieveUlong(DestinationAddress, SourceAddress) \
3888  RtlRetrieveUlong(DestinationAddress, SourceAddress)
3889 
3890 
3891 /*
3892  * VOID
3893  * NdisStoreUlong(
3894  * IN PULONG DestinationAddress,
3895  * IN ULONG Value);
3896  */
3897 #define NdisStoreUlong(DestinationAddress, Value) \
3898  RtlStoreUlong(DestinationAddress, Value)
3899 
3900 
3901 /*
3902  * VOID
3903  * NdisZeroMemory(
3904  * IN PVOID Destination,
3905  * IN ULONG Length)
3906  */
3907 #define NdisZeroMemory(Destination, Length) \
3908  RtlZeroMemory(Destination, Length)
3909 
3910 typedef VOID
3911 (NTAPI *NDIS_BLOCK_INITIALIZER) (
3912  IN PUCHAR Block,
3914  );
3915 
3916 /* Configuration routines */
3917 
3918 #if NDIS_LEGACY_DRIVER
3920 _Success_(*Status >= 0)
3921 NDISAPI
3922 VOID
3923 NTAPI
3925  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
3926  _Out_ PNDIS_HANDLE ConfigurationHandle,
3927  _In_ NDIS_HANDLE WrapperConfigurationContext);
3928 #endif
3929 
3931 _Success_(*Status >= 0)
3932 NDISAPI
3933 VOID
3934 NTAPI
3936  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
3939  _Out_ PUINT NetworkAddressLength,
3940  _In_ NDIS_HANDLE ConfigurationHandle);
3941 
3942 NDISAPI
3943 VOID
3944 NTAPI
3946  OUT PNDIS_STATUS Status,
3947  IN NDIS_HANDLE WrapperConfigurationContext,
3948  OUT PUINT SlotNumber,
3949  OUT PNDIS_EISA_FUNCTION_INFORMATION EisaData);
3950 
3951 NDISAPI
3952 VOID
3953 NTAPI
3955  OUT PNDIS_STATUS Status,
3956  IN NDIS_HANDLE WrapperConfigurationContext,
3957  OUT PUINT SlotNumber,
3958  OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData,
3959  OUT PUINT NumberOfFunctions);
3960 
3961 #if NDIS_LEGACY_MINIPORT
3962 
3964 NDISAPI
3965 ULONG
3966 NTAPI
3968  _In_ NDIS_HANDLE NdisAdapterHandle,
3969  _In_ ULONG SlotNumber,
3970  _In_ ULONG Offset,
3971  _Out_writes_bytes_(Length) PVOID Buffer,
3972  _In_ ULONG Length);
3973 
3975 NDISAPI
3976 ULONG
3977 NTAPI
3979  _In_ NDIS_HANDLE NdisAdapterHandle,
3980  _In_ ULONG SlotNumber,
3981  _In_ ULONG Offset,
3982  _In_reads_bytes_(Length) PVOID Buffer,
3983  _In_ ULONG Length);
3984 
3986 NDISAPI
3987 ULONG
3988 NTAPI
3990  _In_ NDIS_HANDLE NdisAdapterHandle,
3991  _In_ ULONG Offset,
3992  _Out_writes_bytes_(Length) PVOID Buffer,
3993  _In_ ULONG Length);
3994 
3996 NDISAPI
3997 ULONG
3998 NTAPI
4000  _In_ NDIS_HANDLE NdisAdapterHandle,
4001  _In_ ULONG Offset,
4002  _In_reads_bytes_(Length) PVOID Buffer,
4003  _In_ ULONG Length);
4004 
4005 #endif /* NDIS_LEGACY_MINIPORT */
4006 
4007 /* String management routines */
4008 
4009 /*
4010 NDISAPI
4011 NDIS_STATUS
4012 NTAPI
4013 NdisAnsiStringToUnicodeString(
4014  IN OUT PNDIS_STRING DestinationString,
4015  IN PNDIS_ANSI_STRING SourceString);
4016 */
4017 #define NdisAnsiStringToUnicodeString(_us, _as) RtlAnsiStringToUnicodeString(_us, _as, FALSE)
4018 
4019 /*
4020  * BOOLEAN
4021  * NdisEqualString(
4022  * IN PNDIS_STRING String1,
4023  * IN PNDIS_STRING String2,
4024  * IN BOOLEAN CaseInsensitive);
4025  */
4026 #define NdisEqualString RtlEqualString
4027 
4028 #define NdisEqualUnicodeString RtlEqualUnicodeString
4029 
4030 /*
4031 NDISAPI
4032 VOID
4033 NTAPI
4034 NdisInitAnsiString(
4035  IN OUT PNDIS_ANSI_STRING DestinationString,
4036  IN PCSTR SourceString);
4037 */
4038 #define NdisInitAnsiString RtlInitString
4039 
4040 NDISAPI
4041 VOID
4042 NTAPI
4044  IN OUT PNDIS_STRING DestinationString,
4046 
4047 /*
4048 NDISAPI
4049 NDIS_STATUS
4050 NTAPI
4051 NdisUnicodeStringToAnsiString(
4052  IN OUT PNDIS_ANSI_STRING DestinationString,
4053  IN PNDIS_STRING SourceString);
4054 */
4055 #define NdisUnicodeStringToAnsiString(_as, _us) RtlUnicodeStringToAnsiString(_as, _us, FALSE)
4056 
4057 #define NdisFreeString(_s) NdisFreeMemory((_s).Buffer, (_s).MaximumLength, 0)
4058 #define NdisPrintString(_s) DbgPrint("%ls", (_s).Buffer)
4059 
4060 /* Spin lock reoutines */
4061 
4062 /*
4063 NDISAPI
4064 VOID
4065 NTAPI
4066 NdisAllocateSpinLock(
4067  IN PNDIS_SPIN_LOCK SpinLock);
4068 */
4069 #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
4070 
4071 /*
4072 NDISAPI
4073 VOID
4074 NTAPI
4075 NdisFreeSpinLock(
4076  IN PNDIS_SPIN_LOCK SpinLock);
4077 */
4078 #define NdisFreeSpinLock(_SpinLock)
4079 
4080 /*
4081 NDISAPI
4082 VOID
4083 NTAPI
4084 NdisAcquireSpinLock(
4085  IN PNDIS_SPIN_LOCK SpinLock);
4086 */
4087 #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
4088 
4089 /*
4090 NDISAPI
4091 VOID
4092 NTAPI
4093 NdisReleaseSpinLock(
4094  IN PNDIS_SPIN_LOCK SpinLock);
4095 */
4096 #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
4097 
4098 /*
4099 NDISAPI
4100 VOID
4101 NTAPI
4102 NdisDprAcquireSpinLock(
4103  IN PNDIS_SPIN_LOCK SpinLock);
4104 */
4105 #define NdisDprAcquireSpinLock(_SpinLock) KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock)
4106 
4107 /*
4108 NDISAPI
4109 VOID
4110 NTAPI
4111 NdisDprReleaseSpinLock(
4112  IN PNDIS_SPIN_LOCK SpinLock);
4113 */
4114 #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
4115 
4116 /* I/O routines */
4117 
4118 /*
4119  * VOID
4120  * NdisRawReadPortBufferUchar(
4121  * IN ULONG Port,
4122  * OUT PUCHAR Buffer,
4123  * IN ULONG Length);
4124  */
4125 #define NdisRawReadPortBufferUchar(Port, Buffer, Length) \
4126  READ_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length))
4127 
4128 /*
4129  * VOID
4130  * NdisRawReadPortBufferUlong(
4131  * IN ULONG Port,
4132  * OUT PULONG Buffer,
4133  * IN ULONG Length);
4134  */
4135 #define NdisRawReadPortBufferUlong(Port, Buffer, Length) \
4136  READ_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length))
4137 
4138 /*
4139  * VOID
4140  * NdisRawReadPortBufferUshort(
4141  * IN ULONG Port,
4142  * OUT PUSHORT Buffer,
4143  * IN ULONG Length);
4144  */
4145 #define NdisRawReadPortBufferUshort(Port, Buffer, Length) \
4146  READ_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length))
4147 
4148 /*
4149  * VOID
4150  * NdisRawReadPortUchar(
4151  * IN ULONG Port,
4152  * OUT PUCHAR Data);
4153  */
4154 #define NdisRawReadPortUchar(Port, Data) \
4155  *(Data) = READ_PORT_UCHAR((PUCHAR)(Port))
4156 
4157 /*
4158  * VOID
4159  * NdisRawReadPortUlong(
4160  * IN ULONG Port,
4161  * OUT PULONG Data);
4162  */
4163 #define NdisRawReadPortUlong(Port, Data) \
4164  *(Data) = READ_PORT_ULONG((PULONG)(Port))
4165 
4166 /*
4167  * VOID
4168  * NdisRawReadPortUshort(
4169  * IN ULONG Port,
4170  * OUT PUSHORT Data);
4171  */
4172 #define NdisRawReadPortUshort(Port, Data) \
4173  *(Data) = READ_PORT_USHORT((PUSHORT)(Port))
4174 
4175 /*
4176  * VOID
4177  * NdisRawWritePortBufferUchar(
4178  * IN ULONG Port,
4179  * IN PUCHAR Buffer,
4180  * IN ULONG Length);
4181  */
4182 #define NdisRawWritePortBufferUchar(Port, Buffer, Length) \
4183  WRITE_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length))
4184 
4185 /*
4186  * VOID
4187  * NdisRawWritePortBufferUlong(
4188  * IN ULONG Port,
4189  * IN PULONG Buffer,
4190  * IN ULONG Length);
4191  */
4192 #define NdisRawWritePortBufferUlong(Port, Buffer, Length) \
4193  WRITE_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length))
4194 
4195 /*
4196  * VOID
4197  * NdisRawWritePortBufferUshort(
4198  * IN ULONG Port,
4199  * IN PUSHORT Buffer,
4200  * IN ULONG Length);
4201  */
4202 #define NdisRawWritePortBufferUshort(Port, Buffer, Length) \
4203  WRITE_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length))
4204 
4205 /*
4206  * VOID
4207  * NdisRawWritePortUchar(
4208  * IN ULONG Port,
4209  * IN UCHAR Data);
4210  */
4211 #define NdisRawWritePortUchar(Port, Data) \
4212  WRITE_PORT_UCHAR((PUCHAR)(Port), (UCHAR)(Data))
4213 
4214 /*
4215  * VOID
4216  * NdisRawWritePortUlong(
4217  * IN ULONG Port,
4218  * IN ULONG Data);
4219  */
4220 #define NdisRawWritePortUlong(Port, Data) \
4221  WRITE_PORT_ULONG((PULONG)(Port), (ULONG)(Data))
4222 
4223 /*
4224  * VOID
4225  * NdisRawWritePortUshort(
4226  * IN ULONG Port,
4227  * IN USHORT Data);
4228  */
4229 #define NdisRawWritePortUshort(Port, Data) \
4230  WRITE_PORT_USHORT((PUSHORT)(Port), (USHORT)(Data))
4231 
4232 
4233 /*
4234  * VOID
4235  * NdisReadRegisterUchar(
4236  * IN PUCHAR Register,
4237  * OUT PUCHAR Data);
4238  */
4239 #define NdisReadRegisterUchar(Register, Data) \
4240  *(Data) = *(Register)
4241 
4242 /*
4243  * VOID
4244  * NdisReadRegisterUlong(
4245  * IN PULONG Register,
4246  * OUT PULONG Data);
4247  */
4248 #define NdisReadRegisterUlong(Register, Data) \
4249  *(Data) = *(Register)
4250 
4251 /*
4252  * VOID
4253  * NdisReadRegisterUshort(
4254  * IN PUSHORT Register,
4255  * OUT PUSHORT Data);
4256  */
4257 #define NdisReadRegisterUshort(Register, Data) \
4258  *(Data) = *(Register)
4259 
4260 /*
4261  * VOID
4262  * NdisReadRegisterUchar(
4263  * IN PUCHAR Register,
4264  * IN UCHAR Data);
4265  */
4266 #define NdisWriteRegisterUchar(Register, Data) \
4267  WRITE_REGISTER_UCHAR((Register), (Data))
4268 
4269 /*
4270  * VOID
4271  * NdisReadRegisterUlong(
4272  * IN PULONG Register,
4273  * IN ULONG Data);
4274  */
4275 #define NdisWriteRegisterUlong(Register, Data) \
4276  WRITE_REGISTER_ULONG((Register), (Data))
4277 
4278 /*
4279  * VOID
4280  * NdisReadRegisterUshort(
4281  * IN PUSHORT Register,
4282  * IN USHORT Data);
4283  */
4284 #define NdisWriteRegisterUshort(Register, Data) \
4285  WRITE_REGISTER_USHORT((Register), (Data))
4286 
4287 
4288 /* Linked lists */
4289 
4290 /*
4291  * VOID
4292  * NdisInitializeListHead(
4293  * IN PLIST_ENTRY ListHead);
4294  */
4295 #define NdisInitializeListHead InitializeListHead
4296 
4297 /*
4298  * PLIST_ENTRY
4299  * NdisInterlockedInsertHeadList(
4300  * IN PLIST_ENTRY ListHead,
4301  * IN PLIST_ENTRY ListEntry,
4302  * IN PNDIS_SPIN_LOCK SpinLock);
4303  */
4304 #define NdisInterlockedInsertHeadList(_ListHead, _ListEntry, _SpinLock) \
4305  ExInterlockedInsertHeadList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
4306 
4307 /*
4308  * PLIST_ENTRY
4309  * NdisInterlockedInsertTailList(
4310  * IN PLIST_ENTRY ListHead,
4311  * IN PLIST_ENTRY ListEntry,
4312  * IN PNDIS_SPIN_LOCK SpinLock);
4313  */
4314 #define NdisInterlockedInsertTailList(_ListHead, _ListEntry, _SpinLock) \
4315  ExInterlockedInsertTailList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
4316 
4317 /*
4318  * PLIST_ENTRY
4319  * NdisInterlockedRemoveHeadList(
4320  * IN PLIST_ENTRY ListHead,
4321  * IN PNDIS_SPIN_LOCK SpinLock);
4322 */
4323 #define NdisInterlockedRemoveHeadList(_ListHead, _SpinLock) \
4324  ExInterlockedRemoveHeadList(_ListHead, &(_SpinLock)->SpinLock)
4325 
4326 /*
4327  * VOID
4328  * NdisInitializeSListHead(
4329  * IN PSLIST_HEADER SListHead);
4330  */
4331 #define NdisInitializeSListHead(SListHead) ExInitializeSListHead(SListHead)
4332 
4333 /*
4334  * USHORT NdisQueryDepthSList(
4335  * IN PSLIST_HEADER SListHead);
4336  */
4337 #define NdisQueryDepthSList(SListHead) ExQueryDepthSList(SListHead)
4338 
4339 #define NdisInterlockedPushEntryList(ListHead, ListEntry, Lock) \
4340  ExInterlockedPushEntryList(ListHead, ListEntry, &(Lock)->SpinLock)
4341 
4342 #define NdisInterlockedPopEntryList(ListHead, Lock) \
4343  ExInterlockedPopEntryList(ListHead, &(Lock)->SpinLock)
4344 
4345 /* Non-paged lookaside lists */
4346 
4347 #define NdisInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D) \
4348  ExInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D)
4349 #define NdisDeleteNPagedLookasideList(_L) ExDeleteNPagedLookasideList(_L)
4350 #define NdisAllocateFromNPagedLookasideList(_L) ExAllocateFromNPagedLookasideList(_L)
4351 #define NdisFreeToNPagedLookasideList(_L, _E) ExFreeToNPagedLookasideList(_L, _E)
4352 
4353 /* Interlocked routines */
4354 
4355 /*
4356  * LONG
4357  * NdisInterlockedDecrement(
4358  * IN PLONG Addend);
4359  */
4360 #define NdisInterlockedDecrement(Addend) InterlockedDecrement(Addend)
4361 
4362 /*
4363  * LONG
4364  * NdisInterlockedIncrement(
4365  * IN PLONG Addend);
4366  */
4367 #define NdisInterlockedIncrement(Addend) InterlockedIncrement(Addend)
4368 
4369 /*
4370  * VOID
4371  * NdisInterlockedAddUlong(
4372  * IN PULONG Addend,
4373  * IN ULONG Increment,
4374  * IN PNDIS_SPIN_LOCK SpinLock);
4375  */
4376 #define NdisInterlockedAddUlong(_Addend, _Increment, _SpinLock) \
4377  ExInterlockedAddUlong(_Addend, _Increment, &(_SpinLock)->SpinLock)
4378 
4379 /* Miscellaneous routines */
4380 
4382 NDISAPI
4383 VOID
4384 NTAPI
4386  _In_ __drv_freesMem(mem) NDIS_HANDLE ConfigurationHandle);
4387 
4389 _Success_(*Status >= 0)
4390 NDISAPI
4391 VOID
4392 NTAPI
4394  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4396  _In_ NDIS_HANDLE ConfigurationHandle,
4397  _In_ PNDIS_STRING Keyword,
4399 
4401 _Success_(*Status >= 0)
4402 NDISAPI
4403 VOID
4404 NTAPI
4406  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4407  _In_ NDIS_HANDLE WrapperConfigurationContext,
4408  _In_ PNDIS_STRING Keyword,
4409  _In_ PNDIS_CONFIGURATION_PARAMETER ParameterValue);
4410 
4412 NDISAPI
4413 VOID
4414 __cdecl
4416  _In_ NDIS_HANDLE NdisAdapterHandle,
4419  ...);
4420 
4422 NDISAPI
4423 VOID
4424 NTAPI
4426  _Out_ _At_(Destination->Buffer, __drv_allocatesMem(Mem)) PNDIS_STRING Destination,
4427  _In_opt_z_ PUCHAR Source);
4428 
4429 /*
4430  * VOID
4431  * NdisStallExecution(
4432  * IN UINT MicrosecondsToStall)
4433  */
4434 #define NdisStallExecution KeStallExecutionProcessor
4435 
4436 /*
4437 NDISAPI
4438 VOID
4439 NTAPI
4440 NdisGetCurrentSystemTime(
4441  IN PLARGE_INTEGER pSystemTime);
4442 */
4443 #define NdisGetCurrentSystemTime KeQuerySystemTime
4444 
4445 #if NDIS_SUPPORT_60_COMPATIBLE_API
4447 NDISAPI
4448 CCHAR
4449 NTAPI
4451 #endif
4452 
4453 NDISAPI
4454 VOID
4455 NTAPI
4457  OUT PULONG pCpuUsage);
4458 
4459 /* NDIS helper macros */
4460 
4461 /*
4462  * VOID
4463  * NDIS_INIT_FUNCTION(FunctionName)
4464  */
4465 #define NDIS_INIT_FUNCTION(FunctionName) \
4466  alloc_text(init, FunctionName)
4467 
4468 /*
4469  * VOID
4470  * NDIS_PAGABLE_FUNCTION(FunctionName)
4471  */
4472 #define NDIS_PAGEABLE_FUNCTION(FunctionName) \
4473  alloc_text(page, FunctionName)
4474 
4475 #define NDIS_PAGABLE_FUNCTION NDIS_PAGEABLE_FUNCTION
4476 
4477 
4478 /* NDIS 4.0 extensions */
4479 
4481 NDISAPI
4482 VOID
4483 NTAPI
4485  _In_ NDIS_HANDLE MiniportAdapterHandle,
4486  _In_ ULONG Length,
4487  _In_ BOOLEAN Cached,
4488  _In_reads_bytes_(Length) PVOID VirtualAddress,
4489  _In_ NDIS_PHYSICAL_ADDRESS PhysicalAddress);
4490 
4491 NDISAPI
4492 VOID
4493 NTAPI
4495  OUT PNDIS_STATUS Status,
4496  IN NDIS_HANDLE MiniportAdapterHandle,
4497  IN NDIS_HANDLE NdisLinkContext,
4498  IN PUCHAR PacketBuffer,
4499  IN UINT PacketSize);
4500 
4501 NDISAPI
4502 VOID
4503 NTAPI
4505  IN NDIS_HANDLE MiniportAdapterHandle,
4506  IN NDIS_HANDLE NdisLinkContext);
4507 
4508 NDISAPI
4509 VOID
4510 NTAPI
4512  IN NDIS_HANDLE MiniportAdapterHandle,
4513  IN PNDIS_WAN_PACKET Packet,
4514  IN NDIS_STATUS Status);
4515 
4516 NDISAPI
4517 NDIS_STATUS
4518 NTAPI
4520  IN NDIS_HANDLE NdisMacHandle,
4521  IN NDIS_HANDLE NdisWrapperHandle,
4522  IN NDIS_HANDLE WrapperConfigurationContext,
4523  IN ULONG SlotNumber,
4524  OUT PNDIS_RESOURCE_LIST *AssignedResources);
4525 
4526 
4527 /* NDIS 5.0 extensions */
4528 
4530 NDISAPI
4531 NDIS_STATUS
4532 NTAPI
4533 NdisAllocateMemoryWithTag(
4534  _At_(*VirtualAddress, __drv_allocatesMem(Mem)) _Outptr_result_bytebuffer_(Length)
4535  PVOID *VirtualAddress,
4536  _In_ UINT Length,
4537  _In_ ULONG Tag);
4538 
4540 NDISAPI
4541 VOID
4542 NTAPI
4544  _Out_ PULONG pIdleCount,
4546  _Out_ PULONG pIndex);
4547 
4548 #if NDIS_LEGACY_DRIVER
4549 NDISAPI
4550 VOID
4551 NTAPI
4553  OUT PULONG pSystemUpTime);
4554 #endif
4555 
4556 #if NDIS_SUPPORT_60_COMPATIBLE_API
4557 
4562 NDISAPI
4563 VOID
4564 NTAPI
4566  _Inout_ PNDIS_RW_LOCK Lock,
4567  _In_ BOOLEAN fWrite,
4568  _Out_ _IRQL_saves_ PLOCK_STATE LockState);
4569 
4571 NDISAPI
4572 VOID
4573 NTAPI
4575  _Out_ PNDIS_RW_LOCK Lock);
4576 
4578 _Requires_lock_held_(*Lock)
4579 _Releases_lock_(*Lock)
4580 NDISAPI
4581 VOID
4582 NTAPI
4584  _Inout_ PNDIS_RW_LOCK Lock,
4585  _In_ _IRQL_restores_ PLOCK_STATE LockState);
4586 
4587 #if NDIS_SUPPORT_NDIS6
4588 
4589 NDISAPI
4590 VOID
4591 NTAPI
4592 NdisDprAcquireReadWriteLock(
4593  IN PNDIS_RW_LOCK Lock,
4594  IN BOOLEAN fWrite,
4595  IN PLOCK_STATE LockState);
4596 
4597 NDISAPI
4598 VOID
4599 NTAPI
4600 NdisDprReleaseReadWriteLock(
4601  IN PNDIS_RW_LOCK Lock,
4602  IN PLOCK_STATE LockState);
4603 
4604 #endif /* NDIS_SUPPORT_NDIS6 */
4605 
4606 #endif /* NDIS_SUPPORT_60_COMPATIBLE_API */
4607 
4609 NDISAPI
4610 NDIS_STATUS
4611 NTAPI
4613  _In_ NDIS_HANDLE NdisDeviceHandle);
4614 
4616 NDISAPI
4617 VOID
4618 NTAPI
4620  _In_ NDIS_HANDLE MiniportAdapterHandle,
4626 
4628 NDISAPI
4629 NDIS_STATUS
4630 NTAPI
4632  _In_ NDIS_HANDLE MiniportAdapterHandle,
4635 
4637 NDISAPI
4638 NDIS_STATUS
4639 NTAPI
4641  _In_ NDIS_HANDLE MiniportAdapterHandle);
4642 
4644 NDISAPI
4645 NDIS_STATUS
4646 NTAPI
4648  _Out_ PNDIS_STRING AdapterInstanceName,
4649  _In_ NDIS_HANDLE MiniportAdapterHandle);
4650 
4652 NDISAPI
4653 NDIS_STATUS
4654 NTAPI
4656  _In_ NDIS_HANDLE NdisWrapperHandle,
4657  _In_ PNDIS_STRING DeviceName,
4658  _In_ PNDIS_STRING SymbolicName,
4659  _In_reads_(IRP_MJ_PNP) PDRIVER_DISPATCH *MajorFunctions,
4661  _Out_ NDIS_HANDLE *NdisDeviceHandle);
4662 
4664 NDISAPI
4665 VOID
4666 NTAPI
4668  _In_ NDIS_HANDLE NdisWrapperHandle,
4670 
4672 NDISAPI
4673 NDIS_STATUS
4674 NTAPI
4676  _In_ NDIS_HANDLE MiniportAdapterHandle);
4677 
4679 NDISAPI
4680 NDIS_STATUS
4681 NTAPI
4683  _In_ NDIS_HANDLE MiniportAdapterHandle,
4685 
4687 _Success_(*Status >= 0)
4688 NDISAPI
4689 VOID
4690 NTAPI
4692  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4693  _In_ NDIS_HANDLE ConfigurationHandle,
4694  _In_ ULONG Index,
4695  _Out_ PNDIS_STRING KeyName,
4696  _Out_ PNDIS_HANDLE KeyHandle);
4697 
4699 _Success_(*Status >= 0)
4700 NDISAPI
4701 VOID
4702 NTAPI
4704  _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4705  _In_ NDIS_HANDLE ConfigurationHandle,
4706  _In_ PNDIS_STRING SubKeyName,
4707  _Out_ PNDIS_HANDLE SubKeyHandle);
4708 
4711 NDISAPI
4712 NDIS_STATUS
4713 NTAPI
4715  _Out_ PNDIS_STRING AdapterInstanceName,
4716  _In_ NDIS_HANDLE NdisBindingHandle);
4717 
4719 NDISAPI
4720 NDIS_STATUS
4721 NTAPI
4723  _Out_ PNDIS_STRING pAdapterInstanceName,
4724  _In_ NDIS_HANDLE BindingContext);
4725 
4727 NDISAPI
4728 NDIS_STATUS
4729 NTAPI
4732  _In_ NDIS_STATUS EventCode,
4737  _In_reads_bytes_opt_(DataSize) PVOID Data);
4738 
4739 /* Connectionless services */
4740 
4743 NDISAPI
4744 NDIS_STATUS
4745 NTAPI
4747