-
-
Notifications
You must be signed in to change notification settings - Fork 1
PCAP.Filter
PCAP.Filter
Protected Class FilterThis class represents a compiled filter program generated from a high level filtering expression. It is used by the driver to decide which packets will be received by a Capture.
A Capture instance may only use one filter program at a time. Changing the current filter affects all subsequently received packets, but does not affect packets already captured by the driver under the previous filter (if any).
Each instance of Filter is compiled for a specific instance of Capture. If you assign a Filter compiled for one Capture to a different Capture then the Expression is recompiled. Not all legal filtering expressions will be valid for all possible Capture instances, in which case a PCACPException will be raised with a (hopefully) useful error message explaining the incompatibility.
You cannot create an instance of Filter from an invalid or illegal filtering expression. As such, any non-Nil reference to an instance of this class is guaranteed to be a valid filter program for the Source Capture instance.
This example creates a Capture that only receives TCP packets on port 80:
Dim cap As PCAP.Capture = PCAP.BeginCapture(PCAP.GetCaptureDevice(0))
Dim fp As PCAP.Filter = PCAP.Filter.Compile("tcp and port 80", cap)
If fp <> Nil Then
cap.CurrentFilter = fp
Else
Call MsgBox(PCAP.Filter.LastCompileError, 16, "Filter compile error")
End IfWiki home | Project page | Bugs | Become a sponsor
Text, images, and code examples are Copyright ©2014-26 Andrew Lambert, offered under the CC BY-SA 3.0 License.