diff --git a/reactos/drivers/net/tcpip/Makefile_rex b/reactos/drivers/net/tcpip/Makefile_rex deleted file mode 100644 index 5adb05c2851..00000000000 --- a/reactos/drivers/net/tcpip/Makefile_rex +++ /dev/null @@ -1,110 +0,0 @@ -# $Id: Makefile_rex,v 1.2 2000/03/08 22:37:02 ea Exp $ -# -# TCPIP.SYS build spec -# - -TARGETNAME=tcpip - -BASE_CFLAGS = -I../../../include - -OBJECTS_MISC = misc/main.o misc/iface.o misc/$(TARGETNAME).coff - -OBJECTS = $(OBJECTS_MISC) - -all: $(TARGETNAME).sys - -misc/$(TARGETNAME).coff: misc/$(TARGETNAME).rc ../../../include/reactos/resource.h - -ifeq ($(DOSCLI),yes) -CLEAN_FILES = \ - misc\*.o misc\*.coff \ - $(TARGETNAME).o $(TARGETNAME).a \ - junk.tmp base.tmp temp.exp \ - $(TARGETNAME).sys $(TARGETNAME).sym -else -CLEAN_FILES = \ - misc/*.o misc/*.coff \ - $(TARGETNAME).o $(TARGETNAME).a \ - junk.tmp base.tmp temp.exp \ - $(TARGETNAME).sys $(TARGETNAME).sym -endif - -$(TARGETNAME).sys: $(OBJECTS) misc/$(TARGETNAME).def - $(LD) -r $(OBJECTS) -o $(TARGETNAME).o - $(DLLTOOL) \ - --dllname $(TARGETNAME).sys \ - --def misc/$(TARGETNAME).def \ - --output-lib $(TARGETNAME).a \ - --kill-at - $(CC) \ - --subsystem=native \ - -mdll \ - --dll \ - -e _DriverEntry@8 \ - -o junk.tmp \ - -Wl,--image-base,0x0 \ - -Wl,--file-alignment,0x1000 \ - -Wl,--section-alignment,0x1000 \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,--base-file,base.tmp $(TARGETNAME).o \ - -specs=../../../specs \ - ../../../ntoskrnl/ntoskrnl.a - - $(RM) junk.tmp - $(DLLTOOL) \ - --dllname $(TARGETNAME).sys \ - --base-file base.tmp \ - --output-exp temp.exp \ - --def misc/$(TARGETNAME).edf \ - --kill-at - - $(RM) base.tmp - $(CC) \ - --subsystem=native \ - -mdll \ - --dll \ - -e _DllMain@8 \ - -o $(TARGETNAME).sys \ - $(TARGETNAME).o \ - ../../../ntoskrnl/ntoskrnl.a \ - -Wl,--image-base,0x0 \ - -Wl,--file-alignment,0x1000 \ - -Wl,--section-alignment,0x1000 \ - -Wl,--defsym,_end=end \ - -Wl,--defsym,_edata=__data_end__ \ - -Wl,--defsym,_etext=etext \ - -Wl,temp.exp \ - -specs=../../../specs - - $(RM) temp.exp - $(NM) --numeric-sort $(TARGETNAME).sys > $(TARGETNAME).sym - -clean: $(CLEAN_FILES:%=%_clean) - -$(CLEAN_FILES:%=%_clean): %_clean: - - $(RM) $* - -.PHONY: clean $(CLEAN_FILES:%=%_clean) - -floppy: $(FLOPPY_DIR)/drivers/$(TARGETNAME).sys - -$(FLOPPY_DIR)/drivers/$(TARGETNAME).sys: $(TARGETNAME).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGETNAME).sys $(FLOPPY_DIR)\drivers\$(TARGETNAME).sys -else - $(CP) $(TARGETNAME).sys $(FLOPPY_DIR)/drivers/$(TARGETNAME).sys -endif - -dist: $(DIST_DIR)/drivers/$(TARGETNAME).sys - -$(DIST_DIR)/drivers/$(TARGETNAME).sys: $(TARGETNAME).sys -ifeq ($(DOSCLI),yes) - $(CP) $(TARGETNAME).sys ..\..\$(DIST_DIR)\drivers\$(TARGETNAME).sys -else - $(CP) $(TARGETNAME).sys ../../$(DIST_DIR)/drivers/$(TARGETNAME).sys -endif - -#WITH_DEBUGGING = yes -#WIN32_LEAN_AND_MEAN = yes -#WARNINGS_ARE_ERRORS = yes -include ../../../rules.mak - diff --git a/reactos/drivers/net/tcpip/misc/iface.c b/reactos/drivers/net/tcpip/misc/iface.c deleted file mode 100644 index 2f78bd62872..00000000000 --- a/reactos/drivers/net/tcpip/misc/iface.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: iface.c,v 1.1 1999/11/20 20:36:46 ea Exp $ - * - * reactos/services/net/tcpip/misc/iface.c - */ -#include - -VOID -STDCALL -IPAddInterface ( - DWORD Unknown0, - DWORD Unknown1, - DWORD Unknown2, - DWORD Unknown3, - DWORD Unknown4 - ) -{ -} - - -VOID -STDCALL -IPDelInterface ( - DWORD Unknown0 - ) -{ -} - - -VOID -STDCALL -LookupRoute ( - DWORD Unknown0, - DWORD Unknown1 - ) -{ -} - - -/* EOF */ diff --git a/reactos/drivers/net/tcpip/misc/main.c b/reactos/drivers/net/tcpip/misc/main.c deleted file mode 100644 index 52c89f30d30..00000000000 --- a/reactos/drivers/net/tcpip/misc/main.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $Id: main.c,v 1.2 2000/03/08 22:37:02 ea Exp $ */ -#include - -NTSTATUS -STDCALL -DriverEntry ( - IN PDRIVER_OBJECT DriverObject, - IN PUNICODE_STRING RegistryPath - ) -{ - return STATUS_UNSUCCESSFUL; -} - - - -/* EOF */ diff --git a/reactos/drivers/net/tcpip/misc/tcpip.def b/reactos/drivers/net/tcpip/misc/tcpip.def deleted file mode 100644 index 7d39f6764a8..00000000000 --- a/reactos/drivers/net/tcpip/misc/tcpip.def +++ /dev/null @@ -1,12 +0,0 @@ -; $Id: tcpip.def,v 1.1 1999/11/20 20:36:46 ea Exp $ -; -; TCPIP.SYS -; -LIBRARY tcpip.sys - -EXPORTS -IPAddInterface@20 -IPDelInterface@4 -LookupRoute@8 - -; EOF diff --git a/reactos/drivers/net/tcpip/misc/tcpip.edf b/reactos/drivers/net/tcpip/misc/tcpip.edf deleted file mode 100644 index e77a97d50e5..00000000000 --- a/reactos/drivers/net/tcpip/misc/tcpip.edf +++ /dev/null @@ -1,12 +0,0 @@ -; $Id: tcpip.edf,v 1.1 1999/11/20 20:36:46 ea Exp $ -; -; TCPIP.SYS -; -LIBRARY tcpip.sys - -EXPORTS -IPAddInterface=IPAddInterface@20 -IPDelInterface=IPDelInterface@4 -LookupRoute=LookupRoute@8 - -; EOF diff --git a/reactos/drivers/net/tcpip/misc/tcpip.rc b/reactos/drivers/net/tcpip/misc/tcpip.rc deleted file mode 100644 index 57af7b41f36..00000000000 --- a/reactos/drivers/net/tcpip/misc/tcpip.rc +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: tcpip.rc,v 1.1 1999/11/20 20:36:46 ea Exp $ */ -#include -#include - -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US - -VS_VERSION_INFO VERSIONINFO - FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD - PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD - FILEFLAGSMASK 0x3fL -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x40004L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904b0" - BEGIN - VALUE "CompanyName", RES_STR_COMPANY_NAME - VALUE "FileDescription", "TCP/IP kernel module\0" - VALUE "FileVersion", "0.0.0\0" - VALUE "InternalName", "tcpip\0" - VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT - VALUE "OriginalFilename", "tcpip.sys\0" - VALUE "ProductName", RES_STR_PRODUCT_NAME - VALUE "ProductVersion", RES_STR_PRODUCT_VERSION - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x409, 1200 - END -END - diff --git a/reactos/include/net/miniport.h b/reactos/include/net/miniport.h new file mode 100644 index 00000000000..4db57110602 --- /dev/null +++ b/reactos/include/net/miniport.h @@ -0,0 +1,849 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS NDIS library + * FILE: include/net/miniport.h + * PURPOSE: Type definitions available only to NDIS miniport drivers + */ +#ifndef __MINIPORT_H +#define __MINIPORT_H + +#ifdef _MSC_VER +#include +#else /* _MSC_VER */ +#include +#endif /* _MSC_VER */ + +/* Base types */ + +#define IN +#define OUT +#define OPTIONAL + +#define ANYSIZE_ARRAY 1 + +#define CONST const + +#ifdef _MSC_VER + +#ifdef i386 +#define STDCALL _stdcall +#define CDECL _cdecl +#else /* i386 */ +#define STDCALL +#define CDECL +#endif /* i386 */ + +#else /* _MSC_VER */ + +#ifdef i386 +#define STDCALL __attribute__ ((stdcall)) +#define CDECL __attribute__ ((cdecl)) +#else /* i386 */ +#define STDCALL +#define CDECL +#endif /* i386 */ + +#endif /* _MSC_VER */ + +typedef void VOID, *PVOID; +typedef char CHAR, *PCHAR; +typedef unsigned char UCHAR, *PUCHAR; +typedef short SHORT, *PSHORT; +typedef unsigned short USHORT, *PUSHORT; +typedef long LONG,*PLONG; +typedef unsigned long ULONG,*PULONG; +typedef double DOUBLE, *PDOUBLE; +typedef struct _QUAD { + double DoNotUseThisField; +} QUAD,*PQUAD; +typedef QUAD UQUAD, *PUQUAD; +typedef signed int INT, *PINT; +typedef unsigned int UINT, *PUINT; +typedef double LONGLONG, *PLONGLONG; +typedef double ULONGLONG, *PULONGLONG; + +typedef UCHAR BOOLEAN, *PBOOLEAN; +typedef ULONG DWORD, *PDWORD; + +/* Cardinal types */ +typedef CHAR CCHAR, *PCCHAR; +typedef SHORT CSHORT, *PCSHORT; +typedef ULONG CLONG, *PCLONG; + +/* UNICODE (wide character) types */ +#ifndef __cplusplus +typedef short unsigned int wchar_t; +#endif /* __cplusplus */ +typedef wchar_t WCHAR; +typedef WCHAR *PWCHAR; +typedef WCHAR *LPWCH, *PWCH; +typedef CONST WCHAR *LPCWCH, *PCWCH; +typedef WCHAR *NWPSTR; +typedef WCHAR *LPWSTR, *PWSTR; +typedef CONST WCHAR *LPCWSTR, *PCWSTR; + +/* ANSI (multi-byte character) types */ +typedef CHAR *LPCH, *PCH; +typedef CONST CHAR *LPCCH, *PCCH; +typedef CHAR *NPSTR; +typedef CHAR *LPSTR, *PSTR; +typedef CONST CHAR *LPCSTR, *PCSTR; + +/* Neutral ANSI/UNICODE types */ +#ifdef UNICODE + +typedef WCHAR TCHAR, *PTCHAR; +typedef WCHAR TUCHAR, *PTUCHAR; + +typedef LPWSTR LPTCH, PTCH; +typedef LPWSTR PTSTR, LPTSTR; +typedef LPCWSTR LPCTSTR; +typedef LPWSTR LP; +#define _TEXT(string) L##string +#define _T(string) L##string + +#else /* UNICODE */ + +typedef CHAR TCHAR, *PTCHAR; +typedef UCHAR TUCHAR, *PTUCHAR; + +typedef LPSTR LPTCH, PTCH; +typedef LPSTR PTSTR, LPTSTR; +typedef LPCSTR LPCTSTR; +#define _TEXT(string) string +#define _T(string) string + +#endif /* UNICODE */ + +#define TEXT(string) __TEXT(string) + + +typedef union _LARGE_INTEGER { + struct { + ULONG LowPart; + LONG HighPart; + }; + struct { + ULONG LowPart; + LONG HighPart; + } u; + LONGLONG QuadPart; +} LARGE_INTEGER; + +typedef LARGE_INTEGER *PLARGE_INTEGER; + +typedef union _ULARGE_INTEGER { + struct { + ULONG LowPart; + ULONG HighPart; + }; + struct { + ULONG LowPart; + ULONG HighPart; + } u; + ULONGLONG QuadPart; +} ULARGE_INTEGER; + +typedef ULARGE_INTEGER *PULARGE_INTEGER; + + +typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS; + + + +/* NT status type and macros for checking status */ +typedef LONG NTSTATUS; +typedef NTSTATUS *PNTSTATUS; + +#ifdef _MSC_VER +#define NT_SUCCESS(Status) ((ULONG)(Status) >= 0) +#endif /* _MSC_VER */ +#define NT_INFORMATION(Status) ((ULONG)(Status) >> 30 == 1) +#define NT_WARNING(Status) ((ULONG)(Status) >> 30 == 2) +#define NT_ERROR(Status) ((ULONG)(Status) >> 30 == 3) + +#define APPLICATION_ERROR_MASK 0x20000000 +#define ERROR_SEVERITY_SUCCESS 0x00000000 +#define ERROR_SEVERITY_INFORMATIONAL 0x40000000 +#define ERROR_SEVERITY_WARNING 0x80000000 +#define ERROR_SEVERITY_ERROR 0xC0000000 + + + +/* Basic constants */ + +#define FALSE 0 +#define TRUE 1 + +#define NULL ((PVOID)0) + + + +/* Counted strings */ + +typedef struct _STRING +{ + USHORT Length; + USHORT MaximumLength; + PCHAR Buffer; +} STRING, *PSTRING; + +typedef STRING ANSI_STRING, *PANSI_STRING; +typedef STRING OEM_STRING, *POEM_STRING; + +#define ANSI_NULL ((CHAR)0) + +typedef struct _CSTRING +{ + USHORT Length; + USHORT MaximumLength; + CONST CHAR *Buffer; +} CSTRING, *PCSTRING; + +typedef CSTRING CANSI_STRING, *PCANSI_STRING; + + +typedef struct _UNICODE_STRING +{ + USHORT Length; + USHORT MaximumLength; + PWSTR Buffer; +} UNICODE_STRING, *PUNICODE_STRING; + +typedef struct _CUNICODE_STRING +{ + USHORT Length; + USHORT MaximumLength; + CONST PWSTR Buffer; +} CUNICODE_STRING, *PCUNICODE_STRING; + +#define UNICODE_NULL ((WCHAR)0) + + + +/* Linked lists */ + +typedef struct _LIST_ENTRY +{ + struct _LIST_ENTRY *Flink; + struct _LIST_ENTRY *Blink; +} LIST_ENTRY, *PLIST_ENTRY; + +typedef struct _SINGLE_LIST_ENTRY +{ + struct _SINGLE_LIST_ENTRY *Next; +} SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY; + + +/* + * VOID InitializeListHead( + * PLIST_ENTRY ListHead); + */ +#define InitializeListHead(ListHead) \ +{ \ + (ListHead)->Flink = (ListHead); \ + (ListHead)->Blink = (ListHead); \ +} + + +/* + * VOID InsertHeadList( + * LIST_ENTRY ListHead, + * PLIST_ENTRY Entry); + */ +#define InsertHeadList(ListHead, ListEntry) \ +{ \ + PLIST_ENTRY OldFlink; \ + OldFlink = (ListHead)->Flink; \ + (ListEntry)->Flink = OldFlink; \ + (ListEntry)->Blink = (ListHead); \ + OldFlink->Blink = (ListEntry); \ + (ListHead)->Flink = (ListEntry); \ +} + + +/* + * VOID InsertTailList( + * PLIST_ENTRY ListHead, + * PLIST_ENTRY Entry); + */ +#define InsertTailList(ListHead, ListEntry) \ +{ \ + PLIST_ENTRY OldBlink; \ + OldBlink = (ListHead)->Blink; \ + (ListEntry)->Flink = (ListHead); \ + (ListEntry)->Blink = OldBlink; \ + OldBlink->Flink = (ListEntry); \ + (ListHead)->Blink = (ListEntry); \ +} + +/* + * BOOLEAN IsListEmpty( + * PLIST_ENTRY ListHead); + */ +#define IsListEmpty(ListHead) \ + ((ListHead)->Flink == (ListHead)) + + +/* + * PSINGLE_LIST_ENTRY PopEntryList( + * PSINGLE_LIST_ENTRY ListHead); + */ +#define PopEntryList(ListHead) \ + (ListHead)->Next; \ +{ \ + PSINGLE_LIST_ENTRY FirstEntry; \ + \ + FirstEntry = (ListHead)->Next; \ + if (FirstEntry != NULL) \ + { \ + (ListHead)->Next = FirstEntry->Next; \ + } \ +} + + +/* + * VOID PushEntryList( + * PSINGLE_LIST_ENTRY ListHead, + * PSINGLE_LIST_ENTRY Entry); + */ +#define PushEntryList(ListHead, Entry) \ + (Entry)->Next = (ListHead)->Next; \ + (ListHead)->Next = (Entry) + + +/* + * VOID RemoveEntryList( + * PLIST_ENTRY Entry); + */ +#define RemoveEntryList(ListEntry) \ +{ \ + PLIST_ENTRY OldFlink; \ + PLIST_ENTRY OldBlink; \ + OldFlink = (ListEntry)->Flink; \ + OldBlink = (ListEntry)->Blink; \ + OldFlink->Blink = OldBlink; \ + OldBlink->Flink = OldFlink; \ +} + + +/* + * PLIST_ENTRY RemoveHeadList( + * PLIST_ENTRY ListHead); + */ +#define RemoveHeadList(ListHead) \ + (ListHead)->Flink; \ +{ \ + RemoveEntryList((ListHead)->Flink) \ +} + + +/* + * PLIST_ENTRY RemoveTailList( + * PLIST_ENTRY ListHead); + */ +#define RemoveTailList(ListHead) \ + (ListHead)->Blink; \ +{ \ + RemoveEntryList((ListHead)->Blink) \ +} + + +/* Hardware */ + +typedef UCHAR KIRQL, *PKIRQL; + +typedef struct _KSPIN_LOCK +{ + ULONG Lock; +} KSPIN_LOCK, *PKSPIN_LOCK; + + +typedef struct _ADAPTER_OBJECT *PADAPTER_OBJECT; +typedef struct _DEVICE_OBJECT *PDEVICE_OBJECT; +typedef struct _DRIVER_OBJECT *PDRIVER_OBJECT; +typedef struct _FILE_OBJECT *PFILE_OBJECT; + +typedef struct _KINTERRUPT *PKINTERRUPT; + + +/* Memory Descriptor List */ +typedef struct _MDL { + struct _MDL *Next; + CSHORT Size; + CSHORT MdlFlags; + struct _EPROCESS *Process; + PVOID MappedSystemVa; + PVOID StartVa; + ULONG ByteCount; + ULONG ByteOffset; +} MDL, *PMDL; + +#define MDL_MAPPED_TO_SYSTEM_VA 0x0001 +#define MDL_PAGES_LOCKED 0x0002 +#define MDL_SOURCE_IS_NONPAGED_POOL 0x0004 +#define MDL_ALLOCATED_FIXED_SIZE 0x0008 +#define MDL_PARTIAL 0x0010 +#define MDL_PARTIAL_HAS_BEEN_MAPPED 0x0020 +#define MDL_IO_PAGE_READ 0x0040 +#define MDL_WRITE_OPERATION 0x0080 +#define MDL_PARENT_MAPPED_SYSTEM_VA 0x0100 +#define MDL_LOCK_HELD 0x0200 +#define MDL_PHYSICAL_VIEW 0x0400 +#define MDL_IO_SPACE 0x0800 +#define MDL_NETWORK_HEADER 0x1000 +#define MDL_MAPPING_CAN_FAIL 0x2000 +#define MDL_ALLOCATED_MUST_SUCCEED 0x4000 + + +#define MDL_MAPPING_FLAGS (MDL_MAPPED_TO_SYSTEM_VA | \ + MDL_PAGES_LOCKED | \ + MDL_SOURCE_IS_NONPAGED_POOL | \ + MDL_PARTIAL_HAS_BEEN_MAPPED | \ + MDL_PARENT_MAPPED_SYSTEM_VA | \ + MDL_LOCK_HELD | \ + MDL_SYSTEM_VA | \ + MDL_IO_SPACE ) + + +typedef struct _DISPATCHER_HEADER +{ + UCHAR Type; + UCHAR Absolute; + UCHAR Size; + UCHAR Inserted; + LONG SignalState; + LIST_ENTRY WaitListHead; +} DISPATCHER_HEADER; + +typedef struct _KEVENT +{ + DISPATCHER_HEADER Header; +} KEVENT, *PKEVENT; + + +typedef struct _KTIMER +{ + DISPATCHER_HEADER Header; + ULARGE_INTEGER DueTime; + LIST_ENTRY TimerListEntry; + struct _KDPC *Dpc; + LONG Period; +} KTIMER, *PKTIMER; + + +typedef enum _KDPC_IMPORTANCE +{ + LowImportance, + MediumImportance, + HighImportance +} KDPC_IMPORTANCE; + +/* Forward declaration */ +struct _KDPC; + +typedef VOID (*PKDEFERRED_ROUTINE)( + IN struct _KDPC *Dpc, + IN PVOID DeferredContext, + IN PVOID SystemArgument1, + IN PVOID SystemArgument2); + +/* Deferred Procedure Call */ + +typedef struct _KDPC { + CSHORT Type; + UCHAR Number; + UCHAR Importance; + LIST_ENTRY DpcListEntry; + PKDEFERRED_ROUTINE DeferredRoutine; + PVOID DeferredContext; + PVOID SystemArgument1; + PVOID SystemArgument2; + PULONG Lock; +} KDPC, *PKDPC; + + +typedef enum _INTERFACE_TYPE +{ + InterfaceTypeUndefined = -1, + Internal, + Isa, + Eisa, + MicroChannel, + TurboChannel, + PCIBus, + VMEBus, + NuBus, + PCMCIABus, + CBus, + MPIBus, + MPSABus, + ProcessorInternal, + InternalPowerBus, + PNPISABus, + MaximumInterfaceType +} INTERFACE_TYPE, *PINTERFACE_TYPE; + + +typedef enum _DMA_WIDTH +{ + Width8Bits, + Width16Bits, + Width32Bits, + MaximumDmaWidth +} DMA_WIDTH, *PDMA_WIDTH; + +typedef enum _DMA_SPEED +{ + Compatible, + TypeA, + TypeB, + TypeC, + TypeF, + MaximumDmaSpeed +} DMA_SPEED, *PDMA_SPEED; + + +typedef enum _KINTERRUPT_MODE +{ + LevelSensitive, + Latched +} KINTERRUPT_MODE; + + +typedef struct _DMA_CONFIGURATION_BYTE0 +{ + UCHAR Channel:3; + UCHAR Reserved:3; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} DMA_CONFIGURATION_BYTE0; + +typedef struct _DMA_CONFIGURATION_BYTE1 +{ + UCHAR Reserved0:2; + UCHAR TransferSize:2; + UCHAR Timing:2; + UCHAR Reserved1:2; +} DMA_CONFIGURATION_BYTE1; + + +typedef struct _CM_MCA_POS_DATA +{ + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + +typedef struct _EISA_MEMORY_TYPE +{ + UCHAR ReadWrite:1; + UCHAR Cached:1; + UCHAR Reserved0:1; + UCHAR Type:2; + UCHAR Shared:1; + UCHAR Reserved1:1; + UCHAR MoreEntries:1; +} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; + +typedef struct _EISA_MEMORY_CONFIGURATION +{ + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; +} EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; + + +typedef struct _EISA_IRQ_DESCRIPTOR +{ + UCHAR Interrupt:4; + UCHAR Reserved:1; + UCHAR LevelTriggered:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; + +typedef struct _EISA_IRQ_CONFIGURATION +{ + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; +} EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; + +typedef struct _EISA_DMA_CONFIGURATION +{ + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; +} EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; + + +typedef struct _EISA_PORT_DESCRIPTOR +{ + UCHAR NumberPorts:5; + UCHAR Reserved:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; + +typedef struct _EISA_PORT_CONFIGURATION +{ + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; +} EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; + +typedef struct _CM_EISA_SLOT_INFORMATION +{ + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; + +typedef struct _CM_EISA_FUNCTION_INFORMATION +{ + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; +} CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; + + +typedef struct _CM_PARTIAL_RESOURCE_DESCRIPTOR +{ + UCHAR Type; + UCHAR ShareDisposition; + USHORT Flags; + union { + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Generic; + + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Port; + + struct { + ULONG Level; + ULONG Vector; + ULONG Affinity; + } Interrupt; + + struct { + PHYSICAL_ADDRESS Start; + ULONG Length; + } Memory; + + struct { + ULONG Channel; + ULONG Port; + ULONG Reserved1; + } Dma; + + struct { + ULONG Data[3]; + } DevicePrivate; + + struct { + ULONG Start; + ULONG Length; + ULONG Reserved; + } BusNumber; + + struct { + ULONG DataSize; + ULONG Reserved1; + ULONG Reserved2; + } DeviceSpecificData; + } u; +} CM_PARTIAL_RESOURCE_DESCRIPTOR, *PCM_PARTIAL_RESOURCE_DESCRIPTOR; + +typedef struct _CM_PARTIAL_RESOURCE_LIST +{ + USHORT Version; + USHORT Revision; + ULONG Count; + CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]; +} CM_PARTIAL_RESOURCE_LIST, *PCM_PARTIAL_RESOURCE_LIST; + +typedef struct _CM_FULL_RESOURCE_DESCRIPTOR +{ + INTERFACE_TYPE InterfaceType; + ULONG BusNumber; + CM_PARTIAL_RESOURCE_LIST PartialResourceList; +} CM_FULL_RESOURCE_DESCRIPTOR, *PCM_FULL_RESOURCE_DESCRIPTOR; + +typedef struct _CM_RESOURCE_LIST +{ + ULONG Count; + CM_FULL_RESOURCE_DESCRIPTOR List[1]; +} CM_RESOURCE_LIST, *PCM_RESOURCE_LIST; + + + +/* Operating System services */ + +/* Debugging */ + +ULONG CDECL DbgPrint( + PCH Format, + ...); + +#ifdef DBG + +VOID +STDCALL +RtlAssert( + PVOID FailedAssertion, + PVOID FileName, + ULONG LineNumber, + PCHAR Message); + +#define ASSERT(exp) \ + if (!(exp)) \ + RtlAssert(#exp, __FILE__, __LINE__, NULL) + +#define ASSERTMSG(msg, exp) \ + if (!(exp)) \ + RtlAssert(#exp, __FILE__, __LINE__, msg) + +#else /* DBG */ + +#define ASSERT(exp) +#define ASSERTMSG(msg, exp) + +#endif /* DBG */ + + +/* Runtime library */ + +#define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination), (Source), (Length))) +#define RtlMoveMemory(Destination,Source,Length) memmove((Destination), (Source), (Length)) +#define RtlCopyMemory(Destination,Source,Length) memcpy((Destination), (Source), (Length)) +#define RtlFillMemory(Destination,Length,Fill) memset((Destination), (Fill),(Length)) +#define RtlZeroMemory(Destination,Length) memset((Destination), 0, (Length)) + + +/* Core kernel functions */ + +VOID +STDCALL +KeStallExecutionProcessor( + ULONG MicroSeconds); + + +/* I/O functions */ + +VOID +STDCALL +READ_PORT_BUFFER_UCHAR( + PUCHAR Port, + PUCHAR Value, + ULONG Count); + +VOID +STDCALL +READ_PORT_BUFFER_ULONG( + PULONG Port, + PULONG Value, + ULONG Count); + +VOID +STDCALL +READ_PORT_BUFFER_USHORT( + PUSHORT Port, + PUSHORT Value, + ULONG Count); + +UCHAR +STDCALL +READ_PORT_UCHAR( + PUCHAR Port); + +ULONG +STDCALL +READ_PORT_ULONG( + PULONG Port); + +USHORT +STDCALL +READ_PORT_USHORT( + PUSHORT Port); + +VOID +STDCALL +WRITE_PORT_BUFFER_UCHAR( + PUCHAR Port, + PUCHAR Value, + ULONG Count); + +VOID +STDCALL +WRITE_PORT_BUFFER_ULONG( + PULONG Port, + PULONG Value, + ULONG Count); + +VOID +STDCALL +WRITE_PORT_BUFFER_USHORT( + PUSHORT Port, + PUSHORT Value, + ULONG Count); + +VOID +STDCALL +WRITE_PORT_UCHAR( + PUCHAR Port, + UCHAR Value); + +VOID +STDCALL +WRITE_PORT_ULONG( + PULONG Port, + ULONG Value); + +VOID +STDCALL +WRITE_PORT_USHORT( + PUSHORT Port, + USHORT Value); + +VOID +STDCALL +WRITE_REGISTER_UCHAR( + PUCHAR Register, + UCHAR Value); + +VOID +STDCALL +WRITE_REGISTER_ULONG( + PULONG Register, + ULONG Value); + +VOID +STDCALL +WRITE_REGISTER_USHORT( + PUSHORT Register, + USHORT Value); + +#endif /* __MINIPORT_H */ + +/* EOF */ diff --git a/reactos/include/net/ndis.h b/reactos/include/net/ndis.h new file mode 100644 index 00000000000..703d6089216 --- /dev/null +++ b/reactos/include/net/ndis.h @@ -0,0 +1,4455 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS NDIS library + * FILE: include/net/ndis.h + * PURPOSE: Structures used by NDIS drivers + * DEFINES: i386 - Target platform is i386 + * NDIS_WRAPPER - Define only for NDIS wrapper library + * NDIS_MINIPORT_DRIVER - Define only for NDIS miniport drivers + * BINARY_COMPATIBLE - 0 = Use macros for some features + * - 1 = Use imports for features not available + * NDIS40 - Use NDIS 4.0 structures by default + * NDIS50 - Use NDIS 5.0 structures by default + */ +#ifndef __NDIS_H +#define __NDIS_H + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#ifdef NDIS50 +#undef NDIS40 +#define NDIS40 +#endif + + +/* Windows 9x compatibillity for miniports on x86 platform */ +#ifndef BINARY_COMPATIBLE +#if defined(NDIS_MINIPORT_DRIVER) && defined(i386) +#define BINARY_COMPATIBLE 1 +#else +#define BINARY_COMPATIBLE 0 +#endif +#endif + +#define UNALIGNED + + +/* The NDIS library export functions. NDIS miniport drivers import functions */ +#ifdef NDIS_WRAPPER + +#ifdef _MSC_VER +#define EXPIMP __declspec(dllexport) +#else +#define EXPIMP STDCALL +#endif + +#else /* NDIS_WRAPPER */ + +#ifdef _MSC_VER +#define EXPIMP __declspec(dllimport) +#else +#define EXPIMP STDCALL +#endif + +#endif /* NDIS_WRAPPER */ + + + +#ifdef NDIS_MINIPORT_DRIVER + +#include "miniport.h" + +#else /* NDIS_MINIPORT_DRIVER */ + +#ifdef _MSC_VER +#include + +typedef ULONG ULONG_PTR, *PULONG_PTR; + +#else /* _MSC_VER */ +#include + +/* FIXME: Missed some definitions in there */ + +typedef struct _DMA_CONFIGURATION_BYTE0 +{ + UCHAR Channel:3; + UCHAR Reserved:3; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} DMA_CONFIGURATION_BYTE0; + +typedef struct _DMA_CONFIGURATION_BYTE1 +{ + UCHAR Reserved0:2; + UCHAR TransferSize:2; + UCHAR Timing:2; + UCHAR Reserved1:2; +} DMA_CONFIGURATION_BYTE1; + + +typedef struct _CM_MCA_POS_DATA +{ + USHORT AdapterId; + UCHAR PosData1; + UCHAR PosData2; + UCHAR PosData3; + UCHAR PosData4; +} CM_MCA_POS_DATA, *PCM_MCA_POS_DATA; + +typedef struct _EISA_MEMORY_TYPE +{ + UCHAR ReadWrite:1; + UCHAR Cached:1; + UCHAR Reserved0:1; + UCHAR Type:2; + UCHAR Shared:1; + UCHAR Reserved1:1; + UCHAR MoreEntries:1; +} EISA_MEMORY_TYPE, *PEISA_MEMORY_TYPE; + +typedef struct _EISA_MEMORY_CONFIGURATION +{ + EISA_MEMORY_TYPE ConfigurationByte; + UCHAR DataSize; + USHORT AddressLowWord; + UCHAR AddressHighByte; + USHORT MemorySize; +} EISA_MEMORY_CONFIGURATION, *PEISA_MEMORY_CONFIGURATION; + + +typedef struct _EISA_IRQ_DESCRIPTOR +{ + UCHAR Interrupt:4; + UCHAR Reserved:1; + UCHAR LevelTriggered:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_IRQ_DESCRIPTOR, *PEISA_IRQ_DESCRIPTOR; + +typedef struct _EISA_IRQ_CONFIGURATION +{ + EISA_IRQ_DESCRIPTOR ConfigurationByte; + UCHAR Reserved; +} EISA_IRQ_CONFIGURATION, *PEISA_IRQ_CONFIGURATION; + +typedef struct _EISA_DMA_CONFIGURATION +{ + DMA_CONFIGURATION_BYTE0 ConfigurationByte0; + DMA_CONFIGURATION_BYTE1 ConfigurationByte1; +} EISA_DMA_CONFIGURATION, *PEISA_DMA_CONFIGURATION; + + +typedef struct _EISA_PORT_DESCRIPTOR +{ + UCHAR NumberPorts:5; + UCHAR Reserved:1; + UCHAR Shared:1; + UCHAR MoreEntries:1; +} EISA_PORT_DESCRIPTOR, *PEISA_PORT_DESCRIPTOR; + +typedef struct _EISA_PORT_CONFIGURATION +{ + EISA_PORT_DESCRIPTOR Configuration; + USHORT PortAddress; +} EISA_PORT_CONFIGURATION, *PEISA_PORT_CONFIGURATION; + +typedef struct _CM_EISA_SLOT_INFORMATION +{ + UCHAR ReturnCode; + UCHAR ReturnFlags; + UCHAR MajorRevision; + UCHAR MinorRevision; + USHORT Checksum; + UCHAR NumberFunctions; + UCHAR FunctionInformation; + ULONG CompressedId; +} CM_EISA_SLOT_INFORMATION, *PCM_EISA_SLOT_INFORMATION; + +typedef struct _CM_EISA_FUNCTION_INFORMATION +{ + ULONG CompressedId; + UCHAR IdSlotFlags1; + UCHAR IdSlotFlags2; + UCHAR MinorRevision; + UCHAR MajorRevision; + UCHAR Selections[26]; + UCHAR FunctionFlags; + UCHAR TypeString[80]; + EISA_MEMORY_CONFIGURATION EisaMemory[9]; + EISA_IRQ_CONFIGURATION EisaIrq[7]; + EISA_DMA_CONFIGURATION EisaDma[4]; + EISA_PORT_CONFIGURATION EisaPort[20]; + UCHAR InitializationData[60]; +} CM_EISA_FUNCTION_INFORMATION, *PCM_EISA_FUNCTION_INFORMATION; + +#endif /* _MSC_VER */ + +/* FIXME: Missed some definitions in there */ + +typedef CONST CHAR *PCSTR; + +/* Could be defined in tdi.h */ +#ifndef __TDI_H +typedef signed int INT, *PINT; +#endif /* __TDI_H */ + +#endif /* NDIS_MINIPORT_DRIVER */ + +#include "netevent.h" +#include "ndisoid.h" + + + +/* More types */ + +typedef ULONG ULONG_PTR, *PULONG_PTR; + + +#if defined(NDIS_MINIPORT_DRIVER) || !defined(_MSC_VER) + +typedef struct _GUID { + ULONG Data1; + USHORT Data2; + USHORT Data3; + UCHAR Data4[8]; +} GUID; + +#endif /* NDIS_MINIPORT_DRIVER || _MSC_VER */ + + +/* NDIS base types */ + +typedef struct _NDIS_SPIN_LOCK +{ + KSPIN_LOCK SpinLock; + KIRQL OldIrql; +} NDIS_SPIN_LOCK, * PNDIS_SPIN_LOCK; + +typedef struct _NDIS_EVENT +{ + KEVENT Event; +} NDIS_EVENT, *PNDIS_EVENT; + +typedef PVOID NDIS_HANDLE, *PNDIS_HANDLE; +typedef int NDIS_STATUS, *PNDIS_STATUS; + +typedef UNICODE_STRING NDIS_STRING, *PNDIS_STRING; + +typedef PCSTR NDIS_ANSI_STRING, *PNDIS_ANSI_STRING; + +typedef MDL NDIS_BUFFER, *PNDIS_BUFFER; + +/* NDIS_STATUS constants */ +#define NDIS_STATUS_SUCCESS ((NDIS_STATUS)STATUS_SUCCESS) +#define NDIS_STATUS_PENDING ((NDIS_STATUS)STATUS_PENDING) +#define NDIS_STATUS_NOT_RECOGNIZED ((NDIS_STATUS)0x00010001L) +#define NDIS_STATUS_NOT_COPIED ((NDIS_STATUS)0x00010002L) +#define NDIS_STATUS_NOT_ACCEPTED ((NDIS_STATUS)0x00010003L) +#define NDIS_STATUS_CALL_ACTIVE ((NDIS_STATUS)0x00010007L) + +#define NDIS_STATUS_ONLINE ((NDIS_STATUS)0x40010003L) +#define NDIS_STATUS_RESET_START ((NDIS_STATUS)0x40010004L) +#define NDIS_STATUS_RESET_END ((NDIS_STATUS)0x40010005L) +#define NDIS_STATUS_RING_STATUS ((NDIS_STATUS)0x40010006L) +#define NDIS_STATUS_CLOSED ((NDIS_STATUS)0x40010007L) +#define NDIS_STATUS_WAN_LINE_UP ((NDIS_STATUS)0x40010008L) +#define NDIS_STATUS_WAN_LINE_DOWN ((NDIS_STATUS)0x40010009L) +#define NDIS_STATUS_WAN_FRAGMENT ((NDIS_STATUS)0x4001000AL) +#define NDIS_STATUS_MEDIA_CONNECT ((NDIS_STATUS)0x4001000BL) +#define NDIS_STATUS_MEDIA_DISCONNECT ((NDIS_STATUS)0x4001000CL) +#define NDIS_STATUS_HARDWARE_LINE_UP ((NDIS_STATUS)0x4001000DL) +#define NDIS_STATUS_HARDWARE_LINE_DOWN ((NDIS_STATUS)0x4001000EL) +#define NDIS_STATUS_INTERFACE_UP ((NDIS_STATUS)0x4001000FL) +#define NDIS_STATUS_INTERFACE_DOWN ((NDIS_STATUS)0x40010010L) +#define NDIS_STATUS_MEDIA_BUSY ((NDIS_STATUS)0x40010011L) +#define NDIS_STATUS_WW_INDICATION ((NDIS_STATUS)0x40010012L) +#define NDIS_STATUS_TAPI_INDICATION ((NDIS_STATUS)0x40010080L) + +#define NDIS_STATUS_NOT_RESETTABLE ((NDIS_STATUS)0x80010001L) +#define NDIS_STATUS_SOFT_ERRORS ((NDIS_STATUS)0x80010003L) +#define NDIS_STATUS_HARD_ERRORS ((NDIS_STATUS)0x80010004L) +#define NDIS_STATUS_BUFFER_OVERFLOW ((NDIS_STATUS)STATUS_BUFFER_OVERFLOW) + +#define NDIS_STATUS_FAILURE ((NDIS_STATUS)STATUS_UNSUCCESSFUL) +#define NDIS_STATUS_RESOURCES ((NDIS_STATUS)STATUS_INSUFFICIENT_RESOURCES) +#define NDIS_STATUS_CLOSING ((NDIS_STATUS)0xC0010002L) +#define NDIS_STATUS_BAD_VERSION ((NDIS_STATUS)0xC0010004L) +#define NDIS_STATUS_BAD_CHARACTERISTICS ((NDIS_STATUS)0xC0010005L) +#define NDIS_STATUS_ADAPTER_NOT_FOUND ((NDIS_STATUS)0xC0010006L) +#define NDIS_STATUS_OPEN_FAILED ((NDIS_STATUS)0xC0010007L) +#define NDIS_STATUS_DEVICE_FAILED ((NDIS_STATUS)0xC0010008L) +#define NDIS_STATUS_MULTICAST_FULL ((NDIS_STATUS)0xC0010009L) +#define NDIS_STATUS_MULTICAST_EXISTS ((NDIS_STATUS)0xC001000AL) +#define NDIS_STATUS_MULTICAST_NOT_FOUND ((NDIS_STATUS)0xC001000BL) +#define NDIS_STATUS_REQUEST_ABORTED ((NDIS_STATUS)0xC001000CL) +#define NDIS_STATUS_RESET_IN_PROGRESS ((NDIS_STATUS)0xC001000DL) +#define NDIS_STATUS_CLOSING_INDICATING ((NDIS_STATUS)0xC001000EL) +#define NDIS_STATUS_NOT_SUPPORTED ((NDIS_STATUS)STATUS_NOT_SUPPORTED) +#define NDIS_STATUS_INVALID_PACKET ((NDIS_STATUS)0xC001000FL) +#define NDIS_STATUS_OPEN_LIST_FULL ((NDIS_STATUS)0xC0010010L) +#define NDIS_STATUS_ADAPTER_NOT_READY ((NDIS_STATUS)0xC0010011L) +#define NDIS_STATUS_ADAPTER_NOT_OPEN ((NDIS_STATUS)0xC0010012L) +#define NDIS_STATUS_NOT_INDICATING ((NDIS_STATUS)0xC0010013L) +#define NDIS_STATUS_INVALID_LENGTH ((NDIS_STATUS)0xC0010014L) +#define NDIS_STATUS_INVALID_DATA ((NDIS_STATUS)0xC0010015L) +#define NDIS_STATUS_BUFFER_TOO_SHORT ((NDIS_STATUS)0xC0010016L) +#define NDIS_STATUS_INVALID_OID ((NDIS_STATUS)0xC0010017L) +#define NDIS_STATUS_ADAPTER_REMOVED ((NDIS_STATUS)0xC0010018L) +#define NDIS_STATUS_UNSUPPORTED_MEDIA ((NDIS_STATUS)0xC0010019L) +#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((NDIS_STATUS)0xC001001AL) +#define NDIS_STATUS_FILE_NOT_FOUND ((NDIS_STATUS)0xC001001BL) +#define NDIS_STATUS_ERROR_READING_FILE ((NDIS_STATUS)0xC001001CL) +#define NDIS_STATUS_ALREADY_MAPPED ((NDIS_STATUS)0xC001001DL) +#define NDIS_STATUS_RESOURCE_CONFLICT ((NDIS_STATUS)0xC001001EL) +#define NDIS_STATUS_NO_CABLE ((NDIS_STATUS)0xC001001FL) + +#define NDIS_STATUS_INVALID_SAP ((NDIS_STATUS)0xC0010020L) +#define NDIS_STATUS_SAP_IN_USE ((NDIS_STATUS)0xC0010021L) +#define NDIS_STATUS_INVALID_ADDRESS ((NDIS_STATUS)0xC0010022L) +#define NDIS_STATUS_VC_NOT_ACTIVATED ((NDIS_STATUS)0xC0010023L) +#define NDIS_STATUS_DEST_OUT_OF_ORDER ((NDIS_STATUS)0xC0010024L) +#define NDIS_STATUS_VC_NOT_AVAILABLE ((NDIS_STATUS)0xC0010025L) +#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((NDIS_STATUS)0xC0010026L) +#define NDIS_STATUS_INCOMPATABLE_QOS ((NDIS_STATUS)0xC0010027L) +#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((NDIS_STATUS)0xC0010028L) +#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((NDIS_STATUS)0xC0010029L) + +#define NDIS_STATUS_TOKEN_RING_OPEN_ERROR ((NDIS_STATUS)0xC0011000L) + + +/* NDIS error codes for error logging */ + +#define NDIS_ERROR_CODE ULONG + +#define NDIS_ERROR_CODE_RESOURCE_CONFLICT EVENT_NDIS_RESOURCE_CONFLICT +#define NDIS_ERROR_CODE_OUT_OF_RESOURCES EVENT_NDIS_OUT_OF_RESOURCE +#define NDIS_ERROR_CODE_HARDWARE_FAILURE EVENT_NDIS_HARDWARE_FAILURE +#define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND EVENT_NDIS_ADAPTER_NOT_FOUND +#define NDIS_ERROR_CODE_INTERRUPT_CONNECT EVENT_NDIS_INTERRUPT_CONNECT +#define NDIS_ERROR_CODE_DRIVER_FAILURE EVENT_NDIS_DRIVER_FAILURE +#define NDIS_ERROR_CODE_BAD_VERSION EVENT_NDIS_BAD_VERSION +#define NDIS_ERROR_CODE_TIMEOUT EVENT_NDIS_TIMEOUT +#define NDIS_ERROR_CODE_NETWORK_ADDRESS EVENT_NDIS_NETWORK_ADDRESS +#define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION EVENT_NDIS_UNSUPPORTED_CONFIGURATION +#define NDIS_ERROR_CODE_INVALID_VALUE_FROM_ADAPTER EVENT_NDIS_INVALID_VALUE_FROM_ADAPTER +#define NDIS_ERROR_CODE_MISSING_CONFIGURATION_PARAMETER EVENT_NDIS_MISSING_CONFIGURATION_PARAMETER +#define NDIS_ERROR_CODE_BAD_IO_BASE_ADDRESS EVENT_NDIS_BAD_IO_BASE_ADDRESS +#define NDIS_ERROR_CODE_RECEIVE_SPACE_SMALL EVENT_NDIS_RECEIVE_SPACE_SMALL +#define NDIS_ERROR_CODE_ADAPTER_DISABLED EVENT_NDIS_ADAPTER_DISABLED + + +/* Memory allocation flags. Used by Ndis(Allocate|Free)Memory */ +#define NDIS_MEMORY_CONTIGUOUS 0x00000001 +#define NDIS_MEMORY_NONCACHED 0x00000002 + +/* NIC attribute flags. Used by NdisMSetAttributes(Ex) */ +#define NDIS_ATTRIBUTE_IGNORE_PACKET_TIMEOUT 0x00000001 +#define NDIS_ATTRIBUTE_IGNORE_REQUEST_TIMEOUT 0x00000002 +#define NDIS_ATTRIBUTE_IGNORE_TOKEN_RING_ERRORS 0x00000004 +#define NDIS_ATTRIBUTE_BUS_MASTER 0x00000008 +#define NDIS_ATTRIBUTE_INTERMEDIATE_DRIVER 0x00000010 + + + +#define MAXIMUM_PROCESSORS 32 + + + +/* Lock */ + +typedef union _NDIS_RW_LOCK_REFCOUNT +{ + UINT RefCount; + UCHAR cacheLine[16]; +} NDIS_RW_LOCK_REFCOUNT; + +typedef struct _NDIS_RW_LOCK +{ + union + { + struct + { + KSPIN_LOCK SpinLock; + PVOID Context; + }; + UCHAR Reserved[16]; + }; + + NDIS_RW_LOCK_REFCOUNT RefCount[MAXIMUM_PROCESSORS]; +} NDIS_RW_LOCK, *PNDIS_RW_LOCK; + +typedef struct _LOCK_STATE +{ + USHORT LockState; + KIRQL OldIrql; +} LOCK_STATE, *PLOCK_STATE; + + + +/* Timer */ + +typedef VOID (*PNDIS_TIMER_FUNCTION)( + IN PVOID SystemSpecific1, + IN PVOID FunctionContext, + IN PVOID SystemSpecific2, + IN PVOID SystemSpecific3); + +typedef struct _NDIS_TIMER +{ + KTIMER Timer; + KDPC Dpc; +} NDIS_TIMER, *PNDIS_TIMER; + + + +/* Hardware */ + +typedef CM_MCA_POS_DATA NDIS_MCA_POS_DATA, *PNDIS_MCA_POS_DATA; +typedef CM_EISA_SLOT_INFORMATION NDIS_EISA_SLOT_INFORMATION, *PNDIS_EISA_SLOT_INFORMATION; +typedef CM_EISA_FUNCTION_INFORMATION NDIS_EISA_FUNCTION_INFORMATION, *PNDIS_EISA_FUNCTION_INFORMATION; +typedef CM_PARTIAL_RESOURCE_LIST NDIS_RESOURCE_LIST, *PNDIS_RESOURCE_LIST; + +/* Hardware status codes (OID_GEN_HARDWARE_STATUS) */ +typedef enum _NDIS_HARDWARE_STATUS +{ + NdisHardwareStatusReady, + NdisHardwareStatusInitializing, + NdisHardwareStatusReset, + NdisHardwareStatusClosing, + NdisHardwareStatusNotReady +} NDIS_HARDWARE_STATUS, *PNDIS_HARDWARE_STATUS; + +/* OID_GEN_GET_TIME_CAPS */ +typedef struct _GEN_GET_TIME_CAPS +{ + ULONG Flags; + ULONG ClockPrecision; +} GEN_GET_TIME_CAPS, *PGEN_GET_TIME_CAPS; + +/* Flag bits */ +#define READABLE_LOCAL_CLOCK 0x00000001 +#define CLOCK_NETWORK_DERIVED 0x00000002 +#define CLOCK_PRECISION 0x00000004 +#define RECEIVE_TIME_INDICATION_CAPABLE 0x00000008 +#define TIMED_SEND_CAPABLE 0x00000010 +#define TIME_STAMP_CAPABLE 0x00000020 + +/* OID_GEN_GET_NETCARD_TIME */ +typedef struct _GEN_GET_NETCARD_TIME +{ + ULONGLONG ReadTime; +} GEN_GET_NETCARD_TIME, *PGEN_GET_NETCARD_TIME; + +/* NDIS driver medium (OID_GEN_MEDIA_SUPPORTED / OID_GEN_MEDIA_IN_USE) */ +typedef enum _NDIS_MEDIUM +{ + NdisMedium802_3, + NdisMedium802_5, + NdisMediumFddi, + NdisMediumWan, + NdisMediumLocalTalk, + NdisMediumDix, /* Defined for convenience, not a real medium */ + NdisMediumArcnetRaw, + NdisMediumArcnet878_2, + NdisMediumAtm, + NdisMediumWirelessWan, + NdisMediumIrda, + NdisMediumBpc, + NdisMediumCoWan, + NdisMedium1394, + NdisMediumMax +} NDIS_MEDIUM, *PNDIS_MEDIUM; + +/* NDIS packet filter bits (OID_GEN_CURRENT_PACKET_FILTER) */ +#define NDIS_PACKET_TYPE_DIRECTED 0x00000001 +#define NDIS_PACKET_TYPE_MULTICAST 0x00000002 +#define NDIS_PACKET_TYPE_ALL_MULTICAST 0x00000004 +#define NDIS_PACKET_TYPE_BROADCAST 0x00000008 +#define NDIS_PACKET_TYPE_SOURCE_ROUTING 0x00000010 +#define NDIS_PACKET_TYPE_PROMISCUOUS 0x00000020 +#define NDIS_PACKET_TYPE_SMT 0x00000040 +#define NDIS_PACKET_TYPE_ALL_LOCAL 0x00000080 +#define NDIS_PACKET_TYPE_GROUP 0x00001000 +#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL 0x00002000 +#define NDIS_PACKET_TYPE_FUNCTIONAL 0x00004000 +#define NDIS_PACKET_TYPE_MAC_FRAME 0x00008000 + +/* NDIS protocol option bits (OID_GEN_PROTOCOL_OPTIONS) */ +#define NDIS_PROT_OPTION_ESTIMATED_LENGTH 0x00000001 +#define NDIS_PROT_OPTION_NO_LOOPBACK 0x00000002 +#define NDIS_PROT_OPTION_NO_RSVD_ON_RCVPKT 0x00000004 + +/* NDIS MAC option bits (OID_GEN_MAC_OPTIONS) */ +#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA 0x00000001 +#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED 0x00000002 +#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND 0x00000004 +#define NDIS_MAC_OPTION_NO_LOOPBACK 0x00000008 +#define NDIS_MAC_OPTION_FULL_DUPLEX 0x00000010 +#define NDIS_MAC_OPTION_EOTX_INDICATION 0x00000020 +#define NDIS_MAC_OPTION_8021P_PRIORITY 0x00000040 +#define NDIS_MAC_OPTION_RESERVED 0x80000000 + +/* State of the LAN media (OID_GEN_MEDIA_CONNECT_STATUS) */ +typedef enum _NDIS_MEDIA_STATE +{ + NdisMediaStateConnected, + NdisMediaStateDisconnected +} NDIS_MEDIA_STATE, *PNDIS_MEDIA_STATE; + +/* OID_GEN_SUPPORTED_GUIDS */ +typedef struct _NDIS_GUID +{ + GUID Guid; + union + { + NDIS_OID Oid; + NDIS_STATUS Status; + }; + ULONG Size; + ULONG Flags; +} NDIS_GUID, *PNDIS_GUID; + +#define NDIS_GUID_TO_OID 0x00000001 +#define NDIS_GUID_TO_STATUS 0x00000002 +#define NDIS_GUID_ANSI_STRING 0x00000004 +#define NDIS_GUID_UNICODE_STRING 0x00000008 +#define NDIS_GUID_ARRAY 0x00000010 + + + +typedef struct _NDIS_PACKET_POOL +{ + NDIS_SPIN_LOCK SpinLock; + struct _NDIS_PACKET *FreeList; + UINT PacketLength; + UCHAR Buffer[1]; +} NDIS_PACKET_POOL, * PNDIS_PACKET_POOL; + +typedef struct _NDIS_PACKET_PRIVATE +{ + UINT PhysicalCount; + UINT TotalLength; + PNDIS_BUFFER Head; + PNDIS_BUFFER Tail; + PNDIS_PACKET_POOL Pool; + UINT Count; + ULONG Flags; /* See fPACKET_xxx bits below */ + BOOLEAN ValidCounts; + UCHAR NdisPacketFlags; + USHORT NdisPacketOobOffset; +} NDIS_PACKET_PRIVATE, * PNDIS_PACKET_PRIVATE; + +#define fPACKET_CONTAINS_MEDIA_SPECIFIC_INFO 0x40 +#define fPACKET_ALLOCATED_BY_NDIS 0x80 + +typedef struct _NDIS_PACKET { + NDIS_PACKET_PRIVATE Private; + union { + struct { + UCHAR MiniportReserved[2*sizeof(PVOID)]; + UCHAR WrapperReserved[2*sizeof(PVOID)]; + }; + struct { + UCHAR MiniportReservedEx[3*sizeof(PVOID)]; + UCHAR WrapperReservedEx[sizeof(PVOID)]; + }; + struct { + UCHAR MacReserved[4*sizeof(PVOID)]; + }; + }; + ULONG_PTR Reserved[2]; + UCHAR ProtocolReserved[1]; +} NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET; + +typedef struct _NDIS_PACKET_OOB_DATA { + union { + ULONGLONG TimeToSend; + ULONGLONG TimeSent; + }; + ULONGLONG TimeReceived; + UINT HeaderSize; + UINT SizeMediaSpecificInfo; + PVOID MediaSpecificInformation; + NDIS_STATUS Status; +} NDIS_PACKET_OOB_DATA, *PNDIS_PACKET_OOB_DATA; + +typedef struct _NDIS_PM_PACKET_PATTERN +{ + ULONG Priority; + ULONG Reserved; + ULONG MaskSize; + ULONG PatternOffset; + ULONG PatternSize; + ULONG PatternFlags; +} NDIS_PM_PACKET_PATTERN, *PNDIS_PM_PACKET_PATTERN; + + +/* Request types used by NdisRequest */ +typedef enum _NDIS_REQUEST_TYPE +{ + NdisRequestQueryInformation, + NdisRequestSetInformation, + NdisRequestQueryStatistics, + NdisRequestOpen, + NdisRequestClose, + NdisRequestSend, + NdisRequestTransferData, + NdisRequestReset, + NdisRequestGeneric1, + NdisRequestGeneric2, + NdisRequestGeneric3, + NdisRequestGeneric4 +} NDIS_REQUEST_TYPE, *PNDIS_REQUEST_TYPE; + +typedef struct _NDIS_REQUEST { + UCHAR MacReserved[16]; + NDIS_REQUEST_TYPE RequestType; + union _DATA { + struct QUERY_INFORMATION { + NDIS_OID Oid; + PVOID InformationBuffer; + UINT InformationBufferLength; + UINT BytesWritten; + UINT BytesNeeded; + } QUERY_INFORMATION; + struct SET_INFORMATION { + NDIS_OID Oid; + PVOID InformationBuffer; + UINT InformationBufferLength; + UINT BytesRead; + UINT BytesNeeded; + } SET_INFORMATION; + } DATA; +} NDIS_REQUEST, *PNDIS_REQUEST; + + + +/* Wide Area Networks definitions */ + +typedef struct _NDIS_WAN_PACKET +{ + LIST_ENTRY WanPacketQueue; + PUCHAR CurrentBuffer; + ULONG CurrentLength; + PUCHAR StartBuffer; + PUCHAR EndBuffer; + PVOID ProtocolReserved1; + PVOID ProtocolReserved2; + PVOID ProtocolReserved3; + PVOID ProtocolReserved4; + PVOID MacReserved1; + PVOID MacReserved2; + PVOID MacReserved3; + PVOID MacReserved4; +} NDIS_WAN_PACKET, *PNDIS_WAN_PACKET; + + + +/* DMA channel information */ + +typedef struct _NDIS_DMA_DESCRIPTION +{ + BOOLEAN DemandMode; + BOOLEAN AutoInitialize; + BOOLEAN DmaChannelSpecified; + DMA_WIDTH DmaWidth; + DMA_SPEED DmaSpeed; + ULONG DmaPort; + ULONG DmaChannel; +} NDIS_DMA_DESCRIPTION, *PNDIS_DMA_DESCRIPTION; + +typedef struct _NDIS_DMA_BLOCK +{ + PVOID MapRegisterBase; + KEVENT AllocationEvent; + PADAPTER_OBJECT SystemAdapterObject; + BOOLEAN InProgress; +} NDIS_DMA_BLOCK, *PNDIS_DMA_BLOCK; + + +/* Possible hardware architecture */ +typedef enum _NDIS_INTERFACE_TYPE +{ + NdisInterfaceInternal = Internal, + NdisInterfaceIsa = Isa, + NdisInterfaceEisa = Eisa, + NdisInterfaceMca = MicroChannel, + NdisInterfaceTurboChannel = TurboChannel, + NdisInterfacePci = PCIBus, + NdisInterfacePcMcia = PCMCIABus +} NDIS_INTERFACE_TYPE, *PNDIS_INTERFACE_TYPE; + +#define NdisInterruptLatched Latched +#define NdisInterruptLevelSensitive LevelSensitive +typedef KINTERRUPT_MODE NDIS_INTERRUPT_MODE, *PNDIS_INTERRUPT_MODE; + + +typedef enum _NDIS_PARAMETER_TYPE +{ + NdisParameterInteger, + NdisParameterHexInteger, + NdisParameterString, + NdisParameterMultiString +} NDIS_PARAMETER_TYPE, *PNDIS_PARAMETER_TYPE; + +typedef struct _NDIS_CONFIGURATION_PARAMETER +{ + NDIS_PARAMETER_TYPE ParameterType; + union + { + ULONG IntegerData; + NDIS_STRING StringData; + } ParameterData; +} NDIS_CONFIGURATION_PARAMETER, *PNDIS_CONFIGURATION_PARAMETER; + + +typedef PHYSICAL_ADDRESS NDIS_PHYSICAL_ADDRESS, *PNDIS_PHYSICAL_ADDRESS; + +typedef struct _NDIS_PHYSICAL_ADDRESS_UNIT +{ + NDIS_PHYSICAL_ADDRESS PhysicalAddress; + UINT Length; +} NDIS_PHYSICAL_ADDRESS_UNIT, *PNDIS_PHYSICAL_ADDRESS_UNIT; + + +typedef VOID (*ADAPTER_SHUTDOWN_HANDLER)( + IN PVOID ShutdownContext); + + + +#if defined(NDIS_WRAPPER) || !defined(NDIS_MINIPORT_DRIVER) + +/* Structures available only to full MAC drivers */ + +typedef BOOLEAN (*PNDIS_INTERRUPT_SERVICE)( + IN PVOID InterruptContext); + +typedef VOID (*PNDIS_DEFERRED_PROCESSING)( + IN PVOID SystemSpecific1, + IN PVOID InterruptContext, + IN PVOID SystemSpecific2, + IN PVOID SystemSpecific3); + + +typedef struct _NDIS_INTERRUPT +{ + PKINTERRUPT InterruptObject; + KSPIN_LOCK DpcCountLock; + PNDIS_INTERRUPT_SERVICE MacIsr; + PNDIS_DEFERRED_PROCESSING MacDpc; + KDPC InterruptDpc; + PVOID InterruptContext; + UCHAR DpcCount; + BOOLEAN Removing; + /* Used to tell when all DPCs for the adapter are completed */ + KEVENT DpcsCompletedEvent; +} NDIS_INTERRUPT, *PNDIS_INTERRUPT; + + +/* NDIS adapter information */ + +typedef NDIS_STATUS (*PNDIS_ACTIVATE_CALLBACK)( + IN NDIS_HANDLE NdisAdatperHandle, + IN NDIS_HANDLE MacAdapterContext, + IN ULONG DmaChannel); + +typedef struct _NDIS_PORT_DESCRIPTOR +{ + ULONG InitialPort; + ULONG NumberOfPorts; + PVOID * PortOffset; +} NDIS_PORT_DESCRIPTOR, *PNDIS_PORT_DESCRIPTOR; + +typedef struct _NDIS_ADAPTER_INFORMATION +{ + ULONG DmaChannel; + BOOLEAN Master; + BOOLEAN Dma32BitAddresses; + PNDIS_ACTIVATE_CALLBACK ActivateCallback; + NDIS_INTERFACE_TYPE AdapterType; + ULONG PhysicalMapRegistersNeeded; + ULONG MaximumPhysicalMapping; + ULONG NumberOfPortDescriptors; + NDIS_PORT_DESCRIPTOR PortDescriptors[1]; +} NDIS_ADAPTER_INFORMATION, *PNDIS_ADAPTER_INFORMATION; + + +/* Prototypes for NDIS_MAC_CHARACTERISTICS */ + +typedef NDIS_STATUS (*OPEN_ADAPTER_HANDLER)( + OUT PNDIS_STATUS OpenErrorStatus, + OUT NDIS_HANDLE * MacBindingHandle, + OUT PUINT SelectedMediumIndex, + IN PNDIS_MEDIUM MediumArray, + IN UINT MediumArraySize, + IN NDIS_HANDLE NdisBindingContext, + IN NDIS_HANDLE MacAdapterContext, + IN UINT OpenOptions, + IN PSTRING AddressingInformation OPTIONAL); + +typedef NDIS_STATUS (*CLOSE_ADAPTER_HANDLER)( + IN NDIS_HANDLE MacBindingHandle); + +typedef NDIS_STATUS (*SEND_HANDLER)( + IN NDIS_HANDLE MacBindingHandle, + IN PNDIS_PACKET Packet); + +typedef NDIS_STATUS (*WAN_SEND_HANDLER)( + IN NDIS_HANDLE MacBindingHandle, + IN PNDIS_WAN_PACKET Packet); + +typedef NDIS_STATUS (*TRANSFER_DATA_HANDLER)( + IN NDIS_HANDLE MacBindingHandle, + IN NDIS_HANDLE MacReceiveContext, + IN UINT ByteOffset, + IN UINT BytesToTransfer, + OUT PNDIS_PACKET Packet, + OUT PUINT BytesTransferred); + +typedef NDIS_STATUS (*WAN_TRANSFER_DATA_HANDLER)( + VOID); + +typedef NDIS_STATUS (*RESET_HANDLER)( + IN NDIS_HANDLE MacBindingHandle); + +typedef NDIS_STATUS (*REQUEST_HANDLER)( + IN NDIS_HANDLE MacBindingHandle, + IN PNDIS_REQUEST NdisRequest); + +typedef NDIS_STATUS (*QUERY_GLOBAL_STATISTICS_HANDLER)( + IN NDIS_HANDLE MacAdapterContext, + IN PNDIS_REQUEST NdisRequest); + +typedef VOID (*UNLOAD_MAC_HANDLER)( + IN NDIS_HANDLE MacMacContext); + +typedef NDIS_STATUS (*ADD_ADAPTER_HANDLER)( + IN NDIS_HANDLE MacMacContext, + IN NDIS_HANDLE WrapperConfigurationContext, + IN PNDIS_STRING AdapterName); + +typedef VOID (*REMOVE_ADAPTER_HANDLER)( + IN NDIS_HANDLE MacAdapterContext); + +typedef struct _NDIS_MAC_CHARACTERISTICS +{ + UCHAR MajorNdisVersion; + UCHAR MinorNdisVersion; + UINT Reserved; + OPEN_ADAPTER_HANDLER OpenAdapterHandler; + CLOSE_ADAPTER_HANDLER CloseAdapterHandler; + SEND_HANDLER SendHandler; + TRANSFER_DATA_HANDLER TransferDataHandler; + RESET_HANDLER ResetHandler; + REQUEST_HANDLER RequestHandler; + QUERY_GLOBAL_STATISTICS_HANDLER QueryGlobalStatisticsHandler; + UNLOAD_MAC_HANDLER UnloadMacHandler; + ADD_ADAPTER_HANDLER AddAdapterHandler; + REMOVE_ADAPTER_HANDLER RemoveAdapterHandler; + NDIS_STRING Name; +} NDIS_MAC_CHARACTERISTICS, *PNDIS_MAC_CHARACTERISTICS; + +typedef NDIS_MAC_CHARACTERISTICS NDIS_WAN_MAC_CHARACTERISTICS; +typedef NDIS_WAN_MAC_CHARACTERISTICS *PNDIS_WAN_MAC_CHARACTERISTICS; + + + +/* Functions available only to full MAC drivers */ + +VOID +EXPIMP +NdisAllocateSharedMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + OUT PVOID *VirtualAddress, + OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress); + +VOID +EXPIMP +NdisCompleteCloseAdapter( + IN NDIS_HANDLE NdisBindingContext, + IN NDIS_STATUS Status); + +VOID +EXPIMP +NdisCompleteOpenAdapter( + IN NDIS_HANDLE NdisBindingContext, + IN NDIS_STATUS Status, + IN NDIS_STATUS OpenErrorStatus); + +NDIS_STATUS +EXPIMP +NdisDeregisterAdapter( + IN NDIS_HANDLE NdisAdapterHandle); + +VOID +EXPIMP +NdisDeregisterAdapterShutdownHandler( + IN NDIS_HANDLE NdisAdapterHandle); + +VOID +EXPIMP +NdisFreeSharedMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +VOID +EXPIMP +NdisInitializeInterrupt( + OUT PNDIS_STATUS Status, + IN OUT PNDIS_INTERRUPT Interrupt, + IN NDIS_HANDLE NdisAdapterHandle, + IN PNDIS_INTERRUPT_SERVICE InterruptServiceRoutine, + IN PVOID InterruptContext, + IN PNDIS_DEFERRED_PROCESSING DeferredProcessingRoutine, + IN UINT InterruptVector, + IN UINT InterruptLevel, + IN BOOLEAN SharedInterrupt, + IN NDIS_INTERRUPT_MODE InterruptMode); + +VOID +EXPIMP +NdisMapIoSpace( + OUT PNDIS_STATUS Status, + OUT PVOID *VirtualAddress, + IN NDIS_HANDLE NdisAdapterHandle, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, + IN UINT Length); + +NDIS_STATUS +EXPIMP +NdisRegisterAdapter( + OUT PNDIS_HANDLE NdisAdapterHandle, + IN NDIS_HANDLE NdisMacHandle, + IN NDIS_HANDLE MacAdapterContext, + IN NDIS_HANDLE WrapperConfigurationContext, + IN PNDIS_STRING AdapterName, + IN PVOID AdapterInformation); + +VOID +EXPIMP +NdisRegisterAdapterShutdownHandler( + IN NDIS_HANDLE NdisAdapterHandle, + IN PVOID ShutdownContext, + IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler); + +VOID +EXPIMP +NdisRegisterMac( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE NdisMacHandle, + IN NDIS_HANDLE NdisWrapperHandle, + IN NDIS_HANDLE MacMacContext, + IN PNDIS_MAC_CHARACTERISTICS MacCharacteristics, + IN UINT CharacteristicsLength); + +VOID +EXPIMP +NdisReleaseAdapterResources( + IN NDIS_HANDLE NdisAdapterHandle); + +VOID +EXPIMP +NdisRemoveInterrupt( + IN PNDIS_INTERRUPT Interrupt); + +#endif /* NDIS_WRAPPER || !NDIS_MINIPORT_DRIVER */ + + + +#ifdef NDIS50 + +typedef struct _ATM_ADDRESS ATM_ADDRESS, *PATM_ADDRESS; + + +/* OID_GEN_NETWORK_LAYER_ADDRESSES */ +typedef struct _NETWORK_ADDRESS +{ + USHORT AddressLength; + USHORT AddressType; + UCHAR Address[1]; +} NETWORK_ADDRESS, *PNETWORK_ADDRESS; + +typedef struct _NETWORK_ADDRESS_LIST +{ + LONG AddressCount; + USHORT AddressType; + NETWORK_ADDRESS Address[1]; +} NETWORK_ADDRESS_LIST, *PNETWORK_ADDRESS_LIST; + +/* Protocol types supported by NDIS */ +#define NDIS_PROTOCOL_ID_DEFAULT 0x00 +#define NDIS_PROTOCOL_ID_TCP_IP 0x02 +#define NDIS_PROTOCOL_ID_IPX 0x06 +#define NDIS_PROTOCOL_ID_NBF 0x07 +#define NDIS_PROTOCOL_ID_MAX 0x0F +#define NDIS_PROTOCOL_ID_MASK 0x0F + +/* OID_GEN_TRANSPORT_HEADER_OFFSET */ +typedef struct _TRANSPORT_HEADER_OFFSET +{ + USHORT ProtocolType; + USHORT HeaderOffset; +} TRANSPORT_HEADER_OFFSET, *PTRANSPORT_HEADER_OFFSET; + + +/* OID_GEN_CO_LINK_SPEED / OID_GEN_CO_MINIMUM_LINK_SPEED */ +typedef struct _NDIS_CO_LINK_SPEED +{ + ULONG Outbound; + ULONG Inbound; +} NDIS_CO_LINK_SPEED, *PNDIS_CO_LINK_SPEED; + + +typedef enum _NDIS_AF +{ + CO_ADDRESS_FAMILY_Q2931 = 1, + CO_ADDRESS_FAMILY_SPANS, +} NDIS_AF, *PNDIS_AF; + +typedef struct +{ + NDIS_AF AddressFamily; + ULONG MajorVersion; + ULONG MinorVersion; +} CO_ADDRESS_FAMILY, *PCO_ADDRESS_FAMILY; + +typedef enum +{ + BestEffortService, + PredictiveService, + GuaranteedService +} GUARANTEE; + +typedef struct _CO_FLOW_PARAMETERS +{ + ULONG TokenRate; /* In Bytes/sec */ + ULONG TokenBucketSize; /* In Bytes */ + ULONG PeakBandwidth; /* In Bytes/sec */ + ULONG Latency; /* In microseconds */ + ULONG DelayVariation; /* In microseconds */ + GUARANTEE LevelOfGuarantee; /* Guaranteed, Predictive or Best Effort */ + ULONG CostOfCall; /* Reserved for future use, */ + /* must be set to 0 now */ + ULONG NetworkAvailability; /* read-only: 1 if accessible, 0 if not */ + ULONG MaxSduSize; /* In Bytes */ +} CO_FLOW_PARAMETERS, *PCO_FLOW_PARAMETERS; + +typedef struct _CO_SPECIFIC_PARAMETERS +{ + ULONG ParamType; + ULONG Length; + UCHAR Parameters[1]; +} CO_SPECIFIC_PARAMETERS, *PCO_SPECIFIC_PARAMETERS; + +typedef struct _CO_CALL_MANAGER_PARAMETERS { + CO_FLOW_PARAMETERS Transmit; + CO_FLOW_PARAMETERS Receive; + CO_SPECIFIC_PARAMETERS CallMgrSpecific; +} CO_CALL_MANAGER_PARAMETERS, *PCO_CALL_MANAGER_PARAMETERS; + +typedef struct _CO_MEDIA_PARAMETERS +{ + ULONG Flags; + ULONG ReceivePriority; + ULONG ReceiveSizeHint; + CO_SPECIFIC_PARAMETERS MediaSpecific; +} CO_MEDIA_PARAMETERS, *PCO_MEDIA_PARAMETERS; + +/* Definitions for the flags in CO_MEDIA_PARAMETERS */ +#define RECEIVE_TIME_INDICATION 0x00000001 +#define USE_TIME_STAMPS 0x00000002 +#define TRANSMIT_VC 0x00000004 +#define RECEIVE_VC 0x00000008 +#define INDICATE_ERRED_PACKETS 0x00000010 +#define INDICATE_END_OF_TX 0x00000020 +#define RESERVE_RESOURCES_VC 0x00000040 +#define ROUND_DOWN_FLOW 0x00000080 +#define ROUND_UP_FLOW 0x00000100 + +typedef struct _CO_CALL_PARAMETERS +{ + ULONG Flags; + PCO_CALL_MANAGER_PARAMETERS CallMgrParameters; + PCO_MEDIA_PARAMETERS MediaParameters; +} CO_CALL_PARAMETERS, *PCO_CALL_PARAMETERS; + +typedef struct _CO_SAP { + ULONG SapType; + ULONG SapLength; + UCHAR Sap[1]; +} CO_SAP, *PCO_SAP; + +typedef struct _NDIS_IPSEC_PACKET_INFO +{ + union + { + struct + { + NDIS_HANDLE OffloadHandle; + NDIS_HANDLE NextOffloadHandle; + } Transmit; + + struct + { + ULONG SA_DELETE_REQ:1; + ULONG CRYPTO_DONE:1; + ULONG NEXT_CRYPTO_DONE:1; + ULONG CryptoStatus; + } Receive; + }; +} NDIS_IPSEC_PACKET_INFO, *PNDIS_IPSEC_PACKET_INFO; + + +/* Plug and play and power management */ + +/* PnP and PM event codes */ +typedef enum _NET_PNP_EVENT_CODE +{ + NetEventSetPower, + NetEventQueryPower, + NetEventQueryRemoveDevice, + NetEventCancelRemoveDevice, + NetEventReconfigure, + NetEventBindList, + NetEventBindsComplete, + NetEventPnPCapabilities, + NetEventMaximum +} NET_PNP_EVENT_CODE, *PNET_PNP_EVENT_CODE; + +/* Networking PnP event indication structure */ +typedef struct _NET_PNP_EVENT +{ + /* Event code */ + NET_PNP_EVENT_CODE NetEvent; + /* Event specific data */ + PVOID Buffer; + /* Length of event specific data */ + ULONG BufferLength; + + /* Reserved areas */ + ULONG_PTR NdisReserved[4]; + ULONG_PTR TransportReserved[4]; + ULONG_PTR TdiReserved[4]; + ULONG_PTR TdiClientReserved[4]; +} NET_PNP_EVENT, *PNET_PNP_EVENT; + +/* Device power state structure */ +typedef enum _NET_DEVICE_POWER_STATE +{ + NetDeviceStateUnspecified = 0, + NetDeviceStateD0, + NetDeviceStateD1, + NetDeviceStateD2, + NetDeviceStateD3, + NetDeviceStateMaximum +} NET_DEVICE_POWER_STATE, *PNET_DEVICE_POWER_STATE; + + + +/* Call Manager */ + +typedef NDIS_STATUS (*CO_CREATE_VC_HANDLER)( + IN NDIS_HANDLE ProtocolAfContext, + IN NDIS_HANDLE NdisVcHandle, + OUT PNDIS_HANDLE ProtocolVcContext); + +typedef NDIS_STATUS (*CO_DELETE_VC_HANDLER)( + IN NDIS_HANDLE ProtocolVcContext); + +typedef NDIS_STATUS (*CO_REQUEST_HANDLER)( + IN NDIS_HANDLE ProtocolAfContext, + IN NDIS_HANDLE ProtocolVcContext OPTIONAL, + IN NDIS_HANDLE ProtocolPartyContext OPTIONAL, + IN OUT PNDIS_REQUEST NdisRequest); + +typedef VOID (*CO_REQUEST_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolAfContext OPTIONAL, + IN NDIS_HANDLE ProtocolVcContext OPTIONAL, + IN NDIS_HANDLE ProtocolPartyContext OPTIONAL, + IN PNDIS_REQUEST NdisRequest); + + +typedef NDIS_STATUS (*CM_OPEN_AF_HANDLER)( + IN NDIS_HANDLE CallMgrBindingContext, + IN PCO_ADDRESS_FAMILY AddressFamily, + IN NDIS_HANDLE NdisAfHandle, + OUT PNDIS_HANDLE CallMgrAfContext + ); + +typedef +NDIS_STATUS +(*CM_CLOSE_AF_HANDLER)( + IN NDIS_HANDLE CallMgrAfContext + ); + +typedef +NDIS_STATUS +(*CM_REG_SAP_HANDLER)( + IN NDIS_HANDLE CallMgrAfContext, + IN PCO_SAP Sap, + IN NDIS_HANDLE NdisSapHandle, + OUT PNDIS_HANDLE CallMgrSapContext + ); + +typedef +NDIS_STATUS +(*CM_DEREG_SAP_HANDLER)( + IN NDIS_HANDLE CallMgrSapContext + ); + +typedef +NDIS_STATUS +(*CM_MAKE_CALL_HANDLER)( + IN NDIS_HANDLE CallMgrVcContext, + IN OUT PCO_CALL_PARAMETERS CallParameters, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + OUT PNDIS_HANDLE CallMgrPartyContext OPTIONAL + ); + +typedef +NDIS_STATUS +(*CM_CLOSE_CALL_HANDLER)( + IN NDIS_HANDLE CallMgrVcContext, + IN NDIS_HANDLE CallMgrPartyContext OPTIONAL, + IN PVOID CloseData OPTIONAL, + IN UINT Size OPTIONAL + ); + +typedef +VOID +(*CM_INCOMING_CALL_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE CallMgrVcContext, + IN PCO_CALL_PARAMETERS CallParameters + ); + +typedef +NDIS_STATUS +(*CM_ADD_PARTY_HANDLER)( + IN NDIS_HANDLE CallMgrVcContext, + IN OUT PCO_CALL_PARAMETERS CallParameters, + IN NDIS_HANDLE NdisPartyHandle, + OUT PNDIS_HANDLE CallMgrPartyContext + ); + +typedef +NDIS_STATUS +(*CM_DROP_PARTY_HANDLER)( + IN NDIS_HANDLE CallMgrPartyContext, + IN PVOID CloseData OPTIONAL, + IN UINT Size OPTIONAL + ); + +typedef +VOID +(*CM_ACTIVATE_VC_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE CallMgrVcContext, + IN PCO_CALL_PARAMETERS CallParameters + ); + +typedef +VOID +(*CM_DEACTIVATE_VC_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE CallMgrVcContext + ); + +typedef +NDIS_STATUS +(*CM_MODIFY_CALL_QOS_HANDLER)( + IN NDIS_HANDLE CallMgrVcContext, + IN PCO_CALL_PARAMETERS CallParameters + ); + +typedef struct _NDIS_CALL_MANAGER_CHARACTERISTICS +{ + UCHAR MajorVersion; + UCHAR MinorVersion; + + USHORT Filler; + UINT Reserved; + + CO_CREATE_VC_HANDLER CmCreateVcHandler; + CO_DELETE_VC_HANDLER CmDeleteVcHandler; + CM_OPEN_AF_HANDLER CmOpenAfHandler; + CM_CLOSE_AF_HANDLER CmCloseAfHandler; + CM_REG_SAP_HANDLER CmRegisterSapHandler; + CM_DEREG_SAP_HANDLER CmDeregisterSapHandler; + CM_MAKE_CALL_HANDLER CmMakeCallHandler; + CM_CLOSE_CALL_HANDLER CmCloseCallHandler; + CM_INCOMING_CALL_COMPLETE_HANDLER CmIncomingCallCompleteHandler; + CM_ADD_PARTY_HANDLER CmAddPartyHandler; + CM_DROP_PARTY_HANDLER CmDropPartyHandler; + CM_ACTIVATE_VC_COMPLETE_HANDLER CmActivateVcCompleteHandler; + CM_DEACTIVATE_VC_COMPLETE_HANDLER CmDeactivateVcCompleteHandler; + CM_MODIFY_CALL_QOS_HANDLER CmModifyCallQoSHandler; + CO_REQUEST_HANDLER CmRequestHandler; + CO_REQUEST_COMPLETE_HANDLER CmRequestCompleteHandler; +} NDIS_CALL_MANAGER_CHARACTERISTICS, *PNDIS_CALL_MANAGER_CHARACTERISTICS; + + + +/* Call Manager clients */ + +typedef VOID (*CL_OPEN_AF_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolAfContext, + IN NDIS_HANDLE NdisAfHandle); + +typedef VOID (*CL_CLOSE_AF_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolAfContext); + +typedef VOID (*CL_REG_SAP_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolSapContext, + IN PCO_SAP Sap, + IN NDIS_HANDLE NdisSapHandle); + +typedef VOID (*CL_DEREG_SAP_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolSapContext); + +typedef VOID (*CL_MAKE_CALL_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolVcContext, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN PCO_CALL_PARAMETERS CallParameters); + +typedef VOID (*CL_MODIFY_CALL_QOS_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolVcContext, + IN PCO_CALL_PARAMETERS CallParameters); + +typedef VOID (*CL_CLOSE_CALL_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolVcContext, + IN NDIS_HANDLE ProtocolPartyContext OPTIONAL); + +typedef VOID (*CL_ADD_PARTY_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolPartyContext, + IN NDIS_HANDLE NdisPartyHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +typedef VOID (*CL_DROP_PARTY_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolPartyContext); + +typedef NDIS_STATUS (*CL_INCOMING_CALL_HANDLER)( + IN NDIS_HANDLE ProtocolSapContext, + IN NDIS_HANDLE ProtocolVcContext, + IN OUT PCO_CALL_PARAMETERS CallParameters); + +typedef VOID (*CL_INCOMING_CALL_QOS_CHANGE_HANDLER)( + IN NDIS_HANDLE ProtocolVcContext, + IN PCO_CALL_PARAMETERS CallParameters); + +typedef VOID (*CL_INCOMING_CLOSE_CALL_HANDLER)( + IN NDIS_STATUS CloseStatus, + IN NDIS_HANDLE ProtocolVcContext, + IN PVOID CloseData OPTIONAL, + IN UINT Size OPTIONAL); + +typedef VOID (*CL_INCOMING_DROP_PARTY_HANDLER)( + IN NDIS_STATUS DropStatus, + IN NDIS_HANDLE ProtocolPartyContext, + IN PVOID CloseData OPTIONAL, + IN UINT Size OPTIONAL); + +typedef VOID (*CL_CALL_CONNECTED_HANDLER)( + IN NDIS_HANDLE ProtocolVcContext); + + +typedef struct _NDIS_CLIENT_CHARACTERISTICS +{ + UCHAR MajorVersion; + UCHAR MinorVersion; + + USHORT Filler; + UINT Reserved; + + CO_CREATE_VC_HANDLER ClCreateVcHandler; + CO_DELETE_VC_HANDLER ClDeleteVcHandler; + CO_REQUEST_HANDLER ClRequestHandler; + CO_REQUEST_COMPLETE_HANDLER ClRequestCompleteHandler; + CL_OPEN_AF_COMPLETE_HANDLER ClOpenAfCompleteHandler; + CL_CLOSE_AF_COMPLETE_HANDLER ClCloseAfCompleteHandler; + CL_REG_SAP_COMPLETE_HANDLER ClRegisterSapCompleteHandler; + CL_DEREG_SAP_COMPLETE_HANDLER ClDeregisterSapCompleteHandler; + CL_MAKE_CALL_COMPLETE_HANDLER ClMakeCallCompleteHandler; + CL_MODIFY_CALL_QOS_COMPLETE_HANDLER ClModifyCallQoSCompleteHandler; + CL_CLOSE_CALL_COMPLETE_HANDLER ClCloseCallCompleteHandler; + CL_ADD_PARTY_COMPLETE_HANDLER ClAddPartyCompleteHandler; + CL_DROP_PARTY_COMPLETE_HANDLER ClDropPartyCompleteHandler; + CL_INCOMING_CALL_HANDLER ClIncomingCallHandler; + CL_INCOMING_CALL_QOS_CHANGE_HANDLER ClIncomingCallQoSChangeHandler; + CL_INCOMING_CLOSE_CALL_HANDLER ClIncomingCloseCallHandler; + CL_INCOMING_DROP_PARTY_HANDLER ClIncomingDropPartyHandler; + CL_CALL_CONNECTED_HANDLER ClCallConnectedHandler; +} NDIS_CLIENT_CHARACTERISTICS, *PNDIS_CLIENT_CHARACTERISTICS; + +#endif /* NDIS50 */ + + + +/* NDIS protocol structures */ + +/* Prototypes for NDIS 3.0 protocol characteristics */ + +typedef VOID (*OPEN_ADAPTER_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_STATUS Status, + IN NDIS_STATUS OpenErrorStatus); + +typedef VOID (*CLOSE_ADAPTER_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_STATUS Status); + +typedef VOID (*RESET_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_STATUS Status); + +typedef VOID (*REQUEST_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_REQUEST NdisRequest, + IN NDIS_STATUS Status); + +typedef VOID (*STATUS_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_STATUS GeneralStatus, + IN PVOID StatusBuffer, + IN UINT StatusBufferSize); + +typedef VOID (*STATUS_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext); + +typedef VOID (*SEND_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_PACKET Packet, + IN NDIS_STATUS Status); + +typedef VOID (*WAN_SEND_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_WAN_PACKET Packet, + IN NDIS_STATUS Status); + +typedef VOID (*TRANSFER_DATA_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_PACKET Packet, + IN NDIS_STATUS Status, + IN UINT BytesTransferred); + +typedef VOID (*WAN_TRANSFER_DATA_COMPLETE_HANDLER)( + VOID); + +typedef NDIS_STATUS (*RECEIVE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_HANDLE MacReceiveContext, + IN PVOID HeaderBuffer, + IN UINT HeaderBufferSize, + IN PVOID LookAheadBuffer, + IN UINT LookaheadBufferSize, + IN UINT PacketSize); + +typedef NDIS_STATUS (*WAN_RECEIVE_HANDLER)( + IN NDIS_HANDLE NdisLinkHandle, + IN PUCHAR Packet, + IN ULONG PacketSize); + +typedef VOID (*RECEIVE_COMPLETE_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext); + + +/* Protocol characteristics for NDIS 3.0 protocols */ +typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS +{ + UCHAR MajorNdisVersion; + UCHAR MinorNdisVersion; + union + { + UINT Reserved; + UINT Flags; + }; + OPEN_ADAPTER_COMPLETE_HANDLER OpenAdapterCompleteHandler; + CLOSE_ADAPTER_COMPLETE_HANDLER CloseAdapterCompleteHandler; + union + { + SEND_COMPLETE_HANDLER SendCompleteHandler; + WAN_SEND_COMPLETE_HANDLER WanSendCompleteHandler; + }; + union + { + TRANSFER_DATA_COMPLETE_HANDLER TransferDataCompleteHandler; + WAN_TRANSFER_DATA_COMPLETE_HANDLER WanTransferDataCompleteHandler; + }; + + RESET_COMPLETE_HANDLER ResetCompleteHandler; + REQUEST_COMPLETE_HANDLER RequestCompleteHandler; + union + { + RECEIVE_HANDLER ReceiveHandler; + WAN_RECEIVE_HANDLER WanReceiveHandler; + }; + RECEIVE_COMPLETE_HANDLER ReceiveCompleteHandler; + STATUS_HANDLER StatusHandler; + STATUS_COMPLETE_HANDLER StatusCompleteHandler; + NDIS_STRING Name; +} NDIS30_PROTOCOL_CHARACTERISTICS; + + +/* Prototypes for NDIS 4.0 protocol characteristics */ + +typedef INT (*RECEIVE_PACKET_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_PACKET Packet); + +typedef VOID (*BIND_HANDLER)( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE BindContext, + IN PNDIS_STRING DeviceName, + IN PVOID SystemSpecific1, + IN PVOID SystemSpecific2); + +typedef VOID (*UNBIND_HANDLER)( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_HANDLE UnbindContext); + +typedef VOID (*TRANSLATE_HANDLER)( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE ProtocolBindingContext, + OUT PNET_PNP_ID IdList, + IN ULONG IdListLength, + OUT PULONG BytesReturned); + +typedef VOID (*UNLOAD_PROTOCOL_HANDLER)( + VOID); + + +/* Protocol characteristics for NDIS 4.0 protocols */ + +typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS +{ + NDIS30_PROTOCOL_CHARACTERISTICS; + + RECEIVE_PACKET_HANDLER ReceivePacketHandler; + BIND_HANDLER BindAdapterHandler; + UNBIND_HANDLER UnbindAdapterHandler; + TRANSLATE_HANDLER TranslateHandler; + UNLOAD_PROTOCOL_HANDLER UnloadHandler; +} NDIS40_PROTOCOL_CHARACTERISTICS; + + + +/* Prototypes for NDIS 5.0 protocol characteristics */ + +#ifdef NDIS50 + +typedef VOID (*CO_SEND_COMPLETE_HANDLER)( + IN NDIS_STATUS Status, + IN NDIS_HANDLE ProtocolVcContext, + IN PNDIS_PACKET Packet); + +typedef VOID (*CO_STATUS_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_HANDLE ProtocolVcContext OPTIONAL, + IN NDIS_STATUS GeneralStatus, + IN PVOID StatusBuffer, + IN UINT StatusBufferSize); + +typedef UINT (*CO_RECEIVE_PACKET_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN NDIS_HANDLE ProtocolVcContext, + IN PNDIS_PACKET Packet); + +typedef VOID (*CO_AF_REGISTER_NOTIFY_HANDLER)( + IN NDIS_HANDLE ProtocolBindingContext, + IN PCO_ADDRESS_FAMILY AddressFamily); + + +typedef struct _NDIS50_PROTOCOL_CHARACTERISTICS +{ + NDIS40_PROTOCOL_CHARACTERISTICS; + + PVOID ReservedHandlers[4]; + + CO_SEND_COMPLETE_HANDLER CoSendCompleteHandler; + CO_STATUS_HANDLER CoStatusHandler; + CO_RECEIVE_PACKET_HANDLER CoReceivePacketHandler; + CO_AF_REGISTER_NOTIFY_HANDLER CoAfRegisterNotifyHandler; +} NDIS50_PROTOCOL_CHARACTERISTICS; + +#endif /* NDIS50 */ + + +#ifndef NDIS50 +#ifndef NDIS40 +typedef struct _NDIS30_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS; +#else /* NDIS40 */ +typedef struct _NDIS40_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS; +#endif /* NDIS40 */ +#else /* NDIS50 */ +typedef struct _NDIS50_PROTOCOL_CHARACTERISTICS NDIS_PROTOCOL_CHARACTERISTICS; +#endif /* NDIS50 */ + +typedef NDIS_PROTOCOL_CHARACTERISTICS *PNDIS_PROTOCOL_CHARACTERISTICS; + + + +/* Buffer management routines */ + +VOID +EXPIMP +NdisAllocateBuffer( + OUT PNDIS_STATUS Status, + OUT PNDIS_BUFFER *Buffer, + IN NDIS_HANDLE PoolHandle, + IN PVOID VirtualAddress, + IN UINT Length); + +VOID +EXPIMP +NdisAllocateBufferPool( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE PoolHandle, + IN UINT NumberOfDescriptors); + +VOID +EXPIMP +NdisAllocatePacket( + OUT PNDIS_STATUS Status, + OUT PNDIS_PACKET *Packet, + IN NDIS_HANDLE PoolHandle); + +VOID +EXPIMP +NdisAllocatePacketPool( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE PoolHandle, + IN UINT NumberOfDescriptors, + IN UINT ProtocolReservedLength); + +VOID +EXPIMP +NdisCopyBuffer( + OUT PNDIS_STATUS Status, + OUT PNDIS_BUFFER *Buffer, + IN NDIS_HANDLE PoolHandle, + IN PVOID MemoryDescriptor, + IN UINT Offset, + IN UINT Length); + +VOID +EXPIMP +NdisCopyFromPacketToPacket( + IN PNDIS_PACKET Destination, + IN UINT DestinationOffset, + IN UINT BytesToCopy, + IN PNDIS_PACKET Source, + IN UINT SourceOffset, + OUT PUINT BytesCopied); + +VOID +EXPIMP +NdisDprAllocatePacket( + OUT PNDIS_STATUS Status, + OUT PNDIS_PACKET *Packet, + IN NDIS_HANDLE PoolHandle); + +VOID +EXPIMP +NdisDprAllocatePacketNonInterlocked( + OUT PNDIS_STATUS Status, + OUT PNDIS_PACKET *Packet, + IN NDIS_HANDLE PoolHandle); + +VOID +EXPIMP +NdisDprFreePacket( + IN PNDIS_PACKET Packet); + +VOID +EXPIMP +NdisDprFreePacketNonInterlocked( + IN PNDIS_PACKET Packet); + +VOID +EXPIMP +NdisFreeBufferPool( + IN NDIS_HANDLE PoolHandle); + +VOID +EXPIMP +NdisFreePacket( + IN PNDIS_PACKET Packet); + +VOID +EXPIMP +NdisFreePacketPool( + IN NDIS_HANDLE PoolHandle); + +VOID +EXPIMP +NdisReturnPackets( + IN PNDIS_PACKET *PacketsToReturn, + IN UINT NumberOfPackets); + +VOID +EXPIMP +NdisUnchainBufferAtBack( + IN OUT PNDIS_PACKET Packet, + OUT PNDIS_BUFFER *Buffer); + +VOID +EXPIMP +NdisUnchainBufferAtFront( + IN OUT PNDIS_PACKET Packet, + OUT PNDIS_BUFFER *Buffer); + +#if BINARY_COMPATIBLE + +VOID +EXPIMP +NdisAdjustBufferLength( + IN PNDIS_BUFFER Buffer, + IN UINT Length); + +ULONG +EXPIMP +NDIS_BUFFER_TO_SPAN_PAGES( + IN PNDIS_BUFFER Buffer); + +VOID +EXPIMP +NdisFreeBuffer( + IN PNDIS_BUFFER Buffer); + +VOID +EXPIMP +NdisGetBufferPhysicalArraySize( + IN PNDIS_BUFFER Buffer, + OUT PUINT ArraySize); + +VOID +EXPIMP +NdisGetFirstBufferFromPacket( + IN PNDIS_PACKET _Packet, + OUT PNDIS_BUFFER *_FirstBuffer, + OUT PVOID *_FirstBufferVA, + OUT PUINT _FirstBufferLength, + OUT PUINT _TotalBufferLength); + +VOID +EXPIMP +NdisQueryBuffer( + IN PNDIS_BUFFER Buffer, + OUT PVOID *VirtualAddress OPTIONAL, + OUT PUINT Length); + +VOID +EXPIMP +NdisQueryBufferOffset( + IN PNDIS_BUFFER Buffer, + OUT PUINT Offset, + OUT PUINT Length); + +#else /* BINARY_COMPATIBLE */ + +/* + * PVOID NdisAdjustBufferLength( + * IN PNDIS_BUFFER Buffer, + * IN UINT Length); + */ +#define NdisAdjustBufferLength(Buffer, \ + Length) \ +{ \ + (Buffer)->ByteCount = (Length); \ +} + + +/* + * ULONG NDIS_BUFFER_TO_SPAN_PAGES( + * IN PNDIS_BUFFER Buffer); + */ +#define NDIS_BUFFER_TO_SPAN_PAGES(Buffer) \ +( \ + MmGetMdlByteCount(Buffer) == 0 ? \ + 1 : \ + ADDRESS_AND_SIZE_TO_SPAN_PAGES( \ + MmGetMdlVirtualAddress(Buffer), \ + MmGetMdlByteCount(Buffer)) \ +) + + +#if 0 + +/* + * VOID NdisFreeBuffer( + * IN PNDIS_BUFFER Buffer); + */ +#define NdisFreeBuffer(Buffer) \ +{ \ + IoFreeMdl(Buffer) /* ??? */ \ +} + +#else + +VOID +EXPIMP +NdisFreeBuffer( + IN PNDIS_BUFFER Buffer); + +#endif + + +/* + * VOID NdisGetBufferPhysicalArraySize( + * IN PNDIS_BUFFER Buffer, + * OUT PUINT ArraySize); + */ +#define NdisGetBufferPhysicalArraySize(Buffer, \ + ArraySize) \ +{ \ +} + + +/* + * VOID NdisGetFirstBufferFromPacket( + * IN PNDIS_PACKET _Packet, + * OUT PNDIS_BUFFER * _FirstBuffer, + * OUT PVOID * _FirstBufferVA, + * OUT PUINT _FirstBufferLength, + * OUT PUINT _TotalBufferLength) + */ +#define NdisGetFirstBufferFromPacket(Packet, \ + FirstBuffer, \ + FirstBufferVA, \ + FirstBufferLength, \ + TotalBufferLength) \ +{ \ + PNDIS_BUFFER _Buffer; \ + \ + _Buffer = (Packet)->Private.Head; \ + *(FirstBuffer) = _Buffer; \ + *(FirstBufferVA) = MmGetMdlVirtualAddress(_Buffer); \ + if (_Buffer != NULL) { \ + *(FirstBufferLength) = MmGetMdlByteCount(_Buffer); \ + _Buffer = _Buffer->Next; \ + } else \ + *(FirstBufferLength) = 0; \ + *(TotalBufferLength) = *(FirstBufferLength); \ + while (_Buffer != NULL) { \ + *(TotalBufferLength) += MmGetMdlByteCount(_Buffer); \ + _Buffer = _Buffer->Next; \ + } \ +} + +/* + * VOID NdisQueryBuffer( + * IN PNDIS_BUFFER Buffer, + * OUT PVOID *VirtualAddress OPTIONAL, + * OUT PUINT Length) + */ +#define NdisQueryBuffer(Buffer, \ + VirtualAddress, \ + Length) \ +{ \ + if (VirtualAddress != NULL) \ + *(PVOID*)(VirtualAddress) = MmGetSystemAddressForMdl(Buffer); \ + \ + *(Length) = MmGetMdlByteCount(Buffer); \ +} + + +/* + * VOID NdisQueryBufferOffset( + * IN PNDIS_BUFFER Buffer, + * OUT PUINT Offset, + * OUT PUINT Length); + */ +#define NdisQueryBufferOffset(Buffer, \ + Offset, \ + Length) \ +{ \ + *(PUINT)(Offset) = MmGetMdlByteOffset(Buffer); \ + *(PUINT)(Length) = MmGetMdlByteCount(Buffer); \ +} + +#endif /* BINARY_COMPATIBLE */ + + +/* + * PVOID NDIS_BUFFER_LINKAGE( + * IN PNDIS_BUFFER Buffer); + */ +#define NDIS_BUFFER_LINKAGE(Buffer) \ +{ \ + (Buffer)->Next; \ +} + + +/* + * VOID NdisChainBufferAtBack( + * IN OUT PNDIS_PACKET Packet, + * IN OUT PNDIS_BUFFER Buffer) + */ +#define NdisChainBufferAtBack(Packet, \ + Buffer) \ +{ \ + PNDIS_BUFFER NdisBuffer = (Buffer); \ + \ + while (NdisBuffer->Next != NULL) \ + NdisBuffer = NdisBuffer->Next; \ + \ + NdisBuffer->Next = NULL; \ + \ + if ((Packet)->Private.Head != NULL) \ + (Packet)->Private.Tail->Next = (Buffer); \ + else \ + (Packet)->Private.Head = (Buffer); \ + \ + (Packet)->Private.Tail = NdisBuffer; \ + (Packet)->Private.ValidCounts = FALSE; \ +} + + +/* + * VOID NdisChainBufferAtFront( + * IN OUT PNDIS_PACKET Packet, + * IN OUT PNDIS_BUFFER Buffer) + */ +#define NdisChainBufferAtFront(Packet, \ + Buffer) \ +{ \ + PNDIS_BUFFER _NdisBuffer = (Buffer); \ + \ + while (_NdisBuffer->Next != NULL) \ + _NdisBuffer = _NdisBuffer->Next; \ + \ + if ((Packet)->Private.Head == NULL) \ + (Packet)->Private.Tail = _NdisBuffer; \ + \ + _NdisBuffer->Next = (Packet)->Private.Head; \ + (Packet)->Private.Head = (Buffer); \ + (Packet)->Private.ValidCounts = FALSE; \ +} + + +/* + * VOID NdisGetNextBuffer( + * IN PNDIS_BUFFER CurrentBuffer, + * OUT PNDIS_BUFFER * NextBuffer) + */ +#define NdisGetNextBuffer(CurrentBuffer, \ + NextBuffer) \ +{ \ + *(NextBuffer) = (CurrentBuffer)->Next; \ +} + + +/* + * UINT NdisGetPacketFlags( + * IN PNDIS_PACKET Packet); + */ +#define NdisGetPacketFlags(Packet) \ +{ \ + (Packet)->Private.Flags; \ +} + + +/* + * UINT NDIS_GET_PACKET_HEADER_SIZE( + * IN PNDIS_PACKET Packet); + */ +#define NDIS_GET_PACKET_HEADER_SIZE(Packet) \ +{ \ +} + + +/* + * VOID NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO( + * IN PNDIS_PACKET Packet, + * IN PPVOID pMediaSpecificInfo, + * IN PUINT pSizeMediaSpecificInfo); + */ +#define NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet, \ + pMediaSpecificInfo, \ + pSizeMediaSpecificInfo) \ +{ \ +} + + +/* + * VOID NDIS_STATUS NDIS_GET_PACKET_STATUS( + * IN PNDIS_PACKET Packet); + */ +#define NDIS_GET_PACKET_STATUS (Packet) \ +{ \ +} + + +/* + * ULONGLONG NDIS_GET_PACKET_TIME_RECEIVED( + * IN PNDIS_PACKET Packet); + */ +#define NDIS_GET_PACKET_TIME_RECEIVED(Packet) \ +{ \ +} + + +/* + * ULONGLONG NDIS_GET_PACKET_TIME_SENT( + * IN PNDIS_PACKET Packet); + */ +#define NDIS_GET_PACKET_TIME_SENT(Packet) \ +{ \ +} + + +/* + * ULONGLONG NDIS_GET_PACKET_TIME_TO_SEND( + * IN PNDIS_PACKET Packet); + */ +#define NDIS_GET_PACKET_TIME_TO_SEND(Packet) \ +{ \ +} + + +/* + * PNDIS_PACKET_OOB_DATA NDIS_OOB_DATA_FROM_PACKET( + * IN PNDIS_PACKET _Packet); + */ +#define NDIS_OOB_DATA_FROM_PACKET(_Packet) \ +{ \ +} + + +/* + * VOID NdisQueryPacket( + * IN PNDIS_PACKET Packet, + * OUT PUINT PhysicalBufferCount OPTIONAL, + * OUT PUINT BufferCount OPTIONAL, + * OUT PNDIS_BUFFER *FirstBuffer OPTIONAL, + * OUT PUINT TotalPacketLength OPTIONAL); + */ +#define NdisQueryPacket(Packet, \ + PhysicalBufferCount, \ + BufferCount, \ + FirstBuffer, \ + TotalPacketLength) \ +{ \ + if ((FirstBuffer) != NULL) \ + *(FirstBuffer) = (Packet)->Private.Head; \ + if ((TotalPacketLength) || (BufferCount) || (PhysicalBufferCount)) { \ + if (!(Packet)->Private.ValidCounts) { \ + UINT _Offset; \ + UINT _PacketLength; \ + PNDIS_BUFFER _NdisBuffer; \ + UINT _PhysicalBufferCount = 0; \ + UINT _TotalPacketLength = 0; \ + UINT _Count = 0; \ + \ + for (_NdisBuffer = (Packet)->Private.Head; \ + _NdisBuffer != (PNDIS_BUFFER)NULL; \ + _NdisBuffer = _NdisBuffer->Next) { \ + _PhysicalBufferCount += NDIS_BUFFER_TO_SPAN_PAGES(_NdisBuffer); \ + NdisQueryBufferOffset(_NdisBuffer, &_Offset, &_PacketLength); \ + _TotalPacketLength += _PacketLength; \ + _Count++; \ + } \ + (Packet)->Private.PhysicalCount = _PhysicalBufferCount; \ + (Packet)->Private.TotalLength = _TotalPacketLength; \ + (Packet)->Private.Count = _Count; \ + (Packet)->Private.ValidCounts = TRUE; \ + } \ + \ + if (PhysicalBufferCount) \ + *(PUINT)(PhysicalBufferCount) = (Packet)->Private.PhysicalCount; \ + \ + if (BufferCount) \ + *(PUINT)(BufferCount) = (Packet)->Private.Count; \ + \ + if (TotalPacketLength) \ + *(PUINT)(TotalPacketLength) = (Packet)->Private.TotalLength; \ + } \ +} + +/* + * VOID NdisRecalculatePacketCounts( + * IN OUT PNDIS_PACKET Packet); + */ +#define NdisRecalculatePacketCounts(Packet) \ +{ \ +} + + +/* + * VOID NdisReinitializePacket( + * IN OUT PNDIS_PACKET Packet); + */ +#define NdisReinitializePacketCounts(Packet) \ +{ \ +} + + +/* + * VOID NdisSetPacketFlags( + * IN PNDIS_PACKET Packet, + * IN UINT Flags); + */ +#define NdisSetPacketFlags(Packet, Flags) \ + (Packet)->Private.Flags = (Flags); + + +/* + * NDIS_SET_PACKET_HEADER_SIZE( + * IN PNDIS_PACKET Packet, + * IN UINT HdrSize); + */ +#define NDIS_SET_PACKET_HEADER_SIZE(Packet, \ + HdrSize) \ +{ \ +} + + +/* + * NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO( + * IN PNDIS_PACKET Packet, + * IN PVOID MediaSpecificInfo, + * IN UINT SizeMediaSpecificInfo); + */ +#define NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(Packet, \ + MediaSpecificInfo, \ + SizeMediaSpecificInfo) \ +{ \ +} + + +/* + * NDIS_SET_PACKET_STATUS( + * IN PNDIS_PACKET Packet, + * IN NDIS_STATUS Status); + */ +#define NDIS_SET_PACKET_STATUS(Packet, \ + Status) \ +{ \ +} + + +/* + * NDIS_SET_PACKET_TIME_RECEIVED( + * IN PNDIS_PACKET Packet, + * IN ULONGLONG TimeReceived); + */ +#define NDIS_SET_PACKET_TIME_RECEIVED(Packet) \ + TimeReceived) \ +{ \ +} + + +/* + * NDIS_SET_PACKET_TIME_SENT( + * IN PNDIS_PACKET Packet, + * IN ULONGLONG TimeSent); + */ +#define NDIS_SET_PACKET_TIME_SENT(Packet, \ + TimeSent) \ +{ \ +} + + +/* + * + * NDIS_SET_PACKET_TIME_TO_SEND( + * IN PNDIS_PACKET Packet, + * IN ULONGLONG TimeToSend); + */ +#define NDIS_SET_PACKET_TIME_TO_SEND(Packet, \ + TimeToSend) \ +{ \ +} + + +/* + * VOID NdisSetSendFlags( + * IN PNDIS_PACKET Packet, + * IN UINT Flags); + */ +#define NdisSetSendFlags(Packet, Flags)( \ + NdisSetPacketFlags((Packet), (Flags))) + + + +/* Memory management routines */ + +VOID +EXPIMP +NdisCreateLookaheadBufferFromSharedMemory( + IN PVOID pSharedMemory, + IN UINT LookaheadLength, + OUT PVOID *pLookaheadBuffer); + +VOID +EXPIMP +NdisDestroyLookaheadBufferFromSharedMemory( + IN PVOID pLookaheadBuffer); + +VOID +EXPIMP +NdisMoveFromMappedMemory( + OUT PVOID Destination, + IN PVOID Source, + IN ULONG Length); + +VOID +EXPIMP +NdisMoveMappedMemory( + OUT PVOID Destination, + IN PVOID Source, + IN ULONG Length); + +VOID +EXPIMP +NdisMoveToMappedMemory( + OUT PVOID Destination, + IN PVOID Source, + IN ULONG Length); + +VOID +EXPIMP +NdisMUpdateSharedMemory( + IN NDIS_HANDLE MiniportAdapterHandle, + IN ULONG Length, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +NDIS_STATUS +EXPIMP +NdisAllocateMemory( + OUT PVOID *VirtualAddress, + IN UINT Length, + IN UINT MemoryFlags, + IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress); + +VOID +EXPIMP +NdisFreeMemory( + IN PVOID VirtualAddress, + IN UINT Length, + IN UINT MemoryFlags); + +VOID +EXPIMP +NdisImmediateReadSharedMemory( + IN NDIS_HANDLE WrapperConfigurationContext, + IN ULONG SharedMemoryAddress, + OUT PUCHAR Buffer, + IN ULONG Length); + +VOID +EXPIMP +NdisImmediateWriteSharedMemory( + IN NDIS_HANDLE WrapperConfigurationContext, + IN ULONG SharedMemoryAddress, + IN PUCHAR Buffer, + IN ULONG Length); + +VOID +EXPIMP +NdisMAllocateSharedMemory( + IN NDIS_HANDLE MiniportAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + OUT PVOID *VirtualAddress, + OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress); + +NDIS_STATUS +EXPIMP +NdisMAllocateSharedMemoryAsync( + IN NDIS_HANDLE MiniportAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + IN PVOID Context); + +VOID +EXPIMP +NdisMFreeSharedMemory( + IN NDIS_HANDLE MiniportAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +VOID +EXPIMP +NdisUpdateSharedMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Length, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + + +/* + * ULONG NdisGetPhysicalAddressHigh( + * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + */ +#define NdisGetPhysicalAddressHigh(PhysicalAddress) \ + ((PhysicalAddress).HighPart) + +/* + * VOID NdisSetPhysicalAddressHigh( + * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, + * IN ULONG Value); + */ +#define NdisSetPhysicalAddressHigh(PhysicalAddress, Value) \ + ((PhysicalAddress).HighPart) = (Value) + +/* + * ULONG NdisGetPhysicalAddressLow( + * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + */ +#define NdisGetPhysicalAddressLow(PhysicalAddress) \ + ((PhysicalAddress).LowPart) + + +/* + * VOID NdisSetPhysicalAddressLow( + * IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, + * IN ULONG Value); + */ +#define NdisSetPhysicalAddressLow(PhysicalAddress, Value) \ + ((PhysicalAddress).LowPart) = (Value) + +/* + * VOID NDIS_PHYSICAL_ADDRESS_CONST( + * IN ULONG Low, + * IN LONG High); + */ +#define NDIS_PHYSICAL_ADDRESS_CONST(Low, High) \ + { {(ULONG)(Low), (LONG)(High)} } + + +/* + * VOID NdisMoveMemory( + * OUT PVOID Destination, + * IN PVOID Source, + * IN ULONG Length); + */ +#define NdisMoveMemory(Destination, Source, Length) \ + RtlCopyMemory(Destination, Source, Length) + + +/* + * VOID NdisRetrieveUlong( + * IN PULONG DestinationAddress, + * IN PULONG SourceAddress); + */ +#define NdisRetrieveUlong(DestinationAddress, SourceAddress) \ + RtlRetrieveUlong(DestinationAddress, SourceAddress) + + +/* + * VOID NdisStoreUlong( + * IN PULONG DestinationAddress, + * IN ULONG Value); + */ +#define NdisStoreUlong(DestinationAddress, Value) \ + RtlStoreUlong(DestinationAddress, Value) + + +/* + * VOID NdisZeroMemory( + * IN PVOID Destination, + * IN ULONG Length) + */ +#define NdisZeroMemory(Destination, Length) \ + RtlZeroMemory(Destination, Length) + + + +/* String management routines */ + +#if BINARY_COMPATIBLE + +NDIS_STATUS +EXPIMP +NdisAnsiStringToUnicodeString( + IN OUT PNDIS_STRING DestinationString, + IN PNDIS_ANSI_STRING SourceString); + +BOOLEAN +EXPIMP +NdisEqualString( + IN PNDIS_STRING String1, + IN PNDIS_STRING String2, + IN BOOLEAN CaseInsensitive); + +VOID +EXPIMP +NdisInitAnsiString( + IN OUT PNDIS_ANSI_STRING DestinationString, + IN PCSTR SourceString); + +VOID +EXPIMP +NdisInitUnicodeString( + IN OUT PNDIS_STRING DestinationString, + IN PCWSTR SourceString); + +NDIS_STATUS +EXPIMP +NdisUnicodeStringToAnsiString( + IN OUT PNDIS_ANSI_STRING DestinationString, + IN PNDIS_STRING SourceString); + +#else /* BINARY_COMPATIBLE */ + +/* + * NDIS_STATUS NdisAnsiStringToUnicodeString( + * IN OUT PNDIS_STRING DestinationString, + * IN PNDIS_ANSI_STRING SourceString); + */ +#define NdisAnsiStringToUnicodeString(DestinationString, \ + SourceString) \ + RtlAnsiStringToUnicodeString((DestinationString), (SourceString), FALSE) + +/* + * BOOLEAN NdisEqualString( + * IN PNDIS_STRING String1, + * IN PNDIS_STRING String2, + * IN BOOLEAN CaseInsensitive) + */ +#define NdisEqualString(String1, \ + String2, \ + CaseInsensitive) \ + RtlEqualUnicodeString((String1), (String2), (CaseInsensitive)) + +/* + * VOID NdisInitAnsiString( + * IN OUT PNDIS_ANSI_STRING DestinationString, + * IN PCSTR SourceString) + */ +#define NdisInitAnsiString(DestinationString, \ + SourceString) \ + RtlInitString((DestinationString), (SourceString)) + +/* + * VOID NdisInitUnicodeString( + * IN OUT PNDIS_STRING DestinationString, + * IN PCWSTR SourceString) + */ +#define NdisInitUnicodeString(DestinationString, \ + SourceString) \ + RtlInitUnicodeString((DestinationString), (SourceString)) + +/* + * NDIS_STATUS NdisUnicodeStringToAnsiString( + * IN OUT PNDIS_ANSI_STRING DestinationString, + * IN PNDIS_STRING SourceString) + */ +#define NdisUnicodeStringToAnsiString(DestinationString, \ + SourceString) \ + RtlUnicodeStringToAnsiString((DestinationString), (SourceString), FALSE) + +#endif /* BINARY_COMPATIBLE */ + +#define NdisFreeString(_s) NdisFreeMemory((s).Buffer, (s).MaximumLength, 0) +#define NdisPrintString(_s) DbgPrint("%ls", (s).Buffer) + + + +/* I/O routines */ + +/* + * VOID NdisRawReadPortBufferUchar( + * IN ULONG Port, + * OUT PUCHAR Buffer, + * IN ULONG Length); + */ +#define NdisRawReadPortBufferUchar(Port, Buffer, Length) \ + READ_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length)) + +/* + * VOID NdisRawReadPortBufferUlong( + * IN ULONG Port, + * OUT PULONG Buffer, + * IN ULONG Length); + */ +#define NdisRawReadPortBufferUlong(Port, Buffer, Length) \ + READ_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length)) + +/* + * VOID NdisRawReadPortBufferUshort( + * IN ULONG Port, + * OUT PUSHORT Buffer, + * IN ULONG Length); + */ +#define NdisRawReadPortBufferUshort(Port, Buffer, Length) \ + READ_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length)) + + +/* + * VOID NdisRawReadPortUchar( + * IN ULONG Port, + * OUT PUCHAR Data); + */ +#define NdisRawReadPortUchar(Port, Data) \ + *(Data) = READ_PORT_UCHAR((PUCHAR)(Port)) + +/* + * VOID NdisRawReadPortUlong( + * IN ULONG Port, + * OUT PULONG Data); + */ +#define NdisRawReadPortUlong(Port, Data) \ + *(Data) = READ_PORT_ULONG((PULONG)(Port)) + +/* + * VOID NdisRawReadPortUshort( + * IN ULONG Port, + * OUT PUSHORT Data); + */ +#define NdisRawReadPortUshort(Port, Data) \ + *(Data) = READ_PORT_USHORT((PUSHORT)(Port)) + + +/* + * VOID NdisRawWritePortBufferUchar( + * IN ULONG Port, + * IN PUCHAR Buffer, + * IN ULONG Length); + */ +#define NdisRawWritePortBufferUchar(Port, Buffer, Length) \ + WRITE_PORT_BUFFER_UCHAR((PUCHAR)(Port), (PUCHAR)(Buffer), (Length)) + +/* + * VOID NdisRawWritePortBufferUlong( + * IN ULONG Port, + * IN PULONG Buffer, + * IN ULONG Length); + */ +#define NdisRawWritePortBufferUlong(Port, Buffer, Length) \ + WRITE_PORT_BUFFER_ULONG((PULONG)(Port), (PULONG)(Buffer), (Length)) + +/* + * VOID NdisRawWritePortBufferUshort( + * IN ULONG Port, + * IN PUSHORT Buffer, + * IN ULONG Length); + */ +#define NdisRawWritePortBufferUshort(Port, Buffer, Length) \ + WRITE_PORT_BUFFER_USHORT((PUSHORT)(Port), (PUSHORT)(Buffer), (Length)) + + +/* + * VOID NdisRawWritePortUchar( + * IN ULONG Port, + * IN UCHAR Data); + */ +#define NdisRawWritePortUchar(Port, Data) \ + WRITE_PORT_UCHAR((PUCHAR)(Port), (UCHAR)(Data)) + +/* + * VOID NdisRawWritePortUlong( + * IN ULONG Port, + * IN ULONG Data); + */ +#define NdisRawWritePortUlong(Port, Data) \ + WRITE_PORT_ULONG((PULONG)(Port), (ULONG)(Data)) + +/* + * VOID NdisRawWritePortUshort( + * IN ULONG Port, + * IN USHORT Data); + */ +#define NdisRawWritePortUshort(Port, Data) \ + WRITE_PORT_USHORT((PUSHORT)(Port), (USHORT)(Data)) + + +/* + * VOID NdisReadRegisterUchar( + * IN PUCHAR Register, + * OUT PUCHAR Data); + */ +#define NdisReadRegisterUchar(Register, Data) \ + *((PUCHAR)(Data)) = *(Register) + +/* + * VOID NdisReadRegisterUlong( + * IN PULONG Register, + * OUT PULONG Data); + */ +#define NdisReadRegisterUlong(Register, Data) \ + *((PULONG)(Data)) = *(Register) + +/* + * VOID NdisReadRegisterUshort( + * IN PUSHORT Register, + * OUT PUSHORT Data); + */ +#define NdisReadRegisterUshort(Register, Data) \ + *((PUSHORT)(Data)) = *(Register) + + +/* + * VOID NdisReadRegisterUchar( + * IN PUCHAR Register, + * IN UCHAR Data); + */ +#define NdisWriteRegisterUchar(Register, Data) \ + WRITE_REGISTER_UCHAR((Register), (Data)) + +/* + * VOID NdisReadRegisterUlong( + * IN PULONG Register, + * IN ULONG Data); + */ +#define NdisWriteRegisterUlong(Register, Data) \ + WRITE_REGISTER_ULONG((Register), (Data)) + +/* + * VOID NdisReadRegisterUshort( + * IN PUSHORT Register, + * IN USHORT Data); + */ +#define NdisWriteRegisterUshort(Register, Data) \ + WRITE_REGISTER_USHORT((Register), (Data)) + + + +VOID +EXPIMP +NdisCloseAdapter( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle); + +VOID +EXPIMP +NdisCloseConfiguration( + IN NDIS_HANDLE ConfigurationHandle); + +VOID +EXPIMP +NdisCompleteBindAdapter( + IN NDIS_HANDLE BindAdapterContext, + IN NDIS_STATUS Status, + IN NDIS_STATUS OpenStatus); + +VOID +EXPIMP +NdisCompleteUnbindAdapter( + IN NDIS_HANDLE UnbindAdapterContext, + IN NDIS_STATUS Status); + +VOID +EXPIMP +NdisDeregisterProtocol( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisProtocolHandle); + +VOID +EXPIMP +NdisInitializeListHead( + IN PLIST_ENTRY ListHead); + +VOID +EXPIMP +NdisInterlockedAddUlong( + IN PULONG Addend, + IN ULONG Increment, + IN PNDIS_SPIN_LOCK SpinLock); + +PLIST_ENTRY +EXPIMP +NdisInterlockedInsertHeadList( + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PNDIS_SPIN_LOCK SpinLock); + +PLIST_ENTRY +EXPIMP +NdisInterlockedInsertTailList( + IN PLIST_ENTRY ListHead, + IN PLIST_ENTRY ListEntry, + IN PNDIS_SPIN_LOCK SpinLock); + +PLIST_ENTRY +EXPIMP +NdisInterlockedRemoveHeadList( + IN PLIST_ENTRY ListHead, + IN PNDIS_SPIN_LOCK SpinLock); + +VOID +EXPIMP +NdisOpenAdapter( + OUT PNDIS_STATUS Status, + OUT PNDIS_STATUS OpenErrorStatus, + OUT PNDIS_HANDLE NdisBindingHandle, + OUT PUINT SelectedMediumIndex, + IN PNDIS_MEDIUM MediumArray, + IN UINT MediumArraySize, + IN NDIS_HANDLE NdisProtocolHandle, + IN NDIS_HANDLE ProtocolBindingContext, + IN PNDIS_STRING AdapterName, + IN UINT OpenOptions, + IN PSTRING AddressingInformation); + +VOID +EXPIMP +NdisOpenProtocolConfiguration( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE ConfigurationHandle, + IN PNDIS_STRING ProtocolSection); + +NDIS_STATUS +EXPIMP +NdisQueryReceiveInformation( + IN NDIS_HANDLE NdisBindingHandle, + IN NDIS_HANDLE MacContext, + OUT PLONGLONG TimeSent OPTIONAL, + OUT PLONGLONG TimeReceived OPTIONAL, + IN PUCHAR Buffer, + IN UINT BufferSize, + OUT PUINT SizeNeeded); + +VOID +EXPIMP +NdisReadConfiguration( + OUT PNDIS_STATUS Status, + OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, + IN NDIS_HANDLE ConfigurationHandle, + IN PNDIS_STRING Keyword, + IN NDIS_PARAMETER_TYPE ParameterType); + +VOID +EXPIMP +NdisRegisterProtocol( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE NdisProtocolHandle, + IN PNDIS_PROTOCOL_CHARACTERISTICS ProtocolCharacteristics, + IN UINT CharacteristicsLength); + +VOID +EXPIMP +NdisRequest( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle, + IN PNDIS_REQUEST NdisRequest); + +VOID +EXPIMP +NdisReset( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle); + +VOID +EXPIMP +NdisReturnPackets( + IN PNDIS_PACKET *PacketsToReturn, + IN UINT NumberOfPackets); + +VOID +EXPIMP +NdisSend( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle, + IN PNDIS_PACKET Packet); + +VOID +EXPIMP +NdisSendPackets( + IN NDIS_HANDLE NdisBindingHandle, + IN PPNDIS_PACKET PacketArray, + IN UINT NumberOfPackets); + +VOID +EXPIMP +NdisTransferData( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle, + IN NDIS_HANDLE MacReceiveContext, + IN UINT ByteOffset, + IN UINT BytesToTransfer, + IN OUT PNDIS_PACKET Packet, + OUT PUINT BytesTransferred); + +VOID +EXPIMP +NdisWriteConfiguration( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE WrapperConfigurationContext, + IN PNDIS_STRING Keyword, + IN PNDIS_CONFIGURATION_PARAMETER *ParameterValue); + +/* +VOID +EXPIMP +NdisWriteErrorLogEntry( + IN NDIS_HANDLE NdisAdapterHandle, + IN NDIS_ERROR_CODE ErrorCode, + IN ULONG NumberOfErrorValues, + IN ULONG ...); +*/ + + + +/* + * VOID NdisStallExecution( + * IN UINT MicrosecondsToStall) + */ +#define NdisStallExecution(MicroSecondsToStall) \ + KeStallExecutionProcessor(MicroSecondsToStall) + + + +/* NDIS helper macros */ + +/* + * NDIS_INIT_FUNCTION(FunctionName) + */ +#define NDIS_INIT_FUNCTION(FunctionName) \ + alloc_text(init, FunctionName) + +/* + * NDIS_PAGABLE_FUNCTION(FunctionName) + */ +#define NDIS_PAGABLE_FUNCTION(FunctionName) \ + alloc_text(page, FunctionName) + + + +/* NDIS 4.0 extensions */ + +#ifdef NDIS40 + +VOID +EXPIMP +NdisMFreeSharedMemory( + IN NDIS_HANDLE MiniportAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +VOID +EXPIMP +NdisMWanIndicateReceive( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE NdisLinkContext, + IN PUCHAR PacketBuffer, + IN UINT PacketSize); + +VOID +EXPIMP +NdisMWanIndicateReceiveComplete( + IN NDIS_HANDLE MiniportAdapterHandle); + +VOID +EXPIMP +NdisMWanSendComplete( + IN NDIS_HANDLE MiniportAdapterHandle, + IN PNDIS_WAN_PACKET Packet, + IN NDIS_STATUS Status); + +NDIS_STATUS +EXPIMP +NdisPciAssignResources( + IN NDIS_HANDLE NdisMacHandle, + IN NDIS_HANDLE NdisWrapperHandle, + IN NDIS_HANDLE WrapperConfigurationContext, + IN ULONG SlotNumber, + OUT PNDIS_RESOURCE_LIST *AssignedResources); + +VOID +EXPIMP +NdisReadEisaSlotInformationEx( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE WrapperConfigurationContext, + OUT PUINT SlotNumber, + OUT PNDIS_EISA_FUNCTION_INFORMATION *EisaData, + OUT PUINT NumberOfFunctions); + +VOID +EXPIMP +NdisReadMcaPosInformation( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE WrapperConfigurationContext, + IN PUINT ChannelNumber, + OUT PNDIS_MCA_POS_DATA McaData); + +#endif /* NDIS40 */ + + + +/* NDIS 5.0 extensions */ + +#ifdef NDIS50 + +VOID +EXPIMP +NdisAcquireReadWriteLock( + IN PNDIS_RW_LOCK Lock, + IN BOOLEAN fWrite, + IN PLOCK_STATE LockState); + +NDIS_STATUS +EXPIMP +NdisAllocateMemoryWithTag( + OUT PVOID *VirtualAddress, + IN UINT Length, + IN ULONG Tag); + +VOID +EXPIMP +NdisAllocatePacketPoolEx( + OUT PNDIS_STATUS Status, + OUT PNDIS_HANDLE PoolHandle, + IN UINT NumberOfDescriptors, + IN UINT NumberOfOverflowDescriptors, + IN UINT ProtocolReservedLength); + +ULONG +EXPIMP +NdisBufferLength( + IN PNDIS_BUFFER Buffer); + +PVOID +EXPIMP +NdisBufferVirtualAddress( + IN PNDIS_BUFFER Buffer); + +VOID +EXPIMP +NdisCompletePnPEvent( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisBindingHandle, + IN PNET_PNP_EVENT NetPnPEvent); + +VOID +EXPIMP +NdisConvertStringToAtmAddress( + OUT PNDIS_STATUS Status, + IN PNDIS_STRING String, + OUT PATM_ADDRESS AtmAddress); + +VOID +EXPIMP +NdisGetCurrentProcessorCounts( + OUT PULONG pIdleCount, + OUT PULONG pKernelAndUser, + OUT PULONG pIndex); + +VOID +EXPIMP +NdisGetDriverHandle( + IN PNDIS_HANDLE NdisBindingHandle, + OUT PNDIS_HANDLE NdisDriverHandle); + +PNDIS_PACKET +EXPIMP +NdisGetReceivedPacket( + IN PNDIS_HANDLE NdisBindingHandle, + IN PNDIS_HANDLE MacContext); + +VOID +EXPIMP +NdisGetSystemUptime( + OUT PULONG pSystemUpTime); + +VOID +EXPIMP +NdisInitializeReadWriteLock( + IN PNDIS_RW_LOCK Lock); + +LONG +EXPIMP +NdisInterlockedDecrement( + IN PLONG Addend); + +LONG +EXPIMP +NdisInterlockedIncrement( + IN PLONG Addend); + +PSINGLE_LIST_ENTRY +EXPIMP +NdisInterlockedPopEntrySList( + IN PSLIST_HEADER ListHead, + IN PKSPIN_LOCK Lock); + +PSINGLE_LIST_ENTRY +EXPIMP +NdisInterlockedPushEntrySList( + IN PSLIST_HEADER ListHead, + IN PSINGLE_LIST_ENTRY ListEntry, + IN PKSPIN_LOCK Lock); + + +NDIS_STATUS +EXPIMP +NdisMDeregisterDevice( + IN NDIS_HANDLE NdisDeviceHandle); + +VOID +EXPIMP +NdisMGetDeviceProperty( + IN NDIS_HANDLE MiniportAdapterHandle, + IN OUT PDEVICE_OBJECT *PhysicalDeviceObject OPTIONAL, + IN OUT PDEVICE_OBJECT *FunctionalDeviceObject OPTIONAL, + IN OUT PDEVICE_OBJECT *NextDeviceObject OPTIONAL, + IN OUT PCM_RESOURCE_LIST *AllocatedResources OPTIONAL, + IN OUT PCM_RESOURCE_LIST *AllocatedResourcesTranslated OPTIONAL); + +NDIS_STATUS +EXPIMP +NdisMInitializeScatterGatherDma( + IN NDIS_HANDLE MiniportAdapterHandle, + IN BOOLEAN Dma64BitAddresses, + IN ULONG MaximumPhysicalMapping); + +NDIS_STATUS +EXPIMP +NdisMPromoteMiniport( + IN NDIS_HANDLE MiniportAdapterHandle); + +NDIS_STATUS +EXPIMP +NdisMQueryAdapterInstanceName( + OUT PNDIS_STRING AdapterInstanceName, + IN NDIS_HANDLE MiniportAdapterHandle); + +NDIS_STATUS +EXPIMP +NdisMRegisterDevice( + IN NDIS_HANDLE NdisWrapperHandle, + IN PNDIS_STRING DeviceName, + IN PNDIS_STRING SymbolicName, + IN PDRIVER_DISPATCH MajorFunctions[], + OUT PDEVICE_OBJECT *pDeviceObject, + OUT NDIS_HANDLE *NdisDeviceHandle); + +VOID +EXPIMP +NdisMRegisterUnloadHandler( + IN NDIS_HANDLE NdisWrapperHandle, + IN PDRIVER_UNLOAD UnloadHandler); + +NDIS_STATUS +EXPIMP +NdisMRemoveMiniport( + IN NDIS_HANDLE MiniportAdapterHandle); + +NDIS_STATUS +EXPIMP +NdisMSetMiniportSecondary( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE PrimaryMiniportAdapterHandle); + +VOID +EXPIMP +NdisOpenConfigurationKeyByIndex( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE ConfigurationHandle, + IN ULONG Index, + OUT PNDIS_STRING KeyName, + OUT PNDIS_HANDLE KeyHandle); + +VOID +EXPIMP +NdisOpenConfigurationKeyByName( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE ConfigurationHandle, + IN PNDIS_STRING SubKeyName, + OUT PNDIS_HANDLE SubKeyHandle); + +UINT +EXPIMP +NdisPacketPoolUsage( + IN NDIS_HANDLE PoolHandle); + +NDIS_STATUS +EXPIMP +NdisQueryAdapterInstanceName( + OUT PNDIS_STRING AdapterInstanceName, + IN NDIS_HANDLE NdisBindingHandle); + +VOID +EXPIMP +NdisQueryBufferSafe( + IN PNDIS_BUFFER Buffer, + OUT PVOID *VirtualAddress OPTIONAL, + OUT PUINT Length, + IN UINT Priority); + +ULONG +EXPIMP +NdisReadPcmciaAttributeMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Offset, + IN PVOID Buffer, + IN ULONG Length); + +VOID +EXPIMP +NdisReleaseReadWriteLock( + IN PNDIS_RW_LOCK Lock, + IN PLOCK_STATE LockState); + + +NDIS_STATUS +EXPIMP +NdisWriteEventLogEntry( + IN PVOID LogHandle, + IN NDIS_STATUS EventCode, + IN ULONG UniqueEventValue, + IN USHORT NumStrings, + IN PVOID StringsList OPTIONAL, + IN ULONG DataSize, + IN PVOID Data OPTIONAL); + +ULONG +EXPIMP +NdisWritePcmciaAttributeMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Offset, + IN PVOID Buffer, + IN ULONG Length); + + +/* Connectionless services */ + +NDIS_STATUS +EXPIMP +NdisClAddParty( + IN NDIS_HANDLE NdisVcHandle, + IN NDIS_HANDLE ProtocolPartyContext, + IN OUT PCO_CALL_PARAMETERS CallParameters, + OUT PNDIS_HANDLE NdisPartyHandle); + +NDIS_STATUS +EXPIMP +NdisClCloseAddressFamily( + IN NDIS_HANDLE NdisAfHandle); + +NDIS_STATUS +EXPIMP +NdisClCloseCall( + IN NDIS_HANDLE NdisVcHandle, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN PVOID Buffer OPTIONAL, + IN UINT Size); + +NDIS_STATUS +EXPIMP +NdisClDeregisterSap( + IN NDIS_HANDLE NdisSapHandle); + +NDIS_STATUS +EXPIMP +NdisClDropParty( + IN NDIS_HANDLE NdisPartyHandle, + IN PVOID Buffer OPTIONAL, + IN UINT Size); + +VOID +EXPIMP +NdisClIncomingCallComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +NDIS_STATUS +EXPIMP +NdisClMakeCall( + IN NDIS_HANDLE NdisVcHandle, + IN OUT PCO_CALL_PARAMETERS CallParameters, + IN NDIS_HANDLE ProtocolPartyContext OPTIONAL, + OUT PNDIS_HANDLE NdisPartyHandle OPTIONAL); + +NDIS_STATUS +EXPIMP +NdisClModifyCallQoS( + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + + +NDIS_STATUS +EXPIMP +NdisClOpenAddressFamily( + IN NDIS_HANDLE NdisBindingHandle, + IN PCO_ADDRESS_FAMILY AddressFamily, + IN NDIS_HANDLE ProtocolAfContext, + IN PNDIS_CLIENT_CHARACTERISTICS ClCharacteristics, + IN UINT SizeOfClCharacteristics, + OUT PNDIS_HANDLE NdisAfHandle); + +NDIS_STATUS +EXPIMP +NdisClRegisterSap( + IN NDIS_HANDLE NdisAfHandle, + IN NDIS_HANDLE ProtocolSapContext, + IN PCO_SAP Sap, + OUT PNDIS_HANDLE NdisSapHandle); + + +/* Call Manager services */ + +NDIS_STATUS +EXPIMP +NdisCmActivateVc( + IN NDIS_HANDLE NdisVcHandle, + IN OUT PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmAddPartyComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisPartyHandle, + IN NDIS_HANDLE CallMgrPartyContext OPTIONAL, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmCloseAddressFamilyComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisAfHandle); + +VOID +EXPIMP +NdisCmCloseCallComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL); + +NDIS_STATUS +EXPIMP +NdisCmDeactivateVc( + IN NDIS_HANDLE NdisVcHandle); + +VOID +EXPIMP +NdisCmDeregisterSapComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisSapHandle); + +VOID +EXPIMP +NdisCmDispatchCallConnected( + IN NDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisCmDispatchIncomingCall( + IN NDIS_HANDLE NdisSapHandle, + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmDispatchIncomingCallQoSChange( + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmDispatchIncomingCloseCall( + IN NDIS_STATUS CloseStatus, + IN NDIS_HANDLE NdisVcHandle, + IN PVOID Buffer OPTIONAL, + IN UINT Size); + +VOID +EXPIMP +NdisCmDispatchIncomingDropParty( + IN NDIS_STATUS DropStatus, + IN NDIS_HANDLE NdisPartyHandle, + IN PVOID Buffer OPTIONAL, + IN UINT Size); + +VOID +EXPIMP +NdisCmDropPartyComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisPartyHandle); + +VOID +EXPIMP +NdisCmMakeCallComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN NDIS_HANDLE CallMgrPartyContext OPTIONAL, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmModifyCallQoSComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisCmOpenAddressFamilyComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisAfHandle, + IN NDIS_HANDLE CallMgrAfContext); + +NDIS_STATUS +EXPIMP +NdisCmRegisterAddressFamily( + IN NDIS_HANDLE NdisBindingHandle, + IN PCO_ADDRESS_FAMILY AddressFamily, + IN PNDIS_CALL_MANAGER_CHARACTERISTICS CmCharacteristics, + IN UINT SizeOfCmCharacteristics); + +VOID +EXPIMP +NdisCmRegisterSapComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisSapHandle, + IN NDIS_HANDLE CallMgrSapContext); + + +NDIS_STATUS +EXPIMP +NdisMCmActivateVc( + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +NDIS_STATUS +EXPIMP +NdisMCmCreateVc( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE NdisAfHandle, + IN NDIS_HANDLE MiniportVcContext, + OUT PNDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisMCmDeactivateVc( + IN NDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisMCmDeleteVc( + IN NDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisMCmRegisterAddressFamily( + IN NDIS_HANDLE MiniportAdapterHandle, + IN PCO_ADDRESS_FAMILY AddressFamily, + IN PNDIS_CALL_MANAGER_CHARACTERISTICS CmCharacteristics, + IN UINT SizeOfCmCharacteristics); + +NDIS_STATUS +EXPIMP +NdisMCmRequest( + IN NDIS_HANDLE NdisAfHandle, + IN NDIS_HANDLE NdisVcHandle OPTIONAL, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN OUT PNDIS_REQUEST NdisRequest); + + +/* Connection-oriented services */ + +NDIS_STATUS +EXPIMP +NdisCoCreateVc( + IN NDIS_HANDLE NdisBindingHandle, + IN NDIS_HANDLE NdisAfHandle OPTIONAL, + IN NDIS_HANDLE ProtocolVcContext, + IN OUT PNDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisCoDeleteVc( + IN NDIS_HANDLE NdisVcHandle); + +NDIS_STATUS +EXPIMP +NdisCoRequest( + IN NDIS_HANDLE NdisBindingHandle, + IN NDIS_HANDLE NdisAfHandle OPTIONAL, + IN NDIS_HANDLE NdisVcHandle OPTIONAL, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN OUT PNDIS_REQUEST NdisRequest); + +VOID +EXPIMP +NdisCoRequestComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisAfHandle, + IN NDIS_HANDLE NdisVcHandle OPTIONAL, + IN NDIS_HANDLE NdisPartyHandle OPTIONAL, + IN PNDIS_REQUEST NdisRequest); + +VOID +EXPIMP +NdisCoSendPackets( + IN NDIS_HANDLE NdisVcHandle, + IN PPNDIS_PACKET PacketArray, + IN UINT NumberOfPackets); + + +VOID +EXPIMP +NdisMCoActivateVcComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN PCO_CALL_PARAMETERS CallParameters); + +VOID +EXPIMP +NdisMCoDeactivateVcComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle); + +VOID +EXPIMP +NdisMCoIndicateReceivePacket( + IN NDIS_HANDLE NdisVcHandle, + IN PPNDIS_PACKET PacketArray, + IN UINT NumberOfPackets); + +VOID +EXPIMP +NdisMCoIndicateStatus( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE NdisVcHandle OPTIONAL, + IN NDIS_STATUS GeneralStatus, + IN PVOID StatusBuffer OPTIONAL, + IN ULONG StatusBufferSize); + +VOID +EXPIMP +NdisMCoReceiveComplete( + IN NDIS_HANDLE MiniportAdapterHandle); + +VOID +EXPIMP +NdisMCoRequestComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE MiniportAdapterHandle, + IN PNDIS_REQUEST Request); + +VOID +EXPIMP +NdisMCoSendComplete( + IN NDIS_STATUS Status, + IN NDIS_HANDLE NdisVcHandle, + IN PNDIS_PACKET Packet); + + +/* NDIS 5.0 extensions for intermediate drivers */ + +VOID +EXPIMP +NdisIMAssociateMiniport( + IN NDIS_HANDLE DriverHandle, + IN NDIS_HANDLE ProtocolHandle); + +NDIS_STATUS +EXPIMP +NdisIMCancelInitializeDeviceInstance( + IN NDIS_HANDLE DriverHandle, + IN PNDIS_STRING DeviceInstance); + +VOID +EXPIMP +NdisIMCopySendCompletePerPacketInfo( + IN PNDIS_PACKET DstPacket, + IN PNDIS_PACKET SrcPacket); + +VOID +EXPIMP +NdisIMCopySendPerPacketInfo( + IN PNDIS_PACKET DstPacket, + IN PNDIS_PACKET SrcPacket); + +VOID +EXPIMP +NdisIMDeregisterLayeredMiniport( + IN NDIS_HANDLE DriverHandle); + +NDIS_HANDLE +EXPIMP +NdisIMGetBindingContext( + IN NDIS_HANDLE NdisBindingHandle); + +NDIS_HANDLE +EXPIMP +NdisIMGetDeviceContext( + IN NDIS_HANDLE MiniportAdapterHandle); + +NDIS_STATUS +EXPIMP +NdisIMInitializeDeviceInstanceEx( + IN NDIS_HANDLE DriverHandle, + IN PNDIS_STRING DriverInstance, + IN NDIS_HANDLE DeviceContext OPTIONAL); + +#endif /* NDIS50 */ + + + +/* NDIS structures available only to miniport drivers */ + +#if defined(NDIS_WRAPPER) || defined(NDIS_MINIPORT_DRIVER) + +/* Obsolete technology specific defines */ + +#define DECLARE_UNKNOWN_STRUCT(BaseName) \ + typedef struct _##BaseName BaseName, *P##BaseName; + +#define DECLARE_UNKNOWN_PROTOTYPE(Name) \ + typedef VOID (*##Name)(VOID); + + +/* ARCnet */ + +DECLARE_UNKNOWN_STRUCT(ARC_FILTER) + + +VOID +EXPIMP +ArcFilterDprIndicateReceive( + IN PARC_FILTER Filter, + IN PUCHAR pRawHeader, + IN PUCHAR pData, + IN UINT Length); + +VOID +EXPIMP +ArcFilterDprIndicateReceiveComplete( + IN PARC_FILTER Filter); + + +/* Ethernet */ + +#define ETH_LENGTH_OF_ADDRESS 6 + +DECLARE_UNKNOWN_STRUCT(ETH_FILTER) + +DECLARE_UNKNOWN_PROTOTYPE(ETH_ADDRESS_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(ETH_FILTER_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(ETH_DEFERRED_CLOSE) + + +NDIS_STATUS +EXPIMP +EthChangeFilterAddresses( + IN PETH_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT AddressCount, + IN CHAR Addresses[] [ETH_LENGTH_OF_ADDRESS], + IN BOOLEAN Set); + +BOOLEAN +EXPIMP +EthCreateFilter( + IN UINT MaximumMulticastAddresses, + IN ETH_ADDRESS_CHANGE AddressChangeAction, + IN ETH_FILTER_CHANGE FilterChangeAction, + IN ETH_DEFERRED_CLOSE CloseAction, + IN PUCHAR AdapterAddress, + IN PNDIS_SPIN_LOCK Lock, + OUT PETH_FILTER *Filter); + +VOID +EXPIMP +EthDeleteFilter( + IN PETH_FILTER Filter); + +NDIS_STATUS +EXPIMP +EthDeleteFilterOpenAdapter( + IN PETH_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest); + +NDIS_STATUS +EXPIMP +EthFilterAdjust( + IN PETH_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT FilterClasses, + IN BOOLEAN Set); + +VOID +EXPIMP +EthFilterIndicateReceive( + IN PETH_FILTER Filter, + IN NDIS_HANDLE MacReceiveContext, + IN PCHAR Address, + IN PVOID HeaderBuffer, + IN UINT HeaderBufferSize, + IN PVOID LookaheadBuffer, + IN UINT LookaheadBufferSize, + IN UINT PacketSize); + +VOID +EXPIMP +EthFilterIndicateReceiveComplete( + IN PETH_FILTER Filter); + +BOOLEAN +EXPIMP +EthNoteFilterOpenAdapter( + IN PETH_FILTER Filter, + IN NDIS_HANDLE MacBindingHandle, + IN NDIS_HANDLE NdisBindingContext, + OUT PNDIS_HANDLE NdisFilterHandle); + +UINT +EXPIMP +EthNumberOfOpenFilterAddresses( + IN PETH_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle); + +VOID +EXPIMP +EthQueryGlobalFilterAddresses ( + OUT PNDIS_STATUS Status, + IN PETH_FILTER Filter, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [ETH_LENGTH_OF_ADDRESS]); + +VOID +EXPIMP +EthQueryOpenFilterAddresses( + OUT PNDIS_STATUS Status, + IN PETH_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [ETH_LENGTH_OF_ADDRESS]); + +BOOLEAN +EXPIMP +EthShouldAddressLoopBack( + IN PETH_FILTER Filter, + IN CHAR Address[ETH_LENGTH_OF_ADDRESS]); + + +/* FDDI */ + +#define FDDI_LENGTH_OF_LONG_ADDRESS 6 +#define FDDI_LENGTH_OF_SHORT_ADDRESS 2 + +DECLARE_UNKNOWN_STRUCT(FDDI_FILTER) + +DECLARE_UNKNOWN_PROTOTYPE(FDDI_ADDRESS_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(FDDI_FILTER_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(FDDI_DEFERRED_CLOSE) + + +NDIS_STATUS +EXPIMP +FddiChangeFilterLongAddresses( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT AddressCount, + IN CHAR Addresses[] [FDDI_LENGTH_OF_LONG_ADDRESS], + IN BOOLEAN Set); + +NDIS_STATUS +EXPIMP +FddiChangeFilterShortAddresses( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT AddressCount, + IN CHAR Addresses[] [FDDI_LENGTH_OF_SHORT_ADDRESS], + IN BOOLEAN Set); + +BOOLEAN +EXPIMP +FddiCreateFilter( + IN UINT MaximumMulticastLongAddresses, + IN UINT MaximumMulticastShortAddresses, + IN FDDI_ADDRESS_CHANGE AddressChangeAction, + IN FDDI_FILTER_CHANGE FilterChangeAction, + IN FDDI_DEFERRED_CLOSE CloseAction, + IN PUCHAR AdapterLongAddress, + IN PUCHAR AdapterShortAddress, + IN PNDIS_SPIN_LOCK Lock, + OUT PFDDI_FILTER *Filter); + +VOID +EXPIMP +FddiDeleteFilter( + IN PFDDI_FILTER Filter); + +NDIS_STATUS +EXPIMP +FddiDeleteFilterOpenAdapter( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest); + +NDIS_STATUS +EXPIMP +FddiFilterAdjust( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT FilterClasses, + IN BOOLEAN Set); + +VOID +EXPIMP +FddiFilterIndicateReceive( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE MacReceiveContext, + IN PCHAR Address, + IN UINT AddressLength, + IN PVOID HeaderBuffer, + IN UINT HeaderBufferSize, + IN PVOID LookaheadBuffer, + IN UINT LookaheadBufferSize, + IN UINT PacketSize); + +VOID +EXPIMP +FddiFilterIndicateReceiveComplete( + IN PFDDI_FILTER Filter); + +BOOLEAN +EXPIMP +FddiNoteFilterOpenAdapter( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE MacBindingHandle, + IN NDIS_HANDLE NdisBindingContext, + OUT PNDIS_HANDLE NdisFilterHandle); + +UINT +EXPIMP +FddiNumberOfOpenFilterLongAddresses( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle); + +UINT +EXPIMP +FddiNumberOfOpenFilterShortAddresses( + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle); + +VOID +EXPIMP +FddiQueryGlobalFilterLongAddresses( + OUT PNDIS_STATUS Status, + IN PFDDI_FILTER Filter, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [FDDI_LENGTH_OF_LONG_ADDRESS]); + +VOID +EXPIMP +FddiQueryGlobalFilterShortAddresses( + OUT PNDIS_STATUS Status, + IN PFDDI_FILTER Filter, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [FDDI_LENGTH_OF_SHORT_ADDRESS]); + +VOID +EXPIMP +FddiQueryOpenFilterLongAddresses( + OUT PNDIS_STATUS Status, + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [FDDI_LENGTH_OF_LONG_ADDRESS]); + +VOID +EXPIMP +FddiQueryOpenFilterShortAddresses( + OUT PNDIS_STATUS Status, + IN PFDDI_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN UINT SizeOfArray, + OUT PUINT NumberOfAddresses, + IN OUT CHAR AddressArray[] [FDDI_LENGTH_OF_SHORT_ADDRESS]); + +BOOLEAN +EXPIMP +FddiShouldAddressLoopBack( + IN PFDDI_FILTER Filter, + IN CHAR Address[], + IN UINT LengthOfAddress); + + +/* Token Ring */ + +#define TR_LENGTH_OF_FUNCTIONAL 4 +#define TR_LENGTH_OF_ADDRESS 6 + +DECLARE_UNKNOWN_STRUCT(TR_FILTER) + +DECLARE_UNKNOWN_PROTOTYPE(TR_ADDRESS_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(TR_GROUP_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(TR_FILTER_CHANGE) +DECLARE_UNKNOWN_PROTOTYPE(TR_DEFERRED_CLOSE) + + +NDIS_STATUS +EXPIMP +TrChangeFunctionalAddress( + IN PTR_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN CHAR FunctionalAddressArray[TR_LENGTH_OF_FUNCTIONAL], + IN BOOLEAN Set); + +NDIS_STATUS +EXPIMP +TrChangeGroupAddress( + IN PTR_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN CHAR GroupAddressArray[TR_LENGTH_OF_FUNCTIONAL], + IN BOOLEAN Set); + +BOOLEAN +EXPIMP +TrCreateFilter( + IN TR_ADDRESS_CHANGE AddressChangeAction, + IN TR_GROUP_CHANGE GroupChangeAction, + IN TR_FILTER_CHANGE FilterChangeAction, + IN TR_DEFERRED_CLOSE CloseAction, + IN PUCHAR AdapterAddress, + IN PNDIS_SPIN_LOCK Lock, + OUT PTR_FILTER *Filter); + +VOID +EXPIMP +TrDeleteFilter( + IN PTR_FILTER Filter); + +NDIS_STATUS +EXPIMP +TrDeleteFilterOpenAdapter ( + IN PTR_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest); + +NDIS_STATUS +EXPIMP +TrFilterAdjust( + IN PTR_FILTER Filter, + IN NDIS_HANDLE NdisFilterHandle, + IN PNDIS_REQUEST NdisRequest, + IN UINT FilterClasses, + IN BOOLEAN Set); + +VOID +EXPIMP +TrFilterIndicateReceive( + IN PTR_FILTER Filter, + IN NDIS_HANDLE MacReceiveContext, + IN PVOID HeaderBuffer, + IN UINT HeaderBufferSize, + IN PVOID LookaheadBuffer, + IN UINT LookaheadBufferSize, + IN UINT PacketSize); + +VOID +EXPIMP +TrFilterIndicateReceiveComplete( + IN PTR_FILTER Filter); + +BOOLEAN +EXPIMP +TrNoteFilterOpenAdapter( + IN PTR_FILTER Filter, + IN NDIS_HANDLE MacBindingHandle, + IN NDIS_HANDLE NdisBindingContext, + OUT PNDIS_HANDLE NdisFilterHandle); + +BOOLEAN +EXPIMP +TrShouldAddressLoopBack( + IN PTR_FILTER Filter, + IN CHAR DestinationAddress[TR_LENGTH_OF_ADDRESS], + IN CHAR SourceAddress[TR_LENGTH_OF_ADDRESS]); + + + +/* Prototypes for NDIS_MINIPORT_CHARACTERISTICS */ + +typedef BOOLEAN (*W_CHECK_FOR_HANG_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext); + +typedef VOID (*W_DISABLE_INTERRUPT_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext); + +typedef VOID (*W_ENABLE_INTERRUPT_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext); + +typedef VOID (*W_HALT_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext); + +typedef VOID (*W_HANDLE_INTERRUPT_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext); + +typedef NDIS_STATUS (*W_INITIALIZE_HANDLER)( + OUT PNDIS_STATUS OpenErrorStatus, + OUT PUINT SelectedMediumIndex, + IN PNDIS_MEDIUM MediumArray, + IN UINT MediumArraySize, + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE WrapperConfigurationContext); + +typedef VOID (*W_ISR_HANDLER)( + OUT PBOOLEAN InterruptRecognized, + OUT PBOOLEAN QueueMiniportHandleInterrupt, + IN NDIS_HANDLE MiniportAdapterContext); + +typedef NDIS_STATUS (*W_QUERY_INFORMATION_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesWritten, + OUT PULONG BytesNeeded); + +typedef NDIS_STATUS (*W_RECONFIGURE_HANDLER)( + OUT PNDIS_STATUS OpenErrorStatus, + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE WrapperConfigurationContext); + +typedef NDIS_STATUS (*W_RESET_HANDLER)( + OUT PBOOLEAN AddressingReset, + IN NDIS_HANDLE MiniportAdapterContext); + +typedef NDIS_STATUS (*W_SEND_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN PNDIS_PACKET Packet, + IN UINT Flags); + +typedef NDIS_STATUS (*WM_SEND_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE NdisLinkHandle, + IN PNDIS_WAN_PACKET Packet); + +typedef NDIS_STATUS (*W_SET_INFORMATION_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_OID Oid, + IN PVOID InformationBuffer, + IN ULONG InformationBufferLength, + OUT PULONG BytesRead, + OUT PULONG BytesNeeded); + +typedef NDIS_STATUS (*W_TRANSFER_DATA_HANDLER)( + OUT PNDIS_PACKET Packet, + OUT PUINT BytesTransferred, + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE MiniportReceiveContext, + IN UINT ByteOffset, + IN UINT BytesToTransfer); + +typedef NDIS_STATUS (*WM_TRANSFER_DATA_HANDLER)( + VOID); + +typedef struct _NDIS30_MINIPORT_CHARACTERISTICS +{ + UCHAR MajorNdisVersion; + UCHAR MinorNdisVersion; + UINT Reserved; + W_CHECK_FOR_HANG_HANDLER CheckForHangHandler; + W_DISABLE_INTERRUPT_HANDLER DisableInterruptHandler; + W_ENABLE_INTERRUPT_HANDLER EnableInterruptHandler; + W_HALT_HANDLER HaltHandler; + W_HANDLE_INTERRUPT_HANDLER HandleInterruptHandler; + W_INITIALIZE_HANDLER InitializeHandler; + W_ISR_HANDLER ISRHandler; + W_QUERY_INFORMATION_HANDLER QueryInformationHandler; + W_RECONFIGURE_HANDLER ReconfigureHandler; + W_RESET_HANDLER ResetHandler; + union + { + W_SEND_HANDLER SendHandler; + WM_SEND_HANDLER WanSendHandler; + }; + W_SET_INFORMATION_HANDLER SetInformationHandler; + union + { + W_TRANSFER_DATA_HANDLER TransferDataHandler; + WM_TRANSFER_DATA_HANDLER WanTransferDataHandler; + }; +} NDIS30_MINIPORT_CHARACTERISTICS; + + +/* Extensions for NDIS 4.0 miniports */ +#ifdef NDIS40 + +typedef VOID (*W_RETURN_PACKET_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN PNDIS_PACKET Packet); + +typedef VOID (*W_SEND_PACKETS_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN PPNDIS_PACKET PacketArray, + IN UINT NumberOfPackets); + +typedef VOID (*W_ALLOCATE_COMPLETE_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN PVOID VirtualAddress, + IN PNDIS_PHYSICAL_ADDRESS PhysicalAddress, + IN ULONG Length, + IN PVOID Context); + +typedef struct _NDIS40_MINIPORT_CHARACTERISTICS +{ + NDIS30_MINIPORT_CHARACTERISTICS; + + W_RETURN_PACKET_HANDLER ReturnPacketHandler; + W_SEND_PACKETS_HANDLER SendPacketsHandler; + W_ALLOCATE_COMPLETE_HANDLER AllocateCompleteHandler; +} NDIS40_MINIPORT_CHARACTERISTICS; + +#endif /* NDIS40 */ + +/* Extensions for NDIS 5.0 miniports */ + +#ifdef NDIS50 + +typedef NDIS_STATUS (*W_CO_CREATE_VC_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE NdisVcHandle, + OUT PNDIS_HANDLE MiniportVcContext); + +typedef NDIS_STATUS (*W_CO_DELETE_VC_HANDLER)( + IN NDIS_HANDLE MiniportVcContext); + +typedef NDIS_STATUS (*W_CO_ACTIVATE_VC_HANDLER)( + IN NDIS_HANDLE MiniportVcContext, + IN OUT PCO_CALL_PARAMETERS CallParameters); + +typedef NDIS_STATUS (*W_CO_DEACTIVATE_VC_HANDLER)( + IN NDIS_HANDLE MiniportVcContext); + +typedef VOID (*W_CO_SEND_PACKETS_HANDLER)( + IN NDIS_HANDLE MiniportVcContext, + IN PPNDIS_PACKET PacketArray, + IN UINT NumberOfPackets); + +typedef NDIS_STATUS (*W_CO_REQUEST_HANDLER)( + IN NDIS_HANDLE MiniportAdapterContext, + IN NDIS_HANDLE MiniportVcContext OPTIONAL, + IN OUT PNDIS_REQUEST NdisRequest); + +typedef struct _NDIS50_MINIPORT_CHARACTERISTICS +{ + NDIS40_MINIPORT_CHARACTERISTICS; + + W_CO_CREATE_VC_HANDLER CoCreateVcHandler; + W_CO_DELETE_VC_HANDLER CoDeleteVcHandler; + W_CO_ACTIVATE_VC_HANDLER CoActivateVcHandler; + W_CO_DEACTIVATE_VC_HANDLER CoDeactivateVcHandler; + W_CO_SEND_PACKETS_HANDLER CoSendPacketsHandler; + W_CO_REQUEST_HANDLER CoRequestHandler; +} NDIS50_MINIPORT_CHARACTERISTICS; + +#endif /* NDIS50 */ + + +#ifndef NDIS50 +#ifndef NDIS40 +typedef struct _NDIS30_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS; +#else /* NDIS40 */ +typedef struct _NDIS40_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS; +#endif /* NDIS40 */ +#else /* NDIS50 */ +typedef struct _NDIS50_MINIPORT_CHARACTERISTICS NDIS_MINIPORT_CHARACTERISTICS; +#endif /* NDIS50 */ + +typedef NDIS_MINIPORT_CHARACTERISTICS *PNDIS_MINIPORT_CHARACTERISTICS; + + +typedef struct _NDIS_MINIPORT_BLOCK NDIS_MINIPORT_BLOCK, *PNDIS_MINIPORT_BLOCK; + + +typedef struct _NDIS_MINIPORT_INTERRUPT +{ + PKINTERRUPT InterruptObject; + KSPIN_LOCK DpcCountLock; + PVOID MiniportIdField; + W_ISR_HANDLER MiniportIsr; + W_HANDLE_INTERRUPT_HANDLER MiniportDpc; + KDPC InterruptDpc; + PNDIS_MINIPORT_BLOCK Miniport; + + UCHAR DpcCount; + BOOLEAN Filler1; + + KEVENT DpcsCompletedEvent; + + BOOLEAN SharedInterrupt; + BOOLEAN IsrRequested; +} NDIS_MINIPORT_INTERRUPT, *PNDIS_MINIPORT_INTERRUPT; + + +typedef struct _NDIS_MINIPORT_TIMER +{ + KTIMER Timer; + KDPC Dpc; + PNDIS_TIMER_FUNCTION MiniportTimerFunction; + PVOID MiniportTimerContext; + PNDIS_MINIPORT_BLOCK Miniport; + struct _NDIS_MINIPORT_TIMER *NextDeferredTimer; +} NDIS_MINIPORT_TIMER, *PNDIS_MINIPORT_TIMER; + + + +/* NDIS intermediate miniport structures */ + +typedef VOID (*W_MINIPORT_CALLBACK)( + IN NDIS_HANDLE MiniportAdapterContext, + IN PVOID CallbackContext); + + +/* Routines for NDIS miniport drivers */ + +VOID +EXPIMP +NdisMCloseLog( + IN NDIS_HANDLE LogHandle); + +NDIS_STATUS +EXPIMP +NdisMCreateLog( + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT Size, + OUT PNDIS_HANDLE LogHandle); + +VOID +EXPIMP +NdisMDeregisterAdapterShutdownHandler( + IN NDIS_HANDLE MiniportHandle); + +VOID +EXPIMP +NdisMFlushLog( + IN NDIS_HANDLE LogHandle); + +VOID +EXPIMP +NdisMIndicateStatus( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_STATUS GeneralStatus, + IN PVOID StatusBuffer, + IN UINT StatusBufferSize); + +VOID +EXPIMP +NdisMIndicateStatusComplete( + IN NDIS_HANDLE MiniportAdapterHandle); + +VOID +EXPIMP +NdisInitializeWrapper( + OUT PNDIS_HANDLE NdisWrapperHandle, + IN PVOID SystemSpecific1, + IN PVOID SystemSpecific2, + IN PVOID SystemSpecific3); + +/* + * VOID NdisMInitializeWrapper( + * OUT PNDIS_HANDLE NdisWrapperHandle, + * IN PVOID SystemSpecific1, + * IN PVOID SystemSpecific2, + * IN PVOID SystemSpecific3); + */ +#define NdisMInitializeWrapper(n, s1, s2, s3) \ + NdisInitializeWrapper((n),(s1),(s2),(s3)) + +VOID +EXPIMP +NdisMRegisterAdapterShutdownHandler( + IN NDIS_HANDLE MiniportHandle, + IN PVOID ShutdownContext, + IN ADAPTER_SHUTDOWN_HANDLER ShutdownHandler); + +NDIS_STATUS +EXPIMP +NdisMRegisterMiniport( + IN NDIS_HANDLE NdisWrapperHandle, + IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, + IN UINT CharacteristicsLength); + +VOID +EXPIMP +NdisMResetComplete( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_STATUS Status, + IN BOOLEAN AddressingReset); + +VOID +EXPIMP +NdisMSendComplete( + IN NDIS_HANDLE MiniportAdapterHandle, + IN PNDIS_PACKET Packet, + IN NDIS_STATUS Status); + +VOID +EXPIMP +NdisMSendResourcesAvailable( + IN NDIS_HANDLE MiniportAdapterHandle); + +VOID +EXPIMP +NdisMSetAttributes( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE MiniportAdapterContext, + IN BOOLEAN BusMaster, + IN NDIS_INTERFACE_TYPE AdapterType); + +VOID +EXPIMP +NdisMSetAttributesEx( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE MiniportAdapterContext, + IN UINT CheckForHangTimeInSeconds OPTIONAL, + IN ULONG AttributeFlags, + IN NDIS_INTERFACE_TYPE AdapterType); + +VOID +EXPIMP +NdisMSleep( + IN ULONG MicrosecondsToSleep); + +BOOLEAN +EXPIMP +NdisMSynchronizeWithInterrupt( + IN PNDIS_MINIPORT_INTERRUPT Interrupt, + IN PVOID SynchronizeFunction, + IN PVOID SynchronizeContext); + +NDIS_STATUS +EXPIMP +NdisMWriteLogData( + IN NDIS_HANDLE LogHandle, + IN PVOID LogBuffer, + IN UINT LogBufferSize); + +VOID +EXPIMP +NdisTerminateWrapper( + IN NDIS_HANDLE NdisWrapperHandle, + IN PVOID SystemSpecific); + + + +/* Routines for intermediate miniport drivers */ + +NDIS_STATUS +EXPIMP +NdisIMDeInitializeDeviceInstance( + IN NDIS_HANDLE NdisMiniportHandle); + +NDIS_STATUS +EXPIMP +NdisIMInitializeDeviceInstance( + IN NDIS_HANDLE DriverHandle, + IN PNDIS_STRING DeviceInstance); + +NDIS_STATUS +EXPIMP +NdisIMQueueMiniportCallback( + IN NDIS_HANDLE MiniportAdapterHandle, + IN W_MINIPORT_CALLBACK CallbackRoutine, + IN PVOID CallbackContext); + +NDIS_STATUS +EXPIMP +NdisIMRegisterLayeredMiniport( + IN NDIS_HANDLE NdisWrapperHandle, + IN PNDIS_MINIPORT_CHARACTERISTICS MiniportCharacteristics, + IN UINT CharacteristicsLength, + OUT PNDIS_HANDLE DriverHandle); + +VOID +EXPIMP +NdisIMRevertBack( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE SwitchHandle); + +BOOLEAN +EXPIMP +NdisIMSwitchToMiniport( + IN NDIS_HANDLE MiniportAdapterHandle, + OUT PNDIS_HANDLE SwitchHandle); + + +VOID +EXPIMP +NdisMSetResetTimeout( + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT TimeInSeconds); + +NDIS_STATUS +EXPIMP +NdisMAllocateMapRegisters( + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT DmaChannel, + IN BOOLEAN Dma32BitAddresses, + IN ULONG PhysicalMapRegistersNeeded, + IN ULONG MaximumPhysicalMapping); + +VOID +EXPIMP +NdisMFreeMapRegisters( + IN NDIS_HANDLE MiniportAdapterHandle); + +NDIS_STATUS +EXPIMP +NdisMRegisterIoPortRange( + OUT PVOID * PortOffset, + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT InitialPort, + IN UINT NumberOfPorts); + +VOID +EXPIMP +NdisMDeregisterIoPortRange( + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT InitialPort, + IN UINT NumberOfPorts, + IN PVOID PortOffset); + +NDIS_STATUS +EXPIMP +NdisMMapIoSpace( + OUT PVOID * VirtualAddress, + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, + IN UINT Length); + +VOID +EXPIMP +NdisMUnmapIoSpace( + IN NDIS_HANDLE MiniportAdapterHandle, + IN PVOID VirtualAddress, + IN UINT Length); + +NDIS_STATUS +EXPIMP +NdisMRegisterInterrupt( + OUT PNDIS_MINIPORT_INTERRUPT Interrupt, + IN NDIS_HANDLE MiniportAdapterHandle, + IN UINT InterruptVector, + IN UINT InterruptLevel, + IN BOOLEAN RequestIsr, + IN BOOLEAN SharedInterrupt, + IN NDIS_INTERRUPT_MODE InterruptMode); + +VOID +EXPIMP +NdisMDeregisterInterrupt( + IN PNDIS_MINIPORT_INTERRUPT Interrupt); + +BOOLEAN +EXPIMP +NdisMSynchronizeWithInterrupt( + IN PNDIS_MINIPORT_INTERRUPT Interrupt, + IN PVOID SynchronizeFunction, + IN PVOID SynchronizeContext); + +VOID +EXPIMP +NdisMQueryAdapterResources( + OUT PNDIS_STATUS Status, + IN NDIS_HANDLE WrapperConfigurationContext, + OUT PNDIS_RESOURCE_LIST ResourceList, + IN OUT PUINT BufferSize); + + +/* Functions obsoleted by NDIS 5.0 */ + +VOID +EXPIMP +NdisFreeDmaChannel( + IN PNDIS_HANDLE NdisDmaHandle); + +VOID +EXPIMP +NdisFreeSharedMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Length, + IN BOOLEAN Cached, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +NDIS_STATUS +EXPIMP +NdisIMQueueMiniportCallback( + IN NDIS_HANDLE MiniportAdapterHandle, + IN W_MINIPORT_CALLBACK CallbackRoutine, + IN PVOID CallbackContext); + +VOID +EXPIMP +NdisIMRevertBack( + IN NDIS_HANDLE MiniportAdapterHandle, + IN NDIS_HANDLE SwitchHandle); + +BOOLEAN +EXPIMP +NdisIMSwitchToMiniport( + IN NDIS_HANDLE MiniportAdapterHandle, + OUT PNDIS_HANDLE SwitchHandle); + +VOID +EXPIMP +NdisSetupDmaTransfer( + OUT PNDIS_STATUS Status, + IN PNDIS_HANDLE NdisDmaHandle, + IN PNDIS_BUFFER Buffer, + IN ULONG Offset, + IN ULONG Length, + IN BOOLEAN WriteToDevice); + +NTSTATUS +EXPIMP +NdisUpcaseUnicodeString( + OUT PUNICODE_STRING DestinationString, + IN PUNICODE_STRING SourceString); + +VOID +EXPIMP +NdisUpdateSharedMemory( + IN NDIS_HANDLE NdisAdapterHandle, + IN ULONG Length, + IN PVOID VirtualAddress, + IN NDIS_PHYSICAL_ADDRESS PhysicalAddress); + +#endif /* NDIS_WRAPPER || NDIS_MINIPORT_DRIVER */ + +#ifdef __cplusplus +}; +#endif /* __cplusplus */ + +#endif /* __NDIS_H */ + +/* EOF */ diff --git a/reactos/include/net/ndisoid.h b/reactos/include/net/ndisoid.h new file mode 100644 index 00000000000..8680868f3af --- /dev/null +++ b/reactos/include/net/ndisoid.h @@ -0,0 +1,410 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS NDIS library + * FILE: include/net/ndisoid.h + * PURPOSE: NDIS Object ID constants + */ +#ifndef __NDISOID_H +#define __NDISOID_H + + +typedef ULONG NDIS_OID, *PNDIS_OID; + +/* Self-contained variable data structure */ +typedef struct _NDIS_VAR_DATA_DESC +{ + USHORT Length; /* Number of bytes of data */ + USHORT MaximumLength; /* Number of bytes available */ + LONG Offset; /* Offset of data relative to the descriptor */ +} NDIS_VAR_DATA_DESC, *PNDIS_VAR_DATA_DESC; + + + +/* NDIS 4.0 structures */ + +/* Structure used by TRANSLATE_NAME IOCTL */ +typedef struct _NET_PNP_ID +{ + ULONG ClassId; + ULONG Token; +} NET_PNP_ID, *PNET_PNP_ID; + + +typedef struct _NET_PNP_TRANSLATE_LIST +{ + ULONG BytesNeeded; + NET_PNP_ID IdArray[ANYSIZE_ARRAY]; +} NET_PNP_TRANSLATE_LIST, *PNET_PNP_TRANSLATE_LIST; + + + +/* Generel objects */ + +/* General operational characteristics */ + +/* Mandatory */ +#define OID_GEN_SUPPORTED_LIST 0x00010101 +#define OID_GEN_HARDWARE_STATUS 0x00010102 +#define OID_GEN_MEDIA_SUPPORTED 0x00010103 +#define OID_GEN_MEDIA_IN_USE 0x00010104 +#define OID_GEN_MAXIMUM_LOOKAHEAD 0x00010105 +#define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106 +#define OID_GEN_LINK_SPEED 0x00010107 +#define OID_GEN_TRANSMIT_BUFFER_SPACE 0x00010108 +#define OID_GEN_RECEIVE_BUFFER_SPACE 0x00010109 +#define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010A +#define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010B +#define OID_GEN_VENDOR_ID 0x0001010C +#define OID_GEN_VENDOR_DESCRIPTION 0x0001010D +#define OID_GEN_CURRENT_PACKET_FILTER 0x0001010E +#define OID_GEN_CURRENT_LOOKAHEAD 0x0001010F +#define OID_GEN_DRIVER_VERSION 0x00010110 +#define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111 +#define OID_GEN_PROTOCOL_OPTIONS 0x00010112 +#define OID_GEN_MAC_OPTIONS 0x00010113 +#define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114 +#define OID_GEN_MAXIMUM_SEND_PACKETS 0x00010115 +#define OID_GEN_VENDOR_DRIVER_VERSION 0x00010116 + +/* Optional */ +#define OID_GEN_SUPPORTED_GUIDS 0x00010117 +#define OID_GEN_NETWORK_LAYER_ADDRESSES 0x00010118 +#define OID_GEN_TRANSPORT_HEADER_OFFSET 0x00010119 + +/* General statistics */ + +/* Mandatory */ +#define OID_GEN_XMIT_OK 0x00020101 +#define OID_GEN_RCV_OK 0x00020102 +#define OID_GEN_XMIT_ERROR 0x00020103 +#define OID_GEN_RCV_ERROR 0x00020104 +#define OID_GEN_RCV_NO_BUFFER 0x00020105 + +/* Optional */ +#define OID_GEN_DIRECTED_BYTES_XMIT 0x00020201 +#define OID_GEN_DIRECTED_FRAMES_XMIT 0x00020202 +#define OID_GEN_MULTICAST_BYTES_XMIT 0x00020203 +#define OID_GEN_MULTICAST_FRAMES_XMIT 0x00020204 +#define OID_GEN_BROADCAST_BYTES_XMIT 0x00020205 +#define OID_GEN_BROADCAST_FRAMES_XMIT 0x00020206 +#define OID_GEN_DIRECTED_BYTES_RCV 0x00020207 +#define OID_GEN_DIRECTED_FRAMES_RCV 0x00020208 +#define OID_GEN_MULTICAST_BYTES_RCV 0x00020209 +#define OID_GEN_MULTICAST_FRAMES_RCV 0x0002020A +#define OID_GEN_BROADCAST_BYTES_RCV 0x0002020B +#define OID_GEN_BROADCAST_FRAMES_RCV 0x0002020C +#define OID_GEN_RCV_CRC_ERROR 0x0002020D +#define OID_GEN_TRANSMIT_QUEUE_LENGTH 0x0002020E + + +/* Ethernet objects */ + +/* Ethernet operational characteristics */ + +/* Mandatory */ +#define OID_802_3_PERMANENT_ADDRESS 0x01010101 +#define OID_802_3_CURRENT_ADDRESS 0x01010102 +#define OID_802_3_MULTICAST_LIST 0x01010103 +#define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104 + +/* Optional */ +#define OID_802_3_MAC_OPTIONS 0x01010105 + +/* Ethernet statistics */ + +/* Mandatory */ +#define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101 +#define OID_802_3_XMIT_ONE_COLLISION 0x01020102 +#define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103 + +/* Optional */ +#define OID_802_3_XMIT_DEFERRED 0x01020201 +#define OID_802_3_XMIT_MAX_COLLISIONS 0x01020202 +#define OID_802_3_RCV_OVERRUN 0x01020203 +#define OID_802_3_XMIT_UNDERRUN 0x01020204 +#define OID_802_3_XMIT_HEARTBEAT_FAILURE 0x01020205 +#define OID_802_3_XMIT_TIMES_CRS_LOST 0x01020206 +#define OID_802_3_XMIT_LATE_COLLISIONS 0x01020207 + + +/* Token Ring objects */ + +/* Token Ring operational characteristics */ + +/* Mandatory */ +#define OID_802_5_PERMANENT_ADDRESS 0x02010101 +#define OID_802_5_CURRENT_ADDRESS 0x02010102 +#define OID_802_5_CURRENT_FUNCTIONAL 0x02010103 +#define OID_802_5_CURRENT_GROUP 0x02010104 +#define OID_802_5_LAST_OPEN_STATUS 0x02010105 +#define OID_802_5_CURRENT_RING_STATUS 0x02010106 +#define OID_802_5_CURRENT_RING_STATE 0x02010107 + +/* Token Ring statistics */ + +/* Mandatory */ +#define OID_802_5_LINE_ERRORS 0x02020101 +#define OID_802_5_LOST_FRAMES 0x02020102 +#define OID_802_5_BURST_ERRORS 0x02020201 +#define OID_802_5_AC_ERRORS 0x02020202 +#define OID_802_5_ABORT_DELIMETERS 0x02020203 +#define OID_802_5_FRAME_COPIED_ERRORS 0x02020204 +#define OID_802_5_FREQUENCY_ERRORS 0x02020205 +#define OID_802_5_TOKEN_ERRORS 0x02020206 +#define OID_802_5_INTERNAL_ERRORS 0x02020207 + + +/* FDDI objects */ + +/* FDDI operational characteristics */ + +/* Mandatory */ +#define OID_FDDI_LONG_PERMANENT_ADDR 0x03010101 +#define OID_FDDI_LONG_CURRENT_ADDR 0x03010102 +#define OID_FDDI_LONG_MULTICAST_LIST 0x03010103 +#define OID_FDDI_LONG_MAX_LIST_SIZE 0x03010104 +#define OID_FDDI_SHORT_PERMANENT_ADDR 0x03010105 +#define OID_FDDI_SHORT_CURRENT_ADDR 0x03010106 +#define OID_FDDI_SHORT_MULTICAST_LIST 0x03010107 +#define OID_FDDI_SHORT_MAX_LIST_SIZE 0x03010108 + +/* FDDI statistics */ + +/* Mandatory */ +#define OID_FDDI_ATTACHMENT_TYPE 0x03020101 +#define OID_FDDI_UPSTREAM_NODE_LONG 0x03020102 +#define OID_FDDI_DOWNSTREAM_NODE_LONG 0x03020103 +#define OID_FDDI_FRAME_ERRORS 0x03020104 +#define OID_FDDI_FRAMES_LOST 0x03020105 +#define OID_FDDI_RING_MGT_STATE 0x03020106 +#define OID_FDDI_LCT_FAILURES 0x03020107 +#define OID_FDDI_LEM_REJECTS 0x03020108 +#define OID_FDDI_LCONNECTION_STATE 0x03020109 + + +/* LocalTalk objects */ + +/* LocalTalk operational characteristics */ + +/* Mandatory */ +#define OID_LTALK_CURRENT_NODE_ID 0x05010102 + +/* LocalTalk statistics */ + +/* Mandatory */ +#define OID_LTALK_IN_BROADCASTS 0x05020101 +#define OID_LTALK_IN_LENGTH_ERRORS 0x05020102 + +/* Optional */ +#define OID_LTALK_OUT_NO_HANDLERS 0x05020201 +#define OID_LTALK_COLLISIONS 0x05020202 +#define OID_LTALK_DEFERS 0x05020203 +#define OID_LTALK_NO_DATA_ERRORS 0x05020204 +#define OID_LTALK_RANDOM_CTS_ERRORS 0x05020205 +#define OID_LTALK_FCS_ERRORS 0x05020206 + + +/* ARCNET objects */ + +/* ARCNET operational characteristics */ + +/* Mandatory */ +#define OID_ARCNET_PERMANENT_ADDRESS 0x06010101 +#define OID_ARCNET_CURRENT_ADDRESS 0x06010102 + +/* ARCNET statistics */ + +/* Optional */ +#define OID_ARCNET_RECONFIGURATIONS 0x06020201 + + +/* WAN objects */ + +/* Mandatory */ +#define OID_WAN_PERMANENT_ADDRESS 0x04010101 +#define OID_WAN_CURRENT_ADDRESS 0x04010102 +#define OID_WAN_QUALITY_OF_SERVICE 0x04010103 +#define OID_WAN_PROTOCOL_TYPE 0x04010104 +#define OID_WAN_MEDIUM_SUBTYPE 0x04010105 +#define OID_WAN_HEADER_FORMAT 0x04010106 +#define OID_WAN_GET_INFO 0x04010107 +#define OID_WAN_SET_LINK_INFO 0x04010108 +#define OID_WAN_GET_LINK_INFO 0x04010109 +#define OID_WAN_LINE_COUNT 0x0401010A +#define OID_WAN_PROTOCOL_CAPS 0x0401010B +#define OID_WAN_GET_BRIDGE_INFO 0x0401020A +#define OID_WAN_SET_BRIDGE_INFO 0x0401020B + +/* Optional */ +#define OID_WAN_GET_COMP_INFO 0x0401020C +#define OID_WAN_SET_COMP_INFO 0x0401020D +#define OID_WAN_GET_STATS_INFO 0x0401020E + + +/* TAPI objects */ + +/* Madatory */ +#define OID_TAPI_ANSWER 0x07030102 +#define OID_TAPI_CLOSE 0x07030103 +#define OID_TAPI_CLOSE_CALL 0x07030104 +#define OID_TAPI_CONDITIONAL_MEDIA_DETECTION 0x07030105 +#define OID_TAPI_DROP 0x07030109 +#define OID_TAPI_GET_ADDRESS_CAPS 0x0703010A +#define OID_TAPI_GET_ADDRESS_ID 0x0703010B +#define OID_TAPI_GET_ADDRESS_STATUS 0x0703010C +#define OID_TAPI_GET_CALL_ADDRESS_ID 0x0703010D +#define OID_TAPI_GET_CALL_INFO 0x0703010E +#define OID_TAPI_GET_CALL_STATUS 0x0703010F +#define OID_TAPI_GET_DEV_CAPS 0x07030110 +#define OID_TAPI_GET_DEV_CONFIG 0x07030111 +#define OID_TAPI_GET_ID 0x07030113 +#define OID_TAPI_GET_LINE_DEV_STATUS 0x07030114 +#define OID_TAPI_MAKE_CALL 0x07030115 +#define OID_TAPI_OPEN 0x07030117 +#define OID_TAPI_PROVIDER_INITIALIZE 0x07030118 +#define OID_TAPI_PROVIDER_SHUTDOWN 0x07030119 +#define OID_TAPI_SET_APP_SPECIFIC 0x0703011D +#define OID_TAPI_SET_CALL_PARAMS 0x0703011E +#define OID_TAPI_SET_DEFAULT_MEDIA_DETECTION 0x0703011F +#define OID_TAPI_SET_MEDIA_MODE 0x07030121 +#define OID_TAPI_SET_STATUS_MESSAGES 0x07030122 + +/* Optional */ +#define OID_TAPI_ACCEPT 0x07030101 +#define OID_TAPI_CONFIG_DIALOG 0x07030106 +#define OID_TAPI_DEV_SPECIFIC 0x07030107 +#define OID_TAPI_DIAL 0x07030108 +#define OID_TAPI_GET_EXTENSION_ID 0x07030112 +#define OID_TAPI_NEGOTIATE_EXT_VERSION 0x07030116 +#define OID_TAPI_SET_DEV_CONFIG 0x07030120 +#define OID_TAPI_SECURE_CALL 0x0703011A +#define OID_TAPI_SELECT_EXT_VERSION 0x0703011B +#define OID_TAPI_SEND_USER_USER_INFO 0x0703011C + + +/* Wireless objects */ + +/* Mandatory */ +#define OID_WW_GEN_NETWORK_TYPES_SUPPORTED 0x09010101 +#define OID_WW_GEN_NETWORK_TYPE_IN_USE 0x09010102 +#define OID_WW_GEN_HEADER_FORMATS_SUPPORTED 0x09010103 +#define OID_WW_GEN_HEADER_FORMAT_IN_USE 0x09010104 +#define OID_WW_GEN_INDICATION_REQUEST 0x09010105 +#define OID_WW_GEN_DEVICE_INFO 0x09010106 +#define OID_WW_GEN_OPERATION_MODE 0x09010107 +#define OID_WW_GEN_LOCK_STATUS 0x09010108 +#define OID_WW_GEN_DISABLE_TRANSMITTER 0x09010109 +#define OID_WW_GEN_NETWORK_ID 0x0901010A +#define OID_WW_GEN_PERMANENT_ADDRESS 0x0901010B +#define OID_WW_GEN_CURRENT_ADDRESS 0x0901010C +#define OID_WW_GEN_SUSPEND_DRIVER 0x0901010D +#define OID_WW_GEN_BASESTATION_ID 0x0901010E +#define OID_WW_GEN_CHANNEL_ID 0x0901010F +#define OID_WW_GEN_ENCRYPTION_SUPPORTED 0x09010110 +#define OID_WW_GEN_ENCRYPTION_IN_USE 0x09010111 +#define OID_WW_GEN_ENCRYPTION_STATE 0x09010112 +#define OID_WW_GEN_CHANNEL_QUALITY 0x09010113 +#define OID_WW_GEN_REGISTRATION_STATUS 0x09010114 +#define OID_WW_GEN_RADIO_LINK_SPEED 0x09010115 +#define OID_WW_GEN_LATENCY 0x09010116 +#define OID_WW_GEN_BATTERY_LEVEL 0x09010117 +#define OID_WW_GEN_EXTERNAL_POWER 0x09010118 + +/* Optional */ +#define OID_WW_GEN_PING_ADDRESS 0x09010201 +#define OID_WW_GEN_RSSI 0x09010202 +#define OID_WW_GEN_SIM_STATUS 0x09010203 +#define OID_WW_GEN_ENABLE_SIM_PIN 0x09010204 +#define OID_WW_GEN_CHANGE_SIM_PIN 0x09010205 +#define OID_WW_GEN_SIM_PUK 0x09010206 +#define OID_WW_GEN_SIM_EXCEPTION 0x09010207 + +/* Metricom OIDs */ +#define OID_WW_MET_FUNCTION 0x09190101 + +/* DataTac OIDs */ +#define OID_WW_TAC_COMPRESSION 0x09150101 + +#define OID_WW_TAC_SET_CONFIG 0x09150102 +#define OID_WW_TAC_GET_STATUS 0x09150103 +#define OID_WW_TAC_USER_HEADER 0x09150104 + +/* Ardis OIDs */ + +#define OID_WW_ARD_SNDCP 0x09110101 +#define OID_WW_ARD_TMLY_MSG 0x09110102 +#define OID_WW_ARD_DATAGRAM 0x09110103 + +/* CDPD OIDs */ + +#define OID_WW_CDPD_CIRCUIT_SWITCHED 0x090D010E +#define OID_WW_CDPD_TEI 0x090D010F +#define OID_WW_CDPD_RSSI 0x090D0110 + +#define OID_WW_CDPD_CS_SERVICE_PREFERENCE 0x090D0111 +#define OID_WW_CDPD_CS_SERVICE_STATUS 0x090D0112 +#define OID_WW_CDPD_CS_INFO 0x090D0113 +#define OID_WW_CDPD_CS_SUSPEND 0x090D0114 +#define OID_WW_CDPD_CS_DEFAULT_DIAL_CODE 0x090D0115 +#define OID_WW_CDPD_CS_CALLBACK 0x090D0116 +#define OID_WW_CDPD_CS_SID_LIST 0x090D0117 +#define OID_WW_CDPD_CS_CONFIGURATION 0x090D0118 + +/* Pinpoint OIDs */ + +#define OID_WW_PIN_LOC_AUTHORIZE 0x09090101 +#define OID_WW_PIN_LAST_LOCATION 0x09090102 +#define OID_WW_PIN_LOC_FIX 0x09090103 + +/* Mobitex OIDs */ +#define OID_WW_MBX_SUBADDR 0x09050101 +/* OID 0x09050102 is reserved and may not be used */ +#define OID_WW_MBX_FLEXLIST 0x09050103 +#define OID_WW_MBX_GROUPLIST 0x09050104 +#define OID_WW_MBX_TRAFFIC_AREA 0x09050105 +#define OID_WW_MBX_LIVE_DIE 0x09050106 +#define OID_WW_MBX_TEMP_DEFAULTLIST 0x09050107 + + +/* Connection-oriented objects */ + +/* Connection-oriented operational characteristics */ + +/* Mandatory */ +#define OID_GEN_CO_SUPPORTED_LIST OID_GEN_SUPPORTED_LIST +#define OID_GEN_CO_HARDWARE_STATUS OID_GEN_HARDWARE_STATUS +#define OID_GEN_CO_MEDIA_SUPPORTED OID_GEN_MEDIA_SUPPORTED +#define OID_GEN_CO_MEDIA_IN_USE OID_GEN_MEDIA_IN_USE +#define OID_GEN_CO_LINK_SPEED OID_GEN_LINK_SPEED +#define OID_GEN_CO_VENDOR_ID OID_GEN_VENDOR_ID +#define OID_GEN_CO_VENDOR_DESCRIPTION OID_GEN_VENDOR_DESCRIPTION +#define OID_GEN_CO_DRIVER_VERSION OID_GEN_DRIVER_VERSION +#define OID_GEN_CO_PROTOCOL_OPTIONS OID_GEN_PROTOCOL_OPTIONS +#define OID_GEN_CO_MAC_OPTIONS OID_GEN_MAC_OPTIONS +#define OID_GEN_CO_MEDIA_CONNECT_STATUS OID_GEN_MEDIA_CONNECT_STATUS +#define OID_GEN_CO_VENDOR_DRIVER_VERSION OID_GEN_VENDOR_DRIVER_VERSION + +/* Optional */ +#define OID_GEN_CO_SUPPORTED_GUIDS OID_GEN_SUPPORTED_GUIDS +#define OID_GEN_CO_GET_TIME_CAPS OID_GEN_GET_TIME_CAPS +#define OID_GEN_CO_GET_NETCARD_TIME OID_GEN_GET_NETCARD_TIME +#define OID_GEN_CO_MINIMUM_LINK_SPEED 0x00020120 + +/* Connection-oriented statistics */ + +#define OID_GEN_CO_XMIT_PDUS_OK OID_GEN_XMIT_OK +#define OID_GEN_CO_RCV_PDUS_OK OID_GEN_RCV_OK +#define OID_GEN_CO_XMIT_PDUS_ERROR OID_GEN_XMIT_ERROR +#define OID_GEN_CO_RCV_PDUS_ERROR OID_GEN_RCV_ERROR +#define OID_GEN_CO_RCV_PDUS_NO_BUFFER OID_GEN_RCV_NO_BUFFER +#define OID_GEN_CO_RCV_CRC_ERROR OID_GEN_RCV_CRC_ERROR +#define OID_GEN_CO_TRANSMIT_QUEUE_LENGTH OID_GEN_TRANSMIT_QUEUE_LENGTH +#define OID_GEN_CO_BYTES_XMIT OID_GEN_DIRECTED_BYTES_XMIT +#define OID_GEN_CO_BYTES_RCV OID_GEN_DIRECTED_BYTES_RCV +#define OID_GEN_CO_NETCARD_LOAD OID_GEN_NETCARD_LOAD +#define OID_GEN_CO_DEVICE_PROFILE OID_GEN_DEVICE_PROFILE +#define OID_GEN_CO_BYTES_XMIT_OUTSTANDING 0x00020221 + +#endif /* __NDISOID_H */ + +/* EOF */ diff --git a/reactos/include/net/netevent.h b/reactos/include/net/netevent.h new file mode 100644 index 00000000000..2478a979584 --- /dev/null +++ b/reactos/include/net/netevent.h @@ -0,0 +1,16 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS NDIS library + * FILE: include/net/netevent.h + * PURPOSE: Network event constants + */ +#ifndef __NETEVENT_H +#define __NETEVENT_H + +#define EVENT_TRANSPORT_REGISTER_FAILED 0xC000232CL + +#define EVENT_TRANSPORT_ADAPTER_NOT_FOUND 0xC000232EL + +#endif /* __NETEVENT_H */ + +/* EOF */ diff --git a/reactos/include/net/tdi.h b/reactos/include/net/tdi.h new file mode 100644 index 00000000000..88197f5ad3b --- /dev/null +++ b/reactos/include/net/tdi.h @@ -0,0 +1,644 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS TDI library + * FILE: include/net/tdi.h + * PURPOSE: TDI definitions for user mode clients + */ +#ifndef __TDI_H +#define __TDI_H + +/* FIXME: Missed some definitions in ntddk.h */ + +/* Could be defined in ndis.h */ +#ifndef __NDIS_H +typedef signed int INT, *PINT; +#endif + + + +/* Basic types */ + +typedef LONG TDI_STATUS; +typedef PVOID CONNECTION_CONTEXT; + + + +/* TDI status codes */ + +#define TDI_SUCCESS STATUS_SUCCESS +#define TDI_NO_RESOURCES STATUS_INSUFFICIENT_RESOURCES +#define TDI_ADDR_IN_USE STATUS_ADDRESS_ALREADY_EXISTS +#define TDI_BAD_ADDR STATUS_INVALID_ADDRESS_COMPONENT +#define TDI_NO_FREE_ADDR STATUS_TOO_MANY_ADDRESSES +#define TDI_ADDR_INVALID STATUS_INVALID_ADDRESS +#define TDI_ADDR_DELETED STATUS_ADDRESS_CLOSED +#define TDI_BUFFER_OVERFLOW STATUS_BUFFER_OVERFLOW +#define TDI_BAD_EVENT_TYPE STATUS_INVALID_PARAMETER +#define TDI_BAD_OPTION STATUS_INVALID_PARAMETER +#define TDI_CONN_REFUSED STATUS_CONNECTION_REFUSED +#define TDI_INVALID_CONNECTION STATUS_CONNECTION_INVALID +#define TDI_ALREADY_ASSOCIATED STATUS_ADDRESS_ALREADY_ASSOCIATED +#define TDI_NOT_ASSOCIATED STATUS_ADDRESS_NOT_ASSOCIATED +#define TDI_CONNECTION_ACTIVE STATUS_CONNECTION_ACTIVE +#define TDI_CONNECTION_ABORTED STATUS_CONNECTION_ABORTED +#define TDI_CONNECTION_RESET STATUS_CONNECTION_RESET +#define TDI_TIMED_OUT STATUS_IO_TIMEOUT +#define TDI_GRACEFUL_DISC STATUS_GRACEFUL_DISCONNECT +#define TDI_NOT_ACCEPTED STATUS_DATA_NOT_ACCEPTED +#define TDI_MORE_PROCESSING STATUS_MORE_PROCESSING_REQUIRED +#define TDI_INVALID_STATE STATUS_INVALID_DEVICE_STATE +#define TDI_INVALID_PARAMETER STATUS_INVALID_PARAMETER +#define TDI_DEST_NET_UNREACH STATUS_NETWORK_UNREACHABLE +#define TDI_DEST_HOST_UNREACH STATUS_HOST_UNREACHABLE +#define TDI_DEST_UNREACHABLE TDI_DEST_HOST_UNREACH +#define TDI_DEST_PROT_UNREACH STATUS_PROTOCOL_UNREACHABLE +#define TDI_DEST_PORT_UNREACH STATUS_PORT_UNREACHABLE +#define TDI_INVALID_QUERY STATUS_INVALID_DEVICE_REQUEST +#define TDI_REQ_ABORTED STATUS_REQUEST_ABORTED +#define TDI_BUFFER_TOO_SMALL STATUS_BUFFER_TOO_SMALL +#define TDI_CANCELLED STATUS_CANCELLED +#define TDI_BUFFER_TOO_BIG STATUS_INVALID_BUFFER_SIZE +#define TDI_INVALID_REQUEST STATUS_INVALID_DEVICE_REQUEST +#define TDI_PENDING STATUS_PENDING +#define TDI_ITEM_NOT_FOUND STATUS_OBJECT_NAME_NOT_FOUND + +#define TDI_OPTION_EOL 0 +#define TDI_ADDRESS_OPTION_REUSE 1 +#define TDI_ADDRESS_OPTION_DHCP 2 + + + +/* TDI IOCTL codes */ + +#define TDI_CONTROL_CODE(Request, Method) \ + CTL_CODE(FILE_DEVICE_TRANSPORT, Request, Method, FILE_ANY_ACCESS) + +#define IOCTL_TDI_ACCEPT TDI_CONTROL_CODE(0, METHOD_BUFFERED) +#define IOCTL_TDI_CONNECT TDI_CONTROL_CODE(1, METHOD_BUFFERED) +#define IOCTL_TDI_DISCONNECT TDI_CONTROL_CODE(2, METHOD_BUFFERED) +#define IOCTL_TDI_LISTEN TDI_CONTROL_CODE(3, METHOD_BUFFERED) +#define IOCTL_TDI_QUERY_INFORMATION TDI_CONTROL_CODE(4, METHOD_OUT_DIRECT) +#define IOCTL_TDI_RECEIVE TDI_CONTROL_CODE(5, METHOD_OUT_DIRECT) +#define IOCTL_TDI_RECEIVE_DATAGRAM TDI_CONTROL_CODE(6, METHOD_OUT_DIRECT) +#define IOCTL_TDI_SEND TDI_CONTROL_CODE(7, METHOD_IN_DIRECT) +#define IOCTL_TDI_SEND_DATAGRAM TDI_CONTROL_CODE(8, METHOD_IN_DIRECT) +#define IOCTL_TDI_SET_EVENT_HANDLER TDI_CONTROL_CODE(9, METHOD_BUFFERED) +#define IOCTL_TDI_SET_INFORMATION TDI_CONTROL_CODE(10, METHOD_IN_DIRECT) +#define IOCTL_TDI_ASSOCIATE_ADDRESS TDI_CONTROL_CODE(11, METHOD_BUFFERED) +#define IOCTL_TDI_DISASSOCIATE_ADDRESS TDI_CONTROL_CODE(12, METHOD_BUFFERED) +#define IOCTL_TDI_ACTION TDI_CONTROL_CODE(13, METHOD_OUT_DIRECT) + + + +/* TDI transport driver dispatch routines */ + +NTSTATUS TdiDispatchCleanup( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS TdiDispatchClose( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS TdiDispatchCreate( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + +NTSTATUS TdiDispatchDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_STACK_LOCATION IrpSp); + +BOOLEAN TdiDispatchFastDeviceControl( + IN PFILE_OBJECT FileObject, + IN BOOLEAN Wait, + IN PVOID InputBuffer, + IN ULONG InputBufferLength, + IN OUT PVOID OutputBuffer, + IN ULONG OutputBufferLength, + IN ULONG IoControlCode, + OUT PIO_STATUS_BLOCK IoStatus); + +NTSTATUS TdiDispatchInternalDeviceControl( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp); + + + +/* TDI structures */ + +typedef struct _TDI_CONNECTION_INFORMATION +{ + LONG UserDataLength; + PVOID UserData; + LONG OptionsLength; + PVOID Options; + LONG RemoteAddressLength; + PVOID RemoteAddress; +} TDI_CONNECTION_INFORMATION, *PTDI_CONNECTION_INFORMATION; + +typedef struct _TDI_REQUEST +{ + union { + HANDLE AddressHandle; + CONNECTION_CONTEXT ConnectionContext; + HANDLE ControlChannel; + } Handle; + PVOID RequestNotifyObject; + PVOID RequestContext; + TDI_STATUS TdiStatus; +} TDI_REQUEST, *PTDI_REQUEST; + +typedef struct _TDI_REQUEST_STATUS +{ + TDI_STATUS Status; + PVOID RequestContext; + ULONG BytesTransferred; +} TDI_REQUEST_STATUS, *PTDI_REQUEST_STATUS; + + +typedef struct _TA_ADDRESS +{ + USHORT AddressLength; + USHORT AddressType; + UCHAR Address[1]; +} TA_ADDRESS, *PTA_ADDRESS; + +#define TDI_ADDRESS_TYPE_UNSPEC 0 +#define TDI_ADDRESS_TYPE_UNIX 1 +#define TDI_ADDRESS_TYPE_IP 2 +#define TDI_ADDRESS_TYPE_IMPLINK 3 +#define TDI_ADDRESS_TYPE_PUP 4 +#define TDI_ADDRESS_TYPE_CHAOS 5 +#define TDI_ADDRESS_TYPE_NS 6 +#define TDI_ADDRESS_TYPE_IPX 6 +#define TDI_ADDRESS_TYPE_NBS 7 +#define TDI_ADDRESS_TYPE_ECMA 8 +#define TDI_ADDRESS_TYPE_DATAKIT 9 +#define TDI_ADDRESS_TYPE_CCITT 10 +#define TDI_ADDRESS_TYPE_SNA 11 +#define TDI_ADDRESS_TYPE_DECnet 12 +#define TDI_ADDRESS_TYPE_DLI 13 +#define TDI_ADDRESS_TYPE_LAT 14 +#define TDI_ADDRESS_TYPE_HYLINK 15 +#define TDI_ADDRESS_TYPE_APPLETALK 16 +#define TDI_ADDRESS_TYPE_NETBIOS 17 +#define TDI_ADDRESS_TYPE_8022 18 +#define TDI_ADDRESS_TYPE_OSI_TSAP 19 +#define TDI_ADDRESS_TYPE_NETONE 20 +#define TDI_ADDRESS_TYPE_VNS 21 +#define TDI_ADDRESS_TYPE_NETBIOS_EX 22 + + +#define TdiTransportAddress "TransportAddress" +#define TdiConnectionContext "ConnectionContext" +#define TDI_TRANSPORT_ADDRESS_LENGTH (sizeof(TdiTransportAddress) - 1) +#define TDI_CONNECTION_CONTEXT_LENGTH (sizeof(TdiConnectionContext) - 1) + + +typedef struct _TRANSPORT_ADDRESS +{ + LONG TAAddressCount; + TA_ADDRESS Address[1]; +} TRANSPORT_ADDRESS, *PTRANSPORT_ADDRESS; + +typedef struct _TDI_ADDRESS_INFO +{ + ULONG ActivityCount; + TRANSPORT_ADDRESS Address; +} TDI_ADDRESS_INFO, *PTDI_ADDRESS_INFO; + +typedef struct _TDI_ACTION_HEADER +{ + ULONG TransportId; + USHORT ActionCode; + USHORT Reserved; +} TDI_ACTION_HEADER, *PTDI_ACTION_HEADER; + +typedef struct _TDI_ADDRESS_8022 +{ + UCHAR MACAddress[6]; +} TDI_ADDRESS_8022, *PTDI_ADDRESS_8022; + +typedef struct _TDI_ADDRESS_APPLETALK +{ + USHORT Network; + UCHAR Node; + UCHAR Socket; +} TDI_ADDRESS_APPLETALK, *PTDI_ADDRESS_APPLETALK; + +#define TDI_ADDRESS_LENGTH_APPLETALK sizeof(TDI_ADDRESS_APPLETALK) + +typedef struct _TDI_ADDRESS_IP +{ + USHORT sin_port; + ULONG in_addr; + UCHAR sin_zero[8]; +} TDI_ADDRESS_IP, *PTDI_ADDRESS_IP; + +#define TDI_ADDRESS_LENGTH_IP sizeof(TDI_ADDRESS_IP) + +typedef struct _TDI_ADDRESS_IPX +{ + ULONG NetworkAddress; + UCHAR NodeAddress[6]; + USHORT Socket; +} TDI_ADDRESS_IPX, *PTDI_ADDRESS_IPX; + +#define TDI_ADDRESS_LENGTH_IPX sizeof(TDI_ADDRESS_IPX) + +typedef struct _TDI_ADDRESS_NETBIOS +{ + USHORT NetbiosNameType; + UCHAR NetbiosName[16]; +} TDI_ADDRESS_NETBIOS, *PTDI_ADDRESS_NETBIOS; + +#define TDI_ADDRESS_NETBIOS_TYPE_UNIQUE 0x0000 +#define TDI_ADDRESS_NETBIOS_TYPE_GROUP 0x0001 +#define TDI_ADDRESS_NETBIOS_TYPE_QUICK_UNIQUE 0x0002 +#define TDI_ADDRESS_NETBIOS_TYPE_QUICK_GROUP 0x0003 + +#define TDI_ADDRESS_LENGTH_NETBIOS sizeof(TDI_ADDRESS_NETBIOS) + +typedef struct _TDI_ADDRESS_NETBIOS_EX +{ + UCHAR EndpointName[16]; + TDI_ADDRESS_NETBIOS NetbiosAddress; +} TDI_ADDRESS_NETBIOS_EX, *PTDI_ADDRESS_NETBIOS_EX; + +#define TDI_ADDRESS_LENGTH_NETBIOS_EX sizeof(TDI_ADDRESS_NETBIOS_EX) + +typedef struct _TDI_ADDRESS_NETONE +{ + USHORT NetoneNameType; + UCHAR NetoneName[20]; +} TDI_ADDRESS_NETONE, *PTDI_ADDRESS_NETONE; + +#define TDI_ADDRESS_NETONE_TYPE_UNIQUE 0x0000 +#define TDI_ADDRESS_NETONE_TYPE_ROTORED 0x0001 + +#define TDI_ADDRESS_LENGTH_NETONE sizeof(TDI_ADDRESS_NETONE) + +typedef struct _TDI_ADDRESS_NS +{ + ULONG NetworkAddress; + UCHAR NodeAddress[6]; + USHORT Socket; +} TDI_ADDRESS_NS, *PTDI_ADDRESS_NS; + +#define TDI_ADDRESS_LENGTH_NS sizeof(TDI_ADDRESS_NS) + +#define ISO_MAX_ADDR_LENGTH 64 + +#define ISO_HIERARCHICAL 0 +#define ISO_NON_HIERARCHICAL 1 + +typedef struct _TDI_ADDRESS_OSI_TSAP +{ + USHORT tp_addr_type; + USHORT tp_taddr_len; + USHORT tp_tsel_len; + UCHAR tp_addr[ISO_MAX_ADDR_LENGTH]; +} TDI_ADDRESS_OSI_TSAP, *PTDI_ADDRESS_OSI_TSAP; + +#define TDI_ADDRESS_LENGTH_OSI_TSAP sizeof(TDI_ADDRESS_OSI_TSAP) + +typedef struct _TDI_ADDRESS_VNS +{ + UCHAR net_address[4]; + UCHAR subnet_addr[2]; + UCHAR port[2]; + UCHAR hops; + UCHAR filler[5]; +} TDI_ADDRESS_VNS, *PTDI_ADDRESS_VNS; + +#define TDI_ADDRESS_LENGTH_VNS sizeof(TDI_ADDRESS_VNS) + + +/* TDI request structures */ + +typedef struct _TDI_CONNECT_REQUEST +{ + TDI_REQUEST Request; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; + PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; + LARGE_INTEGER Timeout; +} TDI_REQUEST_CONNECT, *PTDI_REQUEST_CONNECT; + +typedef struct _TDI_REQUEST_ACCEPT +{ + TDI_REQUEST Request; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; + PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; +} TDI_REQUEST_ACCEPT, *PTDI_REQUEST_ACCEPT; + +typedef struct _TDI_REQUEST_LISTEN +{ + TDI_REQUEST Request; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; + PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; + USHORT ListenFlags; +} TDI_REQUEST_LISTEN, *PTDI_REQUEST_LISTEN; + +typedef struct _TDI_DISCONNECT_REQUEST +{ + TDI_REQUEST Request; + LARGE_INTEGER Timeout; +} TDI_REQUEST_DISCONNECT, *PTDI_REQUEST_DISCONNECT; + +typedef struct _TDI_REQUEST_SEND +{ + TDI_REQUEST Request; + USHORT SendFlags; +} TDI_REQUEST_SEND, *PTDI_REQUEST_SEND; + +typedef struct _TDI_REQUEST_RECEIVE +{ + TDI_REQUEST Request; + USHORT ReceiveFlags; +} TDI_REQUEST_RECEIVE, *PTDI_REQUEST_RECEIVE; + +typedef struct _TDI_REQUEST_SEND_DATAGRAM +{ + TDI_REQUEST Request; + PTDI_CONNECTION_INFORMATION SendDatagramInformation; +} TDI_REQUEST_SEND_DATAGRAM, *PTDI_REQUEST_SEND_DATAGRAM; + +typedef struct _TDI_REQUEST_RECEIVE_DATAGRAM +{ + TDI_REQUEST Request; + PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation; + PTDI_CONNECTION_INFORMATION ReturnInformation; + USHORT ReceiveFlags; +} TDI_REQUEST_RECEIVE_DATAGRAM, *PTDI_REQUEST_RECEIVE_DATAGRAM; + +typedef struct _TDI_REQUEST_SET_EVENT +{ + TDI_REQUEST Request; + LONG EventType; + PVOID EventHandler; + PVOID EventContext; +} TDI_REQUEST_SET_EVENT_HANDLER, *PTDI_REQUEST_SET_EVENT_HANDLER; + +#define TDI_RECEIVE_BROADCAST 0x00000004 +#define TDI_RECEIVE_MULTICAST 0x00000008 +#define TDI_RECEIVE_PARTIAL 0x00000010 +#define TDI_RECEIVE_NORMAL 0x00000020 +#define TDI_RECEIVE_EXPEDITED 0x00000040 +#define TDI_RECEIVE_PEEK 0x00000080 +#define TDI_RECEIVE_NO_RESPONSE_EXP 0x00000100 +#define TDI_RECEIVE_COPY_LOOKAHEAD 0x00000200 +#define TDI_RECEIVE_ENTIRE_MESSAGE 0x00000400 +#define TDI_RECEIVE_AT_DISPATCH_LEVEL 0x00000800 + +/* Listen flags */ +#define TDI_QUERY_ACCEPT 0x00000001 + +/* Options used for both SendOptions and ReceiveIndicators */ +#define TDI_SEND_EXPEDITED 0x0020 +#define TDI_SEND_PARTIAL 0x0040 +#define TDI_SEND_NO_RESPONSE_EXPECTED 0x0080 +#define TDI_SEND_NON_BLOCKING 0x0100 + +/* Disconnect Flags */ +#define TDI_DISCONNECT_WAIT 0x0001 +#define TDI_DISCONNECT_ABORT 0x0002 +#define TDI_DISCONNECT_RELEASE 0x0004 + +/* TdiRequest structure for TdiQueryInformation request */ +typedef struct _TDI_REQUEST_QUERY_INFORMATION +{ + TDI_REQUEST Request; + ULONG QueryType; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; +} TDI_REQUEST_QUERY_INFORMATION, *PTDI_REQUEST_QUERY_INFORMATION; + +/* TdiRequest structure for TdiSetInformation request */ +typedef struct _TDI_REQUEST_SET_INFORMATION +{ + TDI_REQUEST Request; + ULONG SetType; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; +} TDI_REQUEST_SET_INFORMATION, *PTDI_REQUEST_SET_INFORMATION; + +typedef union _TDI_REQUEST_TYPE +{ + TDI_REQUEST_ACCEPT TdiAccept; + TDI_REQUEST_CONNECT TdiConnect; + TDI_REQUEST_DISCONNECT TdiDisconnect; + TDI_REQUEST_LISTEN TdiListen; + TDI_REQUEST_QUERY_INFORMATION TdiQueryInformation; + TDI_REQUEST_RECEIVE TdiReceive; + TDI_REQUEST_RECEIVE_DATAGRAM TdiReceiveDatagram; + TDI_REQUEST_SEND TdiSend; + TDI_REQUEST_SEND_DATAGRAM TdiSendDatagram; + TDI_REQUEST_SET_EVENT_HANDLER TdiSetEventHandler; + TDI_REQUEST_SET_INFORMATION TdiSetInformation; +} TDI_REQUEST_TYPE, *PTDI_REQUEST_TYPE; + + + +/* Query information types */ + +/* Generic query info types that must be supported by all transports */ +#define TDI_QUERY_BROADCAST_ADDRESS 0x00000001 +#define TDI_QUERY_PROVIDER_INFO 0x00000002 +#define TDI_QUERY_ADDRESS_INFO 0x00000003 +#define TDI_QUERY_CONNECTION_INFO 0x00000004 +#define TDI_QUERY_PROVIDER_STATISTICS 0x00000005 +#define TDI_QUERY_DATAGRAM_INFO 0x00000006 +#define TDI_QUERY_DATA_LINK_ADDRESS 0x00000007 +#define TDI_QUERY_NETWORK_ADDRESS 0x00000008 +#define TDI_QUERY_MAX_DATAGRAM_INFO 0x00000009 + +/* Netbios specific query information types */ +#define TDI_QUERY_ADAPTER_STATUS 0x00000100 +#define TDI_QUERY_SESSION_STATUS 0x00000200 +#define TDI_QUERY_FIND_NAME 0x00000300 + +typedef struct _TA_APPLETALK_ADDR +{ + LONG TAAddressCount; + struct _AddrAtalk { + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_APPLETALK Address[1]; + } Address[1]; +} TA_APPLETALK_ADDRESS, *PTA_APPLETALK_ADDRESS; + +typedef struct _TA_ADDRESS_IP +{ + LONG TAAddressCount; + struct _AddrIp { + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_IP Address[1]; + } Address[1]; +} TA_ADDRESS_IP, *PTA_ADDRESS_IP; + +typedef struct _TA_ADDRESS_IPX +{ + LONG TAAddressCount; + struct _AddrIpx { + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_IP Address[1]; + } Address[1]; +} TA_IPX_ADDRESS, *PTA_IPX_ADDRESS; + +typedef struct _TA_NETBIOS_ADDRESS +{ + LONG TAAddressCount; + struct _Addr{ + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_NETBIOS Address[1]; + } Address[1]; +} TA_NETBIOS_ADDRESS, *PTA_NETBIOS_ADDRESS; + +typedef struct _TA_ADDRESS_NS +{ + LONG TAAddressCount; + struct _AddrNs { + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_NS Address[1]; + } Address[1]; +} TA_NS_ADDRESS, *PTA_NS_ADDRESS; + +typedef struct _TA_ADDRESS_VNS +{ + LONG TAAddressCount; + struct _AddrVns { + USHORT AddressLength; + USHORT AddressType; + TDI_ADDRESS_VNS Address[1]; + } Address[1]; +} TA_VNS_ADDRESS, *PTA_VNS_ADDRESS; + + +/* Structures used for TdiQueryInformation and TdiSetInformation */ + +typedef struct _TDI_ENDPOINT_INFO +{ + ULONG State; + ULONG Event; + ULONG TransmittedTsdus; + ULONG ReceivedTsdus; + ULONG TransmissionErrors; + ULONG ReceiveErrors; + ULONG MinimumLookaheadData; + ULONG MaximumLookaheadData; + ULONG PriorityLevel; + ULONG SecurityLevel; + ULONG SecurityCompartment; +} TDI_ENDPOINT_INFO, *PTDI_ENDPOINT_INFO; + +typedef struct _TDI_CONNECTION_INFO +{ + ULONG State; + ULONG Event; + ULONG TransmittedTsdus; + ULONG ReceivedTsdus; + ULONG TransmissionErrors; + ULONG ReceiveErrors; + LARGE_INTEGER Throughput; + LARGE_INTEGER Delay; + ULONG SendBufferSize; + ULONG ReceiveBufferSize; + BOOLEAN Unreliable; +} TDI_CONNECTION_INFO, *PTDI_CONNECTION_INFO; + +typedef struct _TDI_DATAGRAM_INFO +{ + ULONG MaximumDatagramBytes; + ULONG MaximumDatagramCount; +} TDI_DATAGRAM_INFO, *PTDI_DATAGRAM_INFO; + +typedef struct _TDI_MAX_DATAGRAM_INFO +{ + ULONG MaxDatagramSize; +} TDI_MAX_DATAGRAM_INFO, *PTDI_MAX_DATAGRAM_INFO; + +typedef struct _TDI_PROVIDER_INFO +{ + ULONG Version; + ULONG MaxSendSize; + ULONG MaxConnectionUserData; + ULONG MaxDatagramSize; + ULONG ServiceFlags; + ULONG MinimumLookaheadData; + ULONG MaximumLookaheadData; + ULONG NumberOfResources; + LARGE_INTEGER StartTime; +} TDI_PROVIDER_INFO, *PTDI_PROVIDER_INFO; + +#define TDI_SERVICE_CONNECTION_MODE 0x00000001 +#define TDI_SERVICE_ORDERLY_RELEASE 0x00000002 +#define TDI_SERVICE_CONNECTIONLESS_MODE 0x00000004 +#define TDI_SERVICE_ERROR_FREE_DELIVERY 0x00000008 +#define TDI_SERVICE_SECURITY_LEVEL 0x00000010 +#define TDI_SERVICE_BROADCAST_SUPPORTED 0x00000020 +#define TDI_SERVICE_MULTICAST_SUPPORTED 0x00000040 +#define TDI_SERVICE_DELAYED_ACCEPTANCE 0x00000080 +#define TDI_SERVICE_EXPEDITED_DATA 0x00000100 +#define TDI_SERVICE_INTERNAL_BUFFERING 0x00000200 +#define TDI_SERVICE_ROUTE_DIRECTED 0x00000400 +#define TDI_SERVICE_NO_ZERO_LENGTH 0x00000800 +#define TDI_SERVICE_POINT_TO_POINT 0x00001000 +#define TDI_SERVICE_MESSAGE_MODE 0x00002000 +#define TDI_SERVICE_HALF_DUPLEX 0x00004000 + +typedef struct _TDI_PROVIDER_RESOURCE_STATS +{ + ULONG ResourceId; + ULONG MaximumResourceUsed; + ULONG AverageResourceUsed; + ULONG ResourceExhausted; +} TDI_PROVIDER_RESOURCE_STATS, *PTDI_PROVIDER_RESOURCE_STATS; + +typedef struct _TDI_PROVIDER_STATISTICS +{ + ULONG Version; + ULONG OpenConnections; + ULONG ConnectionsAfterNoRetry; + ULONG ConnectionsAfterRetry; + ULONG LocalDisconnects; + ULONG RemoteDisconnects; + ULONG LinkFailures; + ULONG AdapterFailures; + ULONG SessionTimeouts; + ULONG CancelledConnections; + ULONG RemoteResourceFailures; + ULONG LocalResourceFailures; + ULONG NotFoundFailures; + ULONG NoListenFailures; + ULONG DatagramsSent; + LARGE_INTEGER DatagramBytesSent; + ULONG DatagramsReceived; + LARGE_INTEGER DatagramBytesReceived; + ULONG PacketsSent; + ULONG PacketsReceived; + ULONG DataFramesSent; + LARGE_INTEGER DataFrameBytesSent; + ULONG DataFramesReceived; + LARGE_INTEGER DataFrameBytesReceived; + ULONG DataFramesResent; + LARGE_INTEGER DataFrameBytesResent; + ULONG DataFramesRejected; + LARGE_INTEGER DataFrameBytesRejected; + ULONG ResponseTimerExpirations; + ULONG AckTimerExpirations; + ULONG MaximumSendWindow; + ULONG AverageSendWindow; + ULONG PiggybackAckQueued; + ULONG PiggybackAckTimeouts; + LARGE_INTEGER WastedPacketSpace; + ULONG WastedSpacePackets; + ULONG NumberOfResources; + TDI_PROVIDER_RESOURCE_STATS Resources[1]; +} TDI_PROVIDER_STATISTICS, *PTDI_PROVIDER_STATISTICS; + +#endif /* __TDI_H */ + +/* EOF */ diff --git a/reactos/include/net/tdiinfo.h b/reactos/include/net/tdiinfo.h new file mode 100644 index 00000000000..c8d0826b863 --- /dev/null +++ b/reactos/include/net/tdiinfo.h @@ -0,0 +1,96 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS TDI library + * FILE: include/net/tdiinfo.h + * PURPOSE: TDI definitions for Tdi(Query/Set)InformationEx + */ +#ifndef __TDIINFO_H +#define __TDIINFO_H + +typedef struct TDIEntityID +{ + ULONG tei_entity; + ULONG tei_instance; +} TDIEntityID; + +typedef struct TDIObjectID +{ + TDIEntityID toi_entity; + ULONG toi_class; + ULONG toi_type; + ULONG toi_id; +} TDIObjectID; + +#define CONTEXT_SIZE 16 + +#define MAX_TDI_ENTITIES 512 + +#define INFO_CLASS_GENERIC 0x100 +#define INFO_CLASS_PROTOCOL 0x200 +#define INFO_CLASS_IMPLEMENTATION 0x300 + +#define INFO_TYPE_PROVIDER 0x100 +#define INFO_TYPE_ADDRESS_OBJECT 0x200 +#define INFO_TYPE_CONNECTION 0x300 + + +#define ENTITY_LIST_ID 0 + +#define GENERIC_ENTITY 0 + + +#define IF_ENTITY 0x200 + +#define AT_ENTITY 0x280 + +#define CO_NL_ENTITY 0x300 +#define CL_NL_ENTITY 0x301 + +#define ER_ENTITY 0x380 + +#define CO_TL_ENTITY 0x400 +#define CL_TL_ENTITY 0x401 + + +/* IDs supported by all entities */ + +#define ENTITY_TYPE_ID 1 + + +#define IF_GENERIC 0x200 +#define IF_MIB 0x202 + +#define AT_ARP 0x280 +#define AT_NULL 0x282 + +#define CL_NL_IPX 0x301 +#define CL_NL_IP 0x303 + +#define ER_ICMP 0x380 + +#define CO_TL_NBF 0x400 +#define CO_TL_SPX 0x402 +#define CO_TL_TCP 0x404 +#define CO_TL_SPP 0x406 + +#define CL_TL_NBF 0x401 +#define CL_TL_UDP 0x403 + +/* TCP specific structures */ + +typedef struct _TCP_REQUEST_QUERY_INFORMATION_EX +{ + TDIObjectID ID; + UCHAR Context[CONTEXT_SIZE]; +} TCP_REQUEST_QUERY_INFORMATION_EX, *PTCP_REQUEST_QUERY_INFORMATION_EX; + +typedef struct _TCP_REQUEST_SET_INFORMATION_EX +{ + TDIObjectID ID; + UINT BufferSize; + UCHAR Buffer[1]; +} TCP_REQUEST_SET_INFORMATION_EX, *PTCP_REQUEST_SET_INFORMATION_EX; + +#endif /* __TDIINFO_H */ + +/* EOF */ diff --git a/reactos/include/net/tdikrnl.h b/reactos/include/net/tdikrnl.h new file mode 100644 index 00000000000..a88a04d23df --- /dev/null +++ b/reactos/include/net/tdikrnl.h @@ -0,0 +1,805 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS TDI library + * FILE: include/net/tdikrnl.h + * PURPOSE: TDI definitions for kernel mode drivers + */ +#ifndef __TDIKRNL_H +#define __TDIKRNL_H + +#include "tdi.h" + +#ifndef STDCALL +#define STDCALL +#endif + +typedef struct _TDI_REQUEST_KERNEL +{ + ULONG RequestFlags; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; + PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; + PVOID RequestSpecific; +} TDI_REQUEST_KERNEL, *PTDI_REQUEST_KERNEL; + +/* Request codes */ +#define TDI_ASSOCIATE_ADDRESS 0x01 +#define TDI_DISASSOCIATE_ADDRESS 0x02 +#define TDI_CONNECT 0x03 +#define TDI_LISTEN 0x04 +#define TDI_ACCEPT 0x05 +#define TDI_DISCONNECT 0x06 +#define TDI_SEND 0x07 +#define TDI_RECEIVE 0x08 +#define TDI_SEND_DATAGRAM 0x09 +#define TDI_RECEIVE_DATAGRAM 0x0A +#define TDI_SET_EVENT_HANDLER 0x0B +#define TDI_QUERY_INFORMATION 0x0C +#define TDI_SET_INFORMATION 0x0D +#define TDI_ACTION 0x0E + +#define TDI_DIRECT_SEND 0x27 +#define TDI_DIRECT_SEND_DATAGRAM 0x29 + + +#define TDI_TRANSPORT_ADDRESS_FILE 1 +#define TDI_CONNECTION_FILE 2 +#define TDI_CONTROL_CHANNEL_FILE 3 + +/* Internal TDI IOCTLS */ +#define IOCTL_TDI_QUERY_DIRECT_SEND_HANDLER TDI_CONTROL_CODE(0x80, METHOD_NEITHER) +#define IOCTL_TDI_QUERY_DIRECT_SENDDG_HANDLER TDI_CONTROL_CODE(0x81, METHOD_NEITHER) + +/* TdiAssociateAddress */ +typedef struct _TDI_REQUEST_KERNEL_ASSOCIATE +{ + HANDLE AddressHandle; +} TDI_REQUEST_KERNEL_ASSOCIATE, *PTDI_REQUEST_KERNEL_ASSOCIATE; + +/* TdiDisassociateAddress */ +typedef TDI_REQUEST_KERNEL TDI_REQUEST_KERNEL_DISASSOCIATE, + *PTDI_REQUEST_KERNEL_DISASSOCIATE; + +/* TdiAccept */ +typedef struct _TDI_REQUEST_KERNEL_ACCEPT +{ + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; + PTDI_CONNECTION_INFORMATION ReturnConnectionInformation; +} TDI_REQUEST_KERNEL_ACCEPT, *PTDI_REQUEST_KERNEL_ACCEPT; + +/* TdiReceive */ +typedef struct _TDI_REQUEST_KERNEL_RECEIVE +{ + ULONG ReceiveLength; + ULONG ReceiveFlags; +} TDI_REQUEST_KERNEL_RECEIVE, *PTDI_REQUEST_KERNEL_RECEIVE; + +/* TdiReceiveDatagram */ +typedef struct _TDI_REQUEST_KERNEL_RECEIVEDG +{ + ULONG ReceiveLength; + PTDI_CONNECTION_INFORMATION ReceiveDatagramInformation; + PTDI_CONNECTION_INFORMATION ReturnDatagramInformation; + ULONG ReceiveFlags; +} TDI_REQUEST_KERNEL_RECEIVEDG, *PTDI_REQUEST_KERNEL_RECEIVEDG; + +/* TdiSend */ +typedef struct _TDI_REQUEST_KERNEL_SEND +{ + ULONG SendLength; + ULONG SendFlags; +} TDI_REQUEST_KERNEL_SEND, *PTDI_REQUEST_KERNEL_SEND; + +/* TdiSendDatagram */ +typedef struct _TDI_REQUEST_KERNEL_SENDDG +{ + ULONG SendLength; + PTDI_CONNECTION_INFORMATION SendDatagramInformation; +} TDI_REQUEST_KERNEL_SENDDG, *PTDI_REQUEST_KERNEL_SENDDG; + +/* TdiSetEventHandler */ +typedef struct _TDI_REQUEST_KERNEL_SET_EVENT +{ + LONG EventType; + PVOID EventHandler; + PVOID EventContext; +} TDI_REQUEST_KERNEL_SET_EVENT, *PTDI_REQUEST_KERNEL_SET_EVENT; + +/* TdiQueryInformation */ +typedef struct _TDI_REQUEST_KERNEL_QUERY_INFO +{ + LONG QueryType; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; +} TDI_REQUEST_KERNEL_QUERY_INFORMATION, *PTDI_REQUEST_KERNEL_QUERY_INFORMATION; + +/* TdiSetInformation */ +typedef struct _TDI_REQUEST_KERNEL_SET_INFO +{ + LONG SetType; + PTDI_CONNECTION_INFORMATION RequestConnectionInformation; +} TDI_REQUEST_KERNEL_SET_INFORMATION, *PTDI_REQUEST_KERNEL_SET_INFORMATION; + + +/* Event types */ +#define TDI_EVENT_CONNECT 0 +#define TDI_EVENT_DISCONNECT 1 +#define TDI_EVENT_ERROR 2 +#define TDI_EVENT_RECEIVE 3 +#define TDI_EVENT_RECEIVE_DATAGRAM 4 +#define TDI_EVENT_RECEIVE_EXPEDITED 5 +#define TDI_EVENT_SEND_POSSIBLE 6 +#define TDI_EVENT_CHAINED_RECEIVE 7 +#define TDI_EVENT_CHAINED_RECEIVE_DATAGRAM 8 +#define TDI_EVENT_CHAINED_RECEIVE_EXPEDITED 9 + +typedef NTSTATUS (*PTDI_IND_CONNECT)( + IN PVOID TdiEventContext, + IN LONG RemoteAddressLength, + IN PVOID RemoteAddress, + IN LONG UserDataLength, + IN PVOID UserData, + IN LONG OptionsLength, + IN PVOID Options, + OUT CONNECTION_CONTEXT *ConnectionContext, + OUT PIRP *AcceptIrp); + +NTSTATUS STDCALL TdiDefaultConnectHandler( + IN PVOID TdiEventContext, + IN LONG RemoteAddressLength, + IN PVOID RemoteAddress, + IN LONG UserDataLength, + IN PVOID UserData, + IN LONG OptionsLength, + IN PVOID Options, + OUT CONNECTION_CONTEXT *ConnectionContext, + OUT PIRP *AcceptIrp); + +typedef NTSTATUS (*PTDI_IND_DISCONNECT)( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN LONG DisconnectDataLength, + IN PVOID DisconnectData, + IN LONG DisconnectInformationLength, + IN PVOID DisconnectInformation, + IN ULONG DisconnectFlags); + +NTSTATUS STDCALL TdiDefaultDisconnectHandler( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN LONG DisconnectDataLength, + IN PVOID DisconnectData, + IN LONG DisconnectInformationLength, + IN PVOID DisconnectInformation, + IN ULONG DisconnectFlags); + +typedef NTSTATUS (*PTDI_IND_ERROR)( + IN PVOID TdiEventContext, + IN NTSTATUS Status); + +NTSTATUS STDCALL TdiDefaultErrorHandler( + IN PVOID TdiEventContext, + IN NTSTATUS Status); + +typedef NTSTATUS (*PTDI_IND_RECEIVE)( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +NTSTATUS STDCALL TdiDefaultReceiveHandler( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +typedef NTSTATUS (*PTDI_IND_RECEIVE_DATAGRAM)( + IN PVOID TdiEventContext, + IN LONG SourceAddressLength, + IN PVOID SourceAddress, + IN LONG OptionsLength, + IN PVOID Options, + IN ULONG ReceiveDatagramFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +NTSTATUS STDCALL TdiDefaultRcvDatagramHandler( + IN PVOID TdiEventContext, + IN LONG SourceAddressLength, + IN PVOID SourceAddress, + IN LONG OptionsLength, + IN PVOID Options, + IN ULONG ReceiveDatagramFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +typedef NTSTATUS (*PTDI_IND_RECEIVE_EXPEDITED)( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +NTSTATUS STDCALL TdiDefaultRcvExpeditedHandler( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG BytesIndicated, + IN ULONG BytesAvailable, + OUT ULONG *BytesTaken, + IN PVOID Tsdu, + OUT PIRP *IoRequestPacket); + +typedef NTSTATUS (*PTDI_IND_CHAINED_RECEIVE)( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG ReceiveLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +NTSTATUS STDCALL TdiDefaultChainedReceiveHandler( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG ReceiveLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +typedef NTSTATUS (*PTDI_IND_CHAINED_RECEIVE_DATAGRAM)( + IN PVOID TdiEventContext, + IN LONG SourceAddressLength, + IN PVOID SourceAddress, + IN LONG OptionsLength, + IN PVOID Options, + IN ULONG ReceiveDatagramFlags, + IN ULONG ReceiveDatagramLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +NTSTATUS STDCALL TdiDefaultChainedRcvDatagramHandler( + IN PVOID TdiEventContext, + IN LONG SourceAddressLength, + IN PVOID SourceAddress, + IN LONG OptionsLength, + IN PVOID Options, + IN ULONG ReceiveDatagramFlags, + IN ULONG ReceiveDatagramLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +typedef NTSTATUS (*PTDI_IND_CHAINED_RECEIVE_EXPEDITED)( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG ReceiveLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +NTSTATUS STDCALL TdiDefaultChainedRcvExpeditedHandler( + IN PVOID TdiEventContext, + IN CONNECTION_CONTEXT ConnectionContext, + IN ULONG ReceiveFlags, + IN ULONG ReceiveLength, + IN ULONG StartingOffset, + IN PMDL Tsdu, + IN PVOID TsduDescriptor); + +typedef NTSTATUS (*PTDI_IND_SEND_POSSIBLE)( + IN PVOID TdiEventContext, + IN PVOID ConnectionContext, + IN ULONG BytesAvailable); + +NTSTATUS STDCALL TdiDefaultSendPossibleHandler( + IN PVOID TdiEventContext, + IN PVOID ConnectionContext, + IN ULONG BytesAvailable); + + + +/* Macros and functions to build IRPs */ + +#define TdiBuildBaseIrp( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, IrpSp, Minor) \ +{ \ + IrpSp = IoGetNextIrpStackLocation(Irp); \ + IrpSp->MajorFunction = IRP_MJ_INTERNAL_DEVICE_CONTROL; \ + IrpSp->MinorFunction = (Minor); \ + IrpSp->DeviceObject = (DevObj); \ + IrpSp->FileObject = (FileObj); \ + \ + if (CompRoutine) \ + IoSetCompletionRoutine(Irp, CompRoutine, Contxt, TRUE, TRUE, TRUE) \ + else \ + IoSetCompletionRoutine(Irp, NULL, NULL, FALSE, FALSE, FALSE); \ +} + +/* + * VOID TdiBuildAccept( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo, + * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo); + */ +#define TdiBuildAccept( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + RequestConnectionInfo, ReturnConnectionInfo) \ + { \ + PTDI_REQUEST_KERNEL_ACCEPT _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_ACCEPT); \ + \ + _Request = (PTDI_REQUEST_KERNEL_ACCEPT)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = (RequestConnectionInfo); \ + _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \ +} + +/* + * VOID TdiBuildAction( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PMDL MdlAddr); + */ +#define TdiBuildAction( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr) \ +{ \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_ACTION); \ + \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildAssociateAddress( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN HANDLE AddrHandle); + */ +#define TdiBuildAssociateAddress( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, AddrHandle) \ +{ \ + PTDI_REQUEST_KERNEL_ASSOCIATE _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_ASSOCIATE_ADDRESS); \ + \ + _Request = (PTDI_REQUEST_KERNEL_ASSOCIATE)&_IrpSp->Parameters; \ + _Request->AddressHandle = (HANDLE)(AddrHandle); \ +} + +/* + * VOID TdiBuildConnect( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PLARGE_INTEGER Time, + * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo, + * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo); + */ +#define TdiBuildConnect( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + Time, RequestConnectionInfo, ReturnConnectionInfo) \ +{ \ + PTDI_REQUEST_KERNEL _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_CONNECT); \ + \ + _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = (RequestConnectionInfo); \ + _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \ + _Request->RequestSpecific = (PVOID)(Time); \ +} + +/* + * VOID TdiBuildDisassociateAddress( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt); + */ +#define TdiBuildDisassociateAddress( \ + Irp, DevObj, FileObj, CompRoutine, Contxt) \ +{ \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_DISASSOCIATE_ADDRESS); \ +} + +/* + * VOID TdiBuildDisconnect( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PLARGE_INTEGER Time, + * IN PULONG Flags, + * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo, + * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo); + */ +#define TdiBuildDisconnect( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, Time, \ + Flags, RequestConnectionInfo, ReturnConnectionInfo) \ +{ \ + PTDI_REQUEST_KERNEL _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_DISCONNECT); \ + \ + _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = (RequestConnectionInfo); \ + _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \ + _Request->RequestSpecific = (PVOID)(Time); \ + _Request->RequestFlags = (Flags); \ +} + +/* + * PIRP TdiBuildInternalDeviceControlIrp( + * IN CCHAR IrpSubFunction, + * IN PDEVICE_OBJECT DeviceObject, + * IN PFILE_OBJECT FileObject, + * IN PKEVENT Event, + * IN PIO_STATUS_BLOCK IoStatusBlock); + */ +#define TdiBuildInternalDeviceControlIrp( \ + IrpSubFunction, DeviceObject, \ + FileObject, Event, IoStatusBlock) \ + IoBuildDeviceIoControlRequest( \ + 0x00000003, DeviceObject, \ + NULL, 0, NULL, 0, \ + TRUE, Event, IoStatusBlock) + +/* + * VOID TdiBuildListen( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN ULONG Flags, + * IN PTDI_CONNECTION_INFORMATION RequestConnectionInfo, + * OUT PTDI_CONNECTION_INFORMATION ReturnConnectionInfo); + */ +#define TdiBuildListen( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + Flags, RequestConnectionInfo, ReturnConnectionInfo) \ +{ \ + PTDI_REQUEST_KERNEL _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_LISTEN); \ + \ + _Request = (PTDI_REQUEST_KERNEL)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = (RequestConnectionInfo); \ + _Request->ReturnConnectionInformation = (ReturnConnectionInfo); \ + _Request->RequestFlags = (Flags); \ +} + +VOID STDCALL TdiBuildNetbiosAddress( + IN PUCHAR NetbiosName, + IN BOOLEAN IsGroupName, + IN OUT PTA_NETBIOS_ADDRESS NetworkName); + +NTSTATUS STDCALL TdiBuildNetbiosAddressEa( + IN PUCHAR Buffer, + IN BOOLEAN IsGroupName, + IN PUCHAR NetbiosName); + +/* + * VOID TdiBuildQueryInformation( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN UINT QType, + * IN PMDL MdlAddr); + */ +#define TdiBuildQueryInformation( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, QType, MdlAddr) \ +{ \ + PTDI_REQUEST_KERNEL_QUERY_INFORMATION _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_QUERY_INFORMATION); \ + \ + _Request = (PTDI_REQUEST_KERNEL_QUERY_INFORMATION)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = NULL; \ + _Request->QueryType = (ULONG)(QType); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildReceive( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PMDL MdlAddr, + * IN ULONG InFlags, + * IN ULONG ReceiveLen); + */ +#define TdiBuildReceive( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + MdlAddr, InFlags, ReceiveLen) \ +{ \ + PTDI_REQUEST_KERNEL_RECEIVE _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_RECEIVE); \ + \ + _Request = (PTDI_REQUEST_KERNEL_RECEIVE)&_IrpSp->Parameters; \ + _Request->ReceiveFlags = (InFlags); \ + _Request->ReceiveLength = (ReceiveLen); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildReceiveDatagram( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PMDL MdlAddr, + * IN ULONG ReceiveLen, + * IN PTDI_CONNECTION_INFORMATION ReceiveDatagramInfo, + * OUT PTDI_CONNECTION_INFORMATION ReturnInfo, + * ULONG InFlags); + */ +#define TdiBuildReceiveDatagram( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, MdlAddr, \ + ReceiveLen, ReceiveDatagramInfo, ReturnInfo, InFlags) \ +{ \ + PTDI_REQUEST_KERNEL_RECEIVEDG _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_RECEIVE_DATAGRAM); \ + \ + _Request = (PTDI_REQUEST_KERNEL_RECEIVEDG)&_IrpSp->Parameters; \ + _Request->ReceiveDatagramInformation = (ReceiveDatagramInfo); \ + _Request->ReturnDatagramInformation = (ReturnInfo); \ + _Request->ReceiveLength = (ReceiveLen); \ + _Request->ReceiveFlags = (InFlags); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildSend( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PMDL MdlAddr, + * IN ULONG InFlags, + * IN ULONG SendLen); + */ +#define TdiBuildSend( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + MdlAddr, InFlags, SendLen) \ +{ \ + PTDI_REQUEST_KERNEL_SEND _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_SEND); \ + \ + _Request = (PTDI_REQUEST_KERNEL_SEND)&_IrpSp->Parameters; \ + _Request->SendFlags = (InFlags); \ + _Request->SendLength = (SendLen); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildSendDatagram( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN PMDL MdlAddr, + * IN ULONG SendLen, + * IN PTDI_CONNECTION_INFORMATION SendDatagramInfo); + */ +#define TdiBuildSendDatagram( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + MdlAddr, SendLen, SendDatagramInfo) \ +{ \ + PTDI_REQUEST_KERNEL_SENDDG _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_SEND_DATAGRAM); \ + \ + _Request = (PTDI_REQUEST_KERNEL_SENDDG)&_IrpSp->Parameters; \ + _Request->SendDatagramInformation = (SendDatagramInfo); \ + _Request->SendLength = (SendLen); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + +/* + * VOID TdiBuildSetEventHandler( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN INT InEventType, + * IN PVOID InEventHandler, + * IN PVOID InEventContext); + */ +#define TdiBuildSetEventHandler( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, \ + InEventType, InEventHandler, InEventContext) \ +{ \ + PTDI_REQUEST_KERNEL_SET_EVENT _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_SET_EVENT_HANDLER); \ + \ + _Request = (PTDI_REQUEST_KERNEL_SET_EVENT)&_IrpSp->Parameters; \ + _Request->EventType = (InEventType); \ + _Request->EventHandler = (PVOID)(InEventHandler); \ + _Request->EventContext = (PVOID)(InEventContext); \ +} + +/* + * VOID TdiBuildSetInformation( + * IN PIRP Irp, + * IN PDEVICE_OBJECT DevObj, + * IN PFILE_OBJECT FileObj, + * IN PVOID CompRoutine, + * IN PVOID Contxt, + * IN UINT SType, + * IN PMDL MdlAddr); + */ +#define TdiBuildSetInformation( \ + Irp, DevObj, FileObj, CompRoutine, Contxt, SType, MdlAddr) \ +{ \ + PTDI_REQUEST_KERNEL_SET_INFORMATION _Request; \ + PIO_STACK_LOCATION _IrpSp; \ + \ + _IrpSp = IoGetNextIrpStackLocation(Irp); \ + \ + TdiBuildBaseIrp(Irp, DevObj, FileObj, CompRoutine, \ + Contxt, _IrpSp, TDI_SET_INFORMATION); \ + \ + _Request = (PTDI_REQUEST_KERNEL_SET_INFORMATION)&_IrpSp->Parameters; \ + _Request->RequestConnectionInformation = NULL; \ + _Request->SetType = (ULONG)(SType); \ + (Irp)->MdlAddress = (MdlAddr); \ +} + + + +/* TDI functions */ + +/* + * VOID TdiCompleteRequest( + * IN PIRP Irp, + * IN NTSTATUS Status); + */ +#define TdiCompleteRequest(Irp, Status) \ +{ \ + (Irp)->IoStatus.Status = (Status); \ + IoCompleteRequest((Irp), IO_NETWORK_INCREMENT); \ +} + +NTSTATUS STDCALL TdiCopyBufferToMdl( + IN PVOID SourceBuffer, + IN ULONG SourceOffset, + IN ULONG SourceBytesToCopy, + IN PMDL DestinationMdlChain, + IN ULONG DestinationOffset, + IN PULONG BytesCopied); + +/* + * VOID TdiCopyLookaheadData( + * IN PVOID Destination, + * IN PVOID Source, + * IN ULONG Length, + * IN ULONG ReceiveFlags); + */ +#define TdiCopyLookaheadData(Destination, Source, Length, ReceiveFlags) \ + RtlCopyMemory(Destination, Source, Length) + +NTSTATUS STDCALL TdiCopyMdlToBuffer( + IN PMDL SourceMdlChain, + IN ULONG SourceOffset, + IN PVOID DestinationBuffer, + IN ULONG DestinationOffset, + IN ULONG DestinationBufferSize, + OUT PULONG BytesCopied); + +VOID STDCALL TdiMapBuffer( + IN PMDL MdlChain); + +NTSTATUS STDCALL TdiMapUserRequest( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp, + IN PIO_STACK_LOCATION IrpSp); + +VOID STDCALL TdiReturnChainedReceives( + IN PVOID *TsduDescriptors, + IN ULONG NumberOfTsdus); + +VOID STDCALL TdiUnmapBuffer( + IN PMDL MdlChain); + +#endif /* __TDIKRNL_H */ + +/* EOF */