PDA

View Full Version : How to get list of physical network interfaces?



hitmaneidos
1st February 2012, 10:34
Hi, I'm trying to get the list of all real network interfaces in a computer. Both the active and inactive ones. This is the code I used:



QList<QNetworkInterface> allInterfaces = QNetworkInterface::allInterfaces();
foreach(QNetworkInterface iFace, allInterfaces) {
qDebug() << iFace.humanReadableName();
}


and this is what I get



"Bluetooth Network Connection"
"Wireless Network Connection"
"Local Area Connection"
"Local Area Connection* 9"
"Local Area Connection* 6"
"Local Area Connection* 7"
"Local Area Connection-McAfee NDIS Light-Weight Filter-0000"
"Local Area Connection-WFP LightWeight Filter-0000"
"Local Area Connection* 8"
"Local Area Connection-QoS Packet Scheduler-0000"
"Local Area Connection* 6-McAfee NDIS Light-Weight Filter-0000"
"Local Area Connection* 6-QoS Packet Scheduler-0000"
"Local Area Connection* 8-McAfee NDIS Light-Weight Filter-0000"
"Local Area Connection* 8-QoS Packet Scheduler-0000"
"Local Area Connection* 7-McAfee NDIS Light-Weight Filter-0000"
"Local Area Connection* 7-QoS Packet Scheduler-0000"
"Local Area Connection* 5"
"Local Area Connection* 10"
"Loopback Pseudo-Interface 1"
"Wireless Network Connection-Native WiFi Filter Driver-0000"
"Wireless Network Connection-QoS Packet Scheduler-0000"
"Wireless Network Connection-McAfee NDIS Light-Weight Filter-0000"
"Wireless Network Connection-WFP LightWeight Filter-0000"
"Local Area Connection*"
"Local Area Connection* 2"
"Local Area Connection* 3"
"Local Area Connection* 4"
"isatap.{1A7372EB-C154-48C7-A90C-5D20357D5682}"
"isatap.{1A7372EB-C154-48C7-A90C-5D20357D5682}-McAfee NDIS Light-Weight Filter-0000"
"Teredo Tunneling Pseudo-Interface"
"Reusable ISATAP Interface {881DDFED-EB39-42CA-A446-F4B55E48C2A6}-McAfee NDIS Light-Weight Filter-0000"
"isatap.Belkin-McAfee NDIS Light-Weight Filter-0000"
"Local Area Connection* 11"
"isatap.Belkin"
"isatap.{DBFD5208-893B-4F36-859C-480E466384E0}-McAfee NDIS Light-Weight Filter-0000"
"isatap.{DBFD5208-893B-4F36-859C-480E466384E0}"
"Reusable ISATAP Interface {881DDFED-EB39-42CA-A446-F4B55E48C2A6}"
"Local Area Connection* 11-McAfee NDIS Light-Weight Filter-0000"


I just need the first three as all the others are virtual connections. Filtering the list with network interface flags did not work as they only removed the inactive connections and all these virtual ones seem to be active.

Does anyone have any suggestions? I need help!

Spitfire
1st February 2012, 11:30
I don't think you can distinguish between real and virtual adapters without using platform specific api.

hitmaneidos
2nd February 2012, 03:17
But that means I have to write different code for each platform. Oh, well.. thanks for the info.