com.antiaction.dns
Class DNSName

java.lang.Object
  |
  +--com.antiaction.dns.DNSName

public class DNSName
extends java.lang.Object

DNS Name, handles domainname dis/assembling (including de/compression). As defined in rfc1035.

Version:
2.00
Author:
Nicholas Clarke

Constructor Summary
DNSName()
          Construct a name object and initialize internal compression structures.
 
Method Summary
 byte[] buildPacket(int globalIdx, java.lang.String name, boolean useComp, boolean updComp)
          Build a sub packet containing the name with no, partial or full compresssion used.
 java.lang.String disassemblePacket(byte[] pDat, int pIdx, int pLen)
          Parses the name part of a packet and returns a string.
 int getDisassembledLen()
          Returns the length of the previously disassembled name.
 void printTree()
          Display the hashmap tree structure used for name compression, for debugging purposes only.
 void reset()
          Reset internal compression structures.
 void setDebug(boolean b)
          Toggle debug status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DNSName

public DNSName()
Construct a name object and initialize internal compression structures.
Method Detail

setDebug

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

reset

public void reset()
Reset internal compression structures.

buildPacket

public byte[] buildPacket(int globalIdx,
                          java.lang.String name,
                          boolean useComp,
                          boolean updComp)
                   throws DNSNameException
Build a sub packet containing the name with no, partial or full compresssion used.
Parameters:
globalIdx - used to index labels across names.
name - domain name.
useComp - use compression to build the name.
updComp - update the compression tree structure with new labels.
Throws:
DNSNameException - if the domain name is invalid.

getDisassembledLen

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

disassemblePacket

public java.lang.String disassemblePacket(byte[] pDat,
                                          int pIdx,
                                          int pLen)
                                   throws DNSException,
                                          DNSNameException
Parses the name part of a packet and returns a string.
Parameters:
pDat - array containing the complete packet.
pIdx - index to where in the array the name begins.
pLen - length of the whole packet.
Returns:
domain name in string form.
Throws:
DNSNameException - if the domain name is invalid.
See Also:
getDisassembledLen()

printTree

public void printTree()
Display the hashmap tree structure used for name compression, for debugging purposes only.