ReactOS  0.4.15-dev-994-ga9f6032
requests.c File Reference
#include "pcnet.h"
#include <debug.h>
Include dependency graph for requests.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

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 MiniportOIDList []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 38 of file requests.c.

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 85 of file requests.c.

110 {
112  PVOID CopyFrom;
113  UINT CopySize;
114  ULONG GenericULONG;
115  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
116 
117  DPRINT("Called. OID 0x%x\n", Oid);
118 
119  ASSERT(Adapter);
120 
121  NdisAcquireSpinLock(&Adapter->Lock);
122 
124  CopyFrom = (PVOID)&GenericULONG;
125  CopySize = sizeof(ULONG);
126 
127  switch (Oid)
128  {
130  {
131  CopyFrom = (PVOID)&MiniportOIDList;
132  CopySize = sizeof(MiniportOIDList);
133  break;
134  }
135 
137  {
138  GenericULONG = (ULONG)NdisHardwareStatusReady;
139  break;
140  }
141 
144  {
145  static const NDIS_MEDIUM Medium = NdisMedium802_3;
146  CopyFrom = (PVOID)&Medium;
147  CopySize = sizeof(NDIS_MEDIUM);
148  break;
149  }
150 
153  {
154  GenericULONG = 1500;
155  break;
156  }
157 
159  {
160  /*
161  * The value returned by this OID must be equal to
162  * OID_GEN_MAXIMUM_TOTAL_SIZE - sizeof(ETHERNET_HEADER)
163  * where sizeof(ETHERNET_HEADER) is 14.
164  */
165  GenericULONG = 1500;
166  break;
167  }
168 
169  case OID_GEN_LINK_SPEED:
170  {
171  GenericULONG = Adapter->MediaSpeed * 10000;
172  break;
173  }
174 
176  {
177  /* XXX fix me */
178  GenericULONG = BUFFER_SIZE;
179  break;
180  }
181 
183  {
184  /* XXX fix me */
185  GenericULONG = BUFFER_SIZE;
186  break;
187  }
188 
190  {
191  GenericULONG = BUFFER_SIZE;
192  break;
193  }
194 
196  {
197  GenericULONG = BUFFER_SIZE;
198  break;
199  }
200 
201  case OID_GEN_VENDOR_ID:
202  {
203  UCHAR *CharPtr = (UCHAR *)&GenericULONG;
204  GenericULONG = 0;
205  /* Read the first three bytes of the permanent MAC address */
206  NdisRawReadPortUchar(Adapter->PortOffset, CharPtr);
207  NdisRawReadPortUchar(Adapter->PortOffset + 1, CharPtr + 1);
208  NdisRawReadPortUchar(Adapter->PortOffset + 2, CharPtr + 2);
209  break;
210  }
211 
213  {
214  static UCHAR VendorDesc[] = "ReactOS Team";
215  CopyFrom = VendorDesc;
216  CopySize = sizeof(VendorDesc);
217  break;
218  }
219 
221  {
222  /* XXX implement me */
223  GenericULONG = 1;
224  break;
225  }
226 
228  {
229  GenericULONG = Adapter->CurrentPacketFilter;
230  break;
231  }
232 
234  {
235  /* NDIS version used by the driver. */
236  static const USHORT DriverVersion =
237  (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
238  CopyFrom = (PVOID)&DriverVersion;
239  CopySize = sizeof(DriverVersion);
240  break;
241  }
242 
244  {
245  /* See comment in OID_GEN_MAXIMUM_FRAME_SIZE. */
246  GenericULONG = 1514;
247  break;
248  }
249 
251  {
252  DPRINT("OID_GEN_PROTOCOL_OPTIONS.\n");
254  break;
255  }
256 
257  case OID_GEN_MAC_OPTIONS:
258  {
259  GenericULONG = NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA |
263  break;
264  }
265 
267  {
268  GenericULONG = (ULONG)NdisMediaStateConnected; /* Adapter->MediaState */
269  break;
270  }
271 
273  {
274  GenericULONG = 1;
275  break;
276  }
277 
280  {
281  CopyFrom = (PVOID)&Adapter->InitializationBlockVirt->PADR;
282  CopySize = 6;
283  break;
284  }
285 
287  {
288  GenericULONG = MAX_MULTICAST_ADDRESSES;
289  break;
290  }
291 
292  case OID_GEN_XMIT_OK:
293  GenericULONG = Adapter->Statistics.XmtGoodFrames;
294  break;
295 
296  case OID_GEN_RCV_OK:
297  GenericULONG = Adapter->Statistics.RcvGoodFrames;
298  break;
299 
300  case OID_GEN_XMIT_ERROR:
301  GenericULONG = Adapter->Statistics.XmtRetryErrors +
302  Adapter->Statistics.XmtLossesOfCarrier +
303  Adapter->Statistics.XmtCollisions +
304  Adapter->Statistics.XmtLateCollisions +
307  Adapter->Statistics.XmtBufferErrors;
308  break;
309 
310  case OID_GEN_RCV_ERROR:
311  GenericULONG = Adapter->Statistics.RcvBufferErrors +
312  Adapter->Statistics.RcvCrcErrors +
313  Adapter->Statistics.RcvOverflowErrors +
314  Adapter->Statistics.RcvFramingErrors;
315  break;
316 
318  GenericULONG = Adapter->Statistics.RcvBufferErrors +
319  Adapter->Statistics.RcvOverflowErrors;
320  break;
321 
323  GenericULONG = Adapter->Statistics.RcvCrcErrors;
324  break;
325 
327  GenericULONG = Adapter->Statistics.RcvFramingErrors;
328  break;
329 
331  GenericULONG = Adapter->Statistics.XmtOneRetry;
332  break;
333 
335  GenericULONG = Adapter->Statistics.XmtMoreThanOneRetry;
336  break;
337 
338  default:
339  {
340  DPRINT1("Unknown OID\n");
342  break;
343  }
344  }
345 
347  {
348  if (CopySize > InformationBufferLength)
349  {
350  *BytesNeeded = CopySize;
351  *BytesWritten = 0;
353  }
354  else
355  {
356  NdisMoveMemory(InformationBuffer, CopyFrom, CopySize);
357  *BytesWritten = CopySize;
358  *BytesNeeded = CopySize;
359  }
360  }
361  else
362  {
363  *BytesWritten = 0;
364  *BytesNeeded = 0;
365  }
366 
367  NdisReleaseSpinLock(&Adapter->Lock);
368 
369  DPRINT("Leaving. Status is 0x%x\n", Status);
370 
371  return Status;
372 }
ADAPTER_STATS Statistics
Definition: pcnet.h:108
_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
ULONG XmtGoodFrames
Definition: pcnet.h:39
ULONG XmtLateCollisions
Definition: pcnet.h:43
Definition: pcnet.h:57
ULONG RcvFramingErrors
Definition: pcnet.h:53
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
VOID EXPORT NdisReleaseSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:239
#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_RCV_CRC_ERROR
Definition: ntddndis.h:286
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
ULONG RcvBufferErrors
Definition: pcnet.h:50
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
struct _ADAPTER * PADAPTER
UINT MediaSpeed
Definition: pcnet.h:68
ULONG RcvGoodFrames
Definition: pcnet.h:49
ULONG_PTR PortOffset
Definition: pcnet.h:65
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
ULONG XmtRetryErrors
Definition: pcnet.h:40
static ULONG MiniportOIDList[]
Definition: requests.c:42
#define OID_GEN_PROTOCOL_OPTIONS
Definition: ntddndis.h:250
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#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
void DPRINT(...)
Definition: polytest.cpp:61
void * PVOID
Definition: retypes.h:9
#define MAX_MULTICAST_ADDRESSES
Definition: pcnet.h:155
NDIS_SPIN_LOCK Lock
Definition: pcnet.h:59
#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
#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
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
VOID EXPORT NdisAcquireSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:135
ULONG XmtCollisions
Definition: pcnet.h:42
ULONG XmtMoreThanOneRetry
Definition: pcnet.h:48
ULONG XmtLossesOfCarrier
Definition: pcnet.h:41
#define OID_802_3_RCV_ERROR_ALIGNMENT
Definition: ntddndis.h:307
ULONG RcvCrcErrors
Definition: pcnet.h:51
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
unsigned char UCHAR
Definition: xmlstorage.h:181
Status
Definition: gdiplustypes.h:24
#define OID_802_3_XMIT_ONE_COLLISION
Definition: ntddndis.h:308
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_802_3_XMIT_MORE_COLLISIONS
Definition: ntddndis.h:309
ULONG XmtBufferUnderflows
Definition: pcnet.h:45
ULONG XmtBufferErrors
Definition: pcnet.h:46
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
PINITIALIZATION_BLOCK InitializationBlockVirt
Definition: pcnet.h:81
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
ULONG RcvOverflowErrors
Definition: pcnet.h:52
unsigned short USHORT
Definition: pedump.c:61
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
ULONG XmtExcessiveDeferrals
Definition: pcnet.h:44
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:242
unsigned int UINT
Definition: ndis.h:50
#define DPRINT1
Definition: precomp.h:8
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
unsigned int ULONG
Definition: retypes.h:1
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define NdisRawReadPortUchar(Port, Data)
Definition: ndis.h:4173
ULONG XmtOneRetry
Definition: pcnet.h:47
ULONG CurrentPacketFilter
Definition: pcnet.h:72
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#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

◆ 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 376 of file requests.c.

399 {
400  ULONG GenericULONG;
402  PADAPTER Adapter = (PADAPTER)MiniportAdapterContext;
403 
404  ASSERT(Adapter);
405 
406  DPRINT("Called, OID 0x%x\n", Oid);
407 
408  NdisAcquireSpinLock(&Adapter->Lock);
409 
410  switch (Oid)
411  {
413  {
414  /* Verify length */
415  if (InformationBufferLength < sizeof(ULONG))
416  {
417  *BytesRead = 0;
418  *BytesNeeded = sizeof(ULONG);
420  break;
421  }
422 
423  NdisMoveMemory(&GenericULONG, InformationBuffer, sizeof(ULONG));
424 
425  /* Check for properties the driver don't support */
426  if (GenericULONG &
433  )
434  {
435  *BytesRead = sizeof(ULONG);
436  *BytesNeeded = 0;
438  break;
439  }
440 
441  Adapter->CurrentPacketFilter = GenericULONG;
442 
443  /* FIXME: Set filter on hardware */
444 
445  break;
446  }
447 
449  {
450  /* Verify length */
451  if (InformationBufferLength < sizeof(ULONG))
452  {
453  *BytesRead = 0;
454  *BytesNeeded = sizeof(ULONG);
456  break;
457  }
458 
459  NdisMoveMemory(&GenericULONG, InformationBuffer, sizeof(ULONG));
460 
461  if (GenericULONG > 1500)
463  else
464  Adapter->CurrentLookaheadSize = GenericULONG;
465 
466  break;
467  }
468 
470  {
471  /* Verify length. Must be multiple of hardware address length */
472  if ((InformationBufferLength % 6) != 0)
473  {
474  *BytesRead = 0;
475  *BytesNeeded = InformationBufferLength + (InformationBufferLength % 6);
477  break;
478  }
479 
480  ASSERT((InformationBufferLength / 6) <= MAX_MULTICAST_ADDRESSES);
481 
482  /* Set new multicast address list */
483  //NdisMoveMemory(Adapter->Addresses, InformationBuffer, InformationBufferLength);
484 
485  /* Update hardware */
486  Status = MiSetMulticast(Adapter, InformationBuffer, InformationBufferLength / 6);
487 
488  break;
489  }
490 
491  default:
492  {
493  DPRINT1("Invalid object ID (0x%X).\n", Oid);
494  *BytesRead = 0;
495  *BytesNeeded = 0;
497  break;
498  }
499  }
500 
502  {
503  *BytesRead = InformationBufferLength;
504  *BytesNeeded = 0;
505  }
506 
507  NdisReleaseSpinLock(&Adapter->Lock);
508 
509  DPRINT("Leaving. Status (0x%X).\n", Status);
510 
511  return Status;
512 }
Definition: pcnet.h:57
VOID EXPORT NdisReleaseSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:239
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
struct _ADAPTER * PADAPTER
NDIS_STATUS NTAPI MiSetMulticast(PADAPTER Adapter, UCHAR *Addresses, UINT AddressCount)
Definition: pcnet.c:1262
int NDIS_STATUS
Definition: ntddndis.h:471
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#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
void DPRINT(...)
Definition: polytest.cpp:61
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define MAX_MULTICAST_ADDRESSES
Definition: pcnet.h:155
NDIS_SPIN_LOCK Lock
Definition: pcnet.h:59
VOID EXPORT NdisAcquireSpinLock(IN PNDIS_SPIN_LOCK SpinLock)
Definition: control.c:135
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
ULONG CurrentLookaheadSize
Definition: pcnet.h:73
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
Status
Definition: gdiplustypes.h:24
#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 DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
ULONG CurrentPacketFilter
Definition: pcnet.h:72
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
#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

Variable Documentation

◆ MiniportOIDList

ULONG MiniportOIDList[]
static

Definition at line 42 of file requests.c.

Referenced by MiniportQueryInformation().