From 3842b59f75e0793188fc94fb2c670930a04d7fbe Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Tue, 20 May 2025 00:46:50 +0200 Subject: [PATCH] [TCPIP] Retrieve the interface medium type from NDIS Send OID_GEN_PHYSICAL_MEDIUM and OID_GEN_MEDIA_SUPPORTED query requests to NDIS. This will enable us to distinguish wired and wireless ethernet adapters. --- drivers/network/tcpip/tcpip/iinfo.c | 104 ++++++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/drivers/network/tcpip/tcpip/iinfo.c b/drivers/network/tcpip/tcpip/iinfo.c index cf5e3e7cc4b..8fd1222a162 100644 --- a/drivers/network/tcpip/tcpip/iinfo.c +++ b/drivers/network/tcpip/tcpip/iinfo.c @@ -24,6 +24,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID, PLAN_ADAPTER IF; PCHAR IFDescr; ULONG Size; + ULONG Medium; NDIS_STATUS NdisStatus; if (!Interface) @@ -44,7 +45,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID, OutData->if_index = Interface->Index; /* viz: tcpip keeps those indices */ OutData->if_type = Interface == - Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_ETHERNET; + Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_OTHER; OutData->if_mtu = Interface->MTU; TI_DbgPrint(DEBUG_INFO, ("Getting interface speed\n")); @@ -56,11 +57,102 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID, IFDescr = (PCHAR)&OutData->if_descr[0]; if( IF ) { - GetInterfaceSpeed( Interface, (PUINT)&OutData->if_speed ); - TI_DbgPrint(DEBUG_INFO, - ("IF Speed = %d * 100bps\n", OutData->if_speed)); - memcpy(OutData->if_physaddr, Interface->Address, Interface->AddressLength); - TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n")); + if (OutData->if_type == MIB_IF_TYPE_OTHER) + { + NdisStatus = NDISCall(IF, + NdisRequestQueryInformation, + OID_GEN_PHYSICAL_MEDIUM, + &Medium, + sizeof(ULONG)); + if (NdisStatus == NDIS_STATUS_SUCCESS) + { + switch (Medium) + { +#if 0 + case NdisPhysicalMediumUnspecified: +#endif + case NdisPhysicalMediumWirelessLan: + OutData->if_type = IF_TYPE_IEEE80211; + break; +#if 0 + case NdisPhysicalMediumCableModem: + case NdisPhysicalMediumPhoneLine: + case NdisPhysicalMediumPowerLine: + case NdisPhysicalMediumDSL: + case NdisPhysicalMediumFibreChannel: + case NdisPhysicalMedium1394: + case NdisPhysicalMediumWirelessWan: +#endif + case NdisPhysicalMediumNative802_11: + OutData->if_type = IF_TYPE_IEEE80211; + break; +#if 0 + case NdisPhysicalMediumBluetooth: + case NdisPhysicalMediumInfiniband: + case NdisPhysicalMediumWiMax: + case NdisPhysicalMediumUWB: +#endif + case NdisPhysicalMedium802_3: + OutData->if_type = MIB_IF_TYPE_ETHERNET; + break; + + case NdisPhysicalMedium802_5: + OutData->if_type = MIB_IF_TYPE_TOKENRING; + break; +#if 0 + case NdisPhysicalMediumIrda: + case NdisPhysicalMediumWiredWAN: + case NdisPhysicalMediumWiredCoWan: + case NdisPhysicalMediumOther: +#endif + } + } + } + + if (OutData->if_type == MIB_IF_TYPE_OTHER) + { + NdisStatus = NDISCall(IF, + NdisRequestQueryInformation, + OID_GEN_MEDIA_SUPPORTED, + &Medium, + sizeof(ULONG)); + if (NdisStatus == NDIS_STATUS_SUCCESS) + { + switch (Medium) + { + case NdisMedium802_3: + OutData->if_type = MIB_IF_TYPE_ETHERNET; + break; + + case NdisMedium802_5: + OutData->if_type = MIB_IF_TYPE_TOKENRING; + break; + + case NdisMediumFddi: + OutData->if_type = MIB_IF_TYPE_FDDI; + break; +#if 0 + case NdisMediumWan, + case NdisMediumLocalTalk: + case NdisMediumDix: + case NdisMediumArcnetRaw: + case NdisMediumArcnet878_2: + case NdisMediumAtm: + case NdisMediumWirelessWan: + case NdisMediumIrda: + case NdisMediumBpc: + case NdisMediumCoWan: + case NdisMedium1394: +#endif + } + } + } + + GetInterfaceSpeed( Interface, (PUINT)&OutData->if_speed ); + TI_DbgPrint(DEBUG_INFO, + ("IF Speed = %d * 100bps\n", OutData->if_speed)); + memcpy(OutData->if_physaddr, Interface->Address, Interface->AddressLength); + TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n")); memcpy(&OutData->if_inoctets, &Interface->Stats, sizeof(SEND_RECV_STATS));