ReactOS 0.4.16-dev-1946-g52006dd
info.c File Reference
#include "nic.h"
#include <debug.h>
Include dependency graph for info.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 SupportedOidList []
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 24 of file info.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 70 of file info.c.

78{
79 PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext;
80 ULONG genericUlong;
81 ULONG copyLength;
82 PVOID copySource;
84
86 copySource = &genericUlong;
87 copyLength = sizeof(ULONG);
88
90
91 switch (Oid)
92 {
94 copySource = (PVOID)&SupportedOidList;
95 copyLength = sizeof(SupportedOidList);
96 break;
97
99 genericUlong = adapter->PacketFilter;
100 break;
101
103 genericUlong = (ULONG)NdisHardwareStatusReady; //FIXME
104 break;
105
108 {
109 static const NDIS_MEDIUM medium = NdisMedium802_3;
110 copySource = (PVOID)&medium;
111 copyLength = sizeof(medium);
112 break;
113 }
114
120 genericUlong = MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER);
121 break;
122
124 genericUlong = adapter->LinkSpeedMbps * 1000;
125 break;
126
128 genericUlong = MAXIMUM_FRAME_SIZE;
129 break;
130
132 genericUlong = RECEIVE_BUFFER_SIZE;
133 break;
134
136 //
137 // The 3 bytes of the MAC address is the vendor ID
138 //
139 genericUlong = 0;
140 genericUlong |= (adapter->PermanentMacAddress[0] << 16);
141 genericUlong |= (adapter->PermanentMacAddress[1] << 8);
142 genericUlong |= (adapter->PermanentMacAddress[2] & 0xFF);
143 break;
144
146 {
147 static UCHAR vendorDesc[] = "ReactOS Team";
148 copySource = vendorDesc;
149 copyLength = sizeof(vendorDesc);
150 break;
151 }
152
154 genericUlong = DRIVER_VERSION;
155 break;
156
158 {
159 static const USHORT driverVersion =
160 (NDIS_MINIPORT_MAJOR_VERSION << 8) + NDIS_MINIPORT_MINOR_VERSION;
161 copySource = (PVOID)&driverVersion;
162 copyLength = sizeof(driverVersion);
163 break;
164 }
165
167 genericUlong = MAXIMUM_FRAME_SIZE;
168 break;
169
171 NDIS_DbgPrint(MIN_TRACE, ("OID_GEN_PROTOCOL_OPTIONS is unimplemented\n"));
173 break;
174
180 break;
181
183 genericUlong = adapter->MediaState;
184 break;
185
187 genericUlong = 1;
188 break;
189
191 copySource = adapter->CurrentMacAddress;
192 copyLength = IEEE_802_ADDR_LENGTH;
193 break;
194
196 copySource = adapter->PermanentMacAddress;
197 copyLength = IEEE_802_ADDR_LENGTH;
198 break;
199
201 genericUlong = MAXIMUM_MULTICAST_ADDRESSES;
202 break;
203
205 genericUlong = NdisPhysicalMedium802_3;
206 break;
207
208 case OID_GEN_XMIT_OK:
209 genericUlong = adapter->TransmitOk;
210 break;
211
212 case OID_GEN_RCV_OK:
213 genericUlong = adapter->ReceiveOk;
214 break;
215
217 genericUlong = adapter->TransmitError;
218 break;
219
221 genericUlong = adapter->ReceiveError;
222 break;
223
225 genericUlong = adapter->ReceiveNoBufferSpace;
226 break;
227
229 genericUlong = adapter->ReceiveCrcError;
230 break;
231
233 genericUlong = adapter->ReceiveAlignmentError;
234 break;
235
237 genericUlong = adapter->TransmitOneCollision;
238 break;
239
241 genericUlong = adapter->TransmitMoreCollisions;
242 break;
243
244 default:
245 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID\n"));
247 break;
248 }
249
251 {
252 if (copyLength > InformationBufferLength)
253 {
254 *BytesNeeded = copyLength;
255 *BytesWritten = 0;
257 }
258 else
259 {
260 NdisMoveMemory(InformationBuffer, copySource, copyLength);
261 *BytesWritten = copyLength;
262 *BytesNeeded = copyLength;
263 }
264 }
265 else
266 {
267 *BytesWritten = 0;
268 *BytesNeeded = 0;
269 }
270
272
273 NDIS_DbgPrint(MAX_TRACE, ("Query OID 0x%x: Completed with status 0x%x (%d, %d)\n",
274 Oid, status, *BytesWritten, *BytesNeeded));
275
276 return status;
277}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static NDIS_OID SupportedOidList[]
Definition: info.c:13
#define MAXIMUM_FRAME_SIZE
Definition: nic.h:19
#define RECEIVE_BUFFER_SIZE
Definition: nic.h:20
#define DRIVER_VERSION
Definition: nic.h:22
#define MAXIMUM_MULTICAST_ADDRESSES
Definition: e1000hw.h:23
#define IEEE_802_ADDR_LENGTH
Definition: e1000hw.h:11
return adapter
#define NdisReleaseSpinLock(_SpinLock)
Definition: ndis.h:4115
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_MAC_OPTION_NO_LOOPBACK
Definition: ndis.h:685
#define NDIS_MAC_OPTION_COPY_LOOKAHEAD_DATA
Definition: ndis.h:682
#define NdisAcquireSpinLock(_SpinLock)
Definition: ndis.h:4106
#define NdisMoveMemory(Destination, Source, Length)
Definition: ndis.h:3896
enum _NDIS_MEDIUM NDIS_MEDIUM
#define OID_GEN_TRANSMIT_BLOCK_SIZE
Definition: ntddndis.h:261
#define OID_GEN_PROTOCOL_OPTIONS
Definition: ntddndis.h:269
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:286
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:268
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:288
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:273
@ NdisPhysicalMedium802_3
Definition: ntddndis.h:237
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:321
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:258
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:263
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:265
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:290
#define OID_GEN_PHYSICAL_MEDIUM
Definition: ntddndis.h:283
#define OID_802_3_XMIT_ONE_COLLISION
Definition: ntddndis.h:327
#define OID_802_3_XMIT_MORE_COLLISIONS
Definition: ntddndis.h:328
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:260
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:324
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:267
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:322
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:259
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:254
@ NdisMedium802_3
Definition: ntddndis.h:191
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:257
#define OID_GEN_RCV_CRC_ERROR
Definition: ntddndis.h:305
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:255
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:271
#define OID_GEN_RCV_OK
Definition: ntddndis.h:287
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:256
#define OID_802_3_RCV_ERROR_ALIGNMENT
Definition: ntddndis.h:326
int NDIS_STATUS
Definition: ntddndis.h:496
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:289
@ NdisHardwareStatusReady
Definition: ntddndis.h:471
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:266
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:270
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:264
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:252
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:262
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:272
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:253
unsigned short USHORT
Definition: pedump.c:61
struct _RTL_ADAPTER * PRTL_ADAPTER
Definition: lan.h:33
Definition: ps.c:97
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesWritten
Definition: wdfiotarget.h:960
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ 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 281 of file info.c.

289{
290 PRTL_ADAPTER adapter = (PRTL_ADAPTER)MiniportAdapterContext;
291 ULONG genericUlong;
293
295
297
298 switch (Oid)
299 {
301 if (InformationBufferLength < sizeof(ULONG))
302 {
303 *BytesRead = 0;
304 *BytesNeeded = sizeof(ULONG);
306 break;
307 }
308
309 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
310
311 if (genericUlong &
318 {
319 *BytesRead = sizeof(ULONG);
320 *BytesNeeded = sizeof(ULONG);
322 break;
323 }
324
325 adapter->PacketFilter = genericUlong;
326
329 {
330 NDIS_DbgPrint(MIN_TRACE, ("Failed to apply new packet filter\n"));
331 break;
332 }
333
334 break;
335
337 if (InformationBufferLength < sizeof(ULONG))
338 {
339 *BytesRead = 0;
340 *BytesNeeded = sizeof(ULONG);
342 break;
343 }
344
345 NdisMoveMemory(&genericUlong, InformationBuffer, sizeof(ULONG));
346
347 if (genericUlong > MAXIMUM_FRAME_SIZE - sizeof(ETH_HEADER))
348 {
350 }
351 else
352 {
353 // Ignore this...
354 }
355
356 break;
357
359 if (InformationBufferLength % IEEE_802_ADDR_LENGTH)
360 {
361 *BytesRead = 0;
362 *BytesNeeded = InformationBufferLength + (InformationBufferLength % IEEE_802_ADDR_LENGTH);
364 break;
365 }
366
367 if (InformationBufferLength / 6 > MAXIMUM_MULTICAST_ADDRESSES)
368 {
370 *BytesRead = 0;
372 break;
373 }
374
375 NdisMoveMemory(adapter->MulticastList, InformationBuffer, InformationBufferLength);
376
377 // FIXME: Write to device
378
379 break;
380
381 default:
382 NDIS_DbgPrint(MIN_TRACE, ("Unknown OID\n"));
384 *BytesRead = 0;
385 *BytesNeeded = 0;
386 break;
387 }
388
390 {
391 *BytesRead = InformationBufferLength;
392 *BytesNeeded = 0;
393 }
394
396
397 return status;
398}
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
#define NDIS_STATUS_INVALID_DATA
Definition: ndis.h:486
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_PACKET_TYPE_SOURCE_ROUTING
Definition: ndis.h:667
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL
Definition: ndis.h:672
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
#define NDIS_PACKET_TYPE_GROUP
Definition: ndis.h:671
#define NDIS_PACKET_TYPE_SMT
Definition: ndis.h:669
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:323
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

Variable Documentation

◆ SupportedOidList

ULONG SupportedOidList[]
static

Definition at line 27 of file info.c.