Package com.silabs.na.pcap.impl
Class PcapInputNio
- java.lang.Object
-
- com.silabs.na.pcap.impl.PcapInputNio
-
- All Implemented Interfaces:
IPcapInput
,java.io.Closeable
,java.lang.AutoCloseable
public class PcapInputNio extends java.lang.Object implements IPcapInput
The PCAP implementation variant. https://wiki.wireshark.org/Development/LibpcapFileFormat
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAGIC
static int
NANOSEC_MAGIC
-
Constructor Summary
Constructors Constructor Description PcapInputNio(java.nio.channels.ReadableByteChannel rbc, boolean isBigEndian, boolean isNanosec)
Starts the pcap stream, with the is rolled up at 4 bytes into it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the streams.int
network()
Returns the network ID.Block
nextBlock()
Returns next packet block, or null when at the end of the file.int
snapLen()
SNAP len, defining max length of the packet.java.lang.String
type()
Returns type of the file.java.lang.String
version()
Returns version string of this PCAP file.
-
-
-
Field Detail
-
MAGIC
public static final int MAGIC
- See Also:
- Constant Field Values
-
NANOSEC_MAGIC
public static final int NANOSEC_MAGIC
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PcapInputNio
public PcapInputNio(java.nio.channels.ReadableByteChannel rbc, boolean isBigEndian, boolean isNanosec) throws java.io.IOException
Starts the pcap stream, with the is rolled up at 4 bytes into it.- Parameters:
rbc
- Byte channel that contains data.isBigEndian
- Specifies the endianess of the file.isNanosec
- Specify if timestamps are micro- or nano-seconds.- Throws:
java.io.IOException
- if anything goes wrong with the IO operations.
-
-
Method Detail
-
version
public java.lang.String version()
Returns version string of this PCAP file.- Returns:
- String, represeting the version.
-
network
public int network()
Returns the network ID.- Returns:
- int, representing network.
-
snapLen
public int snapLen()
SNAP len, defining max length of the packet.- Returns:
- value of SNAP len
-
nextBlock
public Block nextBlock() throws java.io.IOException
Returns next packet block, or null when at the end of the file.- Specified by:
nextBlock
in interfaceIPcapInput
- Returns:
- next block read from the input.
- Throws:
java.io.IOException
- if anything goes wrong with the underlying IO operations.
-
type
public java.lang.String type()
Returns type of the file. In this case, "pcap".- Specified by:
type
in interfaceIPcapInput
- Returns:
- "pcap"
-
close
public void close() throws java.io.IOException
Closes the streams.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-