ReactOS 0.4.16-dev-1225-g1286711
info.c
Go to the documentation of this file.
1/*
2 * ReactOS Realtek 8139 Driver
3 *
4 * Copyright (C) 2013 Cameron Gutman
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 */
21
22#include "nic.h"
23
24#define NDEBUG
25#include <debug.h>
26
28{
66};
67
71 IN NDIS_HANDLE MiniportAdapterContext,
72 IN NDIS_OID Oid,
73 IN PVOID InformationBuffer,
74 IN ULONG InformationBufferLength,
76 OUT PULONG BytesNeeded
77 )
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}
278
280NTAPI
282 IN NDIS_HANDLE MiniportAdapterContext,
283 IN NDIS_OID Oid,
284 IN PVOID InformationBuffer,
285 IN ULONG InformationBufferLength,
287 OUT PULONG BytesNeeded
288 )
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}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
NDIS_STATUS NTAPI NICApplyPacketFilter(IN PE1000_ADAPTER Adapter)
Definition: hardware.c:724
static NDIS_OID SupportedOidList[]
Definition: info.c:13
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: info.c:283
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: info.c:74
#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_INVALID_DATA
Definition: ndis.h:486
#define NDIS_STATUS_NOT_SUPPORTED
Definition: ndis.h:479
#define NDIS_PACKET_TYPE_MAC_FRAME
Definition: ndis.h:674
#define NDIS_PACKET_TYPE_SOURCE_ROUTING
Definition: ndis.h:667
#define NDIS_STATUS_INVALID_LENGTH
Definition: ndis.h:485
#define NDIS_PACKET_TYPE_ALL_FUNCTIONAL
Definition: ndis.h:672
#define NDIS_MAC_OPTION_TRANSFERS_NOT_PEND
Definition: ndis.h:684
#define NDIS_MAC_OPTION_RECEIVE_SERIALIZED
Definition: ndis.h:683
#define NDIS_PACKET_TYPE_FUNCTIONAL
Definition: ndis.h:673
#define NDIS_PACKET_TYPE_GROUP
Definition: ndis.h:671
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
#define NDIS_PACKET_TYPE_SMT
Definition: ndis.h:669
#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:242
#define OID_GEN_PROTOCOL_OPTIONS
Definition: ntddndis.h:250
#define OID_GEN_XMIT_OK
Definition: ntddndis.h:267
#define OID_GEN_MAXIMUM_TOTAL_SIZE
Definition: ntddndis.h:249
#define OID_GEN_XMIT_ERROR
Definition: ntddndis.h:269
#define OID_GEN_VENDOR_DRIVER_VERSION
Definition: ntddndis.h:254
@ NdisPhysicalMedium802_3
Definition: ntddndis.h:221
#define OID_802_3_PERMANENT_ADDRESS
Definition: ntddndis.h:302
#define OID_GEN_LINK_SPEED
Definition: ntddndis.h:239
#define OID_GEN_VENDOR_ID
Definition: ntddndis.h:244
#define OID_GEN_CURRENT_PACKET_FILTER
Definition: ntddndis.h:246
#define OID_GEN_RCV_NO_BUFFER
Definition: ntddndis.h:271
#define OID_GEN_PHYSICAL_MEDIUM
Definition: ntddndis.h:264
#define OID_802_3_XMIT_ONE_COLLISION
Definition: ntddndis.h:308
#define OID_802_3_XMIT_MORE_COLLISIONS
Definition: ntddndis.h:309
#define OID_GEN_RECEIVE_BUFFER_SPACE
Definition: ntddndis.h:241
#define OID_802_3_MAXIMUM_LIST_SIZE
Definition: ntddndis.h:305
#define OID_GEN_DRIVER_VERSION
Definition: ntddndis.h:248
#define OID_802_3_MAC_OPTIONS
Definition: ntddndis.h:306
#define OID_802_3_CURRENT_ADDRESS
Definition: ntddndis.h:303
#define OID_802_3_MULTICAST_LIST
Definition: ntddndis.h:304
#define OID_GEN_TRANSMIT_BUFFER_SPACE
Definition: ntddndis.h:240
#define OID_GEN_MEDIA_SUPPORTED
Definition: ntddndis.h:235
@ NdisMedium802_3
Definition: ntddndis.h:188
#define OID_GEN_MAXIMUM_FRAME_SIZE
Definition: ntddndis.h:238
#define OID_GEN_RCV_CRC_ERROR
Definition: ntddndis.h:286
#define OID_GEN_MEDIA_IN_USE
Definition: ntddndis.h:236
#define OID_GEN_MEDIA_CONNECT_STATUS
Definition: ntddndis.h:252
#define OID_GEN_RCV_OK
Definition: ntddndis.h:268
#define OID_GEN_MAXIMUM_LOOKAHEAD
Definition: ntddndis.h:237
#define OID_802_3_RCV_ERROR_ALIGNMENT
Definition: ntddndis.h:307
int NDIS_STATUS
Definition: ntddndis.h:475
#define OID_GEN_RCV_ERROR
Definition: ntddndis.h:270
@ NdisHardwareStatusReady
Definition: ntddndis.h:450
#define OID_GEN_CURRENT_LOOKAHEAD
Definition: ntddndis.h:247
#define OID_GEN_MAC_OPTIONS
Definition: ntddndis.h:251
#define OID_GEN_VENDOR_DESCRIPTION
Definition: ntddndis.h:245
#define OID_GEN_SUPPORTED_LIST
Definition: ntddndis.h:233
ULONG NDIS_OID
Definition: ntddndis.h:230
#define OID_GEN_RECEIVE_BLOCK_SIZE
Definition: ntddndis.h:243
#define OID_GEN_MAXIMUM_SEND_PACKETS
Definition: ntddndis.h:253
#define OID_GEN_HARDWARE_STATUS
Definition: ntddndis.h:234
unsigned short USHORT
Definition: pedump.c:61
struct _RTL_ADAPTER * PRTL_ADAPTER
Definition: lan.h:33
Definition: ps.c:97
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
_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
_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
unsigned char UCHAR
Definition: xmlstorage.h:181