com.adventnet.snmp.snmp2
Class SnmpAPI

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--com.adventnet.snmp.snmp2.SnmpAPI

public class SnmpAPI
extends java.lang.Thread
implements java.io.Serializable

The SnmpAPI class is a root class for AdventNet SNMP API. This class extends "java.lang.Thread". Any network management application written using AdventNet SNMP API, should instantiate this class.

The various vital informations and methods that this class contains are
1. It contains the list of all SnmpSessions which are opened with the help of this SnmpAPI instance.
2. It contains various public constants for the different SNMP versions, SNMP operations, SNMP variables, SNMP error values, SNMP exception values, SNMP table's row status values and the different access constants for these SNMP variables.
3. It contains a SnmpGroup object which maintains the various group counters for this SNMP entity.
4. It contains a list of all SecurityProviders that are installed. By default the USM (User based Security Model) is registered. This corresponds to the "usmUserTable" of the "SNMP-USER-BASED-SM-MIB" mib.
5. It contains a list of all Access Control Providers that are added by users. By default the View based Access Control Model ( VACM ) is registered. These corresponds to the "vacmContextTable", "vacmSecurityToGroupTable", "vacmAccessTable" and "vacmViewTreeFamilyTable" of the "SNMP-VIEW-BASED-ACM-MIB" mib.
6. It contains the SnmpEngineTable which cotains the engine information of various SNMPv3 engines. This table the engineName, engineID, engineTime and engineBoots of the particular SNMP entity.
7. This class holds the snmpEngineID, snmpEngineBoots and the snmpEngineTime of this SNMP entity.
8. It contains the database connection for the tables engine table, usm table and vacm tables.
9. It also provides methods which support persistency of the SecurityModel specific information in the form of serialize() and deSerialized() methods. The security configurations can be serialized so that they could be restored when the SNMPv3 entity is restarted. The SecurityModelTable implementation has to implement the serialize and deSerialize methods. In order to store/restore the configuration information, the API user has to set the file name using the setSerializeFileName method so that the serialize/deSerialize methods use this file for their operation.

The various activities that this thread performs are
1. Monitors each and every request for their timeouts.
2. Responsible for re-transmitting a request in case of a "retry".
3. Removes the received packets from the queue, when the count exceeds a threshold value.

To use the low-level API, instantiate an SnmpAPI. From there, you can create SNMP sessions, and perform SNMP operations. You can create multiple SnmpAPI instances, though there is little reason to do so for most applications.


 
 
 
The following table gives the values for the command types available in SNMP.

SNMP command. Value in decimal as a byte. Value in Hex.
GET_REQ_MSG -96 a0
GETNEXT_REQ_MSG -95 a1
GET_RSP_MSG -94 a2
SET_REQ_MSG -93 a3
TRP_REQ_MSG -92 a4
     
GETBULK_REQ_MSG -91 a5
INFORM_REQ_MSG -90 a6
TRP2_REQ_MSG -89 a7


 
 
 
The following table gives the values for SNMP Data types.

SNMP Variable Value in decimal as a byte. Value in Hex.
STRING 4 4
OBJID 6 6
INTEGER 2 2
NULLOBJ 5 5
IPADDRESS 64 40
NETWORKADDRESS 64 40
COUNTER 65 41
GAUGE 66 42
UNSIGNED32 66 42
TIMETICKS 67 43
OPAQUE 68 44
     
COUNTER64 70 46
UINTEGER32 66 42


 
 
 
The following table gives the values for the Standard SNMP Errors. Only the first 6 errors belong to SNMPv1.

SNMP Error Type Value in decimal as a byte Value in Hex
SNMP_ERR_NOERROR 0 00
SNMP_ERR_TOOBIG 1 01
SNMP_ERR_NOSUCHNAME 2 02
SNMP_ERR_BADVALUE 3 03
SNMP_ERR_READONLY 4 04
SNMP_ERR_GENERR 5 05
     
SNMP_ERR_NOACCESS 6 06
SNMP_ERR_WRONGTYPE 7 07
SNMP_ERR_WRONGLENGTH 8 08
SNMP_ERR_WRONGENCODING 9 09
SNMP_ERR_WRONGVALUE 10 0a
SNMP_ERR_NOCREATION 11 0b
SNMP_ERR_INCONSISTENTVALUE 12 0c
SNMP_ERR_RESOURCEUNAVAILABLE  13 0d
SNMP_ERR_COMMITFAILED 14 0e
SNMP_ERR_UNDOFAILED 15 0f
SNMP_ERR_AUTHORIZATIONERROR 16 10
SNMP_ERR_NOTWRITABLE 17 11
SNMP_ERR_INCONSISTENTNAME 18 12

See Also:
SnmpSession, SnmpGroup, SecurityModelTable, Serialized Form

Field Summary
static int ACCESSFORNOTIFY
          accessible-for-notify in Snmpv2.
static int ACTIVE
          The Active State of the Tables.
(package private)  SnmpTargetAddrExtTable addrExtTable
           
(package private)  SnmpTargetAddrTable addrTable
           
static int ANY_SEC_MODEL
          Constant values for "any" security model.
static byte BITSTRING
          Deprecated. This variable has been deprecated in SNMPv2 protocol.
(package private)  boolean commAuthFlag
          The communityAuthentication flag corresponding to this SnmpAPI.
static byte COUNTER
          SNMP Type Constants.
static byte COUNTER64
          SNMP Type Constants.
static int CREATE_AND_GO
          The createAndGo state of the Tables.
static int CREATE_AND_WAIT
          The createAndWait state of the Tables.
static int CRITICAL
          constant for critical debug messages.
(package private) static boolean DEBUG
          Defines whether debugging output should be generated.
static int debugLevel
          variable having debugLevel , by defaullt FATAL.
static int DESTROY
          The Destroy state of the Tables.
static java.lang.String ENCODING
          The Standard encoding string on which all encoding will be done.
static byte ENDOFMIBVIEWEXP
          SNMP v2 Null Object Exception Value.
static int FATAL
          constant for fatal debug messages.
static byte GAUGE
          SNMP Type Constants.
static byte GET_REQ_MSG
          Constant for SNMP get PDU type.
static byte GET_RSP_MSG
          Constant for SNMP response PDU type.
static byte GETBULK_REQ_MSG
          Constant for SNMP V2 Get Bulk PDU type.
static byte GETNEXT_REQ_MSG
          Constant for SNMP get next PDU type.
static byte INFORM_REQ_MSG
          Constant for SNMP V2 INFORM PDU type.
static byte INTEGER
          SNMP Type Constants.
static byte IPADDRESS
          SNMP Type Constants.
(package private) static int MAX_NAME_LEN
           
static byte NETWORKADDRESS
          SNMP Type Constants.
static int NOACCESS
          no access for anybody.
static int NON_CRITICAL
          constant for non-critical debug messages.
static int NONVOLATILE
          The Nonvolatile Storage type of the Tables.
static byte NOSUCHINSTANCEEXP
          SNMP v2 Null Object Exception Value.
static byte NOSUCHOBJECTEXP
          SNMP v2 Null Object Exception Value.
static int NOT_IN_SERVICE
          The notInService state of the Tables.
static int NOT_READY
          The notReady state of the Tables.
(package private)  boolean notifyFilter
          The NotificationFiltering flag corresponding to this SnmpAPI.
(package private)  SnmpNotifyModule notifyModule
           
static byte NSAP
          Deprecated. This variable has been deprecated in SNMPv2 protocol
static byte NULLOBJ
          SNMP Type Constants.
static byte OBJID
          SNMP Type Constants.
static byte OPAQUE
          SNMP Type Constants.
static int OTHER
          The Other Storage type of the Tables.
static int PERMANENT
          The Permanent Storage type of the Tables.
static int RCREATE
          read-create value in Snmpv2.
static int READONLY
          The Readonly Storage type of the Tables.
static byte REPORT_MSG
          Constant for SNMP V2 Report PDU type.
static int RONLY
          read access for everyone.
static int RWRITE
          add write access for community.
(package private)  SecurityProvider securityProvider
           
(package private)  java.util.Vector sessionList
          List of SNMP sessions managed under this SnmpAPI instance
static byte SET_REQ_MSG
          Constant for SNMP set request PDU type.
(package private) static int SID_MAX_LEN
          Set fields in session and pdu to the following to get a default or unconfigured value.
static byte SNMP_ERR_AUTHORIZATIONERROR
          SNMP error value.
static byte SNMP_ERR_BADVALUE
          SNMP error value.
static byte SNMP_ERR_COMMITFAILED
          SNMP error value.
static byte SNMP_ERR_GENERR
          SNMP error value.
static byte SNMP_ERR_INCONSISTENTNAME
          SNMP error value.
static byte SNMP_ERR_INCONSISTENTVALUE
          SNMP error value.
static byte SNMP_ERR_NOACCESS
          SNMP error value.
static byte SNMP_ERR_NOCREATION
          SNMP error value.
static byte SNMP_ERR_NOERROR
          SNMP error value.
static byte SNMP_ERR_NOSUCHNAME
          SNMP error value.
static byte SNMP_ERR_NOTWRITABLE
          SNMP error value.
static byte SNMP_ERR_READONLY
          SNMP error value.
static byte SNMP_ERR_RESOURCEUNAVAILABLE
          SNMP error value.
static byte SNMP_ERR_TOOBIG
          SNMP error value.
static byte SNMP_ERR_UNDOFAILED
          SNMP error value.
static byte SNMP_ERR_WRONGENCODING
          SNMP error value.
static byte SNMP_ERR_WRONGLENGTH
          SNMP error value.
static byte SNMP_ERR_WRONGTYPE
          SNMP error value.
static byte SNMP_ERR_WRONGVALUE
          SNMP error value.
 int SNMP_PORT
          The snmp port value of 161 for UDP.
 int SNMP_TRAP_PORT
          The trap port value of 162 for UDP.
static int SNMP_VERSION_1
          Constant for setting SNMP Version 1.
static int SNMP_VERSION_2
          Constant for setting SNMP Version 2 (Not supported).
static int SNMP_VERSION_2C
          Constant for setting SNMP Version 2c.
static int SNMP_VERSION_3
          Constant for the SNMP Version 3.
static java.lang.String Standard_Prefix
          Deprecated. instead use the setOIDPrefix(SnmpOID oid) and getOIDPrefix() methods.
static byte STRING
          SNMP Type Constants.
static byte TIMETICKS
          SNMP Type Constants.
static byte TRP_REQ_MSG
          Constant for SNMP trap PDU type.
static byte TRP2_REQ_MSG
          Constant for SNMP V2 Trap PDU type.
static byte UINTEGER32
          Deprecated. This variable has been deprecated in SNMP protocol.
static byte UNSIGNED32
          SNMP Type Constants.
(package private) static int USM_SECURITY_MODEL
           
(package private) static int V1_COMMUNITY_MODEL
           
(package private) static int V2_COMMUNITY_MODEL
           
static int VOLATILE
          The Volatile Storage type of the Tables.
static int WONLY
          only write access for community.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY, values
 
Constructor Summary
SnmpAPI()
          Creates a new SnmpAPI instance and initialises the authoritative snmpEngineID, snmpEngineBoots, snmpEngineTime and the providers, SecurityProvider and ACMProvider.
SnmpAPI(boolean debug)
          Creates a new SnmpAPI instance and initialises the authoritative snmpEngineID, snmpEngineBoots, snmpEngineTime and the providers, SecurityProvider and ACMProvider.
 
Method Summary
(package private)  void addElement(java.lang.Object key, SnmpGroup group)
          Adds the SnmpGroup to the table.
 java.util.Vector checkResponses()
          Checks each session to see if there is any outstanding response.
 java.util.Vector checkTimeouts()
          Checks each session to see if there is any outstanding Time-outs
 void close()
          Stops the API thread which monitors the session for time-outs and retries.
static boolean compare(int[] a, int[] b)
          An int array comparison routine.
(package private) static void debugLogging(java.lang.String methodName, java.lang.String className, java.lang.String debugStr)
           
static void debugPrintHigh(java.lang.Object str)
          debugPrint method for FATAL messages.
static void debugPrintLow(java.lang.Object str)
          debugPrint method for NON_CRITICAL messages.
static void debugPrintMedium(java.lang.Object str)
          debugPrint method for CRITICAL messages.
 boolean deSerialize()
          This deSerializes the SNMPV3 Security tables from the file specified by the setSerializeFileName method.
 boolean deSerializeEngineBoots()
          This deSerializes the engine boots into the file specified by the setSerializeFileName method.
 int genMsgID()
          This number is unique number that is generated for this JVM.
 int genReqID()
          This number is unique number that is generated for this JVM.
 ACMProvider getACMProvider()
          Gets the Access Control Provider maintained bu this SnmpAPI.
 java.lang.String getCharacterEncoding()
          Returns the Character encoding of the String values.
 java.lang.Object getCommunityTable()
          Deprecated. use the following instead
getSecurityProvider().getTable(1); // where 1 stands for v1 security model.
static java.sql.Connection getConnection()
          Returns the database connection instance corresponding to this SnmpAPI instance.
 boolean getDebug()
          Defines whether debugging output is being generated.
 java.lang.String GetEngineBootsSerializeFileName()
          Gets the fileName into which the SNMPv3 engineBoots are to be stored so that they are persistant.
(package private)  java.lang.Object getGroupKey(java.lang.String local_address, int port)
          Returns the key corresponding to the local_addrs and local_port.
static int getMajorVersion()
          Returns the major version of this release of SNMP Library.
static int getMinorVersion()
          Returns the minor version of this release of SNMP Library.
 SnmpNotifyFilterProfileTable getNotifyFilterProfileTable()
          Gets the SnmpNotifyFilterProfileTable that is associated with this SnmpAPI instance.
 SnmpNotifyFilterTable getNotifyFilterTable()
          Gets the SnmpNotifyFilterTable that is associated with this SnmpAPI instance.
 SnmpNotifyTable getNotifyTable()
          Gets the SnmpNotifyTable that is associated with this SnmpAPI instance.
static SnmpOID getOIDPrefix()
          This method returns the OID prefix that is set before.
static int getPatchVersion()
          Returns the patch version of this release of SNMP Library.
(package private) static java.lang.String getReleaseDate()
          Returns the release date of this version of SNMP Library, as a string in the form "yyyy/mm/dd".
static SASClient getSASClient()
          Returns the SASClient instance which has been created at last through the SnmpSession class.
 SecurityProvider getSecurityProvider()
          Gets the SecurityProvider maintained by this SnmpAPI.
 java.lang.String getSerializeFileName()
          Gets the fileName into which the SNMPv3 configuration tables are to be serialized.
 java.util.Vector getSessionList()
          Get the List of SNMP sessions managed under this SnmpAPI instance.
 SnmpEngineTable getSnmpEngine()
          Gets the SnmpEngineTable reference.
 int getSnmpEngineBoots()
          Gets the SnmpEngineBoots (number of times this SNMP engine has booted of this SNMP entity.
 byte[] getSnmpEngineID()
          Gets the authoritative SnmpEngineID associated with this SNMP entity.
 int getSnmpEngineTime()
          Gets the SnmpEngineTime.
 SnmpGroup getSnmpGroup(java.lang.String local_address, int port)
          Gets the SnmpGroup Object corresponding to the SnmpSession's local_addrs and local_port.
static java.sql.Statement getStatement()
          Returns the Statement instance corresponding to this SnmpAPI instance
 SnmpTargetAddrExtTable getTargetAddrExtTable()
          Gets the SnmpTargetAddrExtTable corresponding to this SnmpAPI.
 SnmpTargetAddrTable getTargetAddrTable()
          Gets the SnmpTargetAddrTable corresponding to this SnmpAPI.
 SnmpTargetParamsTable getTargetParamsTable()
          Gets the SnmpTargetParamsTable corresponding to this SnmpAPI.
 int getTimeWindow()
          Gets the time window in which messages are accepted by this SNMP engine.
 java.lang.Object getUSMTable()
          Deprecated. use the following instead.
 SnmpApi.getSecurityProvider().getTable(USM_SECURITY_MODEL); // where USM_SECURITY_MODEL = 3
 java.lang.String getV3ConfigTable()
          Gets the table name that was configured for V3.
static java.lang.String getVersionString()
          Returns a string describing this version of SNMP Library.
(package private) static java.lang.String i18n(java.lang.String str)
           
 void initACMProvider()
          This method initializes the Access Control Provider by reading from the file acmProvider.config .
 void initJdbcParams(java.lang.String driverName, java.lang.String urlString, java.lang.String userName, java.lang.String password)
          This method should be invoked to initialize the Jdbc Parameters in case of database support.
 void initSecurityProvider()
          This method initializes the SecurityProvider by reading from the file securityProvider.confg .
 boolean isCommunityAuthentication()
          Gets the Community Authentication flag for this SnmpAPI instance.
(package private) static boolean isDebugLog(int level)
           
 boolean isNotificationFiltering()
          Gets the notification filtering flag for this SnmpAPI instance.
(package private) static boolean isPerformanceLog(int level)
           
 boolean isV3DatabaseFlag()
          Gets the Database flag for this SnmpAPI instance.
(package private) static void logErrorMessage(java.lang.String error)
          This method will log the message in the LogManager through the static "logErrorMessage(String)" method present in the LogManager class.
(package private) static void logInfoMessage(java.lang.String info)
          This method will log the message in the LogManager through the static "logInfoMessage(String)" method present in the LogManager class.
(package private) static void logMessage(java.lang.String message)
          This method will log the message in the LogManager through the static "logMessage(String)" method present in the LogManager class.
(package private) static void logMessage(java.lang.String message, int id)
          This method will log the message in the LogManager through the static "logMessage(String, int)" method present in the LogManager class.
(package private) static void performanceLogging(java.lang.String methodName, java.lang.String className, long timeDiff)
           
(package private)  void removeElement(java.lang.String local_address, int port)
          Removes the SnmpGroup Object from the table
 void run()
          This method starts the API thread which monitors the sessions to look for the requests which have timed out and retransmits the pdu if required.
 boolean serialize()
          This serializes the SNMPV3 Security tables into the file specified by the setSerializeFileName method.
 boolean serializeEngineBoots()
          This serializes the engine boots into the file specified by the setSerializeFileName method.
 void setCharacterEncoding(java.lang.String encoding)
          Sets the Character encoding of the String values.
 void setCommunityAuthentication(boolean commAuthFlag)
          Enables/Disables the community authentication flag.
(package private)  void setDatabaseOperations()
          Used to set the databaseoperations instance when initJdbcParameters is not called.
 void setDebug(boolean debug)
          Defines whether debugging output should be generated.
static void setDebugLevel(int level)
          sets debugLevel FATAL or CRITICAL or NON_CRITICAL.
 void setEngineBootsSerializeFileName(java.lang.String name)
          Sets the fileName into which the SNMPv3 engineBoots are to be stored so that they are persistant.
 void setNotificationFiltering(boolean notifyFilterFlag)
          Enables/Disables the notification filtering.
static void setOIDPrefix(SnmpOID oid)
          This is added to any Object ID that does not begin with a '.'.
(package private) static void setSASClient(SASClient sas)
           
 void setSerializeFileName(java.lang.String name)
          Sets the fileName into which the SNMPv3 configuration tables are to be serialized.
 void setSnmpEngineBoots(int boots)
          Sets the SnmpEngineBoots (number of times this SNMP engine has booted of this SNMP entity.
 void setSnmpEngineID(byte[] id)
          Sets the authoritative SnmpEngineID for this SNMP entity.
 void setSnmpEngineTime(int time)
          Sets the SnmpEngineTime, the time in seconds after this SNMP engine has booted.
 void setTimeWindow(int win)
          Sets the time window in which messages should be accepted by this SNMP engine
static void setupStdOutErr()
          Deprecated. please use the logging framework instead.
static void setupStdOutErr(java.lang.String dirStr)
          Deprecated. please use the logging framework instead.
 void setV3ConfigTable(java.lang.String tableName)
          Sets the configured tableName specified in the case of V3Database.
 void setV3DatabaseFlag(boolean dBaseFlag)
          Sets the Database flag in the case of V3.
 void start()
           
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sessionList

java.util.Vector sessionList
List of SNMP sessions managed under this SnmpAPI instance

OTHER

public static final int OTHER
The Other Storage type of the Tables.

VOLATILE

public static final int VOLATILE
The Volatile Storage type of the Tables.

NONVOLATILE

public static final int NONVOLATILE
The Nonvolatile Storage type of the Tables.

PERMANENT

public static final int PERMANENT
The Permanent Storage type of the Tables.

READONLY

public static final int READONLY
The Readonly Storage type of the Tables.

commAuthFlag

boolean commAuthFlag
The communityAuthentication flag corresponding to this SnmpAPI.

notifyFilter

boolean notifyFilter
The NotificationFiltering flag corresponding to this SnmpAPI.

notifyModule

SnmpNotifyModule notifyModule

V1_COMMUNITY_MODEL

static final int V1_COMMUNITY_MODEL

V2_COMMUNITY_MODEL

static final int V2_COMMUNITY_MODEL

addrTable

SnmpTargetAddrTable addrTable

addrExtTable

SnmpTargetAddrExtTable addrExtTable

DEBUG

static boolean DEBUG
Defines whether debugging output should be generated. In the debug mode, the PDU data is printed in hex format.
See Also:
SnmpClient.debugPrint(java.lang.String)

ENCODING

public static java.lang.String ENCODING
The Standard encoding string on which all encoding will be done.

SNMP_PORT

public int SNMP_PORT
The snmp port value of 161 for UDP.

SNMP_TRAP_PORT

public int SNMP_TRAP_PORT
The trap port value of 162 for UDP.

SNMP_VERSION_1

public static final int SNMP_VERSION_1
Constant for setting SNMP Version 1.

SNMP_VERSION_2C

public static final int SNMP_VERSION_2C
Constant for setting SNMP Version 2c.

SNMP_VERSION_2

public static final int SNMP_VERSION_2
Constant for setting SNMP Version 2 (Not supported).

SNMP_VERSION_3

public static final int SNMP_VERSION_3
Constant for the SNMP Version 3.

GET_REQ_MSG

public static final byte GET_REQ_MSG
Constant for SNMP get PDU type.

GETNEXT_REQ_MSG

public static final byte GETNEXT_REQ_MSG
Constant for SNMP get next PDU type.

GET_RSP_MSG

public static final byte GET_RSP_MSG
Constant for SNMP response PDU type.

SET_REQ_MSG

public static final byte SET_REQ_MSG
Constant for SNMP set request PDU type.

TRP_REQ_MSG

public static final byte TRP_REQ_MSG
Constant for SNMP trap PDU type.

GETBULK_REQ_MSG

public static final byte GETBULK_REQ_MSG
Constant for SNMP V2 Get Bulk PDU type.

INFORM_REQ_MSG

public static final byte INFORM_REQ_MSG
Constant for SNMP V2 INFORM PDU type.

TRP2_REQ_MSG

public static final byte TRP2_REQ_MSG
Constant for SNMP V2 Trap PDU type.

REPORT_MSG

public static final byte REPORT_MSG
Constant for SNMP V2 Report PDU type.

SNMP_ERR_NOERROR

public static final byte SNMP_ERR_NOERROR
SNMP error value.

SNMP_ERR_TOOBIG

public static final byte SNMP_ERR_TOOBIG
SNMP error value.

SNMP_ERR_NOSUCHNAME

public static final byte SNMP_ERR_NOSUCHNAME
SNMP error value.

SNMP_ERR_BADVALUE

public static final byte SNMP_ERR_BADVALUE
SNMP error value.

SNMP_ERR_READONLY

public static final byte SNMP_ERR_READONLY
SNMP error value.

SNMP_ERR_GENERR

public static final byte SNMP_ERR_GENERR
SNMP error value.

SNMP_ERR_NOACCESS

public static final byte SNMP_ERR_NOACCESS
SNMP error value.

SNMP_ERR_WRONGTYPE

public static final byte SNMP_ERR_WRONGTYPE
SNMP error value.

SNMP_ERR_WRONGLENGTH

public static final byte SNMP_ERR_WRONGLENGTH
SNMP error value.

SNMP_ERR_WRONGENCODING

public static final byte SNMP_ERR_WRONGENCODING
SNMP error value.

SNMP_ERR_WRONGVALUE

public static final byte SNMP_ERR_WRONGVALUE
SNMP error value.

SNMP_ERR_NOCREATION

public static final byte SNMP_ERR_NOCREATION
SNMP error value.

SNMP_ERR_INCONSISTENTVALUE

public static final byte SNMP_ERR_INCONSISTENTVALUE
SNMP error value.

SNMP_ERR_RESOURCEUNAVAILABLE

public static final byte SNMP_ERR_RESOURCEUNAVAILABLE
SNMP error value.

SNMP_ERR_COMMITFAILED

public static final byte SNMP_ERR_COMMITFAILED
SNMP error value.

SNMP_ERR_UNDOFAILED

public static final byte SNMP_ERR_UNDOFAILED
SNMP error value.

SNMP_ERR_AUTHORIZATIONERROR

public static final byte SNMP_ERR_AUTHORIZATIONERROR
SNMP error value.

SNMP_ERR_NOTWRITABLE

public static final byte SNMP_ERR_NOTWRITABLE
SNMP error value.

SNMP_ERR_INCONSISTENTNAME

public static final byte SNMP_ERR_INCONSISTENTNAME
SNMP error value.

INTEGER

public static final byte INTEGER
SNMP Type Constants.

STRING

public static final byte STRING
SNMP Type Constants.

BITSTRING

public static final byte BITSTRING
Deprecated. This variable has been deprecated in SNMPv2 protocol.

SNMP Type Constants.

OBJID

public static final byte OBJID
SNMP Type Constants.

NULLOBJ

public static final byte NULLOBJ
SNMP Type Constants.

IPADDRESS

public static final byte IPADDRESS
SNMP Type Constants.

NETWORKADDRESS

public static final byte NETWORKADDRESS
SNMP Type Constants.

COUNTER

public static final byte COUNTER
SNMP Type Constants.

GAUGE

public static final byte GAUGE
SNMP Type Constants.

UNSIGNED32

public static final byte UNSIGNED32
SNMP Type Constants.

TIMETICKS

public static final byte TIMETICKS
SNMP Type Constants.

OPAQUE

public static final byte OPAQUE
SNMP Type Constants.

UINTEGER32

public static final byte UINTEGER32
Deprecated. This variable has been deprecated in SNMP protocol.

SNMP Type Constants.

NSAP

public static final byte NSAP
Deprecated. This variable has been deprecated in SNMPv2 protocol

SNMP Type Constants.

COUNTER64

public static final byte COUNTER64
SNMP Type Constants.

NOSUCHOBJECTEXP

public static final byte NOSUCHOBJECTEXP
SNMP v2 Null Object Exception Value.

NOSUCHINSTANCEEXP

public static final byte NOSUCHINSTANCEEXP
SNMP v2 Null Object Exception Value.

ENDOFMIBVIEWEXP

public static final byte ENDOFMIBVIEWEXP
SNMP v2 Null Object Exception Value.

SID_MAX_LEN

static int SID_MAX_LEN
Set fields in session and pdu to the following to get a default or unconfigured value.

MAX_NAME_LEN

static int MAX_NAME_LEN

RONLY

public static final int RONLY
read access for everyone.

WONLY

public static final int WONLY
only write access for community.

RWRITE

public static final int RWRITE
add write access for community.

NOACCESS

public static final int NOACCESS
no access for anybody.

RCREATE

public static final int RCREATE
read-create value in Snmpv2.

ACCESSFORNOTIFY

public static final int ACCESSFORNOTIFY
accessible-for-notify in Snmpv2.

Standard_Prefix

public static java.lang.String Standard_Prefix
Deprecated. instead use the setOIDPrefix(SnmpOID oid) and getOIDPrefix() methods.

This is added to any Object ID string, that does not begin with a '.'. Since it is static, the change made in this variable will be reflected in all SnmpAPI instances used by the client application. Used primarily when creating an SnmpOID instance.
See Also:
SnmpOID

USM_SECURITY_MODEL

static final int USM_SECURITY_MODEL

securityProvider

SecurityProvider securityProvider

ACTIVE

public static final int ACTIVE
The Active State of the Tables.

NOT_IN_SERVICE

public static final int NOT_IN_SERVICE
The notInService state of the Tables.

NOT_READY

public static final int NOT_READY
The notReady state of the Tables.

CREATE_AND_GO

public static final int CREATE_AND_GO
The createAndGo state of the Tables.

CREATE_AND_WAIT

public static final int CREATE_AND_WAIT
The createAndWait state of the Tables.

DESTROY

public static final int DESTROY
The Destroy state of the Tables.

ANY_SEC_MODEL

public static final int ANY_SEC_MODEL
Constant values for "any" security model.

FATAL

public static final int FATAL
constant for fatal debug messages.

CRITICAL

public static final int CRITICAL
constant for critical debug messages.

NON_CRITICAL

public static final int NON_CRITICAL
constant for non-critical debug messages.

debugLevel

public static int debugLevel
variable having debugLevel , by defaullt FATAL.
Constructor Detail

SnmpAPI

public SnmpAPI()
Creates a new SnmpAPI instance and initialises the authoritative snmpEngineID, snmpEngineBoots, snmpEngineTime and the providers, SecurityProvider and ACMProvider. The SnmpEngineID is initialised to a randorm value of 12 octets and the snmpEngineBoots and snmpEngineTime are initialised to value 0. The attributes snmpEngineID, snmpEngineBoots and snmpEngineTime are useful only for an agent side implementation. These default values can be overriden by the respective set methods of these attributes. These three attributes are not relevant for a manager side implementation.

The constructor also instantiates the different SnmpV3 configuration tables i.e USMUserTable, SnmpEngineTable, VacmContextTable, VacmGroupTable, VacmGroupAccessTable and VacmViewTreeTable. These tables are used to store the different users, SNMPv3 entity and the vacm information. The API user need not instantiate these configuration tables and instead, has to use the methods provided in this class to access these tables.

See Also:
SnmpEngineTable

SnmpAPI

public SnmpAPI(boolean debug)
Creates a new SnmpAPI instance and initialises the authoritative snmpEngineID, snmpEngineBoots, snmpEngineTime and the providers, SecurityProvider and ACMProvider. The debug flag will be set to the value passed as parameter. The SnmpEngineID is initialised to a randorm value of 12 octets and the snmpEngineBoots and snmpEngineTime are initialised to value 0. The attributes snmpEngineID, snmpEngineBoots and snmpEngineTime are useful only for an agent side implementation. These default values can be overriden by the respective set methods of these attributes. These three attributes are not relevant for a manager side implementation.

The constructor also instantiates the different SnmpV3 configuration tables i.e USMUserTable, SnmpEngineTable, VacmContextTable, VacmGroupTable, VacmGroupAccessTable and VacmViewTreeTable. These tables are used to store the different users, SNMPv3 entity and the vacm information. The API user need not instantiate these configuration tables and instead, has to use the methods provided in this class to access these tables.

Parameters:
debug - The debug flag to be set for this SnmpAPI instance.
See Also:
SnmpEngineTable
Method Detail

start

public void start()
Overrides:
start in class java.lang.Thread

getTargetAddrTable

public SnmpTargetAddrTable getTargetAddrTable()
Gets the SnmpTargetAddrTable corresponding to this SnmpAPI.

setCommunityAuthentication

public void setCommunityAuthentication(boolean commAuthFlag)
Enables/Disables the community authentication flag.
Parameters:
commAuthFlag - The community Authentication flag to be set.

setNotificationFiltering

public void setNotificationFiltering(boolean notifyFilterFlag)
Enables/Disables the notification filtering.
Parameters:
notifyFilterFlag - The notification filter flag to be set.

isCommunityAuthentication

public boolean isCommunityAuthentication()
Gets the Community Authentication flag for this SnmpAPI instance.

isNotificationFiltering

public boolean isNotificationFiltering()
Gets the notification filtering flag for this SnmpAPI instance.

getNotifyTable

public SnmpNotifyTable getNotifyTable()
Gets the SnmpNotifyTable that is associated with this SnmpAPI instance.
Returns:
SnmpNotifyTable associated with this SnmpAPI instance.

getNotifyFilterTable

public SnmpNotifyFilterTable getNotifyFilterTable()
Gets the SnmpNotifyFilterTable that is associated with this SnmpAPI instance.
Returns:
SnmpNotifyFilterTable associated with this SnmpAPI instance.

getNotifyFilterProfileTable

public SnmpNotifyFilterProfileTable getNotifyFilterProfileTable()
Gets the SnmpNotifyFilterProfileTable that is associated with this SnmpAPI instance.
Returns:
SnmpNotifyFilterProfileTable associated with this SnmpAPI instance.

getTargetParamsTable

public SnmpTargetParamsTable getTargetParamsTable()
Gets the SnmpTargetParamsTable corresponding to this SnmpAPI.
Returns:
SnmpTargetParamsTable associated with this SnmpAPI instance.

getCommunityTable

public java.lang.Object getCommunityTable()
Deprecated. use the following instead
getSecurityProvider().getTable(1); // where 1 stands for v1 security model.

Gets the SnmpCommuityTable corresponding to this SnmpAPI.
Returns:
returns the community table as an object of SnmpCommunityTable.

getTargetAddrExtTable

public SnmpTargetAddrExtTable getTargetAddrExtTable()
Gets the SnmpTargetAddrExtTable corresponding to this SnmpAPI.
Returns:
returns the instance of SnmpTargetAddrExtTable maintained by this SnmpAPI object.

getSessionList

public java.util.Vector getSessionList()
Get the List of SNMP sessions managed under this SnmpAPI instance.

setDebug

public void setDebug(boolean debug)
Defines whether debugging output should be generated. In the debug mode, the PDU data is printed in hex format.
See Also:
SnmpClient.debugPrint(java.lang.String)

getDebug

public boolean getDebug()
Defines whether debugging output is being generated. In the debug mode, the PDU data is printed in hex format.
See Also:
SnmpClient.debugPrint(java.lang.String)

getStatement

public static java.sql.Statement getStatement()
Returns the Statement instance corresponding to this SnmpAPI instance
Returns:
the Statement corresponding to this SnmpAPI instance.

getConnection

public static java.sql.Connection getConnection()
Returns the database connection instance corresponding to this SnmpAPI instance.
Returns:
the Connection instance corresponding to this SnmpAPI instance.

getSASClient

public static SASClient getSASClient()
Returns the SASClient instance which has been created at last through the SnmpSession class. Opening an instance of SnmpSession passing applet as an argument will create an instance of SASClient and this SASClient instance will be stored in the SnmpAPI (the API instance which is passed to the constructor of SnmpSession).
Returns:
returns the SASClient maintained by this object.

setSASClient

static void setSASClient(SASClient sas)

initJdbcParams

public void initJdbcParams(java.lang.String driverName,
                           java.lang.String urlString,
                           java.lang.String userName,
                           java.lang.String password)
                    throws java.sql.SQLException,
                           java.lang.ClassNotFoundException
This method should be invoked to initialize the Jdbc Parameters in case of database support. If this method is invoked the DataBase flag will be set.
Parameters:
driverName - Name of the DataBase driver.
URL - URL pointing to the DataBase file name
userName - userName
passWord - password
Throws:
java.sql.SQLException - if the database connection could not be established
java.lang.ClassNotFoundException - if the driver class is not present in the classpath

setV3ConfigTable

public void setV3ConfigTable(java.lang.String tableName)
Sets the configured tableName specified in the case of V3Database.
Parameters:
tableName - the name of the table that should be configured.

getV3ConfigTable

public java.lang.String getV3ConfigTable()
Gets the table name that was configured for V3.
Returns:
returns the SNMPv3 config table that was set previously.

setV3DatabaseFlag

public void setV3DatabaseFlag(boolean dBaseFlag)
Sets the Database flag in the case of V3.
Parameters:
dBaseFlag - the flag to be set.

isV3DatabaseFlag

public boolean isV3DatabaseFlag()
Gets the Database flag for this SnmpAPI instance.

run

public void run()
This method starts the API thread which monitors the sessions to look for the requests which have timed out and retransmits the pdu if required. This thread can be stopped by the close method provided in this class. The outstanding requests are monitored for time-outs. If the request has timedout, then the pdu is retransmitted. If there are no more retries, then pdu is removed from the request list and prints the time out message if the debug is true.
Overrides:
run in class java.lang.Thread

close

public void close()
Stops the API thread which monitors the session for time-outs and retries. Thread.stop() is deprecated in JDK 1.2 .

genReqID

public int genReqID()
This number is unique number that is generated for this JVM. This integer is a constantly increasing number. This number starts from zero. The range of numbers that it produces are -2147483648 through 2147483647 except zero. Once this count reaches the maximun positive, it switches over to the negative side.
Returns:
returns the unique number which can be used for setting the request id.

genMsgID

public int genMsgID()
This number is unique number that is generated for this JVM. This integer is a constantly increasing number. This number starts from zero. The range of numbers that it produces are -2147483648 through 2147483647 except zero. Once this count reaches the maximun positive, it switches over to the negative side.
Returns:
returns the unique number which can be used for setting the message id.

checkResponses

public java.util.Vector checkResponses()
Checks each session to see if there is any outstanding response.
Returns:
list of sessions with outstanding responses.
See Also:
SnmpSession

checkTimeouts

public java.util.Vector checkTimeouts()
Checks each session to see if there is any outstanding Time-outs
Returns:
returns a vector of SnmpSession objects with requests that have timed out.
See Also:
SnmpSession

setCharacterEncoding

public void setCharacterEncoding(java.lang.String encoding)
Sets the Character encoding of the String values. The default will be ISO8859_1 which is the standard. All the string encoding will be done based on this encoding string.
Parameters:
encoding - the string based on which the string encoding is to be done.
See Also:
getCharacterEncoding()

getCharacterEncoding

public java.lang.String getCharacterEncoding()