org.jnetpcap.util.resolver
Interface Resolver

All Known Implementing Classes:
AbstractResolver, IEEEOuiPrefixResolver, IpResolver

public interface Resolver

A resolver interface that can resolver various types of addresses and specific protocol numbers and types to a human readable name. The resolver will do an appropriate type of look up is appropriate for a given protocol, to try and map a binary entity to a human assigned and readable one.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
static class Resolver.ResolverType
          Type of resolver that can be registered with JRegistry.
 
Field Summary
static java.lang.String RESOLVER_SEARCH_PATH_PROPERTY
           
 
Method Summary
 boolean canBeResolved(byte[] address)
          Checks if a mapping exists or can be made.
 void clearCache()
          Resets the cache to its defaults.
 void initializeIfNeeded()
          This method is called everytime the resolver is requested from JRegistry.
 boolean isCached(byte[] address)
          Checks if resolver already has a mapping made for this particular address.
 int loadCache(java.net.URL url)
          Attempts to load the cache from the given URL.
 java.lang.String resolve(byte[] address)
          Attempts to resole an address to a human readable form.
 int saveCache()
          Forces cache contents to be saved to the default cache file.
 

Field Detail

RESOLVER_SEARCH_PATH_PROPERTY

static final java.lang.String RESOLVER_SEARCH_PATH_PROPERTY
See Also:
Constant Field Values
Method Detail

canBeResolved

boolean canBeResolved(byte[] address)
Checks if a mapping exists or can be made. This operation may trigger a lookup which may take certain amount of time to complete, some times many seconds or even minutes.

Parameters:
address - address to check mapping for
Returns:
true the mapping can be made, otherwise false

clearCache

void clearCache()
Resets the cache to its defaults.


initializeIfNeeded

void initializeIfNeeded()
This method is called everytime the resolver is requested from JRegistry. This method allows the resolver to initialize itself if it isn't already initialized.


isCached

boolean isCached(byte[] address)
Checks if resolver already has a mapping made for this particular address. This operation does not block and returns immediately. The mapping may include a negative lookup, one that failed before. None the less the negative result is cached along with positive results.

Parameters:
address - address to check for
Returns:
true if mapping is already cached, otherwise false

loadCache

int loadCache(java.net.URL url)
              throws java.io.IOException
Attempts to load the cache from the given URL. The format of the file retrieved from the url is resolver specified. The default cache file format is attempted at some point in the file scan until the file can be read or the load fails.

Parameters:
url - URL of the resource containing the database to load
Returns:
number of entries cached
Throws:
java.io.IOException - any IO errors

resolve

java.lang.String resolve(byte[] address)
Attempts to resole an address to a human readable form. Any possible or required look ups are performed, sometimes taking a long time to complete if neccessary. All results, positive and negative for the lookup, are cached for certain amount of time. Defaults are minutes for positive lookup and minutes for negative.

Parameters:
address - address to try and resolve
Returns:
human readable form if lookup succeeded (position) or null if lookup failed to produce a human label (negative)

saveCache

int saveCache()
              throws java.io.IOException
Forces cache contents to be saved to the default cache file.

Returns:
number of cached entries saved
Throws:
java.io.IOException - any IO errors during save