Class IpV4Packet.IpV4Header

java.lang.Object
org.pcap4j.packet.AbstractPacket.AbstractHeader
org.pcap4j.packet.IpV4Packet.IpV4Header
All Implemented Interfaces:
Serializable, IpPacket.IpHeader, Packet.Header
Enclosing class:
IpV4Packet

public static final class IpV4Packet.IpV4Header extends AbstractPacket.AbstractHeader implements IpPacket.IpHeader
Since:
pcap4j 0.9.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • logger

      private static final org.slf4j.Logger logger
    • VERSION_AND_IHL_OFFSET

      private static final int VERSION_AND_IHL_OFFSET
      See Also:
    • VERSION_AND_IHL_SIZE

      private static final int VERSION_AND_IHL_SIZE
      See Also:
    • TOS_OFFSET

      private static final int TOS_OFFSET
      See Also:
    • TOS_SIZE

      private static final int TOS_SIZE
      See Also:
    • TOTAL_LENGTH_OFFSET

      private static final int TOTAL_LENGTH_OFFSET
      See Also:
    • TOTAL_LENGTH_SIZE

      private static final int TOTAL_LENGTH_SIZE
      See Also:
    • IDENTIFICATION_OFFSET

      private static final int IDENTIFICATION_OFFSET
      See Also:
    • IDENTIFICATION_SIZE

      private static final int IDENTIFICATION_SIZE
      See Also:
    • FLAGS_AND_FRAGMENT_OFFSET_OFFSET

      private static final int FLAGS_AND_FRAGMENT_OFFSET_OFFSET
      See Also:
    • FLAGS_AND_FRAGMENT_OFFSET_SIZE

      private static final int FLAGS_AND_FRAGMENT_OFFSET_SIZE
      See Also:
    • TTL_OFFSET

      private static final int TTL_OFFSET
      See Also:
    • TTL_SIZE

      private static final int TTL_SIZE
      See Also:
    • PROTOCOL_OFFSET

      private static final int PROTOCOL_OFFSET
      See Also:
    • PROTOCOL_SIZE

      private static final int PROTOCOL_SIZE
      See Also:
    • HEADER_CHECKSUM_OFFSET

      private static final int HEADER_CHECKSUM_OFFSET
      See Also:
    • HEADER_CHECKSUM_SIZE

      private static final int HEADER_CHECKSUM_SIZE
      See Also:
    • SRC_ADDR_OFFSET

      private static final int SRC_ADDR_OFFSET
      See Also:
    • SRC_ADDR_SIZE

      private static final int SRC_ADDR_SIZE
      See Also:
    • DST_ADDR_OFFSET

      private static final int DST_ADDR_OFFSET
      See Also:
    • DST_ADDR_SIZE

      private static final int DST_ADDR_SIZE
      See Also:
    • OPTIONS_OFFSET

      private static final int OPTIONS_OFFSET
      See Also:
    • MIN_IPV4_HEADER_SIZE

      private static final int MIN_IPV4_HEADER_SIZE
      See Also:
    • version

      private final IpVersion version
    • ihl

      private final byte ihl
    • tos

      private final IpV4Packet.IpV4Tos tos
    • totalLength

      private final short totalLength
    • identification

      private final short identification
    • reservedFlag

      private final boolean reservedFlag
    • dontFragmentFlag

      private final boolean dontFragmentFlag
    • moreFragmentFlag

      private final boolean moreFragmentFlag
    • fragmentOffset

      private final short fragmentOffset
    • ttl

      private final byte ttl
    • protocol

      private final IpNumber protocol
    • headerChecksum

      private final short headerChecksum
    • srcAddr

      private final Inet4Address srcAddr
    • dstAddr

      private final Inet4Address dstAddr
    • options

      private final List<IpV4Packet.IpV4Option> options
    • padding

      private final byte[] padding
  • Constructor Details

  • Method Details

    • calcHeaderChecksum

      private short calcHeaderChecksum(boolean zeroInsteadOfChecksum)
    • getVersion

      public IpVersion getVersion()
      Specified by:
      getVersion in interface IpPacket.IpHeader
      Returns:
      version
    • getIhl

      public byte getIhl()
      Returns:
      ihl
    • getIhlAsInt

      public int getIhlAsInt()
      Returns:
      ihl
    • getTos

      public IpV4Packet.IpV4Tos getTos()
      Returns:
      tos
    • getTotalLength

      public short getTotalLength()
      Returns:
      totalLength
    • getTotalLengthAsInt

      public int getTotalLengthAsInt()
      Returns:
      totalLength
    • getIdentification

      public short getIdentification()
      Returns:
      identification
    • getIdentificationAsInt

      public int getIdentificationAsInt()
      Returns:
      identification
    • getReservedFlag

      public boolean getReservedFlag()
      Returns:
      reservedFlag
    • getDontFragmentFlag

      public boolean getDontFragmentFlag()
      Returns:
      dontFragmentFlag
    • getMoreFragmentFlag

      public boolean getMoreFragmentFlag()
      Returns:
      moreFragmentFlag
    • getFragmentOffset

      public short getFragmentOffset()
      Returns:
      fragmentOffset
    • getTtl

      public byte getTtl()
      Returns:
      ttl
    • getTtlAsInt

      public int getTtlAsInt()
      Returns:
      ttl
    • getProtocol

      public IpNumber getProtocol()
      Specified by:
      getProtocol in interface IpPacket.IpHeader
      Returns:
      an IpNumber object which indicates the protocol of the following header.
    • getHeaderChecksum

      public short getHeaderChecksum()
      Returns:
      headerChecksum
    • getSrcAddr

      public Inet4Address getSrcAddr()
      Specified by:
      getSrcAddr in interface IpPacket.IpHeader
      Returns:
      srcAddr
    • getDstAddr

      public Inet4Address getDstAddr()
      Specified by:
      getDstAddr in interface IpPacket.IpHeader
      Returns:
      dstAddr
    • getOptions

      public List<IpV4Packet.IpV4Option> getOptions()
      Returns:
      options
    • getPadding

      public byte[] getPadding()
      Returns:
      padding
    • hasValidChecksum

      public boolean hasValidChecksum(boolean acceptZero)
      Parameters:
      acceptZero - acceptZero
      Returns:
      true if the packet represented by this object has a valid checksum; false otherwise.
    • getRawFields

      protected List<byte[]> getRawFields()
      Description copied from class: AbstractPacket.AbstractHeader
      Returns a list of byte arrays which represents this header's fields. This method is called by calcLength() and buildRawData().
      Specified by:
      getRawFields in class AbstractPacket.AbstractHeader
      Returns:
      a list of byte arrays which represents this header's fields
    • getRawFields

      private List<byte[]> getRawFields(boolean zeroInsteadOfChecksum)
    • buildRawData

      private byte[] buildRawData(boolean zeroInsteadOfChecksum)
    • measureLengthWithoutPadding

      private int measureLengthWithoutPadding()
    • calcLength

      protected int calcLength()
      Description copied from class: AbstractPacket.AbstractHeader
      This method calculates the value length() will return by adding up the lengths of byte arrays in the list getRawFields() returns.
      Overrides:
      calcLength in class AbstractPacket.AbstractHeader
      Returns:
      a calculated length
    • buildString

      protected String buildString()
      Description copied from class: AbstractPacket.AbstractHeader
      This method builds the value toString() will return.
      Overrides:
      buildString in class AbstractPacket.AbstractHeader
      Returns:
      a string representation of this object
    • equals

      public boolean equals(Object obj)
      Description copied from class: AbstractPacket.AbstractHeader
      Indicates whether some other object is "equal to" this one using return values of getRawData(). This method should be overridden so that it does more strict comparisons more efficiently.
      Overrides:
      equals in class AbstractPacket.AbstractHeader
    • calcHashCode

      protected int calcHashCode()
      Description copied from class: AbstractPacket.AbstractHeader
      This method builds the value hashCode() will return using the byte array getRawData() returns. This method may be better to be overridden for performance reason.
      Overrides:
      calcHashCode in class AbstractPacket.AbstractHeader
      Returns:
      a calculated hash code value for the object