private void Start() { Debug.Assert(_devices == null); _devices = LibPcapLiveDeviceList.New(); var interestingDevices = _devices.Where(IsInteresting); foreach (var device in interestingDevices) { device.OnPacketArrival += device_OnPacketArrival; try { device.Open(DeviceMode.Normal, 100); } 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"); } }
protected override void OnStarting() { if (Target.IpAddress.Equals(Sender.IpAddress)) { throw new Exception("Target and Sender can't be same"); } _device = LibPcapLiveDeviceList.New()[Device.Name]; }
public IpSnifferWinPcap(string filter) { _filter = filter; BufferSize = 1 << 24; _devices = LibPcapLiveDeviceList.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; }
public void ListTest() { var dl = LibPcapLiveDeviceList.New(); // test that we can look up devices by name foreach (var d in dl) { Assert.IsNotNull(dl[d.Name]); } }
public void Start() { if (IsRunning) { return; } device = LibPcapLiveDeviceList.New()[Device.Name]; device.Open(DeviceMode.Promiscuous, 50); device.Filter = "(ether dst " + device.MacAddress + ") and ip and " + "(not dst " + NetUtils.GeIPv4Address(device) + ")"; device.OnPacketArrival += OnPacketArrival; device.StartCapture(); IsRunning = true; }