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
Author:
Brian Wellington
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The length of a DNS Header in wire format.
  • 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.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    int
    getCount(int field)
    Retrieves the record count for the given section
    boolean
    getFlag(int bit)
    Retrieves a flag
    int
    Retrieves the message ID
    int
    Retrieves the mesasge's opcode
    int
    Retrieves the mesasge's rcode
    Converts the header's flags into a String
    void
    setFlag(int bit)
    Sets a flag to the supplied 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
    byte[]
     
    void
    unsetFlag(int bit)
    Sets a flag to the supplied value

    Methods inherited from class java.lang.Object

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

    • 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

      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

      public byte[] toWire()
    • 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:
    • 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:
    • getCount

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

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

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

      public Header clone()
      Overrides:
      clone in class Object