|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.adventnet.snmp.mibs.MibModule
public class MibModule
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.
| 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 |
|---|
java.util.Vector augList
java.util.Vector moduleComps
boolean isVersion2Mib
java.lang.String name
MibNode root
java.util.Hashtable nodeList
java.util.Hashtable trapList
java.lang.String filename
MibOperations mibOps
java.util.Hashtable notificationList
java.util.Hashtable notificationTypeList
java.util.Hashtable notificationGroupList
java.util.Hashtable objectGroupList
java.util.Hashtable moduleIdentityList
java.util.Hashtable modComList
MibNode moduleIdentity
MibNode agentCapabilitiesNode
java.util.Vector agentCapVect
java.lang.String preModuleComments
java.util.Vector moduleCompliance
java.lang.String importedModules
java.util.Vector importsVector
java.util.Vector vectorOID
java.util.Vector stc
java.util.Vector rootNodes
java.util.Vector oidVector
java.util.Hashtable imports
java.lang.String importsString
java.io.DataInputStream inp
java.io.DataInputStream descInp
java.lang.String mibModules
java.util.Hashtable seqList
java.util.Hashtable unResolvedNodes
java.util.Hashtable unResolvedTCList
java.util.Hashtable tcList
java.util.Hashtable nonDefnStdTCs
java.util.Vector impVect
| Constructor Detail |
|---|
MibModule()
MibModule(java.lang.String name)
MibModule(java.lang.String module,
java.io.DataInputStream istr,
java.io.DataInputStream dstr,
MibOperations mibops)
throws java.io.IOException,
MibException
module - The Mib Module name. This is not the filename.istr - The DataInputStream corresponding to the compiled MIB filedstr - The DataInputStream corresponding to the description set
file.
java.io.IOException - is thrown on IO errors wjhile loading MIB.
MIBException - is thrown on parse or import loading errors.
MibException
MibModule(java.io.InputStream istr,
MibOperations mibOps,
java.lang.String fileName)
throws java.io.IOException,
MibException
istr - The DataInputStream corresponding to the MIB file.mibOps - The MibOperations instance.
java.io.IOException - is thrown on IO errors wjhile loading MIB.
MIBException - is thrown on parse or import loading errors.
MibException| Method Detail |
|---|
public boolean getMibVersion()
If the MibModule contains any one of the following Macro constructs, this module will be treated as an SMIv2 MIB.
public java.lang.String getName()
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
toString()public java.lang.String toString()
toString in class java.lang.ObjectgetName()public MibNode getRootNode()
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.
getRootNodes()public java.util.Vector getRootNodes()
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.
getRootNode()public java.util.Enumeration getDefinedTraps()
getMibTrap(java.lang.String)public MibTrap getMibTrap(java.lang.String name)
name - the name of the trap
MibOperations.getMibTrap(com.adventnet.snmp.snmp2.SnmpOID, int, int)public java.util.Enumeration getDefinedNotifications()
getMibNotification(java.lang.String)public MibNode getMibNotification(java.lang.String name)
name - label of the node whose macro-type is NOTIFICATION-TYPE
public java.util.Enumeration getDefinedNodes()
public java.lang.String getFileName()
public java.lang.String getFilename()
getFileName()public MibNode getModuleIdentity()
java.lang.String getPreModuleComments()
public MibNode getAgentCapabilities()
public java.util.Enumeration getDefinedAgentCapabilities()
public AgentCapabilities getAgentCapabilities(java.lang.String acName)
public java.util.Enumeration getDefinedModuleCompliances()
public ModuleCompliance getModuleCompliance(java.lang.String mcName)
void removeModuleComplianceSyntax()
public java.lang.String getImportedModules()
getImports()
void readFromHashtables()
throws MibException,
java.io.IOException
MibException
java.io.IOExceptionpublic java.lang.String translateToNames(java.lang.String oid)
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"
oid - numbered OID string(e.g. .1.3.6.1.2.1.1.3.0)
public java.lang.String translateToNumbers(java.lang.String oid)
oid - OID String( e.g. .iso.org.dod)
public MibNode getMibNodeByName(java.lang.String nodeLabel)
nodeLabel - the name of the node
public MibNode getMibNode(java.lang.String oid)
oid - String OID
public LeafSyntax getLeafSyntax(SnmpOID oid)
oid - the SnmpOID instance of the node
public MibNode getMibNode(SnmpOID oid)
oid - an instance of SnmpOID
public MibNode getMibNode(java.util.Vector oid)
oid - Vector of Strings OID
public MibNode getMibNode(int[] oid)
oid - Integer array of the OID
public MibNode getNearestNode(int[] oid)
oid - Integer array of the OID
public SnmpOID getSnmpOID(java.lang.String s)
s - String OID(e.g. .1.3.6 or .iso.org.dod)
java.lang.String getAccessStr(int type)
int getAccess(int type)
java.lang.String getSyntaxType(int type)
java.lang.String getStatus(int value)
void performResolution(MibModule m)
throws MibException
MibException
void upDateRootsChildren(MibNode rootNode,
MibNode node)
void update(MibNode parent,
MibNode node)
void readImportedOid()
throws java.io.IOException
java.io.IOException
void readImportedTC()
throws java.io.IOException
java.io.IOException
java.lang.String readNextDesc()
throws java.io.IOException
java.io.IOException
void readFile()
throws MibException,
java.io.IOException
MIBException - is thrown on parse or import loading errors.
MibException
java.io.IOException
void skipToEol()
throws java.io.IOException
java.io.IOException
void readTCs()
throws java.io.IOException
java.io.IOException
void readStdTCs()
throws java.io.IOException
java.io.IOException
void readTraps()
throws java.io.IOException
java.io.IOException
void readSequences()
throws java.io.IOException
java.io.IOException
Sequence readSequence()
throws java.io.IOException
java.io.IOExceptionvoid debugPrint(java.lang.String s)
java.lang.String printOctets(byte[] data,
int length)
data - the byte array representing the data to be printed.length - the number of bytes of data to be printed in hex format.int byteToInt(byte b)
b - the byte to convert
boolean isResolved()
public java.util.Enumeration getDefinedTCs()
getMibTC(java.lang.String)public MibTC getMibTC(java.lang.String name)
name - the label of the TEXTUAL-CONVENTION
public java.util.Hashtable getImports()
void removeChildren()
public java.util.Enumeration getDefinedNotificationTypes()
getNotificationType(java.lang.String),
getDefinedNotifications()public NotificationType getNotificationType(java.lang.String name)
name - label of the node whose macro-type is NOTIFICATION-TYPE
getMibNotification(java.lang.String)public java.util.Enumeration getDefinedNotificationGroups()
getNotificationGroup(java.lang.String)public NotificationGroup getNotificationGroup(java.lang.String name)
name - label of the node whose macro-type is NOTIFICATION-GROUP
public java.util.Enumeration getDefinedObjectGroups()
getObjectGroup(java.lang.String)public ObjectGroup getObjectGroup(java.lang.String name)
name - label of the node whose macro-type is OBJECT-GROUP
public ModuleIdentity getMibModuleIdentity()
name - label of the node whose macro-type is MODULE-IDENTITY
MibNode getCurrentRoot()
boolean isBaseNode(MibNode node)
boolean isDigit(java.lang.String oid)
java.util.Hashtable getModIdenTable()
java.util.Hashtable getModComTable()
java.util.Hashtable getNotiTypeTable()
java.util.Hashtable getNotiGrpTable()
java.util.Hashtable getObjGrpTable()
MibTC getNonDefinedStdTC(java.lang.String name)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||