com.antiaction.dns.record
Class DNSRDataA

java.lang.Object
  |
  +--com.antiaction.dns.record.DNSRDataA
All Implemented Interfaces:
java.lang.Cloneable, DNSRDataInterface

public class DNSRDataA
extends java.lang.Object
implements DNSRDataInterface

DNS A Record container. As defined in rfc1035.

Version:
2.00
Author:
Nicholas Clarke

Field Summary
protected  java.lang.String ipAddr
          IP address.
protected  byte[] ipAddrArr
          IP record.
protected static int rtype
          Record of type A.
 
Constructor Summary
DNSRDataA()
          Instantiate and initialize a default A record object.
 
Method Summary
 byte[] buildPacket(DNSName dnsname, int globalIdx)
          Build and return the rdata packet on the internal state.
 java.lang.Object clone()
          Overrides Cloneable.
 void disassemblePacket(DNSName dnsname, byte[] pDat, int pIdx, int pLen)
          Parses the rdata part of a record.
 int getDisassembledLen()
          Returns the length of the previously disassembled rdata part.
 java.lang.String getIPAddr()
          Get the IP address of this record.
 int getRType()
          Get the record type.
 void setDebug(boolean b)
          Toggle debug status.
 void setIPAddr(java.lang.String ip)
          Validate and set the IP address of this record.
static java.util.ArrayList Split(java.lang.String str, java.lang.String dstr)
          Splits a string according to a substring and returns an arraylist where each item represents a string delimited by the substring.
 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

rtype

protected static int rtype
Record of type A.

ipAddrArr

protected byte[] ipAddrArr
IP record.

ipAddr

protected java.lang.String ipAddr
IP address.
Constructor Detail

DNSRDataA

public DNSRDataA()
Instantiate and initialize a default A record object.
Method Detail

clone

public java.lang.Object clone()
Overrides Cloneable.
Specified by:
clone in interface DNSRDataInterface
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.
Specified by:
setDebug in interface DNSRDataInterface
Parameters:
b - boolean.

buildPacket

public byte[] buildPacket(DNSName dnsname,
                          int globalIdx)
                   throws DNSNameException
Build and return the rdata packet on the internal state.
Specified by:
buildPacket in interface DNSRDataInterface
Parameters:
dnsname - used for domain name compression in the same message.
globalIdx - current index of the message being assembled. (Domain name compression)
Returns:
the rdata 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 rdata part.
Specified by:
getDisassembledLen in interface DNSRDataInterface
See Also:
disassemblePacket(DNSName, byte[], int, int)

disassemblePacket

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

getRType

public int getRType()
Get the record type.
Specified by:
getRType in interface DNSRDataInterface
Returns:
record type.

setIPAddr

public void setIPAddr(java.lang.String ip)
               throws DNSRDataException
Validate and set the IP address of this record.
Parameters:
ip - ip address.
Throws:
DNSRDataException - if the ip address is not valid.

getIPAddr

public java.lang.String getIPAddr()
Get the IP address of this record.
Returns:
the IP address.

toString

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

Split

public static java.util.ArrayList Split(java.lang.String str,
                                        java.lang.String dstr)
Splits a string according to a substring and returns an arraylist where each item represents a string delimited by the substring.
Parameters:
str - string to split.
dstr - substring used to split the string.
Returns:
arraylist where each entry represents a string delimited by the subitem.