public class Header
extends java.lang.Object
implements java.lang.Cloneable
Message
Modifier and Type | Field and Description |
---|---|
private int[] |
counts |
private int |
flags |
private int |
id |
static int |
LENGTH
The length of a DNS Header in wire format.
|
private static java.util.Random |
random |
Constructor and Description |
---|
Header()
Create a new empty header with a random message id
|
Header(byte[] b)
Creates a new Header from its DNS wire format representation
|
Header(DNSInput in)
Parses a Header from a stream containing DNS wire format.
|
Header(int id)
Create a new empty header.
|
Modifier and Type | Method and Description |
---|---|
private static void |
checkFlag(int bit) |
Header |
clone() |
(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) boolean[] |
getFlags() |
(package private) int |
getFlagsByte() |
int |
getID()
Retrieves the message ID
|
int |
getOpcode()
Retrieves the mesasge's opcode
|
int |
getRcode()
Retrieves the mesasge's rcode
|
(package private) void |
incCount(int field) |
java.lang.String |
printFlags()
Converts the header's flags into a String
|
private void |
printFlags(java.lang.StringBuilder sb) |
(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
|
java.lang.String |
toString()
Converts the header into a String
|
(package private) java.lang.String |
toStringWithRcode(int newrcode) |
byte[] |
toWire() |
(package private) void |
toWire(DNSOutput out) |
void |
unsetFlag(int bit)
Sets a flag to the supplied value
|
private static boolean |
validFlag(int bit) |
private int id
private int flags
private int[] counts
private static final java.util.Random random
public static final int LENGTH
public Header(int id)
id
- The message idpublic Header()
Header(DNSInput in) throws java.io.IOException
java.io.IOException
public Header(byte[] b) throws java.io.IOException
b
- A byte array containing the DNS Header.java.io.IOException
void toWire(DNSOutput out)
public byte[] toWire()
private static boolean validFlag(int bit)
private static void checkFlag(int bit)
static int setFlag(int flags, int bit, boolean value)
public void setFlag(int bit)
Flags
public void unsetFlag(int bit)
Flags
public boolean getFlag(int bit)
Flags
boolean[] getFlags()
public int getID()
public void setID(int id)
public void setRcode(int value)
Rcode
public int getRcode()
Rcode
public void setOpcode(int value)
Opcode
public int getOpcode()
Opcode
void setCount(int field, int value)
void incCount(int field)
void decCount(int field)
public int getCount(int field)
Section
int getFlagsByte()
public java.lang.String printFlags()
private void printFlags(java.lang.StringBuilder sb)
java.lang.String toStringWithRcode(int newrcode)
public java.lang.String toString()
toString
in class java.lang.Object
public Header clone()
clone
in class java.lang.Object