|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectsimnet.Resolver
DNS.DNS
A simple DNS resolver. Assuming that all domain names are lower case (or, treat domain names as case sensitive). No support for retransmissions of requests or wildcards. No support for multiple addresses for one host.
| Nested Class Summary | |
(package private) class |
DNS.CacheCleaner
TimerTask to remove stale items from the cache. |
(package private) class |
DNS.PendingRequest
An object for doRemoteQuery to wait for, and to contain the response packet. |
(package private) class |
DNS.Processor
Thread that handles the processing of all requests/responses. |
(package private) class |
DNS.RecursiveRequestProcessor
A thread that processes a recursive request and returns a response to the sender. |
| Field Summary | |
(package private) java.util.Hashtable |
cache
Cache of RRGroups returned by queries to remote name servers, indexed by RRGroup name. |
protected int |
CACHE_TTL
Global Parameter -- how long RRs may be cached before they are considered invalid. |
protected java.util.Timer |
cacheCleaner
Thread to remove expired items from our cache. |
protected boolean |
client
Whether or not this resolver is a stub (client) or local (!client) resolver |
protected int |
nameserver
If we are a client, then this is our nameserver |
protected java.util.Hashtable |
pending
Used to keep track of pending requests. |
protected DNS.Processor |
processor
Our primary thread to handle requests/responses. |
protected java.util.Random |
random
Used to generate request id's, so they (probably) will be unique. |
protected java.lang.String |
resolverName
the name of our resolver (not DNS, but node, mostly used in DNSSEC) |
protected int |
ROOT
Global Parameter -- ip address of root node. |
(package private) RRGroup |
rootARRG
Address of the ROOT name server. |
protected java.lang.String |
ROOTNAME
Global Parameter -- name of root node. |
(package private) RRGroup |
rootNSRRG
Information for ROOT name server. |
protected int |
RR_DURATION
Global Parameter -- how long RRs may last until they are considered invalid. |
protected DatagramSocket |
sock
Used to communicate DNS requests/responses |
protected int |
TIMEOUT
Global Parameter -- amount of time that should pass before we consider a request failed. |
(package private) java.util.Hashtable |
zones
Holds information about our zone(s) -- for servers only. |
| Fields inherited from class simnet.Resolver |
node, sim |
| Constructor Summary | |
DNS()
|
|
| Method Summary | |
boolean |
authoritativeFor(java.lang.String name)
Check if we are authoritative for a certain name. |
protected void |
cache(RRGroup rrg)
Put an RRGroup in the cache. |
protected RRGroup |
checkCache(java.lang.String name,
java.lang.String type)
Check the cache for an RRGroup that matches this name and type. |
java.lang.String |
chop(java.lang.String name)
Utility method to remove the first part of a period-delimited name. |
protected void |
clientPreProcessRequest(DNSRequest req)
Method where stub resolver can do any processing that it needs to before sending a request. |
protected void |
createRootRRGs()
Fill out our pointers to the ROOT of the DNS |
void |
customInit(java.lang.String[] config)
Loads information for this resolver. |
void |
dds()
Wrapper method to display the DNS state of a resolver. |
java.util.LinkedList |
doIterativeQuery(java.lang.String name,
java.lang.String type)
Method that checks our zones database and the cache for information pertaining to to the specified name. |
java.util.LinkedList |
doRecursiveQuery(java.lang.String name,
java.lang.String type)
Method to recursively search for the answer to a query. |
protected java.util.LinkedList |
doRemoteQuery(java.lang.String name,
java.lang.String type,
int server,
boolean recurse)
Query a remote name server, get the results and cache and return them. |
void |
dump_dns_state()
Prints the state (zone database, cache and pending requests). |
protected java.util.LinkedList |
getBestNS(java.lang.String name,
boolean includeCache)
Method to search all name servers (in our zones and cache) to get the one that is 'most' authoratative for the specified name. |
int |
getHostByName(java.lang.String name)
Performs a lookup of the specified name. |
protected java.util.LinkedList |
getNameServers(boolean includeCache)
Method that finds all Name servers that we know about. |
java.lang.String |
getNSByName(java.lang.String name)
|
protected RRGroup |
getRRGroup(java.lang.String name,
java.lang.String type)
Method to search all of our zones for an RRGroup holding an RR for a certain name/type. |
boolean |
hasFinalAnswer(java.util.LinkedList rrgs,
java.lang.String name,
java.lang.String type)
Check to see if the first item in the linked list is the answer we are looking for -- an NX or A record that has the correct name. |
protected boolean |
loadRR(java.lang.String zone,
java.lang.String[] tokens)
Loads the tokenized record for the specified zone into the database. |
void |
nslookup(java.lang.String name)
Method that can be called from the UI to lookup an ip address. |
protected void |
preProcessRequest(DNSRequest req,
int ip)
Method where local resolver can do any processing that it needs to on receiving a request. |
protected void |
preProcessResponse(DNSResponse resp,
int ip)
Method where local resolver can do any processing that it needs to on receiving a response. |
protected boolean |
verify(DNSResponse resp)
|
protected boolean |
verify(RRGroup rrg)
Determine whether this RRGroup can be used. |
boolean |
zoneEndsWith(java.lang.String name,
java.lang.String zoneName)
|
| Methods inherited from class simnet.Resolver |
finalize, initialize |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected boolean client
protected int nameserver
protected java.lang.String resolverName
protected java.util.Random random
protected DatagramSocket sock
protected java.util.Hashtable pending
DNS.PendingRequest.
protected DNS.Processor processor
protected java.util.Timer cacheCleaner
java.util.Hashtable zones
java.util.Hashtable cache
RRGroup rootNSRRG
RRGroup rootARRG
protected int CACHE_TTL
protected int RR_DURATION
protected int ROOT
protected java.lang.String ROOTNAME
protected int TIMEOUT
| Constructor Detail |
public DNS()
| Method Detail |
public void customInit(java.lang.String[] config)
throws java.lang.Exception
customInit in class Resolverconfig - Parsed array that represents resource records and server information.
java.lang.Exception - If an entry of config cannot be processed correctly
protected boolean loadRR(java.lang.String zone,
java.lang.String[] tokens)
throws java.lang.Exception
zone - The zone this record is intokens - Parsed string that specifies an RR
java.lang.Exception - If the RR isn't defined correctlyprotected void createRootRRGs()
public java.util.LinkedList doIterativeQuery(java.lang.String name,
java.lang.String type)
name - The name of the node we are looking up.
public java.util.LinkedList doRecursiveQuery(java.lang.String name,
java.lang.String type)
throws DNSException
name - The name of the node to query
DNSException - if verification of RRGroups fail. This is only if they are expired for regular DNS
protected java.util.LinkedList doRemoteQuery(java.lang.String name,
java.lang.String type,
int server,
boolean recurse)
throws DNSException
name - The name to lookupserver - The name server to queryrecurse - Whether or not this should be recurive. Clients should
set this to true, servers should not.
DNSException - When verification of results fail.protected void cache(RRGroup rrg)
rrg - The RRGroup to cache.
protected RRGroup checkCache(java.lang.String name,
java.lang.String type)
name - the name the RRGroup should matchtype - the type of the RR that this RRGroup should hold
protected boolean verify(RRGroup rrg)
rrg - The RRGroup to verify
protected boolean verify(DNSResponse resp)
protected java.util.LinkedList getBestNS(java.lang.String name,
boolean includeCache)
name - the name we are queryingincludeCache - whether or not we should search our cache too
public boolean zoneEndsWith(java.lang.String name,
java.lang.String zoneName)
protected java.util.LinkedList getNameServers(boolean includeCache)
includeCache - whether or not to check the cache
protected RRGroup getRRGroup(java.lang.String name,
java.lang.String type)
name - The name we want to search.
public boolean authoritativeFor(java.lang.String name)
name - The name to check
public void nslookup(java.lang.String name)
name - The name we are looking uppublic java.lang.String getNSByName(java.lang.String name)
public int getHostByName(java.lang.String name)
getHostByName in class Resolvername - The name we are querying
public boolean hasFinalAnswer(java.util.LinkedList rrgs,
java.lang.String name,
java.lang.String type)
rrgs - list or RRGroups that we are checkingname - the name we are looking for
protected void preProcessResponse(DNSResponse resp,
int ip)
resp - The response we received.ip - The ip this response will be sent to.
protected void preProcessRequest(DNSRequest req,
int ip)
req - The request we received.protected void clientPreProcessRequest(DNSRequest req)
req - The request we will send.public java.lang.String chop(java.lang.String name)
public void dds()
public void dump_dns_state()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||