xref: /reactos/sdk/include/ddk/ndis.h (revision aad80191)
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 
45 typedef _Return_type_success_(return >= 0) int NDIS_STATUS, *PNDIS_STATUS;
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 {
63   NetDeviceStateUnspecified = 0,
64   NetDeviceStateD0,
65   NetDeviceStateD1,
66   NetDeviceStateD2,
67   NetDeviceStateD3,
68   NetDeviceStateMaximum
69 } NET_DEVICE_POWER_STATE, *PNET_DEVICE_POWER_STATE;
70 
71 typedef enum _NET_PNP_EVENT_CODE {
72   NetEventSetPower,
73   NetEventQueryPower,
74   NetEventQueryRemoveDevice,
75   NetEventCancelRemoveDevice,
76   NetEventReconfigure,
77   NetEventBindList,
78   NetEventBindsComplete,
79   NetEventPnPCapabilities,
80   NetEventPause,
81   NetEventRestart,
82   NetEventPortActivation,
83   NetEventPortDeactivation,
84   NetEventIMReEnableDevice,
85   NetEventMaximum
86 } NET_PNP_EVENT_CODE, *PNET_PNP_EVENT_CODE;
87 
88 typedef struct _NET_PNP_EVENT {
89   NET_PNP_EVENT_CODE NetEvent;
90   PVOID Buffer;
91   ULONG BufferLength;
92   ULONG_PTR NdisReserved[4];
93   ULONG_PTR TransportReserved[4];
94   ULONG_PTR TdiReserved[4];
95   ULONG_PTR TdiClientReserved[4];
96 } NET_PNP_EVENT, *PNET_PNP_EVENT;
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 
319 typedef struct _NDIS_MINIPORT_BLOCK NDIS_MINIPORT_BLOCK, *PNDIS_MINIPORT_BLOCK;
320 
321 typedef struct _REFERENCE {
322   KSPIN_LOCK SpinLock;
323   USHORT ReferenceCount;
324   BOOLEAN Closing;
325 } REFERENCE, *PREFERENCE;
326 
327 /* NDIS base types */
328 
329 typedef struct _NDIS_SPIN_LOCK {
330   KSPIN_LOCK SpinLock;
331   KIRQL OldIrql;
332 } NDIS_SPIN_LOCK, *PNDIS_SPIN_LOCK;
333 
334 typedef struct _NDIS_EVENT {
335   KEVENT Event;
336 } NDIS_EVENT, *PNDIS_EVENT;
337 
338 typedef PVOID NDIS_HANDLE, *PNDIS_HANDLE;
339 
340 typedef ANSI_STRING NDIS_ANSI_STRING, *PNDIS_ANSI_STRING;
341 typedef UNICODE_STRING NDIS_STRING, *PNDIS_STRING;
342 
343 typedef MDL NDIS_BUFFER, *PNDIS_BUFFER;
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 #define NDIS_STATUS_HOST_UNREACHABLE            ((NDIS_STATUS)STATUS_HOST_UNREACHABLE)
513 
514 #if NDIS_SUPPORT_NDIS6
515 
516 #define NDIS_STATUS_SEND_ABORTED                ((NDIS_STATUS)STATUS_NDIS_REQUEST_ABORTED)
517 #define NDIS_STATUS_PAUSED                      ((NDIS_STATUS)STATUS_NDIS_PAUSED)
518 #define NDIS_STATUS_INTERFACE_NOT_FOUND         ((NDIS_STATUS)STATUS_NDIS_INTERFACE_NOT_FOUND)
519 #define NDIS_STATUS_INVALID_PARAMETER           ((NDIS_STATUS)STATUS_INVALID_PARAMETER)
520 #define NDIS_STATUS_UNSUPPORTED_REVISION        ((NDIS_STATUS)STATUS_NDIS_UNSUPPORTED_REVISION)
521 #define NDIS_STATUS_INVALID_PORT                ((NDIS_STATUS)STATUS_NDIS_INVALID_PORT)
522 #define NDIS_STATUS_INVALID_PORT_STATE          ((NDIS_STATUS)STATUS_NDIS_INVALID_PORT_STATE)
523 #define NDIS_STATUS_INVALID_STATE               ((NDIS_STATUS)STATUS_INVALID_DEVICE_STATE)
524 #define NDIS_STATUS_MEDIA_DISCONNECTED          ((NDIS_STATUS)STATUS_NDIS_MEDIA_DISCONNECTED)
525 #define NDIS_STATUS_LOW_POWER_STATE             ((NDIS_STATUS)STATUS_NDIS_LOW_POWER_STATE)
526 #define NDIS_STATUS_DOT11_AUTO_CONFIG_ENABLED   ((NDIS_STATUS)STATUS_NDIS_DOT11_AUTO_CONFIG_ENABLED)
527 #define NDIS_STATUS_DOT11_MEDIA_IN_USE          ((NDIS_STATUS)STATUS_NDIS_DOT11_MEDIA_IN_USE)
528 #define NDIS_STATUS_DOT11_POWER_STATE_INVALID   ((NDIS_STATUS)STATUS_NDIS_DOT11_POWER_STATE_INVALID)
529 #define NDIS_STATUS_UPLOAD_IN_PROGRESS          ((NDIS_STATUS)0xC0231001L)
530 #define NDIS_STATUS_REQUEST_UPLOAD              ((NDIS_STATUS)0xC0231002L)
531 #define NDIS_STATUS_UPLOAD_REQUESTED            ((NDIS_STATUS)0xC0231003L)
532 #define NDIS_STATUS_OFFLOAD_TCP_ENTRIES         ((NDIS_STATUS)0xC0231004L)
533 #define NDIS_STATUS_OFFLOAD_PATH_ENTRIES        ((NDIS_STATUS)0xC0231005L)
534 #define NDIS_STATUS_OFFLOAD_NEIGHBOR_ENTRIES    ((NDIS_STATUS)0xC0231006L)
535 #define NDIS_STATUS_OFFLOAD_IP_ADDRESS_ENTRIES  ((NDIS_STATUS)0xC0231007L)
536 #define NDIS_STATUS_OFFLOAD_HW_ADDRESS_ENTRIES  ((NDIS_STATUS)0xC0231008L)
537 #define NDIS_STATUS_OFFLOAD_VLAN_ENTRIES        ((NDIS_STATUS)0xC0231009L)
538 #define NDIS_STATUS_OFFLOAD_TCP_XMIT_BUFFER     ((NDIS_STATUS)0xC023100AL)
539 #define NDIS_STATUS_OFFLOAD_TCP_RCV_BUFFER      ((NDIS_STATUS)0xC023100BL)
540 #define NDIS_STATUS_OFFLOAD_TCP_RCV_WINDOW      ((NDIS_STATUS)0xC023100CL)
541 #define NDIS_STATUS_OFFLOAD_VLAN_MISMATCH       ((NDIS_STATUS)0xC023100DL)
542 #define NDIS_STATUS_OFFLOAD_DATA_NOT_ACCEPTED   ((NDIS_STATUS)0xC023100EL)
543 #define NDIS_STATUS_OFFLOAD_POLICY              ((NDIS_STATUS)0xC023100FL)
544 #define NDIS_STATUS_OFFLOAD_DATA_PARTIALLY_ACCEPTED ((NDIS_STATUS)0xC0231010L)
545 #define NDIS_STATUS_OFFLOAD_REQUEST_RESET       ((NDIS_STATUS)0xC0231011L)
546 
547 #if NDIS_SUPPORT_NDIS620
548 #define NDIS_STATUS_PM_WOL_PATTERN_LIST_FULL    ((NDIS_STATUS)STATUS_NDIS_PM_WOL_PATTERN_LIST_FULL)
549 #define NDIS_STATUS_PM_PROTOCOL_OFFLOAD_LIST_FULL ((NDIS_STATUS)STATUS_NDIS_PM_PROTOCOL_OFFLOAD_LIST_FULL)
550 #endif
551 
552 #endif /* NDIS_SUPPORT_NDIS6 */
553 
554 #if (NDIS_SUPPORT_NDIS620)
555 #define NDIS_STATUS_OFFLOAD_CONNECTION_REJECTED ((NDIS_STATUS)STATUS_NDIS_OFFLOAD_CONNECTION_REJECTED)
556 #endif
557 
558 /* NDIS error codes for error logging */
559 
560 #define NDIS_ERROR_CODE ULONG
561 
562 #define NDIS_ERROR_CODE_RESOURCE_CONFLICT               EVENT_NDIS_RESOURCE_CONFLICT
563 #define NDIS_ERROR_CODE_OUT_OF_RESOURCES                EVENT_NDIS_OUT_OF_RESOURCE
564 #define NDIS_ERROR_CODE_HARDWARE_FAILURE                EVENT_NDIS_HARDWARE_FAILURE
565 #define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND               EVENT_NDIS_ADAPTER_NOT_FOUND
566 #define NDIS_ERROR_CODE_INTERRUPT_CONNECT               EVENT_NDIS_INTERRUPT_CONNECT
567 #define NDIS_ERROR_CODE_DRIVER_FAILURE                  EVENT_NDIS_DRIVER_FAILURE
568 #define NDIS_ERROR_CODE_BAD_VERSION                     EVENT_NDIS_BAD_VERSION
569 #define NDIS_ERROR_CODE_TIMEOUT                         EVENT_NDIS_TIMEOUT
570 #define NDIS_ERROR_CODE_NETWORK_ADDRESS                 EVENT_NDIS_NETWORK_ADDRESS
571 #define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION       EVENT_NDIS_UNSUPPORTED_CONFIGURATION
572 #define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER      EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER
573 #define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER
574 #define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS             EVENT_NDIS_BAD_IO_BASE_ADDRESS
575 #define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL             EVENT_NDIS_RECEIVE_SPACE_SMALL
576 #define NDIS_ERROR_CODE_ADAPTER_DISABLED                EVENT_NDIS_ADAPTER_DISABLED
577 
578 /* Memory allocation flags. Used by Ndis[Allocate|Free]Memory */
579 #define NDIS_MEMORY_CONTIGUOUS            0x00000001
580 #define NDIS_MEMORY_NONCACHED             0x00000002
581 
582 /* NIC attribute flags. Used by NdisMSetAttributes(Ex) */
583 #define	NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT    0x00000001
584 #define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT   0x00000002
585 #define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS 0x00000004
586 #define NDIS_ATTRIBUTE_BUS_MASTER               0x00000008
587 #define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER      0x00000010
588 #define NDIS_ATTRIBUTE_DESERIALIZE              0x00000020
589 #define NDIS_ATTRIBUTE_NO_HALT_ON_SUSPEND       0x00000040
590 #define NDIS_ATTRIBUTE_SURPRISE_REMOVE_OK       0x00000080
591 #define NDIS_ATTRIBUTE_NOT_CO_NDIS              0x00000100
592 #define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS    0x00000200
593 
594 /* Lock */
595 
596 #if NDIS_SUPPORT_60_COMPATIBLE_API
597 
598 typedef union _NDIS_RW_LOCK_REFCOUNT {
599   UINT RefCount;
600   UCHAR cacheLine[16];
601 } NDIS_RW_LOCK_REFCOUNT;
602 
603 typedef struct _NDIS_RW_LOCK {
604   __MINGW_EXTENSION union {
605     __MINGW_EXTENSION struct {
606       KSPIN_LOCK SpinLock;
607       PVOID Context;
608     };
609     UCHAR Reserved[16];
610   };
611   __MINGW_EXTENSION union {
612     NDIS_RW_LOCK_REFCOUNT RefCount[MAXIMUM_PROCESSORS];
613     ULONG RefCountEx[sizeof(NDIS_RW_LOCK_REFCOUNT)/sizeof(ULONG) * MAXIMUM_PROCESSORS];
614     __MINGW_EXTENSION struct {
615       KSPIN_LOCK RefCountLock;
616       volatile ULONG SharedRefCount;
617       volatile BOOLEAN WriterWaiting;
618     };
619   };
620 } NDIS_RW_LOCK, *PNDIS_RW_LOCK;
621 
622 typedef struct _LOCK_STATE {
623   USHORT LockState;
624   KIRQL OldIrql;
625 } LOCK_STATE, *PLOCK_STATE;
626 
627 #endif /* NDIS_SUPPORT_60_COMPATIBLE_API */
628 
629 /* Timer */
630 
631 _IRQL_requires_(DISPATCH_LEVEL)
632 _IRQL_requires_same_
633 _Function_class_(NDIS_TIMER_FUNCTION)
634 typedef VOID
635 (NTAPI NDIS_TIMER_FUNCTION)(
636   _In_ PVOID SystemSpecific1,
637   _In_ PVOID FunctionContext,
638   _In_ PVOID SystemSpecific2,
639   _In_ PVOID SystemSpecific3);
640 typedef NDIS_TIMER_FUNCTION *PNDIS_TIMER_FUNCTION;
641 
642 typedef struct _NDIS_TIMER {
643   KTIMER Timer;
644   KDPC Dpc;
645 } NDIS_TIMER, *PNDIS_TIMER;
646 
647 /* Hardware */
648 
649 typedef CM_MCA_POS_DATA NDIS_MCA_POS_DATA, *PNDIS_MCA_POS_DATA;
650 typedef CM_EISA_SLOT_INFORMATION NDIS_EISA_SLOT_INFORMATION, *PNDIS_EISA_SLOT_INFORMATION;
651 typedef CM_EISA_FUNCTION_INFORMATION NDIS_EISA_FUNCTION_INFORMATION, *PNDIS_EISA_FUNCTION_INFORMATION;
652 typedef CM_PARTIAL_RESOURCE_LIST NDIS_RESOURCE_LIST, *PNDIS_RESOURCE_LIST;
653 
654 /* Flag bits */
655 #define	READABLE_LOCAL_CLOCK                    0x00000001
656 #define	CLOCK_NETWORK_DERIVED                   0x00000002
657 #define	CLOCK_PRECISION                         0x00000004
658 #define	RECEIVE_TIME_INDICATION_CAPABLE         0x00000008
659 #define	TIMED_SEND_CAPABLE                      0x00000010
660 #define	TIME_STAMP_CAPABLE                      0x00000020
661 
662 /* NDIS packet filter bits (OID_GEN_CURRENT_PACKET_FILTER) */
663 #define NDIS_PACKET_TYPE_DIRECTED               0x00000001
664 #define NDIS_PACKET_TYPE_MULTICAST              0x00000002
665 #define NDIS_PACKET_TYPE_ALL_MULTICAST          0x00000004
666 #define NDIS_PACKET_TYPE_BROADCAST              0x00000008
667 #define NDIS_PACKET_TYPE_SOURCE_ROUTING         0x00000010
668 #define NDIS_PACKET_TYPE_PROMISCUOUS            0x00000020
669 #define NDIS_PACKET_TYPE_SMT                    0x00000040
670 #define NDIS_PACKET_TYPE_ALL_LOCAL              0x00000080
671 #define NDIS_PACKET_TYPE_GROUP                  0x00001000
672 #define NDIS_PACKET_TYPE_ALL_FUNCTIONAL         0x00002000
673 #define NDIS_PACKET_TYPE_FUNCTIONAL             0x00004000
674 #define NDIS_PACKET_TYPE_MAC_FRAME              0x00008000
675 
676 /* NDIS protocol option bits (OID_GEN_PROTOCOL_OPTIONS) */
677 #define NDIS_PROT_OPTION_ESTIMATED_LENGTH       0x00000001
678 #define NDIS_PROT_OPTION_NO_LOOPBACK            0x00000002
679 #define NDIS_PROT_OPTION_NO_RSVD_ON_RCVPKT      0x00000004
680 
681 /* NDIS MAC option bits (OID_GEN_MAC_OPTIONS) */
682 #define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA     0x00000001
683 #define NDIS_MAC_OPTION_RECEIVE_SERIALIZED      0x00000002
684 #define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND      0x00000004
685 #define NDIS_MAC_OPTION_NO_LOOPBACK             0x00000008
686 #define NDIS_MAC_OPTION_FULL_DUPLEX             0x00000010
687 #define	NDIS_MAC_OPTION_EOTX_INDICATION         0x00000020
688 #define	NDIS_MAC_OPTION_8021P_PRIORITY          0x00000040
689 #define NDIS_MAC_OPTION_RESERVED                0x80000000
690 
691 #define	NDIS_GUID_TO_OID                  0x00000001
692 #define	NDIS_GUID_TO_STATUS               0x00000002
693 #define	NDIS_GUID_ANSI_STRING             0x00000004
694 #define	NDIS_GUID_UNICODE_STRING          0x00000008
695 #define	NDIS_GUID_ARRAY                   0x00000010
696 
697 #if NDIS_LEGACY_DRIVER
698 
699 /* NDIS_PACKET_PRIVATE.Flags constants */
700 #define fPACKET_WRAPPER_RESERVED             0x3f
701 #define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40
702 #define fPACKET_ALLOCATED_BY_NDIS            0x80
703 
704 #define NDIS_FLAGS_PROTOCOL_ID_MASK          0x0000000f
705 #define NDIS_FLAGS_MULTICAST_PACKET          0x00000010
706 #define NDIS_FLAGS_RESERVED2                 0x00000020
707 #define NDIS_FLAGS_RESERVED3                 0x00000040
708 #define NDIS_FLAGS_DONT_LOOPBACK             0x00000080
709 #define NDIS_FLAGS_IS_LOOPBACK_PACKET        0x00000100
710 #define NDIS_FLAGS_LOOPBACK_ONLY             0x00000200
711 #define NDIS_FLAGS_RESERVED4                 0x00000400
712 #define NDIS_FLAGS_DOUBLE_BUFFERED           0x00000800
713 #define NDIS_FLAGS_SENT_AT_DPC               0x00001000
714 #define NDIS_FLAGS_USES_SG_BUFFER_LIST       0x00002000
715 #define NDIS_FLAGS_USES_ORIGINAL_PACKET      0x00004000
716 #define NDIS_FLAGS_PADDED                    0x00010000
717 #define NDIS_FLAGS_XLATE_AT_TOP              0x00020000
718 
719 typedef NDIS_HANDLE PNDIS_PACKET_POOL;
720 
721 typedef struct _NDIS_PACKET_PRIVATE {
722   UINT PhysicalCount;
723   UINT TotalLength;
724   PNDIS_BUFFER Head;
725   PNDIS_BUFFER Tail;
726   PNDIS_PACKET_POOL Pool;
727   UINT Count;
728   ULONG Flags;
729   BOOLEAN ValidCounts;
730   UCHAR NdisPacketFlags;
731   USHORT NdisPacketOobOffset;
732 } NDIS_PACKET_PRIVATE, *PNDIS_PACKET_PRIVATE;
733 
734 typedef struct _NDIS_PACKET {
735   NDIS_PACKET_PRIVATE Private;
736   __MINGW_EXTENSION union {
737     __MINGW_EXTENSION struct {
738       UCHAR MiniportReserved[2 * sizeof(PVOID)];
739       UCHAR WrapperReserved[2 * sizeof(PVOID)];
740     };
741     __MINGW_EXTENSION struct {
742       UCHAR MiniportReservedEx[3 * sizeof(PVOID)];
743       UCHAR WrapperReservedEx[sizeof(PVOID)];
744     };
745     __MINGW_EXTENSION struct {
746       UCHAR MacReserved[4 * sizeof(PVOID)];
747     };
748   };
749   ULONG_PTR Reserved[2];
750   UCHAR ProtocolReserved[1];
751 } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
752 
753 typedef struct _NDIS_PACKET_STACK {
754   ULONG_PTR IMReserved[2];
755   ULONG_PTR NdisReserved[4];
756 } NDIS_PACKET_STACK, *PNDIS_PACKET_STACK;
757 
758 #endif /* NDIS_LEGACY_DRIVER */
759 
760 typedef enum _NDIS_CLASS_ID {
761   NdisClass802_3Priority,
762   NdisClassWirelessWanMbxMailbox,
763   NdisClassIrdaPacketInfo,
764   NdisClassAtmAALInfo
765 } NDIS_CLASS_ID;
766 
767 typedef struct _MEDIA_SPECIFIC_INFORMATION {
768   UINT NextEntryOffset;
769   NDIS_CLASS_ID ClassId;
770   UINT Size;
771   UCHAR ClassInformation[1];
772 } MEDIA_SPECIFIC_INFORMATION, *PMEDIA_SPECIFIC_INFORMATION;
773 
774 #if NDIS_LEGACY_DRIVER
775 typedef struct _NDIS_PACKET_OOB_DATA {
776   __MINGW_EXTENSION union {
777     ULONGLONG TimeToSend;
778     ULONGLONG TimeSent;
779   };
780   ULONGLONG TimeReceived;
781   UINT HeaderSize;
782   UINT SizeMediaSpecificInfo;
783   PVOID MediaSpecificInformation;
784   NDIS_STATUS Status;
785 } NDIS_PACKET_OOB_DATA, *PNDIS_PACKET_OOB_DATA;
786 #endif
787 
788 /* Request types used by NdisRequest */
789 typedef enum _NDIS_REQUEST_TYPE {
790   NdisRequestQueryInformation,
791   NdisRequestSetInformation,
792   NdisRequestQueryStatistics,
793   NdisRequestOpen,
794   NdisRequestClose,
795   NdisRequestSend,
796   NdisRequestTransferData,
797   NdisRequestReset,
798   NdisRequestGeneric1,
799   NdisRequestGeneric2,
800   NdisRequestGeneric3,
801   NdisRequestGeneric4,
802 #if NDIS_SUPPORT_NDIS6
803   NdisRequestMethod,
804 #endif
805 } NDIS_REQUEST_TYPE, *PNDIS_REQUEST_TYPE;
806 
807 #if NDIS_LEGACY_DRIVER
808 typedef struct _NDIS_REQUEST {
809   UCHAR MacReserved[4 * sizeof(PVOID)];
810   NDIS_REQUEST_TYPE RequestType;
811   union _DATA {
812     struct QUERY_INFORMATION {
813       NDIS_OID Oid;
814       PVOID InformationBuffer;
815       UINT InformationBufferLength;
816       UINT BytesWritten;
817       UINT BytesNeeded;
818     } QUERY_INFORMATION;
819     struct SET_INFORMATION {
820       NDIS_OID Oid;
821       PVOID InformationBuffer;
822       UINT InformationBufferLength;
823       UINT BytesRead;
824       UINT BytesNeeded;
825     } SET_INFORMATION;
826  } DATA;
827 #if (defined(NDIS50) || defined(NDIS51) || defined(NDIS50_MINIPORT) || defined(NDIS51_MINIPORT))
828   UCHAR NdisReserved[9 * sizeof(PVOID)];
829   __MINGW_EXTENSION union {
830     UCHAR CallMgrReserved[2 * sizeof(PVOID)];
831     UCHAR ProtocolReserved[2 * sizeof(PVOID)];
832   };
833   UCHAR MiniportReserved[2 * sizeof(PVOID)];
834 #endif
835 } NDIS_REQUEST, *PNDIS_REQUEST;
836 #endif /* NDIS_LEGACY_DRIVER */
837 
838 /* Wide Area Networks definitions */
839 
840 #if NDIS_LEGACY_DRIVER
841 typedef struct _NDIS_WAN_PACKET {
842   LIST_ENTRY WanPacketQueue;
843   PUCHAR CurrentBuffer;
844   ULONG CurrentLength;
845   PUCHAR StartBuffer;
846   PUCHAR EndBuffer;
847   PVOID ProtocolReserved1;
848   PVOID ProtocolReserved2;
849   PVOID ProtocolReserved3;
850   PVOID ProtocolReserved4;
851   PVOID MacReserved1;
852   PVOID MacReserved2;
853   PVOID MacReserved3;
854   PVOID MacReserved4;
855 } NDIS_WAN_PACKET, *PNDIS_WAN_PACKET;
856 #endif
857 
858 /* DMA channel information */
859 
860 typedef struct _NDIS_DMA_DESCRIPTION {
861   BOOLEAN  DemandMode;
862   BOOLEAN  AutoInitialize;
863   BOOLEAN  DmaChannelSpecified;
864   DMA_WIDTH  DmaWidth;
865   DMA_SPEED  DmaSpeed;
866   ULONG  DmaPort;
867   ULONG  DmaChannel;
868 } NDIS_DMA_DESCRIPTION, *PNDIS_DMA_DESCRIPTION;
869 
870 typedef struct _NDIS_DMA_BLOCK {
871   PVOID  MapRegisterBase;
872   KEVENT  AllocationEvent;
873   PADAPTER_OBJECT  SystemAdapterObject;
874   PVOID  Miniport;
875   BOOLEAN  InProgress;
876 } NDIS_DMA_BLOCK, *PNDIS_DMA_BLOCK;
877 
878 typedef UCHAR NDIS_DMA_SIZE;
879 
880 #define NDIS_DMA_24BITS                         ((NDIS_DMA_SIZE)0)
881 #define NDIS_DMA_32BITS                         ((NDIS_DMA_SIZE)1)
882 #define NDIS_DMA_64BITS                         ((NDIS_DMA_SIZE)2)
883 
884 typedef enum _NDIS_PROCESSOR_TYPE {
885   NdisProcessorX86,
886   NdisProcessorMips,
887   NdisProcessorAlpha,
888   NdisProcessorPpc,
889   NdisProcessorAmd64,
890   NdisProcessorIA64
891 } NDIS_PROCESSOR_TYPE, *PNDIS_PROCESSOR_TYPE;
892 
893 typedef enum _NDIS_ENVIRONMENT_TYPE {
894   NdisEnvironmentWindows,
895   NdisEnvironmentWindowsNt
896 } NDIS_ENVIRONMENT_TYPE, *PNDIS_ENVIRONMENT_TYPE;
897 
898 /* Possible hardware architecture */
899 typedef enum _NDIS_INTERFACE_TYPE {
900   NdisInterfaceInternal = Internal,
901   NdisInterfaceIsa = Isa,
902   NdisInterfaceEisa = Eisa,
903   NdisInterfaceMca = MicroChannel,
904   NdisInterfaceTurboChannel = TurboChannel,
905   NdisInterfacePci = PCIBus,
906   NdisInterfacePcMcia = PCMCIABus,
907   NdisInterfaceCBus = CBus,
908   NdisInterfaceMPIBus = MPIBus,
909   NdisInterfaceMPSABus = MPSABus,
910   NdisInterfaceProcessorInternal = ProcessorInternal,
911   NdisInterfaceInternalPowerBus = InternalPowerBus,
912   NdisInterfacePNPISABus = PNPISABus,
913   NdisInterfacePNPBus = PNPBus,
914   NdisInterfaceUSB,
915   NdisInterfaceIrda,
916   NdisInterface1394,
917   NdisMaximumInterfaceType
918 } NDIS_INTERFACE_TYPE, *PNDIS_INTERFACE_TYPE;
919 
920 #define NdisInterruptLevelSensitive       LevelSensitive
921 #define NdisInterruptLatched              Latched
922 
923 typedef KINTERRUPT_MODE NDIS_INTERRUPT_MODE, *PNDIS_INTERRUPT_MODE;
924 
925 typedef enum _NDIS_PARAMETER_TYPE {
926   NdisParameterInteger,
927   NdisParameterHexInteger,
928   NdisParameterString,
929   NdisParameterMultiString,
930   NdisParameterBinary
931 } NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE;
932 
933 typedef struct _BINARY_DATA {
934   USHORT Length;
935   _Field_size_bytes_(Length) PVOID Buffer;
936 } BINARY_DATA;
937 
938 typedef struct _NDIS_CONFIGURATION_PARAMETER {
939   NDIS_PARAMETER_TYPE ParameterType;
940   union {
941     ULONG IntegerData;
942     NDIS_STRING StringData;
943     BINARY_DATA BinaryData;
944   } ParameterData;
945 } NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER;
946 
947 typedef PHYSICAL_ADDRESS NDIS_PHYSICAL_ADDRESS, *PNDIS_PHYSICAL_ADDRESS;
948 
949 typedef struct _NDIS_PHYSICAL_ADDRESS_UNIT {
950   NDIS_PHYSICAL_ADDRESS PhysicalAddress;
951   UINT Length;
952 } NDIS_PHYSICAL_ADDRESS_UNIT, *PNDIS_PHYSICAL_ADDRESS_UNIT;
953 
954 typedef struct _NDIS_WAN_LINE_DOWN {
955   UCHAR RemoteAddress[6];
956   UCHAR LocalAddress[6];
957 } NDIS_WAN_LINE_DOWN, *PNDIS_WAN_LINE_DOWN;
958 
959 typedef struct _NDIS_WAN_LINE_UP {
960   ULONG LinkSpeed;
961   ULONG MaximumTotalSize;
962   NDIS_WAN_QUALITY Quality;
963   USHORT SendWindow;
964   UCHAR RemoteAddress[6];
965   OUT UCHAR LocalAddress[6];
966   ULONG ProtocolBufferLength;
967   PUCHAR ProtocolBuffer;
968   USHORT ProtocolType;
969   NDIS_STRING DeviceName;
970 } NDIS_WAN_LINE_UP, *PNDIS_WAN_LINE_UP;
971 
972 typedef NTSTATUS
973 (NTAPI *TDI_REGISTER_CALLBACK)(
974   _In_ PUNICODE_STRING DeviceName,
975   _Out_ HANDLE *TdiHandle);
976 
977 typedef NTSTATUS
978 (NTAPI *TDI_PNP_HANDLER)(
979   _In_ PUNICODE_STRING UpperComponent,
980   _In_ PUNICODE_STRING LowerComponent,
981   _In_ PUNICODE_STRING BindList,
982   _In_ PVOID ReconfigBuffer,
983   _In_ UINT ReconfigBufferSize,
984   _In_ UINT Operation);
985 
986 typedef struct _OID_LIST    OID_LIST, *POID_LIST;
987 
988 /* PnP state */
989 
990 typedef enum _NDIS_PNP_DEVICE_STATE {
991   NdisPnPDeviceAdded,
992   NdisPnPDeviceStarted,
993   NdisPnPDeviceQueryStopped,
994   NdisPnPDeviceStopped,
995   NdisPnPDeviceQueryRemoved,
996   NdisPnPDeviceRemoved,
997   NdisPnPDeviceSurpriseRemoved
998 } NDIS_PNP_DEVICE_STATE;
999 
1000 #define	NDIS_DEVICE_NOT_STOPPABLE                 0x00000001
1001 #define	NDIS_DEVICE_NOT_REMOVEABLE                0x00000002
1002 #define	NDIS_DEVICE_NOT_SUSPENDABLE               0x00000004
1003 #define NDIS_DEVICE_DISABLE_PM                    0x00000008
1004 #define NDIS_DEVICE_DISABLE_WAKE_UP               0x00000010
1005 #define NDIS_DEVICE_DISABLE_WAKE_ON_RECONNECT     0x00000020
1006 #define NDIS_DEVICE_RESERVED                      0x00000040
1007 #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET  0x00000080
1008 #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100
1009 
1010 /* Protocol types supported by NDIS */
1011 #define	NDIS_PROTOCOL_ID_DEFAULT        0x00
1012 #define	NDIS_PROTOCOL_ID_TCP_IP         0x02
1013 #define	NDIS_PROTOCOL_ID_IPX            0x06
1014 #define	NDIS_PROTOCOL_ID_NBF            0x07
1015 #define	NDIS_PROTOCOL_ID_MAX            0x0F
1016 #define	NDIS_PROTOCOL_ID_MASK           0x0F
1017 
1018 typedef ULONG NDIS_AF, *PNDIS_AF;
1019 
1020 #define CO_ADDRESS_FAMILY_Q2931           ((NDIS_AF)0x1)
1021 #define CO_ADDRESS_FAMILY_PSCHED          ((NDIS_AF)0x2)
1022 #define CO_ADDRESS_FAMILY_L2TP            ((NDIS_AF)0x3)
1023 #define CO_ADDRESS_FAMILY_IRDA            ((NDIS_AF)0x4)
1024 #define CO_ADDRESS_FAMILY_1394            ((NDIS_AF)0x5)
1025 #define CO_ADDRESS_FAMILY_PPP             ((NDIS_AF)0x6)
1026 #define CO_ADDRESS_FAMILY_INFINIBAND      ((NDIS_AF)0x7)
1027 #define CO_ADDRESS_FAMILY_TAPI            ((NDIS_AF)0x800)
1028 #define CO_ADDRESS_FAMILY_TAPI_PROXY      ((NDIS_AF)0x801)
1029 
1030 #define CO_ADDRESS_FAMILY_PROXY           0x80000000
1031 
1032 typedef struct _CO_ADDRESS_FAMILY {
1033   NDIS_AF AddressFamily;
1034   ULONG MajorVersion;
1035   ULONG MinorVersion;
1036 } CO_ADDRESS_FAMILY, *PCO_ADDRESS_FAMILY;
1037 
1038 typedef struct _CO_SPECIFIC_PARAMETERS {
1039   ULONG  ParamType;
1040   ULONG  Length;
1041   UCHAR  Parameters[1];
1042 } CO_SPECIFIC_PARAMETERS, *PCO_SPECIFIC_PARAMETERS;
1043 
1044 typedef struct _CO_CALL_MANAGER_PARAMETERS {
1045   FLOWSPEC  Transmit;
1046   FLOWSPEC  Receive;
1047   CO_SPECIFIC_PARAMETERS  CallMgrSpecific;
1048 } CO_CALL_MANAGER_PARAMETERS, *PCO_CALL_MANAGER_PARAMETERS;
1049 
1050 /* CO_MEDIA_PARAMETERS.Flags constants */
1051 #define RECEIVE_TIME_INDICATION           0x00000001
1052 #define USE_TIME_STAMPS                   0x00000002
1053 #define TRANSMIT_VC                       0x00000004
1054 #define RECEIVE_VC                        0x00000008
1055 #define INDICATE_ERRED_PACKETS            0x00000010
1056 #define INDICATE_END_OF_TX                0x00000020
1057 #define RESERVE_RESOURCES_VC              0x00000040
1058 #define	ROUND_DOWN_FLOW                   0x00000080
1059 #define	ROUND_UP_FLOW                     0x00000100
1060 
1061 typedef struct _CO_MEDIA_PARAMETERS {
1062   ULONG  Flags;
1063   ULONG  ReceivePriority;
1064   ULONG  ReceiveSizeHint;
1065   CO_SPECIFIC_PARAMETERS  MediaSpecific;
1066 } CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS;
1067 
1068 /* CO_CALL_PARAMETERS.Flags constants */
1069 #define PERMANENT_VC                      0x00000001
1070 #define CALL_PARAMETERS_CHANGED           0x00000002
1071 #define QUERY_CALL_PARAMETERS             0x00000004
1072 #define BROADCAST_VC                      0x00000008
1073 #define MULTIPOINT_VC                     0x00000010
1074 
1075 typedef struct _CO_CALL_PARAMETERS {
1076   ULONG  Flags;
1077   PCO_CALL_MANAGER_PARAMETERS  CallMgrParameters;
1078   PCO_MEDIA_PARAMETERS  MediaParameters;
1079 } CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS;
1080 
1081 typedef struct _CO_SAP {
1082   ULONG SapType;
1083   ULONG SapLength;
1084   UCHAR Sap[1];
1085 } CO_SAP, *PCO_SAP;
1086 
1087 #if NDIS_LEGACY_DRIVER
1088 typedef struct _NDIS_IPSEC_PACKET_INFO {
1089   __MINGW_EXTENSION union {
1090     struct {
1091       NDIS_HANDLE OffloadHandle;
1092       NDIS_HANDLE NextOffloadHandle;
1093     } Transmit;
1094     struct {
1095       ULONG SA_DELETE_REQ:1;
1096       ULONG CRYPTO_DONE:1;
1097       ULONG NEXT_CRYPTO_DONE:1;
1098       ULONG CryptoStatus;
1099     } Receive;
1100   };
1101 } NDIS_IPSEC_PACKET_INFO, *PNDIS_IPSEC_PACKET_INFO;
1102 #endif
1103 
1104 #if (NDIS_SUPPORT_NDIS6 || NDIS60)
1105 typedef struct _NDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO {
1106   __MINGW_EXTENSION union {
1107     struct {
1108       NDIS_HANDLE OffloadHandle;
1109     } Transmit;
1110     struct {
1111       USHORT SaDeleteReq:1;
1112       USHORT CryptoDone:1;
1113       USHORT NextCryptoDone:1;
1114       USHORT Pad:13;
1115       USHORT CryptoStatus;
1116     } Receive;
1117   };
1118 } NDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO, *PNDIS_IPSEC_OFFLOAD_V1_NET_BUFFER_LIST_INFO;
1119 #endif
1120 
1121 /* NDIS_MAC_FRAGMENT.Errors constants */
1122 #define WAN_ERROR_CRC               			0x00000001
1123 #define WAN_ERROR_FRAMING           			0x00000002
1124 #define WAN_ERROR_HARDWAREOVERRUN   			0x00000004
1125 #define WAN_ERROR_BUFFEROVERRUN     			0x00000008
1126 #define WAN_ERROR_TIMEOUT           			0x00000010
1127 #define WAN_ERROR_ALIGNMENT         			0x00000020
1128 
1129 typedef struct _NDIS_MAC_FRAGMENT {
1130   NDIS_HANDLE  NdisLinkContext;
1131   ULONG  Errors;
1132 } NDIS_MAC_FRAGMENT, *PNDIS_MAC_FRAGMENT;
1133 
1134 typedef struct _NDIS_MAC_LINE_DOWN {
1135   NDIS_HANDLE  NdisLinkContext;
1136 } NDIS_MAC_LINE_DOWN, *PNDIS_MAC_LINE_DOWN;
1137 
1138 typedef struct _NDIS_MAC_LINE_UP {
1139   ULONG  LinkSpeed;
1140   NDIS_WAN_QUALITY  Quality;
1141   USHORT  SendWindow;
1142   NDIS_HANDLE  ConnectionWrapperID;
1143   NDIS_HANDLE  NdisLinkHandle;
1144   NDIS_HANDLE  NdisLinkContext;
1145 } NDIS_MAC_LINE_UP, *PNDIS_MAC_LINE_UP;
1146 
1147 typedef struct _NDIS_PACKET_8021Q_INFO {
1148   __MINGW_EXTENSION union {
1149     struct {
1150       UINT32 UserPriority:3;
1151       UINT32 CanonicalFormatId:1;
1152       UINT32 VlanId:12;
1153       UINT32 Reserved:16;
1154     } TagHeader;
1155     PVOID Value;
1156   };
1157 } NDIS_PACKET_8021Q_INFO, *PNDIS_PACKET_8021Q_INFO;
1158 
1159 typedef enum _NDIS_PER_PACKET_INFO {
1160   TcpIpChecksumPacketInfo,
1161   IpSecPacketInfo,
1162   TcpLargeSendPacketInfo,
1163   ClassificationHandlePacketInfo,
1164   NdisReserved,
1165   ScatterGatherListPacketInfo,
1166   Ieee8021QInfo,
1167   OriginalPacketInfo,
1168   PacketCancelId,
1169   OriginalNetBufferList,
1170   CachedNetBufferList,
1171   ShortPacketPaddingInfo,
1172   MaxPerPacketInfo
1173 } NDIS_PER_PACKET_INFO, *PNDIS_PER_PACKET_INFO;
1174 
1175 #if NDIS_LEGACY_DRIVER
1176 
1177 typedef struct _NDIS_PACKET_EXTENSION {
1178   PVOID NdisPacketInfo[MaxPerPacketInfo];
1179 } NDIS_PACKET_EXTENSION, *PNDIS_PACKET_EXTENSION;
1180 
1181 typedef enum _NDIS_TASK {
1182   TcpIpChecksumNdisTask,
1183   IpSecNdisTask,
1184   TcpLargeSendNdisTask,
1185   MaxNdisTask
1186 } NDIS_TASK, *PNDIS_TASK;
1187 
1188 typedef enum _NDIS_ENCAPSULATION {
1189   UNSPECIFIED_Encapsulation,
1190   NULL_Encapsulation,
1191   IEEE_802_3_Encapsulation,
1192   IEEE_802_5_Encapsulation,
1193   LLC_SNAP_ROUTED_Encapsulation,
1194   LLC_SNAP_BRIDGED_Encapsulation
1195 } NDIS_ENCAPSULATION;
1196 
1197 typedef struct _NDIS_ENCAPSULATION_FORMAT {
1198   NDIS_ENCAPSULATION Encapsulation;
1199   struct {
1200     ULONG FixedHeaderSize:1;
1201     ULONG Reserved:31;
1202   } Flags;
1203   ULONG EncapsulationHeaderSize;
1204 } NDIS_ENCAPSULATION_FORMAT, *PNDIS_ENCAPSULATION_FORMAT;
1205 
1206 typedef struct _NDIS_TASK_OFFLOAD_HEADER {
1207   ULONG Version;
1208   ULONG Size;
1209   ULONG Reserved;
1210   ULONG OffsetFirstTask;
1211   NDIS_ENCAPSULATION_FORMAT EncapsulationFormat;
1212 } NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER;
1213 
1214 typedef struct _NDIS_TASK_OFFLOAD {
1215   ULONG Version;
1216   ULONG Size;
1217   NDIS_TASK Task;
1218   ULONG OffsetNextTask;
1219   ULONG TaskBufferLength;
1220   UCHAR TaskBuffer[1];
1221 } NDIS_TASK_OFFLOAD, *PNDIS_TASK_OFFLOAD;
1222 
1223 typedef struct _NDIS_TASK_TCP_IP_CHECKSUM {
1224   struct {
1225     ULONG IpOptionsSupported:1;
1226     ULONG TcpOptionsSupported:1;
1227     ULONG TcpChecksum:1;
1228     ULONG UdpChecksum:1;
1229     ULONG IpChecksum:1;
1230   } V4Transmit;
1231   struct {
1232     ULONG IpOptionsSupported:1;
1233     ULONG TcpOptionsSupported:1;
1234     ULONG TcpChecksum:1;
1235     ULONG UdpChecksum:1;
1236     ULONG IpChecksum:1;
1237   } V4Receive;
1238   struct {
1239     ULONG IpOptionsSupported:1;
1240     ULONG TcpOptionsSupported:1;
1241     ULONG TcpChecksum:1;
1242     ULONG UdpChecksum:1;
1243   } V6Transmit;
1244   struct {
1245     ULONG IpOptionsSupported:1;
1246     ULONG TcpOptionsSupported:1;
1247     ULONG TcpChecksum:1;
1248     ULONG UdpChecksum:1;
1249   } V6Receive;
1250 } NDIS_TASK_TCP_IP_CHECKSUM, *PNDIS_TASK_TCP_IP_CHECKSUM;
1251 
1252 #define NDIS_TASK_TCP_LARGE_SEND_V0 0
1253 
1254 typedef struct _NDIS_TASK_TCP_LARGE_SEND {
1255   ULONG Version;
1256   ULONG MaxOffLoadSize;
1257   ULONG MinSegmentCount;
1258   BOOLEAN TcpOptions;
1259   BOOLEAN IpOptions;
1260 } NDIS_TASK_TCP_LARGE_SEND, *PNDIS_TASK_TCP_LARGE_SEND;
1261 
1262 typedef struct _NDIS_TASK_IPSEC {
1263   struct {
1264     ULONG AH_ESP_COMBINED;
1265     ULONG TRANSPORT_TUNNEL_COMBINED;
1266     ULONG V4_OPTIONS;
1267     ULONG RESERVED;
1268   } Supported;
1269   struct {
1270     ULONG MD5:1;
1271     ULONG SHA_1:1;
1272     ULONG Transport:1;
1273     ULONG Tunnel:1;
1274     ULONG Send:1;
1275     ULONG Receive:1;
1276   } V4AH;
1277   struct {
1278     ULONG DES:1;
1279     ULONG RESERVED:1;
1280     ULONG TRIPLE_DES:1;
1281     ULONG NULL_ESP:1;
1282     ULONG Transport:1;
1283     ULONG Tunnel:1;
1284     ULONG Send:1;
1285     ULONG Receive:1;
1286   } V4ESP;
1287 } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
1288 
1289 #endif /* NDIS_LEGACY_DRIVER */
1290 
1291 #define IPSEC_TPT_UDPESP_ENCAPTYPE_IKE                 0x00000001
1292 #define IPSEC_TUN_UDPESP_ENCAPTYPE_IKE                 0x00000002
1293 #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_IKE          0x00000004
1294 #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_IKE   0x00000008
1295 #define IPSEC_TPT_UDPESP_ENCAPTYPE_OTHER               0x00000010
1296 #define IPSEC_TUN_UDPESP_ENCAPTYPE_OTHER               0x00000020
1297 #define IPSEC_TPTOVERTUN_UDPESP_ENCAPTYPE_OTHER        0x00000040
1298 #define IPSEC_TPT_UDPESP_OVER_PURE_TUN_ENCAPTYPE_OTHER 0x00000080
1299 
1300 #if NDIS_LEGACY_DRIVER
1301 
1302 /*
1303  * PNDIS_PACKET
1304  * NDIS_GET_ORIGINAL_PACKET(
1305  *   IN PNDIS_PACKET  Packet);
1306  */
1307 #define NDIS_GET_ORIGINAL_PACKET(Packet) \
1308   NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, OriginalPacketInfo)
1309 
1310 /*
1311  * PVOID
1312  * NDIS_GET_PACKET_CANCEL_ID(
1313  *   IN PNDIS_PACKET  Packet);
1314  */
1315 #define NDIS_GET_PACKET_CANCEL_ID(Packet) \
1316   NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, PacketCancelId)
1317 
1318 /*
1319  * PNDIS_PACKET_EXTENSION
1320  * NDIS_PACKET_EXTENSION_FROM_PACKET(
1321  *   IN PNDIS_PACKET  Packet);
1322  */
1323 #define NDIS_PACKET_EXTENSION_FROM_PACKET(Packet) \
1324   ((PNDIS_PACKET_EXTENSION)((PUCHAR)(Packet) \
1325     + (Packet)->Private.NdisPacketOobOffset + sizeof(NDIS_PACKET_OOB_DATA)))
1326 
1327 /*
1328  * PVOID
1329  * NDIS_PER_PACKET_INFO_FROM_PACKET(
1330  *   IN OUT  PNDIS_PACKET  Packet,
1331  *   IN NDIS_PER_PACKET_INFO  InfoType);
1332  */
1333 #define NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, InfoType) \
1334   ((PNDIS_PACKET_EXTENSION)((PUCHAR)(Packet) + (Packet)->Private.NdisPacketOobOffset \
1335     + sizeof(NDIS_PACKET_OOB_DATA)))->NdisPacketInfo[(InfoType)]
1336 
1337 /*
1338  * VOID
1339  * NDIS_SET_ORIGINAL_PACKET(
1340  *   IN OUT  PNDIS_PACKET  Packet,
1341  *   IN PNDIS_PACKET  OriginalPacket);
1342  */
1343 #define NDIS_SET_ORIGINAL_PACKET(Packet, OriginalPacket) \
1344   NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, OriginalPacketInfo) = (OriginalPacket)
1345 
1346 /*
1347  * VOID
1348  * NDIS_SET_PACKET_CANCEL_ID(
1349  *  IN PNDIS_PACKET  Packet
1350  *  IN ULONG_PTR  CancelId);
1351  */
1352 #define NDIS_SET_PACKET_CANCEL_ID(Packet, CancelId) \
1353   NDIS_PER_PACKET_INFO_FROM_PACKET(Packet, PacketCancelId) = (CancelId)
1354 
1355 #define NdisSetPacketCancelId(_Packet, _CancelId) NDIS_SET_PACKET_CANCEL_ID(_Packet, _CancelId)
1356 #define NdisGetPacketCancelId(_Packet) NDIS_GET_PACKET_CANCEL_ID(_Packet)
1357 
1358 #endif /* NDIS_LEGACY_DRIVER */
1359 
1360 #if NDIS_SUPPORT_NDIS6
1361 typedef struct _NDIS_GENERIC_OBJECT {
1362   NDIS_OBJECT_HEADER Header;
1363   PVOID Caller;
1364   PVOID CallersCaller;
1365   PDRIVER_OBJECT DriverObject;
1366 } NDIS_GENERIC_OBJECT, *PNDIS_GENERIC_OBJECT;
1367 #endif
1368 
1369 /* NDIS_TASK_OFFLOAD_HEADER.Version constants */
1370 #define NDIS_TASK_OFFLOAD_VERSION 1
1371 
1372 #define MAX_HASHES                     4
1373 #define TRUNCATED_HASH_LEN             12
1374 
1375 #define CRYPTO_SUCCESS                   0
1376 #define CRYPTO_GENERIC_ERROR             1
1377 #define CRYPTO_TRANSPORT_AH_AUTH_FAILED  2
1378 #define CRYPTO_TRANSPORT_ESP_AUTH_FAILED 3
1379 #define CRYPTO_TUNNEL_AH_AUTH_FAILED     4
1380 #define CRYPTO_TUNNEL_ESP_AUTH_FAILED    5
1381 #define CRYPTO_INVALID_PACKET_SYNTAX     6
1382 #define CRYPTO_INVALID_PROTOCOL          7
1383 
1384 typedef struct _NDIS_TCP_IP_CHECKSUM_PACKET_INFO {
1385   __MINGW_EXTENSION union {
1386     struct {
1387       ULONG NdisPacketChecksumV4:1;
1388       ULONG NdisPacketChecksumV6:1;
1389       ULONG NdisPacketTcpChecksum:1;
1390       ULONG NdisPacketUdpChecksum:1;
1391       ULONG NdisPacketIpChecksum:1;
1392       } Transmit;
1393     struct {
1394       ULONG NdisPacketTcpChecksumFailed:1;
1395       ULONG NdisPacketUdpChecksumFailed:1;
1396       ULONG NdisPacketIpChecksumFailed:1;
1397       ULONG NdisPacketTcpChecksumSucceeded:1;
1398       ULONG NdisPacketUdpChecksumSucceeded:1;
1399       ULONG NdisPacketIpChecksumSucceeded:1;
1400       ULONG NdisPacketLoopback:1;
1401     } Receive;
1402     ULONG Value;
1403   };
1404 } NDIS_TCP_IP_CHECKSUM_PACKET_INFO, *PNDIS_TCP_IP_CHECKSUM_PACKET_INFO;
1405 
1406 typedef struct _NDIS_WAN_CO_FRAGMENT {
1407   ULONG Errors;
1408 } NDIS_WAN_CO_FRAGMENT, *PNDIS_WAN_CO_FRAGMENT;
1409 
1410 typedef struct _NDIS_WAN_FRAGMENT {
1411   UCHAR RemoteAddress[6];
1412   UCHAR LocalAddress[6];
1413 } NDIS_WAN_FRAGMENT, *PNDIS_WAN_FRAGMENT;
1414 
1415 typedef struct _WAN_CO_LINKPARAMS {
1416   ULONG TransmitSpeed;
1417   ULONG ReceiveSpeed;
1418   ULONG SendWindow;
1419 } WAN_CO_LINKPARAMS, *PWAN_CO_LINKPARAMS;
1420 
1421 typedef struct _NDIS_WAN_GET_STATS {
1422   UCHAR LocalAddress[6];
1423   ULONG BytesSent;
1424   ULONG BytesRcvd;
1425   ULONG FramesSent;
1426   ULONG FramesRcvd;
1427   ULONG CRCErrors;
1428   ULONG TimeoutErrors;
1429   ULONG AlignmentErrors;
1430   ULONG SerialOverrunErrors;
1431   ULONG FramingErrors;
1432   ULONG BufferOverrunErrors;
1433   ULONG BytesTransmittedUncompressed;
1434   ULONG BytesReceivedUncompressed;
1435   ULONG BytesTransmittedCompressed;
1436   ULONG BytesReceivedCompressed;
1437 } NDIS_WAN_GET_STATS, *PNDIS_WAN_GET_STATS;
1438 
1439 /* Call Manager */
1440 
1441 typedef VOID
1442 (NTAPI *CM_ACTIVATE_VC_COMPLETE_HANDLER)(
1443   IN NDIS_STATUS  Status,
1444   IN NDIS_HANDLE  CallMgrVcContext,
1445   IN PCO_CALL_PARAMETERS  CallParameters);
1446 
1447 typedef NDIS_STATUS
1448 (NTAPI *CM_ADD_PARTY_HANDLER)(
1449   IN NDIS_HANDLE  CallMgrVcContext,
1450   IN OUT PCO_CALL_PARAMETERS  CallParameters,
1451   IN NDIS_HANDLE  NdisPartyHandle,
1452   OUT PNDIS_HANDLE  CallMgrPartyContext);
1453 
1454 typedef NDIS_STATUS
1455 (NTAPI *CM_CLOSE_AF_HANDLER)(
1456   IN NDIS_HANDLE  CallMgrAfContext);
1457 
1458 typedef NDIS_STATUS
1459 (NTAPI *CM_CLOSE_CALL_HANDLER)(
1460   IN NDIS_HANDLE  CallMgrVcContext,
1461   IN NDIS_HANDLE  CallMgrPartyContext  OPTIONAL,
1462   IN PVOID  CloseData  OPTIONAL,
1463   IN UINT  Size  OPTIONAL);
1464 
1465 typedef NDIS_STATUS
1466 (NTAPI *CM_DEREG_SAP_HANDLER)(
1467   IN NDIS_HANDLE  CallMgrSapContext);
1468 
1469 typedef VOID
1470 (NTAPI *CM_DEACTIVATE_VC_COMPLETE_HANDLER)(
1471 	IN NDIS_STATUS  Status,
1472 	IN NDIS_HANDLE  CallMgrVcContext);
1473 
1474 typedef NDIS_STATUS
1475 (NTAPI *CM_DROP_PARTY_HANDLER)(
1476   IN NDIS_HANDLE  CallMgrPartyContext,
1477   IN PVOID  CloseData  OPTIONAL,
1478   IN UINT  Size  OPTIONAL);
1479 
1480 typedef VOID
1481 (NTAPI *CM_INCOMING_CALL_COMPLETE_HANDLER)(
1482   IN NDIS_STATUS  Status,
1483   IN NDIS_HANDLE  CallMgrVcContext,
1484   IN PCO_CALL_PARAMETERS  CallParameters);
1485 
1486 typedef NDIS_STATUS
1487 (NTAPI *CM_MAKE_CALL_HANDLER)(
1488   IN NDIS_HANDLE  CallMgrVcContext,
1489   IN OUT PCO_CALL_PARAMETERS  CallParameters,
1490   IN NDIS_HANDLE  NdisPartyHandle	OPTIONAL,
1491   OUT PNDIS_HANDLE  CallMgrPartyContext  OPTIONAL);
1492 
1493 typedef NDIS_STATUS
1494 (NTAPI *CM_MODIFY_CALL_QOS_HANDLER)(
1495   IN NDIS_HANDLE  CallMgrVcContext,
1496   IN PCO_CALL_PARAMETERS  CallParameters);
1497 
1498 typedef NDIS_STATUS
1499 (NTAPI *CM_OPEN_AF_HANDLER)(
1500 	IN NDIS_HANDLE  CallMgrBindingContext,
1501 	IN PCO_ADDRESS_FAMILY  AddressFamily,
1502 	IN NDIS_HANDLE  NdisAfHandle,
1503 	OUT PNDIS_HANDLE  CallMgrAfContext);
1504 
1505 typedef NDIS_STATUS
1506 (NTAPI *CM_REG_SAP_HANDLER)(
1507   IN NDIS_HANDLE  CallMgrAfContext,
1508   IN PCO_SAP  Sap,
1509   IN NDIS_HANDLE  NdisSapHandle,
1510   OUT	PNDIS_HANDLE  CallMgrSapContext);
1511 
1512 typedef NDIS_STATUS
1513 (NTAPI *CO_CREATE_VC_HANDLER)(
1514   IN NDIS_HANDLE  ProtocolAfContext,
1515   IN NDIS_HANDLE  NdisVcHandle,
1516   OUT PNDIS_HANDLE  ProtocolVcContext);
1517 
1518 typedef NDIS_STATUS
1519 (NTAPI *CO_DELETE_VC_HANDLER)(
1520   IN NDIS_HANDLE  ProtocolVcContext);
1521 
1522 #define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(PVOID))
1523 
1524 /* Prototypes for NDIS 5.0 protocol characteristics */
1525 
1526 _IRQL_requires_(PASSIVE_LEVEL)
1527 typedef VOID
1528 (NTAPI *CO_SEND_COMPLETE_HANDLER)(
1529   _In_ NDIS_STATUS Status,
1530   _In_ NDIS_HANDLE ProtocolVcContext,
1531   _In_ PNDIS_PACKET Packet);
1532 
1533 _IRQL_requires_max_(DISPATCH_LEVEL)
1534 typedef VOID
1535 (NTAPI *CO_STATUS_HANDLER)(
1536   _In_ NDIS_HANDLE ProtocolBindingContext,
1537   _In_opt_ NDIS_HANDLE ProtocolVcContext,
1538   _In_ NDIS_STATUS GeneralStatus,
1539   _In_ PVOID StatusBuffer,
1540   _In_ UINT StatusBufferSize);
1541 
1542 _IRQL_requires_max_(DISPATCH_LEVEL)
1543 typedef UINT
1544 (NTAPI *CO_RECEIVE_PACKET_HANDLER)(
1545   _In_ NDIS_HANDLE ProtocolBindingContext,
1546   _In_ NDIS_HANDLE ProtocolVcContext,
1547   _In_ PNDIS_PACKET Packet);
1548 
1549 _IRQL_requires_max_(DISPATCH_LEVEL)
1550 typedef NDIS_STATUS
1551 (NTAPI *CO_REQUEST_HANDLER)(
1552   _In_ NDIS_HANDLE ProtocolAfContext,
1553   _In_opt_ NDIS_HANDLE ProtocolVcContext,
1554   _In_opt_ NDIS_HANDLE ProtocolPartyContext,
1555   _Inout_ PNDIS_REQUEST NdisRequest);
1556 
1557 _IRQL_requires_max_(DISPATCH_LEVEL)
1558 typedef VOID
1559 (NTAPI *CO_REQUEST_COMPLETE_HANDLER)(
1560   _In_ NDIS_STATUS Status,
1561   _In_opt_ NDIS_HANDLE ProtocolAfContext,
1562   _In_opt_ NDIS_HANDLE ProtocolVcContext,
1563   _In_opt_ NDIS_HANDLE ProtocolPartyContext,
1564   _In_ PNDIS_REQUEST NdisRequest);
1565 
1566 typedef struct _NDIS_CALL_MANAGER_CHARACTERISTICS {
1567 	UCHAR  MajorVersion;
1568 	UCHAR  MinorVersion;
1569 	USHORT  Filler;
1570 	UINT  Reserved;
1571 	CO_CREATE_VC_HANDLER  CmCreateVcHandler;
1572 	CO_DELETE_VC_HANDLER  CmDeleteVcHandler;
1573 	CM_OPEN_AF_HANDLER  CmOpenAfHandler;
1574 	CM_CLOSE_AF_HANDLER	 CmCloseAfHandler;
1575 	CM_REG_SAP_HANDLER  CmRegisterSapHandler;
1576 	CM_DEREG_SAP_HANDLER  CmDeregisterSapHandler;
1577 	CM_MAKE_CALL_HANDLER  CmMakeCallHandler;
1578 	CM_CLOSE_CALL_HANDLER  CmCloseCallHandler;
1579 	CM_INCOMING_CALL_COMPLETE_HANDLER  CmIncomingCallCompleteHandler;
1580 	CM_ADD_PARTY_HANDLER  CmAddPartyHandler;
1581 	CM_DROP_PARTY_HANDLER  CmDropPartyHandler;
1582 	CM_ACTIVATE_VC_COMPLETE_HANDLER  CmActivateVcCompleteHandler;
1583 	CM_DEACTIVATE_VC_COMPLETE_HANDLER  CmDeactivateVcCompleteHandler;
1584 	CM_MODIFY_CALL_QOS_HANDLER  CmModifyCallQoSHandler;
1585 	CO_REQUEST_HANDLER  CmRequestHandler;
1586 	CO_REQUEST_COMPLETE_HANDLER  CmRequestCompleteHandler;
1587 } NDIS_CALL_MANAGER_CHARACTERISTICS, *PNDIS_CALL_MANAGER_CHARACTERISTICS;
1588 
1589 
1590 
1591 /* Call Manager clients */
1592 
1593 typedef VOID (*CL_OPEN_AF_COMPLETE_HANDLER)(
1594   IN NDIS_STATUS Status,
1595   IN NDIS_HANDLE ProtocolAfContext,
1596   IN NDIS_HANDLE NdisAfHandle);
1597 
1598 typedef VOID
1599 (NTAPI *CL_CLOSE_AF_COMPLETE_HANDLER)(
1600   IN NDIS_STATUS  Status,
1601   IN NDIS_HANDLE  ProtocolAfContext);
1602 
1603 typedef VOID
1604 (NTAPI *CL_REG_SAP_COMPLETE_HANDLER)(
1605   IN NDIS_STATUS  Status,
1606   IN NDIS_HANDLE  ProtocolSapContext,
1607   IN PCO_SAP  Sap,
1608   IN NDIS_HANDLE  NdisSapHandle);
1609 
1610 typedef VOID
1611 (NTAPI *CL_DEREG_SAP_COMPLETE_HANDLER)(
1612   IN NDIS_STATUS  Status,
1613   IN NDIS_HANDLE  ProtocolSapContext);
1614 
1615 typedef VOID
1616 (NTAPI *CL_MAKE_CALL_COMPLETE_HANDLER)(
1617   IN NDIS_STATUS  Status,
1618   IN NDIS_HANDLE  ProtocolVcContext,
1619   IN NDIS_HANDLE  NdisPartyHandle  OPTIONAL,
1620   IN PCO_CALL_PARAMETERS  CallParameters);
1621 
1622 typedef VOID
1623 (NTAPI *CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)(
1624   IN NDIS_STATUS  Status,
1625   IN NDIS_HANDLE  ProtocolVcContext,
1626   IN PCO_CALL_PARAMETERS  CallParameters);
1627 
1628 typedef VOID
1629 (NTAPI *CL_CLOSE_CALL_COMPLETE_HANDLER)(
1630   IN NDIS_STATUS  Status,
1631   IN NDIS_HANDLE  ProtocolVcContext,
1632   IN NDIS_HANDLE  ProtocolPartyContext  OPTIONAL);
1633 
1634 typedef VOID
1635 (NTAPI *CL_ADD_PARTY_COMPLETE_HANDLER)(
1636   IN NDIS_STATUS  Status,
1637   IN NDIS_HANDLE  ProtocolPartyContext,
1638   IN NDIS_HANDLE  NdisPartyHandle,
1639   IN PCO_CALL_PARAMETERS  CallParameters);
1640 
1641 typedef VOID
1642 (NTAPI *CL_DROP_PARTY_COMPLETE_HANDLER)(
1643   IN NDIS_STATUS  Status,
1644   IN NDIS_HANDLE  ProtocolPartyContext);
1645 
1646 typedef NDIS_STATUS
1647 (NTAPI *CL_INCOMING_CALL_HANDLER)(
1648   IN NDIS_HANDLE  ProtocolSapContext,
1649   IN NDIS_HANDLE  ProtocolVcContext,
1650   IN OUT PCO_CALL_PARAMETERS  CallParameters);
1651 
1652 typedef VOID
1653 (NTAPI *CL_INCOMING_CALL_QOS_CHANGE_HANDLER)(
1654   IN NDIS_HANDLE  ProtocolVcContext,
1655   IN PCO_CALL_PARAMETERS  CallParameters);
1656 
1657 typedef VOID
1658 (NTAPI *CL_INCOMING_CLOSE_CALL_HANDLER)(
1659   IN NDIS_STATUS  CloseStatus,
1660   IN NDIS_HANDLE  ProtocolVcContext,
1661   IN PVOID  CloseData  OPTIONAL,
1662   IN UINT  Size  OPTIONAL);
1663 
1664 typedef VOID
1665 (NTAPI *CL_INCOMING_DROP_PARTY_HANDLER)(
1666   IN NDIS_STATUS  DropStatus,
1667   IN NDIS_HANDLE  ProtocolPartyContext,
1668   IN PVOID  CloseData  OPTIONAL,
1669   IN UINT  Size  OPTIONAL);
1670 
1671 typedef VOID
1672 (NTAPI *CL_CALL_CONNECTED_HANDLER)(
1673   IN NDIS_HANDLE  ProtocolVcContext);
1674 
1675 
1676 typedef struct _NDIS_CLIENT_CHARACTERISTICS {
1677   UCHAR  MajorVersion;
1678   UCHAR  MinorVersion;
1679   USHORT  Filler;
1680   UINT  Reserved;
1681   CO_CREATE_VC_HANDLER  ClCreateVcHandler;
1682   CO_DELETE_VC_HANDLER  ClDeleteVcHandler;
1683   CO_REQUEST_HANDLER  ClRequestHandler;
1684   CO_REQUEST_COMPLETE_HANDLER  ClRequestCompleteHandler;
1685   CL_OPEN_AF_COMPLETE_HANDLER  ClOpenAfCompleteHandler;
1686   CL_CLOSE_AF_COMPLETE_HANDLER  ClCloseAfCompleteHandler;
1687   CL_REG_SAP_COMPLETE_HANDLER  ClRegisterSapCompleteHandler;
1688   CL_DEREG_SAP_COMPLETE_HANDLER  ClDeregisterSapCompleteHandler;
1689   CL_MAKE_CALL_COMPLETE_HANDLER  ClMakeCallCompleteHandler;
1690   CL_MODIFY_CALL_QOS_COMPLETE_HANDLER	 ClModifyCallQoSCompleteHandler;
1691   CL_CLOSE_CALL_COMPLETE_HANDLER  ClCloseCallCompleteHandler;
1692   CL_ADD_PARTY_COMPLETE_HANDLER  ClAddPartyCompleteHandler;
1693   CL_DROP_PARTY_COMPLETE_HANDLER  ClDropPartyCompleteHandler;
1694   CL_INCOMING_CALL_HANDLER  ClIncomingCallHandler;
1695   CL_INCOMING_CALL_QOS_CHANGE_HANDLER  ClIncomingCallQoSChangeHandler;
1696   CL_INCOMING_CLOSE_CALL_HANDLER  ClIncomingCloseCallHandler;
1697   CL_INCOMING_DROP_PARTY_HANDLER  ClIncomingDropPartyHandler;
1698   CL_CALL_CONNECTED_HANDLER  ClCallConnectedHandler;
1699 } NDIS_CLIENT_CHARACTERISTICS, *PNDIS_CLIENT_CHARACTERISTICS;
1700 
1701 
1702 /* NDIS protocol structures */
1703 
1704 /* Prototypes for NDIS 3.0 protocol characteristics */
1705 
1706 typedef VOID
1707 (NTAPI *OPEN_ADAPTER_COMPLETE_HANDLER)(
1708   _In_ NDIS_HANDLE ProtocolBindingContext,
1709   _In_ NDIS_STATUS Status,
1710   _In_ NDIS_STATUS OpenErrorStatus);
1711 
1712 typedef VOID
1713 (NTAPI *CLOSE_ADAPTER_COMPLETE_HANDLER)(
1714   _In_ NDIS_HANDLE ProtocolBindingContext,
1715   _In_ NDIS_STATUS Status);
1716 
1717 typedef VOID
1718 (NTAPI *RESET_COMPLETE_HANDLER)(
1719   _In_ NDIS_HANDLE ProtocolBindingContext,
1720   _In_ NDIS_STATUS Status);
1721 
1722 typedef VOID
1723 (NTAPI *REQUEST_COMPLETE_HANDLER)(
1724   _In_ NDIS_HANDLE ProtocolBindingContext,
1725   _In_ PNDIS_REQUEST NdisRequest,
1726   _In_ NDIS_STATUS Status);
1727 
1728 typedef VOID
1729 (NTAPI *STATUS_HANDLER)(
1730   _In_ NDIS_HANDLE ProtocolBindingContext,
1731   _In_ NDIS_STATUS GeneralStatus,
1732   _In_ PVOID StatusBuffer,
1733   _In_ UINT StatusBufferSize);
1734 
1735 typedef VOID
1736 (NTAPI *STATUS_COMPLETE_HANDLER)(
1737   _In_ NDIS_HANDLE ProtocolBindingContext);
1738 
1739 typedef VOID
1740 (NTAPI *SEND_COMPLETE_HANDLER)(
1741   _In_ NDIS_HANDLE ProtocolBindingContext,
1742   _In_ PNDIS_PACKET Packet,
1743   _In_ NDIS_STATUS Status);
1744 
1745 typedef VOID
1746 (NTAPI *WAN_SEND_COMPLETE_HANDLER)(
1747   _In_ NDIS_HANDLE ProtocolBindingContext,
1748   _In_ PNDIS_WAN_PACKET Packet,
1749   _In_ NDIS_STATUS Status);
1750 
1751 typedef VOID
1752 (NTAPI *TRANSFER_DATA_COMPLETE_HANDLER)(
1753   _In_ NDIS_HANDLE ProtocolBindingContext,
1754   _In_ PNDIS_PACKET Packet,
1755   _In_ NDIS_STATUS Status,
1756   _In_ UINT BytesTransferred);
1757 
1758 typedef VOID
1759 (NTAPI *WAN_TRANSFER_DATA_COMPLETE_HANDLER)(
1760   VOID);
1761 
1762 typedef NDIS_STATUS
1763 (NTAPI *RECEIVE_HANDLER)(
1764   _In_ NDIS_HANDLE ProtocolBindingContext,
1765   _In_ NDIS_HANDLE MacReceiveContext,
1766   _In_ PVOID HeaderBuffer,
1767   _In_ UINT HeaderBufferSize,
1768   _In_ PVOID LookAheadBuffer,
1769   _In_ UINT LookaheadBufferSize,
1770   _In_ UINT PacketSize);
1771 
1772 typedef NDIS_STATUS
1773 (NTAPI *WAN_RECEIVE_HANDLER)(
1774   _In_ NDIS_HANDLE NdisLinkHandle,
1775   _In_ PUCHAR Packet,
1776   _In_ ULONG PacketSize);
1777 
1778 typedef VOID
1779 (NTAPI *RECEIVE_COMPLETE_HANDLER)(
1780   _In_ NDIS_HANDLE ProtocolBindingContext);
1781 
1782 /* Protocol characteristics for NDIS 3.0 protocols */
1783 
1784 #define NDIS30_PROTOCOL_CHARACTERISTICS_S \
1785   UCHAR  MajorNdisVersion; \
1786   UCHAR  MinorNdisVersion; \
1787   USHORT  Filler; \
1788   _ANONYMOUS_UNION union { \
1789     UINT  Reserved; \
1790     UINT  Flags; \
1791   } DUMMYUNIONNAME; \
1792   OPEN_ADAPTER_COMPLETE_HANDLER  OpenAdapterCompleteHandler; \
1793   CLOSE_ADAPTER_COMPLETE_HANDLER  CloseAdapterCompleteHandler; \
1794   _ANONYMOUS_UNION union { \
1795     SEND_COMPLETE_HANDLER  SendCompleteHandler; \
1796     WAN_SEND_COMPLETE_HANDLER  WanSendCompleteHandler; \
1797   } DUMMYUNIONNAME2; \
1798   _ANONYMOUS_UNION union { \
1799     TRANSFER_DATA_COMPLETE_HANDLER  TransferDataCompleteHandler; \
1800     WAN_TRANSFER_DATA_COMPLETE_HANDLER  WanTransferDataCompleteHandler; \
1801   } DUMMYUNIONNAME3; \
1802   RESET_COMPLETE_HANDLER  ResetCompleteHandler; \
1803   REQUEST_COMPLETE_HANDLER  RequestCompleteHandler; \
1804   _ANONYMOUS_UNION union { \
1805     RECEIVE_HANDLER	 ReceiveHandler; \
1806     WAN_RECEIVE_HANDLER  WanReceiveHandler; \
1807   } DUMMYUNIONNAME4; \
1808   RECEIVE_COMPLETE_HANDLER  ReceiveCompleteHandler; \
1809   STATUS_HANDLER  StatusHandler; \
1810   STATUS_COMPLETE_HANDLER  StatusCompleteHandler; \
1811   NDIS_STRING  Name;
1812 
1813 typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS {
1814   NDIS30_PROTOCOL_CHARACTERISTICS_S
1815 } NDIS30_PROTOCOL_CHARACTERISTICS, *PNDIS30_PROTOCOL_CHARACTERISTICS;
1816 
1817 
1818 /* Prototypes for NDIS 4.0 protocol characteristics */
1819 
1820 typedef INT
1821 (NTAPI *RECEIVE_PACKET_HANDLER)(
1822   IN NDIS_HANDLE ProtocolBindingContext,
1823   IN PNDIS_PACKET Packet);
1824 
1825 typedef VOID
1826 (NTAPI *BIND_HANDLER)(
1827   OUT PNDIS_STATUS Status,
1828   IN NDIS_HANDLE BindContext,
1829   IN PNDIS_STRING DeviceName,
1830   IN PVOID SystemSpecific1,
1831   IN PVOID SystemSpecific2);
1832 
1833 typedef VOID
1834 (NTAPI *UNBIND_HANDLER)(
1835   OUT PNDIS_STATUS Status,
1836   IN NDIS_HANDLE ProtocolBindingContext,
1837   IN NDIS_HANDLE UnbindContext);
1838 
1839 typedef NDIS_STATUS
1840 (NTAPI *PNP_EVENT_HANDLER)(
1841   IN NDIS_HANDLE ProtocolBindingContext,
1842   IN PNET_PNP_EVENT NetPnPEvent);
1843 
1844 typedef VOID
1845 (NTAPI *UNLOAD_PROTOCOL_HANDLER)(
1846   VOID);
1847 
1848 /* Protocol characteristics for NDIS 4.0 protocols */
1849 
1850 typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS {
1851   UCHAR MajorNdisVersion;
1852   UCHAR MinorNdisVersion;
1853   USHORT Filler;
1854   __MINGW_EXTENSION union {
1855     UINT Reserved;
1856     UINT Flags;
1857   };
1858   OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler;
1859   CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler;
1860   __MINGW_EXTENSION union {
1861     SEND_COMPLETE_HANDLER SendCompleteHandler;
1862     WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler;
1863   };
1864   __MINGW_EXTENSION union {
1865     TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler;
1866     WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler;
1867   };
1868   RESET_COMPLETE_HANDLER ResetCompleteHandler;
1869   REQUEST_COMPLETE_HANDLER RequestCompleteHandler;
1870   __MINGW_EXTENSION union {
1871     RECEIVE_HANDLER ReceiveHandler;
1872     WAN_RECEIVE_HANDLER WanReceiveHandler;
1873   };
1874   RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler;
1875   STATUS_HANDLER StatusHandler;
1876   STATUS_COMPLETE_HANDLER StatusCompleteHandler;
1877   NDIS_STRING Name;
1878   RECEIVE_PACKET_HANDLER ReceivePacketHandler;
1879   BIND_HANDLER BindAdapterHandler;
1880   UNBIND_HANDLER UnbindAdapterHandler;
1881   PNP_EVENT_HANDLER PnPEventHandler;
1882   UNLOAD_PROTOCOL_HANDLER UnloadHandler;
1883 } NDIS40_PROTOCOL_CHARACTERISTICS;
1884 
1885 typedef VOID
1886 (NTAPI PROTCOL_CO_AF_REGISTER_NOTIFY)(
1887   IN NDIS_HANDLE ProtocolBindingContext,
1888   IN PCO_ADDRESS_FAMILY AddressFamily);
1889 typedef PROTCOL_CO_AF_REGISTER_NOTIFY *CO_AF_REGISTER_NOTIFY_HANDLER;
1890 
1891 #if NDIS_LEGACY_PROTOCOL
1892 
1893 typedef struct _NDIS50_PROTOCOL_CHARACTERISTICS {
1894 #ifdef __cplusplus
1895   NDIS40_PROTOCOL_CHARACTERISTICS Ndis40Chars;
1896 #else
1897   NDIS40_PROTOCOL_CHARACTERISTICS;
1898 #endif
1899   PVOID ReservedHandlers[4];
1900   CO_SEND_COMPLETE_HANDLER CoSendCompleteHandler;
1901   CO_STATUS_HANDLER CoStatusHandler;
1902   CO_RECEIVE_PACKET_HANDLER CoReceivePacketHandler;
1903   CO_AF_REGISTER_NOTIFY_HANDLER CoAfRegisterNotifyHandler;
1904 } NDIS50_PROTOCOL_CHARACTERISTICS;
1905 
1906 #if (defined(NDIS50) || defined(NDIS51))
1907 typedef NDIS50_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS;
1908 #else
1909 typedef NDIS40_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS;
1910 #endif
1911 
1912 typedef NDIS_PROTOCOL_CHARACTERISTICS *PNDIS_PROTOCOL_CHARACTERISTICS;
1913 
1914 #endif /* NDIS_LEGACY_PROTOCOL */
1915 
1916 /* Prototypes for NDIS_MINIPORT_CHARACTERISTICS */
1917 
1918 typedef BOOLEAN
1919 (NTAPI *W_CHECK_FOR_HANG_HANDLER)(
1920   _In_ NDIS_HANDLE MiniportAdapterContext);
1921 
1922 typedef VOID
1923 (NTAPI *W_DISABLE_INTERRUPT_HANDLER)(
1924   _In_ NDIS_HANDLE MiniportAdapterContext);
1925 
1926 typedef VOID
1927 (NTAPI *W_ENABLE_INTERRUPT_HANDLER)(
1928   _In_ NDIS_HANDLE MiniportAdapterContext);
1929 
1930 typedef VOID
1931 (NTAPI *W_HALT_HANDLER)(
1932   _In_ NDIS_HANDLE MiniportAdapterContext);
1933 
1934 typedef VOID
1935 (NTAPI *W_HANDLE_INTERRUPT_HANDLER)(
1936   _In_ NDIS_HANDLE MiniportAdapterContext);
1937 
1938 typedef NDIS_STATUS
1939 (NTAPI *W_INITIALIZE_HANDLER)(
1940   _Out_ PNDIS_STATUS OpenErrorStatus,
1941   _Out_ PUINT SelectedMediumIndex,
1942   _In_ PNDIS_MEDIUM MediumArray,
1943   _In_ UINT MediumArraySize,
1944   _In_ NDIS_HANDLE MiniportAdapterContext,
1945   _In_ NDIS_HANDLE WrapperConfigurationContext);
1946 
1947 typedef VOID
1948 (NTAPI *W_ISR_HANDLER)(
1949   _Out_ PBOOLEAN InterruptRecognized,
1950   _Out_ PBOOLEAN QueueMiniportHandleInterrupt,
1951   _In_ NDIS_HANDLE MiniportAdapterContext);
1952 
1953 typedef NDIS_STATUS
1954 (NTAPI *W_QUERY_INFORMATION_HANDLER)(
1955   _In_ NDIS_HANDLE MiniportAdapterContext,
1956   _In_ NDIS_OID Oid,
1957   _In_ PVOID InformationBuffer,
1958   _In_ ULONG InformationBufferLength,
1959   _Out_ PULONG BytesWritten,
1960   _Out_ PULONG BytesNeeded);
1961 
1962 typedef NDIS_STATUS
1963 (NTAPI *W_RECONFIGURE_HANDLER)(
1964   _Out_ PNDIS_STATUS OpenErrorStatus,
1965   _In_ NDIS_HANDLE MiniportAdapterContext,
1966   _In_ NDIS_HANDLE WrapperConfigurationContext);
1967 
1968 typedef NDIS_STATUS
1969 (NTAPI *W_RESET_HANDLER)(
1970   _Out_ PBOOLEAN AddressingReset,
1971   _In_ NDIS_HANDLE MiniportAdapterContext);
1972 
1973 typedef NDIS_STATUS
1974 (NTAPI *W_SEND_HANDLER)(
1975   _In_ NDIS_HANDLE MiniportAdapterContext,
1976   _In_ PNDIS_PACKET Packet,
1977   _In_ UINT Flags);
1978 
1979 typedef NDIS_STATUS
1980 (NTAPI *WM_SEND_HANDLER)(
1981   _In_ NDIS_HANDLE MiniportAdapterContext,
1982   _In_ NDIS_HANDLE NdisLinkHandle,
1983   _In_ PNDIS_WAN_PACKET Packet);
1984 
1985 typedef NDIS_STATUS
1986 (NTAPI *W_SET_INFORMATION_HANDLER)(
1987   _In_ NDIS_HANDLE MiniportAdapterContext,
1988   _In_ NDIS_OID Oid,
1989   _In_ PVOID InformationBuffer,
1990   _In_ ULONG InformationBufferLength,
1991   _Out_ PULONG BytesRead,
1992   _Out_ PULONG BytesNeeded);
1993 
1994 typedef NDIS_STATUS
1995 (NTAPI *W_TRANSFER_DATA_HANDLER)(
1996   _Out_ PNDIS_PACKET Packet,
1997   _Out_ PUINT BytesTransferred,
1998   _In_ NDIS_HANDLE MiniportAdapterContext,
1999   _In_ NDIS_HANDLE MiniportReceiveContext,
2000   _In_ UINT ByteOffset,
2001   _In_ UINT BytesToTransfer);
2002 
2003 typedef NDIS_STATUS
2004 (NTAPI *WM_TRANSFER_DATA_HANDLER)(VOID);
2005 
2006 typedef VOID
2007 (NTAPI *ADAPTER_SHUTDOWN_HANDLER)(
2008   _In_ PVOID ShutdownContext);
2009 
2010 typedef VOID
2011 (NTAPI *W_RETURN_PACKET_HANDLER)(
2012   _In_ NDIS_HANDLE MiniportAdapterContext,
2013   _In_ PNDIS_PACKET Packet);
2014 
2015 typedef VOID
2016 (NTAPI *W_SEND_PACKETS_HANDLER)(
2017   _In_ NDIS_HANDLE MiniportAdapterContext,
2018   _In_ PPNDIS_PACKET PacketArray,
2019   _In_ UINT NumberOfPackets);
2020 
2021 typedef VOID
2022 (NTAPI *W_ALLOCATE_COMPLETE_HANDLER)(
2023   _In_ NDIS_HANDLE MiniportAdapterContext,
2024   _In_ PVOID VirtualAddress,
2025   _In_ PNDIS_PHYSICAL_ADDRESS PhysicalAddress,
2026   _In_ ULONG Length,
2027   _In_ PVOID Context);
2028 
2029 /* NDIS structures available only to miniport drivers */
2030 
2031 #define NDIS30_MINIPORT_CHARACTERISTICS_S \
2032   UCHAR  MajorNdisVersion; \
2033   UCHAR  MinorNdisVersion; \
2034   UINT  Reserved; \
2035   W_CHECK_FOR_HANG_HANDLER  CheckForHangHandler; \
2036   W_DISABLE_INTERRUPT_HANDLER  DisableInterruptHandler; \
2037   W_ENABLE_INTERRUPT_HANDLER  EnableInterruptHandler; \
2038   W_HALT_HANDLER  HaltHandler; \
2039   W_HANDLE_INTERRUPT_HANDLER  HandleInterruptHandler; \
2040   W_INITIALIZE_HANDLER  InitializeHandler; \
2041   W_ISR_HANDLER  ISRHandler; \
2042   W_QUERY_INFORMATION_HANDLER  QueryInformationHandler; \
2043   W_RECONFIGURE_HANDLER  ReconfigureHandler; \
2044   W_RESET_HANDLER  ResetHandler; \
2045   W_SEND_HANDLER  SendHandler; \
2046   W_SET_INFORMATION_HANDLER  SetInformationHandler; \
2047   W_TRANSFER_DATA_HANDLER  TransferDataHandler;
2048 
2049 typedef struct _NDIS30_MINIPORT_CHARACTERISTICS {
2050   NDIS30_MINIPORT_CHARACTERISTICS_S
2051 } NDIS30_MINIPORT_CHARACTERISTICS, *PSNDIS30_MINIPORT_CHARACTERISTICS;
2052 
2053 #ifdef __cplusplus
2054 
2055 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
2056   NDIS30_MINIPORT_CHARACTERISTICS  Ndis30Chars; \
2057   W_RETURN_PACKET_HANDLER  ReturnPacketHandler; \
2058   W_SEND_PACKETS_HANDLER  SendPacketsHandler; \
2059   W_ALLOCATE_COMPLETE_HANDLER  AllocateCompleteHandler;
2060 
2061 #else /* !__cplusplus */
2062 
2063 #define NDIS40_MINIPORT_CHARACTERISTICS_S \
2064   NDIS30_MINIPORT_CHARACTERISTICS_S \
2065   W_RETURN_PACKET_HANDLER  ReturnPacketHandler; \
2066   W_SEND_PACKETS_HANDLER  SendPacketsHandler; \
2067   W_ALLOCATE_COMPLETE_HANDLER  AllocateCompleteHandler;
2068 
2069 #endif /* !__cplusplus */
2070 
2071 typedef struct _NDIS40_MINIPORT_CHARACTERISTICS {
2072   NDIS40_MINIPORT_CHARACTERISTICS_S
2073 } NDIS40_MINIPORT_CHARACTERISTICS, *PNDIS40_MINIPORT_CHARACTERISTICS;
2074 
2075 /* Extensions for NDIS 5.0 miniports */
2076 
2077 _IRQL_requires_max_(DISPATCH_LEVEL)
2078 _Function_class_(MINIPORT_CO_CREATE_VC)
2079 typedef NDIS_STATUS
2080 (NTAPI MINIPORT_CO_CREATE_VC)(
2081   _In_ NDIS_HANDLE MiniportAdapterContext,
2082   _In_ NDIS_HANDLE NdisVcHandle,
2083   _Out_ PNDIS_HANDLE MiniportVcContext);
2084 typedef MINIPORT_CO_CREATE_VC *W_CO_CREATE_VC_HANDLER;
2085 
2086 _IRQL_requires_max_(DISPATCH_LEVEL)
2087 _Function_class_(MINIPORT_CO_DELETE_VC)
2088 typedef NDIS_STATUS
2089 (NTAPI MINIPORT_CO_DELETE_VC)(
2090   _In_ NDIS_HANDLE MiniportVcContext);
2091 typedef MINIPORT_CO_DELETE_VC *W_CO_DELETE_VC_HANDLER;
2092 
2093 _IRQL_requires_max_(DISPATCH_LEVEL)
2094 _Function_class_(MINIPORT_CO_ACTIVATE_VC)
2095 typedef NDIS_STATUS
2096 (NTAPI MINIPORT_CO_ACTIVATE_VC)(
2097   _In_ NDIS_HANDLE MiniportVcContext,
2098   _Inout_ PCO_CALL_PARAMETERS CallParameters);
2099 typedef MINIPORT_CO_ACTIVATE_VC *W_CO_ACTIVATE_VC_HANDLER;
2100 
2101 _IRQL_requires_max_(DISPATCH_LEVEL)
2102 _Function_class_(MINIPORT_CO_DEACTIVATE_VC)
2103 typedef NDIS_STATUS
2104 (NTAPI MINIPORT_CO_DEACTIVATE_VC)(
2105   _In_ NDIS_HANDLE MiniportVcContext);
2106 typedef MINIPORT_CO_DEACTIVATE_VC *W_CO_DEACTIVATE_VC_HANDLER;
2107 
2108 typedef VOID
2109 (NTAPI *W_CO_SEND_PACKETS_HANDLER)(
2110   _In_ NDIS_HANDLE MiniportVcContext,
2111   _In_ PPNDIS_PACKET PacketArray,
2112   _In_ UINT NumberOfPackets);
2113 
2114 typedef NDIS_STATUS
2115 (NTAPI *W_CO_REQUEST_HANDLER)(
2116   _In_ NDIS_HANDLE MiniportAdapterContext,
2117   _In_opt_ NDIS_HANDLE MiniportVcContext,
2118   _Inout_ PNDIS_REQUEST NdisRequest);
2119 
2120 #ifdef __cplusplus
2121 
2122 #define NDIS50_MINIPORT_CHARACTERISTICS_S \
2123   NDIS40_MINIPORT_CHARACTERISTICS  Ndis40Chars; \
2124   W_CO_CREATE_VC_HANDLER  CoCreateVcHandler; \
2125   W_CO_DELETE_VC_HANDLER  CoDeleteVcHandler; \
2126   W_CO_ACTIVATE_VC_HANDLER  CoActivateVcHandler; \
2127   W_CO_DEACTIVATE_VC_HANDLER  CoDeactivateVcHandler; \
2128   W_CO_SEND_PACKETS_HANDLER  CoSendPacketsHandler; \
2129   W_CO_REQUEST_HANDLER  CoRequestHandler;
2130 
2131 #else /* !__cplusplus */
2132 
2133 #define NDIS50_MINIPORT_CHARACTERISTICS_S \
2134   NDIS40_MINIPORT_CHARACTERISTICS_S \
2135   W_CO_CREATE_VC_HANDLER  CoCreateVcHandler; \
2136   W_CO_DELETE_VC_HANDLER  CoDeleteVcHandler; \
2137   W_CO_ACTIVATE_VC_HANDLER  CoActivateVcHandler; \
2138   W_CO_DEACTIVATE_VC_HANDLER  CoDeactivateVcHandler; \
2139   W_CO_SEND_PACKETS_HANDLER  CoSendPacketsHandler; \
2140   W_CO_REQUEST_HANDLER  CoRequestHandler;
2141 
2142 #endif /* !__cplusplus */
2143 
2144 typedef struct _NDIS50_MINIPORT_CHARACTERISTICS {
2145    NDIS50_MINIPORT_CHARACTERISTICS_S
2146 } NDIS50_MINIPORT_CHARACTERISTICS, *PSNDIS50_MINIPORT_CHARACTERISTICS;
2147 
2148 /* Extensions for NDIS 5.1 miniports */
2149 
2150 typedef VOID
2151 (NTAPI *W_CANCEL_SEND_PACKETS_HANDLER)(
2152   _In_ NDIS_HANDLE MiniportAdapterContext,
2153   _In_ PVOID CancelId);
2154 
2155 typedef VOID
2156 (NTAPI *W_PNP_EVENT_NOTIFY_HANDLER)(
2157   _In_ NDIS_HANDLE MiniportAdapterContext,
2158   _In_ NDIS_DEVICE_PNP_EVENT PnPEvent,
2159   _In_ PVOID InformationBuffer,
2160   _In_ ULONG InformationBufferLength);
2161 
2162 typedef VOID
2163 (NTAPI *W_MINIPORT_SHUTDOWN_HANDLER)(
2164   _In_ PVOID ShutdownContext);
2165 
2166 #ifdef __cplusplus
2167 
2168 #define NDIS51_MINIPORT_CHARACTERISTICS_S \
2169   NDIS50_MINIPORT_CHARACTERISTICS  Ndis50Chars; \
2170   W_CANCEL_SEND_PACKETS_HANDLER  CancelSendPacketsHandler; \
2171   W_PNP_EVENT_NOTIFY_HANDLER  PnPEventNotifyHandler; \
2172   W_MINIPORT_SHUTDOWN_HANDLER  AdapterShutdownHandler; \
2173   PVOID Reserved1; \
2174   PVOID Reserved2; \
2175   PVOID Reserved3; \
2176   PVOID Reserved4;
2177 
2178 #else
2179 
2180 #define NDIS51_MINIPORT_CHARACTERISTICS_S \
2181   NDIS50_MINIPORT_CHARACTERISTICS_S \
2182   W_CANCEL_SEND_PACKETS_HANDLER  CancelSendPacketsHandler; \
2183   W_PNP_EVENT_NOTIFY_HANDLER  PnPEventNotifyHandler; \
2184   W_MINIPORT_SHUTDOWN_HANDLER  AdapterShutdownHandler; \
2185   PVOID Reserved1; \
2186   PVOID Reserved2; \
2187   PVOID Reserved3; \
2188   PVOID Reserved4;
2189 
2190 #endif
2191 
2192 typedef struct _NDIS51_MINIPORT_CHARACTERISTICS {
2193   NDIS51_MINIPORT_CHARACTERISTICS_S
2194 } NDIS51_MINIPORT_CHARACTERISTICS, *PSNDIS51_MINIPORT_CHARACTERISTICS;
2195 
2196 #if defined(NDIS51_MINIPORT)
2197 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2198   NDIS51_MINIPORT_CHARACTERISTICS_S
2199 } NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;
2200 #elif defined(NDIS50_MINIPORT)
2201 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2202   NDIS50_MINIPORT_CHARACTERISTICS_S
2203 } NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;
2204 #elif defined(NDIS40_MINIPORT)
2205 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2206   NDIS40_MINIPORT_CHARACTERISTICS_S
2207 } NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;
2208 #else /* NDIS30 */
2209 typedef struct _NDIS_MINIPORT_CHARACTERISTICS {
2210   NDIS30_MINIPORT_CHARACTERISTICS_S
2211 } NDIS_MINIPORT_CHARACTERISTICS, *PNDIS_MINIPORT_CHARACTERISTICS;
2212 #endif
2213 
2214 typedef struct _NDIS_MINIPORT_INTERRUPT {
2215   PKINTERRUPT InterruptObject;
2216   KSPIN_LOCK DpcCountLock;
2217   PVOID Reserved;
2218   W_ISR_HANDLER MiniportIsr;
2219   W_HANDLE_INTERRUPT_HANDLER MiniportDpc;
2220   KDPC InterruptDpc;
2221   PNDIS_MINIPORT_BLOCK Miniport;
2222   UCHAR DpcCount;
2223   BOOLEAN Filler1;
2224   KEVENT DpcsCompletedEvent;
2225   BOOLEAN SharedInterrupt;
2226   BOOLEAN IsrRequested;
2227 } NDIS_MINIPORT_INTERRUPT, *PNDIS_MINIPORT_INTERRUPT;
2228 
2229 /* Structures available only to full MAC drivers */
2230 
2231 typedef BOOLEAN
2232 (NTAPI *PNDIS_INTERRUPT_SERVICE)(
2233   IN PVOID  InterruptContext);
2234 
2235 typedef VOID
2236 (NTAPI *PNDIS_DEFERRED_PROCESSING)(
2237   IN PVOID  SystemSpecific1,
2238   IN PVOID  InterruptContext,
2239   IN PVOID  SystemSpecific2,
2240   IN PVOID  SystemSpecific3);
2241 
2242 typedef struct _NDIS_WRAPPER_HANDLE NDIS_WRAPPER_HANDLE, *PNDIS_WRAPPER_HANDLE;
2243 typedef struct _NDIS_PROTOCOL_BLOCK NDIS_PROTOCOL_BLOCK, *PNDIS_PROTOCOL_BLOCK;
2244 typedef struct _NDIS_OPEN_BLOCK NDIS_OPEN_BLOCK, *PNDIS_OPEN_BLOCK;
2245 typedef struct _NDIS_M_DRIVER_BLOCK NDIS_M_DRIVER_BLOCK, *PNDIS_M_DRIVER_BLOCK;
2246 typedef struct _NDIS_OFFLOAD NDIS_OFFLOAD, *PNDIS_OFFLOAD;
2247 typedef struct _NDIS_AF_LIST NDIS_AF_LIST, *PNDIS_AF_LIST;
2248 typedef struct _X_FILTER ETH_FILTER, *PETH_FILTER;
2249 #if NDIS_SUPPORT_NDIS6
2250 typedef USHORT NET_FRAME_TYPE, *PNET_FRAME_TYPE;
2251 #endif
2252 
2253 typedef struct _NDIS_MINIPORT_TIMER {
2254   KTIMER  Timer;
2255   KDPC  Dpc;
2256   PNDIS_TIMER_FUNCTION  MiniportTimerFunction;
2257   PVOID  MiniportTimerContext;
2258   PNDIS_MINIPORT_BLOCK  Miniport;
2259   struct _NDIS_MINIPORT_TIMER  *NextDeferredTimer;
2260 } NDIS_MINIPORT_TIMER, *PNDIS_MINIPORT_TIMER;
2261 
2262 typedef struct _NDIS_INTERRUPT {
2263   PKINTERRUPT  InterruptObject;
2264   KSPIN_LOCK  DpcCountLock;
2265   PNDIS_INTERRUPT_SERVICE  MacIsr;
2266   PNDIS_DEFERRED_PROCESSING  MacDpc;
2267   KDPC  InterruptDpc;
2268   PVOID  InterruptContext;
2269   UCHAR  DpcCount;
2270   BOOLEAN	 Removing;
2271   KEVENT  DpcsCompletedEvent;
2272 } NDIS_INTERRUPT, *PNDIS_INTERRUPT;
2273 
2274 
2275 typedef enum _NDIS_WORK_ITEM_TYPE {
2276   NdisWorkItemRequest,
2277   NdisWorkItemSend,
2278   NdisWorkItemReturnPackets,
2279   NdisWorkItemResetRequested,
2280   NdisWorkItemResetInProgress,
2281   NdisWorkItemHalt,
2282   NdisWorkItemSendLoopback,
2283   NdisWorkItemMiniportCallback,
2284   NdisMaxWorkItems
2285 } NDIS_WORK_ITEM_TYPE, *PNDIS_WORK_ITEM_TYPE;
2286 
2287 #define	NUMBER_OF_WORK_ITEM_TYPES         NdisMaxWorkItems
2288 #define	NUMBER_OF_SINGLE_WORK_ITEMS       6
2289 
2290 typedef struct _NDIS_MINIPORT_WORK_ITEM {
2291 	SINGLE_LIST_ENTRY  Link;
2292 	NDIS_WORK_ITEM_TYPE  WorkItemType;
2293 	PVOID  WorkItemContext;
2294 } NDIS_MINIPORT_WORK_ITEM, *PNDIS_MINIPORT_WORK_ITEM;
2295 
2296 struct _NDIS_WORK_ITEM;
2297 typedef VOID (NTAPI *NDIS_PROC)(struct _NDIS_WORK_ITEM *, PVOID);
2298 
2299 typedef struct _NDIS_WORK_ITEM {
2300   PVOID Context;
2301   NDIS_PROC Routine;
2302   UCHAR WrapperReserved[8*sizeof(PVOID)];
2303 } NDIS_WORK_ITEM, *PNDIS_WORK_ITEM;
2304 
2305 typedef struct _NDIS_BIND_PATHS {
2306 	UINT  Number;
2307 	NDIS_STRING  Paths[1];
2308 } NDIS_BIND_PATHS, *PNDIS_BIND_PATHS;
2309 
2310 
2311 typedef VOID
2312 (NTAPI *ETH_RCV_COMPLETE_HANDLER)(
2313   _In_ PETH_FILTER Filter);
2314 
2315 typedef VOID
2316 (NTAPI *ETH_RCV_INDICATE_HANDLER)(
2317   _In_ PETH_FILTER Filter,
2318   _In_ NDIS_HANDLE MacReceiveContext,
2319   _In_ PCHAR Address,
2320   _In_ PVOID HeaderBuffer,
2321   _In_ UINT HeaderBufferSize,
2322   _In_ PVOID LookaheadBuffer,
2323   _In_ UINT LookaheadBufferSize,
2324   _In_ UINT PacketSize);
2325 
2326 typedef VOID
2327 (NTAPI *FDDI_RCV_COMPLETE_HANDLER)(
2328   IN PFDDI_FILTER  Filter);
2329 
2330 typedef VOID
2331 (NTAPI *FDDI_RCV_INDICATE_HANDLER)(
2332   IN PFDDI_FILTER  Filter,
2333   IN NDIS_HANDLE  MacReceiveContext,
2334   IN PCHAR  Address,
2335   IN UINT  AddressLength,
2336   IN PVOID  HeaderBuffer,
2337   IN UINT  HeaderBufferSize,
2338   IN PVOID  LookaheadBuffer,
2339   IN UINT  LookaheadBufferSize,
2340   IN UINT  PacketSize);
2341 
2342 typedef VOID
2343 (NTAPI *FILTER_PACKET_INDICATION_HANDLER)(
2344   _In_ NDIS_HANDLE Miniport,
2345   _In_ PPNDIS_PACKET PacketArray,
2346   _In_ UINT NumberOfPackets);
2347 
2348 typedef VOID
2349 (NTAPI *TR_RCV_COMPLETE_HANDLER)(
2350   _In_ PTR_FILTER Filter);
2351 
2352 typedef VOID
2353 (NTAPI *TR_RCV_INDICATE_HANDLER)(
2354   _In_ PTR_FILTER Filter,
2355   _In_ NDIS_HANDLE MacReceiveContext,
2356   _In_ PVOID HeaderBuffer,
2357   _In_ UINT HeaderBufferSize,
2358   _In_ PVOID LookaheadBuffer,
2359   _In_ UINT LookaheadBufferSize,
2360   _In_ UINT PacketSize);
2361 
2362 typedef VOID
2363 (NTAPI *WAN_RCV_COMPLETE_HANDLER)(
2364   _In_ NDIS_HANDLE MiniportAdapterHandle,
2365   _In_ NDIS_HANDLE NdisLinkContext);
2366 
2367 typedef VOID
2368 (NTAPI *WAN_RCV_HANDLER)(
2369   _Out_ PNDIS_STATUS Status,
2370   _In_ NDIS_HANDLE MiniportAdapterHandle,
2371   _In_ NDIS_HANDLE NdisLinkContext,
2372   _In_ PUCHAR Packet,
2373   _In_ ULONG PacketSize);
2374 
2375 typedef VOID
2376 (FASTCALL *NDIS_M_DEQUEUE_WORK_ITEM)(
2377   IN PNDIS_MINIPORT_BLOCK  Miniport,
2378   IN NDIS_WORK_ITEM_TYPE  WorkItemType,
2379   OUT PVOID  *WorkItemContext);
2380 
2381 typedef NDIS_STATUS
2382 (FASTCALL *NDIS_M_QUEUE_NEW_WORK_ITEM)(
2383   IN PNDIS_MINIPORT_BLOCK  Miniport,
2384   IN NDIS_WORK_ITEM_TYPE  WorkItemType,
2385   IN PVOID  WorkItemContext);
2386 
2387 typedef NDIS_STATUS
2388 (FASTCALL *NDIS_M_QUEUE_WORK_ITEM)(
2389   IN PNDIS_MINIPORT_BLOCK  Miniport,
2390   IN NDIS_WORK_ITEM_TYPE  WorkItemType,
2391   IN PVOID  WorkItemContext);
2392 
2393 typedef VOID
2394 (NTAPI *NDIS_M_REQ_COMPLETE_HANDLER)(
2395   _In_ NDIS_HANDLE MiniportAdapterHandle,
2396   _In_ NDIS_STATUS Status);
2397 
2398 typedef VOID
2399 (NTAPI *NDIS_M_RESET_COMPLETE_HANDLER)(
2400   _In_ NDIS_HANDLE MiniportAdapterHandle,
2401   _In_ NDIS_STATUS Status,
2402   _In_ BOOLEAN AddressingReset);
2403 
2404 typedef VOID
2405 (NTAPI *NDIS_M_SEND_COMPLETE_HANDLER)(
2406   _In_ NDIS_HANDLE MiniportAdapterHandle,
2407   _In_ PNDIS_PACKET Packet,
2408   _In_ NDIS_STATUS Status);
2409 
2410 typedef VOID
2411 (NTAPI *NDIS_M_SEND_RESOURCES_HANDLER)(
2412   _In_ NDIS_HANDLE MiniportAdapterHandle);
2413 
2414 typedef BOOLEAN
2415 (FASTCALL *NDIS_M_START_SENDS)(
2416   _In_ PNDIS_MINIPORT_BLOCK Miniport);
2417 
2418 typedef VOID
2419 (NTAPI *NDIS_M_STATUS_HANDLER)(
2420   _In_ NDIS_HANDLE MiniportHandle,
2421   _In_ NDIS_STATUS GeneralStatus,
2422   _In_ PVOID StatusBuffer,
2423   _In_ UINT StatusBufferSize);
2424 
2425 typedef VOID
2426 (NTAPI *NDIS_M_STS_COMPLETE_HANDLER)(
2427   _In_ NDIS_HANDLE MiniportAdapterHandle);
2428 
2429 typedef VOID
2430 (NTAPI *NDIS_M_TD_COMPLETE_HANDLER)(
2431   _In_ NDIS_HANDLE MiniportAdapterHandle,
2432   _In_ PNDIS_PACKET Packet,
2433   _In_ NDIS_STATUS Status,
2434   _In_ UINT BytesTransferred);
2435 
2436 typedef VOID (NTAPI *NDIS_WM_SEND_COMPLETE_HANDLER)(
2437   _In_ NDIS_HANDLE MiniportAdapterHandle,
2438   _In_ PVOID Packet,
2439   _In_ NDIS_STATUS Status);
2440 
2441 
2442 #if ARCNET
2443 
2444 #define ARC_SEND_BUFFERS                  8
2445 #define ARC_HEADER_SIZE                   4
2446 
2447 typedef struct _NDIS_ARC_BUF {
2448   NDIS_HANDLE  ArcnetBufferPool;
2449   PUCHAR  ArcnetLookaheadBuffer;
2450   UINT  NumFree;
2451   ARC_BUFFER_LIST ArcnetBuffers[ARC_SEND_BUFFERS];
2452 } NDIS_ARC_BUF, *PNDIS_ARC_BUF;
2453 
2454 #endif /* ARCNET */
2455 
2456 typedef struct _NDIS_LOG {
2457   PNDIS_MINIPORT_BLOCK  Miniport;
2458   KSPIN_LOCK  LogLock;
2459   PIRP  Irp;
2460   UINT  TotalSize;
2461   UINT  CurrentSize;
2462   UINT  InPtr;
2463   UINT  OutPtr;
2464   UCHAR  LogBuf[1];
2465 } NDIS_LOG, *PNDIS_LOG;
2466 
2467 #if ARCNET
2468 #define FILTERDBS_ARCNET_S \
2469   PARC_FILTER  ArcDB;
2470 #else /* !ARCNET */
2471 #define FILTERDBS_ARCNET_S \
2472   PVOID  XXXDB;
2473 #endif /* !ARCNET */
2474 
2475 #define FILTERDBS_S \
2476   _ANONYMOUS_UNION union { \
2477     PETH_FILTER  EthDB; \
2478     PNULL_FILTER  NullDB; \
2479   } DUMMYUNIONNAME; \
2480   PTR_FILTER  TrDB; \
2481   PFDDI_FILTER  FddiDB; \
2482   FILTERDBS_ARCNET_S
2483 
2484 typedef struct _FILTERDBS {
2485   FILTERDBS_S
2486 } FILTERDBS, *PFILTERDBS;
2487 
2488 struct _NDIS_MINIPORT_BLOCK {
2489   NDIS_OBJECT_HEADER Header;
2490   PNDIS_MINIPORT_BLOCK  NextMiniport;
2491   PNDIS_M_DRIVER_BLOCK  DriverHandle;
2492   NDIS_HANDLE  MiniportAdapterContext;
2493   UNICODE_STRING  MiniportName;
2494   PNDIS_BIND_PATHS  BindPaths;
2495   NDIS_HANDLE  OpenQueue;
2496   REFERENCE  ShortRef;
2497   NDIS_HANDLE  DeviceContext;
2498   UCHAR  Padding1;
2499   UCHAR  LockAcquired;
2500   UCHAR  PmodeOpens;
2501   UCHAR  AssignedProcessor;
2502   KSPIN_LOCK  Lock;
2503   PNDIS_REQUEST  MediaRequest;
2504   PNDIS_MINIPORT_INTERRUPT  Interrupt;
2505   ULONG  Flags;
2506   ULONG  PnPFlags;
2507   LIST_ENTRY  PacketList;
2508   PNDIS_PACKET  FirstPendingPacket;
2509   PNDIS_PACKET  ReturnPacketsQueue;
2510   ULONG  RequestBuffer;
2511   PVOID  SetMCastBuffer;
2512   PNDIS_MINIPORT_BLOCK  PrimaryMiniport;
2513   PVOID  WrapperContext;
2514   PVOID  BusDataContext;
2515   ULONG  PnPCapabilities;
2516   PCM_RESOURCE_LIST  Resources;
2517   NDIS_TIMER  WakeUpDpcTimer;
2518   UNICODE_STRING  BaseName;
2519   UNICODE_STRING  SymbolicLinkName;
2520   ULONG  CheckForHangSeconds;
2521   USHORT  CFHangTicks;
2522   USHORT  CFHangCurrentTick;
2523   NDIS_STATUS  ResetStatus;
2524   NDIS_HANDLE  ResetOpen;
2525   FILTERDBS_S
2526   FILTER_PACKET_INDICATION_HANDLER  PacketIndicateHandler;
2527   NDIS_M_SEND_COMPLETE_HANDLER  SendCompleteHandler;
2528   NDIS_M_SEND_RESOURCES_HANDLER  SendResourcesHandler;
2529   NDIS_M_RESET_COMPLETE_HANDLER  ResetCompleteHandler;
2530   NDIS_MEDIUM  MediaType;
2531   ULONG  BusNumber;
2532   NDIS_INTERFACE_TYPE  BusType;
2533   NDIS_INTERFACE_TYPE  AdapterType;
2534   PDEVICE_OBJECT  DeviceObject;
2535   PDEVICE_OBJECT  PhysicalDeviceObject;
2536   PDEVICE_OBJECT  NextDeviceObject;
2537   PMAP_REGISTER_ENTRY  MapRegisters;
2538   PNDIS_AF_LIST  CallMgrAfList;
2539   PVOID  MiniportThread;
2540   PVOID  SetInfoBuf;
2541   USHORT  SetInfoBufLen;
2542   USHORT  MaxSendPackets;
2543   NDIS_STATUS  FakeStatus;
2544   PVOID  LockHandler;
2545   PUNICODE_STRING  pAdapterInstanceName;
2546   PNDIS_MINIPORT_TIMER  TimerQueue;
2547   UINT  MacOptions;
2548   PNDIS_REQUEST  PendingRequest;
2549   UINT  MaximumLongAddresses;
2550   UINT  MaximumShortAddresses;
2551   UINT  CurrentLookahead;
2552   UINT  MaximumLookahead;
2553   W_HANDLE_INTERRUPT_HANDLER  HandleInterruptHandler;
2554   W_DISABLE_INTERRUPT_HANDLER  DisableInterruptHandler;
2555   W_ENABLE_INTERRUPT_HANDLER  EnableInterruptHandler;
2556   W_SEND_PACKETS_HANDLER  SendPacketsHandler;
2557   NDIS_M_START_SENDS  DeferredSendHandler;
2558   ETH_RCV_INDICATE_HANDLER  EthRxIndicateHandler;
2559   TR_RCV_INDICATE_HANDLER  TrRxIndicateHandler;
2560   FDDI_RCV_INDICATE_HANDLER  FddiRxIndicateHandler;
2561   ETH_RCV_COMPLETE_HANDLER  EthRxCompleteHandler;
2562   TR_RCV_COMPLETE_HANDLER  TrRxCompleteHandler;
2563   FDDI_RCV_COMPLETE_HANDLER  FddiRxCompleteHandler;
2564   NDIS_M_STATUS_HANDLER  StatusHandler;
2565   NDIS_M_STS_COMPLETE_HANDLER  StatusCompleteHandler;
2566   NDIS_M_TD_COMPLETE_HANDLER  TDCompleteHandler;
2567   NDIS_M_REQ_COMPLETE_HANDLER  QueryCompleteHandler;
2568   NDIS_M_REQ_COMPLETE_HANDLER  SetCompleteHandler;
2569   NDIS_WM_SEND_COMPLETE_HANDLER  WanSendCompleteHandler;
2570   WAN_RCV_HANDLER  WanRcvHandler;
2571   WAN_RCV_COMPLETE_HANDLER  WanRcvCompleteHandler;
2572 #if defined(NDIS_WRAPPER)
2573   PNDIS_MINIPORT_BLOCK  NextGlobalMiniport;
2574   SINGLE_LIST_ENTRY  WorkQueue[NUMBER_OF_WORK_ITEM_TYPES];
2575   SINGLE_LIST_ENTRY  SingleWorkItems[NUMBER_OF_SINGLE_WORK_ITEMS];
2576   UCHAR  SendFlags;
2577   UCHAR  TrResetRing;
2578   UCHAR  ArcnetAddress;
2579   UCHAR  XState;
2580   _ANONYMOUS_UNION union {
2581 #if ARCNET
2582     PNDIS_ARC_BUF  ArcBuf;
2583 #endif
2584     PVOID  BusInterface;
2585   } DUMMYUNIONNAME;
2586   PNDIS_LOG  Log;
2587   ULONG  SlotNumber;
2588   PCM_RESOURCE_LIST  AllocatedResources;
2589   PCM_RESOURCE_LIST  AllocatedResourcesTranslated;
2590   SINGLE_LIST_ENTRY  PatternList;
2591   NDIS_PNP_CAPABILITIES  PMCapabilities;
2592   DEVICE_CAPABILITIES  DeviceCaps;
2593   ULONG  WakeUpEnable;
2594   DEVICE_POWER_STATE  CurrentDevicePowerState;
2595   PIRP  pIrpWaitWake;
2596   SYSTEM_POWER_STATE  WaitWakeSystemState;
2597   LARGE_INTEGER  VcIndex;
2598   KSPIN_LOCK  VcCountLock;
2599   LIST_ENTRY  WmiEnabledVcs;
2600   PNDIS_GUID  pNdisGuidMap;
2601   PNDIS_GUID  pCustomGuidMap;
2602   USHORT  VcCount;
2603   USHORT  cNdisGuidMap;
2604   USHORT  cCustomGuidMap;
2605   USHORT  CurrentMapRegister;
2606   PKEVENT  AllocationEvent;
2607   USHORT  BaseMapRegistersNeeded;
2608   USHORT  SGMapRegistersNeeded;
2609   ULONG  MaximumPhysicalMapping;
2610   NDIS_TIMER  MediaDisconnectTimer;
2611   USHORT  MediaDisconnectTimeOut;
2612   USHORT  InstanceNumber;
2613   NDIS_EVENT  OpenReadyEvent;
2614   NDIS_PNP_DEVICE_STATE  PnPDeviceState;
2615   NDIS_PNP_DEVICE_STATE  OldPnPDeviceState;
2616   PGET_SET_DEVICE_DATA  SetBusData;
2617   PGET_SET_DEVICE_DATA  GetBusData;
2618   KDPC  DeferredDpc;
2619 #if 0
2620   /* FIXME: */
2621   NDIS_STATS  NdisStats;
2622 #else
2623   ULONG  NdisStats;
2624 #endif
2625   PNDIS_PACKET  IndicatedPacket[MAXIMUM_PROCESSORS];
2626   PKEVENT  RemoveReadyEvent;
2627   PKEVENT  AllOpensClosedEvent;
2628   PKEVENT  AllRequestsCompletedEvent;
2629   ULONG  InitTimeMs;
2630   NDIS_MINIPORT_WORK_ITEM  WorkItemBuffer[NUMBER_OF_SINGLE_WORK_ITEMS];
2631   PDMA_ADAPTER  SystemAdapterObject;
2632   ULONG  DriverVerifyFlags;
2633   POID_LIST  OidList;
2634   USHORT  InternalResetCount;
2635   USHORT  MiniportResetCount;
2636   USHORT  MediaSenseConnectCount;
2637   USHORT  MediaSenseDisconnectCount;
2638   PNDIS_PACKET  *xPackets;
2639   ULONG  UserModeOpenReferences;
2640   _ANONYMOUS_UNION union {
2641     PVOID  SavedSendHandler;
2642     PVOID  SavedWanSendHandler;
2643   } DUMMYUNIONNAME2;
2644   PVOID  SavedSendPacketsHandler;
2645   PVOID  SavedCancelSendPacketsHandler;
2646   W_SEND_PACKETS_HANDLER  WSendPacketsHandler;
2647   ULONG  MiniportAttributes;
2648   PDMA_ADAPTER  SavedSystemAdapterObject;
2649   USHORT  NumOpens;
2650   USHORT  CFHangXTicks;
2651   ULONG  RequestCount;
2652   ULONG  IndicatedPacketsCount;
2653   ULONG  PhysicalMediumType;
2654   PNDIS_REQUEST  LastRequest;
2655   LONG  DmaAdapterRefCount;
2656   PVOID  FakeMac;
2657   ULONG  LockDbg;
2658   ULONG  LockDbgX;
2659   PVOID  LockThread;
2660   ULONG  InfoFlags;
2661   KSPIN_LOCK  TimerQueueLock;
2662   PKEVENT  ResetCompletedEvent;
2663   PKEVENT  QueuedBindingCompletedEvent;
2664   PKEVENT  DmaResourcesReleasedEvent;
2665   FILTER_PACKET_INDICATION_HANDLER  SavedPacketIndicateHandler;
2666   ULONG  RegisteredInterrupts;
2667   PNPAGED_LOOKASIDE_LIST  SGListLookasideList;
2668   ULONG  ScatterGatherListSize;
2669 #endif /* _NDIS_ */
2670 };
2671 
2672 #if NDIS_LEGACY_DRIVER
2673 
2674 typedef NDIS_STATUS
2675 (NTAPI *WAN_SEND_HANDLER)(
2676   _In_ NDIS_HANDLE MacBindingHandle,
2677   _In_ NDIS_HANDLE LinkHandle,
2678   _In_ PVOID Packet);
2679 
2680 typedef VOID
2681 (NTAPI *SEND_PACKETS_HANDLER)(
2682   _In_ NDIS_HANDLE MiniportAdapterContext,
2683   _In_ PPNDIS_PACKET PacketArray,
2684   _In_ UINT NumberOfPackets);
2685 
2686 typedef NDIS_STATUS
2687 (NTAPI *SEND_HANDLER)(
2688   _In_ NDIS_HANDLE NdisBindingHandle,
2689   _In_ PNDIS_PACKET Packet);
2690 
2691 typedef NDIS_STATUS
2692 (NTAPI *TRANSFER_DATA_HANDLER)(
2693   _In_ NDIS_HANDLE NdisBindingHandle,
2694   _In_ NDIS_HANDLE MacReceiveContext,
2695   _In_ UINT ByteOffset,
2696   _In_ UINT BytesToTransfer,
2697   _Out_ PNDIS_PACKET Packet,
2698   _Out_ PUINT BytesTransferred);
2699 
2700 typedef NDIS_STATUS
2701 (NTAPI *RESET_HANDLER)(
2702   _In_ NDIS_HANDLE NdisBindingHandle);
2703 
2704 typedef NDIS_STATUS
2705 (NTAPI *REQUEST_HANDLER)(
2706   _In_ NDIS_HANDLE NdisBindingHandle,
2707   _In_ PNDIS_REQUEST NdisRequest);
2708 
2709 #endif /* NDIS_LEGACY_DRIVER */
2710 
2711 #if defined(NDIS_WRAPPER)
2712 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S \
2713   ULONG Flags; \
2714   ULONG References; \
2715   KSPIN_LOCK SpinLock; \
2716   NDIS_HANDLE  FilterHandle; \
2717   ULONG  ProtocolOptions; \
2718   USHORT  CurrentLookahead; \
2719   USHORT  ConnectDampTicks; \
2720   USHORT  DisconnectDampTicks; \
2721   W_SEND_HANDLER  WSendHandler; \
2722   W_TRANSFER_DATA_HANDLER  WTransferDataHandler; \
2723   W_SEND_PACKETS_HANDLER  WSendPacketsHandler; \
2724   W_CANCEL_SEND_PACKETS_HANDLER  CancelSendPacketsHandler; \
2725   ULONG  WakeUpEnable; \
2726   PKEVENT  CloseCompleteEvent; \
2727   QUEUED_CLOSE  QC; \
2728   ULONG  AfReferences; \
2729   PNDIS_OPEN_BLOCK  NextGlobalOpen;
2730 #else
2731 #define NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
2732 #endif
2733 
2734 #define NDIS_COMMON_OPEN_BLOCK_S \
2735   PVOID  MacHandle; \
2736   NDIS_HANDLE  BindingHandle; \
2737   PNDIS_MINIPORT_BLOCK  MiniportHandle; \
2738   PNDIS_PROTOCOL_BLOCK  ProtocolHandle; \
2739   NDIS_HANDLE  ProtocolBindingContext; \
2740   PNDIS_OPEN_BLOCK  MiniportNextOpen; \
2741   PNDIS_OPEN_BLOCK  ProtocolNextOpen; \
2742   NDIS_HANDLE  MiniportAdapterContext; \
2743   BOOLEAN  Reserved1; \
2744   BOOLEAN  Reserved2; \
2745   BOOLEAN  Reserved3; \
2746   BOOLEAN  Reserved4; \
2747   PNDIS_STRING  BindDeviceName; \
2748   KSPIN_LOCK  Reserved5; \
2749   PNDIS_STRING  RootDeviceName; \
2750   _ANONYMOUS_UNION union { \
2751     SEND_HANDLER  SendHandler; \
2752     WAN_SEND_HANDLER  WanSendHandler; \
2753   } DUMMYUNIONNAME; \
2754   TRANSFER_DATA_HANDLER  TransferDataHandler; \
2755   SEND_COMPLETE_HANDLER  SendCompleteHandler; \
2756   TRANSFER_DATA_COMPLETE_HANDLER  TransferDataCompleteHandler; \
2757   RECEIVE_HANDLER  ReceiveHandler; \
2758   RECEIVE_COMPLETE_HANDLER  ReceiveCompleteHandler; \
2759   WAN_RECEIVE_HANDLER  WanReceiveHandler; \
2760   REQUEST_COMPLETE_HANDLER  RequestCompleteHandler; \
2761   RECEIVE_PACKET_HANDLER  ReceivePacketHandler; \
2762   SEND_PACKETS_HANDLER  SendPacketsHandler; \
2763   RESET_HANDLER  ResetHandler; \
2764   REQUEST_HANDLER  RequestHandler; \
2765   RESET_COMPLETE_HANDLER  ResetCompleteHandler; \
2766   STATUS_HANDLER  StatusHandler; \
2767   STATUS_COMPLETE_HANDLER  StatusCompleteHandler; \
2768   NDIS_COMMON_OPEN_BLOCK_WRAPPER_S
2769 
2770 typedef struct _NDIS_COMMON_OPEN_BLOCK {
2771   NDIS_COMMON_OPEN_BLOCK_S
2772 } NDIS_COMMON_OPEN_BLOCK;
2773 
2774 struct _NDIS_OPEN_BLOCK
2775 {
2776 #ifdef __cplusplus
2777   NDIS_COMMON_OPEN_BLOCK NdisCommonOpenBlock;
2778 #else
2779   NDIS_COMMON_OPEN_BLOCK_S
2780 #endif
2781 };
2782 
2783 #include <xfilter.h>
2784 
2785 #define NDIS_M_MAX_LOOKAHEAD           526
2786 
2787 _IRQL_requires_max_(DISPATCH_LEVEL)
2788 NDISAPI
2789 VOID
2790 NTAPI
2791 NdisInitializeTimer(
2792   _Inout_ PNDIS_TIMER Timer,
2793   _In_ PNDIS_TIMER_FUNCTION TimerFunction,
2794   _In_opt_ _Points_to_data_ PVOID FunctionContext);
2795 
2796 _IRQL_requires_max_(DISPATCH_LEVEL)
2797 NDISAPI
2798 VOID
2799 NTAPI
2800 NdisCancelTimer(
2801   _In_ PNDIS_TIMER Timer,
2802   _Out_ _At_(*TimerCancelled, _Must_inspect_result_) PBOOLEAN TimerCancelled);
2803 
2804 _IRQL_requires_max_(DISPATCH_LEVEL)
2805 NDISAPI
2806 VOID
2807 NTAPI
2808 NdisSetTimer(
2809   _In_ PNDIS_TIMER Timer,
2810   _In_ UINT MillisecondsToDelay);
2811 
2812 NDISAPI
2813 VOID
2814 NTAPI
2815 NdisSetPeriodicTimer(
2816   _In_ PNDIS_TIMER NdisTimer,
2817   _In_ UINT MillisecondsPeriod);
2818 
2819 _IRQL_requires_max_(DISPATCH_LEVEL)
2820 NDISAPI
2821 VOID
2822 NTAPI
2823 NdisSetTimerEx(
2824   _In_ PNDIS_TIMER NdisTimer,
2825   _In_ UINT MillisecondsToDelay,
2826   _In_ PVOID FunctionContext);
2827 
2828 _IRQL_requires_(PASSIVE_LEVEL)
2829 NDISAPI
2830 PVOID
2831 NTAPI
2832 NdisGetRoutineAddress(
2833   _In_ PNDIS_STRING NdisRoutineName);
2834 
2835 _IRQL_requires_max_(DISPATCH_LEVEL)
2836 NDISAPI
2837 UINT
2838 NTAPI
2839 NdisGetVersion(VOID);
2840 
2841 #if NDIS_LEGACY_DRIVER
2842 
2843 _IRQL_requires_max_(DISPATCH_LEVEL)
2844 NDISAPI
2845 VOID
2846 NTAPI
2847 NdisAllocateBuffer(
2848   _Out_ PNDIS_STATUS Status,
2849   _Out_ PNDIS_BUFFER *Buffer,
2850   _In_opt_ NDIS_HANDLE PoolHandle,
2851   _In_reads_bytes_(Length) PVOID VirtualAddress,
2852   _In_ UINT Length);
2853 
2854 _IRQL_requires_max_(DISPATCH_LEVEL)
2855 NDISAPI
2856 VOID
2857 NTAPI
2858 NdisAllocateBufferPool(
2859   _Out_ PNDIS_STATUS Status,
2860   _Out_ PNDIS_HANDLE PoolHandle,
2861   _In_ UINT NumberOfDescriptors);
2862 
2863 _IRQL_requires_max_(DISPATCH_LEVEL)
2864 NDISAPI
2865 VOID
2866 NTAPI
2867 NdisFreeBufferPool(
2868   _In_ NDIS_HANDLE PoolHandle);
2869 
2870 /*
2871 NDISAPI
2872 VOID
2873 NTAPI
2874 NdisFreeBuffer(
2875   IN PNDIS_BUFFER Buffer);
2876 */
2877 #define NdisFreeBuffer IoFreeMdl
2878 
2879 _IRQL_requires_max_(DISPATCH_LEVEL)
2880 NDISAPI
2881 VOID
2882 NTAPI
2883 NdisAllocatePacketPool(
2884   _Out_ PNDIS_STATUS Status,
2885   _Out_ PNDIS_HANDLE PoolHandle,
2886   _In_ UINT NumberOfDescriptors,
2887   _In_ UINT ProtocolReservedLength);
2888 
2889 _IRQL_requires_max_(DISPATCH_LEVEL)
2890 NDISAPI
2891 VOID
2892 NTAPI
2893 NdisAllocatePacketPoolEx(
2894   _Out_ PNDIS_STATUS Status,
2895   _Out_ PNDIS_HANDLE PoolHandle,
2896   _In_ UINT NumberOfDescriptors,
2897   _In_ UINT NumberOfOverflowDescriptors,
2898   _In_ UINT ProtocolReservedLength);
2899 
2900 _IRQL_requires_max_(DISPATCH_LEVEL)
2901 NDISAPI
2902 VOID
2903 NTAPI
2904 NdisSetPacketPoolProtocolId(
2905   _In_ NDIS_HANDLE PacketPoolHandle,
2906   _In_ UINT ProtocolId);
2907 
2908 _IRQL_requires_max_(DISPATCH_LEVEL)
2909 NDISAPI
2910 UINT
2911 NTAPI
2912 NdisPacketPoolUsage(
2913   _In_ NDIS_HANDLE PoolHandle);
2914 
2915 _IRQL_requires_max_(DISPATCH_LEVEL)
2916 NDISAPI
2917 UINT
2918 NTAPI
2919 NdisPacketSize(
2920   _In_ UINT ProtocolReservedSize);
2921 
2922 _IRQL_requires_max_(DISPATCH_LEVEL)
2923 NDISAPI
2924 NDIS_HANDLE
2925 NTAPI
2926 NdisGetPoolFromPacket(
2927   _In_ PNDIS_PACKET Packet);
2928 
2929 _IRQL_requires_max_(DISPATCH_LEVEL)
2930 NDISAPI
2931 PNDIS_PACKET_STACK
2932 NTAPI
2933 NdisIMGetCurrentPacketStack(
2934   _In_ PNDIS_PACKET Packet,
2935   _Out_ BOOLEAN *StacksRemaining);
2936 
2937 _IRQL_requires_max_(DISPATCH_LEVEL)
2938 NDISAPI
2939 VOID
2940 NTAPI
2941 NdisFreePacketPool(
2942   _In_ NDIS_HANDLE PoolHandle);
2943 
2944 _IRQL_requires_max_(DISPATCH_LEVEL)
2945 NDISAPI
2946 VOID
2947 NTAPI
2948 NdisFreePacket(
2949   _In_ PNDIS_PACKET Packet);
2950 
2951 _IRQL_requires_(DISPATCH_LEVEL)
2952 NDISAPI
2953 VOID
2954 NTAPI
2955 NdisDprFreePacket(
2956   _In_ PNDIS_PACKET Packet);
2957 
2958 _IRQL_requires_(DISPATCH_LEVEL)
2959 NDISAPI
2960 VOID
2961 NTAPI
2962 NdisDprFreePacketNonInterlocked(
2963   _In_ PNDIS_PACKET Packet);
2964 
2965 _IRQL_requires_max_(DISPATCH_LEVEL)
2966 NDISAPI
2967 VOID
2968 NTAPI
2969 NdisAllocatePacket(
2970   _Out_ PNDIS_STATUS Status,
2971   _Out_ PNDIS_PACKET *Packet,
2972   _In_ NDIS_HANDLE PoolHandle);
2973 
2974 _IRQL_requires_(DISPATCH_LEVEL)
2975 NDISAPI
2976 VOID
2977 NTAPI
2978 NdisDprAllocatePacket(
2979   _Out_ PNDIS_STATUS Status,
2980   _Out_ PNDIS_PACKET *Packet,
2981   _In_ NDIS_HANDLE PoolHandle);
2982 
2983 _IRQL_requires_(DISPATCH_LEVEL)
2984 NDISAPI
2985 VOID
2986 NTAPI
2987 NdisDprAllocatePacketNonInterlocked(
2988   _Out_ PNDIS_STATUS Status,
2989   _Out_ PNDIS_PACKET *Packet,
2990   _In_ NDIS_HANDLE PoolHandle);
2991 
2992 /*
2993  * VOID
2994  * NdisReinitializePacket(
2995  *   IN OUT  PNDIS_PACKET  Packet);
2996  */
2997 #define NdisReinitializePacket(Packet) {        \
2998   (Packet)->Private.Head = (PNDIS_BUFFER)NULL;  \
2999   (Packet)->Private.ValidCounts = FALSE;        \
3000 }
3001 
3002 /*
3003 NDISAPI
3004 VOID
3005 NTAPI
3006 NdisQueryBuffer(
3007   IN PNDIS_BUFFER Buffer,
3008   OUT PVOID *VirtualAddress OPTIONAL,
3009   OUT PUINT Length);
3010 */
3011 #define NdisQueryBuffer(_Buffer, _VirtualAddress, _Length) {         \
3012   if (ARGUMENT_PRESENT(_VirtualAddress)) {                           \
3013     *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdl(_Buffer); \
3014   }                                                                  \
3015   *(_Length) = MmGetMdlByteCount(_Buffer);                           \
3016 }
3017 
3018 NDISAPI
3019 VOID
3020 NTAPI
3021 NdisGetFirstBufferFromPacket(
3022   IN PNDIS_PACKET _Packet,
3023   OUT PNDIS_BUFFER *_FirstBuffer,
3024   OUT PVOID *_FirstBufferVA,
3025   OUT PUINT _FirstBufferLength,
3026   OUT PUINT _TotalBufferLength);
3027 
3028 /*
3029  * VOID
3030  * NdisGetFirstBufferFromPacketSafe(
3031  * IN PNDIS_PACKET _Packet,
3032  * OUT PNDIS_BUFFER * _FirstBuffer,
3033  * OUT PVOID * _FirstBufferVA,
3034  * OUT PUINT _FirstBufferLength,
3035  * OUT PUINT _TotalBufferLength),
3036  * IN MM_PAGE_PRIORITY _Priority)
3037  */
3038 #define NdisGetFirstBufferFromPacketSafe(_Packet,                             \
3039                                      _FirstBuffer,                            \
3040                                      _FirstBufferVA,                          \
3041                                      _FirstBufferLength,                      \
3042                                      _TotalBufferLength,                      \
3043                                      _Priority)                               \
3044 {                                                                             \
3045   PNDIS_BUFFER _Buffer;                                                       \
3046                                                                               \
3047   _Buffer         = (_Packet)->Private.Head;                                  \
3048   *(_FirstBuffer) = _Buffer;                                                  \
3049   if (_Buffer != NULL) {                                                      \
3050     *(_FirstBufferVA)     = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
3051     *(_FirstBufferLength) = MmGetMdlByteCount(_Buffer);                       \
3052     _Buffer = _Buffer->Next;                                                  \
3053     *(_TotalBufferLength) = *(_FirstBufferLength);                            \
3054     while (_Buffer != NULL) {                                                 \
3055       *(_TotalBufferLength) += MmGetMdlByteCount(_Buffer);                    \
3056       _Buffer = _Buffer->Next;                                                \
3057     }                                                                         \
3058   }                                                                           \
3059   else {                                                                      \
3060     *(_FirstBufferVA) = 0;                                                    \
3061     *(_FirstBufferLength) = 0;                                                \
3062     *(_TotalBufferLength) = 0;                                                \
3063   }                                                                           \
3064 }
3065 
3066 /*
3067  * VOID
3068  * NdisRecalculatePacketCounts(
3069  *   IN OUT PNDIS_PACKET Packet);
3070  */
3071 #define NdisRecalculatePacketCounts(Packet) {     \
3072   PNDIS_BUFFER _Buffer = (Packet)->Private.Head;  \
3073   if (_Buffer != NULL) {                          \
3074     while (_Buffer->Next != NULL) {               \
3075       _Buffer = _Buffer->Next;                    \
3076     }                                             \
3077     (Packet)->Private.Tail = _Buffer;             \
3078   }                                               \
3079   (Packet)->Private.ValidCounts = FALSE;          \
3080 }
3081 
3082 /*
3083  * VOID
3084  * NdisChainBufferAtFront(
3085  *   IN OUT PNDIS_PACKET Packet,
3086  *   IN OUT PNDIS_BUFFER Buffer)
3087  */
3088 #define NdisChainBufferAtFront(Packet,        \
3089                                Buffer)        \
3090 {                                             \
3091   PNDIS_BUFFER _NdisBuffer = (Buffer);        \
3092                                               \
3093   while (_NdisBuffer->Next != NULL)           \
3094     _NdisBuffer = _NdisBuffer->Next;          \
3095                                               \
3096   if ((Packet)->Private.Head == NULL)         \
3097     (Packet)->Private.Tail = _NdisBuffer;     \
3098                                               \
3099   _NdisBuffer->Next = (Packet)->Private.Head; \
3100   (Packet)->Private.Head = (Buffer);          \
3101   (Packet)->Private.ValidCounts = FALSE;      \
3102 }
3103 
3104 /*
3105  * VOID
3106  * NdisChainBufferAtBack(
3107  *   IN OUT PNDIS_PACKET Packet,
3108  *   IN OUT PNDIS_BUFFER Buffer)
3109  */
3110 #define NdisChainBufferAtBack(Packet,           \
3111                               Buffer)           \
3112 {                                               \
3113   PNDIS_BUFFER _NdisBuffer = (Buffer);           \
3114                                                 \
3115   while (_NdisBuffer->Next != NULL)              \
3116     _NdisBuffer = _NdisBuffer->Next;              \
3117                                                 \
3118   _NdisBuffer->Next = NULL;                      \
3119                                                 \
3120   if ((Packet)->Private.Head != NULL)           \
3121     (Packet)->Private.Tail->Next = (Buffer);    \
3122   else                                          \
3123     (Packet)->Private.Head = (Buffer);          \
3124                                                 \
3125   (Packet)->Private.Tail = _NdisBuffer;          \
3126   (Packet)->Private.ValidCounts = FALSE;        \
3127 }
3128 
3129 NDISAPI
3130 VOID
3131 NTAPI
3132 NdisUnchainBufferAtFront(
3133   IN OUT PNDIS_PACKET Packet,
3134   OUT PNDIS_BUFFER *Buffer);
3135 
3136 NDISAPI
3137 VOID
3138 NTAPI
3139 NdisUnchainBufferAtBack(
3140   IN OUT PNDIS_PACKET Packet,
3141   OUT PNDIS_BUFFER *Buffer);
3142 
3143 _IRQL_requires_max_(DISPATCH_LEVEL)
3144 NDISAPI
3145 VOID
3146 NTAPI
3147 NdisCopyFromPacketToPacket(
3148   _In_ PNDIS_PACKET Destination,
3149   _In_ UINT DestinationOffset,
3150   _In_ UINT BytesToCopy,
3151   _In_ PNDIS_PACKET Source,
3152   _In_ UINT SourceOffset,
3153   _Out_ PUINT BytesCopied);
3154 
3155 NDISAPI
3156 VOID
3157 NTAPI
3158 NdisCopyFromPacketToPacketSafe(
3159   IN PNDIS_PACKET Destination,
3160   IN UINT DestinationOffset,
3161   IN UINT BytesToCopy,
3162   IN PNDIS_PACKET Source,
3163   IN UINT SourceOffset,
3164   OUT PUINT BytesCopied,
3165   IN MM_PAGE_PRIORITY Priority);
3166 
3167 _IRQL_requires_max_(DISPATCH_LEVEL)
3168 __drv_preferredFunction("NdisAllocateMemoryWithTag", "Obsolete")
3169 NDISAPI
3170 NDIS_STATUS
3171 NTAPI
3172 NdisAllocateMemory(
3173   _At_(*VirtualAddress, __drv_allocatesMem(Mem)) _Outptr_result_bytebuffer_(Length)
3174     PVOID *VirtualAddress,
3175   _In_ UINT Length,
3176   _In_ UINT MemoryFlags,
3177   _In_ NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress);
3178 
3179 #define NdisInitializeWorkItem(_WI_, _R_, _C_) { \
3180   (_WI_)->Context = _C_;                         \
3181   (_WI_)->Routine = _R_;                         \
3182 }
3183 
3184 _IRQL_requires_max_(DISPATCH_LEVEL)
3185 NDISAPI
3186 NDIS_STATUS
3187 NTAPI
3188 NdisScheduleWorkItem(
3189   _In_ __drv_aliasesMem PNDIS_WORK_ITEM WorkItem);
3190 
3191 _IRQL_requires_max_(DISPATCH_LEVEL)
3192 NDISAPI
3193 VOID
3194 NTAPI
3195 NdisSetPacketStatus(
3196   _In_ PNDIS_PACKET Packet,
3197   _In_ NDIS_STATUS Status,
3198   _In_ NDIS_HANDLE Handle,
3199   _In_ ULONG Code);
3200 
3201 #endif /* NDIS_LEGACY_DRIVER */
3202 
3203 _IRQL_requires_(PASSIVE_LEVEL)
3204 NDISAPI
3205 VOID
3206 NTAPI
3207 NdisOpenFile(
3208   _Out_ PNDIS_STATUS Status,
3209   _Out_ PNDIS_HANDLE FileHandle,
3210   _Out_ PUINT FileLength,
3211   _In_ PNDIS_STRING FileName,
3212   _In_ NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress);
3213 
3214 _IRQL_requires_(PASSIVE_LEVEL)
3215 NDISAPI
3216 VOID
3217 NTAPI
3218 NdisCloseFile(
3219   _In_ NDIS_HANDLE FileHandle);
3220 
3221 _IRQL_requires_max_(DISPATCH_LEVEL)
3222 NDISAPI
3223 VOID
3224 NTAPI
3225 NdisMapFile(
3226   _Out_ PNDIS_STATUS Status,
3227   _Out_ PVOID *MappedBuffer,
3228   _In_ NDIS_HANDLE FileHandle);
3229 
3230 _IRQL_requires_(PASSIVE_LEVEL)
3231 NDISAPI
3232 VOID
3233 NTAPI
3234 NdisUnmapFile(
3235   _In_ NDIS_HANDLE FileHandle);
3236 
3237 _IRQL_requires_max_(DISPATCH_LEVEL)
3238 NDISAPI
3239 ULONG
3240 NTAPI
3241 NdisGetSharedDataAlignment(VOID);
3242 
3243 #define NdisFlushBuffer(Buffer,WriteToDevice) \
3244   KeFlushIoBuffers((Buffer),!(WriteToDevice), TRUE)
3245 
3246 _IRQL_requires_max_(DISPATCH_LEVEL)
3247 NDISAPI
3248 VOID
3249 NTAPI
3250 NdisCopyBuffer(
3251   _Out_ PNDIS_STATUS Status,
3252   _Out_ PNDIS_BUFFER *Buffer,
3253   _In_ NDIS_HANDLE PoolHandle,
3254   _In_ PVOID MemoryDescriptor,
3255   _In_ UINT Offset,
3256   _In_ UINT Length);
3257 
3258 /*
3259  * VOID
3260  * NdisCopyLookaheadData(
3261  *   IN PVOID Destination,
3262  *   IN PVOID Source,
3263  *   IN ULONG Length,
3264  *   IN ULONG ReceiveFlags);
3265  */
3266 
3267 #if defined(_M_IX86) || defined(_M_AMD64)
3268 #define NdisCopyLookaheadData(Destination, Source, Length, MacOptions) \
3269   RtlCopyMemory(Destination, Source, Length)
3270 #else
3271 #define NdisCopyLookaheadData(Destination, Source, Length, MacOptions) \
3272   { \
3273     if ((MacOptions) & NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA) \
3274     { \
3275       RtlCopyMemory(Destination, Source, Length); \
3276     } \
3277     else \
3278     { \
3279       PUCHAR _Src = (PUCHAR)(Source); \
3280       PUCHAR _Dest = (PUCHAR)(Destination); \
3281       PUCHAR _End = _Dest + (Length); \
3282       while (_Dest < _End) \
3283         *_Dest++ = *_Src++; \
3284     } \
3285   }
3286 #endif
3287 
3288 /*
3289 NDISAPI
3290 VOID
3291 NTAPI
3292 NdisAdjustBufferLength(
3293   IN PNDIS_BUFFER Buffer,
3294   IN UINT Length);
3295 */
3296 #define NdisAdjustBufferLength(Buffer, Length) \
3297   (((Buffer)->ByteCount) = (Length))
3298 
3299 #if NDIS_SUPPORT_NDIS6
3300 #define NdisAdjustMdlLength(_Mdl, _Length) \
3301   (((_Mdl)->ByteCount) = (_Length))
3302 #endif
3303 
3304 /*
3305 NDISAPI
3306 ULONG
3307 NTAPI
3308 NdisBufferLength(
3309   IN PNDIS_BUFFER Buffer);
3310 */
3311 #define NdisBufferLength MmGetMdlByteCount
3312 
3313 /*
3314 NDISAPI
3315 PVOID
3316 NTAPI
3317 NdisBufferVirtualAddress(
3318   IN PNDIS_BUFFER Buffer);
3319 */
3320 #define NdisBufferVirtualAddress MmGetSystemAddressForMdl
3321 
3322 #define NdisBufferVirtualAddressSafe MmGetSystemAddressForMdlSafe
3323 
3324 NDISAPI
3325 ULONG
3326 NTAPI
3327 NDIS_BUFFER_TO_SPAN_PAGES(
3328   IN PNDIS_BUFFER Buffer);
3329 
3330 /*
3331 NDISAPI
3332 VOID
3333 NTAPI
3334 NdisGetBufferPhysicalArraySize(
3335   IN PNDIS_BUFFER Buffer,
3336   OUT PUINT ArraySize);
3337 */
3338 #define NdisGetBufferPhysicalArraySize(Buffer, ArraySize) \
3339   (*(ArraySize) = NDIS_BUFFER_TO_SPAN_PAGES(Buffer))
3340 
3341 /*
3342 NDISAPI
3343 VOID
3344 NTAPI
3345 NdisQueryBufferOffset(
3346   IN PNDIS_BUFFER Buffer,
3347   OUT PUINT Offset,
3348   OUT PUINT Length);
3349 */
3350 #define NdisQueryBufferOffset(_Buffer, _Offset, _Length) { \
3351   *(_Offset) = MmGetMdlByteOffset(_Buffer);                \
3352   *(_Length) = MmGetMdlByteCount(_Buffer);                 \
3353 }
3354 
3355 /*
3356  * PVOID
3357  * NDIS_BUFFER_LINKAGE(
3358  *   IN PNDIS_BUFFER Buffer);
3359  */
3360 #define NDIS_BUFFER_LINKAGE(Buffer) (Buffer)->Next
3361 
3362 /*
3363  * VOID
3364  * NdisGetNextBuffer(
3365  *   IN PNDIS_BUFFER CurrentBuffer,
3366  *   OUT PNDIS_BUFFER * NextBuffer)
3367  */
3368 #define NdisGetNextBuffer(CurrentBuffer,  \
3369                           NextBuffer)     \
3370 {                                         \
3371   *(NextBuffer) = (CurrentBuffer)->Next;  \
3372 }
3373 
3374 #if NDIS_LEGACY_DRIVER
3375 
3376 #define NDIS_PACKET_FIRST_NDIS_BUFFER(_Packet) ((_Packet)->Private.Head)
3377 #define NDIS_PACKET_LAST_NDIS_BUFFER(_Packet) ((_Packet)->Private.Tail)
3378 #define NDIS_PACKET_VALID_COUNTS(_Packet) ((_Packet)->Private.ValidCounts)
3379 
3380 /*
3381  * UINT
3382  * NdisGetPacketFlags(
3383  *   IN PNDIS_PACKET  Packet);
3384  */
3385 #define NdisGetPacketFlags(Packet) (Packet)->Private.Flags
3386 
3387 /*
3388  * ULONG
3389  * NDIS_GET_PACKET_PROTOCOL_TYPE(
3390  *   IN PNDIS_PACKET Packet);
3391  */
3392 #define NDIS_GET_PACKET_PROTOCOL_TYPE(_Packet) \
3393   ((_Packet)->Private.Flags & NDIS_PROTOCOL_ID_MASK)
3394 
3395 /*
3396  * PNDIS_PACKET_OOB_DATA
3397  * NDIS_OOB_DATA_FROM_PACKET(
3398  *   IN PNDIS_PACKET Packet);
3399  */
3400 #define NDIS_OOB_DATA_FROM_PACKET(_Packet)    \
3401   (PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3402   (_Packet)->Private.NdisPacketOobOffset)
3403 
3404 /*
3405  * ULONG
3406  * NDIS_GET_PACKET_HEADER_SIZE(
3407  *   IN PNDIS_PACKET Packet);
3408  */
3409 #define NDIS_GET_PACKET_HEADER_SIZE(_Packet)   \
3410   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3411   (_Packet)->Private.NdisPacketOobOffset))->HeaderSize
3412 
3413 /*
3414  * NDIS_STATUS
3415  * NDIS_GET_PACKET_STATUS(
3416  *   IN PNDIS_PACKET Packet);
3417  */
3418 #define NDIS_GET_PACKET_STATUS(_Packet)        \
3419   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) + \
3420   (_Packet)->Private.NdisPacketOobOffset))->Status
3421 
3422 /*
3423  * ULONGLONG
3424  * NDIS_GET_PACKET_TIME_TO_SEND(
3425  *   IN PNDIS_PACKET Packet);
3426  */
3427 #define NDIS_GET_PACKET_TIME_TO_SEND(_Packet)   \
3428   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +  \
3429   (_Packet)->Private.NdisPacketOobOffset))->TimeToSend
3430 
3431 /*
3432  * ULONGLONG
3433  * NDIS_GET_PACKET_TIME_SENT(
3434  *   IN PNDIS_PACKET Packet);
3435  */
3436 #define NDIS_GET_PACKET_TIME_SENT(_Packet)      \
3437   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +  \
3438   (_Packet)->Private.NdisPacketOobOffset))->TimeSent
3439 
3440 /*
3441  * ULONGLONG
3442  * NDIS_GET_PACKET_TIME_RECEIVED(
3443  *   IN PNDIS_PACKET Packet);
3444  */
3445 #define NDIS_GET_PACKET_TIME_RECEIVED(_Packet)  \
3446   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +  \
3447   (_Packet)->Private.NdisPacketOobOffset))->TimeReceived
3448 
3449 /*
3450  * VOID
3451  * NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(
3452  *   IN PNDIS_PACKET Packet,
3453  *   IN PPVOID pMediaSpecificInfo,
3454  *   IN PUINT pSizeMediaSpecificInfo);
3455  */
3456 #define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(_Packet,                                  \
3457                                             _pMediaSpecificInfo,                      \
3458                                             _pSizeMediaSpecificInfo)                  \
3459 {                                                                                     \
3460   if (!((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS) ||            \
3461       !((_Packet)->Private.NdisPacketFlags & fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO))   \
3462     {                                                                                 \
3463       *(_pMediaSpecificInfo) = NULL;                                                  \
3464       *(_pSizeMediaSpecificInfo) = 0;                                                 \
3465     }                                                                                 \
3466   else                                                                                \
3467     {                                                                                 \
3468       *(_pMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +           \
3469         (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation;           \
3470       *(_pSizeMediaSpecificInfo) = ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +       \
3471         (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo;              \
3472     }                                                                                 \
3473 }
3474 
3475 /*
3476  * VOID
3477  * NDIS_SET_PACKET_HEADER_SIZE(
3478  *   IN PNDIS_PACKET Packet,
3479  *   IN UINT HdrSize);
3480  */
3481 #define NDIS_SET_PACKET_HEADER_SIZE(_Packet, _HdrSize)              \
3482   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +                      \
3483   (_Packet)->Private.NdisPacketOobOffset))->HeaderSize = (_HdrSize)
3484 
3485 /*
3486  * VOID
3487  * NDIS_SET_PACKET_STATUS(
3488  *   IN PNDIS_PACKET Packet,
3489  *   IN NDIS_STATUS Status);
3490  */
3491 #define NDIS_SET_PACKET_STATUS(_Packet, _Status)  \
3492   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +    \
3493   (_Packet)->Private.NdisPacketOobOffset))->Status = (_Status)
3494 
3495 /*
3496  * VOID
3497  * NDIS_SET_PACKET_TIME_TO_SEND(
3498  *   IN PNDIS_PACKET Packet,
3499  *   IN ULONGLONG TimeToSend);
3500  */
3501 #define NDIS_SET_PACKET_TIME_TO_SEND(_Packet, _TimeToSend)  \
3502   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +              \
3503   (_Packet)->Private.NdisPacketOobOffset))->TimeToSend = (_TimeToSend)
3504 
3505 /*
3506  * VOID
3507  * NDIS_SET_PACKET_TIME_SENT(
3508  *   IN PNDIS_PACKET Packet,
3509  *   IN ULONGLONG TimeSent);
3510  */
3511 #define NDIS_SET_PACKET_TIME_SENT(_Packet, _TimeSent) \
3512   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +        \
3513   (_Packet)->Private.NdisPacketOobOffset))->TimeSent = (_TimeSent)
3514 
3515 /*
3516  * VOID
3517  * NDIS_SET_PACKET_TIME_RECEIVED(
3518  *   IN PNDIS_PACKET Packet,
3519  *   IN ULONGLONG TimeReceived);
3520  */
3521 #define NDIS_SET_PACKET_TIME_RECEIVED(_Packet, _TimeReceived) \
3522   ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +                \
3523   (_Packet)->Private.NdisPacketOobOffset))->TimeReceived = (_TimeReceived)
3524 
3525 /*
3526  * VOID
3527  * NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(
3528  *   IN PNDIS_PACKET Packet,
3529  *   IN PVOID MediaSpecificInfo,
3530  *   IN UINT SizeMediaSpecificInfo);
3531  */
3532 #define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(_Packet,                      \
3533                                             _MediaSpecificInfo,           \
3534                                             _SizeMediaSpecificInfo)       \
3535 {                                                                         \
3536   if ((_Packet)->Private.NdisPacketFlags & fPACKET_ALLOCATED_BY_NDIS)     \
3537     {                                                                     \
3538       (_Packet)->Private.NdisPacketFlags |= fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO; \
3539       ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +                        \
3540         (_Packet)->Private.NdisPacketOobOffset))->MediaSpecificInformation = \
3541           (_MediaSpecificInfo);                                           \
3542       ((PNDIS_PACKET_OOB_DATA)((PUCHAR)(_Packet) +                        \
3543         (_Packet)->Private.NdisPacketOobOffset))->SizeMediaSpecificInfo = \
3544           (_SizeMediaSpecificInfo);                                       \
3545     }                                                                     \
3546 }
3547 
3548 /*
3549  * VOID
3550  * NdisSetPacketFlags(
3551  *   IN PNDIS_PACKET  Packet,
3552  *   IN UINT  Flags);
3553  */
3554 #define NdisSetPacketFlags(Packet, Flags) (Packet)->Private.Flags |= (Flags)
3555 
3556 /*
3557  * VOID
3558  * NdisClearPacketFlags(
3559  *   IN PNDIS_PACKET  Packet,
3560  *   IN UINT  Flags);
3561  */
3562 #define NdisClearPacketFlags(Packet, Flags) (Packet)->Private.Flags &= ~(Flags)
3563 
3564 /*
3565  * VOID
3566  * NdisQueryPacket(
3567  *   IN PNDIS_PACKET Packet,
3568  *   OUT PUINT PhysicalBufferCount OPTIONAL,
3569  *   OUT PUINT BufferCount OPTIONAL,
3570  *   OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3571  *   OUT PUINT TotalPacketLength OPTIONAL);
3572  */
3573 static __inline
3574 VOID
3575 NdisQueryPacket(
3576   IN PNDIS_PACKET Packet,
3577   OUT PUINT PhysicalBufferCount OPTIONAL,
3578   OUT PUINT BufferCount OPTIONAL,
3579   OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3580   OUT PUINT TotalPacketLength OPTIONAL)
3581 {
3582   if (FirstBuffer)
3583     *FirstBuffer = Packet->Private.Head;
3584   if (TotalPacketLength || BufferCount || PhysicalBufferCount) {
3585     if (!Packet->Private.ValidCounts) {
3586       UINT Offset;
3587       UINT PacketLength;
3588       PNDIS_BUFFER NdisBuffer;
3589       UINT _PhysicalBufferCount = 0;
3590       UINT _TotalPacketLength = 0;
3591       UINT Count = 0;
3592 
3593       for (NdisBuffer = Packet->Private.Head;
3594            NdisBuffer != (PNDIS_BUFFER)NULL;
3595            NdisBuffer = NdisBuffer->Next) {
3596         _PhysicalBufferCount += NDIS_BUFFER_TO_SPAN_PAGES(NdisBuffer);
3597         NdisQueryBufferOffset(NdisBuffer, &Offset, &PacketLength);
3598         _TotalPacketLength += PacketLength;
3599         Count++;
3600       }
3601       Packet->Private.PhysicalCount = _PhysicalBufferCount;
3602       Packet->Private.TotalLength = _TotalPacketLength;
3603       Packet->Private.Count = Count;
3604       Packet->Private.ValidCounts = TRUE;
3605     }
3606 
3607     if (PhysicalBufferCount)
3608       *PhysicalBufferCount = Packet->Private.PhysicalCount;
3609 
3610     if (BufferCount)
3611       *BufferCount = Packet->Private.Count;
3612 
3613     if (TotalPacketLength)
3614       *TotalPacketLength = Packet->Private.TotalLength;
3615   }
3616 }
3617 
3618 /*
3619  * VOID
3620  * NdisQueryPacketLength(
3621  *   IN PNDIS_PACKET Packet,
3622  *   OUT PUINT PhysicalBufferCount OPTIONAL,
3623  *   OUT PUINT BufferCount OPTIONAL,
3624  *   OUT PNDIS_BUFFER *FirstBuffer OPTIONAL,
3625  *   OUT PUINT TotalPacketLength OPTIONAL);
3626  */
3627 #define NdisQueryPacketLength(_Packet,                              \
3628                               _TotalPacketLength)                   \
3629 {                                                                   \
3630   if (!(_Packet)->Private.ValidCounts) {                            \
3631     NdisQueryPacket(_Packet, NULL, NULL, NULL, _TotalPacketLength); \
3632   }                                                                 \
3633   else *(_TotalPacketLength) = (_Packet)->Private.TotalLength;      \
3634 }
3635 
3636 #endif /* NDIS_LEGACY_DRIVER */
3637 
3638 /* Memory management routines */
3639 
3640 /*
3641 NDISAPI
3642 VOID
3643 NTAPI
3644 NdisCreateLookaheadBufferFromSharedMemory(
3645   IN PVOID pSharedMemory,
3646   IN UINT LookaheadLength,
3647   OUT PVOID *pLookaheadBuffer);
3648 */
3649 #define NdisCreateLookaheadBufferFromSharedMemory(_S, _L, _B) ((*(_B)) = (_S))
3650 
3651 NDISAPI
3652 VOID
3653 NTAPI
3654 NdisDestroyLookaheadBufferFromSharedMemory(
3655   IN PVOID pLookaheadBuffer);
3656 
3657 #if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_ARM) || defined(_M_PPC)
3658 
3659 /*
3660  * VOID
3661  * NdisMoveMappedMemory(
3662  *   OUT PVOID  Destination,
3663  *   IN PVOID  Source,
3664  *   IN ULONG  Length);
3665  */
3666 #define NdisMoveMappedMemory(Destination, Source, Length) \
3667   RtlCopyMemory(Destination, Source, Length)
3668 
3669 /*
3670  * VOID
3671  * NdisZeroMappedMemory(
3672  *   IN PVOID  Destination,
3673  *   IN ULONG  Length);
3674  */
3675 #define NdisZeroMappedMemory(Destination, Length) \
3676   RtlZeroMemory(Destination, Length)
3677 
3678 #else
3679 
3680 #define NdisMoveMappedMemory(Destination, Source, Length) \
3681 { \
3682   PUCHAR _Dest = Destination, _Src = Source, _End = _Dest + Length; \
3683   while (_Dest < _End) \
3684     *_Dest++ = _Src++; \
3685 }
3686 
3687 #define NdisZeroMappedMemory(Destination, Length) \
3688 { \
3689   PUCHAR _Dest = Destination, _End = _Dest + Length; \
3690   while (_Dest < _End) \
3691     *_Dest++ = 0; \
3692 }
3693 
3694 #endif /* _M_IX86 or _M_AMD64 */
3695 
3696 /*
3697  * VOID
3698  * NdisMoveFromMappedMemory(
3699  *   OUT PVOID  Destination,
3700  *   IN PVOID  Source,
3701  *   IN ULONG  Length);
3702  */
3703 #define NdisMoveFromMappedMemory(Destination, Source, Length) \
3704   NdisMoveMappedMemory(Destination, Source, Length)
3705 
3706 /*
3707  * VOID
3708  * NdisMoveToMappedMemory(
3709  *   OUT PVOID  Destination,
3710  *   IN PVOID  Source,
3711  *   IN ULONG  Length);
3712  */
3713 #define NdisMoveToMappedMemory(Destination, Source, Length) \
3714   NdisMoveMappedMemory(Destination, Source, Length)
3715 
3716 /*
3717  * VOID
3718  * NdisMUpdateSharedMemory(
3719  *   IN NDIS_HANDLE  MiniportAdapterHandle,
3720  *   IN ULONG  Length,
3721  *   IN PVOID  VirtualAddress,
3722  *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress);
3723  */
3724 #define NdisMUpdateSharedMemory(_H, _L, _V, _P) \
3725   NdisUpdateSharedMemory(_H, _L, _V, _P)
3726 
3727 _When_(MemoryFlags==0, _IRQL_requires_max_(DISPATCH_LEVEL))
3728 _When_(MemoryFlags==NDIS_MEMORY_CONTIGUOUS, _IRQL_requires_(PASSIVE_LEVEL))
3729 _When_(MemoryFlags==NDIS_MEMORY_NONCACHED, _IRQL_requires_max_(APC_LEVEL))
3730 NDISAPI
3731 VOID
3732 NTAPI
3733 NdisFreeMemory(
3734   _In_reads_bytes_(Length) __drv_freesMem(Mem) PVOID VirtualAddress,
3735   _In_ UINT Length,
3736   _In_ _Pre_satisfies_(MemoryFlags == 0 || MemoryFlags == NDIS_MEMORY_NONCACHED || MemoryFlags == NDIS_MEMORY_CONTIGUOUS)
3737     UINT MemoryFlags);
3738 
3739 NDISAPI
3740 VOID
3741 NTAPI
3742 NdisFreeMemoryWithTag(
3743   IN PVOID VirtualAddress,
3744   IN ULONG Tag);
3745 
3746 NDISAPI
3747 VOID
3748 NTAPI
3749 NdisImmediateReadSharedMemory(
3750   IN NDIS_HANDLE WrapperConfigurationContext,
3751   IN ULONG       SharedMemoryAddress,
3752   OUT PUCHAR      Buffer,
3753   IN ULONG       Length);
3754 
3755 NDISAPI
3756 VOID
3757 NTAPI
3758 NdisImmediateWriteSharedMemory(
3759   IN NDIS_HANDLE WrapperConfigurationContext,
3760   IN ULONG       SharedMemoryAddress,
3761   IN PUCHAR      Buffer,
3762   IN ULONG       Length);
3763 
3764 _IRQL_requires_(PASSIVE_LEVEL)
3765 NDISAPI
3766 VOID
3767 NTAPI
3768 NdisMAllocateSharedMemory(
3769   _In_ NDIS_HANDLE MiniportAdapterHandle,
3770   _In_ ULONG Length,
3771   _In_ BOOLEAN Cached,
3772   _Outptr_result_bytebuffer_(Length) _At_(*VirtualAddress, _Must_inspect_result_)
3773     PVOID *VirtualAddress,
3774   _Out_ _At_(*PhysicalAddress, _Must_inspect_result_)
3775     PNDIS_PHYSICAL_ADDRESS PhysicalAddress);
3776 
3777 _IRQL_requires_max_(DISPATCH_LEVEL)
3778 NDISAPI
3779 NDIS_STATUS
3780 NTAPI
3781 NdisMAllocateSharedMemoryAsync(
3782   _In_ NDIS_HANDLE MiniportAdapterHandle,
3783   _In_ ULONG Length,
3784   _In_ BOOLEAN Cached,
3785   _In_ PVOID Context);
3786 
3787 #if defined(NDIS50)
3788 
3789 #define NdisUpdateSharedMemory(NdisAdapterHandle, \
3790                                Length,            \
3791                                VirtualAddress,    \
3792                                PhysicalAddress)
3793 
3794 #else
3795 
3796 NDISAPI
3797 VOID
3798 NTAPI
3799 NdisUpdateSharedMemory(
3800   IN NDIS_HANDLE             NdisAdapterHandle,
3801   IN ULONG                   Length,
3802   IN PVOID                   VirtualAddress,
3803   IN NDIS_PHYSICAL_ADDRESS   PhysicalAddress);
3804 
3805 #endif /* defined(NDIS50) */
3806 
3807 /*
3808  * ULONG
3809  * NdisGetPhysicalAddressHigh(
3810  *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress);
3811  */
3812 #define NdisGetPhysicalAddressHigh(PhysicalAddress) \
3813   ((PhysicalAddress).HighPart)
3814 
3815 /*
3816  * VOID
3817  * NdisSetPhysicalAddressHigh(
3818  *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
3819  *   IN ULONG  Value);
3820  */
3821 #define NdisSetPhysicalAddressHigh(PhysicalAddress, Value) \
3822   ((PhysicalAddress).HighPart) = (Value)
3823 
3824 /*
3825  * ULONG
3826  * NdisGetPhysicalAddressLow(
3827  *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress);
3828  */
3829 #define NdisGetPhysicalAddressLow(PhysicalAddress) \
3830   ((PhysicalAddress).LowPart)
3831 
3832 
3833 /*
3834  * VOID
3835  * NdisSetPhysicalAddressLow(
3836  *   IN NDIS_PHYSICAL_ADDRESS  PhysicalAddress,
3837  *   IN ULONG  Value);
3838  */
3839 #define NdisSetPhysicalAddressLow(PhysicalAddress, Value) \
3840   ((PhysicalAddress).LowPart) = (Value)
3841 
3842 /*
3843  * VOID
3844  * NDIS_PHYSICAL_ADDRESS_CONST(
3845  *   IN ULONG  Low,
3846  *   IN LONG  High);
3847  */
3848 #define NDIS_PHYSICAL_ADDRESS_CONST(Low, High)  \
3849     { {(ULONG)(Low), (LONG)(High)} }
3850 
3851 /*
3852  * ULONG
3853  * NdisEqualMemory(
3854  *  IN CONST VOID  *Source1,
3855  *  IN CONST VOID  *Source2,
3856  *  IN ULONG  Length);
3857  */
3858 #define NdisEqualMemory(Source1, Source2, Length) \
3859   RtlEqualMemory(Source1, Source2, Length)
3860 
3861 /*
3862  * VOID
3863  * NdisFillMemory(
3864  *   IN PVOID  Destination,
3865  *   IN ULONG  Length,
3866  *   IN UCHAR  Fill);
3867  */
3868 #define NdisFillMemory(Destination, Length, Fill) \
3869   RtlFillMemory(Destination, Length, Fill)
3870 
3871 /*
3872  * VOID
3873  * NdisMoveMemory(
3874  *   OUT  PVOID  Destination,
3875  *   IN PVOID  Source,
3876  *   IN ULONG  Length);
3877  */
3878 #define NdisMoveMemory(Destination, Source, Length) \
3879   RtlCopyMemory(Destination, Source, Length)
3880 
3881 
3882 /*
3883  * VOID
3884  * NdisRetrieveUlong(
3885  *   IN PULONG  DestinationAddress,
3886  *   IN PULONG  SourceAddress);
3887  */
3888 #define NdisRetrieveUlong(DestinationAddress, SourceAddress) \
3889   RtlRetrieveUlong(DestinationAddress, SourceAddress)
3890 
3891 
3892 /*
3893  * VOID
3894  * NdisStoreUlong(
3895  *   IN PULONG  DestinationAddress,
3896  *   IN ULONG  Value);
3897  */
3898 #define NdisStoreUlong(DestinationAddress, Value) \
3899   RtlStoreUlong(DestinationAddress, Value)
3900 
3901 
3902 /*
3903  * VOID
3904  * NdisZeroMemory(
3905  *   IN PVOID  Destination,
3906  *   IN ULONG  Length)
3907  */
3908 #define NdisZeroMemory(Destination, Length) \
3909   RtlZeroMemory(Destination, Length)
3910 
3911 typedef VOID
3912 (NTAPI *NDIS_BLOCK_INITIALIZER) (
3913     IN  PUCHAR  Block,
3914     IN  SIZE_T  NumberOfBytes
3915     );
3916 
3917 /* Configuration routines */
3918 
3919 #if NDIS_LEGACY_DRIVER
3920 _IRQL_requires_(PASSIVE_LEVEL)
3921 _Success_(*Status >= 0)
3922 NDISAPI
3923 VOID
3924 NTAPI
3925 NdisOpenConfiguration(
3926   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
3927   _Out_ PNDIS_HANDLE ConfigurationHandle,
3928   _In_ NDIS_HANDLE WrapperConfigurationContext);
3929 #endif
3930 
3931 _IRQL_requires_(PASSIVE_LEVEL)
3932 _Success_(*Status >= 0)
3933 NDISAPI
3934 VOID
3935 NTAPI
3936 NdisReadNetworkAddress(
3937   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
3938   _Outptr_result_bytebuffer_to_(*NetworkAddressLength, *NetworkAddressLength)
3939     PVOID *NetworkAddress,
3940   _Out_ PUINT NetworkAddressLength,
3941   _In_ NDIS_HANDLE ConfigurationHandle);
3942 
3943 NDISAPI
3944 VOID
3945 NTAPI
3946 NdisReadEisaSlotInformation(
3947   OUT PNDIS_STATUS  Status,
3948   IN NDIS_HANDLE  WrapperConfigurationContext,
3949   OUT PUINT  SlotNumber,
3950   OUT PNDIS_EISA_FUNCTION_INFORMATION  EisaData);
3951 
3952 NDISAPI
3953 VOID
3954 NTAPI
3955 NdisReadEisaSlotInformationEx(
3956   OUT PNDIS_STATUS  Status,
3957   IN NDIS_HANDLE  WrapperConfigurationContext,
3958   OUT PUINT  SlotNumber,
3959   OUT PNDIS_EISA_FUNCTION_INFORMATION  *EisaData,
3960   OUT PUINT  NumberOfFunctions);
3961 
3962 #if NDIS_LEGACY_MINIPORT
3963 
3964 _IRQL_requires_max_(DISPATCH_LEVEL)
3965 NDISAPI
3966 ULONG
3967 NTAPI
3968 NdisReadPciSlotInformation(
3969   _In_ NDIS_HANDLE NdisAdapterHandle,
3970   _In_ ULONG SlotNumber,
3971   _In_ ULONG Offset,
3972   _Out_writes_bytes_(Length) PVOID Buffer,
3973   _In_ ULONG Length);
3974 
3975 _IRQL_requires_max_(DISPATCH_LEVEL)
3976 NDISAPI
3977 ULONG
3978 NTAPI
3979 NdisWritePciSlotInformation(
3980   _In_ NDIS_HANDLE NdisAdapterHandle,
3981   _In_ ULONG SlotNumber,
3982   _In_ ULONG Offset,
3983   _In_reads_bytes_(Length) PVOID Buffer,
3984   _In_ ULONG Length);
3985 
3986 _IRQL_requires_max_(DISPATCH_LEVEL)
3987 NDISAPI
3988 ULONG
3989 NTAPI
3990 NdisReadPcmciaAttributeMemory(
3991   _In_ NDIS_HANDLE NdisAdapterHandle,
3992   _In_ ULONG Offset,
3993   _Out_writes_bytes_(Length) PVOID Buffer,
3994   _In_ ULONG Length);
3995 
3996 _IRQL_requires_max_(DISPATCH_LEVEL)
3997 NDISAPI
3998 ULONG
3999 NTAPI
4000 NdisWritePcmciaAttributeMemory(
4001   _In_ NDIS_HANDLE NdisAdapterHandle,
4002   _In_ ULONG Offset,
4003   _In_reads_bytes_(Length) PVOID Buffer,
4004   _In_ ULONG Length);
4005 
4006 #endif /* NDIS_LEGACY_MINIPORT */
4007 
4008 /* String management routines */
4009 
4010 /*
4011 NDISAPI
4012 NDIS_STATUS
4013 NTAPI
4014 NdisAnsiStringToUnicodeString(
4015   IN OUT PNDIS_STRING DestinationString,
4016   IN PNDIS_ANSI_STRING SourceString);
4017 */
4018 #define NdisAnsiStringToUnicodeString(_us, _as) RtlAnsiStringToUnicodeString(_us, _as, FALSE)
4019 
4020 /*
4021  * BOOLEAN
4022  * NdisEqualString(
4023  *   IN PNDIS_STRING String1,
4024  *   IN PNDIS_STRING String2,
4025  *   IN BOOLEAN CaseInsensitive);
4026  */
4027 #define NdisEqualString RtlEqualString
4028 
4029 #define NdisEqualUnicodeString RtlEqualUnicodeString
4030 
4031 /*
4032 NDISAPI
4033 VOID
4034 NTAPI
4035 NdisInitAnsiString(
4036   IN OUT PNDIS_ANSI_STRING DestinationString,
4037   IN PCSTR SourceString);
4038 */
4039 #define NdisInitAnsiString RtlInitString
4040 
4041 NDISAPI
4042 VOID
4043 NTAPI
4044 NdisInitUnicodeString(
4045   IN OUT PNDIS_STRING  DestinationString,
4046   IN PCWSTR  SourceString);
4047 
4048 /*
4049 NDISAPI
4050 NDIS_STATUS
4051 NTAPI
4052 NdisUnicodeStringToAnsiString(
4053   IN OUT PNDIS_ANSI_STRING DestinationString,
4054   IN PNDIS_STRING SourceString);
4055 */
4056 #define NdisUnicodeStringToAnsiString(_as, _us) RtlUnicodeStringToAnsiString(_as, _us, FALSE)
4057 
4058 #define NdisFreeString(_s) NdisFreeMemory((_s).Buffer, (_s).MaximumLength, 0)
4059 #define NdisPrintString(_s) DbgPrint("%ls", (_s).Buffer)
4060 
4061 /* Spin lock reoutines */
4062 
4063 /*
4064 NDISAPI
4065 VOID
4066 NTAPI
4067 NdisAllocateSpinLock(
4068   IN PNDIS_SPIN_LOCK SpinLock);
4069 */
4070 #define NdisAllocateSpinLock(_SpinLock) KeInitializeSpinLock(&(_SpinLock)->SpinLock)
4071 
4072 /*
4073 NDISAPI
4074 VOID
4075 NTAPI
4076 NdisFreeSpinLock(
4077   IN PNDIS_SPIN_LOCK  SpinLock);
4078 */
4079 #define NdisFreeSpinLock(_SpinLock)
4080 
4081 /*
4082 NDISAPI
4083 VOID
4084 NTAPI
4085 NdisAcquireSpinLock(
4086   IN PNDIS_SPIN_LOCK  SpinLock);
4087 */
4088 #define NdisAcquireSpinLock(_SpinLock) KeAcquireSpinLock(&(_SpinLock)->SpinLock, &(_SpinLock)->OldIrql)
4089 
4090 /*
4091 NDISAPI
4092 VOID
4093 NTAPI
4094 NdisReleaseSpinLock(
4095   IN PNDIS_SPIN_LOCK  SpinLock);
4096 */
4097 #define NdisReleaseSpinLock(_SpinLock) KeReleaseSpinLock(&(_SpinLock)->SpinLock,(_SpinLock)->OldIrql)
4098 
4099 /*
4100 NDISAPI
4101 VOID
4102 NTAPI
4103 NdisDprAcquireSpinLock(
4104   IN PNDIS_SPIN_LOCK  SpinLock);
4105 */
4106 #define NdisDprAcquireSpinLock(_SpinLock) KeAcquireSpinLockAtDpcLevel(&(_SpinLock)->SpinLock)
4107 
4108 /*
4109 NDISAPI
4110 VOID
4111 NTAPI
4112 NdisDprReleaseSpinLock(
4113   IN PNDIS_SPIN_LOCK  SpinLock);
4114 */
4115 #define NdisDprReleaseSpinLock(_SpinLock) KeReleaseSpinLockFromDpcLevel(&(_SpinLock)->SpinLock)
4116 
4117 /* I/O routines */
4118 
4119 /*
4120  * VOID
4121  * NdisRawReadPortBufferUchar(
4122  *   IN ULONG Port,
4123  *   OUT PUCHAR Buffer,
4124  *   IN ULONG Length);
4125  */
4126 #define NdisRawReadPortBufferUchar(Port, Buffer, Length) \
4127   READ_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length))
4128 
4129 /*
4130  * VOID
4131  * NdisRawReadPortBufferUlong(
4132  *   IN ULONG Port,
4133  *   OUT PULONG Buffer,
4134  *   IN ULONG Length);
4135  */
4136 #define NdisRawReadPortBufferUlong(Port, Buffer, Length) \
4137   READ_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length))
4138 
4139 /*
4140  * VOID
4141  * NdisRawReadPortBufferUshort(
4142  *   IN ULONG Port,
4143  *   OUT PUSHORT Buffer,
4144  *   IN ULONG Length);
4145  */
4146 #define NdisRawReadPortBufferUshort(Port, Buffer, Length) \
4147   READ_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length))
4148 
4149 /*
4150  * VOID
4151  * NdisRawReadPortUchar(
4152  *   IN ULONG Port,
4153  *   OUT PUCHAR Data);
4154  */
4155 #define NdisRawReadPortUchar(Port, Data) \
4156   *(Data) = READ_PORT_UCHAR((PUCHAR)(Port))
4157 
4158 /*
4159  * VOID
4160  * NdisRawReadPortUlong(
4161  *   IN ULONG Port,
4162  *   OUT PULONG Data);
4163  */
4164 #define NdisRawReadPortUlong(Port, Data) \
4165   *(Data) = READ_PORT_ULONG((PULONG)(Port))
4166 
4167 /*
4168  * VOID
4169  * NdisRawReadPortUshort(
4170  *   IN ULONG Port,
4171  *   OUT PUSHORT Data);
4172  */
4173 #define NdisRawReadPortUshort(Port, Data) \
4174   *(Data) = READ_PORT_USHORT((PUSHORT)(Port))
4175 
4176 /*
4177  * VOID
4178  * NdisRawWritePortBufferUchar(
4179  *   IN ULONG Port,
4180  *   IN PUCHAR Buffer,
4181  *   IN ULONG Length);
4182  */
4183 #define NdisRawWritePortBufferUchar(Port, Buffer, Length) \
4184   WRITE_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length))
4185 
4186 /*
4187  * VOID
4188  * NdisRawWritePortBufferUlong(
4189  *   IN ULONG Port,
4190  *   IN PULONG Buffer,
4191  *   IN ULONG Length);
4192  */
4193 #define NdisRawWritePortBufferUlong(Port, Buffer, Length) \
4194   WRITE_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length))
4195 
4196 /*
4197  * VOID
4198  * NdisRawWritePortBufferUshort(
4199  *   IN ULONG Port,
4200  *   IN PUSHORT Buffer,
4201  *   IN ULONG Length);
4202  */
4203 #define NdisRawWritePortBufferUshort(Port, Buffer, Length) \
4204   WRITE_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length))
4205 
4206 /*
4207  * VOID
4208  * NdisRawWritePortUchar(
4209  *   IN ULONG Port,
4210  *   IN UCHAR Data);
4211  */
4212 #define NdisRawWritePortUchar(Port, Data) \
4213   WRITE_PORT_UCHAR((PUCHAR)(Port), (UCHAR)(Data))
4214 
4215 /*
4216  * VOID
4217  * NdisRawWritePortUlong(
4218  *   IN ULONG Port,
4219  *   IN ULONG Data);
4220  */
4221 #define NdisRawWritePortUlong(Port, Data) \
4222   WRITE_PORT_ULONG((PULONG)(Port), (ULONG)(Data))
4223 
4224 /*
4225  * VOID
4226  * NdisRawWritePortUshort(
4227  *   IN ULONG Port,
4228  *   IN USHORT Data);
4229  */
4230 #define NdisRawWritePortUshort(Port, Data) \
4231   WRITE_PORT_USHORT((PUSHORT)(Port), (USHORT)(Data))
4232 
4233 
4234 /*
4235  * VOID
4236  * NdisReadRegisterUchar(
4237  *   IN PUCHAR Register,
4238  *   OUT PUCHAR Data);
4239  */
4240 #define NdisReadRegisterUchar(Register, Data) \
4241   *(Data) = *(Register)
4242 
4243 /*
4244  * VOID
4245  * NdisReadRegisterUlong(
4246  *   IN PULONG  Register,
4247  *   OUT PULONG  Data);
4248  */
4249 #define NdisReadRegisterUlong(Register, Data)   \
4250   *(Data) = *(Register)
4251 
4252 /*
4253  * VOID
4254  * NdisReadRegisterUshort(
4255  *   IN PUSHORT Register,
4256  *   OUT PUSHORT Data);
4257  */
4258 #define NdisReadRegisterUshort(Register, Data) \
4259     *(Data) = *(Register)
4260 
4261 /*
4262  * VOID
4263  * NdisReadRegisterUchar(
4264  *   IN PUCHAR Register,
4265  *   IN UCHAR Data);
4266  */
4267 #define NdisWriteRegisterUchar(Register, Data) \
4268   WRITE_REGISTER_UCHAR((Register), (Data))
4269 
4270 /*
4271  * VOID
4272  * NdisReadRegisterUlong(
4273  *   IN PULONG Register,
4274  *   IN ULONG Data);
4275  */
4276 #define NdisWriteRegisterUlong(Register, Data) \
4277   WRITE_REGISTER_ULONG((Register), (Data))
4278 
4279 /*
4280  * VOID
4281  * NdisReadRegisterUshort(
4282  *   IN PUSHORT Register,
4283  *   IN USHORT Data);
4284  */
4285 #define NdisWriteRegisterUshort(Register, Data) \
4286   WRITE_REGISTER_USHORT((Register), (Data))
4287 
4288 
4289 /* Linked lists */
4290 
4291 /*
4292  * VOID
4293  * NdisInitializeListHead(
4294  *   IN PLIST_ENTRY ListHead);
4295  */
4296 #define NdisInitializeListHead InitializeListHead
4297 
4298 /*
4299  * PLIST_ENTRY
4300  * NdisInterlockedInsertHeadList(
4301  *   IN PLIST_ENTRY  ListHead,
4302  *   IN PLIST_ENTRY  ListEntry,
4303  *   IN PNDIS_SPIN_LOCK  SpinLock);
4304  */
4305 #define NdisInterlockedInsertHeadList(_ListHead, _ListEntry, _SpinLock) \
4306   ExInterlockedInsertHeadList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
4307 
4308 /*
4309  * PLIST_ENTRY
4310  * NdisInterlockedInsertTailList(
4311  *   IN PLIST_ENTRY  ListHead,
4312  *   IN PLIST_ENTRY  ListEntry,
4313  *   IN PNDIS_SPIN_LOCK  SpinLock);
4314  */
4315 #define NdisInterlockedInsertTailList(_ListHead, _ListEntry, _SpinLock) \
4316   ExInterlockedInsertTailList(_ListHead, _ListEntry, &(_SpinLock)->SpinLock)
4317 
4318 /*
4319  * PLIST_ENTRY
4320  * NdisInterlockedRemoveHeadList(
4321  *   IN PLIST_ENTRY  ListHead,
4322  *   IN PNDIS_SPIN_LOCK  SpinLock);
4323 */
4324 #define NdisInterlockedRemoveHeadList(_ListHead, _SpinLock) \
4325   ExInterlockedRemoveHeadList(_ListHead, &(_SpinLock)->SpinLock)
4326 
4327 /*
4328  * VOID
4329  * NdisInitializeSListHead(
4330  *   IN PSLIST_HEADER SListHead);
4331  */
4332 #define NdisInitializeSListHead(SListHead) ExInitializeSListHead(SListHead)
4333 
4334 /*
4335  * USHORT NdisQueryDepthSList(
4336  *   IN PSLIST_HEADER SListHead);
4337  */
4338 #define NdisQueryDepthSList(SListHead) ExQueryDepthSList(SListHead)
4339 
4340 #define NdisInterlockedPushEntryList(ListHead, ListEntry, Lock) \
4341   ExInterlockedPushEntryList(ListHead, ListEntry, &(Lock)->SpinLock)
4342 
4343 #define NdisInterlockedPopEntryList(ListHead, Lock) \
4344   ExInterlockedPopEntryList(ListHead, &(Lock)->SpinLock)
4345 
4346 /* Non-paged lookaside lists */
4347 
4348 #define NdisInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D) \
4349   ExInitializeNPagedLookasideList(_L, _AR, _FR, _Fl, _S, _T, _D)
4350 #define NdisDeleteNPagedLookasideList(_L) ExDeleteNPagedLookasideList(_L)
4351 #define NdisAllocateFromNPagedLookasideList(_L) ExAllocateFromNPagedLookasideList(_L)
4352 #define NdisFreeToNPagedLookasideList(_L, _E) ExFreeToNPagedLookasideList(_L, _E)
4353 
4354 /* Interlocked routines */
4355 
4356 /*
4357  * LONG
4358  * NdisInterlockedDecrement(
4359  *   IN PLONG  Addend);
4360  */
4361 #define NdisInterlockedDecrement(Addend) InterlockedDecrement(Addend)
4362 
4363 /*
4364  * LONG
4365  * NdisInterlockedIncrement(
4366  *   IN PLONG  Addend);
4367  */
4368 #define NdisInterlockedIncrement(Addend) InterlockedIncrement(Addend)
4369 
4370 /*
4371  * VOID
4372  * NdisInterlockedAddUlong(
4373  *   IN PULONG  Addend,
4374  *   IN ULONG  Increment,
4375  *   IN PNDIS_SPIN_LOCK  SpinLock);
4376  */
4377 #define NdisInterlockedAddUlong(_Addend, _Increment, _SpinLock) \
4378   ExInterlockedAddUlong(_Addend, _Increment, &(_SpinLock)->SpinLock)
4379 
4380 /* Miscellaneous routines */
4381 
4382 _IRQL_requires_(PASSIVE_LEVEL)
4383 NDISAPI
4384 VOID
4385 NTAPI
4386 NdisCloseConfiguration(
4387   _In_ __drv_freesMem(mem) NDIS_HANDLE ConfigurationHandle);
4388 
4389 _IRQL_requires_(PASSIVE_LEVEL)
4390 _Success_(*Status >= 0)
4391 NDISAPI
4392 VOID
4393 NTAPI
4394 NdisReadConfiguration(
4395   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4396   _Out_ PNDIS_CONFIGURATION_PARAMETER *ParameterValue,
4397   _In_ NDIS_HANDLE ConfigurationHandle,
4398   _In_ PNDIS_STRING Keyword,
4399   _In_ NDIS_PARAMETER_TYPE ParameterType);
4400 
4401 _IRQL_requires_(PASSIVE_LEVEL)
4402 _Success_(*Status >= 0)
4403 NDISAPI
4404 VOID
4405 NTAPI
4406 NdisWriteConfiguration(
4407   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4408   _In_ NDIS_HANDLE WrapperConfigurationContext,
4409   _In_ PNDIS_STRING Keyword,
4410   _In_ PNDIS_CONFIGURATION_PARAMETER ParameterValue);
4411 
4412 _IRQL_requires_max_(DISPATCH_LEVEL)
4413 NDISAPI
4414 VOID
4415 __cdecl
4416 NdisWriteErrorLogEntry(
4417   _In_ NDIS_HANDLE NdisAdapterHandle,
4418   _In_ NDIS_ERROR_CODE ErrorCode,
4419   _In_ ULONG NumberOfErrorValues,
4420   ...);
4421 
4422 _IRQL_requires_(PASSIVE_LEVEL)
4423 NDISAPI
4424 VOID
4425 NTAPI
4426 NdisInitializeString(
4427   _Out_ _At_(Destination->Buffer, __drv_allocatesMem(Mem)) PNDIS_STRING Destination,
4428   _In_opt_z_ PUCHAR Source);
4429 
4430 /*
4431  * VOID
4432  * NdisStallExecution(
4433  *   IN UINT MicrosecondsToStall)
4434  */
4435 #define NdisStallExecution KeStallExecutionProcessor
4436 
4437 /*
4438 NDISAPI
4439 VOID
4440 NTAPI
4441 NdisGetCurrentSystemTime(
4442   IN PLARGE_INTEGER  pSystemTime);
4443 */
4444 #define NdisGetCurrentSystemTime KeQuerySystemTime
4445 
4446 #if NDIS_SUPPORT_60_COMPATIBLE_API
4447 _IRQL_requires_(PASSIVE_LEVEL)
4448 NDISAPI
4449 CCHAR
4450 NTAPI
4451 NdisSystemProcessorCount(VOID);
4452 #endif
4453 
4454 NDISAPI
4455 VOID
4456 NTAPI
4457 NdisGetCurrentProcessorCpuUsage(
4458   OUT PULONG pCpuUsage);
4459 
4460 /* NDIS helper macros */
4461 
4462 /*
4463  * VOID
4464  * NDIS_INIT_FUNCTION(FunctionName)
4465  */
4466 #define NDIS_INIT_FUNCTION(FunctionName)    \
4467   alloc_text(init, FunctionName)
4468 
4469 /*
4470  * VOID
4471  * NDIS_PAGABLE_FUNCTION(FunctionName)
4472  */
4473 #define NDIS_PAGEABLE_FUNCTION(FunctionName) \
4474   alloc_text(page, FunctionName)
4475 
4476 #define NDIS_PAGABLE_FUNCTION NDIS_PAGEABLE_FUNCTION
4477 
4478 
4479 /* NDIS 4.0 extensions */
4480 
4481 _IRQL_requires_max_(DISPATCH_LEVEL)
4482 NDISAPI
4483 VOID
4484 NTAPI
4485 NdisMFreeSharedMemory(
4486   _In_ NDIS_HANDLE MiniportAdapterHandle,
4487   _In_ ULONG Length,
4488   _In_ BOOLEAN Cached,
4489   _In_reads_bytes_(Length) PVOID VirtualAddress,
4490   _In_ NDIS_PHYSICAL_ADDRESS PhysicalAddress);
4491 
4492 NDISAPI
4493 VOID
4494 NTAPI
4495 NdisMWanIndicateReceive(
4496 	OUT PNDIS_STATUS  Status,
4497 	IN NDIS_HANDLE  MiniportAdapterHandle,
4498 	IN NDIS_HANDLE  NdisLinkContext,
4499 	IN PUCHAR  PacketBuffer,
4500 	IN UINT  PacketSize);
4501 
4502 NDISAPI
4503 VOID
4504 NTAPI
4505 NdisMWanIndicateReceiveComplete(
4506   IN NDIS_HANDLE MiniportAdapterHandle,
4507   IN NDIS_HANDLE NdisLinkContext);
4508 
4509 NDISAPI
4510 VOID
4511 NTAPI
4512 NdisMWanSendComplete(
4513 	IN NDIS_HANDLE  MiniportAdapterHandle,
4514 	IN PNDIS_WAN_PACKET  Packet,
4515 	IN NDIS_STATUS  Status);
4516 
4517 NDISAPI
4518 NDIS_STATUS
4519 NTAPI
4520 NdisPciAssignResources(
4521 	IN NDIS_HANDLE  NdisMacHandle,
4522 	IN NDIS_HANDLE  NdisWrapperHandle,
4523 	IN NDIS_HANDLE  WrapperConfigurationContext,
4524 	IN ULONG  SlotNumber,
4525 	OUT PNDIS_RESOURCE_LIST  *AssignedResources);
4526 
4527 
4528 /* NDIS 5.0 extensions */
4529 
4530 _IRQL_requires_max_(DISPATCH_LEVEL)
4531 NDISAPI
4532 NDIS_STATUS
4533 NTAPI
4534 NdisAllocateMemoryWithTag(
4535   _At_(*VirtualAddress, __drv_allocatesMem(Mem)) _Outptr_result_bytebuffer_(Length)
4536     PVOID *VirtualAddress,
4537   _In_ UINT Length,
4538   _In_ ULONG Tag);
4539 
4540 _IRQL_requires_max_(DISPATCH_LEVEL)
4541 NDISAPI
4542 VOID
4543 NTAPI
4544 NdisGetCurrentProcessorCounts(
4545   _Out_ PULONG pIdleCount,
4546   _Out_ PULONG pKernelAndUser,
4547   _Out_ PULONG pIndex);
4548 
4549 #if NDIS_LEGACY_DRIVER
4550 NDISAPI
4551 VOID
4552 NTAPI
4553 NdisGetSystemUpTime(
4554   OUT PULONG pSystemUpTime);
4555 #endif
4556 
4557 #if NDIS_SUPPORT_60_COMPATIBLE_API
4558 
4559 _IRQL_requires_max_(DISPATCH_LEVEL)
4560 _IRQL_raises_(DISPATCH_LEVEL)
4561 _When_(fWrite, _Acquires_exclusive_lock_(*Lock))
4562 _When_(!fWrite, _Acquires_shared_lock_(*Lock))
4563 NDISAPI
4564 VOID
4565 NTAPI
4566 NdisAcquireReadWriteLock(
4567   _Inout_ PNDIS_RW_LOCK Lock,
4568   _In_ BOOLEAN fWrite,
4569   _Out_ _IRQL_saves_ PLOCK_STATE LockState);
4570 
4571 _IRQL_requires_max_(DISPATCH_LEVEL)
4572 NDISAPI
4573 VOID
4574 NTAPI
4575 NdisInitializeReadWriteLock(
4576   _Out_ PNDIS_RW_LOCK Lock);
4577 
4578 _IRQL_requires_(DISPATCH_LEVEL)
4579 _Requires_lock_held_(*Lock)
4580 _Releases_lock_(*Lock)
4581 NDISAPI
4582 VOID
4583 NTAPI
4584 NdisReleaseReadWriteLock(
4585   _Inout_ PNDIS_RW_LOCK Lock,
4586   _In_ _IRQL_restores_ PLOCK_STATE LockState);
4587 
4588 #if NDIS_SUPPORT_NDIS6
4589 
4590 NDISAPI
4591 VOID
4592 NTAPI
4593 NdisDprAcquireReadWriteLock(
4594   IN PNDIS_RW_LOCK Lock,
4595   IN BOOLEAN fWrite,
4596   IN PLOCK_STATE LockState);
4597 
4598 NDISAPI
4599 VOID
4600 NTAPI
4601 NdisDprReleaseReadWriteLock(
4602   IN PNDIS_RW_LOCK Lock,
4603   IN PLOCK_STATE LockState);
4604 
4605 #endif /* NDIS_SUPPORT_NDIS6 */
4606 
4607 #endif /* NDIS_SUPPORT_60_COMPATIBLE_API */
4608 
4609 _IRQL_requires_(PASSIVE_LEVEL)
4610 NDISAPI
4611 NDIS_STATUS
4612 NTAPI
4613 NdisMDeregisterDevice(
4614   _In_ NDIS_HANDLE NdisDeviceHandle);
4615 
4616 _IRQL_requires_(PASSIVE_LEVEL)
4617 NDISAPI
4618 VOID
4619 NTAPI
4620 NdisMGetDeviceProperty(
4621   _In_ NDIS_HANDLE MiniportAdapterHandle,
4622   _Inout_opt_ PDEVICE_OBJECT *PhysicalDeviceObject,
4623   _Inout_opt_ PDEVICE_OBJECT *FunctionalDeviceObject,
4624   _Inout_opt_ PDEVICE_OBJECT *NextDeviceObject,
4625   _Inout_opt_ PCM_RESOURCE_LIST *AllocatedResources,
4626   _Inout_opt_ PCM_RESOURCE_LIST *AllocatedResourcesTranslated);
4627 
4628 _IRQL_requires_(PASSIVE_LEVEL)
4629 NDISAPI
4630 NDIS_STATUS
4631 NTAPI
4632 NdisMInitializeScatterGatherDma(
4633   _In_ NDIS_HANDLE MiniportAdapterHandle,
4634   _In_ BOOLEAN Dma64BitAddresses,
4635   _In_ ULONG MaximumPhysicalMapping);
4636 
4637 _IRQL_requires_max_(DISPATCH_LEVEL)
4638 NDISAPI
4639 NDIS_STATUS
4640 NTAPI
4641 NdisMPromoteMiniport(
4642   _In_ NDIS_HANDLE MiniportAdapterHandle);
4643 
4644 _IRQL_requires_(PASSIVE_LEVEL)
4645 NDISAPI
4646 NDIS_STATUS
4647 NTAPI
4648 NdisMQueryAdapterInstanceName(
4649   _Out_ PNDIS_STRING AdapterInstanceName,
4650   _In_ NDIS_HANDLE MiniportAdapterHandle);
4651 
4652 _IRQL_requires_(PASSIVE_LEVEL)
4653 NDISAPI
4654 NDIS_STATUS
4655 NTAPI
4656 NdisMRegisterDevice(
4657   _In_ NDIS_HANDLE NdisWrapperHandle,
4658   _In_ PNDIS_STRING DeviceName,
4659   _In_ PNDIS_STRING SymbolicName,
4660   _In_reads_(IRP_MJ_PNP) PDRIVER_DISPATCH *MajorFunctions,
4661   _Out_ PDEVICE_OBJECT *pDeviceObject,
4662   _Out_ NDIS_HANDLE *NdisDeviceHandle);
4663 
4664 _IRQL_requires_(PASSIVE_LEVEL)
4665 NDISAPI
4666 VOID
4667 NTAPI
4668 NdisMRegisterUnloadHandler(
4669   _In_ NDIS_HANDLE NdisWrapperHandle,
4670   _In_ PDRIVER_UNLOAD UnloadHandler);
4671 
4672 _IRQL_requires_max_(DISPATCH_LEVEL)
4673 NDISAPI
4674 NDIS_STATUS
4675 NTAPI
4676 NdisMRemoveMiniport(
4677   _In_ NDIS_HANDLE MiniportAdapterHandle);
4678 
4679 _IRQL_requires_(PASSIVE_LEVEL)
4680 NDISAPI
4681 NDIS_STATUS
4682 NTAPI
4683 NdisMSetMiniportSecondary(
4684   _In_ NDIS_HANDLE MiniportAdapterHandle,
4685   _In_ NDIS_HANDLE PrimaryMiniportAdapterHandle);
4686 
4687 _IRQL_requires_max_(APC_LEVEL)
4688 _Success_(*Status >= 0)
4689 NDISAPI
4690 VOID
4691 NTAPI
4692 NdisOpenConfigurationKeyByIndex(
4693   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4694   _In_ NDIS_HANDLE ConfigurationHandle,
4695   _In_ ULONG Index,
4696   _Out_ PNDIS_STRING KeyName,
4697   _Out_ PNDIS_HANDLE KeyHandle);
4698 
4699 _IRQL_requires_max_(APC_LEVEL)
4700 _Success_(*Status >= 0)
4701 NDISAPI
4702 VOID
4703 NTAPI
4704 NdisOpenConfigurationKeyByName(
4705   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
4706   _In_ NDIS_HANDLE ConfigurationHandle,
4707   _In_ PNDIS_STRING SubKeyName,
4708   _Out_ PNDIS_HANDLE SubKeyHandle);
4709 
4710 _Must_inspect_result_
4711 _IRQL_requires_max_(DISPATCH_LEVEL)
4712 NDISAPI
4713 NDIS_STATUS
4714 NTAPI
4715 NdisQueryAdapterInstanceName(
4716   _Out_ PNDIS_STRING AdapterInstanceName,
4717   _In_ NDIS_HANDLE NdisBindingHandle);
4718 
4719 _Must_inspect_result_
4720 NDISAPI
4721 NDIS_STATUS
4722 NTAPI
4723 NdisQueryBindInstanceName(
4724   _Out_ PNDIS_STRING pAdapterInstanceName,
4725   _In_ NDIS_HANDLE BindingContext);
4726 
4727 _IRQL_requires_max_(DISPATCH_LEVEL)
4728 NDISAPI
4729 NDIS_STATUS
4730 NTAPI
4731 NdisWriteEventLogEntry(
4732   _In_ _Points_to_data_ PVOID LogHandle,
4733   _In_ NDIS_STATUS EventCode,
4734   _In_ ULONG UniqueEventValue,
4735   _In_ USHORT NumStrings,
4736   _In_opt_ PVOID StringsList,
4737   _In_ ULONG DataSize,
4738   _In_reads_bytes_opt_(DataSize) PVOID Data);
4739 
4740 /* Connectionless services */
4741 
4742 _Must_inspect_result_
4743 _IRQL_requires_max_(DISPATCH_LEVEL)
4744 NDISAPI
4745 NDIS_STATUS
4746 NTAPI
4747 NdisClAddParty(
4748   _In_ NDIS_HANDLE NdisVcHandle,
4749   _In_ NDIS_HANDLE ProtocolPartyContext,
4750   _In_ PCO_CALL_PARAMETERS CallParameters,
4751   _Out_ PNDIS_HANDLE NdisPartyHandle);
4752 
4753 _Must_inspect_result_
4754 _IRQL_requires_max_(DISPATCH_LEVEL)
4755 NDISAPI
4756 NDIS_STATUS
4757 NTAPI
4758 NdisClCloseAddressFamily(
4759   _In_ NDIS_HANDLE NdisAfHandle);
4760 
4761 _Must_inspect_result_
4762 _IRQL_requires_max_(DISPATCH_LEVEL)
4763 NDISAPI
4764 NDIS_STATUS
4765 NTAPI
4766 NdisClCloseCall(
4767   _In_ NDIS_HANDLE NdisVcHandle,
4768   _In_opt_ NDIS_HANDLE NdisPartyHandle,
4769   _In_reads_bytes_opt_(Size) PVOID Buffer,
4770   _In_ UINT Size);
4771 
4772 _Must_inspect_result_
4773 _IRQL_requires_max_(DISPATCH_LEVEL)
4774 NDISAPI
4775 NDIS_STATUS
4776 NTAPI
4777 NdisClDeregisterSap(
4778   _In_ NDIS_HANDLE NdisSapHandle);
4779 
4780 _Must_inspect_result_
4781 _IRQL_requires_max_(DISPATCH_LEVEL)
4782 NDISAPI
4783 NDIS_STATUS
4784 NTAPI
4785 NdisClDropParty(
4786   _In_ NDIS_HANDLE NdisPartyHandle,
4787   _In_reads_bytes_opt_(Size) PVOID Buffer,
4788   _In_opt_ UINT Size);
4789 
4790 _IRQL_requires_max_(DISPATCH_LEVEL)
4791 NDISAPI
4792 VOID
4793 NTAPI
4794 NdisClIncomingCallComplete(
4795   _In_ NDIS_STATUS Status,
4796   _In_ NDIS_HANDLE NdisVcHandle,
4797   _In_ PCO_CALL_PARAMETERS CallParameters);
4798 
4799 _Must_inspect_result_
4800 _IRQL_requires_max_(DISPATCH_LEVEL)
4801 NDISAPI
4802 NDIS_STATUS
4803 NTAPI
4804 NdisClMakeCall(
4805   _In_ NDIS_HANDLE NdisVcHandle,
4806   _Inout_ PCO_CALL_PARAMETERS CallParameters,
4807   _In_opt_ NDIS_HANDLE ProtocolPartyContext,
4808   _Out_opt_ PNDIS_HANDLE NdisPartyHandle);
4809 
4810 _Must_inspect_result_
4811 _IRQL_requires_max_(DISPATCH_LEVEL)
4812 NDISAPI
4813 NDIS_STATUS
4814 NTAPI
4815 NdisClModifyCallQoS(
4816   _In_ NDIS_HANDLE NdisVcHandle,
4817   _In_ PCO_CALL_PARAMETERS CallParameters);
4818 
4819 _Must_inspect_result_
4820 _IRQL_requires_(PASSIVE_LEVEL)
4821 NDISAPI
4822 NDIS_STATUS
4823 NTAPI
4824 NdisClOpenAddressFamily(
4825   _In_ NDIS_HANDLE NdisBindingHandle,
4826   _In_ PCO_ADDRESS_FAMILY AddressFamily,
4827   _In_ NDIS_HANDLE ProtocolAfContext,
4828   _In_ PNDIS_CLIENT_CHARACTERISTICS ClCharacteristics,
4829   _In_ UINT SizeOfClCharacteristics,
4830   _Out_ PNDIS_HANDLE NdisAfHandle);
4831 
4832 _Must_inspect_result_
4833 _IRQL_requires_max_(DISPATCH_LEVEL)
4834 NDISAPI
4835 NDIS_STATUS
4836 NTAPI
4837 NdisClRegisterSap(
4838   _In_ NDIS_HANDLE NdisAfHandle,
4839   _In_ NDIS_HANDLE ProtocolSapContext,
4840   _In_ PCO_SAP Sap,
4841   _Out_ PNDIS_HANDLE NdisSapHandle);
4842 
4843 
4844 /* Call Manager services */
4845 
4846 _Must_inspect_result_
4847 _IRQL_requires_max_(DISPATCH_LEVEL)
4848 NDISAPI
4849 NDIS_STATUS
4850 NTAPI
4851 NdisCmActivateVc(
4852   _In_ NDIS_HANDLE NdisVcHandle,
4853   _Inout_ PCO_CALL_PARAMETERS CallParameters);
4854 
4855 _IRQL_requires_max_(DISPATCH_LEVEL)
4856 NDISAPI
4857 VOID
4858 NTAPI
4859 NdisCmAddPartyComplete(
4860   _In_ NDIS_STATUS Status,
4861   _In_ NDIS_HANDLE NdisPartyHandle,
4862   _In_opt_ NDIS_HANDLE CallMgrPartyContext,
4863   _In_ PCO_CALL_PARAMETERS CallParameters);
4864 
4865 _IRQL_requires_max_(DISPATCH_LEVEL)
4866 NDISAPI
4867 VOID
4868 NTAPI
4869 NdisCmCloseAddressFamilyComplete(
4870   _In_ NDIS_STATUS Status,
4871   _In_ NDIS_HANDLE NdisAfHandle);
4872 
4873 _IRQL_requires_max_(DISPATCH_LEVEL)
4874 NDISAPI
4875 VOID
4876 NTAPI
4877 NdisCmCloseCallComplete(
4878   _In_ NDIS_STATUS Status,
4879   _In_ NDIS_HANDLE NdisVcHandle,
4880   _In_opt_ NDIS_HANDLE NdisPartyHandle);
4881 
4882 _Must_inspect_result_
4883 _IRQL_requires_max_(DISPATCH_LEVEL)
4884 NDISAPI
4885 NDIS_STATUS
4886 NTAPI
4887 NdisCmDeactivateVc(
4888   _In_ NDIS_HANDLE NdisVcHandle);
4889 
4890 _IRQL_requires_max_(DISPATCH_LEVEL)
4891 NDISAPI
4892 VOID
4893 NTAPI
4894 NdisCmDeregisterSapComplete(
4895   _In_ NDIS_STATUS Status,
4896   _In_ NDIS_HANDLE NdisSapHandle);
4897 
4898 _IRQL_requires_max_(DISPATCH_LEVEL)
4899 NDISAPI
4900 VOID
4901 NTAPI
4902 NdisCmDispatchCallConnected(
4903   _In_ NDIS_HANDLE NdisVcHandle);
4904 
4905 _Must_inspect_result_
4906 _IRQL_requires_max_(DISPATCH_LEVEL)
4907 NDISAPI
4908 NDIS_STATUS
4909 NTAPI
4910 NdisCmDispatchIncomingCall(
4911   _In_ NDIS_HANDLE NdisSapHandle,
4912   _In_ NDIS_HANDLE NdisVcHandle,
4913   _In_ PCO_CALL_PARAMETERS CallParameters);
4914 
4915 _IRQL_requires_max_(DISPATCH_LEVEL)
4916 NDISAPI
4917 VOID
4918 NTAPI
4919 NdisCmDispatchIncomingCallQoSChange(
4920   _In_ NDIS_HANDLE NdisVcHandle,
4921   _In_ PCO_CALL_PARAMETERS CallParameters);
4922 
4923 _IRQL_requires_max_(DISPATCH_LEVEL)
4924 NDISAPI
4925 VOID
4926 NTAPI
4927 NdisCmDispatchIncomingCloseCall(
4928   _In_ NDIS_STATUS CloseStatus,
4929   _In_ NDIS_HANDLE NdisVcHandle,
4930   _In_reads_bytes_opt_(Size) PVOID Buffer,
4931   _In_ UINT Size);
4932 
4933 _IRQL_requires_max_(DISPATCH_LEVEL)
4934 NDISAPI
4935 VOID
4936 NTAPI
4937 NdisCmDispatchIncomingDropParty(
4938   _In_ NDIS_STATUS DropStatus,
4939   _In_ NDIS_HANDLE NdisPartyHandle,
4940   _In_reads_bytes_opt_(Size) PVOID Buffer,
4941   _In_ UINT Size);
4942 
4943 _IRQL_requires_max_(DISPATCH_LEVEL)
4944 NDISAPI
4945 VOID
4946 NTAPI
4947 NdisCmDropPartyComplete(
4948   _In_ NDIS_STATUS Status,
4949   _In_ NDIS_HANDLE NdisPartyHandle);
4950 
4951 _IRQL_requires_max_(DISPATCH_LEVEL)
4952 NDISAPI
4953 VOID
4954 NTAPI
4955 NdisCmMakeCallComplete(
4956   _In_ NDIS_STATUS Status,
4957   _In_ NDIS_HANDLE NdisVcHandle,
4958   _In_opt_ NDIS_HANDLE NdisPartyHandle,
4959   _In_opt_ NDIS_HANDLE CallMgrPartyContext,
4960   _In_ PCO_CALL_PARAMETERS CallParameters);
4961 
4962 _IRQL_requires_max_(DISPATCH_LEVEL)
4963 NDISAPI
4964 VOID
4965 NTAPI
4966 NdisCmModifyCallQoSComplete(
4967   _In_ NDIS_STATUS Status,
4968   _In_ NDIS_HANDLE NdisVcHandle,
4969   _In_ PCO_CALL_PARAMETERS CallParameters);
4970 
4971 _IRQL_requires_max_(DISPATCH_LEVEL)
4972 NDISAPI
4973 VOID
4974 NTAPI
4975 NdisCmOpenAddressFamilyComplete(
4976   _In_ NDIS_STATUS Status,
4977   _In_ NDIS_HANDLE NdisAfHandle,
4978   _In_ NDIS_HANDLE CallMgrAfContext);
4979 
4980 _Must_inspect_result_
4981 _IRQL_requires_(PASSIVE_LEVEL)
4982 NDISAPI
4983 NDIS_STATUS
4984 NTAPI
4985 NdisCmRegisterAddressFamily(
4986   _In_ NDIS_HANDLE NdisBindingHandle,
4987   _In_ PCO_ADDRESS_FAMILY AddressFamily,
4988   _In_ PNDIS_CALL_MANAGER_CHARACTERISTICS CmCharacteristics,
4989   _In_ UINT SizeOfCmCharacteristics);
4990 
4991 _IRQL_requires_max_(DISPATCH_LEVEL)
4992 NDISAPI
4993 VOID
4994 NTAPI
4995 NdisCmRegisterSapComplete(
4996   _In_ NDIS_STATUS Status,
4997   _In_ NDIS_HANDLE NdisSapHandle,
4998   _In_ NDIS_HANDLE CallMgrSapContext);
4999 
5000 _IRQL_requires_max_(DISPATCH_LEVEL)
5001 NDISAPI
5002 NDIS_STATUS
5003 NTAPI
5004 NdisMCmActivateVc(
5005   _In_ NDIS_HANDLE NdisVcHandle,
5006   _In_ PCO_CALL_PARAMETERS CallParameters);
5007 
5008 _IRQL_requires_max_(DISPATCH_LEVEL)
5009 NDISAPI
5010 NDIS_STATUS
5011 NTAPI
5012 NdisMCmCreateVc(
5013   _In_ NDIS_HANDLE MiniportAdapterHandle,
5014   _In_ NDIS_HANDLE NdisAfHandle,
5015   _In_ NDIS_HANDLE MiniportVcContext,
5016   _Out_ PNDIS_HANDLE NdisVcHandle);
5017 
5018 _IRQL_requires_max_(DISPATCH_LEVEL)
5019 NDISAPI
5020 NDIS_STATUS
5021 NTAPI
5022 NdisMCmDeactivateVc(
5023   _In_ NDIS_HANDLE NdisVcHandle);
5024 
5025 _IRQL_requires_max_(DISPATCH_LEVEL)
5026 NDISAPI
5027 NDIS_STATUS
5028 NTAPI
5029 NdisMCmDeleteVc(
5030   _In_ NDIS_HANDLE NdisVcHandle);
5031 
5032 NDISAPI
5033 NDIS_STATUS
5034 NTAPI
5035 NdisMCmRegisterAddressFamily(
5036   IN NDIS_HANDLE  MiniportAdapterHandle,
5037   IN PCO_ADDRESS_FAMILY  AddressFamily,
5038   IN PNDIS_CALL_MANAGER_CHARACTERISTICS  CmCharacteristics,
5039   IN UINT  SizeOfCmCharacteristics);
5040 
5041 _IRQL_requires_max_(DISPATCH_LEVEL)
5042 NDISAPI
5043 NDIS_STATUS
5044 NTAPI
5045 NdisMCmRequest(
5046   _In_ NDIS_HANDLE NdisAfHandle,
5047   _In_opt_ NDIS_HANDLE NdisVcHandle,
5048   _In_opt_ NDIS_HANDLE NdisPartyHandle,
5049   _Inout_ PNDIS_REQUEST NdisRequest);
5050 
5051 
5052 /* Connection-oriented services */
5053 
5054 _Must_inspect_result_
5055 _IRQL_requires_max_(DISPATCH_LEVEL)
5056 NDISAPI
5057 NDIS_STATUS
5058 NTAPI
5059 NdisCoCreateVc(
5060   _In_ NDIS_HANDLE NdisBindingHandle,
5061   _In_opt_ NDIS_HANDLE NdisAfHandle ,
5062   _In_ NDIS_HANDLE ProtocolVcContext,
5063   _Inout_ PNDIS_HANDLE NdisVcHandle);
5064 
5065 _Must_inspect_result_
5066 _IRQL_requires_max_(DISPATCH_LEVEL)
5067 NDISAPI
5068 NDIS_STATUS
5069 NTAPI
5070 NdisCoDeleteVc(
5071   _In_ NDIS_HANDLE NdisVcHandle);
5072 
5073 _Must_inspect_result_
5074 _IRQL_requires_max_(DISPATCH_LEVEL)
5075 NDISAPI
5076 NDIS_STATUS
5077 NTAPI
5078 NdisCoRequest(
5079   _In_ NDIS_HANDLE NdisBindingHandle,
5080   _In_opt_ NDIS_HANDLE NdisAfHandle,
5081   _In_opt_ NDIS_HANDLE NdisVcHandle,
5082   _In_opt_ NDIS_HANDLE NdisPartyHandle,
5083   _Inout_ PNDIS_REQUEST NdisRequest);
5084 
5085 _IRQL_requires_max_(DISPATCH_LEVEL)
5086 NDISAPI
5087 VOID
5088 NTAPI
5089 NdisCoRequestComplete(
5090   _In_ NDIS_STATUS Status,
5091   _In_ NDIS_HANDLE NdisAfHandle,
5092   _In_opt_ NDIS_HANDLE NdisVcHandle,
5093   _In_opt_ NDIS_HANDLE NdisPartyHandle,
5094   _In_ PNDIS_REQUEST NdisRequest);
5095 
5096 _IRQL_requires_max_(DISPATCH_LEVEL)
5097 NDISAPI
5098 VOID
5099 NTAPI
5100 NdisCoSendPackets(
5101   _In_ NDIS_HANDLE NdisVcHandle,
5102   _In_ PPNDIS_PACKET PacketArray,
5103   _In_ UINT NumberOfPackets);
5104 
5105 _IRQL_requires_max_(DISPATCH_LEVEL)
5106 NDISAPI
5107 VOID
5108 NTAPI
5109 NdisMCoActivateVcComplete(
5110   _In_ NDIS_STATUS Status,
5111   _In_ NDIS_HANDLE NdisVcHandle,
5112   _In_ PCO_CALL_PARAMETERS CallParameters);
5113 
5114 _IRQL_requires_max_(DISPATCH_LEVEL)
5115 NDISAPI
5116 VOID
5117 NTAPI
5118 NdisMCoDeactivateVcComplete(
5119   _In_ NDIS_STATUS Status,
5120   _In_ NDIS_HANDLE NdisVcHandle);
5121 
5122 _IRQL_requires_(DISPATCH_LEVEL)
5123 NDISAPI
5124 VOID
5125 NTAPI
5126 NdisMCoIndicateReceivePacket(
5127   _In_ NDIS_HANDLE NdisVcHandle,
5128   _In_ PPNDIS_PACKET PacketArray,
5129   _In_ UINT NumberOfPackets);
5130 
5131 _IRQL_requires_max_(DISPATCH_LEVEL)
5132 NDISAPI
5133 VOID
5134 NTAPI
5135 NdisMCoIndicateStatus(
5136   _In_ NDIS_HANDLE MiniportAdapterHandle,
5137   _In_opt_ NDIS_HANDLE NdisVcHandle,
5138   _In_ NDIS_STATUS GeneralStatus,
5139   _In_reads_bytes_opt_(StatusBufferSize) PVOID StatusBuffer,
5140   _In_ ULONG StatusBufferSize);
5141 
5142 _IRQL_requires_(DISPATCH_LEVEL)
5143 NDISAPI
5144 VOID
5145 NTAPI
5146 NdisMCoReceiveComplete(
5147   _In_ NDIS_HANDLE MiniportAdapterHandle);
5148 
5149 _IRQL_requires_max_(DISPATCH_LEVEL)
5150 NDISAPI
5151 VOID
5152 NTAPI
5153 NdisMCoRequestComplete(
5154   _In_ NDIS_STATUS Status,
5155   _In_ NDIS_HANDLE MiniportAdapterHandle,
5156   _In_ PNDIS_REQUEST Request);
5157 
5158 _IRQL_requires_(DISPATCH_LEVEL)
5159 NDISAPI
5160 VOID
5161 NTAPI
5162 NdisMCoSendComplete(
5163   _In_ NDIS_STATUS Status,
5164   _In_ NDIS_HANDLE NdisVcHandle,
5165   _In_ PNDIS_PACKET Packet);
5166 
5167 
5168 /* NDIS 5.0 extensions for intermediate drivers */
5169 
5170 _IRQL_requires_(PASSIVE_LEVEL)
5171 NDISAPI
5172 VOID
5173 NTAPI
5174 NdisIMAssociateMiniport(
5175   _In_ NDIS_HANDLE DriverHandle,
5176   _In_ NDIS_HANDLE ProtocolHandle);
5177 
5178 _IRQL_requires_(PASSIVE_LEVEL)
5179 NDISAPI
5180 NDIS_STATUS
5181 NTAPI
5182 NdisIMCancelInitializeDeviceInstance(
5183   _In_ NDIS_HANDLE DriverHandle,
5184   _In_ PNDIS_STRING DeviceInstance);
5185 
5186 NDISAPI
5187 VOID
5188 NTAPI
5189 NdisIMCopySendCompletePerPacketInfo(
5190   IN PNDIS_PACKET  DstPacket,
5191   IN PNDIS_PACKET  SrcPacket);
5192 
5193 NDISAPI
5194 VOID
5195 NTAPI
5196 NdisIMCopySendPerPacketInfo(
5197   IN PNDIS_PACKET  DstPacket,
5198   IN PNDIS_PACKET  SrcPacket);
5199 
5200 _IRQL_requires_(PASSIVE_LEVEL)
5201 NDISAPI
5202 VOID
5203 NTAPI
5204 NdisIMDeregisterLayeredMiniport(
5205   _In_ NDIS_HANDLE DriverHandle);
5206 
5207 _IRQL_requires_max_(APC_LEVEL)
5208 NDISAPI
5209 NDIS_HANDLE
5210 NTAPI
5211 NdisIMGetBindingContext(
5212   _In_ NDIS_HANDLE NdisBindingHandle);
5213 
5214 _IRQL_requires_max_(DISPATCH_LEVEL)
5215 NDISAPI
5216 NDIS_HANDLE
5217 NTAPI
5218 NdisIMGetDeviceContext(
5219   _In_ NDIS_HANDLE MiniportAdapterHandle);
5220 
5221 _IRQL_requires_(PASSIVE_LEVEL)
5222 NDISAPI
5223 NDIS_STATUS
5224 NTAPI
5225 NdisIMInitializeDeviceInstanceEx(
5226   _In_ NDIS_HANDLE DriverHandle,
5227   _In_ PNDIS_STRING DriverInstance,
5228   _In_opt_ NDIS_HANDLE DeviceContext);
5229 
5230 /*
5231 NDISAPI
5232 PSINGLE_LIST_ENTRY
5233 NTAPI
5234 NdisInterlockedPopEntrySList(
5235   IN PSLIST_HEADER ListHead,
5236   IN PKSPIN_LOCK Lock);
5237 */
5238 #define NdisInterlockedPopEntrySList(SListHead, Lock) \
5239   ExInterlockedPopEntrySList(SListHead, &(Lock)->SpinLock)
5240 
5241 /*
5242 NDISAPI
5243 PSINGLE_LIST_ENTRY
5244 NTAPI
5245 NdisInterlockedPushEntrySList(
5246   IN PSLIST_HEADER ListHead,
5247   IN PSINGLE_LIST_ENTRY ListEntry,
5248   IN PKSPIN_LOCK Lock);
5249 */
5250 #define NdisInterlockedPushEntrySList(SListHead, SListEntry, Lock) \
5251   ExInterlockedPushEntrySList(SListHead, SListEntry, &(Lock)->SpinLock)
5252 
5253 #define NdisInterlockedFlushSList(SListHead) ExInterlockedFlushSList(SListHead)
5254 
5255 /*
5256 NDISAPI
5257 VOID
5258 NTAPI
5259 NdisQueryBufferSafe(
5260   IN PNDIS_BUFFER Buffer,
5261   OUT PVOID *VirtualAddress OPTIONAL,
5262   OUT PUINT Length,
5263   IN UINT Priority);
5264 */
5265 #define NdisQueryBufferSafe(_Buffer, _VirtualAddress, _Length, _Priority) {         \
5266   if (ARGUMENT_PRESENT(_VirtualAddress)) {                                          \
5267     *(PVOID *)(_VirtualAddress) = MmGetSystemAddressForMdlSafe(_Buffer, _Priority); \
5268   }                                                                                 \
5269   *(_Length) = MmGetMdlByteCount(_Buffer);                                          \
5270 }
5271 
5272 /* Routines for NDIS miniport drivers */
5273 
5274 #if NDIS_SUPPORT_NDIS6
5275 
5276 NDISAPI
5277 PNDIS_GENERIC_OBJECT
5278 NTAPI
5279 NdisAllocateGenericObject(
5280   PDRIVER_OBJECT DriverObject OPTIONAL,
5281   ULONG Tag,
5282   USHORT Size);
5283 
5284 NDISAPI
5285 VOID
5286 NTAPI
5287 NdisFreeGenericObject(
5288   IN PNDIS_GENERIC_OBJECT NdisObject);
5289 
5290 #endif /* NDIS_SUPPORT_NDIS6 */
5291 
5292 NDISAPI
5293 VOID
5294 NTAPI
5295 NdisInitializeWrapper(
5296   OUT PNDIS_HANDLE  NdisWrapperHandle,
5297   IN PVOID  SystemSpecific1,
5298   IN PVOID  SystemSpecific2,
5299   IN PVOID  SystemSpecific3);
5300 
5301 _Must_inspect_result_
5302 _IRQL_requires_(PASSIVE_LEVEL)
5303 __drv_preferredFunction("NdisMInitializeScatterGatherDma", "See details in NdisMAllocateMapRegisters documentation")
5304 NDISAPI
5305 NDIS_STATUS
5306 NTAPI
5307 NdisMAllocateMapRegisters(
5308   _In_ NDIS_HANDLE MiniportAdapterHandle,
5309   _In_ UINT DmaChannel,
5310   _In_ NDIS_DMA_SIZE DmaSize,
5311   _In_ ULONG PhysicalMapRegistersNeeded,
5312   _In_ ULONG MaximumPhysicalMapping);
5313 
5314 /*
5315  * VOID
5316  * NdisMArcIndicateReceive(
5317  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5318  *   IN PUCHAR  HeaderBuffer,
5319  *   IN PUCHAR  DataBuffer,
5320  *   IN UINT  Length);
5321  */
5322 #define NdisMArcIndicateReceive(MiniportAdapterHandle, \
5323                                 HeaderBuffer,          \
5324                                 DataBuffer,            \
5325                                 Length)                \
5326 {                                                      \
5327     ArcFilterDprIndicateReceive(                       \
5328         (((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->ArcDB), \
5329         (HeaderBuffer), \
5330         (DataBuffer),   \
5331         (Length));      \
5332 }
5333 
5334 /*
5335  * VOID
5336  * NdisMArcIndicateReceiveComplete(
5337  *   IN NDIS_HANDLE  MiniportAdapterHandle);
5338  */
5339 #define NdisMArcIndicateReceiveComplete(MiniportAdapterHandle) \
5340 {                                                              \
5341     if (((PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle)->EthDB)  \
5342 	    {                                                        \
5343 	        NdisMEthIndicateReceiveComplete(_H);                 \
5344 	    }                                                        \
5345                                                                \
5346     ArcFilterDprIndicateReceiveComplete(                       \
5347       ((PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle)->ArcDB);   \
5348 }
5349 
5350 _IRQL_requires_(PASSIVE_LEVEL)
5351 NDISAPI
5352 VOID
5353 NTAPI
5354 NdisMCloseLog(
5355   _In_ NDIS_HANDLE LogHandle);
5356 
5357 _IRQL_requires_(PASSIVE_LEVEL)
5358 NDISAPI
5359 NDIS_STATUS
5360 NTAPI
5361 NdisMCreateLog(
5362   _In_ NDIS_HANDLE MiniportAdapterHandle,
5363   _In_ UINT Size,
5364   _Out_ PNDIS_HANDLE LogHandle);
5365 
5366 NDISAPI
5367 VOID
5368 NTAPI
5369 NdisMDeregisterAdapterShutdownHandler(
5370   _In_ NDIS_HANDLE MiniportHandle);
5371 
5372 #if NDIS_LEGACY_MINIPORT
5373 
5374 _IRQL_requires_(PASSIVE_LEVEL)
5375 NDISAPI
5376 VOID
5377 NTAPI
5378 NdisMDeregisterInterrupt(
5379   _In_ PNDIS_MINIPORT_INTERRUPT Interrupt);
5380 
5381 _IRQL_requires_(PASSIVE_LEVEL)
5382 NDISAPI
5383 VOID
5384 NTAPI
5385 NdisMRegisterAdapterShutdownHandler(
5386   _In_ NDIS_HANDLE MiniportHandle,
5387   _In_ PVOID ShutdownContext,
5388   _In_ ADAPTER_SHUTDOWN_HANDLER ShutdownHandler);
5389 
5390 NDISAPI
5391 NDIS_STATUS
5392 NTAPI
5393 NdisMRegisterInterrupt(
5394   OUT PNDIS_MINIPORT_INTERRUPT Interrupt,
5395   IN NDIS_HANDLE MiniportAdapterHandle,
5396   IN UINT InterruptVector,
5397   IN UINT InterruptLevel,
5398   IN BOOLEAN RequestIsr,
5399   IN BOOLEAN SharedInterrupt,
5400   IN NDIS_INTERRUPT_MODE InterruptMode);
5401 
5402 NDISAPI
5403 NDIS_STATUS
5404 NTAPI
5405 NdisMRegisterMiniport(
5406   IN NDIS_HANDLE NdisWrapperHandle,
5407   IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
5408   IN UINT CharacteristicsLength);
5409 
5410 NDISAPI
5411 BOOLEAN
5412 NTAPI
5413 NdisMSynchronizeWithInterrupt(
5414   IN PNDIS_MINIPORT_INTERRUPT Interrupt,
5415   IN PVOID SynchronizeFunction,
5416   IN PVOID SynchronizeContext);
5417 #endif /* NDIS_LEGACY_MINIPORT */
5418 
5419 _IRQL_requires_(PASSIVE_LEVEL)
5420 NDISAPI
5421 VOID
5422 NTAPI
5423 NdisMDeregisterIoPortRange(
5424   _In_ NDIS_HANDLE MiniportAdapterHandle,
5425   _In_ UINT InitialPort,
5426   _In_ UINT NumberOfPorts,
5427   _In_ PVOID PortOffset);
5428 
5429 /*
5430  * VOID
5431  * NdisMEthIndicateReceive(
5432  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5433  *   IN NDIS_HANDLE  MiniportReceiveContext,
5434  *   IN PVOID  HeaderBuffer,
5435  *   IN UINT  HeaderBufferSize,
5436  *   IN PVOID  LookaheadBuffer,
5437  *   IN UINT  LookaheadBufferSize,
5438  *   IN UINT  PacketSize);
5439  */
5440 #define NdisMEthIndicateReceive(MiniportAdapterHandle,  \
5441                                 MiniportReceiveContext, \
5442                                 HeaderBuffer,           \
5443                                 HeaderBufferSize,       \
5444                                 LookaheadBuffer,        \
5445                                 LookaheadBufferSize,    \
5446                                 PacketSize)             \
5447 {                                                       \
5448     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->EthRxIndicateHandler)( \
5449 		((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->EthDB,  \
5450 		(MiniportReceiveContext), \
5451 		(HeaderBuffer),           \
5452 		(HeaderBuffer),           \
5453 		(HeaderBufferSize),       \
5454 		(LookaheadBuffer),        \
5455 		(LookaheadBufferSize),    \
5456 		(PacketSize));            \
5457 }
5458 
5459 /*
5460  * VOID
5461  * NdisMEthIndicateReceiveComplete(
5462  *   IN NDIS_HANDLE MiniportAdapterHandle);
5463  */
5464 #define NdisMEthIndicateReceiveComplete(MiniportAdapterHandle) \
5465 {                                                              \
5466     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->EthRxCompleteHandler)( \
5467         ((PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle)->EthDB);    \
5468 }
5469 
5470 /*
5471  * VOID
5472  * NdisMFddiIndicateReceive(
5473  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5474  *   IN NDIS_HANDLE  MiniportReceiveContext,
5475  *   IN PVOID  HeaderBuffer,
5476  *   IN UINT  HeaderBufferSize,
5477  *   IN PVOID  LookaheadBuffer,
5478  *   IN UINT  LookaheadBufferSize,
5479  *   IN UINT  PacketSize);
5480  */
5481 #define NdisMFddiIndicateReceive(MiniportAdapterHandle,  \
5482                                  MiniportReceiveContext, \
5483                                  HeaderBuffer,           \
5484                                  HeaderBufferSize,       \
5485                                  LookaheadBuffer,        \
5486                                  LookaheadBufferSize,    \
5487                                  PacketSize)             \
5488 {                                                        \
5489     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->FddiRxIndicateHandler)( \
5490         (((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->FddiDB),   \
5491         (MiniportReceiveContext),              \
5492         (PUCHAR)(HeaderBuffer) + 1,            \
5493         (((*(PUCHAR*)(HeaderBuffer)) & 0x40) ? \
5494             FDDI_LENGTH_OF_LONG_ADDRESS :      \
5495 		    FDDI_LENGTH_OF_SHORT_ADDRESS),     \
5496         (HeaderBuffer),                        \
5497         (HeaderBufferSize),                    \
5498         (LookaheadBuffer),                     \
5499         (LookaheadBufferSize),                 \
5500         (PacketSize));                         \
5501 }
5502 
5503 
5504 
5505 /*
5506  * VOID
5507  * NdisMFddiIndicateReceiveComplete(
5508  *   IN NDIS_HANDLE  MiniportAdapterHandle);
5509  */
5510 #define NdisMFddiIndicateReceiveComplete(MiniportAdapterHandle) \
5511 {                                                               \
5512     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->FddiRxCompleteHandler)( \
5513         ((PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle)->FddiDB);      \
5514 }
5515 
5516 _IRQL_requires_max_(DISPATCH_LEVEL)
5517 NDISAPI
5518 VOID
5519 NTAPI
5520 NdisMFlushLog(
5521   _In_ NDIS_HANDLE LogHandle);
5522 
5523 _IRQL_requires_(PASSIVE_LEVEL)
5524 NDISAPI
5525 VOID
5526 NTAPI
5527 NdisMFreeMapRegisters(
5528   _In_ NDIS_HANDLE MiniportAdapterHandle);
5529 
5530 /*
5531  * VOID
5532  * EXPORT
5533  * NdisMIndicateReceivePacket(
5534  *  IN NDIS_HANDLE  MiniportAdapterHandle,
5535  *  IN PPNDIS_PACKET  ReceivePackets,
5536  *  IN UINT  NumberOfPackets);
5537  */
5538 #define NdisMIndicateReceivePacket(MiniportAdapterHandle, \
5539   ReceivePackets, NumberOfPackets)                        \
5540   (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->PacketIndicateHandler)( \
5541   MiniportAdapterHandle, ReceivePackets, NumberOfPackets)
5542 
5543 /*
5544  * VOID
5545  * NdisMIndicateStatus(
5546  *  IN NDIS_HANDLE  MiniportAdapterHandle,
5547  *  IN NDIS_STATUS  GeneralStatus,
5548  *  IN PVOID  StatusBuffer,
5549  *  IN UINT  StatusBufferSize);
5550  */
5551 
5552 #define NdisMIndicateStatus(MiniportAdapterHandle,  \
5553    GeneralStatus, StatusBuffer, StatusBufferSize)   \
5554   (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->StatusHandler)(   \
5555   MiniportAdapterHandle, GeneralStatus, StatusBuffer, StatusBufferSize)
5556 
5557 /*
5558  * VOID
5559  * NdisMIndicateStatusComplete(
5560  *   IN NDIS_HANDLE  MiniportAdapterHandle);
5561  */
5562 #define NdisMIndicateStatusComplete(MiniportAdapterHandle) \
5563   (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->StatusCompleteHandler)( \
5564     MiniportAdapterHandle)
5565 
5566 /*
5567  * VOID
5568  * NdisMInitializeWrapper(
5569  *   OUT PNDIS_HANDLE  NdisWrapperHandle,
5570  *   IN PVOID  SystemSpecific1,
5571  *   IN PVOID  SystemSpecific2,
5572  *   IN PVOID  SystemSpecific3);
5573  */
5574 #define NdisMInitializeWrapper(NdisWrapperHandle, \
5575                                SystemSpecific1,   \
5576                                SystemSpecific2,   \
5577                                SystemSpecific3)   \
5578     NdisInitializeWrapper((NdisWrapperHandle),    \
5579                           (SystemSpecific1),      \
5580                           (SystemSpecific2),      \
5581                           (SystemSpecific3))
5582 
5583 _Must_inspect_result_
5584 _IRQL_requires_(PASSIVE_LEVEL)
5585 NDISAPI
5586 NDIS_STATUS
5587 NTAPI
5588 NdisMMapIoSpace(
5589   _Outptr_result_bytebuffer_(Length) PVOID *VirtualAddress,
5590   _In_ NDIS_HANDLE MiniportAdapterHandle,
5591   _In_ NDIS_PHYSICAL_ADDRESS PhysicalAddress,
5592   _In_ UINT Length);
5593 
5594 /*
5595  * VOID
5596  * NdisMQueryInformationComplete(
5597  *  IN NDIS_HANDLE  MiniportAdapterHandle,
5598  *  IN NDIS_STATUS  Status);
5599  */
5600 #define NdisMQueryInformationComplete(MiniportAdapterHandle, Status) \
5601   (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->QueryCompleteHandler)(MiniportAdapterHandle, Status)
5602 
5603 _Must_inspect_result_
5604 _IRQL_requires_(PASSIVE_LEVEL)
5605 NDISAPI
5606 NDIS_STATUS
5607 NTAPI
5608 NdisMRegisterIoPortRange(
5609   _Out_ PVOID *PortOffset,
5610   _In_ NDIS_HANDLE MiniportAdapterHandle,
5611   _In_ UINT InitialPort,
5612   _In_ UINT NumberOfPorts);
5613 
5614 NDISAPI
5615 VOID
5616 NTAPI
5617 NdisMSetTimer(
5618   IN PNDIS_MINIPORT_TIMER  Timer,
5619   IN UINT  MillisecondsToDelay);
5620 
5621 _IRQL_requires_max_(DISPATCH_LEVEL)
5622 NDISAPI
5623 VOID
5624 NTAPI
5625 NdisMInitializeTimer(
5626   _Inout_ PNDIS_MINIPORT_TIMER Timer,
5627   _In_ NDIS_HANDLE MiniportAdapterHandle,
5628   _In_ PNDIS_TIMER_FUNCTION TimerFunction,
5629   _In_ PVOID FunctionContext);
5630 
5631 _IRQL_requires_max_(DISPATCH_LEVEL)
5632 NDISAPI
5633 VOID
5634 NTAPI
5635 NdisMSetPeriodicTimer(
5636   _In_ PNDIS_MINIPORT_TIMER Timer,
5637   _In_ UINT MillisecondPeriod);
5638 
5639 _IRQL_requires_max_(DISPATCH_LEVEL)
5640 NDISAPI
5641 VOID
5642 NTAPI
5643 NdisMCancelTimer(
5644   _In_ PNDIS_MINIPORT_TIMER Timer,
5645   _Out_ _At_(*TimerCancelled, _Must_inspect_result_) PBOOLEAN TimerCancelled);
5646 
5647 #if !defined(NDIS_WRAPPER)
5648 
5649 /*
5650  * VOID
5651  * NdisMResetComplete(
5652  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5653  *   IN NDIS_STATUS  Status,
5654  *   IN BOOLEAN  AddressingReset);
5655  */
5656 #define NdisMResetComplete(MiniportAdapterHandle, \
5657                            Status,                \
5658                            AddressingReset)       \
5659 {                                                 \
5660     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->ResetCompleteHandler)( \
5661         MiniportAdapterHandle, Status, AddressingReset); \
5662 }
5663 
5664 /*
5665  * VOID
5666  * NdisMSendComplete(
5667  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5668  *   IN PNDIS_PACKET  Packet,
5669  *   IN NDIS_STATUS  Status);
5670  */
5671 #define	NdisMSendComplete(MiniportAdapterHandle, \
5672                           Packet,                \
5673                           Status)                \
5674 {                                                \
5675     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->SendCompleteHandler)( \
5676         MiniportAdapterHandle, Packet, Status);  \
5677 }
5678 
5679 /*
5680  * VOID
5681  * NdisMSendResourcesAvailable(
5682  *   IN NDIS_HANDLE  MiniportAdapterHandle);
5683  */
5684 #define	NdisMSendResourcesAvailable(MiniportAdapterHandle) \
5685 {                                                \
5686     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->SendResourcesHandler)( \
5687         MiniportAdapterHandle); \
5688 }
5689 
5690 /*
5691  * VOID
5692  * NdisMTransferDataComplete(
5693  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5694  *   IN PNDIS_PACKET  Packet,
5695  *   IN NDIS_STATUS  Status,
5696  *   IN UINT  BytesTransferred);
5697  */
5698 #define	NdisMTransferDataComplete(MiniportAdapterHandle, \
5699                                   Packet,                \
5700                                   Status,                \
5701                                   BytesTransferred)      \
5702 {                                                        \
5703     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->TDCompleteHandler)( \
5704         MiniportAdapterHandle, Packet, Status, BytesTransferred)           \
5705 }
5706 
5707 #endif /* !_NDIS_ */
5708 
5709 
5710 /*
5711  * VOID
5712  * NdisMSetAttributes(
5713  *  IN NDIS_HANDLE  MiniportAdapterHandle,
5714  *  IN NDIS_HANDLE  MiniportAdapterContext,
5715  *  IN BOOLEAN  BusMaster,
5716  *  IN NDIS_INTERFACE_TYPE  AdapterType);
5717  */
5718 #define NdisMSetAttributes(MiniportAdapterHandle,   \
5719                            MiniportAdapterContext,  \
5720                            BusMaster,               \
5721                            AdapterType)             \
5722   NdisMSetAttributesEx(MiniportAdapterHandle,       \
5723     MiniportAdapterContext,                         \
5724     0,                                              \
5725     (BusMaster) ? NDIS_ATTRIBUTE_BUS_MASTER : 0,    \
5726     AdapterType)
5727 
5728 NDISAPI
5729 VOID
5730 NTAPI
5731 NdisMSetAttributesEx(
5732   IN NDIS_HANDLE  MiniportAdapterHandle,
5733   IN NDIS_HANDLE  MiniportAdapterContext,
5734   IN UINT  CheckForHangTimeInSeconds   OPTIONAL,
5735   IN ULONG  AttributeFlags,
5736   IN NDIS_INTERFACE_TYPE AdapterType);
5737 
5738 /*
5739  * VOID
5740  * NdisMSetInformationComplete(
5741  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5742  *   IN NDIS_STATUS  Status);
5743  */
5744 #define NdisMSetInformationComplete(MiniportAdapterHandle, \
5745                                     Status) \
5746   (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->SetCompleteHandler)( \
5747     MiniportAdapterHandle, Status)
5748 
5749 _IRQL_requires_max_(APC_LEVEL)
5750 NDISAPI
5751 VOID
5752 NTAPI
5753 NdisMSleep(
5754   _In_ ULONG MicrosecondsToSleep);
5755 
5756 /*
5757  * VOID
5758  * NdisMTrIndicateReceive(
5759  *   IN NDIS_HANDLE  MiniportAdapterHandle,
5760  *   IN NDIS_HANDLE  MiniportReceiveContext,
5761  *   IN PVOID  HeaderBuffer,
5762  *   IN UINT  HeaderBufferSize,
5763  *   IN PVOID  LookaheadBuffer,
5764  *   IN UINT  LookaheadBufferSize,
5765  *   IN UINT  PacketSize);
5766  */
5767 #define NdisMTrIndicateReceive(MiniportAdapterHandle,  \
5768                                MiniportReceiveContext, \
5769                                HeaderBuffer,           \
5770                                HeaderBufferSize,       \
5771                                LookaheadBuffer,        \
5772                                LookaheadBufferSize,    \
5773                                PacketSize)             \
5774 {                                                      \
5775     (*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->TrRxIndicateHandler)( \
5776       (((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->TrDB),     \
5777 		(MiniportReceiveContext), \
5778 		(HeaderBuffer),           \
5779 		(HeaderBuffer),           \
5780 		(HeaderBufferSize),       \
5781 		(LookaheadBuffer),        \
5782 		(LookaheadBufferSize),    \
5783 		(PacketSize));            \
5784 }
5785 
5786 /*
5787  * VOID
5788  * NdisMTrIndicateReceiveComplete(
5789  *   IN NDIS_HANDLE  MiniportAdapterHandle);
5790  */
5791 #define NdisMTrIndicateReceiveComplete(MiniportAdapterHandle) \
5792 {                                                             \
5793 	(*((PNDIS_MINIPORT_BLOCK)(MiniportAdapterHandle))->TrRxCompleteHandler)( \
5794     ((PNDIS_MINIPORT_BLOCK)MiniportAdapterHandle)->TrDB);    \
5795 }
5796 
5797 _IRQL_requires_max_(DISPATCH_LEVEL)
5798 NDISAPI
5799 NDIS_STATUS
5800 NTAPI
5801 NdisMWriteLogData(
5802   _In_ NDIS_HANDLE LogHandle,
5803   _In_reads_bytes_(LogBufferSize) PVOID LogBuffer,
5804   _In_ UINT LogBufferSize);
5805 
5806 _IRQL_requires_(PASSIVE_LEVEL)
5807 NDISAPI
5808 VOID
5809 NTAPI
5810 NdisMQueryAdapterResources(
5811   _Out_ PNDIS_STATUS Status,
5812   _In_ NDIS_HANDLE WrapperConfigurationContext,
5813   _Out_ PNDIS_RESOURCE_LIST ResourceList,
5814   _Inout_ PUINT BufferSize);
5815 
5816 _IRQL_requires_(PASSIVE_LEVEL)
5817 NDISAPI
5818 VOID
5819 NTAPI
5820 NdisTerminateWrapper(
5821   _In_ NDIS_HANDLE NdisWrapperHandle,
5822   _In_opt_ PVOID SystemSpecific);
5823 
5824 _IRQL_requires_(PASSIVE_LEVEL)
5825 NDISAPI
5826 VOID
5827 NTAPI
5828 NdisMUnmapIoSpace(
5829   _In_ NDIS_HANDLE MiniportAdapterHandle,
5830   _In_reads_bytes_(Length) PVOID VirtualAddress,
5831   _In_ UINT Length);
5832 
5833 /* Event functions */
5834 
5835 _IRQL_requires_max_(DISPATCH_LEVEL)
5836 NDISAPI
5837 VOID
5838 NTAPI
5839 NdisInitializeEvent(
5840   _Out_ PNDIS_EVENT Event);
5841 
5842 _IRQL_requires_max_(DISPATCH_LEVEL)
5843 NDISAPI
5844 VOID
5845 NTAPI
5846 NdisSetEvent(
5847   _In_ PNDIS_EVENT Event);
5848 
5849 _IRQL_requires_max_(DISPATCH_LEVEL)
5850 NDISAPI
5851 VOID
5852 NTAPI
5853 NdisResetEvent(
5854   _In_ PNDIS_EVENT Event);
5855 
5856 _When_(MsToWait != 0, _Check_return_)
5857 _IRQL_requires_(PASSIVE_LEVEL)
5858 NDISAPI
5859 BOOLEAN
5860 NTAPI
5861 NdisWaitEvent(
5862   _In_ PNDIS_EVENT Event,
5863   _In_ UINT MsToWait);
5864 
5865 /* NDIS intermediate miniport structures */
5866 
5867 typedef VOID (NTAPI *W_MINIPORT_CALLBACK)(
5868   IN NDIS_HANDLE  MiniportAdapterContext,
5869   IN PVOID  CallbackContext);
5870 
5871 /* Routines for intermediate miniport drivers */
5872 
5873 _IRQL_requires_(PASSIVE_LEVEL)
5874 NDISAPI
5875 NDIS_STATUS
5876 NTAPI
5877 NdisIMDeInitializeDeviceInstance(
5878   _In_ NDIS_HANDLE NdisMiniportHandle);
5879 
5880 /*
5881  * NDIS_STATUS
5882  * NdisIMInitializeDeviceInstance(
5883  *   IN NDIS_HANDLE  DriverHandle,
5884  *   IN PNDIS_STRING  DeviceInstance);
5885  */
5886 #define NdisIMInitializeDeviceInstance(DriverHandle, DeviceInstance) \
5887   NdisIMInitializeDeviceInstanceEx(DriverHandle, DeviceInstance, NULL)
5888 
5889 /* Functions obsoleted by NDIS 5.0 */
5890 
5891 NDISAPI
5892 VOID
5893 NTAPI
5894 NdisFreeDmaChannel(
5895   IN PNDIS_HANDLE  NdisDmaHandle);
5896 
5897 NDISAPI
5898 VOID
5899 NTAPI
5900 NdisSetupDmaTransfer(
5901   OUT PNDIS_STATUS  Status,
5902   IN PNDIS_HANDLE  NdisDmaHandle,
5903   IN PNDIS_BUFFER  Buffer,
5904   IN ULONG  Offset,
5905   IN ULONG  Length,
5906   IN BOOLEAN  WriteToDevice);
5907 
5908 /*
5909 NDISAPI
5910 NTSTATUS
5911 NTAPI
5912 NdisUpcaseUnicodeString(
5913   OUT PUNICODE_STRING DestinationString,
5914   IN PUNICODE_STRING SourceString);
5915 */
5916 #define NdisUpcaseUnicodeString(_d, _s) RtlUpcaseUnicodeString(_d, _s, FALSE)
5917 
5918 
5919 /* Routines for NDIS protocol drivers */
5920 
5921 #if NDIS_LEGACY_PROTOCOL
5922 
5923 NDISAPI
5924 NDIS_STATUS
5925 NTAPI
5926 NdisIMRegisterLayeredMiniport(
5927   _In_ NDIS_HANDLE NdisWrapperHandle,
5928   _In_ PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics,
5929   _In_ UINT CharacteristicsLength,
5930   _Out_ PNDIS_HANDLE DriverHandle);
5931 
5932 NDISAPI
5933 VOID
5934 NTAPI
5935 NdisTransferData(
5936   OUT PNDIS_STATUS Status,
5937   IN NDIS_HANDLE NdisBindingHandle,
5938   IN NDIS_HANDLE MacReceiveContext,
5939   IN UINT ByteOffset,
5940   IN UINT BytesToTransfer,
5941   IN OUT PNDIS_PACKET Packet,
5942   OUT PUINT BytesTransferred);
5943 
5944 NDISAPI
5945 VOID
5946 NTAPI
5947 NdisSend(
5948   OUT PNDIS_STATUS Status,
5949   IN NDIS_HANDLE NdisBindingHandle,
5950   IN PNDIS_PACKET Packet);
5951 
5952 NDISAPI
5953 VOID
5954 NTAPI
5955 NdisSendPackets(
5956   IN NDIS_HANDLE NdisBindingHandle,
5957   IN PPNDIS_PACKET PacketArray,
5958   IN UINT NumberOfPackets);
5959 
5960 _IRQL_requires_max_(DISPATCH_LEVEL)
5961 NDISAPI
5962 VOID
5963 NTAPI
5964 NdisRequest(
5965   _Out_ PNDIS_STATUS Status,
5966   _In_ NDIS_HANDLE NdisBindingHandle,
5967   _In_ PNDIS_REQUEST NdisRequest);
5968 
5969 _IRQL_requires_max_(DISPATCH_LEVEL)
5970 NDISAPI
5971 VOID
5972 NTAPI
5973 NdisReset(
5974   _Out_ PNDIS_STATUS Status,
5975   _In_ NDIS_HANDLE NdisBindingHandle);
5976 
5977 _IRQL_requires_max_(DISPATCH_LEVEL)
5978 NDISAPI
5979 VOID
5980 NTAPI
5981 NdisDeregisterProtocol(
5982   _Out_ PNDIS_STATUS Status,
5983   _In_ NDIS_HANDLE NdisProtocolHandle);
5984 
5985 _IRQL_requires_(PASSIVE_LEVEL)
5986 NDISAPI
5987 VOID
5988 NTAPI
5989 NdisOpenAdapter(
5990   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
5991   _Out_ PNDIS_STATUS OpenErrorStatus,
5992   _Out_ PNDIS_HANDLE NdisBindingHandle,
5993   _Out_ PUINT SelectedMediumIndex,
5994   _In_reads_(MediumArraySize) PNDIS_MEDIUM MediumArray,
5995   _In_ UINT MediumArraySize,
5996   _In_ NDIS_HANDLE NdisProtocolHandle,
5997   _In_ NDIS_HANDLE ProtocolBindingContext,
5998   _In_ PNDIS_STRING AdapterName,
5999   _In_ UINT OpenOptions,
6000   _In_opt_ PSTRING AddressingInformation);
6001 
6002 _IRQL_requires_(PASSIVE_LEVEL)
6003 NDISAPI
6004 VOID
6005 NTAPI
6006 NdisCloseAdapter(
6007   _Out_ PNDIS_STATUS Status,
6008   _In_ NDIS_HANDLE NdisBindingHandle);
6009 
6010 _IRQL_requires_(PASSIVE_LEVEL)
6011 NDISAPI
6012 VOID
6013 NTAPI
6014 NdisCompleteBindAdapter(
6015   _In_ NDIS_HANDLE BindAdapterContext,
6016   _In_ NDIS_STATUS Status,
6017   _In_ NDIS_STATUS OpenStatus);
6018 
6019 _IRQL_requires_(PASSIVE_LEVEL)
6020 NDISAPI
6021 VOID
6022 NTAPI
6023 NdisCompleteUnbindAdapter(
6024   _In_ NDIS_HANDLE UnbindAdapterContext,
6025   _In_ NDIS_STATUS Status);
6026 
6027 NDISAPI
6028 VOID
6029 NTAPI
6030 NdisSetProtocolFilter(
6031   _At_(*Status, _Must_inspect_result_) _Out_ PNDIS_STATUS Status,
6032   _In_ NDIS_HANDLE NdisBindingHandle,
6033   _In_ RECEIVE_HANDLER ReceiveHandler,
6034   _In_ RECEIVE_PACKET_HANDLER ReceivePacketHandler,
6035   _In_ NDIS_MEDIUM Medium,
6036   _In_ UINT Offset,
6037   _In_ UINT Size,
6038   _In_ PUCHAR Pattern);
6039 
6040 _IRQL_requires_max_(DISPATCH_LEVEL)
6041 NDISAPI
6042 VOID
6043 NTAPI
6044 NdisGetDriverHandle(
6045   _In_ PNDIS_HANDLE NdisBindingHandle,
6046   _Out_ PNDIS_HANDLE NdisDriverHandle);
6047 
6048 _IRQL_requires_(PASSIVE_LEVEL)
6049 NDISAPI
6050 VOID
6051 NTAPI
6052 NdisOpenProtocolConfiguration(
6053   _Out_ PNDIS_STATUS Status,
6054   _Out_ PNDIS_HANDLE ConfigurationHandle,
6055   _In_ PNDIS_STRING ProtocolSection);
6056 
6057 _IRQL_requires_(PASSIVE_LEVEL)
6058 NDISAPI
6059 VOID
6060 NTAPI
6061 NdisCompletePnPEvent(
6062   _In_ NDIS_STATUS Status,
6063   _In_ NDIS_HANDLE NdisBindingHandle,
6064   _In_ PNET_PNP_EVENT NetPnPEvent);
6065 
6066 /*
6067  * VOID
6068  * NdisSetSendFlags(
6069  *   IN PNDIS_PACKET Packet,
6070  *   IN UINT Flags);
6071  */
6072 #define NdisSetSendFlags(_Packet,_Flags)(_Packet)->Private.Flags = (_Flags)
6073 
6074 #define NdisQuerySendFlags(_Packet,_Flags) *(_Flags) = (_Packet)->Private.Flags
6075 
6076 _IRQL_requires_max_(DISPATCH_LEVEL)
6077 NDISAPI
6078 VOID
6079 NTAPI
6080 NdisReturnPackets(
6081   _In_reads_(NumberOfPackets) PNDIS_PACKET *PacketsToReturn,
6082   _In_ UINT NumberOfPackets);
6083 
6084 _Must_inspect_result_
6085 _IRQL_requires_max_(DISPATCH_LEVEL)
6086 NDISAPI
6087 PNDIS_PACKET
6088 NTAPI
6089 NdisGetReceivedPacket(
6090   _In_ PNDIS_HANDLE NdisBindingHandle,
6091   _In_ PNDIS_HANDLE MacContext);
6092 
6093 _IRQL_requires_max_(DISPATCH_LEVEL)
6094 NDISAPI
6095 VOID
6096 NTAPI
6097 NdisCancelSendPackets(
6098   _In_ NDIS_HANDLE NdisBindingHandle,
6099   _In_ _Points_to_data_ PVOID CancelId);
6100 
6101 _Must_inspect_result_
6102 _IRQL_requires_max_(DISPATCH_LEVEL)
6103 NDISAPI
6104 NDIS_STATUS
6105 NTAPI
6106 NdisQueryPendingIOCount(
6107   _In_ _Points_to_data_ PVOID NdisBindingHandle,
6108   _Out_ PULONG IoCount);
6109 
6110 _IRQL_requires_(PASSIVE_LEVEL)
6111 NDISAPI
6112 VOID
6113 NTAPI
6114 NdisRegisterProtocol(
6115   _Out_ PNDIS_STATUS Status,
6116   _Out_ PNDIS_HANDLE NdisProtocolHandle,
6117   _In_ PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics,
6118   _In_ UINT CharacteristicsLength);
6119 
6120 #endif /* NDIS_LEGACY_PROTOCOL */
6121 
6122 _IRQL_requires_max_(DISPATCH_LEVEL)
6123 NDISAPI
6124 UCHAR
6125 NTAPI
6126 NdisGeneratePartialCancelId(VOID);
6127 
6128 _IRQL_requires_(PASSIVE_LEVEL)
6129 NDISAPI
6130 VOID
6131 NTAPI
6132 NdisReEnumerateProtocolBindings(
6133   _In_ NDIS_HANDLE NdisProtocolHandle);
6134 
6135 NDISAPI
6136 VOID
6137 NTAPI
6138 NdisRegisterTdiCallBack(
6139   _In_ TDI_REGISTER_CALLBACK RegisterCallback,
6140   _In_ TDI_PNP_HANDLER PnPHandler);
6141 
6142 NDISAPI
6143 VOID
6144 NTAPI
6145 NdisDeregisterTdiCallBack(VOID);
6146 
6147 /* Obsoleted in Windows XP */
6148 
6149 /* Prototypes for NDIS_MAC_CHARACTERISTICS */
6150 
6151 typedef NDIS_STATUS (*OPEN_ADAPTER_HANDLER)(
6152   OUT PNDIS_STATUS  OpenErrorStatus,
6153   OUT NDIS_HANDLE  *MacBindingHandle,
6154   OUT PUINT  SelectedMediumIndex,
6155   IN PNDIS_MEDIUM  MediumArray,
6156   IN UINT  MediumArraySize,
6157   IN NDIS_HANDLE  NdisBindingContext,
6158   IN NDIS_HANDLE  MacAdapterContext,
6159   IN UINT  OpenOptions,
6160   IN PSTRING  AddressingInformation  OPTIONAL);
6161 
6162 typedef NDIS_STATUS (NTAPI *CLOSE_ADAPTER_HANDLER)(
6163   IN NDIS_HANDLE  MacBindingHandle);
6164 
6165 typedef NDIS_STATUS (NTAPI *WAN_TRANSFER_DATA_HANDLER)(
6166   VOID);
6167 
6168 typedef NDIS_STATUS (NTAPI *QUERY_GLOBAL_STATISTICS_HANDLER)(
6169   IN NDIS_HANDLE  MacAdapterContext,
6170   IN PNDIS_REQUEST  NdisRequest);
6171 
6172 typedef VOID (NTAPI *UNLOAD_MAC_HANDLER)(
6173   IN NDIS_HANDLE  MacMacContext);
6174 
6175 typedef NDIS_STATUS (NTAPI *ADD_ADAPTER_HANDLER)(
6176   IN NDIS_HANDLE  MacMacContext,
6177   IN NDIS_HANDLE  WrapperConfigurationContext,
6178   IN PNDIS_STRING  AdapterName);
6179 
6180 typedef VOID (*REMOVE_ADAPTER_HANDLER)(
6181   IN NDIS_HANDLE  MacAdapterContext);
6182 
6183 typedef struct _NDIS_MAC_CHARACTERISTICS {
6184   UCHAR  MajorNdisVersion;
6185   UCHAR  MinorNdisVersion;
6186   USHORT  Filler;
6187   UINT  Reserved;
6188   OPEN_ADAPTER_HANDLER  OpenAdapterHandler;
6189   CLOSE_ADAPTER_HANDLER  CloseAdapterHandler;
6190   SEND_HANDLER  SendHandler;
6191   TRANSFER_DATA_HANDLER  TransferDataHandler;
6192   RESET_HANDLER  ResetHandler;
6193   REQUEST_HANDLER  RequestHandler;
6194   QUERY_GLOBAL_STATISTICS_HANDLER  QueryGlobalStatisticsHandler;
6195   UNLOAD_MAC_HANDLER  UnloadMacHandler;
6196   ADD_ADAPTER_HANDLER  AddAdapterHandler;
6197   REMOVE_ADAPTER_HANDLER  RemoveAdapterHandler;
6198   NDIS_STRING  Name;
6199 } NDIS_MAC_CHARACTERISTICS, *PNDIS_MAC_CHARACTERISTICS;
6200 
6201 typedef	NDIS_MAC_CHARACTERISTICS        NDIS_WAN_MAC_CHARACTERISTICS;
6202 typedef	NDIS_WAN_MAC_CHARACTERISTICS    *PNDIS_WAN_MAC_CHARACTERISTICS;
6203 
6204 #ifdef __cplusplus
6205 }
6206 #endif
6207 
6208 #endif /* _NDIS_ */
6209 
6210 /* EOF */
6211