/// <summary> /// Runs the program and returns if a given filter applies to the packet /// </summary> /// <param name="bpfProgram"> /// A <see cref="IntPtr"/> /// </param> public bool Matches(ReadOnlySpan <byte> data) { var header = new PcapHeader(0, 0, (uint)data.Length, (uint)data.Length); var hdrPtr = header.MarshalToIntPtr(TimestampResolution.Microsecond); int result; unsafe { fixed(byte *p_packet = data) { result = LibPcapSafeNativeMethods.pcap_offline_filter(this, hdrPtr, new IntPtr(p_packet)); } } Marshal.FreeHGlobal(hdrPtr); return(result != 0); }
/// <summary> /// Runs the program and returns if a given filter applies to the packet /// </summary> /// <param name="bpfProgram"> /// A <see cref="IntPtr"/> /// </param> public bool Matches(ReadOnlySpan <byte> data) { var header = new PcapHeader() { CaptureLength = (uint)data.Length, PacketLength = (uint)data.Length, }; IntPtr hdrPtr = header.MarshalToIntPtr(); int result; unsafe { fixed(byte *p_packet = data) { result = LibPcapSafeNativeMethods.pcap_offline_filter(this, hdrPtr, new IntPtr(p_packet)); } } Marshal.FreeHGlobal(hdrPtr); return(result != 0); }
public static bool RunBpfProgram(IntPtr bpfProgram, IntPtr header, IntPtr data) { return(LibPcapSafeNativeMethods.pcap_offline_filter(bpfProgram, header, data)); }
public static bool RunBpfProgram(IntPtr bpfProgram, IntPtr header, IntPtr data) { var result = LibPcapSafeNativeMethods.pcap_offline_filter(bpfProgram, header, data); return(result != 0); }
public bool Matches(IntPtr header, IntPtr data) { var result = LibPcapSafeNativeMethods.pcap_offline_filter(this, header, data); return(result != 0); }