com.antiaction.dns
Class DNSRecordHeader

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

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

DNS Record Header, contains the header portion of a resource record. As defined in rfc1035.

Version:
2.00
Author:
Nicholas Clarke

Field Summary
protected  int rclass
          Record class.
protected  java.lang.String rname
          Domain name associated.
protected  int rttl
          Record Time To Live.
protected  int rtype
          Record type.
 
Constructor Summary
DNSRecordHeader()
          Instantiate and initialize a default question object.
 
Method Summary
 byte[] buildPacket(DNSName dnsname, int globalIdx)
          Build and return the record header based on the internal state.
 java.lang.Object clone()
          Overrides Cloneable.
 void disassemblePacket(DNSName dnsname, byte[] pDat, int pIdx, int pLen)
          Parses the record header part of a packet.
 int getDisassembledLen()
          Returns the length of the previously disassembled record header.
 int getRClass()
          Get the record class.
 java.lang.String getRName()
          Get the record name.
 int getRTTL()
          Get the record class.
 int getRType()
          Get the record type.
 void setDebug(boolean b)
          Toggle debug status.
 void setRClass(int rc)
          Set the record class.
 void setRName(java.lang.String s)
          Set the record name.
 void setRTTL(int rt)
          Set the record ttl.
 void setRType(int rt)
          Set the record 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

rname

protected java.lang.String rname
Domain name associated.

rtype

protected int rtype
Record type.

rclass

protected int rclass
Record class.

rttl

protected int rttl
Record Time To Live.
Constructor Detail

DNSRecordHeader

public DNSRecordHeader()
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 record header 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 record header part of a record as a byte array.
Throws:
DNSNameException - if the domain name is invalid.

getDisassembledLen

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

disassemblePacket

public void disassemblePacket(DNSName dnsname,
                              byte[] pDat,
                              int pIdx,
                              int pLen)
                       throws DNSException,
                              DNSNameException
Parses the record header 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 record header begins.
pLen - length of the whole packet.
Throws:
DNSException - if the packet is corrupted.
DNSNameException - if the domain name is invalid.
See Also:
getDisassembledLen()

setRName

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

getRName

public java.lang.String getRName()
Get the record name.
Returns:
domain name.

setRType

public void setRType(int rt)
Set the record type.
Parameters:
rt - record type.

getRType

public int getRType()
Get the record type.
Returns:
record type.

setRClass

public void setRClass(int rc)
Set the record class.
Parameters:
rc - record class.

getRClass

public int getRClass()
Get the record class.
Returns:
record class.

setRTTL

public void setRTTL(int rt)
Set the record ttl.
Parameters:
rt - record ttl.

getRTTL

public int getRTTL()
Get the record class.
Returns:
record 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.