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 voidclose()Closes the output stream.voidwriteEnhancedPacketBlock(int interfaceId, long timestamp, byte[] data)Writes enhanced packet block.voidwriteInterfaceDescriptionBlock(LinkType linkType, int timestampResolution)Writes an interface description block.voidwriteSectionHeaderBlock(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:
writeInterfaceDescriptionBlockin 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.IOExceptionWrites enhanced packet block.- Specified by:
writeEnhancedPacketBlockin 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.IOExceptionWrites 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.IOExceptionCloses the output stream.- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-