com.antiaction.dns
Class DNSQuestion

java.lang.Object
  |
  +--com.antiaction.dns.DNSQuestion
All Implemented Interfaces:
java.lang.Cloneable

public class DNSQuestion
extends java.lang.Object
implements java.lang.Cloneable

DNS Question, dis/assembles question portions of a DNS packet. As defined in rfc1035.

Version:
2.00
Author:
Nicholas Clarke

Field Summary
protected  int qclass
          Question class.
protected  java.lang.String qname
          Question name.
protected  int qtype
          Question type.
 
Constructor Summary
DNSQuestion()
          Instantiate and initialize a default question object.
 
Method Summary
 byte[] buildPacket(DNSName dnsname, int globalIdx)
          Build and return the question based on the internal state.
 java.lang.Object clone()
          Overrides Cloneable.
 void disassemblePacket(DNSName dnsname, byte[] pDat, int pIdx, int pLen)
          Parses the question part of a packet.
 int getDisassembledLen()
          Returns the length of the previously disassembled question.
 int getQClass()
          Get the question class
 java.lang.String getQName()
          Get the question domain name.
 int getQType()
          Get the question type.
 void setDebug(boolean b)
          Toggle debug status.
 void setQClass(int qc)
          Set the question class.
 void setQName(java.lang.String s)
          Set the question domain name.
 void setQType(int qt)
          Set the question type.
 java.lang.String toString()
          Returns a string representation of the internal state, mostly for debugging purposes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

qname

protected java.lang.String qname
Question name.

qtype

protected int qtype
Question type.

qclass

protected int qclass
Question class.
Constructor Detail

DNSQuestion

public DNSQuestion()
Instantiate and initialize a default question object.
Method Detail

clone

public java.lang.Object clone()
Overrides Cloneable.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this instance.
Throws:
OutOfMemoryError - if there is not enough memory.
See Also:
Cloneable

setDebug

public void setDebug(boolean b)
Toggle debug status.
Parameters:
b - boolean.

buildPacket

public byte[] buildPacket(DNSName dnsname,
                          int globalIdx)
                   throws DNSNameException
Build and return the question based on the internal state.
Parameters:
dnsname - used for domain name compression in the same message.
globalIdx - current index of the message being assembled. (Domain name compression)
Returns:
the question part of the message as a byte array.
Throws:
DNSNameException - if the domain name is invalid.

getDisassembledLen

public int getDisassembledLen()
Returns the length of the previously disassembled question.
Returns:
length of previously disassembled question.
See Also:
disassemblePacket(DNSName, byte[], int, int)

disassemblePacket

public void disassemblePacket(DNSName dnsname,
                              byte[] pDat,
                              int pIdx,
                              int pLen)
                       throws DNSException,
                              DNSNameException
Parses the question part of a packet.
Parameters:
dnsname - used for domain name compression in the same message.
pDat - array containing the complete packet.
pIdx - index to where in the array the question begins.
pLen - length of the whole packet.
Throws:
DNSException - if the packet is corrupted.
DNSNameException - if the domain name is invalid.
See Also:
getDisassembledLen()

setQName

public void setQName(java.lang.String s)
Set the question domain name.
Parameters:
s - domain name.

getQName

public java.lang.String getQName()
Get the question domain name.
Returns:
domain name.

setQType

public void setQType(int qt)
Set the question type.
Parameters:
qt - question type.

getQType

public int getQType()
Get the question type.
Returns:
question type.

setQClass

public void setQClass(int qc)
Set the question class.
Parameters:
qc - question class.

getQClass

public int getQClass()
Get the question class
Returns:
question class.

toString

public java.lang.String toString()
Returns a string representation of the internal state, mostly for debugging purposes.
Overrides:
toString in class java.lang.Object
Returns:
debug string.