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"); } }
public IpSnifferWinPcap(string filter) { _filter = filter; BufferSize = 1 << 24; _devices = WinPcapDeviceList.New(); _devices = null; }
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(); } }
void Start() { if (listeningToPorts.Count <= 0) { return; } if (devices == null) { devices = WinPcapDeviceList.New(); } var ports = GetStringPorts(); Console.WriteLine("Starting listener id:" + myId + " on ports:" + ports + " ..."); foreach (WinPcapDevice dev in devices) { dev.Open(DeviceMode.Normal); dev.Mode = CaptureMode.Statistics; dev.Filter = GetPortsFilter(); dev.OnPcapStatistics += OnPcapStatistics; dev.StartCapture(); } Console.WriteLine("Started listener id:" + myId + " on ports:" + ports); hasStarted = true; }
public IpSnifferWinPcap(string filter, List <string> servers) { _filter = filter; _servers = servers; BufferSize = 8192 * 1024; _devices = WinPcapDeviceList.New();//check for winpcap installed if not - exception to fallback to rawsockets _devices = null; }
public IpSnifferWinPcap(string filter) { _filter = filter; BufferSize = 1 << 24; _devices = WinPcapDeviceList.New(); //BasicTeraData.LogError(string.Join("\r\n",_devices.Select(x=>x.Description)),true,true); //check for winpcap installed if not - exception to fallback to rawsockets _devices = null; }
private void Start() { Debug.Assert(_devices == null); _devices = WinPcapDeviceList.New(); var interestingDevices = _devices; foreach (var device in interestingDevices) { device.OnPacketArrival += device_OnPacketArrival; device.Open(DeviceMode.Promiscuous, 1000); device.Filter = _filter; 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) { device.KernelBufferSize = (uint)BufferSize.Value; } device.StartCapture(); } }