public class DNSMessage extends Object
parse(byte[])
) or serialized
(toArray()
).Modifier and Type | Class and Description |
---|---|
static class |
DNSMessage.OPCODE
Symbolic DNS Opcode values.
|
static class |
DNSMessage.RESPONSE_CODE
Possible DNS reply codes.
|
Modifier and Type | Field and Description |
---|---|
protected Record[] |
additionalResourceRecords
Additional resousrce records.
|
protected Record[] |
answers
The answers section content.
|
protected boolean |
authenticData
True if the server regarded the response as authentic.
|
protected boolean |
authoritativeAnswer
True if this is a authorative response.
|
protected boolean |
checkDisabled
True if the server should not check the replies.
|
protected int |
id
The DNS message id.
|
protected Record[] |
nameserverRecords
The nameserver records.
|
protected DNSMessage.OPCODE |
opcode
The DNS message opcode.
|
protected boolean |
query
True if this is a query.
|
protected Question[] |
questions
The question section content.
|
protected long |
receiveTimestamp
The receive timestamp of this message.
|
protected boolean |
recursionAvailable
True if recursion is possible.
|
protected boolean |
recursionDesired
True if the server should recurse.
|
protected DNSMessage.RESPONSE_CODE |
responseCode
The response code of this dns message.
|
protected boolean |
truncated
True on truncate, tcp should be used.
|
Constructor and Description |
---|
DNSMessage() |
Modifier and Type | Method and Description |
---|---|
Record[] |
getAdditionalResourceRecords()
Retrieve the additional resource records attached to this DNS message.
|
Record[] |
getAnswers()
Retrieve the answer records of this DNS message.
|
int |
getId()
Retrieve the current DNS message id.
|
Record[] |
getNameserverRecords()
Retrieve the nameserver records of this DNS message.
|
DNSMessage.OPCODE |
getOpcode()
Retrieve the opcode of this message.
|
Question[] |
getQuestions()
Retrieve the question section of this message.
|
long |
getReceiveTimestamp()
Get the receive timestamp if this message was created via parse.
|
DNSMessage.RESPONSE_CODE |
getResponseCode()
Retrieve the response code of this message.
|
boolean |
isAuthenticData()
Retrieve the authentic data flag of this message.
|
boolean |
isAuthoritativeAnswer()
True if the DNS message is an authoritative answer.
|
boolean |
isCheckDisabled()
Check if checks are disabled.
|
boolean |
isQuery()
Retrieve the query type (true or false;
|
boolean |
isRecursionAvailable()
Retrieve the recursion available flag of this DNS message.
|
boolean |
isRecursionDesired()
Check if this message preferes recursion.
|
boolean |
isTruncated()
Retrieve the truncation status of this message.
|
static DNSMessage |
parse(byte[] data)
Build a DNS Message based on a binary DNS message.
|
void |
setAuthenticData(boolean authenticData)
Set the authentic data flag on this DNS message.
|
void |
setAuthoritativeAnswer(boolean authoritativeAnswer)
Set the authoritative answer flag.
|
void |
setCheckDisabled(boolean checkDisabled)
Change the check status of this packet.
|
void |
setId(int id)
Set the current DNS message id.
|
void |
setQuery(boolean query)
Set the query status of this message.
|
void |
setQuestions(Question... questions)
Set the question part of this message.
|
void |
setRecursionAvailable(boolean recursionAvailable)
Set the recursion available flog from this DNS message.
|
void |
setRecursionDesired(boolean recursionDesired)
Set the recursion desired flag on this message.
|
void |
setTruncated(boolean truncated)
Set the truncation bit on this DNS message.
|
byte[] |
toArray()
Generate a binary dns packet out of this message.
|
String |
toString() |
protected int id
protected DNSMessage.OPCODE opcode
protected DNSMessage.RESPONSE_CODE responseCode
protected boolean query
protected boolean authoritativeAnswer
protected boolean truncated
protected boolean recursionDesired
protected boolean recursionAvailable
protected boolean authenticData
protected boolean checkDisabled
protected Question[] questions
protected Record[] answers
protected Record[] nameserverRecords
protected Record[] additionalResourceRecords
protected long receiveTimestamp
public int getId()
public void setId(int id)
id
- The new DNS message id.public long getReceiveTimestamp()
public boolean isQuery()
public void setQuery(boolean query)
query
- The new query status.public boolean isAuthoritativeAnswer()
public void setAuthoritativeAnswer(boolean authoritativeAnswer)
authoritativeAnswer
- Tge new authoritative answer value.public boolean isTruncated()
public void setTruncated(boolean truncated)
truncated
- The new truncated bit status.public boolean isRecursionDesired()
public void setRecursionDesired(boolean recursionDesired)
recursionDesired
- The new recusrion setting.public boolean isRecursionAvailable()
public void setRecursionAvailable(boolean recursionAvailable)
recursionAvailable
- The new recursion available status.public boolean isAuthenticData()
public void setAuthenticData(boolean authenticData)
authenticData
- The new authentic data flag value.public boolean isCheckDisabled()
public void setCheckDisabled(boolean checkDisabled)
checkDisabled
- The new check disabled value.public byte[] toArray() throws IOException
IOException
- Should never happen.public static DNSMessage parse(byte[] data) throws IOException
data
- The DNS message data.IOException
- On read errors.public void setQuestions(Question... questions)
questions
- The questions.public DNSMessage.OPCODE getOpcode()
public DNSMessage.RESPONSE_CODE getResponseCode()
public Question[] getQuestions()
public Record[] getAnswers()
public Record[] getNameserverRecords()
public Record[] getAdditionalResourceRecords()
Copyright © 2014–2015. All rights reserved.