ReactOS 0.4.15-dev-8127-g6338913
lan.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/lan.h
5 * PURPOSE: LAN adapter definitions
6 */
7
8#pragma once
9
10/* NDIS version this driver supports */
11#define NDIS_VERSION_MAJOR 4
12#define NDIS_VERSION_MINOR 0
13
14/* Macros */
15
16#define MIN(value1, value2) \
17 ((value1 < value2)? value1 : value2)
18
19#define MAX(value1, value2) \
20 ((value1 > value2)? value1 : value2)
21
22#define NDIS_BUFFER_TAG FOURCC('n','b','u','f')
23#define NDIS_PACKET_TAG FOURCC('n','p','k','t')
24
25/* Media we support */
26#define MEDIA_ETH 0
27
28#define MAX_MEDIA 1
29
30#define IEEE_802_ADDR_LENGTH 6
31
32/* Ethernet header layout */
33typedef struct ETH_HEADER {
34 UCHAR DstAddr[IEEE_802_ADDR_LENGTH]; /* Destination MAC address */
35 UCHAR SrcAddr[IEEE_802_ADDR_LENGTH]; /* Source MAC address */
36 USHORT EType; /* Ethernet protocol type */
38
39#define MAX_MEDIA_ETH sizeof(ETH_HEADER)
40
41/* Broadcast masks */
42#define BCAST_ETH_MASK 0x01
43
44/* Broadcast values to check against */
45#define BCAST_ETH_CHECK 0x01
46
47/* Offset of broadcast address */
48#define BCAST_ETH_OFFSET 0x00
49
50typedef struct _LAN_ADDRESS_C {
54
55/* Per adapter information */
56typedef struct LAN_ADAPTER {
57 LIST_ENTRY ListEntry; /* Entry on list */
58 LIST_ENTRY AddressList; /* Addresses associated */
59 LIST_ENTRY ForeignList; /* List of known addresses */
60 KSPIN_LOCK Lock; /* Lock for this structure */
61 UINT Index; /* Adapter Index */
62 UCHAR State; /* State of the adapter */
63 KEVENT Event; /* Opening event */
64 PVOID Context; /* Upper layer context information */
65 NDIS_HANDLE NdisHandle; /* NDIS binding handle */
66 NDIS_STATUS NdisStatus; /* NDIS status of last request */
67 NDIS_MEDIUM Media; /* Media type */
68 UCHAR HWAddress[IEEE_802_ADDR_LENGTH]; /* Local HW address */
69 UINT HWAddressLength; /* Length of HW address */
70 UCHAR BCastMask; /* Mask for checking broadcast */
71 UCHAR BCastCheck; /* Value to check against */
72 UCHAR BCastOffset; /* Offset in frame to check against */
73 UCHAR HeaderSize; /* Size of link-level header */
74 USHORT MTU; /* Maximum Transfer Unit */
75 UINT MinFrameSize; /* Minimum frame size in bytes */
76 UINT MaxPacketSize; /* Maximum packet size when sending */
77 UINT MaxSendPackets; /* Maximum number of packets per send */
78 UINT MacOptions; /* MAC options for NIC driver/adapter */
79 UINT Speed; /* Link speed */
80 UINT PacketFilter; /* Packet filter for this adapter */
81 UINT Lookahead; /* Lookahead for adapter */
82 UNICODE_STRING RegistryPath; /* Registry path for later query */
84
85typedef struct _LAN_PACKET {
90
91typedef struct _LAN_PROTOCOL {
100
101typedef struct _LAN_DEVICE_EXT {
109
110/* LAN adapter state constants */
111#define LAN_STATE_OPENING 0
112#define LAN_STATE_RESETTING 1
113#define LAN_STATE_STARTED 2
114#define LAN_STATE_STOPPED 3
115
116/* Size of out lookahead buffer */
117#define LOOKAHEAD_SIZE 128
118
119/* Ethernet types. We swap constants so we can compare values at runtime
120 without swapping them there */
121#define ETYPE_IPv4 WH2N(0x0800)
122#define ETYPE_IPv6 WH2N(0x86DD)
123#define ETYPE_ARP WH2N(0x0806)
124
125/* Protocols */
126#define LAN_PROTO_IPv4 0x0000 /* Internet Protocol version 4 */
127#define LAN_PROTO_IPv6 0x0001 /* Internet Protocol version 6 */
128#define LAN_PROTO_ARP 0x0002 /* Address Resolution Protocol */
129
130
134
136
138
140
142 PLAN_ADAPTER Adapter,
146 UINT Length);
147
149 UINT Offset,
150 PCHAR *DataOut,
151 PUINT Size );
152
155 PCHAR File, UINT Line );
156
158
161
163
164/* EOF */
Type
Definition: Type.h:7
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
Definition: File.h:16
#define Len
Definition: deflate.h:82
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
struct ETH_HEADER * PETH_HEADER
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
Definition: routines.c:65
struct _LAN_ADDRESS_C LAN_ADDRESS_C
struct _LAN_PROTOCOL * PLAN_PROTOCOL
NDIS_STATUS AllocatePacketWithBufferX(PNDIS_PACKET *NdisPacket, PCHAR Data, UINT Len, PCHAR File, UINT Line)
Definition: routines.c:82
struct _LAN_ADDRESS_C * PLAN_ADDRESS_C
PLAN_ADAPTER FindAdapterByIndex(PLAN_DEVICE_EXT DeviceExt, UINT Index)
Definition: lan.c:1073
struct _LAN_PACKET LAN_PACKET
struct LAN_ADAPTER LAN_ADAPTER
VOID LANUnregisterProtocol(VOID)
Unregisters this protocol driver with NDIS.
Definition: lan.c:943
struct _LAN_DEVICE_EXT * PLAN_DEVICE_EXT
struct _LAN_DEVICE_EXT LAN_DEVICE_EXT
struct LAN_ADAPTER * PLAN_ADAPTER
NDIS_STATUS LANRegisterAdapter(PNDIS_STRING AdapterName, PNDIS_STRING RegistryPath)
Registers protocol with an NDIS adapter.
Definition: lan.c:637
NDIS_STATUS LANUnregisterAdapter(PLAN_ADAPTER Adapter)
Unregisters protocol with NDIS adapter.
Definition: lan.c:847
NTSTATUS LANRegisterProtocol(PNDIS_STRING Name)
Registers this protocol driver with NDIS.
Definition: lan.c:893
struct ETH_HEADER ETH_HEADER
struct _LAN_PACKET * PLAN_PACKET
struct _LAN_PROTOCOL LAN_PROTOCOL
NDIS_STATUS NDISCall(PLAN_ADAPTER Adapter, NDIS_REQUEST_TYPE Type, NDIS_OID OID, PVOID Buffer, UINT Length)
Send a request to NDIS.
Definition: lan.c:29
VOID FreeNdisPacketX(PNDIS_PACKET Packet, PCHAR File, UINT Line)
Definition: routines.c:118
NDIS_STATUS InitNdisPools()
Definition: routines.c:6
VOID CloseNdisPools()
Definition: routines.c:19
UINT64 OID
Definition: marshal.c:88
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
unsigned int * PUINT
Definition: ndis.h:50
unsigned int UINT
Definition: ndis.h:50
enum _NDIS_REQUEST_TYPE NDIS_REQUEST_TYPE
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:6016
enum _NDIS_MEDIUM NDIS_MEDIUM
int NDIS_STATUS
Definition: ntddndis.h:475
ULONG NDIS_OID
Definition: ntddndis.h:230
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
unsigned short USHORT
Definition: pedump.c:61
Definition: lan.h:33
UCHAR SrcAddr[IEEE_802_ADDR_LENGTH]
Definition: lan.h:35
USHORT EType
Definition: lan.h:36
UCHAR DstAddr[IEEE_802_ADDR_LENGTH]
Definition: lan.h:34
UINT PacketFilter
Definition: lan.h:80
LIST_ENTRY ForeignList
Definition: lan.h:59
PVOID Context
Definition: lan.h:64
UINT MinFrameSize
Definition: lan.h:75
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]
Definition: lan.h:68
UNICODE_STRING RegistryPath
Definition: lan.h:82
KSPIN_LOCK Lock
Definition: lan.h:60
LIST_ENTRY AddressList
Definition: lan.h:58
UCHAR HeaderSize
Definition: lan.h:73
USHORT MTU
Definition: lan.h:74
KEVENT Event
Definition: lan.h:63
UCHAR State
Definition: lan.h:62
NDIS_STATUS NdisStatus
Definition: lan.h:66
UINT Index
Definition: lan.h:61
UINT HWAddressLength
Definition: lan.h:69
UINT MacOptions
Definition: lan.h:78
UINT Lookahead
Definition: lan.h:81
LIST_ENTRY ListEntry
Definition: lan.h:57
NDIS_HANDLE NdisHandle
Definition: lan.h:65
UINT MaxSendPackets
Definition: lan.h:77
UCHAR BCastMask
Definition: lan.h:70
UCHAR BCastCheck
Definition: lan.h:71
NDIS_MEDIUM Media
Definition: lan.h:67
UCHAR BCastOffset
Definition: lan.h:72
UINT Speed
Definition: lan.h:79
UINT MaxPacketSize
Definition: lan.h:76
Definition: ncftp.h:79
LIST_ENTRY ListEntry
Definition: lan.h:51
LAN_ADDRESS ClientPart
Definition: lan.h:52
UINT ProtoId
Definition: lan.h:107
LIST_ENTRY AdapterListHead
Definition: lan.h:104
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
KSPIN_LOCK Lock
Definition: lan.h:103
UINT AdapterId
Definition: lan.h:106
LIST_ENTRY ProtocolListHead
Definition: lan.h:105
UINT TotalSize
Definition: lan.h:88
PETH_HEADER EthHeader
Definition: lan.h:87
PNDIS_PACKET NdisPacket
Definition: lan.h:86
UINT Buffered
Definition: lan.h:96
LIST_ENTRY ReadIrpListHead
Definition: lan.h:93
UINT Id
Definition: lan.h:94
UINT NumEtherTypes
Definition: lan.h:97
UINT LastServicePass
Definition: lan.h:95
USHORT EtherType[1]
Definition: lan.h:98
LIST_ENTRY ListEntry
Definition: lan.h:92
Definition: typedefs.h:120
#define IEEE_802_ADDR_LENGTH
Definition: lan.h:15
char * PCHAR
Definition: typedefs.h:51
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:215
unsigned char UCHAR
Definition: xmlstorage.h:181