xref: /reactos/drivers/network/lan/include/net_lan.h (revision 84ccccab)
1 #pragma once
2 
3 #include "net_wh.h"
4 
5 #define FSCTL_LAN_BASE FILE_DEVICE_NETWORK
6 #define _LAN_CONTROL_CODE(Function, Method) \
7     CTL_CODE(FSCTL_LAN_BASE, Function, Method, FILE_WRITE_ACCESS)
8 
9 #define LAN_ENUM_ADAPTERS         0
10 #define LAN_BUFFERED_MODE         1
11 #define LAN_ADAPTER_INFO          2
12 
13 #define IOCTL_IF_ENUM_ADAPTERS    \
14     _LAN_CONTROL_CODE(LAN_ENUM_ADAPTERS,METHOD_BUFFERED)
15 #define IOCTL_IF_BUFFERED_MODE    \
16     _LAN_CONTROL_CODE(LAN_BUFFERED_MODE,METHOD_BUFFERED)
17 #define IOCTL_IF_ADAPTER_INFO     \
18     _LAN_CONTROL_CODE(LAN_ADAPTER_INFO,METHOD_BUFFERED)
19 
20 typedef struct _LAN_PACKET_HEADER_T {
21     UINT  Adapter;
22     UINT  AddressType;
23     UINT  AddressLen;
24     UINT  PacketType;
25     PVOID Mdl;
26 } LAN_PACKET_HEADER_T, *PLAN_PACKET_HEADER_T;
27 
28 typedef struct _LAN_PACKET_HEADER {
29     LAN_PACKET_HEADER_T Fixed;
30     CHAR Address[1];
31 } LAN_PACKET_HEADER, *PLAN_PACKET_HEADER;
32 
33 typedef struct _LAN_ADDRESS {
34     UINT Adapter;
35     UINT Flags;
36     USHORT AddressType;
37     USHORT AddressLen;
38     USHORT HWAddressType;
39     USHORT HWAddressLen;
40     CHAR Address[1];
41 } LAN_ADDRESS, *PLAN_ADDRESS;
42 
43 typedef struct _LAN_ADAPTER_INFO_S {
44     UINT Index;
45     UINT Media;
46     UINT Speed;
47     USHORT AddressLen;
48     USHORT Overhead;
49     USHORT MTU;
50     USHORT RegKeySize;
51 } LAN_ADAPTER_INFO_S, *PLAN_ADAPTER_INFO_S;
52 
53 #define LAN_DATA_PTR(PH) \
54   ((PH)->Address + (PH)->Fixed.AddressLen)
55 #define LAN_ALLOC_SIZE(AddrLen,PayloadLen) \
56   (sizeof(LAN_PACKET_HEADER_T) + (AddrLen) + (PayloadLen))
57 #define LAN_PAYLOAD_SIZE(PH,Size) \
58   (Size - (PH)->Fixed.AddressLen - sizeof(LAN_PACKET_HEADER_T))
59 
60 #define LAN_ADDR_SIZE(AddrLen,HWAddrLen) \
61   (sizeof(LAN_ADDRESS) - 1 + (AddrLen) + (HWAddrLen))
62 #define LAN_ADDR_PTR(LA) \
63   ((LA)->Address)
64 #define LAN_HWADDR_PTR(LA) \
65   ((LA)->Address + (LA)->AddressLen)
66 
67 #define LAN_EA_INFO_SIZE(NumTypes) \
68   sizeof(FILE_FULL_EA_INFORMATION) + (6 + sizeof(USHORT) * NumTypes)
69 #define LAN_FILL_EA_INFO(Ea,NumTypes,Types) \
70   { \
71     RtlCopyMemory( (Ea)->EaName, "TYPES", 6 ); \
72     (Ea)->EaNameLength = 6; \
73     (Ea)->EaValueLength = sizeof(USHORT) * (NumTypes); \
74     RtlCopyMemory( (Ea)->EaName + (Ea)->EaNameLength, \
75 		   (Types), \
76 		   sizeof(USHORT) * (NumTypes) ); \
77   }
78