Exemple #1
0
        private void Start()
        {
            Debug.Assert(_devices == null);
            try
            {
                _devices = WinPcapDeviceList.New();
            }
            catch (DllNotFoundException ex)
            {
                throw new NetworkSniffingException("WinPcap is not installed", ex);
            }
            var interestingDevices = _devices.Where(IsInteresting);

            foreach (var device in interestingDevices)
            {
                device.OnPacketArrival += device_OnPacketArrival;
                device.Open(DeviceMode.Normal, 1000);
                device.Filter = _filter;
                if (BufferSize != null)
                {
                    device.KernelBufferSize = (uint)BufferSize.Value;
                }
                device.StartCapture();
            }
        }
        private void Start()
        {
            Debug.Assert(_devices == null);
            _devices = WinPcapDeviceList.New();
            var interestingDevices = _devices.Where(IsInteresting);

            foreach (var device in interestingDevices)
            {
                device.OnPacketArrival += device_OnPacketArrival;
                try { device.Open(DeviceMode.Normal, 1000); }
                catch (Exception e) { Logger.Warn($"Failed to open device {device.Name}. {e.Message}"); continue; }
                device.Filter = _filter;
                if (BufferSize != null)
                {
                    try
                    {
                        device.KernelBufferSize = (uint)BufferSize.Value;
                    }
                    catch (Exception e)
                    {
                        Logger.Warn(
                            $"Failed to set KernelBufferSize to {BufferSize.Value} on {device.Name}. {e.Message}");
                    }
                }
                device.StartCapture();
                Console.WriteLine("winpcap capture");
            }
        }
 private void Finish()
 {
     Debug.Assert(_devices != null);
     foreach (var device in _devices.Where(device => device.Opened))
     {
         try { device.StopCapture(); } catch { };//SharpPcap.PcapException: captureThread was aborted after 00:00:02 - it's normal when there is no traffic while stopping
         device.Close();
     }
     _devices = null;
 }
 private void Finish()
 {
     Debug.Assert(_devices != null);
     foreach (var device in _devices.Where(device => device.Opened))
     {
         device.StopCapture();
         device.Close();
     }
     _devices = null;
 }
Exemple #5
0
        private void Finish()
        {
            return;

            foreach (var device in _devices.Where(device => device.Opened))
            {
                device.StopCapture();
                device.Close();
            }
            _devices = null;
        }
Exemple #6
0
 private void Finish()
 {
     Debug.Assert(_devices != null);
     foreach (var device in _devices.Where(device => device.Opened))
     {
         try { device.StopCapture(); }
         catch { };//CaptureThread was aborted
         device.Close();
     }
     _devices = null;
 }
Exemple #7
0
        private void Start()
        {
            Debug.Assert(_devices == null);
            _devices = WinPcapDeviceList.New();
            var interestingDevices = _devices.Where(IsInteresting);

            foreach (var device in interestingDevices)
            {
                device.OnPacketArrival += device_OnPacketArrival;
                device.Open(DeviceMode.Promiscuous, 1000);
                device.Filter           = _filter;
                device.KernelBufferSize = (uint)BufferSize;
                device.StartCapture();
            }
        }
 private void Start()
 {
     Debug.Assert(_devices == null);
     try
     {
         _devices = WinPcapDeviceList.New();
     }
     catch (DllNotFoundException ex)
     {
         throw new NetworkSniffingException("WinPcap is not installed", ex);
     }
     var interestingDevices = _devices.Where(IsInteresting);
     foreach (var device in interestingDevices)
     {
         device.OnPacketArrival += device_OnPacketArrival;
         device.Open(DeviceMode.Promiscuous, 1000);
         device.Filter = _filter;
         if (BufferSize != null)
             device.KernelBufferSize = (uint)BufferSize.Value;
         device.StartCapture();
     }
 }
 private void Start()
 {
     Debug.Assert(_devices == null);
     _devices = WinPcapDeviceList.New();
     var interestingDevices = _devices.Where(IsInteresting);
     foreach (var device in interestingDevices)
     {
         device.OnPacketArrival += device_OnPacketArrival;
         device.Open(DeviceMode.Promiscuous, 1000);
         device.Filter = _filter;
         device.KernelBufferSize = (uint)BufferSize;
         device.StartCapture();
     }
 }
 private void Start()
 {
     Debug.Assert(_devices == null);
     _devices = WinPcapDeviceList.New();
     var interestingDevices = _devices.Where(IsInteresting);
     foreach (var device in interestingDevices)
     {
         device.OnPacketArrival += device_OnPacketArrival;
         device.Open(DeviceMode.Promiscuous, 1000);
         device.Filter = _filter;
         if (BufferSize != null)
         {
             try
             {
                 device.KernelBufferSize = (uint) BufferSize.Value;
             }
             catch (Exception e)
             {
                 Logger.Warn($"Failed to set KernelBufferSize to {BufferSize.Value} on {device.Name}. {e.Message}");
             }
         }
         device.StartCapture();
     }
 }