|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.protocols.dns.DNSAddressRequest
The DNSAddressRequest holds a DNS request to lookup the IP address of a host - provides for transmitting and receiving the response for this lookup. NOTES: A DNS request and response has the following fileds header questions answers authorities additional information The header has the following format: id - unique id sent by the client and returned by the server in its response 16 bits of flags - Query(0)/response(1) flag opcode - that has type of query AA - set if the response is an authoritative answer TC - set if response is truncated RD - set if recursion is desired RA - set if recursion is available Z - reserved bits RCODE - response code This class checks only for the received response to have the answer(which will hold the IP address) - ignores the authorities and additional info
Field Summary | |
int |
CLASS_IN
Defines the class internet in the domain name system. |
private static int |
globalID
The global id, used to get the request id. |
java.util.List |
m_answers
The list of answers. |
boolean |
m_authoritative
True if the answer is authoratitve. |
boolean |
m_recursive
True if the message is recursive. |
java.lang.String |
m_reqHost
The host to request information from. |
int |
m_reqID
The id used to seralize the request. |
boolean |
m_truncated
True if the message is truncated. |
int |
OPCODE_QUERY
The op code for a query in the header. |
int |
SHIFT_AUTHORITATIVE
The offset of the authoritative bit in the header. |
int |
SHIFT_OPCODE
The offset of the opcode bits in the header. |
int |
SHIFT_QUERY
The offset of the query bit in the header. |
int |
SHIFT_RECURSE_AVAILABLE
The offset of the requrse avail bit in the header. |
int |
SHIFT_RECURSE_PLEASE
The offset of the recurse req bit in the header. |
int |
SHIFT_RESERVED
The offset of the reserved bits in the header. |
int |
SHIFT_RESPONSE_CODE
The offset of the response code bits in the header. |
int |
SHIFT_TRUNCATED
The offset of the truncated bit in the header. |
int |
TYPE_ADDR
Defines the address type. |
Constructor Summary | |
DNSAddressRequest(java.lang.String host)
Constructs a DNSAddressRequest for ths hostname passed. |
Method Summary | |
byte[] |
buildRequest()
Builds the address request. |
static java.lang.String |
codeName(int code)
Returns the code string for the error code recieved. |
private void |
decodeFlags(int flags)
Decodes the integer to get the flags - refer header for more info on the flags. |
java.util.List |
getAnswers()
Return an enumeration of the recieved answers. |
java.lang.String |
getHost()
The hostname that will be request from the DNS box. |
int |
getRequestID()
The request id for this particular instance. |
boolean |
isAuthoritative()
Returns true if the answer is authoritative. |
boolean |
isRecursive()
Returns true if the answer is recursive. |
boolean |
isTruncated()
Returns true if the answer is truncated. |
void |
receiveResponse(byte[] data,
int length)
Extracts the response from the bytearray. |
void |
verifyResponse(byte[] data,
int length)
This method only goes so far as to decode the flags in the response byte array to verify that a DNS server sent the response. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final int CLASS_IN
Defines the class internet in the domain name system.
public final int TYPE_ADDR
Defines the address type.
public final int SHIFT_QUERY
The offset of the query bit in the header.
public final int SHIFT_OPCODE
The offset of the opcode bits in the header.
public final int SHIFT_AUTHORITATIVE
The offset of the authoritative bit in the header.
public final int SHIFT_TRUNCATED
The offset of the truncated bit in the header.
public final int SHIFT_RECURSE_PLEASE
The offset of the recurse req bit in the header.
public final int SHIFT_RECURSE_AVAILABLE
The offset of the requrse avail bit in the header.
public final int SHIFT_RESERVED
The offset of the reserved bits in the header.
public final int SHIFT_RESPONSE_CODE
The offset of the response code bits in the header.
public final int OPCODE_QUERY
The op code for a query in the header.
public java.lang.String m_reqHost
The host to request information from. This would be the nameserver if it supports DNS.
public int m_reqID
The id used to seralize the request. This allows the client (us) and the server (host) to match exchanges.
public boolean m_authoritative
True if the answer is authoratitve.
public boolean m_truncated
True if the message is truncated.
public boolean m_recursive
True if the message is recursive.
public java.util.List m_answers
The list of answers.
private static int globalID
The global id, used to get the request id.
Constructor Detail |
public DNSAddressRequest(java.lang.String host)
Constructs a DNSAddressRequest for ths hostname passed. The host string that is passed to the address string should be a hostname in "x.y.z" where x, y, and z are strings. This is not suppose to be a dotted decimal address.
host
- hostname for which address is to be constructedMethod Detail |
private void decodeFlags(int flags) throws java.io.IOException
Decodes the integer to get the flags - refer header for more info on the flags.
java.io.IOException
public byte[] buildRequest() throws java.io.IOException
Builds the address request.
java.io.IOException
public void receiveResponse(byte[] data, int length) throws java.io.IOException
Extracts the response from the bytearray.
data
- The byte array containing the response.length
- The length of the byte array.
java.io.IOException
- Thrown if there is an error while reading the recieved
packetpublic void verifyResponse(byte[] data, int length) throws java.io.IOException
This method only goes so far as to decode the flags in the response byte array to verify that a DNS server sent the response.
NOTE: This is really a hack to get around the fact that the receiveResponse() method is not robust enough to handle all possible DNS server responses.
data
- The byte array containing the response.length
- The length of the byte array.
java.io.IOException
- Thrown if there is an error while reading the recieved
packetpublic java.util.List getAnswers()
Return an enumeration of the recieved answers.
public int getRequestID()
The request id for this particular instance.
public java.lang.String getHost()
The hostname that will be request from the DNS box.
public boolean isTruncated()
Returns true if the answer is truncated.
public boolean isRecursive()
Returns true if the answer is recursive.
public boolean isAuthoritative()
Returns true if the answer is authoritative.
public static java.lang.String codeName(int code)
Returns the code string for the error code recieved.
code
- The error code.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |