|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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("IF-MIB.my"); 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++) { System.out.println(szMibs[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++) { System.out.println(cSnmpMIBDictionaryList[i].getMIBDictionaryName()); }
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,
java.io.InputStream 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, java.io.InputStream cInputStream) throws java.lang.Exception
name
- name to assign to the mibcInputStream
- input stream used to read in the raw
mib definition; format used is implementation dependentjava.lang.Exception
- thrown if there was a problem loading
the MIBpublic void unloadMIB(java.lang.String szName) throws java.lang.IllegalArgumentException
szName
- name to assign to the mibjava.lang.IllegalArgumentException
- thrown if the MIB name wasn't foundpublic SnmpMIBDictionary getMIBDictionary(java.lang.String szMibName)
szMibName
- common name used to specify the mib. (e.g. "rfc1213")public java.lang.String[] listAvailableMIBs()
public SnmpMIBDictionary[] findMIBs(java.lang.String szVarName)
szVarName
- MIB variable name/OID to lookup
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Home Services Products Purchase Contact Us About Us Legal Ceramics
Copyright © 2003-2008 jSNMP Enterprises All rights reserved.