public static final class PcapHandle.Builder extends Object
PcapNetworkInterface#openLive
does
but with more parameters.Constructor and Description |
---|
PcapHandle.Builder(String deviceName) |
Modifier and Type | Method and Description |
---|---|
PcapHandle.Builder |
bufferSize(int bufferSize) |
PcapHandle |
build() |
PcapHandle.Builder |
direction(PcapHandle.PcapDirection direction)
Set direction flag, which controls whether we accept only incoming packets, only outgoing
packets, or both.
|
PcapHandle.Builder |
immediateMode(boolean immediateMode)
Set immediate mode, which allows programs to process packets as soon as they arrive.
|
PcapHandle.Builder |
promiscuousMode(PcapNetworkInterface.PromiscuousMode promiscuousMode) |
PcapHandle.Builder |
rfmon(boolean rfmon) |
PcapHandle.Builder |
snaplen(int snaplen) |
PcapHandle.Builder |
timeoutMillis(int timeoutMillis) |
PcapHandle.Builder |
timestampPrecision(PcapHandle.TimestampPrecision timestampPrecision) |
public PcapHandle.Builder(String deviceName)
deviceName
- A value PcapNetworkInterface.getName()
returns.public PcapHandle.Builder snaplen(int snaplen)
snaplen
- Snapshot length, which is the number of bytes captured for each packet. If
this method isn't called, the platform's default snaplen will be applied at build()
.public PcapHandle.Builder promiscuousMode(PcapNetworkInterface.PromiscuousMode promiscuousMode)
promiscuousMode
- Promiscuous mode. If this method isn't called, the platform's default
mode will be used at build()
.public PcapHandle.Builder rfmon(boolean rfmon)
rfmon
- Whether monitor mode should be set on a PcapHandle when it is built. If true,
monitor mode will be set, otherwise it will not be set. Some platforms don't support
setting monitor mode. Calling this method on such platforms may cause PcapNativeException
at build()
. If this method isn't called, the platform's default mode will be
applied at build()
(if supported).public PcapHandle.Builder timeoutMillis(int timeoutMillis)
timeoutMillis
- Read timeout. Most OSs buffer packets. The OSs pass the packets to
Pcap4j after the buffer gets full or the read timeout expires. Must be non-negative. May
be ignored by some OSs. 0 means disable buffering on Solaris. 0 means infinite on the
other OSs. 1 through 9 means infinite on Solaris. If this method isn't called, the
platform's default timeout will be applied at build()
.public PcapHandle.Builder bufferSize(int bufferSize)
bufferSize
- The buffer size, which is in units of bytes. If this method isn't called,
the platform's default buffer size will be applied at build()
.public PcapHandle.Builder timestampPrecision(PcapHandle.TimestampPrecision timestampPrecision)
timestampPrecision
- The timestamp precision. If this method isn't called, microsecond
precision will be applied at build()
.public PcapHandle.Builder direction(PcapHandle.PcapDirection direction)
direction
- The direction of packets to capture. If this method isn't called, no packets
will be filtered by their direction.public PcapHandle.Builder immediateMode(boolean immediateMode)
immediateMode
- Whether immediate mode should be set on a PcapHandle when it is built.
If true, immediate mode will be set, otherwise it will not be set. Some platforms and
library versions don't support setting immediate mode. Calling this method in such cases
may cause PcapNativeException at build()
. If this method isn't called, immediate
mode will not be set build()
.public PcapHandle build() throws PcapNativeException
PcapNativeException
- if an error occurs in the pcap native library.Copyright © 2011–2019 Pcap4J.org. All rights reserved.