ReactOS  0.4.14-dev-606-g14ebc0b
info.c File Reference
#include "nic.h"
#include <debug.h>
Include dependency graph for info.c:

Go to the source code of this file.

Functions

NDIS_STATUS NTAPI MiniportQueryInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesWritten, OUT PULONG BytesNeeded)
 
NDIS_STATUS NTAPI MiniportSetInformation (IN NDIS_HANDLE MiniportAdapterContext, IN NDIS_OID Oid, IN PVOID InformationBuffer, IN ULONG InformationBufferLength, OUT PULONG BytesRead, OUT PULONG BytesNeeded)
 

Variables

static ULONG SupportedOidList []
 

Function Documentation

◆ MiniportQueryInformation()

NDIS_STATUS NTAPI MiniportQueryInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesWritten,
OUT PULONG  BytesNeeded 
)

Definition at line 51 of file info.c.

58 {
59  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
60  ULONG genericUlong;
61  ULONG copyLength;
62  PVOID copySource;
64 
66  copySource = &genericUlong;
67  copyLength = sizeof(ULONG);
68 
69  switch (Oid)
70  {
72  copySource = (PVOID)&SupportedOidList;
73  copyLength = sizeof(SupportedOidList);
74  break;
75 
77  genericUlong = Adapter->PacketFilter;
78  break;
79 
82  genericUlong = (ULONG)NdisHardwareStatusReady; //FIXME
83  break;
84 
87  {
88  static const NDIS_MEDIUM medium = NdisMedium802_3;
89  copySource = (PVOID)&medium;
90  copyLength = sizeof(medium);
91  break;
92  }
93 
99  genericUlong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
100  break;
101 
103  genericUlong = MAXIMUM_MULTICAST_ADDRESSES;
104  break;
105 
106  case OID_GEN_LINK_SPEED:
107  genericUlong = Adapter->LinkSpeedMbps * 10000;
108  break;
109 
111  genericUlong = MAXIMUM_FRAME_SIZE;
112  break;
113 
115  genericUlong = RECEIVE_BUFFER_SIZE;
116  break;
117 
118  case OID_GEN_VENDOR_ID:
119  /* The 3 bytes of the MAC address is the vendor ID */
120  genericUlong = 0;
121  genericUlong |= (Adapter->PermanentMacAddress[0] << 16);
122  genericUlong |= (Adapter->PermanentMacAddress[1] << 8);
123  genericUlong |= (Adapter->PermanentMacAddress[2] & 0xFF);
124  break;
125 
127  {
128  static UCHAR vendorDesc[] = "ReactOS Team";
129  copySource = vendorDesc;
130  copyLength = sizeof(vendorDesc);
131  break;
132  }
133 
135  genericUlong = DRIVER_VERSION;
136  break;
137 
139  {
140  static const USHORT driverVersion =
141  (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
142  copySource = (PVOID)&driverVersion;
143  copyLength = sizeof(driverVersion);
144  break;
145  }
146 
148  genericUlong = MAXIMUM_FRAME_SIZE;
149  break;
150 
152  genericUlong = 1;
153  break;
154 
155  case OID_GEN_MAC_OPTIONS:
156  genericUlong = NDIS_MAC_OPTION_RECEIVE_SERIALIZED |
160  break;
161 
163  genericUlong = Adapter->MediaState;
164  break;
165 
166 
168  copySource = Adapter->MulticastList[0].MacAddress;
169  copyLength = IEEE_802_ADDR_LENGTH;
170  break;
171 
173  copySource = Adapter->PermanentMacAddress;
174  copyLength = IEEE_802_ADDR_LENGTH;
175  break;
176 
177  case OID_GEN_XMIT_OK:
178  genericUlong = 0;
179  break;
180  case OID_GEN_RCV_OK:
181  genericUlong = 0;
182  break;
183  case OID_GEN_XMIT_ERROR:
184  genericUlong = 0;
185  break;
186  case OID_GEN_RCV_ERROR:
187  genericUlong = 0;
188  break;
190  genericUlong = 0;
191  break;
192 
193  default:
194  NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
196  break;
197  }
198 
200  {
201  if (copyLength > InformationBufferLength)
202  {
203  *BytesNeeded = copyLength;
204  *BytesWritten = 0;
206  }
207  else
208  {
209  NdisMoveMemory(InformationBuffer, copySource, copyLength);
210  *BytesWritten = copyLength;
211  *BytesNeeded = copyLength;
212  }
213  }
214  else
215  {
216  *BytesWritten = 0;
217  *BytesNeeded = 0;
218  }
219 
220  /* XMIT_ERROR and RCV_ERROR are really noisy, so do not log those. */
221  if (Oid != OID_GEN_XMIT_ERROR && Oid != OID_GEN_RCV_ERROR)
222  {
223  NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x(%s): Completed with status 0x%x (%d, %d)\n",
224  Oid, Oid2Str(Oid), status, *BytesWritten, *BytesNeeded));
225  }
226 
227  return status;
228 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesWritten
Definition: fltkernel.h:1293
static ULONG
Definition: info.c:26
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
enum _NDIS_MEDIUM NDIS_MEDIUM
#define DRIVER_VERSION
Definition: nic.h:22
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
struct _E1000_ADAPTER * PE1000_ADAPTER
static ULONG SupportedOidList[]
Definition: info.c:13
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
ULONG PacketFilter
Definition: nic.h:44
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
ULONG MediaState
Definition: nic.h:43
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
struct _ETH_HEADER ETH_HEADER
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
ULONG LinkSpeedMbps
Definition: nic.h:42
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
UCHAR PermanentMacAddress[IEEE_802_ADDR_LENGTH]
Definition: nic.h:37
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
struct _E1000_ADAPTER::@987 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
static PVOID
Definition: info.c:26
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define MAX_TRACE
Definition: debug.h:16
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
unsigned short USHORT
Definition: pedump.c:61
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
#define RECEIVE_BUFFER_SIZE
Definition: nic.h:20
#define UNIMPLEMENTED_DBGBREAK(...)
Definition: debug.h:57
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
static SERVICE_STATUS status
Definition: service.c:31
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
Definition: ps.c:97

Referenced by DriverEntry().

◆ MiniportSetInformation()

NDIS_STATUS NTAPI MiniportSetInformation ( IN NDIS_HANDLE  MiniportAdapterContext,
IN NDIS_OID  Oid,
IN PVOID  InformationBuffer,
IN ULONG  InformationBufferLength,
OUT PULONG  BytesRead,
OUT PULONG  BytesNeeded 
)

Definition at line 232 of file info.c.

239 {
240  PE1000_ADAPTER Adapter = (PE1000_ADAPTER)MiniportAdapterContext;
241  ULONG genericUlong;
243 
245 
246  switch (Oid)
247  {
249  if (InformationBufferLength < sizeof(ULONG))
250  {
251  *BytesRead = 0;
252  *BytesNeeded = sizeof(ULONG);
254  break;
255  }
256 
257  NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
258 
259  if (genericUlong &
266  {
267  *BytesRead = sizeof(ULONG);
268  *BytesNeeded = sizeof(ULONG);
270  break;
271  }
272 
273  Adapter->PacketFilter = genericUlong;
274 
275  status = NICApplyPacketFilter(Adapter);
277  {
278  NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter (0x%x)\n", status));
279  break;
280  }
281 
282  break;
283 
285  if (InformationBufferLength < sizeof(ULONG))
286  {
287  *BytesRead = 0;
288  *BytesNeeded = sizeof(ULONG);
290  break;
291  }
292 
293  NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
294 
295  if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
296  {
298  }
299  else
300  {
301  // Ignore this...
302  }
303 
304  break;
305 
307  if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
308  {
309  *BytesRead = 0;
310  *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
312  break;
313  }
314 
315  if (InformationBufferLength / 6 > MAXIMUM_MULTICAST_ADDRESSES)
316  {
318  *BytesRead = 0;
320  break;
321  }
322 
323  NdisMoveMemory(Adapter->MulticastList, InformationBuffer, InformationBufferLength);
324  NICUpdateMulticastList(Adapter);
325  break;
326 
327  default:
328  NDIS_DbgPrint(MIN_TRACE, ("Unknown OID 0x%x(%s)\n", Oid, Oid2Str(Oid)));
330  *BytesRead = 0;
331  *BytesNeeded = 0;
332  break;
333  }
334 
336  {
337  *BytesRead = InformationBufferLength;
338  *BytesNeeded = 0;
339  }
340 
341  return status;
342 }
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
static ULONG
Definition: info.c:26
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:752
struct _E1000_ADAPTER * PE1000_ADAPTER
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
ULONG PacketFilter
Definition: nic.h:44
Definition: lan.h:33
#define NDIS_PACKET_TYPE_SOURCE_ROUTING
Definition: ndis.h:667
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_PACKET_TYPE_GROUP
Definition: ndis.h:671
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
const char * Oid2Str(IN NDIS_OID Oid)
Definition: debug.c:12
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
struct _E1000_ADAPTER::@987 MulticastList[MAXIMUM_MULTICAST_ADDRESSES]
#define NDIS_PACKET_TYPE_SMT
Definition: ndis.h:669
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL
Definition: ndis.h:672
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICUpdateMulticastList(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:722
unsigned int ULONG
Definition: retypes.h:1
#define MIN_TRACE
Definition: debug.h:14
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define NDIS_PACKET_TYPE_ALL_LOCAL
Definition: ndis.h:670
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
static SERVICE_STATUS status
Definition: service.c:31
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
Definition: ps.c:97

Referenced by DriverEntry().

Variable Documentation

◆ SupportedOidList

ULONG SupportedOidList[]
static

Definition at line 13 of file info.c.

Referenced by MiniportQueryInformation().