[TCPIP] Get max link speed, MTU and max packet size when adapter is connected

This commit is contained in:
Hervé Poussineau 2023-12-13 19:54:50 +01:00
parent 4c9037fff1
commit 3e3d34d97b
2 changed files with 34 additions and 41 deletions

View file

@ -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,48 +754,41 @@ 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;
/* 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;
/* 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;
}
/* 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;
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
Adapter->State = Context->State;
return TRUE;

View file

@ -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 */