ReactOS  0.4.14-dev-57-g333b8f1
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 */
33 typedef 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 
50 typedef struct _LAN_ADDRESS_C {
54 
55 /* Per adapter information */
56 typedef 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 
85 typedef struct _LAN_PACKET {
90 
91 typedef struct _LAN_PROTOCOL {
100 
101 typedef 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,
144  NDIS_OID OID,
145  PVOID Buffer,
146  UINT Length);
147 
149  UINT Offset,
150  PCHAR *DataOut,
151  PUINT Size );
152 
154  PCHAR Data, UINT Len,
155  PCHAR File, UINT Line );
156 
158 
161 
163 
164 /* EOF */
UNICODE_STRING RegistryPath
Definition: lan.h:82
signed char * PCHAR
Definition: retypes.h:7
PVOID Context
Definition: lan.h:64
UINT PacketFilter
Definition: lan.h:80
KSPIN_LOCK Lock
Definition: lan.h:103
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
Type
Definition: Type.h:6
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1548
enum _NDIS_MEDIUM NDIS_MEDIUM
NDIS_HANDLE NdisProtocolHandle
Definition: lan.h:102
UINT AdapterId
Definition: lan.h:106
LIST_ENTRY ForeignList
Definition: lan.h:59
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
Definition: routines.c:65
LIST_ENTRY AdapterListHead
Definition: lan.h:104
UCHAR BCastOffset
Definition: lan.h:72
LONG NTSTATUS
Definition: precomp.h:26
ULONG NDIS_OID
Definition: ntddndis.h:230
UINT Speed
Definition: lan.h:79
UINT HWAddressLength
Definition: lan.h:69
NDIS_STATUS AllocatePacketWithBufferX(PNDIS_PACKET *NdisPacket, PCHAR Data, UINT Len, PCHAR File, UINT Line)
Definition: routines.c:82
PLAN_ADAPTER FindAdapterByIndex(PLAN_DEVICE_EXT DeviceExt, UINT Index)
Definition: lan.c:1073
LIST_ENTRY ListEntry
Definition: lan.h:51
PETH_HEADER EthHeader
Definition: lan.h:87
UINT MinFrameSize
Definition: lan.h:75
PNDIS_PACKET NdisPacket
Definition: lan.h:86
UCHAR SrcAddr[IEEE_802_ADDR_LENGTH]
Definition: lan.h:35
struct _LAN_ADDRESS_C * PLAN_ADDRESS_C
int NDIS_STATUS
Definition: ntddndis.h:471
LIST_ENTRY ProtocolListHead
Definition: lan.h:105
UINT Lookahead
Definition: lan.h:81
LIST_ENTRY AddressList
Definition: lan.h:58
LIST_ENTRY ListEntry
Definition: lan.h:57
UINT Buffered
Definition: lan.h:96
USHORT EtherType[1]
Definition: lan.h:98
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
Definition: lan.h:33
UCHAR BCastCheck
Definition: lan.h:71
UINT ProtoId
Definition: lan.h:107
USHORT MTU
Definition: lan.h:74
UCHAR BCastMask
Definition: lan.h:70
NDIS_STATUS NdisStatus
Definition: lan.h:66
LIST_ENTRY ListEntry
Definition: lan.h:92
struct _LAN_DEVICE_EXT LAN_DEVICE_EXT
UINT Index
Definition: lan.h:61
VOID CloseNdisPools(VOID)
UINT LastServicePass
Definition: lan.h:95
Definition: bufpool.h:45
struct _LAN_PROTOCOL * PLAN_PROTOCOL
UCHAR DstAddr[IEEE_802_ADDR_LENGTH]
Definition: lan.h:34
struct _LAN_PROTOCOL LAN_PROTOCOL
struct LAN_ADAPTER * PLAN_ADAPTER
NDIS_MEDIUM Media
Definition: lan.h:67
KSPIN_LOCK Lock
Definition: lan.h:60
static const UCHAR Index[8]
Definition: usbohci.c:18
UCHAR HeaderSize
Definition: lan.h:73
#define Len
Definition: deflate.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
UINT64 OID
Definition: marshal.c:88
UINT MacOptions
Definition: lan.h:78
Definition: ncftp.h:79
unsigned char UCHAR
Definition: xmlstorage.h:181
NDIS_STATUS LANRegisterAdapter(PNDIS_STRING AdapterName, PNDIS_STRING RegistryPath)
Registers protocol with an NDIS adapter.
Definition: lan.c:637
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
NDIS_HANDLE NdisHandle
Definition: lan.h:65
NDIS_STATUS LANUnregisterAdapter(PLAN_ADAPTER Adapter)
Unregisters protocol with NDIS adapter.
Definition: lan.c:847
NDIS_STATUS InitNdisPools(VOID)
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]
Definition: lan.h:68
KEVENT Event
Definition: lan.h:63
struct _LAN_PACKET * PLAN_PACKET
enum _NDIS_REQUEST_TYPE NDIS_REQUEST_TYPE
struct _LAN_DEVICE_EXT * PLAN_DEVICE_EXT
unsigned short USHORT
Definition: pedump.c:61
UCHAR State
Definition: lan.h:62
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
struct LAN_ADAPTER LAN_ADAPTER
unsigned int UINT
Definition: ndis.h:50
NTSTATUS LANRegisterProtocol(PNDIS_STRING Name)
Registers this protocol driver with NDIS.
Definition: lan.c:893
VOID FreeNdisPacketX(PNDIS_PACKET Packet, PCHAR File, UINT Line)
Definition: routines.c:118
LAN_ADDRESS ClientPart
Definition: lan.h:52
struct ETH_HEADER ETH_HEADER
#define IEEE_802_ADDR_LENGTH
Definition: lan.h:30
UINT Id
Definition: lan.h:94
UINT MaxSendPackets
Definition: lan.h:77
UINT TotalSize
Definition: lan.h:88
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
Definition: File.h:15
_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:6013
UINT NumEtherTypes
Definition: lan.h:97
struct _LAN_ADDRESS_C LAN_ADDRESS_C
struct _LAN_PACKET LAN_PACKET
VOID LANUnregisterProtocol(VOID)
Unregisters this protocol driver with NDIS.
Definition: lan.c:943
unsigned int * PUINT
Definition: ndis.h:50
struct ETH_HEADER * PETH_HEADER
LIST_ENTRY ReadIrpListHead
Definition: lan.h:93
USHORT EType
Definition: lan.h:36
UINT MaxPacketSize
Definition: lan.h:76