public final class Pcaps
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static BpfProgram |
compileFilter(int snaplen,
DataLinkType dlt,
java.lang.String bpfExpression,
BpfProgram.BpfCompileMode mode,
java.net.Inet4Address netmask) |
static DataLinkType |
dataLinkNameToVal(java.lang.String name) |
static java.lang.String |
dataLinkTypeToDescription(DataLinkType dlt) |
static java.lang.String |
dataLinkTypeToName(DataLinkType dlt) |
static java.lang.String |
dataLinkValToDescription(int dataLinkVal) |
static java.lang.String |
dataLinkValToName(int dataLinkVal) |
static java.util.List<PcapNetworkInterface> |
findAllDevs()
Gets all devices.
|
static PcapNetworkInterface |
getDevByAddress(java.net.InetAddress addr)
Gets a device by IP address.
|
static PcapNetworkInterface |
getDevByName(java.lang.String name)
Gets a device by name.
|
static java.lang.String |
libVersion() |
static java.lang.String |
lookupDev() |
static Inet4NetworkAddress |
lookupNet(java.lang.String devName) |
static PcapHandle |
openDead(DataLinkType dlt,
int snaplen) |
static PcapHandle |
openDead(DataLinkType dlt,
int snaplen,
PcapHandle.TimestampPrecision precision) |
static PcapHandle |
openOffline(java.lang.String filePath) |
static PcapHandle |
openOffline(java.lang.String filePath,
PcapHandle.TimestampPrecision precision) |
static java.lang.String |
strError(int error) |
static java.lang.String |
toBpfString(java.net.InetAddress inetAddr) |
static java.lang.String |
toBpfString(MacAddress macAddr) |
public static java.util.List<PcapNetworkInterface> findAllDevs() throws PcapNativeException
PcapNativeException - if an error occurs in the pcap native library.public static PcapNetworkInterface getDevByAddress(java.net.InetAddress addr) throws PcapNativeException
addr - addrPcapNativeException - if an error occurs in the pcap native library.public static PcapNetworkInterface getDevByName(java.lang.String name) throws PcapNativeException
name - namePcapNativeException - if an error occurs in the pcap native library.public static java.lang.String lookupDev()
throws PcapNativeException
PcapNativeException - if an error occurs in the pcap native library.public static Inet4NetworkAddress lookupNet(java.lang.String devName) throws PcapNativeException
devName - devNameInet4NetworkAddress object.PcapNativeException - if an error occurs in the pcap native library.public static PcapHandle openOffline(java.lang.String filePath) throws PcapNativeException
filePath - "-" means stdinPcapNativeException - if an error occurs in the pcap native library.public static PcapHandle openOffline(java.lang.String filePath, PcapHandle.TimestampPrecision precision) throws PcapNativeException
filePath - "-" means stdinprecision - precisionPcapNativeException - if an error occurs in the pcap native library.public static PcapHandle openDead(DataLinkType dlt, int snaplen) throws PcapNativeException
dlt - dltsnaplen - Snapshot length, which is the number of bytes captured for each packet.PcapNativeException - if an error occurs in the pcap native library.public static PcapHandle openDead(DataLinkType dlt, int snaplen, PcapHandle.TimestampPrecision precision) throws PcapNativeException
dlt - dltsnaplen - Snapshot length, which is the number of bytes captured for each packet.precision - precisionPcapNativeException - if an error occurs in the pcap native library.public static BpfProgram compileFilter(int snaplen, DataLinkType dlt, java.lang.String bpfExpression, BpfProgram.BpfCompileMode mode, java.net.Inet4Address netmask) throws PcapNativeException
snaplen - snaplendlt - dltbpfExpression - bpfExpressionmode - modenetmask - netmaskBpfProgram object.PcapNativeException - if an error occurs in the pcap native library.public static DataLinkType dataLinkNameToVal(java.lang.String name) throws PcapNativeException
name - a data link type name, which is a DLT_ name with the DLT_ removed.DataLinkType object.PcapNativeException - if an error occurs in the pcap native library.public static java.lang.String dataLinkTypeToName(DataLinkType dlt) throws PcapNativeException
dlt - dltPcapNativeException - if an error occurs in the pcap native library.public static java.lang.String dataLinkValToName(int dataLinkVal)
throws PcapNativeException
dataLinkVal - dataLinkValPcapNativeException - if an error occurs in the pcap native library.public static java.lang.String dataLinkTypeToDescription(DataLinkType dlt) throws PcapNativeException
dlt - dltPcapNativeException - if an error occurs in the pcap native library.public static java.lang.String dataLinkValToDescription(int dataLinkVal)
throws PcapNativeException
dataLinkVal - dataLinkValPcapNativeException - if an error occurs in the pcap native library.public static java.lang.String strError(int error)
error - errorpublic static java.lang.String libVersion()
public static java.lang.String toBpfString(java.net.InetAddress inetAddr)
inetAddr - Inet4Address or Inet6Addresspublic static java.lang.String toBpfString(MacAddress macAddr)
macAddr - macAddrCopyright © 2011 - 2018 Pcap4J.org. All rights reserved.