Class PcapWriteHandler

All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler, ChannelOutboundHandler, java.io.Closeable, java.lang.AutoCloseable

public final class PcapWriteHandler extends ChannelDuplexHandler implements java.io.Closeable

PcapWriteHandler captures ByteBuf from SocketChannel / ServerChannel or DatagramPacket and writes it into Pcap OutputStream.

Things to keep in mind when using PcapWriteHandler with TCP:

  • Field Details

    • logger

      private final InternalLogger logger
      Logger for logging events
    • pCapWriter

      private PcapWriter pCapWriter
      PcapWriter Instance
    • outputStream

      private final java.io.OutputStream outputStream
      OutputStream where we'll write Pcap data.
    • captureZeroByte

      private final boolean captureZeroByte
      true if we want to capture packets with zero bytes else false.
    • writePcapGlobalHeader

      private final boolean writePcapGlobalHeader
      true if we want to write Pcap Global Header on initialization of PcapWriter else false.
    • sharedOutputStream

      private final boolean sharedOutputStream
      true if we want to synchronize on the OutputStream while writing else false.
    • sendSegmentNumber

      private long sendSegmentNumber
      TCP Sender Segment Number. It'll start with 1 and keep incrementing with number of bytes read/sent and wrap at the uint32 max.
    • receiveSegmentNumber

      private long receiveSegmentNumber
      TCP Receiver Segment Number. It'll start with 1 and keep incrementing with number of bytes read/sent and wrap at the uint32 max
    • channelType

      private PcapWriteHandler.ChannelType channelType
      Type of the channel this handler is registered on
    • initiatorAddr

      private java.net.InetSocketAddress initiatorAddr
      Address of the initiator of the connection
    • handlerAddr

      private java.net.InetSocketAddress handlerAddr
      Address of the receiver of the connection
    • isServerPipeline

      private boolean isServerPipeline
      Set to true if this handler is registered on a server pipeline
    • state

      private final java.util.concurrent.atomic.AtomicReference<State> state
      Current of this PcapWriteHandler
  • Constructor Details

    • PcapWriteHandler

      @Deprecated public PcapWriteHandler(java.io.OutputStream outputStream)
      Deprecated.
      Create new PcapWriteHandler Instance. captureZeroByte is set to false and writePcapGlobalHeader is set to true.
      Parameters:
      outputStream - OutputStream where Pcap data will be written. Call close() to close this OutputStream.
      Throws:
      java.lang.NullPointerException - If OutputStream is null then we'll throw an NullPointerException
    • PcapWriteHandler

      @Deprecated public PcapWriteHandler(java.io.OutputStream outputStream, boolean captureZeroByte, boolean writePcapGlobalHeader)
      Deprecated.
      Create new PcapWriteHandler Instance
      Parameters:
      outputStream - OutputStream where Pcap data will be written. Call close() to close this OutputStream.
      captureZeroByte - Set to true to enable capturing packets with empty (0 bytes) payload. Otherwise, if set to false, empty packets will be filtered out.
      writePcapGlobalHeader - Set to true to write Pcap Global Header on initialization. Otherwise, if set to false, Pcap Global Header will not be written on initialization. This could when writing Pcap data on a existing file where Pcap Global Header is already present.
      Throws:
      java.lang.NullPointerException - If OutputStream is null then we'll throw an NullPointerException
    • PcapWriteHandler

      private PcapWriteHandler(PcapWriteHandler.Builder builder, java.io.OutputStream outputStream)
  • Method Details