Beispiel #1
0
        private void lbxAirPcapDeviceListI_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            gbxDevInfoI.Visibility = Visibility.Visible;
            AirPcapDevice dev = lbxAirPcapDeviceListI.SelectedItem as AirPcapDevice;

            gbxDevInfo.DataContext   = dev;
            lbxAdressesI.ItemsSource = dev.Addresses;
        }
Beispiel #2
0
        /// <summary>
        /// Return the gateway IPAddress of the selected network interface's
        /// </summary>
        /// <param name="friendlyname">The friendly name of the selected network interface</param>
        /// <returns>Returns the gateway IPAddress of the selected network interface's</returns>
        private IPAddress GetGatewayIP(string friendlyname)
        {
            IPAddress retval        = null;
            string    interfacename = "";

            foreach (ICaptureDevice capturedevice in CaptureDeviceList.Instance)
            {
                if (capturedevice is WinPcapDevice)
                {
                    WinPcapDevice winpcapdevice = (WinPcapDevice)capturedevice;
                    if (winpcapdevice.Interface.FriendlyName == friendlyname)
                    {
                        interfacename = winpcapdevice.Interface.Name;
                    }
                }
                else if (capturedevice is AirPcapDevice)
                {
                    AirPcapDevice airpcapdevice = (AirPcapDevice)capturedevice;
                    if (airpcapdevice.Interface.FriendlyName == friendlyname)
                    {
                        interfacename = airpcapdevice.Interface.Name;
                    }
                }
            }
            if (interfacename != "")
            {
                foreach (var networkinterface in NetworkInterface.GetAllNetworkInterfaces())
                {
                    if (networkinterface.Name == friendlyname)
                    {
                        foreach (var gateway in networkinterface.GetIPProperties().GatewayAddresses)
                        {
                            if (gateway.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) //filter ipv4 gateway ip address
                            {
                                retval = gateway.Address;
                            }
                        }
                    }
                }
            }
            return(retval);
        }
Beispiel #3
0
        /// <summary>
        /// Populate the available network cards
        /// </summary>
        public List <string> PopulateInterfaces()//Not used
        {
            CaptureDeviceList capturedevicelist         = CaptureDeviceList.Instance;
            List <string>     capturedevicelistofstring = new List <string>();

            capturedevicelist.ToList().ForEach((ICaptureDevice capturedevice) =>
            {
                if (capturedevice is WinPcapDevice)
                {
                    WinPcapDevice winpcapdevice = (WinPcapDevice)capturedevice;
                    capturedevicelistofstring.Add(winpcapdevice.Interface.FriendlyName);
                }
                else if (capturedevice is AirPcapDevice)
                {
                    AirPcapDevice airpcapdevice = (AirPcapDevice)capturedevice;
                    capturedevicelistofstring.Add(airpcapdevice.Interface.FriendlyName);
                }
            });
            return(capturedevicelistofstring);
        }
Beispiel #4
0
        /// <summary>
        /// Populate the available network cards
        /// </summary>
        public void PopulateInterfaces()
        {
            CaptureDeviceList capturedevicelist         = CaptureDeviceList.Instance;
            List <string>     capturedevicelistofstring = new List <string>();

            capturedevicelist.ToList().ForEach((ICaptureDevice capturedevice) =>
            {
                if (capturedevice is WinPcapDevice)
                {
                    WinPcapDevice winpcapdevice = (WinPcapDevice)capturedevice;
                    capturedevicelistofstring.Add(winpcapdevice.Interface.FriendlyName);
                }
                else if (capturedevice is AirPcapDevice)
                {
                    AirPcapDevice airpcapdevice = (AirPcapDevice)capturedevice;
                    capturedevicelistofstring.Add(airpcapdevice.Interface.FriendlyName);
                }
            });
            _view.ToolStripComboBoxDeviceList.Items.AddRange(capturedevicelistofstring.ToArray());
        }
Beispiel #5
0
 public void SetDevices(CaptureDeviceList devices)
 {
     _devices = devices;
     foreach (ICaptureDevice dev in _devices)
     {
         if (dev is AirPcapDevice)
         {
             AirPcapDevice cpd = dev as AirPcapDevice;
             devicesList.Items.Add(cpd.Interface.FriendlyName + " - " + dev.Description.ToString());
         }
         else if (dev is WinPcapDevice)
         {
             WinPcapDevice cpd = dev as WinPcapDevice;
             devicesList.Items.Add(cpd.Interface.FriendlyName + " - " + dev.Description.ToString());
         }
         else if (dev is LibPcapLiveDevice)
         {
             LibPcapLiveDevice cpd = dev as LibPcapLiveDevice;
             devicesList.Items.Add(cpd.Interface.FriendlyName + " - " + dev.Description.ToString());
         }
     }
 }