org.jnetpcap.util.resolver
Class IEEEOuiPrefixResolver

java.lang.Object
  extended by org.jnetpcap.util.resolver.AbstractResolver
      extended by org.jnetpcap.util.resolver.IEEEOuiPrefixResolver
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, Resolver

public class IEEEOuiPrefixResolver
extends AbstractResolver

A resolver that resolves the first 3 bytes of a MAC address to a manufacturer code. The resolver loads jNetPcap supplied compressed oui database of manufacturer codes and caches that information. The resolver can also download over the internet, if requested, a raw IEEE OUI database of manufacturer code, parse it and produce a cache file for future use.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jnetpcap.util.resolver.Resolver
Resolver.ResolverType
 
Field Summary
static java.lang.String IEEE_OUI_DATABASE_PATH
          Default URI path to IEEE raw oui database of manufacturer codes.
 
Fields inherited from class org.jnetpcap.util.resolver.AbstractResolver
INFINITE_TIMEOUT, logger
 
Fields inherited from interface org.jnetpcap.util.resolver.Resolver
RESOLVER_SEARCH_PATH_PROPERTY
 
Constructor Summary
IEEEOuiPrefixResolver()
          Creates an uninitalized Oui prefix resolver.
 
Method Summary
 void initializeIfNeeded()
          Initializes the resolver by first checking if there are any cached entries, if none, it reads the compressed oui database supplied with jNetPcap in the resource directory .
 int loadCache(java.net.URL url)
          Download IEEE supplied OUI.txt database of manufacturer prefixes and codes.
 java.lang.String resolveToName(byte[] address, long hash)
          Resolves the supplied address to a human readable name.
protected  java.lang.String resolveToName(long number, long hash)
          Resolves number to a name.
 long toHashCode(byte[] address)
          Generates a special hashcode for first 3 bytes of the address that is unique for every address.
 
Methods inherited from class org.jnetpcap.util.resolver.AbstractResolver
addToCache, addToCache, canBeResolved, clearCache, finalize, getCacheCapacity, getCacheLoadFactor, getNegativeTimeout, getPositiveTimeout, hasCacheFile, isCached, loadCache, loadCache, propertyChange, resolve, saveCache, saveCache, setCacheCapacity, setCacheLoadFactor, setNegativeTimeout, setPositiveTimeout, toHashCode, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IEEE_OUI_DATABASE_PATH

public static final java.lang.String IEEE_OUI_DATABASE_PATH
Default URI path to IEEE raw oui database of manufacturer codes. The URI is "http://standards.ieee.org/regauth/oui/oui.txt".

See Also:
Constant Field Values
Constructor Detail

IEEEOuiPrefixResolver

public IEEEOuiPrefixResolver()
Creates an uninitalized Oui prefix resolver. The resolver is "late" initialized when its first called on to do work.

Parameters:
type -
Method Detail

initializeIfNeeded

public void initializeIfNeeded()
Initializes the resolver by first checking if there are any cached entries, if none, it reads the compressed oui database supplied with jNetPcap in the resource directory .

Specified by:
initializeIfNeeded in interface Resolver
Overrides:
initializeIfNeeded in class AbstractResolver

loadCache

public int loadCache(java.net.URL url)
              throws java.io.IOException
Download IEEE supplied OUI.txt database of manufacturer prefixes and codes. The file is downloaded using the protocol specified in the URL, parsed and cached indefinately. The machine making the URL connection must have internet connection available as well as neccessary security permissions form JRE in order to make the connection.

Specified by:
loadCache in interface Resolver
Overrides:
loadCache in class AbstractResolver
Parameters:
url - The url of the IEEE resource to load. If the url is null, the default uri is attempted "http://standards.ieee.org/regauth/oui/oui.txt".
Returns:
number of entries cached
Throws:
java.io.IOException - any IO errors

resolveToName

public java.lang.String resolveToName(byte[] address,
                                      long hash)
Resolves the supplied address to a human readable name.

Specified by:
resolveToName in class AbstractResolver
Parameters:
address - address to resolve
hash - computed hash code for the address, identifies the address uniquely
Returns:
resolved name or null if not resolved

toHashCode

public long toHashCode(byte[] address)
Generates a special hashcode for first 3 bytes of the address that is unique for every address.

Specified by:
toHashCode in class AbstractResolver

resolveToName

protected java.lang.String resolveToName(long number,
                                         long hash)
Description copied from class: AbstractResolver
Resolves number to a name. Performs any neccessary lookups to try and resolve the name. The method should not access any of the cached information. THis method is called only after the cache has already been checked and failed to produce a positive or negative lookup entry.

Specified by:
resolveToName in class AbstractResolver
Parameters:
number - a number value to resolve
hash - computed hash code for the number, identifies the number uniquely