VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/VBoxNetFlt/win/drv/VBoxNetFltCmn-win.h@ 41010

Last change on this file since 41010 was 38738, checked in by vboxsync, 13 years ago

Less Assert redefinition, adding RT_NO_STRICT to help.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.5 KB
Line 
1/* $Id: VBoxNetFltCmn-win.h 38738 2011-09-13 14:31:50Z vboxsync $ */
2/** @file
3 * VBoxNetFltCmn-win.h - Bridged Networking Driver, Windows Specific Code.
4 * Common header with configuration defines and global defs
5 */
6
7/*
8 * Copyright (C) 2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___VBoxNetFltCmn_win_h___
20#define ___VBoxNetFltCmn_win_h___
21
22#define LOG_GROUP LOG_GROUP_NET_FLT_DRV
23
24/* debugging flags */
25#ifdef DEBUG
26//# define DEBUG_NETFLT_PACKETS
27# ifndef DEBUG_misha
28# define RT_NO_STRICT
29# endif
30/* # define DEBUG_NETFLT_LOOPBACK */
31/* receive logic has several branches */
32/* the DEBUG_NETFLT_RECV* macros used to debug the ProtocolReceive callback
33 * which is typically not used in case the underlying miniport indicates the packets with NdisMIndicateReceivePacket
34 * the best way to debug the ProtocolReceive (which in turn has several branches) is to enable the DEBUG_NETFLT_RECV
35 * one by one in the below order, i.e.
36 * first DEBUG_NETFLT_RECV
37 * then DEBUG_NETFLT_RECV + DEBUG_NETFLT_RECV_NOPACKET */
38//# define DEBUG_NETFLT_RECV
39//# define DEBUG_NETFLT_RECV_NOPACKET
40//# define DEBUG_NETFLT_RECV_TRANSFERDATA
41/* use ExAllocatePoolWithTag instead of NdisAllocateMemoryWithTag */
42// #define DEBUG_NETFLT_USE_EXALLOC
43#endif
44
45#include <VBox/intnet.h>
46#include <VBox/log.h>
47#include <VBox/err.h>
48#include <VBox/version.h>
49#include <iprt/initterm.h>
50#include <iprt/assert.h>
51#include <iprt/spinlock.h>
52#include <iprt/semaphore.h>
53#include <iprt/process.h>
54#include <iprt/alloc.h>
55#include <iprt/alloca.h>
56#include <iprt/time.h>
57#include <iprt/net.h>
58
59RT_C_DECLS_BEGIN
60/* ntddk.h has a missing #pragma pack(), work around it
61 * see #ifdef VBOX_WITH_WORKAROUND_MISSING_PACK below for detail */
62#define VBOX_WITH_WORKAROUND_MISSING_PACK
63#if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
64# define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
65# define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
66# define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
67# define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
68# define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
69# define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
70# define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
71# define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
72# pragma warning(disable : 4163)
73# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
74# pragma warning(disable : 4103)
75# endif
76# include <ntddk.h>
77# pragma warning(default : 4163)
78# ifdef VBOX_WITH_WORKAROUND_MISSING_PACK
79# pragma pack()
80# pragma warning(default : 4103)
81# endif
82# undef _InterlockedExchange
83# undef _InterlockedExchangeAdd
84# undef _InterlockedCompareExchange
85# undef _InterlockedAddLargeStatistic
86# undef _interlockedbittestandset
87# undef _interlockedbittestandreset
88# undef _interlockedbittestandset64
89# undef _interlockedbittestandreset64
90# include <ndis.h>
91#else
92//# include <ntddk.h>
93/* can include ndis.h right away */
94# include <ndis.h>
95#endif
96RT_C_DECLS_END
97
98#define VBOXNETFLT_OS_SPECFIC 1
99
100/** version
101 * NOTE: we are NOT using NDIS 5.1 features now */
102#ifdef NDIS51_MINIPORT
103# define VBOXNETFLT_VERSION_MP_NDIS_MAJOR 5
104# define VBOXNETFLT_VERSION_MP_NDIS_MINOR 1
105#else
106# define VBOXNETFLT_VERSION_MP_NDIS_MAJOR 5
107# define VBOXNETFLT_VERSION_MP_NDIS_MINOR 0
108#endif
109
110#ifndef VBOXNETADP
111#ifdef NDIS51
112# define VBOXNETFLT_VERSION_PT_NDIS_MAJOR 5
113# define VBOXNETFLT_VERSION_PT_NDIS_MINOR 1 /* todo: use 0 here as well ? */
114#else
115# define VBOXNETFLT_VERSION_PT_NDIS_MAJOR 5
116# define VBOXNETFLT_VERSION_PT_NDIS_MINOR 0
117#endif
118
119# define VBOXNETFLT_NAME_PROTOCOL L"VBoxNetFlt"
120/** device to be used to prevent the driver unload & ioctl interface (if necessary in the future) */
121# define VBOXNETFLT_NAME_LINK L"\\DosDevices\\Global\\VBoxNetFlt"
122# define VBOXNETFLT_NAME_DEVICE L"\\Device\\VBoxNetFlt"
123#else
124# define VBOXNETFLT_NAME_LINK L"\\DosDevices\\Global\\VBoxNetAdp"
125# define VBOXNETFLT_NAME_DEVICE L"\\Device\\VBoxNetAdp"
126#endif
127
128typedef struct VBOXNETFLTINS *PVBOXNETFLTINS;
129
130/** configuration */
131
132/** Ndis Packet pool settings
133 * these are applied to both receive and send packet pools */
134/* number of packets for normal used */
135#define VBOXNETFLT_PACKET_POOL_SIZE_NORMAL 0x000000FF
136/* number of additional overflow packets */
137#define VBOXNETFLT_PACKET_POOL_SIZE_OVERFLOW 0x0000FF00
138
139/** packet queue size used when the driver is working in the "active" mode */
140#define VBOXNETFLT_PACKET_INFO_POOL_SIZE 0x0000FFFF
141
142#ifndef VBOXNETADP
143/** memory tag used for memory allocations
144 * (VBNF stands for VBox NetFlt) */
145# define VBOXNETFLT_MEM_TAG 'FNBV'
146#else
147/** memory tag used for memory allocations
148 * (VBNA stands for VBox NetAdp) */
149# define VBOXNETFLT_MEM_TAG 'ANBV'
150#endif
151
152/** receive and transmit Ndis buffer pool size */
153#define VBOXNETFLT_BUFFER_POOL_SIZE_TX 128
154#define VBOXNETFLT_BUFFER_POOL_SIZE_RX 128
155
156#define VBOXNETFLT_PACKET_ETHEADER_SIZE 14
157#define VBOXNETFLT_PACKET_HEADER_MATCH_SIZE 24
158#define VBOXNETFLT_PACKET_QUEUE_SG_SEGS_ALLOC 32
159
160
161#if defined(DEBUG_NETFLT_PACKETS) || !defined(VBOX_LOOPBACK_USEFLAGS)
162# define VBOXNETFLT_PACKETMATCH_LENGTH (VBOXNETFLT_PACKET_ETHEADER_SIZE + 2)
163#endif
164
165#ifdef VBOXNETADP
166#define VBOXNETADP_HEADER_SIZE 14
167#define VBOXNETADP_MAX_DATA_SIZE 1500
168#define VBOXNETADP_MAX_PACKET_SIZE (VBOXNETADP_HEADER_SIZE + VBOXNETADP_MAX_DATA_SIZE)
169#define VBOXNETADP_MIN_PACKET_SIZE 60
170/* link speed 100Mbps (measured in 100 bps) */
171#define VBOXNETADP_LINK_SPEED 1000000
172#define VBOXNETADP_MAX_LOOKAHEAD_SIZE VBOXNETADP_MAX_DATA_SIZE
173#define VBOXNETADP_VENDOR_ID 0x080027
174#define VBOXNETADP_VENDOR_DRIVER_VERSION 0x00010000
175#define VBOXNETADP_VENDOR_DESC "Sun"
176#define VBOXNETADP_MAX_MCAST_LIST 32
177#define VBOXNETADP_ETH_ADDRESS_LENGTH 6
178
179//#define VBOXNETADP_REPORT_DISCONNECTED
180#endif
181/* type defs */
182
183/** Flag specifying that the type of enqueued packet
184 * if set the info contains the PINTNETSG packet
185 * if clear the packet info contains the PNDIS_PACKET packet
186 * Typically the packet queue we are maintaining contains PNDIS_PACKETs only,
187 * however in case the underlying miniport indicates a packet with the NDIS_STATUS_RESOURCES status
188 * we MUST return the packet back to the miniport immediately
189 * this is why we are creating the INTNETSG, copying the ndis packet info there and enqueueing it */
190#define VBOXNETFLT_PACKET_SG 0x00000001
191
192/** the flag specifying that the packet source
193 * if set the packet comes from the host (upperlying protocol)
194 * if clear the packet comes from the wire (underlying miniport) */
195#define VBOXNETFLT_PACKET_SRC_HOST 0x00000002
196
197#ifndef VBOXNETFLT_NO_PACKET_QUEUE
198/** flag specifying the packet was originated by our driver
199 * i.e. we could use it on our needs and should not return it
200 * we are enqueueing "our" packets on ProtocolReceive call-back when
201 * Ndis does not give us a receive packet (the driver below us has called NdisM..IndicateReceive)
202 * this is supported for Ndis Packet only */
203#define VBOXNETFLT_PACKET_MINE 0x00000004
204
205/** flag passed to vboxNetFltWinQuEnqueuePacket specifying that the packet should be copied
206 * this is supported for Ndis Packet only */
207#define VBOXNETFLT_PACKET_COPY 0x00000008
208#endif
209
210/** packet queue element containing the packet info */
211typedef struct VBOXNETFLT_PACKET_INFO
212{
213 /** list entry used for enqueueing the info */
214 LIST_ENTRY ListEntry;
215 /** pointer to the pool containing this packet info */
216 struct VBOXNETFLT_PACKET_INFO_POOL *pPool;
217 /** flags describing the referenced packet. Contains PACKET_xxx flags (i.e. PACKET_SG, PACKET_SRC_HOST) */
218 uint32_t fFlags;
219 /** pointer to the packet this info represents */
220 PVOID pPacket;
221} VBOXNETFLT_PACKET_INFO, *PVBOXNETFLT_PACKET_INFO;
222
223/* paranoid check to make sure the elements in the packet info array are properly aligned */
224AssertCompile((sizeof(VBOXNETFLT_PACKET_INFO) & (sizeof(PVOID) - 1)) == 0);
225
226/** represents the packet queue */
227typedef LIST_ENTRY PVBOXNETFLT_ACKET_QUEUE, *PVBOXNETFLT_PACKET_QUEUE;
228
229/*
230 * we are using non-interlocked versions of LIST_ENTRY-related operations macros and synchronize
231 * access to the queue and its elements by acquiring/releasing a spinlock using Ndis[Acquire,Release]Spinlock
232 *
233 * we are NOT using interlocked versions of insert/remove head/tail list functions because we need to iterate though
234 * the queue elements as well as remove elements from the midle of the queue
235 *
236 * * @todo: it seems that we can switch to using interlocked versions of list-entry functions
237 * since we have removed all functionality (mentioned above, i.e. queue elements iteration, etc.) that might prevent us from doing this
238 */
239typedef struct VBOXNETFLT_INTERLOCKED_PACKET_QUEUE
240{
241 /** queue */
242 PVBOXNETFLT_ACKET_QUEUE Queue;
243 /** queue lock */
244 NDIS_SPIN_LOCK Lock;
245} VBOXNETFLT_INTERLOCKED_PACKET_QUEUE, *PVBOXNETFLT_INTERLOCKED_PACKET_QUEUE;
246
247typedef struct VBOXNETFLT_SINGLE_LIST
248{
249 /** queue */
250 SINGLE_LIST_ENTRY Head;
251 /** pointer to the list tail. used to enqueue elements to the tail of the list */
252 PSINGLE_LIST_ENTRY pTail;
253} VBOXNETFLT_SINGLE_LIST, *PVBOXNETFLT_SINGLE_LIST;
254
255typedef struct VBOXNETFLT_INTERLOCKED_SINGLE_LIST
256{
257 /** queue */
258 VBOXNETFLT_SINGLE_LIST List;
259 /** queue lock */
260 NDIS_SPIN_LOCK Lock;
261} VBOXNETFLT_INTERLOCKED_SINGLE_LIST, *PVBOXNETFLT_INTERLOCKED_SINGLE_LIST;
262
263/** packet info pool contains free packet info elements to be used for the packet queue
264 * we are using the pool mechanism to allocate packet queue elements
265 * the pool mechanism is pretty simple now, we are allocating a bunch of memory
266 * for maintaining VBOXNETFLT_PACKET_INFO_POOL_SIZE queue elements and just returning null when the pool is exhausted
267 * This mechanism seems to be enough for now since we are using VBOXNETFLT_PACKET_INFO_POOL_SIZE = 0xffff which is
268 * the maximum size of packets the ndis packet pool supports */
269typedef struct VBOXNETFLT_PACKET_INFO_POOL
270{
271 /** free packet info queue */
272 VBOXNETFLT_INTERLOCKED_PACKET_QUEUE Queue;
273 /** memory bugger used by the pool */
274 PVOID pBuffer;
275} VBOXNETFLT_PACKET_INFO_POOL, *PVBOXNETFLT_PACKET_INFO_POOL;
276
277typedef enum VBOXNETDEVOPSTATE
278{
279 kVBoxNetDevOpState_InvalidValue = 0,
280 kVBoxNetDevOpState_Initializing,
281 kVBoxNetDevOpState_Initialized,
282 kVBoxNetDevOpState_Deinitializing,
283 kVBoxNetDevOpState_Deinitialized,
284
285} VBOXNETDEVOPSTATE;
286
287typedef enum VBOXNETFLT_WINIFSTATE
288{
289 /** The usual invalid state. */
290 kVBoxWinIfState_Invalid = 0,
291 /** Initialization. */
292 kVBoxWinIfState_Connecting,
293 /** Connected fuly functional state */
294 kVBoxWinIfState_Connected,
295 /** Disconnecting */
296 kVBoxWinIfState_Disconnecting,
297 /** Disconnected */
298 kVBoxWinIfState_Disconnected,
299} VBOXNETFLT_WINIFSTATE;
300
301/** structure used to maintain the state and reference count of the miniport and protocol */
302typedef struct VBOXNETFLT_WINIF_DEVICE
303{
304 /** initialize state */
305 VBOXNETDEVOPSTATE OpState;
306 /** ndis power state */
307 NDIS_DEVICE_POWER_STATE PowerState;
308 /** reference count */
309 uint32_t cReferences;
310} VBOXNETFLT_WINIF_DEVICE, *PVBOXNETFLT_WINIF_DEVICE;
311
312#define VBOXNDISREQUEST_INPROGRESS 1
313#define VBOXNDISREQUEST_QUEUED 2
314
315typedef struct VBOXNETFLTWIN_STATE
316{
317 union
318 {
319 struct
320 {
321 UINT fRequestInfo : 2;
322 UINT fInterfaceClosing : 1;
323 UINT fStandBy : 1;
324 UINT fProcessingPacketFilter : 1;
325 UINT fPPFNetFlt : 1;
326 UINT fUpperProtSetFilterInitialized : 1;
327 UINT Reserved : 25;
328 };
329 UINT Value;
330 };
331} VBOXNETFLTWIN_STATE, *PVBOXNETFLTWIN_STATE;
332
333DECLINLINE(VBOXNETFLTWIN_STATE) vboxNetFltWinAtomicUoReadWinState(VBOXNETFLTWIN_STATE State)
334{
335 UINT fValue = ASMAtomicUoReadU32((volatile uint32_t *)&State.Value);
336 return *((PVBOXNETFLTWIN_STATE)((void*)&fValue));
337}
338
339/* miniport layer globals */
340typedef struct VBOXNETFLTGLOBALS_MP
341{
342 /** our miniport handle */
343 NDIS_HANDLE hMiniport;
344 /** ddis wrapper handle */
345 NDIS_HANDLE hNdisWrapper;
346} VBOXNETFLTGLOBALS_MP, *PVBOXNETFLTGLOBALS_MP;
347
348#ifndef VBOXNETADP
349/* protocol layer globals */
350typedef struct VBOXNETFLTGLOBALS_PT
351{
352 /** our protocol handle */
353 NDIS_HANDLE hProtocol;
354} VBOXNETFLTGLOBALS_PT, *PVBOXNETFLTGLOBALS_PT;
355#endif /* #ifndef VBOXNETADP */
356
357typedef struct VBOXNETFLTGLOBALS_WIN
358{
359 /** synch event used for device creation synchronization */
360 KEVENT SynchEvent;
361 /** Device reference count */
362 int cDeviceRefs;
363 /** ndis device */
364 NDIS_HANDLE hDevice;
365 /** device object */
366 PDEVICE_OBJECT pDevObj;
367 /* loopback flags */
368 /* ndis packet flags to disable packet loopback */
369 UINT fPacketDontLoopBack;
370 /* ndis packet flags specifying whether the packet is looped back */
371 UINT fPacketIsLoopedBack;
372 /* Minport info */
373 VBOXNETFLTGLOBALS_MP Mp;
374#ifndef VBOXNETADP
375 /* Protocol info */
376 VBOXNETFLTGLOBALS_PT Pt;
377#endif
378} VBOXNETFLTGLOBALS_WIN, *PVBOXNETFLTGLOBALS_WIN;
379
380extern VBOXNETFLTGLOBALS_WIN g_VBoxNetFltGlobalsWin;
381
382/** represents filter driver device context*/
383typedef struct VBOXNETFLTWIN
384{
385 /** handle used by miniport edge for ndis calls */
386 NDIS_HANDLE hMiniport;
387 /** miniport edge state */
388 VBOXNETFLT_WINIF_DEVICE MpState;
389 /** ndis packet pool used for receives */
390 NDIS_HANDLE hRecvPacketPool;
391 /** ndis buffer pool used for receives */
392 NDIS_HANDLE hRecvBufferPool;
393 /** driver bind adapter state. */
394 VBOXNETFLT_WINIFSTATE enmState;
395#ifndef VBOXNETADP
396 /* misc state flags */
397 VBOXNETFLTWIN_STATE StateFlags;
398 /** handle used by protocol edge for ndis calls */
399 NDIS_HANDLE hBinding;
400 /** protocol edge state */
401 VBOXNETFLT_WINIF_DEVICE PtState;
402 /** ndis packet pool used for receives */
403 NDIS_HANDLE hSendPacketPool;
404 /** ndis buffer pool used for receives */
405 NDIS_HANDLE hSendBufferPool;
406 /** used for maintaining the pending send packets for handling packet loopback */
407 VBOXNETFLT_INTERLOCKED_SINGLE_LIST SendPacketQueue;
408 /** used for serializing calls to the NdisRequest in the vboxNetFltWinSynchNdisRequest */
409 RTSEMFASTMUTEX hSynchRequestMutex;
410 /** event used to synchronize with the Ndis Request completion in the vboxNetFltWinSynchNdisRequest */
411 KEVENT hSynchCompletionEvent;
412 /** status of the Ndis Request initiated by the vboxNetFltWinSynchNdisRequest */
413 NDIS_STATUS volatile SynchCompletionStatus;
414 /** pointer to the Ndis Request being executed by the vboxNetFltWinSynchNdisRequest */
415 PNDIS_REQUEST volatile pSynchRequest;
416 /** open/close adapter status.
417 * Since ndis adapter open and close requests may complete asynchronously,
418 * we are using event mechanism to wait for open/close completion
419 * the status field is being set by the completion call-back */
420 NDIS_STATUS OpenCloseStatus;
421 /** open/close adaptor completion event */
422 NDIS_EVENT OpenCloseEvent;
423 /** medium we are attached to */
424 NDIS_MEDIUM enmMedium;
425 /**
426 * Passdown request info
427 */
428 /** ndis request we pass down to the miniport below */
429 NDIS_REQUEST PassDownRequest;
430 /** Ndis pass down request bytes read or written original pointer */
431 PULONG pcPDRBytesRW;
432 /** Ndis pass down request bytes needed original pointer */
433 PULONG pcPDRBytesNeeded;
434 /** true if we should indicate the receive complete used by the ProtocolReceive mechanism.
435 * We need to indicate it only with the ProtocolReceive + NdisMEthIndicateReceive path.
436 * Note: we're using KeGetCurrentProcessorNumber, which is not entirely correct in case
437 * we're running on 64bit win7+, which can handle > 64 CPUs, however since KeGetCurrentProcessorNumber
438 * always returns the number < than the number of CPUs in the first group, we're guaranteed to have CPU index < 64
439 * @todo: use KeGetCurrentProcessorNumberEx for Win7+ 64 and dynamically extended array */
440 bool abIndicateRxComplete[64];
441 /** Pending transfer data packet queue (i.e. packets that were indicated as pending on NdisTransferData call */
442 VBOXNETFLT_INTERLOCKED_SINGLE_LIST TransferDataList;
443 /* mac options initialized on OID_GEN_MAC_OPTIONS */
444 ULONG fMacOptions;
445 /** our miniport devuice name */
446 NDIS_STRING MpDeviceName;
447 /** synchronize with unbind with Miniport initialization */
448 NDIS_EVENT MpInitCompleteEvent;
449 /** media connect status that we indicated */
450 NDIS_STATUS MpIndicatedMediaStatus;
451 /** media connect status pending to indicate */
452 NDIS_STATUS MpUnindicatedMediaStatus;
453 /** packet filter flags set by the upper protocols */
454 ULONG fUpperProtocolSetFilter;
455 /** packet filter flags set by the upper protocols */
456 ULONG fSetFilterBuffer;
457 /** packet filter flags set by us */
458 ULONG fOurSetFilter;
459#else
460 volatile ULONG cTxSuccess;
461 volatile ULONG cRxSuccess;
462 volatile ULONG cTxError;
463 volatile ULONG cRxError;
464#endif
465} VBOXNETFLTWIN, *PVBOXNETFLTWIN;
466
467typedef struct VBOXNETFLT_PACKET_QUEUE_WORKER
468{
469 /** this event is used to initiate a packet queue worker thread kill */
470 KEVENT KillEvent;
471 /** this event is used to notify a worker thread that the packets are added to the queue */
472 KEVENT NotifyEvent;
473 /** pointer to the packet queue worker thread object */
474 PKTHREAD pThread;
475 /** pointer to the SG used by the packet queue for IntNet receive notifications */
476 PINTNETSG pSG;
477 /** Packet queue */
478 VBOXNETFLT_INTERLOCKED_PACKET_QUEUE PacketQueue;
479 /** Packet info pool, i.e. the pool for the packet queue elements */
480 VBOXNETFLT_PACKET_INFO_POOL PacketInfoPool;
481} VBOXNETFLT_PACKET_QUEUE_WORKER, *PVBOXNETFLT_PACKET_QUEUE_WORKER;
482
483/* protocol reserved data held in ndis packet */
484typedef struct VBOXNETFLT_PKTRSVD_PT
485{
486 /** original packet received from the upperlying protocol
487 * can be null if the packet was originated by intnet */
488 PNDIS_PACKET pOrigPacket;
489 /** pointer to the buffer to be freed on send completion
490 * can be null if no buffer is to be freed */
491 PVOID pBufToFree;
492#if !defined(VBOX_LOOPBACK_USEFLAGS) || defined(DEBUG_NETFLT_PACKETS)
493 SINGLE_LIST_ENTRY ListEntry;
494 /* true if the packet is from IntNet */
495 bool bFromIntNet;
496#endif
497} VBOXNETFLT_PKTRSVD_PT, *PVBOXNETFLT_PKTRSVD_PT;
498
499/** miniport reserved data held in ndis packet */
500typedef struct VBOXNETFLT_PKTRSVD_MP
501{
502 /** original packet received from the underling miniport
503 * can be null if the packet was originated by intnet */
504 PNDIS_PACKET pOrigPacket;
505 /** pointer to the buffer to be freed on receive completion
506 * can be null if no buffer is to be freed */
507 PVOID pBufToFree;
508} VBOXNETFLT_PKTRSVD_MP, *PVBOXNETFLT_PKTRSVD_MP;
509
510/** represents the data stored in the protocol reserved field of ndis packet on NdisTransferData processing */
511typedef struct VBOXNETFLT_PKTRSVD_TRANSFERDATA_PT
512{
513 /** next packet in a list */
514 SINGLE_LIST_ENTRY ListEntry;
515 /* packet buffer start */
516 PNDIS_BUFFER pOrigBuffer;
517} VBOXNETFLT_PKTRSVD_TRANSFERDATA_PT, *PVBOXNETFLT_PKTRSVD_TRANSFERDATA_PT;
518
519/* VBOXNETFLT_PKTRSVD_TRANSFERDATA_PT should fit into PROTOCOL_RESERVED_SIZE_IN_PACKET because we use protocol reserved part
520 * of our miniport edge on transfer data processing for honding our own info */
521AssertCompile(sizeof (VBOXNETFLT_PKTRSVD_TRANSFERDATA_PT) <= PROTOCOL_RESERVED_SIZE_IN_PACKET);
522/* this should fit in MiniportReserved */
523AssertCompile(sizeof (VBOXNETFLT_PKTRSVD_MP) <= RT_SIZEOFMEMB(NDIS_PACKET, MiniportReserved));
524/* we use RTAsmAtomic*U32 for those, make sure we're correct */
525AssertCompile(sizeof (NDIS_DEVICE_POWER_STATE) == sizeof (uint32_t));
526AssertCompile(sizeof (UINT) == sizeof (uint32_t));
527
528
529#define NDIS_FLAGS_SKIP_LOOPBACK_W2K 0x400
530
531#include "../../VBoxNetFltInternal.h"
532#include "VBoxNetFltRt-win.h"
533#ifndef VBOXNETADP
534# include "VBoxNetFltP-win.h"
535#endif
536#include "VBoxNetFltM-win.h"
537
538#endif /* #ifndef ___VBoxNetFltCmn_win_h___ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette