Home / Class/ PcapHeaders Class — netty Architecture

PcapHeaders Class — netty Architecture

Architecture documentation for the PcapHeaders class in PcapHeaders.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  ca377b13_ba44_e9e2_c017_239dcb8201b3["PcapHeaders"]
  320ae17f_5154_c386_dcc5_a3bcc7a01383["PcapHeaders.java"]
  ca377b13_ba44_e9e2_c017_239dcb8201b3 -->|defined in| 320ae17f_5154_c386_dcc5_a3bcc7a01383
  7b0a04ee_efa9_0408_dc32_0ab30f7c2405["PcapHeaders()"]
  ca377b13_ba44_e9e2_c017_239dcb8201b3 -->|method| 7b0a04ee_efa9_0408_dc32_0ab30f7c2405
  1dc2da91_dc52_2985_fef5_28005550d013["writeGlobalHeader()"]
  ca377b13_ba44_e9e2_c017_239dcb8201b3 -->|method| 1dc2da91_dc52_2985_fef5_28005550d013
  003c7cbc_73a3_c2ae_0aa9_ac1564727a55["writePacketHeader()"]
  ca377b13_ba44_e9e2_c017_239dcb8201b3 -->|method| 003c7cbc_73a3_c2ae_0aa9_ac1564727a55

Relationship Graph

Source Code

handler/src/main/java/io/netty/handler/pcap/PcapHeaders.java lines 23–69

final class PcapHeaders {

    /**
     * Pcap Global Header built from:
     * <ol>
     *      <li> magic_number </li>
     *      <li> version_major </li>
     *      <li> version_minor </li>
     *      <li> thiszone </li>
     *      <li> sigfigs </li>
     *      <li> snaplen </li>
     *      <li> network </li>
     * </ol>
     */
    private static final byte[] GLOBAL_HEADER = {-95, -78, -61, -44, 0, 2, 0, 4, 0, 0,
            0, 0, 0, 0, 0, 0, 0, 0, -1, -1, 0, 0, 0, 1};

    private PcapHeaders() {
        // Prevent outside initialization
    }

    /**
     * Writes the Pcap Global Header to the provided {@code OutputStream}
     *
     * @param outputStream OutputStream where Pcap data will be written.
     * @throws IOException if there is an error writing to the {@code OutputStream}
     */
    static void writeGlobalHeader(OutputStream outputStream) throws IOException {
        outputStream.write(GLOBAL_HEADER);
    }

    /**
     * Write Pcap Packet Header
     *
     * @param byteBuf  ByteBuf where we'll write header data
     * @param ts_sec   timestamp seconds
     * @param ts_usec  timestamp microseconds
     * @param incl_len number of octets of packet saved in file
     * @param orig_len actual length of packet
     */
    static void writePacketHeader(ByteBuf byteBuf, int ts_sec, int ts_usec, int incl_len, int orig_len) {
        byteBuf.writeInt(ts_sec);
        byteBuf.writeInt(ts_usec);
        byteBuf.writeInt(incl_len);
        byteBuf.writeInt(orig_len);
    }
}

Frequently Asked Questions

What is the PcapHeaders class?
PcapHeaders is a class in the netty codebase, defined in handler/src/main/java/io/netty/handler/pcap/PcapHeaders.java.
Where is PcapHeaders defined?
PcapHeaders is defined in handler/src/main/java/io/netty/handler/pcap/PcapHeaders.java at line 23.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free