Пример #1
0
        public void SelectedCaptureDevice(IpInterface selectedIpInterface)
        {
            this.Clear();
            CaptureDeviceList deviceList = CaptureDeviceList.Instance;

            foreach (var device in deviceList.OfType <NpcapDevice>())
            {
                if (device.Name == selectedIpInterface?.HwName)
                {
                    this.Add(device);
                }

                if (device.Interface.Addresses.Count > 0) // just for the debugging purpose - save the local MacAddresses
                {
                    this.AddLocalPhysicalAddress(device.Interface.MacAddress);
                }
            }

            if (!this.Any())                                         //no device found, let's make an assumption and pick first
            {
                this.Add(deviceList.OfType <NpcapDevice>().First()); // if we take all -> huge perf fckup
            }
        }