java.lang.Object
org.pcap4j.core.Pcaps
- Since:
- pcap4j 0.9.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BpfProgramcompileFilter(int snaplen, DataLinkType dlt, String bpfExpression, BpfProgram.BpfCompileMode mode, Inet4Address netmask) static DataLinkTypedataLinkNameToVal(String name) static Stringstatic Stringstatic StringdataLinkValToDescription(int dataLinkVal) static StringdataLinkValToName(int dataLinkVal) static List<PcapNetworkInterface> Gets all devices.static PcapNetworkInterfacegetDevByAddress(InetAddress addr) Gets a device by IP address.static PcapNetworkInterfacegetDevByName(String name) Gets a device by name.static Stringstatic Stringstatic Inet4NetworkAddressstatic PcapHandleopenDead(DataLinkType dlt, int snaplen) static PcapHandleopenDead(DataLinkType dlt, int snaplen, PcapHandle.TimestampPrecision precision) static PcapHandleopenOffline(String filePath) static PcapHandleopenOffline(String filePath, PcapHandle.TimestampPrecision precision) static StringstrError(int error) static StringtoBpfString(InetAddress inetAddr) static StringtoBpfString(MacAddress macAddr)
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
lock
-
-
Constructor Details
-
Pcaps
private Pcaps()
-
-
Method Details
-
findAllDevs
Gets all devices.- Returns:
- a list of PcapNetworkInterfaces.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
getDevByAddress
Gets a device by IP address.- Parameters:
addr- addr- Returns:
- a PcapNetworkInterface.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
getDevByName
Gets a device by name.- Parameters:
name- name- Returns:
- a PcapNetworkInterface.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
lookupDev
- Returns:
- a name of a network interface.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
lookupNet
- Parameters:
devName- devName- Returns:
- an
Inet4NetworkAddressobject. - Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
openOffline
- Parameters:
filePath- "-" means stdin- Returns:
- a new PcapHandle object.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
openOffline
public static PcapHandle openOffline(String filePath, PcapHandle.TimestampPrecision precision) throws PcapNativeException - Parameters:
filePath- "-" means stdinprecision- precision- Returns:
- a new PcapHandle object.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
openDead
- Parameters:
dlt- dltsnaplen- Snapshot length, which is the number of bytes captured for each packet.- Returns:
- a new PcapHandle object.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
openDead
public static PcapHandle openDead(DataLinkType dlt, int snaplen, PcapHandle.TimestampPrecision precision) throws PcapNativeException - Parameters:
dlt- dltsnaplen- Snapshot length, which is the number of bytes captured for each packet.precision- precision- Returns:
- a new PcapHandle object.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
compileFilter
public static BpfProgram compileFilter(int snaplen, DataLinkType dlt, String bpfExpression, BpfProgram.BpfCompileMode mode, Inet4Address netmask) throws PcapNativeException - Parameters:
snaplen- snaplendlt- dltbpfExpression- bpfExpressionmode- modenetmask- netmask- Returns:
- a
BpfProgramobject. - Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
dataLinkNameToVal
- Parameters:
name- a data link type name, which is a DLT_ name with the DLT_ removed.- Returns:
- a
DataLinkTypeobject. - Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
dataLinkTypeToName
- Parameters:
dlt- dlt- Returns:
- data link type name
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
dataLinkValToName
- Parameters:
dataLinkVal- dataLinkVal- Returns:
- data link type name
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
dataLinkTypeToDescription
- Parameters:
dlt- dlt- Returns:
- a short description of that data link type.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
dataLinkValToDescription
- Parameters:
dataLinkVal- dataLinkVal- Returns:
- a short description of that data link type.
- Throws:
PcapNativeException- if an error occurs in the pcap native library.
-
strError
- Parameters:
error- error- Returns:
- an error message.
-
libVersion
- Returns:
- a string giving information about the version of the libpcap library being used; note that it contains more information than just a version number.
-
toBpfString
- Parameters:
inetAddr- Inet4Address or Inet6Address- Returns:
- a string representation of an InetAddress for BPF.
-
toBpfString
- Parameters:
macAddr- macAddr- Returns:
- a string representation of a MAC address for BPF.
-