https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3e3d34d97b7b687bac71d…
commit 3e3d34d97b7b687bac71d48269e7279d5ea0a6de
Author: Hervé Poussineau <hpoussin(a)reactos.org>
AuthorDate: Wed Dec 13 19:54:50 2023 +0100
Commit: Hervé Poussineau <hpoussin(a)reactos.org>
CommitDate: Sat Jan 13 15:23:46 2024 +0100
[TCPIP] Get max link speed, MTU and max packet size when adapter is connected
---
drivers/network/tcpip/datalink/lan.c | 71 ++++++++++++++++--------------------
drivers/network/tcpip/include/lan.h | 2 +-
2 files changed, 33 insertions(+), 40 deletions(-)
diff --git a/drivers/network/tcpip/datalink/lan.c b/drivers/network/tcpip/datalink/lan.c
index 0440c098f49..ccd0f555ef5 100644
--- a/drivers/network/tcpip/datalink/lan.c
+++ b/drivers/network/tcpip/datalink/lan.c
@@ -718,7 +718,7 @@ BOOLEAN ReconfigureAdapter(PRECONFIGURE_CONTEXT Context)
{
PLAN_ADAPTER Adapter = Context->Adapter;
PIP_INTERFACE Interface = Adapter->Context;
- //NDIS_STATUS NdisStatus;
+ NDIS_STATUS NdisStatus;
IP_ADDRESS DefaultMask;
/* Initialize the default unspecified address (0.0.0.0) */
@@ -754,47 +754,40 @@ BOOLEAN ReconfigureAdapter(PRECONFIGURE_CONTEXT Context)
TCPUpdateInterfaceIPInformation(Interface);
TCPUpdateInterfaceLinkStatus(Interface);
- /* We're done here if the adapter isn't connected */
- if (Context->State != LAN_STATE_STARTED)
+ if (Context->State == LAN_STATE_STARTED)
{
- Adapter->State = Context->State;
- return TRUE;
- }
-
- /* NDIS Bug! */
-#if 0
- /* Get maximum link speed */
- NdisStatus = NDISCall(Adapter,
- NdisRequestQueryInformation,
- OID_GEN_LINK_SPEED,
- &Interface->Speed,
- sizeof(UINT));
-
- if (!NT_SUCCESS(NdisStatus))
- Interface->Speed = IP_DEFAULT_LINK_SPEED;
-
- Adapter->Speed = Interface->Speed * 100L;
-
- /* Get maximum frame size */
- NdisStatus = NDISCall(Adapter,
- NdisRequestQueryInformation,
- OID_GEN_MAXIMUM_FRAME_SIZE,
- &Adapter->MTU,
- sizeof(UINT));
- if (NdisStatus != NDIS_STATUS_SUCCESS)
- return FALSE;
+ /* Get maximum link speed */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_LINK_SPEED,
+ &Interface->Speed,
+ sizeof(Interface->Speed));
+
+ if (!NT_SUCCESS(NdisStatus))
+ Interface->Speed = IP_DEFAULT_LINK_SPEED;
+
+ Adapter->Speed = Interface->Speed * 100L;
+
+ /* Get maximum frame size */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_MAXIMUM_FRAME_SIZE,
+ &Adapter->MTU,
+ sizeof(Adapter->MTU));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ return FALSE;
- Interface->MTU = Adapter->MTU;
+ Interface->MTU = Adapter->MTU;
- /* Get maximum packet size */
- NdisStatus = NDISCall(Adapter,
- NdisRequestQueryInformation,
- OID_GEN_MAXIMUM_TOTAL_SIZE,
- &Adapter->MaxPacketSize,
- sizeof(UINT));
- if (NdisStatus != NDIS_STATUS_SUCCESS)
- return FALSE;
-#endif
+ /* Get maximum packet size */
+ NdisStatus = NDISCall(Adapter,
+ NdisRequestQueryInformation,
+ OID_GEN_MAXIMUM_TOTAL_SIZE,
+ &Adapter->MaxPacketSize,
+ sizeof(Adapter->MaxPacketSize));
+ if (NdisStatus != NDIS_STATUS_SUCCESS)
+ return FALSE;
+ }
Adapter->State = Context->State;
diff --git a/drivers/network/tcpip/include/lan.h b/drivers/network/tcpip/include/lan.h
index ab8f4bc5ba6..f99f588188e 100644
--- a/drivers/network/tcpip/include/lan.h
+++ b/drivers/network/tcpip/include/lan.h
@@ -52,7 +52,7 @@ typedef struct LAN_ADAPTER {
UCHAR BCastCheck; /* Value to check against */
UCHAR BCastOffset; /* Offset in frame to check against */
UCHAR HeaderSize; /* Size of link-level header */
- USHORT MTU; /* Maximum Transfer Unit */
+ UINT MTU; /* Maximum Transfer Unit */
UINT MinFrameSize; /* Minimum frame size in bytes */
UINT MaxPacketSize; /* Maximum packet size when sending */
UINT MaxSendPackets; /* Maximum number of packets per send */