com.adventnet.snmp.mibs
Class MibModule

java.lang.Object
  extended by com.adventnet.snmp.mibs.MibModule
All Implemented Interfaces:
com.adventnet.snmp.mibs.mibparser.MIBConstants, java.io.Serializable
Direct Known Subclasses:
JdbcMibModule

public class MibModule
extends java.lang.Object
implements com.adventnet.snmp.mibs.mibparser.MIBConstants, java.io.Serializable

This class represents a MIB module, and enables operations on MIB modules loaded from MIB files.

Typically one MIB module is specified in an MIB file. Th MibModule instance can be obtained by loading the MIB through the MibOperations object.

                MibOperations mibOps = new MibOperations();
                MibModule module = null;
                try
                {
                        mibOps.loadMibModule("RFC1213-MIB");
                        module = mibOps.getMibModule("RFC1213-MIB");                    
                }
                catch(Excepion ex)
                {
                }
  

The functions in MibOperations which apply across all loaded MIBs. Use this class to restrict your operation to a specific MIB module. This is not advisable always. Infact, some of the methods will use mibOps to get the appropriate values.

We can obtain the all Macro types present in the MIB module.
The following table lists the macrotypes and the methods for getting the corresponding macrotype objects defined in the module.

Macro Types Methods for retreiving the macro types 
AGENT-CAPABILITIES getDefinedAgentCapabilities()
MODULE-IDENTITY getMibModuleIdentity()
MODULE-COMPLIANCE getDefinedModuleCompliances()
NOTIFICATION-TYPE getDefinedNotificationTypes()
OBJECT-TYPE/OBJECT IDENTIFIERS getDefinedNodes()
OBJECT-GROUP getDefinedObjectGroups()
TEXTUAL-CONVENTION getDefinedTCs()
TRAP-TYPE  getDefinedTraps()

Each MIB Module is associated with a MibModule instance, which is built from parsing a MIB file. The root in a module is the highest node defined in the given module file, e.g. mgmt in rfc1213, or rmon in rfc1271-RMON. However, the parent nodes including "iso" are nodes in the module nodeList.

Once parsed, the MIB module is attached to the MibOperations instance so subsequent operations will make use of the MIB definitions.

The compiled approach has taken a slightly different route. In the ideal case a particular node will not be replicated across two MIBs. The relationships and the dependencies of the nodes upon elements in other MIBs are instead kept track of.

See Also:
Serialized Form

Nested Class Summary
(package private)  class MibModule.ImportOid
          This class will represent an imported Oid.
(package private)  class MibModule.ImportsClass
          An instance of this class exists for each imported MIB.
 
Field Summary
(package private)  MibNode agentCapabilitiesNode
           
(package private)  java.util.Vector agentCapVect
           
(package private)  java.util.Vector augList
           
(package private)  java.io.DataInputStream descInp
          The principal input streams
(package private)  java.lang.String filename
          To report parse errors.
(package private)  java.lang.String importedModules
           
(package private)  java.util.Hashtable imports
          Hashtable containing list of modules this mib is dependent and the corresponding ImportObjects
(package private)  java.lang.String importsString
          Contains the IMPORTS as defined in MIB(i.e; the format)
(package private)  java.util.Vector importsVector
           
(package private)  java.util.Vector impVect
           
(package private)  java.io.DataInputStream inp
          The principal input streams
(package private)  boolean isVersion2Mib
          Defines the SMI version of this MIB module.
(package private)  java.lang.String mibModules
           
(package private)  MibOperations mibOps
          The api to which this module should be added
(package private)  java.util.Hashtable modComList
           
(package private)  java.util.Vector moduleCompliance
           
(package private)  java.util.Vector moduleComps
           
(package private)  MibNode moduleIdentity
           
(package private)  java.util.Hashtable moduleIdentityList
           
(package private)  java.lang.String name
           
(package private)  java.util.Hashtable nodeList
          Nodelist containing nodes defined in this module.
(package private)  java.util.Hashtable nonDefnStdTCs
           
(package private)  java.util.Hashtable notificationGroupList
           
(package private)  java.util.Hashtable notificationList
           
(package private)  java.util.Hashtable notificationTypeList
           
(package private)  java.util.Hashtable objectGroupList
           
(package private)  java.util.Vector oidVector
           
(package private)  java.lang.String preModuleComments
           
(package private)  MibNode root
           
(package private)  java.util.Vector rootNodes
           
(package private)  java.util.Hashtable seqList
           
(package private)  java.util.Vector stc
           
(package private)  java.util.Hashtable tcList
          List of TEXTUAL-CONVENTION defined in this module
(package private)  java.util.Hashtable trapList
          List of traps defined in this module
(package private)  java.util.Hashtable unResolvedNodes
          Contains list of nodes which need to be resolved.
(package private)  java.util.Hashtable unResolvedTCList
          Contains for each syntax element identified by so called name, the vector corresponding to elements whose syntax needs to be set with the syntax of specific type.
(package private)  java.util.Vector vectorOID
           
 
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
MibModule()
          Empty constructor.
MibModule(java.io.InputStream istr, MibOperations mibOps, java.lang.String fileName)
          Let this be the only constructor to directly load MIBs from text Files.
MibModule(java.lang.String name)
           
MibModule(java.lang.String module, java.io.DataInputStream istr, java.io.DataInputStream dstr, MibOperations mibops)
          Let this be the only constructor we use.
 
Method Summary
(package private)  int byteToInt(byte b)
          Since JAVA does not support unsigned types, we need a converter from unsigned byte to int that preserves the last 8 bits.
(package private)  void debugPrint(java.lang.String s)
          To print debug outputs
(package private)  int getAccess(int type)
          Returns the old access constant values corresponding to the new access constants.
(package private)  java.lang.String getAccessStr(int type)
          Returns the String corresponding to the access clause.
 MibNode getAgentCapabilities()
          Deprecated. since 4.0. Instead you can use the method getDefinedAgentCapabilities
 AgentCapabilities getAgentCapabilities(java.lang.String acName)
          Returns the AgentCapabilities object present in this module.
(package private)  MibNode getCurrentRoot()
          Retrieves the actual root from the existing set of current root oid elements.
 java.util.Enumeration getDefinedAgentCapabilities()
          Returns the Enumeration of AgentCapabilities present in this module.
 java.util.Enumeration getDefinedModuleCompliances()
          Returns the ModuleCompliances present in this module.
 java.util.Enumeration getDefinedNodes()
          Gets all the nodes defined in this module using this method.
 java.util.Enumeration getDefinedNotificationGroups()
          Gets all the NotificationGroup objects defined in this module.
 java.util.Enumeration getDefinedNotifications()
          Gets all the NOTIFICATION-TYPE objects defined in this module.
 java.util.Enumeration getDefinedNotificationTypes()
          Gets all the NotificationType objects defined in this module.
 java.util.Enumeration getDefinedObjectGroups()
          Gets all the ObjectGroup objects defined in this module.
 java.util.Enumeration getDefinedTCs()
          Gets all the TEXTUAL-CONVENTIONS defined in this module.
 java.util.Enumeration getDefinedTraps()
          Gets all the TRAP-TYPE objects defined in this MIB module.
 java.lang.String getFilename()
          Deprecated. since 2.1 . Instead you can use the method getFileName()
 java.lang.String getFileName()
          Gets the filename of this module.
 java.lang.String getImportedModules()
          Gets the names of the modules imported by this module.
 java.util.Hashtable getImports()
          Gets the imported elements in the MIB.
 LeafSyntax getLeafSyntax(SnmpOID oid)
          Gets the syntax of the node corresponding to this oid.
 ModuleIdentity getMibModuleIdentity()
          Gets the ModuleIdentity object for the given name.
 MibNode getMibNode(int[] oid)
          Gets the MibNode corresponding to the int array of OID.
 MibNode getMibNode(SnmpOID oid)
          Gets the MibNode corresponding to the SnmpOID argument
 MibNode getMibNode(java.lang.String oid)
          Gets the MibNode corresponding to the String OID argument.
 MibNode getMibNode(java.util.Vector oid)
          Gets the MibNode per the Vector of Strings OID argument.
 MibNode getMibNodeByName(java.lang.String nodeLabel)
          Gives the MibNode corresponding to the specified nodeLabel
 MibNode getMibNotification(java.lang.String name)
          Gets the NOTIFICATION-TYPE object corresponding to the given name.
 MibTC getMibTC(java.lang.String name)
          Gets the TEXTUAL-CONVENTION corresponding to the given name.
 MibTrap getMibTrap(java.lang.String name)
          Used to get the MibTrap object by giving the trap name.
Using the MibTrap object, the trap informations such as the enterprise, trap number etc.
 boolean getMibVersion()
          Used to know whether the loaded MIB module is an SMIv1 MIB (Structure of Management Information) or SMIv2 MIB.
(package private)  java.util.Hashtable getModComTable()
           
(package private)  java.util.Hashtable getModIdenTable()
           
 ModuleCompliance getModuleCompliance(java.lang.String mcName)
          Returns the ModuleComplience object corresponding to the given name.
 MibNode getModuleIdentity()
          Gives the MODULE-IDENTITY node defined in the MIB.
 java.lang.String getName()
          Gets the name of this MIB module.
 MibNode getNearestNode(int[] oid)
          Gets the Nearest MibNode corresponding to the int array of OID.
(package private)  MibTC getNonDefinedStdTC(java.lang.String name)
           
 NotificationGroup getNotificationGroup(java.lang.String name)
          Gets the NotificationGroup object for the given name.
 NotificationType getNotificationType(java.lang.String name)
          Gets the NotificationType object for the given name.
(package private)  java.util.Hashtable getNotiGrpTable()
           
(package private)  java.util.Hashtable getNotiTypeTable()
           
 ObjectGroup getObjectGroup(java.lang.String name)
          Gets the ObjectGroup object for the given name.
(package private)  java.util.Hashtable getObjGrpTable()
           
(package private)  java.lang.String getPreModuleComments()
           
 MibNode getRootNode()
          Gets a reference to the root node in this MIB module.
 java.util.Vector getRootNodes()
          Returns a collection of root nodes.
 SnmpOID getSnmpOID(java.lang.String s)
          Creates an SnmpOID instance from the specified string and information from this Module.
(package private)  java.lang.String getStatus(int value)
          Returns String corresdponding to status value.
(package private)  java.lang.String getSyntaxType(int type)
          The String representing the syntax type.
(package private)  boolean isBaseNode(MibNode node)
          Checks if node is one of the base nodes iso,ccitt or joint-iso-ccitt.
(package private)  boolean isDigit(java.lang.String oid)
           
(package private)  boolean isResolved()
          Checks if any import resolutions are still pending.
(package private)  void performResolution(MibModule m)
          performs resolutions.
(package private)  java.lang.String printOctets(byte[] data, int length)
          Print octet data in a more readable form
(package private)  void readFile()
          This performs the high level reading operations
(package private)  void readFromHashtables()
           
(package private)  void readImportedOid()
          Reads in the imported oid elements and stores them in ImportsClass objects.
(package private)  void readImportedTC()
          Reads in any imported TC and puts them into the respective ImportsClass objects.
(package private)  java.lang.String readNextDesc()
          Reads in the next string from the descriptions file
(package private)  Sequence readSequence()
           
(package private)  void readSequences()
          Reads in the sequences and stores them in seqList
(package private)  void readStdTCs()
          Reads in all the standard TCs used in this MIB Module.
(package private)  void readTCs()
          Reads in all the TCs defined in this MIB Module.
(package private)  void readTraps()
          reads in all the traps defined in this MIB
(package private)  void removeChildren()
           
(package private)  void removeModuleComplianceSyntax()
           
(package private)  void skipToEol()
          Reads bytes till it encounters an end of line char
 java.lang.String toString()
          Returns the name of this MibModule.
 java.lang.String translateToNames(java.lang.String oid)
          Used for translating numbered OID String to named OID String.
 java.lang.String translateToNumbers(java.lang.String oid)
          Used for translating named OID String to numbered OID String.
(package private)  void update(MibNode parent, MibNode node)
           
(package private)  void upDateRootsChildren(MibNode rootNode, MibNode node)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

augList

java.util.Vector augList

moduleComps

java.util.Vector moduleComps

isVersion2Mib

boolean isVersion2Mib
Defines the SMI version of this MIB module. Will be set to true if this module contains any SMIv2 Macro construct.


name

java.lang.String name

root

MibNode root

nodeList

java.util.Hashtable nodeList
Nodelist containing nodes defined in this module.


trapList

java.util.Hashtable trapList
List of traps defined in this module


filename

java.lang.String filename
To report parse errors. API users need not use this variable


mibOps

MibOperations mibOps
The api to which this module should be added


notificationList

java.util.Hashtable notificationList

notificationTypeList

java.util.Hashtable notificationTypeList

notificationGroupList

java.util.Hashtable notificationGroupList

objectGroupList

java.util.Hashtable objectGroupList

moduleIdentityList

java.util.Hashtable moduleIdentityList

modComList

java.util.Hashtable modComList

moduleIdentity

MibNode moduleIdentity

agentCapabilitiesNode

MibNode agentCapabilitiesNode

agentCapVect

java.util.Vector agentCapVect

preModuleComments

java.lang.String preModuleComments

moduleCompliance

java.util.Vector moduleCompliance

importedModules

java.lang.String importedModules

importsVector

java.util.Vector importsVector

vectorOID

java.util.Vector vectorOID

stc

java.util.Vector stc

rootNodes

java.util.Vector rootNodes

oidVector

java.util.Vector oidVector

imports

java.util.Hashtable imports
Hashtable containing list of modules this mib is dependent and the corresponding ImportObjects


importsString

java.lang.String importsString
Contains the IMPORTS as defined in MIB(i.e; the format)


inp

java.io.DataInputStream inp
The principal input streams


descInp

java.io.DataInputStream descInp
The principal input streams


mibModules

java.lang.String mibModules

seqList

java.util.Hashtable seqList

unResolvedNodes

java.util.Hashtable unResolvedNodes
Contains list of nodes which need to be resolved.


unResolvedTCList

java.util.Hashtable unResolvedTCList
Contains for each syntax element identified by so called name, the vector corresponding to elements whose syntax needs to be set with the syntax of specific type.


tcList

java.util.Hashtable tcList
List of TEXTUAL-CONVENTION defined in this module


nonDefnStdTCs

java.util.Hashtable nonDefnStdTCs

impVect

java.util.Vector impVect
Constructor Detail

MibModule

MibModule()
Empty constructor. Just to prevent silly things from happening.


MibModule

MibModule(java.lang.String name)

MibModule

MibModule(java.lang.String module,
          java.io.DataInputStream istr,
          java.io.DataInputStream dstr,
          MibOperations mibops)
    throws java.io.IOException,
           MibException
Let this be the only constructor we use. If we need an import module let the mibOps figure out where to locate it from. Keep this simple and straightforward. No Applet dependencies etc. Just use couple of InputStreams, get the work done. Add the request for import modules and return.

Parameters:
module - The Mib Module name. This is not the filename.
istr - The DataInputStream corresponding to the compiled MIB file
dstr - The DataInputStream corresponding to the description set file.
Throws:
java.io.IOException - is thrown on IO errors wjhile loading MIB.
MIBException - is thrown on parse or import loading errors.
MibException

MibModule

MibModule(java.io.InputStream istr,
          MibOperations mibOps,
          java.lang.String fileName)
    throws java.io.IOException,
           MibException
Let this be the only constructor to directly load MIBs from text Files. If we need an import module let the mibOps figure out where to locate it from. Keep this simple and straightforward. No Applet dependencies etc. Just use a single InputStream, get the work done. Add the request for import modules and return.

Parameters:
istr - The DataInputStream corresponding to the MIB file.
mibOps - The MibOperations instance.
Throws:
java.io.IOException - is thrown on IO errors wjhile loading MIB.
MIBException - is thrown on parse or import loading errors.
MibException
Method Detail

getMibVersion

public boolean getMibVersion()
Used to know whether the loaded MIB module is an SMIv1 MIB (Structure of Management Information) or SMIv2 MIB.

If the MibModule contains any one of the following Macro constructs, this module will be treated as an SMIv2 MIB.

Returns:
true, if this MibModule is an SMIv2 MIB.
false, this MibModule is an SMIv1 MIB.

getName

public java.lang.String getName()
Gets the name of this MIB module.

The module name begins with an upper-case letter and continues with zero or more letters, digits, or hyphens, except that a hyphen can not be the last character, nor can there be two consecutive hyphens. For example, RFC1213-MIB

Returns:
String the name of the module as defined in the MIB.
See Also:
toString()

toString

public java.lang.String toString()
Returns the name of this MibModule. This method is same as the getName() method.

Overrides:
toString in class java.lang.Object
See Also:
getName()

getRootNode

public MibNode getRootNode()
Gets a reference to the root node in this MIB module.

This method will create a root node by getting the common ancestor node of all the nodes present in this module.
If a module has more than one root node this method will return null. In that case the method getRootNodes() can be used which retuns all the root nodes.

Returns:
MibNode. The root node if there is a single root node.
returns null, if there are more than one root node or if the module contains only TEXUAL-CONVENTIONs and TRAP-TYPE macro types but no OBJECT-TYPE node objects.
See Also:
getRootNodes()

getRootNodes

public java.util.Vector getRootNodes()
Returns a collection of root nodes.

In case of a module containing a single root node, both the methods getRootNode() and getRootNodes() will return the root node.
In case of module containing more than one root nodes like iso and ccitt, the getRootNode() will return null and the getRootNodes() will return a collection of root nodes.

Returns:
Vector of MibNodes representing the root set, if multiple rootnodes present in this module.
null, when a module contains only TEXUAL-CONVENTIONs and TRAP-TYPE macro types but no OBJECT-TYPE node objects.
See Also:
getRootNode()

getDefinedTraps

public java.util.Enumeration getDefinedTraps()
Gets all the TRAP-TYPE objects defined in this MIB module.

Returns:
Enumeration of MibTrap objects, if present in this module
Otherwise, returns Enumeration object with zero entries.
See Also:
getMibTrap(java.lang.String)

getMibTrap

public MibTrap getMibTrap(java.lang.String name)
Used to get the MibTrap object by giving the trap name.
Using the MibTrap object, the trap informations such as the enterprise, trap number etc. can be obtained. If you do not know the trap name, but you know other details of the trap such as enterprise, genericType and specificType of the trap, then you can use the method getMibTrap() in the class MibOperations.

Parameters:
name - the name of the trap
Returns:
MibTrap object if defined in this module, else return null.
See Also:
MibOperations.getMibTrap(com.adventnet.snmp.snmp2.SnmpOID, int, int)

getDefinedNotifications

public java.util.Enumeration getDefinedNotifications()
Gets all the NOTIFICATION-TYPE objects defined in this module.

Returns:
Enumeration of MibNodes. These MibNode objects contain all the information about the NOTIFICATION-TYPE objects.
See Also:
getMibNotification(java.lang.String)

getMibNotification

public MibNode getMibNotification(java.lang.String name)
Gets the NOTIFICATION-TYPE object corresponding to the given name.

Parameters:
name - label of the node whose macro-type is NOTIFICATION-TYPE
Returns:
MibNode corresponding to the name of the NOTIFICATION-TYPE, if present in this module
else return null.

getDefinedNodes

public java.util.Enumeration getDefinedNodes()
Gets all the nodes defined in this module using this method.

Returns:
Enumeration of MibNodes.

getFileName

public java.lang.String getFileName()
Gets the filename of this module.

Returns:
the name of the file in which this module is defined.

getFilename

public java.lang.String getFilename()
Deprecated. since 2.1 . Instead you can use the method getFileName()

See Also:
getFileName()

getModuleIdentity

public MibNode getModuleIdentity()
Gives the MODULE-IDENTITY node defined in the MIB. In an SMIv1 MIB, the MODULE-IDENTITY node will not be present.

Returns:
the MODULE-IDENTITY node.
null if not available.

getPreModuleComments

java.lang.String getPreModuleComments()

getAgentCapabilities

public MibNode getAgentCapabilities()
Deprecated. since 4.0. Instead you can use the method getDefinedAgentCapabilities

Gets the node corresponding to AgentCapabilities for this module.

Returns:
the AGENT-CAPABILITIES node in the MIB.
null, if not available.

getDefinedAgentCapabilities

public java.util.Enumeration getDefinedAgentCapabilities()
Returns the Enumeration of AgentCapabilities present in this module.

Returns:
the Enumeration containing AgentCapabilities object.
empty Enumeration , if AgentCapabilities object not available.

getAgentCapabilities

public AgentCapabilities getAgentCapabilities(java.lang.String acName)
Returns the AgentCapabilities object present in this module.

Returns:
the AgentCapabilities object if present else
returns null.

getDefinedModuleCompliances

public java.util.Enumeration getDefinedModuleCompliances()
Returns the ModuleCompliances present in this module.

Returns:
the Enumeration containing ModuleCompliance object.
empty Enumeration, if ModuleCompliance is not present in this Module.

getModuleCompliance

public ModuleCompliance getModuleCompliance(java.lang.String mcName)
Returns the ModuleComplience object corresponding to the given name.

Returns:
the ModuleCompliance object if present
else returns null.

removeModuleComplianceSyntax

void removeModuleComplianceSyntax()

getImportedModules

public java.lang.String getImportedModules()
Gets the names of the modules imported by this module.

Returns:
space separated list of imported module names.
empty String, if there are no imported modules.
See Also:
getImports()

readFromHashtables

void readFromHashtables()
                  throws MibException,
                         java.io.IOException
Throws:
MibException
java.io.IOException

translateToNames

public java.lang.String translateToNames(java.lang.String oid)
Used for translating numbered OID String to named OID String. In case the oid not starting with a dot, it will append the standard prefix .1.3.6.1.2.1 and the return the named OID String.

for example, if the input argument is 1.3.0, then this method will return ".iso.org.dod.internet.mgmt.mib-2.system.sysUpTime.0"

Parameters:
oid - numbered OID string(e.g. .1.3.6.1.2.1.1.3.0)
Returns:
the named oid String
null if the node is not found in this module

translateToNumbers

public java.lang.String translateToNumbers(java.lang.String oid)
Used for translating named OID String to numbered OID String. In case the oid not starting with a dot, it will append the standard prefix .1.3.6.1.2.1 and the return the OID String.

Parameters:
oid - OID String( e.g. .iso.org.dod)
Returns:
the numbered oid String
null if the node is not found in this module

getMibNodeByName

public MibNode getMibNodeByName(java.lang.String nodeLabel)
Gives the MibNode corresponding to the specified nodeLabel

Parameters:
nodeLabel - the name of the node
Returns:
MibNode object if the node is present in the module.
null otherwise

getMibNode

public MibNode getMibNode(java.lang.String oid)
Gets the MibNode corresponding to the String OID argument. This method will accept the OID string in following formats: 1. numbered OID string. MibNode node = module.getMibNode(".1.3.6.1.2.1.1.1"); 2. named OID string. MibNode node = module.getMibNode(".iso.org.dod.internet.mgmt.mib-2.snmp.sysDescr"); MibNode node = module.getMibNode("interfaces.ifTable.ifEntry.ifType"); MibNode node = module.getMibNode("system.sysDescr"); MibNode node = module.getMibNode("system.sysDescr"); MibNode node = module.getMibNode("sysDescr"); 3. numbered oid string without standard prefix. If the oid string not startswith the dot (".") the standard_prefix .1.3.6.1.2.1 will be prepended with the given oid string. MibNode node = module.getMibNode("1.1"); 4. combination of numbered and named OID string oid format. MibNode node = module.getMibNode(".1.3.6.1.2.1.system.1"); MibNode node = module.getMibNode(".iso.3.dod.2.mgmt.1.system.1"); MibNode node = module.getMibNode("interfaces.2.1.ifType"); The oid string can be given with the instance string in case of the leaf node. The leaf node objects are scalar or columnar node. MibNode node = module.getMibNode("1.1.0"); or MibNode node = module.getMibNode("sysDescr.0");

Parameters:
oid - String OID
Returns:
MibNode, if the node corresponding to the oid is present
null if the node is not present in this module or the instance present in the the non-leaf nodes.

getLeafSyntax

public LeafSyntax getLeafSyntax(SnmpOID oid)
Gets the syntax of the node corresponding to this oid. This does a search of the node in the module and returns the syntax for this SnmpOID instance.

Parameters:
oid - the SnmpOID instance of the node
Returns:
LeafSyntax object.
null if this node is not a leaf node

getMibNode

public MibNode getMibNode(SnmpOID oid)
Gets the MibNode corresponding to the SnmpOID argument

Parameters:
oid - an instance of SnmpOID
Returns:
MibNode, if the node is present. null otherwise.

getMibNode

public MibNode getMibNode(java.util.Vector oid)
Gets the MibNode per the Vector of Strings OID argument. For something like system.1 it will return sysDescr and if the vector contains sysDescr and nothing else, it will return the node for sysDescr This method always tries to retrieve a leaf node. If it matches a non-leaf node, then that node is returned only if the match of oid elements is exact(i.e no undefined child components, should exist in that system. If not so the system.1 will fail to return a node if loaded MIB does not contain sysDescr node But mib-2.1 will return system if the system node is available).

Parameters:
oid - Vector of Strings OID
Returns:
the MibNode per the Vector of Strings OID argument
null, if the node is not found

getMibNode

public MibNode getMibNode(int[] oid)
Gets the MibNode corresponding to the int array of OID. If there are more oid numbers than the node we could find then this method returns only the leaf node

Parameters:
oid - Integer array of the OID
Returns:
MibNode, if the node is present, null otherwise.

getNearestNode

public MibNode getNearestNode(int[] oid)
Gets the Nearest MibNode corresponding to the int array of OID. This method returns the nearest node even if it is not a leaf node (when there are more oid numbers than the node we could find).

Parameters:
oid - Integer array of the OID
Returns:
MibNode if the node is present, null otherwise.

getSnmpOID

public SnmpOID getSnmpOID(java.lang.String s)
Creates an SnmpOID instance from the specified string and information from this Module. It requires the first argument to be an 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.

Parameters:
s - String OID(e.g. .1.3.6 or .iso.org.dod)
Returns:
the SnmpOID instance if found
else return null.

getAccessStr

java.lang.String getAccessStr(int type)
Returns the String corresponding to the access clause. The corresponding constants are defined in USMConstants.


getAccess

int getAccess(int type)
Returns the old access constant values corresponding to the new access constants. The new access constants are defined in MIBConstants. The earlier ones were defined in SnmpAPI


getSyntaxType

java.lang.String getSyntaxType(int type)
The String representing the syntax type. The int value parameters should be among those in MIBConstants.

Returns:
String such as INTEGER,OCTET STRING etc.

getStatus

java.lang.String getStatus(int value)
Returns String corresdponding to status value. The status value should be one of those in MIBConstants.


performResolution

void performResolution(MibModule m)
                 throws MibException
performs resolutions. There is some redundancy in the imports etc., in the sense that there are variable and objects which are not required. clean it up, when you understand this stuff well.

Throws:
MibException

upDateRootsChildren

void upDateRootsChildren(MibNode rootNode,
                         MibNode node)

update

void update(MibNode parent,
            MibNode node)

readImportedOid

void readImportedOid()
               throws java.io.IOException
Reads in the imported oid elements and stores them in ImportsClass objects.

Throws:
java.io.IOException

readImportedTC

void readImportedTC()
              throws java.io.IOException
Reads in any imported TC and puts them into the respective ImportsClass objects.

Throws:
java.io.IOException

readNextDesc

java.lang.String readNextDesc()
                        throws java.io.IOException
Reads in the next string from the descriptions file

Throws:
java.io.IOException

readFile

void readFile()
        throws MibException,
               java.io.IOException
This performs the high level reading operations

Throws:
MIBException - is thrown on parse or import loading errors.
MibException
java.io.IOException

skipToEol

void skipToEol()
         throws java.io.IOException
Reads bytes till it encounters an end of line char

Throws:
java.io.IOException

readTCs

void readTCs()
       throws java.io.IOException
Reads in all the TCs defined in this MIB Module.

Throws:
java.io.IOException

readStdTCs

void readStdTCs()
          throws java.io.IOException
Reads in all the standard TCs used in this MIB Module.

Throws:
java.io.IOException

readTraps

void readTraps()
         throws java.io.IOException
reads in all the traps defined in this MIB

Throws:
java.io.IOException

readSequences

void readSequences()
             throws java.io.IOException
Reads in the sequences and stores them in seqList

Throws:
java.io.IOException

readSequence

Sequence readSequence()
                throws java.io.IOException
Throws:
java.io.IOException

debugPrint

void debugPrint(java.lang.String s)
To print debug outputs


printOctets

java.lang.String printOctets(byte[] data,
                             int length)
Print octet data in a more readable form

Parameters:
data - the byte array representing the data to be printed.
length - the number of bytes of data to be printed in hex format.

byteToInt

int byteToInt(byte b)
Since JAVA does not support unsigned types, we need a converter from unsigned byte to int that preserves the last 8 bits.

Parameters:
b - the byte to convert
Returns:
the integer value of the byte

isResolved

boolean isResolved()
Checks if any import resolutions are still pending. this is checked before adding the module to mibops.


getDefinedTCs

public java.util.Enumeration getDefinedTCs()
Gets all the TEXTUAL-CONVENTIONS defined in this module.

Returns:
Enumeration of MibTC objects, if present in this module.
Enumeration object with zero entries, if not present. These MibTC objects contain all the information about the TEXTUAL-CONVENTION.
See Also:
getMibTC(java.lang.String)

getMibTC

public MibTC getMibTC(java.lang.String name)
Gets the TEXTUAL-CONVENTION corresponding to the given name.

Parameters:
name - the label of the TEXTUAL-CONVENTION
Returns:
MibTC object corresponding to the name of the TC, if present in this module. null otherwise.

getImports

public java.util.Hashtable getImports()
Gets the imported elements in the MIB. The Hashtable contains the key as MIB module name and the value containing the Vector of the names of the imported elements.

Returns:
Hashtable of Imported elements.

removeChildren

void removeChildren()

getDefinedNotificationTypes

public java.util.Enumeration getDefinedNotificationTypes()
Gets all the NotificationType objects defined in this module.

Returns:
Enumeration of NotificationType object. These NotificationType objects contain all the information about this NOTIFICATION-TYPE macro.
See Also:
getNotificationType(java.lang.String), getDefinedNotifications()

getNotificationType

public NotificationType getNotificationType(java.lang.String name)
Gets the NotificationType object for the given name.

Parameters:
name - label of the node whose macro-type is NOTIFICATION-TYPE
Returns:
NotificationType object corresponding to the name, if present in this module
else return null.
See Also:
getMibNotification(java.lang.String)

getDefinedNotificationGroups

public java.util.Enumeration getDefinedNotificationGroups()
Gets all the NotificationGroup objects defined in this module.

Returns:
Enumeration of NotificationGroup object. These NotificationGroup objects contain all the information about this NOTIFICATION-GROUP macro.
See Also:
getNotificationGroup(java.lang.String)

getNotificationGroup

public NotificationGroup getNotificationGroup(java.lang.String name)
Gets the NotificationGroup object for the given name.

Parameters:
name - label of the node whose macro-type is NOTIFICATION-GROUP
Returns:
NotificationGroup object corresponding to the name, if present in this module
else return null.

getDefinedObjectGroups

public java.util.Enumeration getDefinedObjectGroups()
Gets all the ObjectGroup objects defined in this module.

Returns:
Enumeration of ObjectGroup object. These ObjectGroup objects contain all the information about this OBJECT-GROUP macro.
See Also:
getObjectGroup(java.lang.String)

getObjectGroup

public ObjectGroup getObjectGroup(java.lang.String name)
Gets the ObjectGroup object for the given name.

Parameters:
name - label of the node whose macro-type is OBJECT-GROUP
Returns:
ObjectGroup object corresponding to the name, if present in this module
else return null.

getMibModuleIdentity

public ModuleIdentity getMibModuleIdentity()
Gets the ModuleIdentity object for the given name.

Parameters:
name - label of the node whose macro-type is MODULE-IDENTITY
Returns:
ModuleIdentity object corresponding to the name, if present in this module
else return null.

getCurrentRoot

MibNode getCurrentRoot()
Retrieves the actual root from the existing set of current root oid elements. Also cleans the rootOid list to avoid duplication and redundant elements. This routine needs to be optimized if getting called too many times.


isBaseNode

boolean isBaseNode(MibNode node)
Checks if node is one of the base nodes iso,ccitt or joint-iso-ccitt. The check is reference based and not node label or oid based.


isDigit

boolean isDigit(java.lang.String oid)

getModIdenTable

java.util.Hashtable getModIdenTable()

getModComTable

java.util.Hashtable getModComTable()

getNotiTypeTable

java.util.Hashtable getNotiTypeTable()

getNotiGrpTable

java.util.Hashtable getNotiGrpTable()

getObjGrpTable

java.util.Hashtable getObjGrpTable()

getNonDefinedStdTC

MibTC getNonDefinedStdTC(java.lang.String name)