Class DnsPacket.DnsHeader

  • All Implemented Interfaces:
    java.io.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                    |
     +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
     
    Author:
    Kaito Yamada
    See Also:
    RFC 1035, RFC 2535, Serialized Form
    • Method Detail

      • 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 java.util.List<DnsQuestion> getQuestions()
        Returns:
        questions
      • getAnswers

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

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

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