Class DnsPacket.DnsHeader

All Implemented Interfaces:
Serializable, Packet.Header
Enclosing class:
DnsPacket

public static final class DnsPacket.DnsHeader extends AbstractPacket.AbstractHeader
DNS header
 +---------------------+
 |        Header       |
 +---------------------+
 |       Question      | the question for the name server
 +---------------------+
 |        Answer       | RRs answering the question
 +---------------------+
 |      Authority      | RRs pointing toward an authority
 +---------------------+
 |      Additional     | RRs holding additional information
 +---------------------+

 Header:
                                 1  1  1  1  1  1
   0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                      ID                       |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |QR|   Opcode  |AA|TC|RD|RA| Z|AD|CD|   RCODE   |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                    QDCOUNT                    |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                    ANCOUNT                    |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                    NSCOUNT                    |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 |                    ARCOUNT                    |
 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
 
Version:
pcap4j 1.7.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • ID_OFFSET

      private static final int ID_OFFSET
      See Also:
    • ID_SIZE

      private static final int ID_SIZE
      See Also:
    • FLAGS_OFFSET

      private static final int FLAGS_OFFSET
      See Also:
    • FLAGS_SIZE

      private static final int FLAGS_SIZE
      See Also:
    • QDCOUNT_OFFSET

      private static final int QDCOUNT_OFFSET
      See Also:
    • QDCOUNT_SIZE

      private static final int QDCOUNT_SIZE
      See Also:
    • ANCOUNT_OFFSET

      private static final int ANCOUNT_OFFSET
      See Also:
    • ANCOUNT_SIZE

      private static final int ANCOUNT_SIZE
      See Also:
    • NSCOUNT_OFFSET

      private static final int NSCOUNT_OFFSET
      See Also:
    • NSCOUNT_SIZE

      private static final int NSCOUNT_SIZE
      See Also:
    • ARCOUNT_OFFSET

      private static final int ARCOUNT_OFFSET
      See Also:
    • ARCOUNT_SIZE

      private static final int ARCOUNT_SIZE
      See Also:
    • DNS_MIN_HEADER_SIZE

      private static final int DNS_MIN_HEADER_SIZE
      See Also:
    • id

      private final short id
    • response

      private final boolean response
    • opCode

      private final DnsOpCode opCode
    • authoritativeAnswer

      private final boolean authoritativeAnswer
    • truncated

      private final boolean truncated
    • recursionDesired

      private final boolean recursionDesired
    • recursionAvailable

      private final boolean recursionAvailable
    • reserved

      private final boolean reserved
    • authenticData

      private final boolean authenticData
    • checkingDisabled

      private final boolean checkingDisabled
    • rCode

      private final DnsRCode rCode
    • qdCount

      private final short qdCount
    • anCount

      private final short anCount
    • nsCount

      private final short nsCount
    • arCount

      private final short arCount
    • questions

      private final List<DnsQuestion> questions
    • answers

      private final List<DnsResourceRecord> answers
    • authorities

      private final List<DnsResourceRecord> authorities
    • additionalInfo

      private final List<DnsResourceRecord> additionalInfo
  • Constructor Details

  • Method Details

    • getId

      public short getId()
      Returns:
      id
    • isResponse

      public boolean isResponse()
      Returns:
      true if the QR bit is set to 1; false otherwise.
    • getOpCode

      public DnsOpCode getOpCode()
      Returns:
      opCode
    • isAuthoritativeAnswer

      public boolean isAuthoritativeAnswer()
      Returns:
      true if the AA bit is set to 1; false otherwise.
    • isTruncated

      public boolean isTruncated()
      Returns:
      true if the TC bit is set to 1; false otherwise.
    • isRecursionDesired

      public boolean isRecursionDesired()
      Returns:
      true if the RD bit is set to 1; false otherwise.
    • isRecursionAvailable

      public boolean isRecursionAvailable()
      Returns:
      true if the RA bit is set to 1; false otherwise.
    • getReservedBit

      public boolean getReservedBit()
      Returns:
      true if the Z bit is set to 1; false otherwise.
    • isAuthenticData

      public boolean isAuthenticData()
      Returns:
      true if the AD bit is set to 1; false otherwise.
    • isCheckingDisabled

      public boolean isCheckingDisabled()
      Returns:
      true if the CD bit is set to 1; false otherwise.
    • getrCode

      public DnsRCode getrCode()
      Returns:
      rCode
    • getQdCount

      public short getQdCount()
      Returns:
      qdCount
    • getQdCountAsInt

      public int getQdCountAsInt()
      Returns:
      qdCount
    • getAnCount

      public short getAnCount()
      Returns:
      anCount
    • getAnCountAsInt

      public int getAnCountAsInt()
      Returns:
      anCount
    • getNsCount

      public short getNsCount()
      Returns:
      nsCount
    • getNsCountAsInt

      public int getNsCountAsInt()
      Returns:
      nsCount
    • getArCount

      public short getArCount()
      Returns:
      arCount
    • getArCountAsInt

      public int getArCountAsInt()
      Returns:
      arCount
    • getQuestions

      public List<DnsQuestion> getQuestions()
      Returns:
      questions
    • getAnswers

      public List<DnsResourceRecord> getAnswers()
      Returns:
      answers
    • getAuthorities

      public List<DnsResourceRecord> getAuthorities()
      Returns:
      authorities
    • getAdditionalInfo

      public List<DnsResourceRecord> getAdditionalInfo()
      Returns:
      additionalInfo
    • 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
    • length

      public int length()
      Description copied from class: AbstractPacket.AbstractHeader
      Returns the header length in bytes. This method calls calcLength() and caches the return value when it is called for the first time, and then, this method returns the cached value from the second time.
      Specified by:
      length in interface Packet.Header
      Overrides:
      length in class AbstractPacket.AbstractHeader
      Returns:
      the length of the byte stream of the header represented by this object in bytes
    • 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