Package org.xbill.DNS

Class Header

java.lang.Object
org.xbill.DNS.Header
All Implemented Interfaces:
Cloneable

public class Header extends Object implements Cloneable
A DNS message header
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private int[]
     
    private int
     
    private int
     
    static final int
    The length of a DNS Header in wire format.
    private static final Random
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new empty header with a random message id
    Header(byte[] b)
    Creates a new Header from its DNS wire format representation
    Header(int id)
    Create a new empty header.
    Parses a Header from a stream containing DNS wire format.
  • Method Summary

    Modifier and Type
    Method
    Description
    private static void
    checkFlag(int bit)
     
     
    (package private) void
    decCount(int field)
     
    int
    getCount(int field)
    Retrieves the record count for the given section
    boolean
    getFlag(int bit)
    Retrieves a flag
    (package private) static boolean
    getFlag(int flags, int bit)
     
    (package private) boolean[]
     
    (package private) int
     
    int
    Retrieves the message ID
    int
    Retrieves the mesasge's opcode
    int
    Retrieves the mesasge's rcode
    (package private) void
    incCount(int field)
     
    Converts the header's flags into a String
    private void
     
    (package private) void
    setCount(int field, int value)
     
    void
    setFlag(int bit)
    Sets a flag to the supplied value
    (package private) static int
    setFlag(int flags, int bit, boolean value)
     
    void
    setID(int id)
    Sets the message ID
    void
    setOpcode(int value)
    Sets the message's opcode
    void
    setRcode(int value)
    Sets the message's rcode
    Converts the header into a String
    (package private) String
    toStringWithRcode(int newrcode)
     
    byte[]
     
    (package private) void
     
    void
    unsetFlag(int bit)
    Sets a flag to the supplied value
    private static boolean
    validFlag(int bit)
     

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • id

      private int id
    • flags

      private int flags
    • counts

      private int[] counts
    • random

      private static final Random random
    • LENGTH

      public static final int LENGTH
      The length of a DNS Header in wire format.
      See Also:
  • Constructor Details

    • Header

      public Header(int id)
      Create a new empty header.
      Parameters:
      id - The message id
    • Header

      public Header()
      Create a new empty header with a random message id
    • Header

      Header(DNSInput in) throws IOException
      Parses a Header from a stream containing DNS wire format.
      Throws:
      IOException
    • Header

      public Header(byte[] b) throws IOException
      Creates a new Header from its DNS wire format representation
      Parameters:
      b - A byte array containing the DNS Header.
      Throws:
      IOException
  • Method Details

    • toWire

      void toWire(DNSOutput out)
    • toWire

      public byte[] toWire()
    • validFlag

      private static boolean validFlag(int bit)
    • checkFlag

      private static void checkFlag(int bit)
    • setFlag

      static int setFlag(int flags, int bit, boolean value)
    • getFlag

      static boolean getFlag(int flags, int bit)
    • setFlag

      public void setFlag(int bit)
      Sets a flag to the supplied value
      See Also:
    • unsetFlag

      public void unsetFlag(int bit)
      Sets a flag to the supplied value
      See Also:
    • getFlag

      public boolean getFlag(int bit)
      Retrieves a flag
      See Also:
    • getFlags

      boolean[] getFlags()
    • getID

      public int getID()
      Retrieves the message ID
    • setID

      public void setID(int id)
      Sets the message ID
    • setRcode

      public void setRcode(int value)
      Sets the message's rcode
      See Also:
    • getRcode

      public int getRcode()
      Retrieves the mesasge's rcode
      See Also:
    • setOpcode

      public void setOpcode(int value)
      Sets the message's opcode
      See Also:
    • getOpcode

      public int getOpcode()
      Retrieves the mesasge's opcode
      See Also:
    • setCount

      void setCount(int field, int value)
    • incCount

      void incCount(int field)
    • decCount

      void decCount(int field)
    • getCount

      public int getCount(int field)
      Retrieves the record count for the given section
      See Also:
    • getFlagsByte

      int getFlagsByte()
    • printFlags

      public String printFlags()
      Converts the header's flags into a String
    • printFlags

      private void printFlags(StringBuilder sb)
    • toStringWithRcode

      String toStringWithRcode(int newrcode)
    • toString

      public String toString()
      Converts the header into a String
      Overrides:
      toString in class Object
    • clone

      public Header clone()
      Overrides:
      clone in class Object