Skip to content

Commit 3842b59

Browse files
committed
[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.
1 parent c876fe3 commit 3842b59

File tree

1 file changed

+98
-6
lines changed

1 file changed

+98
-6
lines changed

drivers/network/tcpip/tcpip/iinfo.c

Lines changed: 98 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
2424
PLAN_ADAPTER IF;
2525
PCHAR IFDescr;
2626
ULONG Size;
27+
ULONG Medium;
2728
NDIS_STATUS NdisStatus;
2829

2930
if (!Interface)
@@ -44,7 +45,7 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
4445
OutData->if_index = Interface->Index;
4546
/* viz: tcpip keeps those indices */
4647
OutData->if_type = Interface ==
47-
Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_ETHERNET;
48+
Loopback ? MIB_IF_TYPE_LOOPBACK : MIB_IF_TYPE_OTHER;
4849
OutData->if_mtu = Interface->MTU;
4950
TI_DbgPrint(DEBUG_INFO,
5051
("Getting interface speed\n"));
@@ -56,11 +57,102 @@ TDI_STATUS InfoTdiQueryGetInterfaceMIB(TDIEntityID ID,
5657
IFDescr = (PCHAR)&OutData->if_descr[0];
5758

5859
if( IF ) {
59-
GetInterfaceSpeed( Interface, (PUINT)&OutData->if_speed );
60-
TI_DbgPrint(DEBUG_INFO,
61-
("IF Speed = %d * 100bps\n", OutData->if_speed));
62-
memcpy(OutData->if_physaddr, Interface->Address, Interface->AddressLength);
63-
TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n"));
60+
if (OutData->if_type == MIB_IF_TYPE_OTHER)
61+
{
62+
NdisStatus = NDISCall(IF,
63+
NdisRequestQueryInformation,
64+
OID_GEN_PHYSICAL_MEDIUM,
65+
&Medium,
66+
sizeof(ULONG));
67+
if (NdisStatus == NDIS_STATUS_SUCCESS)
68+
{
69+
switch (Medium)
70+
{
71+
#if 0
72+
case NdisPhysicalMediumUnspecified:
73+
#endif
74+
case NdisPhysicalMediumWirelessLan:
75+
OutData->if_type = IF_TYPE_IEEE80211;
76+
break;
77+
#if 0
78+
case NdisPhysicalMediumCableModem:
79+
case NdisPhysicalMediumPhoneLine:
80+
case NdisPhysicalMediumPowerLine:
81+
case NdisPhysicalMediumDSL:
82+
case NdisPhysicalMediumFibreChannel:
83+
case NdisPhysicalMedium1394:
84+
case NdisPhysicalMediumWirelessWan:
85+
#endif
86+
case NdisPhysicalMediumNative802_11:
87+
OutData->if_type = IF_TYPE_IEEE80211;
88+
break;
89+
#if 0
90+
case NdisPhysicalMediumBluetooth:
91+
case NdisPhysicalMediumInfiniband:
92+
case NdisPhysicalMediumWiMax:
93+
case NdisPhysicalMediumUWB:
94+
#endif
95+
case NdisPhysicalMedium802_3:
96+
OutData->if_type = MIB_IF_TYPE_ETHERNET;
97+
break;
98+
99+
case NdisPhysicalMedium802_5:
100+
OutData->if_type = MIB_IF_TYPE_TOKENRING;
101+
break;
102+
#if 0
103+
case NdisPhysicalMediumIrda:
104+
case NdisPhysicalMediumWiredWAN:
105+
case NdisPhysicalMediumWiredCoWan:
106+
case NdisPhysicalMediumOther:
107+
#endif
108+
}
109+
}
110+
}
111+
112+
if (OutData->if_type == MIB_IF_TYPE_OTHER)
113+
{
114+
NdisStatus = NDISCall(IF,
115+
NdisRequestQueryInformation,
116+
OID_GEN_MEDIA_SUPPORTED,
117+
&Medium,
118+
sizeof(ULONG));
119+
if (NdisStatus == NDIS_STATUS_SUCCESS)
120+
{
121+
switch (Medium)
122+
{
123+
case NdisMedium802_3:
124+
OutData->if_type = MIB_IF_TYPE_ETHERNET;
125+
break;
126+
127+
case NdisMedium802_5:
128+
OutData->if_type = MIB_IF_TYPE_TOKENRING;
129+
break;
130+
131+
case NdisMediumFddi:
132+
OutData->if_type = MIB_IF_TYPE_FDDI;
133+
break;
134+
#if 0
135+
case NdisMediumWan,
136+
case NdisMediumLocalTalk:
137+
case NdisMediumDix:
138+
case NdisMediumArcnetRaw:
139+
case NdisMediumArcnet878_2:
140+
case NdisMediumAtm:
141+
case NdisMediumWirelessWan:
142+
case NdisMediumIrda:
143+
case NdisMediumBpc:
144+
case NdisMediumCoWan:
145+
case NdisMedium1394:
146+
#endif
147+
}
148+
}
149+
}
150+
151+
GetInterfaceSpeed( Interface, (PUINT)&OutData->if_speed );
152+
TI_DbgPrint(DEBUG_INFO,
153+
("IF Speed = %d * 100bps\n", OutData->if_speed));
154+
memcpy(OutData->if_physaddr, Interface->Address, Interface->AddressLength);
155+
TI_DbgPrint(DEBUG_INFO, ("Got HWAddr\n"));
64156

65157
memcpy(&OutData->if_inoctets, &Interface->Stats, sizeof(SEND_RECV_STATS));
66158

0 commit comments

Comments
 (0)