Package com.silabs.na.pcap.impl
Class PcapngOutput
- java.lang.Object
-
- com.silabs.na.pcap.impl.PcapngOutput
-
- All Implemented Interfaces:
IPcapOutput
,java.io.Closeable
,java.lang.AutoCloseable
public class PcapngOutput extends java.lang.Object implements IPcapOutput
Pcapng implementation of the output stream.
-
-
Constructor Summary
Constructors Constructor Description PcapngOutput(java.io.File f)
Creates the output stream for the pcapng.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the output stream.void
writeEnhancedPacketBlock(int interfaceId, long timestamp, byte[] data)
Writes enhanced packet block.void
writeInterfaceDescriptionBlock(LinkType linkType, int timestampResolution)
Writes an interface description block.void
writeSectionHeaderBlock(java.lang.String hardware, java.lang.String osName, java.lang.String applicationName)
Writes a section header block.
-
-
-
Method Detail
-
writeInterfaceDescriptionBlock
public void writeInterfaceDescriptionBlock(LinkType linkType, int timestampResolution) throws java.io.IOException
Writes an interface description block. You MUST write one of those before you write enhanced packet block.- Specified by:
writeInterfaceDescriptionBlock
in interfaceIPcapOutput
- Parameters:
linkType
- Link type for the block.timestampResolution
- Timestamp resolution for the block. See Pcap.RESOLUTION_* constants.- Throws:
java.io.IOException
- in case of errors with underlying IO operations
-
writeEnhancedPacketBlock
public void writeEnhancedPacketBlock(int interfaceId, long timestamp, byte[] data) throws java.io.IOException
Writes enhanced packet block.- Specified by:
writeEnhancedPacketBlock
in interfaceIPcapOutput
- Parameters:
interfaceId
- Interface id of this packet. The interface description block with a given interface id had to exist earlier in the file.timestamp
- Timestamp in nanoseconds.data
- Payload of the packet.- Throws:
java.io.IOException
- in case of errors with underlying IO operations.
-
writeSectionHeaderBlock
public void writeSectionHeaderBlock(java.lang.String hardware, java.lang.String osName, java.lang.String applicationName) throws java.io.IOException
Writes a section header block.- Parameters:
hardware
- String describing hardware used for creating this file.osName
- String describing operating system used in creation of this file.applicationName
- Name of the application creating the PCAPNG file.- Throws:
java.io.IOException
- in case of underlying IO exceptions.
-
close
public void close() throws java.io.IOException
Closes the output stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
-