|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.adventnet.snmp.mibs.MibOperations
The MibOperations Class provides MIB support for the SNMP libraries. It enables the user to support SNMP operations by using the information in the MIB Modules.
The MibOperations class is used for the following functionalities:
The MibOperations class needs to be instantiated to parse and use MIBs. Instantiate this class to add dynamic MIB support to your SNMP applications.
For instance, to use in an application
MibOperations mibOps = new MibOperations(); try { mibOps.loadMibModules("RFC1213-MIB"); } catch (Exception ex) { System.err.println("Error loading MIBs: " + ex); }
We can get the objects of MibModule, MibNode, LeafSyntax, MibTrap from the methods present in the MibOperations class.
The method encodeInstanceString(Vector, Vector) can be used to encode the given index value based on the syntax of the indexMibNodes.
We can also create varbind using the method createVariableBinding(String,String[],String) with the supplied parameters.
LeafSyntax instance can be obtained using the methods getLeafSyntax(SnmpOID) and getSyntaxByName(String).
The methods toByteString() and toString() can be used to print the datas.
Some methods like getMibNode() are present both in MibModule and in the MibOperations class. If the method getMibNode() in MibOperations is used, then the node will be searched in all the mibs loaded so far whereas if you use the method getMibNode() in MibModule then the search is restricted to that particular Module.
To get a MibModule instance you can use the method getMibModule(String). This will return the MibModule. The argument for getMibModule is the module name. The argument should be case sensitive,that is to say, the case of the argument should match with the case of the module name. To get the enumeration of all the modules loaded, use MibOperations.getMibModules().
In case the module is getting loaded from a http url location, there might be issues related to content-type handling. Specifically, unless the web-server is configured to handle MIB extensions cds and cmi, you can receive errors in loading the MIB. While plain MIB files are in ascii, configuration issues on web-server do not come into the picture. But , the compiled MIB being binary type is affected if the content-type is indicated by the server as text/plain or text/html etc.
Loading mibs directly is not thread safe whereas loading mibs in compiled mode is thread safe. Before loading the mib in the compiled mode , the cmi and cds files of the correspoding mib file should be created.
Field Summary | |
static int |
ALL_MESSAGES
For printing all the debug messages |
static byte |
CRITICAL
For setting the critical parsing level |
static int |
CRITICAL_MESSAGES
For printing all the critical messages |
static byte |
LENIENT
For setting flexible parsing level. |
static byte |
MYSQL
For setting the MySql database |
static byte |
NORMAL
For setting normal parsing level. |
static byte |
ORACLE
For setting the Oracle database |
static byte |
SERIOUS
For setting the serious parsing level |
static int |
SERIOUS_MESSAGES
For printing all the serious messages |
static int |
WARNING_MESSAGES
For printing all the warning messages |
Fields inherited from interface com.adventnet.snmp.mibs.mibparser.MIBConstants |
ACCESS_ACCESSIBLE_FOR_NOTIFY, ACCESS_NOT_ACCESSIBLE, ACCESS_NOT_IMPLEMENTED, ACCESS_READ_CREATE, ACCESS_READ_ONLY, ACCESS_READ_WRITE, ACCESS_WRITE_ONLY, accessStr, AGENT_CAPABILITIES, alphaStr, BITSTRING, COUNTER, COUNTER32, COUNTER64, GAUGE, GAUGE32, INTEGER, INTEGER32, IPADDRESS, macroStr, MODULE_COMPLIANCE, MODULE_IDENTITY, NETWORKADDRESS, NOTIFICATION_GROUP, NOTIFICATION_TYPE, NULL, numericStr, OBJECT_GROUP, OBJECT_IDENTIFIER, OBJECT_IDENTITY, OBJECT_TYPE, OCTETSTRING, OPAQUE, SEQUENCE, STATUS_CURRENT, STATUS_DEPRECATED, STATUS_MANDATORY, STATUS_OBSOLETE, STATUS_OPTIONAL, statusStr, TEXTUAL_CONVENTION, TIMETICKS, TRAP_TYPE, UNSIGNED32 |
Constructor Summary | |
MibOperations()
This instantiates a new MibOperations instance for MIB operations. |
Method Summary | |
void |
addChecks(byte[] checks,
byte parsingLevel)
Used to add checks to the existing parsing level. |
void |
addLabel(java.lang.String addLabel)
Used to add label which should not be treated as a reserved word by the MIB parser. |
void |
createCompiledMibs(java.lang.String mibs)
Used to create compiled mibs namely the cmi and cds files. |
SnmpVarBind |
createVariableBinding(java.lang.String varName,
java.lang.String[] indexes,
java.lang.String value)
Creates an SnmpVarBind instance with the supplied parameters. |
void |
enableDisplayHint(boolean flag)
Used to set the displayHint flag. |
java.lang.String |
encodeInstanceString(java.util.Vector indexValue,
java.util.Vector indexMibNodes)
Encodes an instance string based on the Snmp Type of the indexMibNode. |
byte[] |
getChecks(byte parsingLevel)
Used to get the checks available for a particular parsingLevel. |
byte |
getDatabaseName()
Gets the name of the Database. |
java.util.Vector |
getErrorMessages(java.lang.String module)
Returns Vector of MibErrorMessages object for the module specified. |
java.util.Vector |
getErrorModuleNames()
Returns the names of modules which are having parsing errors. |
java.lang.String |
getErrorString(SnmpPDU pdu)
Gives a detailed error information on the PDU using information from the loaded MIBs. |
boolean |
getIgnoreSpecificControlCodes()
Used to get the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values |
byte |
getImportsParsingLevel()
Returns the parsingLevel for the dependency MIB files. |
java.lang.String |
getInstanceString(SnmpOID oid)
Gets the Instance portion of OID as a String. |
java.lang.String |
getInstanceString(SnmpOID oid,
MibNode node)
Gets the Instance portion of OID as a String. |
LeafSyntax |
getLeafSyntax(SnmpOID oid)
Gets the syntax for the node corresponding to this oid. |
MibModule |
getMibModule(MibNode node)
Gets the MIB Module that contains the specified MibNode. |
MibModule |
getMibModule(java.lang.String name)
Gets the MIB Module from list of already loaded MIBs. |
java.util.Enumeration |
getMibModuleNames()
Gets the names of the Mib modules loaded. |
java.util.Enumeration |
getMibModules()
Gets all the MIB modules loaded in this MibOperations instance. |
MibNode |
getMibNode(SnmpOID oid)
Gets the MibNode for this SnmpOID instance by searching all the MIB modules. |
MibNode |
getMibNode(java.lang.String oidString)
Gets the node corresponding to this label. |
MibNode |
getMibNode(java.lang.String nodeLabel,
java.lang.String mib)
Gets the node correspoding to the label in this mib. |
MibNode |
getMibNode(java.util.Vector oid)
Gives the MibNode per the Vector of Strings OID argument. |
java.lang.String |
getMibPath()
Gets the search Path in which the MIB files are searched. |
MibTrap |
getMibTrap(SnmpOID enterprise,
int genericType,
int specificType)
Gets the trap definition matching the given enterprise, generic type and specific type values. |
java.lang.String |
getModuleNameDefinition(java.lang.String file)
Lets you know the module name contained in this MIB file. |
java.lang.String[] |
getModuleNameDefinitions(java.lang.String fileName)
Gives all the module names contained in this mib file. |
int |
getModuleSize()
Returns the number of modules loaded in this MibOperations instance. |
java.lang.String |
getMultipleRevision()
Gets the multiple revisions availabe for the MIB. |
MibNode |
getNearestNode(SnmpOID oid)
Gets the node corresponding to the oid which is nearest to this SnmpOID instance. |
java.util.Vector |
getNodesFromNames(java.util.Vector nodes)
Gets the MibNodes corresponding to the names in the Vector. |
java.util.Vector |
getNodesFromString(java.lang.String nodeList)
Gets the MibNodes corresponding to the node names in the nodelist. |
NotificationType |
getNotificationType(SnmpOID trapoid)
Gets the NotificationType object of the given trap oid |
boolean |
getOverwriteCMI()
Deprecated. since 4.0, replaced by isOverwriteCMI() |
byte |
getParsingLevel()
Returns the parsingLevel. |
java.lang.String |
getSerializedMibFileName()
Retrieves the Serialized MIB file name. |
SnmpOID |
getSnmpOID(java.lang.String s)
Creates an SnmpOID instance based on the loaded MIBs. |
LeafSyntax |
getSyntaxByName(java.lang.String name)
Gets the syntax for the node represented by the String argument. |
java.util.Vector |
getTCList(SnmpOID oid)
This method returns the vector of Textual Conventions for the given SnmpOID drill down till to the base syntax level.This method requires the relavent mib(s) should be loaded into the miboperations before invoking the getTCList(snmpoid). |
boolean |
getThrowFileNotFound()
Deprecated. |
void |
initJdbcParams(java.lang.String driverName,
java.lang.String URL,
java.lang.String userName,
java.lang.String passWord)
If you need to use database support, you have to invoke this method to initialize the Jdbc Parameters. |
boolean |
isDBConnected()
Used to know whether the Database connection is alive or not. |
boolean |
isDisplayHintEnabled()
Used to know whether the displayHint flag is enabled or not. |
boolean |
isLoadFromCompiledMibs()
Used to know whether the MIB is loaded from the compiled mibs. |
boolean |
isLoadFromDatabase()
Used to know whether the MIB is loaded from the DataBase. |
boolean |
isLoadFromSerializedMibs()
Used to know whether the MIB is loaded from serialized mibs. |
boolean |
isMultipleRevision()
Used to know whether the multiple revision is set or not. |
boolean |
isOverwriteCMI()
Used to know whether the compiled mib files are overwritten. |
boolean |
isOverwriteDatabase()
Gets the overwriteDataBase boolean. |
boolean |
isOverwriteSerializedMibs()
Used to know whether the serialized mib files are overwritten. |
boolean |
isReadDesc()
Used to know whether reading the descriptions from compiled modules is enabled. |
boolean |
isSerializeMibs()
Gets the serializeMibs boolean |
boolean |
isShowImportedIndex()
Used to know whether the external indices are shown in the Mib tree. |
MibModule |
loadMibModule(java.applet.Applet applet,
java.net.URL url)
Load a MIB Module from an applet using the URL. |
MibModule |
loadMibModule(java.lang.String fileName)
Load a MIB Module from this file. |
void |
loadMibModules(java.applet.Applet applet,
java.lang.String mibs)
Load a set of MIB Modules from an applet using the string URLs. |
void |
loadMibModules(java.lang.String mibs)
Load a set of MIB Modules from files. |
void |
registerParsingLevel(byte parsingLevel,
byte[] checks)
Used to create an used defined parsing level. |
void |
removeChecks(byte[] checks,
byte parsingLevel)
Used to remove checks from the existing parsing level. |
void |
resetMibPath()
Resets the search Path in which the Mib Parser will search for the MIB modules. |
void |
setDatabaseName(byte type)
Used to set the database. |
void |
setDebug(boolean debug)
Defines whether debugging output should be generated to stdout. |
static void |
setDebugMessageLevel(int level)
Sets the debug message level. |
void |
setIgnoreSpecificControlCodes(boolean specConCode)
Used to set the value determining whether the new-line characters, tabs and carriage returns are printed as they are or their hex values. |
void |
setImportsParsingLevel(byte parsingLevel)
Used to set the level of parsing for the dependency MIB files. |
void |
setLoadFromCompiledMibs(boolean flag)
Defines whether to load mib from compiled MIBs. |
void |
setLoadFromDatabase(boolean flag)
Defines whether to load the MIB from DataBase. |
void |
setLoadFromSerializedMibs(boolean flag)
Defines whether to load mib from serialized MIB file. |
void |
setMibFileExtension(java.lang.String extension)
Registers the extensions with which the MIB file is to be searched. |
void |
setMibPath(java.lang.String path)
Sets the search Path in which the Mib Parser will search for the MIB modules. |
void |
setMultipleRevision(java.lang.String revisionFileName)
Sets the Multiple revision for the MIB. |
void |
setOverwriteCMI(boolean overWrite)
Defines whether to overwrite the existing compiled files. |
void |
setOverwriteDatabase(boolean overWrite)
Defines whether to overwrite the existing database files. |
void |
setOverwriteSerializedMibs(boolean flag)
Defines whether to overwrite the existing serialized MIB files. |
void |
setParsingLevel(byte parsingLevel)
Used to set the level of parsing. |
void |
setReadDesc(boolean readFlag)
Sets the flag for reading the descriptions from compiled mib modules. |
void |
setSerializedMibFileName(java.lang.String fileName)
Defines the name with which the serialized MIB file is to be stored. |
void |
setSerializeMibs(boolean flag)
Defines whether to serialize the MibModule. |
void |
setShowImportedIndex(boolean flag)
Sets the showImportedIndex boolean value. |
void |
setThrowFileNotFound(boolean value)
Deprecated. |
java.lang.String |
toByteString(SnmpPDU pdu)
Returns the byte representation of the SnmpPDU using the MIB information. |
java.lang.String |
toByteString(SnmpVarBind varBind)
Returns the byte representation of SnmpVarbind using the MIB information. |
java.lang.String |
toByteString(SnmpVar var,
SnmpOID oid)
Gives a translated value for the SnmpVar instance using the MIB information. |
java.lang.String |
toShortString(SnmpOID oid)
Provides the short translated name representation for the SnmpOID instance. |
java.lang.String |
toString(SnmpOID oid)
Provides the translated name representation for the SnmpOID instance if found in loaded Mibs. |
java.lang.String |
toString(SnmpPDU pdu)
Returns the string value of the pdu using the MIB information |
java.lang.String |
toString(SnmpVarBind varbind)
Provides a translated value for an SNMP variable binding using information from the loaded MIBs. |
java.lang.String |
toString(SnmpVar var,
SnmpOID oid)
Provides a translated value for an SNMP variable using information from the loaded MIBs. |
java.lang.String |
toTagString(SnmpVarBind varbind)
Provides a translated value for an SNMP variable binding using information from the loaded MIBs. |
void |
unloadAllMibModules()
Unload all the loaded MibModules. |
boolean |
unloadMibModule(MibModule module)
Unloads the MibModule from the modules table. |
MibModule |
unloadMibModule(java.lang.String name)
Unloads the MibModule from the MibModules loaded in this instance. |
java.lang.String |
varBindsToString(SnmpPDU pdu)
Gets variable bindings in the PDU, using the information from loaded MIBs. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int ALL_MESSAGES
public static final int WARNING_MESSAGES
public static final int SERIOUS_MESSAGES
public static final int CRITICAL_MESSAGES
public static final byte MYSQL
public static final byte ORACLE
public static final byte LENIENT
public static final byte NORMAL
public static final byte SERIOUS
public static final byte CRITICAL
Constructor Detail |
public MibOperations()
Method Detail |
public void setMibFileExtension(java.lang.String extension)
The file will be searched with the name of the module with this extension.
So the MIB filename should be same as the modulename with this extension.
for example,
MibOperations mibOps = new MibOperations(); mibOps.setMibFileExtension("mi2,abc"); mibOps.loadMibModule("RFC1213-MIB");The file will be searched in the following sequence
In this case, it searches for the file in the following order RFC1213-MIB, RFC1213-MIB.mi2, RFC1213-MIB.abc, RFC1213-MIB.mib, RFC1213-MIB.txt, RFC1213-MIB.my
In case of applications, it also searches for the MIB module in all the files, present in that directory.
extension
- Extension of the MIB file.public void setThrowFileNotFound(boolean value)
value
- the boolean valuepublic boolean getThrowFileNotFound()
public void setDebug(boolean debug)
debug
- the boolean value.
The debugging output is generated to stdout if the boolean is set to true.public void setSerializeMibs(boolean flag)
By default, the Serialized MIB file will be saved with this filename with ".ser" as extension in the same directory from which the mib is loaded. If the fileName contains any other extension, that extension is removed and the serialized file will be created with ".ser" extension.
for example, if RMON2-MIB is loaded, it will serialize this module along with the Imported Modules viz ., RFC1271-MIB,RFC1213-MIB, and TOKEN-RING-RMON and saves it in a single file.
MibOperations mibOps = new MibOperations(); mibOps.setSerializeMibs(true); try { mibOps.loadMibModules("RMON2-MIB.mib"); } catch(Exception ex) { System.out.println(ex); }
In this case, if the filename is RMON2-MIB.mib the serialized file will be saved as RMON2-MIB.ser.
If you want to create the serialized file with any other name the method setSerializedMibFileName() can be used.
Serialization is not supported in applets.
flag
- the boolean valuesetSerializedMibFileName(java.lang.String)
,
setLoadFromSerializedMibs(boolean)
public boolean isSerializeMibs()
setSerializeMibs(boolean)
public void setLoadFromSerializedMibs(boolean flag)
If the serialized MIB file is already present, then the MIB will be loaded from the serialized MIB file. Else, the serialized file will be created and MIB will be loaded from the serialized MIB file.
The serialized MIB file will be created with the name of MIB file.
flag
- the boolean value.setSerializeMibs(boolean)
public boolean isLoadFromSerializedMibs()
setLoadFromSerializedMibs(boolean)
public void setSerializedMibFileName(java.lang.String fileName)
If the input argument is rfc1213, then the serialized MIB file will be created with the name rfc1213.ser
NOTE : This applies only if setLoadFromSerializedMibs(boolean) or
setSerializeMibs(boolean) is set to true.
fileName
- the name of the file in which the serialized file is to be stored.setLoadFromSerializedMibs(boolean)
,
loadMibModule(String)
,
loadMibModules(Applet,String)
,
loadMibModule(Applet,URL)
public java.lang.String getSerializedMibFileName()
setSerializedMibFileName(java.lang.String)
public void setOverwriteSerializedMibs(boolean flag)
After loading the MIB file as a serialized MIB file, if you do any changes in the MIB file and load it again it will not get reflected in the loaded MIB file. So at that time, this method has to be called, to overwrite the serialized MIB files and get the latest changes.
Setting this boolean to true is recommended only if you have changed the contents of the
MIB file. Otherwise, this will unnecessarily increase the loading time of the MIB's.
NOTE: This applies only when the setLoadFromSerializedMibs is set to true.
public boolean isOverwriteSerializedMibs()
setOverwriteSerializedMibs(boolean)
public void setLoadFromCompiledMibs(boolean flag)
For example, RFC1213-MIB is loaded, it will automatically load RFC1213-MIB.cmi if it exists. Otherwise it will create the compiled files by parsing the MIB and then load from the compiled MIB file. This is in case of application.
In case of applets, due to the restriction imposed for writing the files, compiled MIB files cannot be created automatically.
So in case of applets, the MIBs can be loaded from compiled files
only if they are already present. We can create the compiled MIB
files using the method createCompiledMibs(String).
flag
- the boolean value createCompiledMibs(java.lang.String)
public boolean isLoadFromCompiledMibs()
setLoadFromCompiledMibs(boolean)
public void setOverwriteCMI(boolean overWrite)
After loading the MIB file as a compiled MIB file, if you do any changes in the MIB file and load it again it will not get reflected in the loaded MIB file. So at that time, this method has to be called, to overwrite the compiled MIB files and get the latest changes.
Setting this boolean to true is recommended only if you have
changed the contents of the MIB file. Otherwise, this will
unnecessarily increase the loading time of the MIB's.
NOTE: This applies only when the setLoadFromCompiledMibs(boolean)
is set to true.
overWrite
- the boolean valuepublic boolean getOverwriteCMI()
isOverwriteCMI()
setOverwriteCMI(boolean)
public boolean isOverwriteCMI()
setOverwriteCMI(boolean)
public void setMibPath(java.lang.String path)
for example,
If the primary MIB file IF-MIB is in the directory "../mibs" and
if the imported MIB file is in the directory "../examples"
then the SearchPath can be set as follows
mibOperations.setMibPath("../mibs | ../examples");
If the SearchPath is not set, then the MIB files are searched in the current working directory, or in the directory from where the MIB file is loaded.
If the search path is set, the MIB file will be searched in the directories specified using this method in addition to the current directory and the directory from where the MIB file is loaded. The MIB files will be searched in the order specified using this method.
public void resetMibPath()
public java.lang.String getMibPath()
setMibPath(java.lang.String)
public void loadMibModules(java.lang.String mibs) throws MibException, java.io.IOException, java.io.FileNotFoundException
In case of loading the files from space seperated directories, the whole
String should be given within the double quotes.
for example, if the
MIB file is present in the directory 'Program Files',
mibOps.loadMibModules("\"../../mibs/Program Files/RFC1213-MIB\"")
The MIB file can be loaded in the following options,
If the mib file is present is different directories, the search path can be set using the method setMibPath(). The mib file will be searched in the order in which the path specified.
The parsingLevel can be set using the method setParsingLevel(). The default parsingLevel is LENIENT.
While loading a mib, imported modules also have to be loaded. So it searches for the imported module with the fileName defined in the IMPORTS section. If it could not find the file with the moduleName, then it search all the file in the directory. If it finds the file which contains the imported MIB module, then the imported module is loaded. Otherwise, if the imported module doesnot exist, then IMPORTS failed Exception will be thrown.
The default extension of the file name may be .mib,.txt,.my. In case of applications, the imported mib file can be present with any extensions. But in case of loading the mib from jar, url, applet if the extension is other than .mib,.txt,.my, then the method setMibFileExtension() has to be used.
For loading the mibs from applets, the method loadMibModules(Applet, String)
can be used.
mibs
- list of file names seperated by a space,tab, new line, carriage return and pipe symbol.
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.setLoadFromSerializedMibs(boolean)
,
setLoadFromCompiledMibs(boolean)
,
setLoadFromDatabase(boolean)
,
setMibFileExtension(java.lang.String)
,
loadMibModules(Applet, String)
,
setMibPath(java.lang.String)
,
setParsingLevel(byte)
,
setImportsParsingLevel(byte)
public void loadMibModules(java.applet.Applet applet, java.lang.String mibs) throws MibException, java.io.IOException, java.io.FileNotFoundException
applet
- applet from which the mib is loaded.mibs
- space seperated list of mib files.
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.public MibModule loadMibModule(java.applet.Applet applet, java.net.URL url) throws MibException, java.io.IOException, java.io.FileNotFoundException
applet
- applet from which the mib is loaded.url
- the name of the URL
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.public MibModule loadMibModule(java.lang.String fileName) throws MibException, java.io.IOException, java.io.FileNotFoundException
fileName
- the name of the mib file to be loaded.
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.public void createCompiledMibs(java.lang.String mibs) throws MibException, java.io.IOException, java.io.FileNotFoundException
So before creating compiled mibs for a directory of mibs, you should make sure that no compiled mibs (i.e; cmi and cds files) exist in that directory, inorder to recompile all the mibs in that directory.
mibs
- the space seperated list of mib files for which the
compiled mib files is to be generated.
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.public MibModule getMibModule(java.lang.String name)
name
- the MibModule name defined in the DEFINITIONS clause of the
MIB. The name is not identified by the filename of the MIB.
getMibModules()
public java.lang.String getModuleNameDefinition(java.lang.String file) throws MibException, java.io.IOException, java.io.FileNotFoundException
In most cases API users would not require this method as they would only need to load MIBs. This method is used to get the module name of the MIB module present in the MIB file without loading the MIB file. This method will return the first module name present in this MIB file. If the multiple MIB module, present in this MIB file, the getMibModuleDefintions(String) method can be used to retrieve all the MIB modules present in this MIB file.
file
- name of the file containing the MIB module.
MibException
- is thrown upon parse errors.
java.io.IOException
- is thrown upon IO errors.
java.io.FileNotFoundException
- is thrown if the file is not found.getModuleNameDefinitions(java.lang.String)
public MibModule getMibModule(MibNode node)
node
- the node for which module is required.
MibNode.getImportedModuleName()
public java.util.Enumeration getMibModules()
getMibModule(java.lang.String)
public static void setDebugMessageLevel(int level)
level
- the various debug levels as mentioned below
public SnmpVarBind createVariableBinding(java.lang.String varName, java.lang.String[] indexes, java.lang.String value) throws java.lang.IllegalArgumentException, SnmpException
Supply the Snmp variable value when using for SNMP set. if value is null, SnmpNull is used as needed by get requests.
for example, if you want to create the request for the columnar node
"atPhysAddress", defined in the module RFC1213-MIB,
the varName is "atPhysAddress"
Let the String array indexes contain the values 1 and 192.168.1.100
and the String Value be "theAddress".
then the output varbind will be
.1.3.6.1.2.1.3.1.1.2.1.1.192.168.1.100: theAddress
varName
- The name, or numeric object ID, of MIB variable
for which this request is being createdindexes
- The ordered list of index values String array of the index values.
Parameter can be null for non-tabular columns.value
- The value to be used for sets. The value is null for gets.
SnmpException
- is thrown upon variable creation errors.
i.e. If the index values contradict with the syntax of the
indexMibNodes.
java.lang.IllegalArgumentException
- is thrown if the parameter indexes is null
or if size of the String array indexes is not same as the number of
indexMibNodes.public SnmpOID getSnmpOID(java.lang.String s)
s
- String OID of the form .N.N.N..., or N.N.N..., in which case
the static Standard_Prefix in the SnmpAPI class is used.
N can be a number or a name.
public java.util.Vector getTCList(SnmpOID oid)
oid
- SnmpOID object.
public LeafSyntax getLeafSyntax(SnmpOID oid)
MibOperations mibOps = new MibOperations(); mibOps.loadMibModule("RFC1213-MIB"); MibNode node = mibOps.getMibNode(new SnmpOID(".1.3.6.1.2.1.1.1")); LeafSyntax leaf = node.getSyntax();
oid
- SnmpOID object.
public MibNode getMibNode(java.util.Vector oid)
oid
- Vector of String OIDs
public java.lang.String varBindsToString(SnmpPDU pdu)
pdu
- the SnmpPDU instance
public java.lang.String getErrorString(SnmpPDU pdu)
pdu
- the SnmpPDU instance
public java.lang.String toByteString(SnmpPDU pdu)
pdu
- the SnmpPDU instance
toString(SnmpPDU)
public java.lang.String toByteString(SnmpVarBind varBind)
varBind
- the SnmpVarBind instance
toString(SnmpVarBind)
public java.lang.String toByteString(SnmpVar var, SnmpOID oid)
toString(SnmpVar,SnmpOID)
public java.lang.String toString(SnmpPDU pdu)
pdu
- the SnmpPDU instance
public java.lang.String toString(SnmpVarBind varbind)
varbind
- the SnmpVarBind instance
public java.lang.String toTagString(SnmpVarBind varbind)
varbind
- the SnmpVarBind instance
public java.lang.String toString(SnmpVar var, SnmpOID oid)
var
- the SnmpVar object for the oid.oid
- the oid whose value needs to be printed.
public java.lang.String toString(SnmpOID oid)
oid
- the SnmpOID instance value
public java.lang.String toShortString(SnmpOID oid)
oid
- the SnmpOID instance
public java.lang.String getInstanceString(SnmpOID oid)
oid
- the SnmpOID for which the instance component is required.
LeafSyntax.decodeInstanceString(java.lang.String, java.util.Vector)
,
LeafSyntax.encodeInstanceString(java.util.Vector, java.util.Vector)
public java.lang.String getInstanceString(SnmpOID oid, MibNode node)
oid
- the SnmpOID instancenode
- the MibNode object corresponding to the oid.
Please note that this verification is not comprehensive for sake of efficiency. So it is not ensured that a null will be returned for a mismatched node. This returns the sub-string corresponding to the instance. For cases such as MibNode being system and OID as sysDescr the return value will start with the sub-id of mib-2. The intersection of the node oid and the given oid are eliminated from the returned oid string.
public MibNode getMibNode(SnmpOID oid)
oid
- the SnmpOID instance
public MibNode getNearestNode(SnmpOID oid)
oid
- the SnmpOID instance
public MibTrap getMibTrap(SnmpOID enterprise, int genericType, int specificType)
enterprise
- the enterprise value of the trap-typegenericType
- the integer valuespecificType
- the integer value
public NotificationType getNotificationType(SnmpOID trapoid)
public MibNode getMibNode(java.lang.String oidString)
oidString
- the name of the node
MibModule.getMibNode(String)
public MibNode getMibNode(java.lang.String nodeLabel, java.lang.String mib)
nodeLabel
- the name of the MibNodemib
- the MIB name in which the node is being searched.
public java.util.Vector getNodesFromNames(java.util.Vector nodes)
nodes
- Vector of the node names.
public java.util.Vector getNodesFromString(java.lang.String nodeList)
nodeList
- list of the node names separated by space or comma.
public LeafSyntax getSyntaxByName(java.lang.String name)
name
- the name of the syntax or TC
public int getModuleSize()
public boolean unloadMibModule(MibModule module)
module
- the nstance of the MibModule to be unloaded.
public MibModule unloadMibModule(java.lang.String name)
name
- the name of the module to be unloaded.
public void unloadAllMibModules()
public void addLabel(java.lang.String addLabel)
So if a particular reserved word in MIB is to be used in a different manner, then the conflict can be resolved by using this method. The addLabel should be invoked before loading the MIB file. Some MIB modules contains the reserved word as the identifier.
For example, suppose if a module contains a TC whose name is one of the reserved words, Unsigned32
Unsigned32 ::= INTEGER(0 .. 2147483647)If you wish you do not want to treat Unsigned32 as a reserved word, then you can do the following
MibOperations mibOps = new MibOperations(); mibOps.addLabel("Unsigned32"); mibOps.loadMibModules("mibFile");The following are the RESERVED key words
addLabel
- the word which should not be treated as a reserved
word.public boolean getIgnoreSpecificControlCodes()
setIgnoreSpecificControlCodes(boolean)
public void setIgnoreSpecificControlCodes(boolean specConCode)
specConCode
- the boolean value public void setReadDesc(boolean readFlag)
readFlag
- the boolean valuepublic boolean isReadDesc()
public java.util.Enumeration getMibModuleNames()
public java.lang.String encodeInstanceString(java.util.Vector indexValue, java.util.Vector indexMibNodes) throws java.lang.NumberFormatException
indexValue
- Vector of String values.indexMibNodes
- Vector of indexMibNodes corresponding to the indexValue
java.lang.NumberFormatException
public void initJdbcParams(java.lang.String driverName, java.lang.String URL, java.lang.String userName, java.lang.String passWord) throws MibException
driverName
- Name of the DataBase driver.URL
- URL pointing to the DataBase file nameuserName
- userNamepassWord
- password
MibException
- if any SQLException is thrown.public void setLoadFromDatabase(boolean flag)
flag
- the boolean value.initJdbcParams(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
,
setDatabaseName(byte)
public boolean isLoadFromDatabase()
setLoadFromDatabase(boolean flag)
public void setOverwriteDatabase(boolean overWrite)
overWrite
- the boolean valuepublic boolean isOverwriteDatabase()
setOverwriteDatabase(boolean overWrite)
public void setDatabaseName(byte type)
type
- the byte value (e.g. MibOperations.ORACLE )public byte getDatabaseName()
setDatabaseName(byte type)
public void setMultipleRevision(java.lang.String revisionFileName)
revisionFileName
- the name of the files containing different Revisions of the MibModule.
The file names can be seperated by space or pipe(|) symbol.public java.lang.String getMultipleRevision()
public boolean isMultipleRevision()
public void setShowImportedIndex(boolean flag)
flag
- the boolean value. public boolean isShowImportedIndex()
public java.lang.String[] getModuleNameDefinitions(java.lang.String fileName) throws java.io.FileNotFoundException, MibException, java.io.IOException
fileName
- name of the file containing the MIB module.
java.io.FileNotFoundException
MibException
java.io.IOException
getModuleNameDefinition(java.lang.String)
public void setParsingLevel(byte parsingLevel)
public void setImportsParsingLevel(byte parsingLevel)
parsingLevel
- the various parsing levels as mentioned below
public void registerParsingLevel(byte parsingLevel, byte[] checks)
parsingLevel
- the byte value other than 0,1,2,3checks
- the checks to be included in this new parsing levelpublic void addChecks(byte[] checks, byte parsingLevel)
checks
- the byte array of checks to be added.parsingLevel
- the parsinglevel in which the checks are added.public void removeChecks(byte[] checks, byte parsingLevel)
checks
- the byte array of checks to be removed.parsingLevel
- the parsinglevel from which the checks are removed.public byte getParsingLevel()
setParsingLevel(byte)
public byte getImportsParsingLevel()
setParsingLevel(byte)
public byte[] getChecks(byte parsingLevel)
parsingLevel
- the parsingLevel
public java.util.Vector getErrorModuleNames()
getErrorMessages(java.lang.String)
public java.util.Vector getErrorMessages(java.lang.String module)
getErrorModuleNames()
public void enableDisplayHint(boolean flag)
flag
- the boolean valuepublic boolean isDisplayHintEnabled()
public boolean isDBConnected()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |