Interface SnmpMIBService

All Known Implementing Classes:

public interface SnmpMIBService

A service interface for a directory of MIB Dictionary objects. Allows MIBs to be loaded, and returns object references to dictionaries for those mibs.

A SnmpMIBService manages a collection of MIB Dictionaries, each of which contains a series of name to OID mappings. The MIB Dictionaries are uniquely identified by name (normally the mib name in lowercase). To make a MIB Dictionary available for use, it must be loaded into the MIB service using the SnmpMIBService.loadMIB() method. Once loaded, the dictionary can be retrieved for using the getMIBDictionary() method.

The most common use of the MIB Service and MIB Dictionary classes is to resolve SNMP names into their relevant OIDs (and vice-versa). While there are methods in the MIB Dictionary classes to support this, the service interface contains a shortcut that allows all known MIB Dictionaries to be searched in one step. See findMIBs() for more details.

Usage: The following code snippet provides an example of showing the loading and use of mibs with the service:

      // Create the service
      SnmpMIBService cSnmpMIBService = SnmpLocalInterfaces.getMIBService();
      // Load the IF-MIB MIB file into the service
      InputStream cInputStream = jMIBC.loadMib("");
      cSnmpMIBService.loadMIB("IF-MIB", cInputStream);

      // Or alternately, load the IF-MIB jMIB file into the service
      //cSnmpMIBService.loadMIB("IF-MIB", new FileInputStream("IF-MIB.jmib"));
      // Get a handle to the mib dictionary for the MIB
      SnmpMIBDictionary cSnmpMIBDictionary = cSnmpMIBService.getMIBDictionary("IF-MIB");

      // Resolve a name from the MIB to its OID
      System.out.println("OID for myname is: " + cSnmpMIBDictionary.resolveName("ifAdminStatus"));

      // List of all the MIBs in the service
      String[] szMibs = cSnmpMIBService.listAvailableMIBs();
      System.out.println("Available MIBs:\n");
      for (int i=0; i < szMibs.length; i++) 

      // List all MIBs in the service that contain the name "IF-MIB"
      SnmpMIBDictionary[] cSnmpMIBDictionaryList = cSnmpMIBService.findMIBs("IF-MIB");
      System.out.println("There are " + Integer.toString(cSnmpMIBDictionaryList.length) +
                         " MIBs containing the name 'IF-MIB':\n");
      for (int i=0; i < cSnmpMIBDictionaryList.length; i++) 

Method Summary
 SnmpMIBDictionary[] findMIBs(java.lang.String szVarName)
          Search all available MIBs for a given name/OID.
 SnmpMIBDictionary getMIBDictionary(java.lang.String szMibName)
          Finds the MIB Dictionary object for a specified MIB.
 java.lang.String[] listAvailableMIBs()
          Provides a list of the MIB definitions available to the service.
 void loadMIB(java.lang.String szName, cInputStream)
          Load a MIB definition into the service, making a new MIB dictionary available for it.
 void unloadMIB(java.lang.String szName)
          Unload a MIB definition from the service.

Method Detail


public void loadMIB(java.lang.String szName,
             throws java.lang.Exception
Load a MIB definition into the service, making a new MIB dictionary available for it.
name - name to assign to the mib
cInputStream - input stream used to read in the raw mib definition; format used is implementation dependent
java.lang.Exception - thrown if there was a problem loading the MIB


public void unloadMIB(java.lang.String szName)
               throws java.lang.IllegalArgumentException
Unload a MIB definition from the service.
szName - name to assign to the mib
java.lang.IllegalArgumentException - thrown if the MIB name wasn't found


public SnmpMIBDictionary getMIBDictionary(java.lang.String szMibName)
Finds the MIB Dictionary object for a specified MIB.
szMibName - common name used to specify the mib. (e.g. "rfc1213")
MIB Dictionary object, corresponding to the named MIB


public java.lang.String[] listAvailableMIBs()
Provides a list of the MIB definitions available to the service.
list of MIB definitions available to the service


public SnmpMIBDictionary[] findMIBs(java.lang.String szVarName)
Search all available MIBs for a given name/OID.
szVarName - MIB variable name/OID to lookup
one or more MIB dictionary objects, each of which contains a mapping for szVarName, or null if no mappings were found

Home  Services  Products  Purchase  Contact Us  About Us  Legal  Ceramics
Copyright © 2003-2008 jSNMP Enterprises All rights reserved.