I am using a WinPCapDevice and have already initialized it. I just want to be able to get the IP from that device and I cannot find anywhere how to extract the IP address of the Device. If there isnt a way to do it then is there another way to get the IP address of a WinPCapDevice so that I can check it against a list of IPAddresses?
Here is the small chunk of code that I am talking about.
IPHostEntry host;
host = Dns.GetHostEntry(Dns.GetHostName());
foreach (IPAddress ip in host.AddressList)
{
if (ip.AddressFamily.ToString() == "InterNetwork")
{
localIPAddress = ip.ToString();
//Want to check if my WinPCapDevice device's IP is equal to ip
}
}
The
WinPcapDevice
class contains a property calledAddresses
. This property holds all addresses (IP) associated with the device:Of course, you could also use the
CaptureDeviceList
class to get a list of specific devices. Every device in this list implementsICaptureDevice
. You then have to cast to aWinPcapDevice
, aLibPcapLiveDevice
or aAirPcapDevice
in order to access the Address property.Hope, this helps.