Reputation: 743
I was working on a project this morning and encountered an interesting issue. I noticed that sometimes NetworkInterface.NetworkInterfaceType
contains a value that is not in the documented enum list, specifically a value of "53". This interface is an OpenVPN connection and I've been able to work around it but it's certainly confusing. Has anybody else encountered this issue?
private static void GetEndpoints()
{
List<IPAddress> AddressList = new List<IPAddress>();
NetworkInterface[] Interfaces = NetworkInterface.GetAllNetworkInterfaces();
string Msg = String.Empty;
foreach(NetworkInterface I in Interfaces)
{
Msg += String.Format("{0} ({1}) - {2}\r\n",
I.Name,
I.GetIPProperties()
.UnicastAddresses
.Where(x => x.Address.AddressFamily == AddressFamily.InterNetwork)
.FirstOrDefault()
?.Address,
I.NetworkInterfaceType);
}
MessageBox.Show(Msg);
}
Upvotes: 3
Views: 1188
Reputation: 190925
Tracing the actual call to GetAdaptersInfo
and the result PIP_ADAPTER_INFO
, you can view the types defined in Ipifcons.h
from this source, it is a virtual one.
Upvotes: 7