- java.lang.Object
-
- org.pcap4j.core.BpfProgram
-
public final class BpfProgram extends java.lang.Object- Since:
- pcap4j 0.9.16
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBpfProgram.BpfCompileMode
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringexpressionprivate booleanfreedprivate java.lang.Objectlockprivate NativeMappings.bpf_programprogram
-
Constructor Summary
Constructors Constructor Description BpfProgram(NativeMappings.bpf_program program, java.lang.String expression)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplyFilter(byte[] packet)Apply the filter on a given packet.booleanapplyFilter(byte[] packet, int orgPacketLen, int packetLen)Apply the filter on a given packet.booleanapplyFilter(Packet packet)Apply the filter on a given packet.voidfree()java.lang.StringgetExpression()(package private) NativeMappings.bpf_programgetProgram()booleanisFreed()
-
-
-
Field Detail
-
program
private final NativeMappings.bpf_program program
-
expression
private final java.lang.String expression
-
freed
private volatile boolean freed
-
lock
private final java.lang.Object lock
-
-
Constructor Detail
-
BpfProgram
BpfProgram(NativeMappings.bpf_program program, java.lang.String expression)
-
-
Method Detail
-
getProgram
NativeMappings.bpf_program getProgram()
-
getExpression
public java.lang.String getExpression()
- Returns:
- expression
-
applyFilter
public boolean applyFilter(Packet packet)
Apply the filter on a given packet. Return true if the packet given passes the filter that is built from this program.- Parameters:
packet- the packet to apply the filter on- Returns:
- true if this program is not freed and the packet passes the filter; false otherwise.
-
applyFilter
public boolean applyFilter(byte[] packet)
Apply the filter on a given packet. Return true if the packet given passes the filter that is built from this program.- Parameters:
packet- the packet to apply the filter on- Returns:
- true if this program is not freed and the packet passes the filter; false otherwise.
-
applyFilter
public boolean applyFilter(byte[] packet, int orgPacketLen, int packetLen)Apply the filter on a given packet. Return true if the packet given passes the filter that is built from this program.- Parameters:
packet- a byte array including the packet to apply the filter onorgPacketLen- the length of the original packetpacketLen- the length of the packet present- Returns:
- true if this program is not freed and the packet passes the filter; false otherwise.
-
isFreed
public boolean isFreed()
- Returns:
- true if the bpf_program represented by this object is freed; false otherwise.
-
free
public void free()
-
-