com.adventnet.snmp.beans
Class SnmpTarget

java.lang.Object
  |
  +--com.adventnet.snmp.beans.SnmpServer
        |
        +--com.adventnet.snmp.beans.SnmpTarget
All Implemented Interfaces:
CustomizerTemplate, java.util.EventListener, java.io.Serializable, java.beans.VetoableChangeListener
Direct Known Subclasses:
SnmpPoller, SnmpTable

public class SnmpTarget
extends SnmpServer
implements java.beans.VetoableChangeListener, CustomizerTemplate

This class is a lightweight SNMP session for use with other beans in applications and applets. It sends synchronous SNMP requests. It contains an array of OIDs specifying variables used in SNMP operations, and list of values for set and trap operations. MIB support and other SNMP functions are built into this class. The SnmpTarget bean is used for many of the common operations that we do with a SNMP agent such as get, getnext, set and trap operations. MIB support and other SNMP functions are built into this class. This bean can be used to make a single variable request, multiple variable requests, walking a table and a number of operations, including loading MIBs to support SNMP operations, getting all instances of a variable type, etc

To use in an application, simply instantiate, specify the object IDs, and perform operations. For example,

    SnmpTarget target = new SnmpTarget();
    target.setTargetHost("localhost");  // set host, or other parameters
    target.setObjectID(".1.3.6.1.2.1.1.1.0"); // or 1.1.0 with standard prefix
    String result = target.snmpGet();
    
if (result == null) System.err.println("Failed: "+target.getErrorString()); else System.out.println("Response: "+result);
To use in an applet use an alternate constructor, but the procedure is the same. For example,
    SnmpTarget target = new SnmpTarget(appletInstance);
    target.setTargetHost("localhost");  // set host, or other parameters
    target.setObjectID(".1.3.6.1.2.1.1.1.0");  // or 1.1.0 with standard prefix
    String result = target.snmpGet();
    
if (result == null) System.err.println("Failed: "+target.getErrorString()); else System.out.println("Response: "+result);
This class supports multiple variable requests, and a number of operations, including loading MIBs to support SNMP operations, getting all instances of a variable type, etc..

For multiple variable requests, set the OID list using the setObjectIDList(String[]) or setSnmpOIDList(SnmpOID[]) methods. Your SNMP operations with this SnmpTarget will use this list.

We can also register for events from the SnmpTarget component, so that we can notify another object whenever a response is received for any request. This may be useful for example in applying the result of a query to multiple objects. However, in most cases, the synchronous use of this component will not use events and event registration. The listeners that are registered for receiving responses from the agent should register, using setSendTimeoutEvents(true) to get the timeout events, which otherwise, will not be passed to the listener. This class can be used directly, and it will also be used by beans, e.g. SnmpPoller bean, which provides SNMP services. For garbage collection of the resources used, releaseResources() method should be invoked. Different SnmpTarget instances on the same JVM, will reuse the SnmpAPI, SnmpSession and MibOperations instance. So, for releasing these resources, releaseResources() method should be called on every SnmpTarget instance created and when this method is called on the final instance of SnmpTarget, these will be garbage collected.

See Also:
Serialized Form

Field Summary
 boolean serialize
          based on this flag v3 table like USMUserTable and SnmpEngineTable will be serialized
static byte SNMPGET
          Constant for SNMP get request.
static byte SNMPGETBULK
          Constant for SNMP V2 Get Bulk request.
static byte SNMPGETNEXT
          Constant for SNMP get next request.
static byte SNMPINFORM
          Constant for SNMP V2 INFORM request.
static byte SNMPREPORT
          Constant for SNMP V2 Report request.
static byte SNMPRESPONSE
          Constant for SNMP response request
static byte SNMPSET
          Constant for SNMP set request.
static byte SNMPTRAP
          Constant for SNMP trap request.
static byte SNMPV2TRAP
          Constant for SNMP V2 Trap request.
static int VERSION1
          Constant for SNMP Version 1.
static int VERSION2C
          Constant for SNMP Version 2C.
static int VERSION3
          Constant for SNMP Version 3.
 
Fields inherited from class com.adventnet.snmp.beans.SnmpServer
AUTH_NO_PRIV, AUTH_PRIV, MD5_AUTH, NO_AUTH, NO_AUTH_NO_PRIV, oidList, SHA_AUTH
 
Constructor Summary
SnmpTarget()
          This constructor is used in applications.
SnmpTarget(java.applet.Applet applet)
          Use this constructor for applets.
SnmpTarget(java.applet.Applet applet, int port, java.lang.String session)
          Use this constructor for creating a new session for this applet.
SnmpTarget(int protocol, ProtocolOptions options)
          This constructor is used for applications which use protocol other than UDP/IP.
SnmpTarget(int port, java.lang.String session)
          This constructor is used for creating a new session for this application.
SnmpTarget(java.lang.String[] localAddrs, java.lang.String sessionName)
          Use this constructor for applications in which the session needs to be bound to some local address.
 
Method Summary
 void addLogClient(LoggerProperties loggerProps)
          Adds the Log client for which the target has to redirect the log messages.
 void addLogClient(LogInterface client)
          Add the Log client for which the target has to redirect the log messages
 int addObjectID(java.lang.String s)
          This method adds an SnmpOID specified by string to the SnmpOID list.
 void addResultListener(ResultListener l)
          Adds a listener for events from this target.
 int addSnmpOID(SnmpOID oid)
          This method adds an SnmpOID to the previously set list of SnmpOID
 void addSnmpPropertyListener(SnmpPropertyListener l)
          Adds SnmpPropertyListener to the SnmpPropertyListener list.
 void addV3HandShakeResultListener(V3HandShakeResultListener l)
          Adds a listener to receive the events when SnmpEngineID discovery and time Synchronization is performed by the method async_create_v3_tables.
protected  void genEvent(SnmpPDU pdu)
          Generates the events to the listeners
protected  void genTimeoutEvent(SnmpPDU pdu)
          Generates the events to the listeners
 boolean getAttemptComplete()
          Returns if the splitting pdu is enabled to get the complete data by splitting the varbinds into multiple request.
 boolean getAttemptPartial()
          Returns the boolean state of whether this target will try to get partial data from an agent if the request is a multiple variable request.
 java.lang.String getAuthPassword()
          Gets the SNMP V3 AuthPassword
 int getAuthProtocol()
          Gets the SNMP V3 AuthProtocol
 java.lang.String getCommunity()
          Gets the SNMP target Community
 SnmpResultObject getCompleteResponse()
          Gets the complete data from the agent by splitting the varbinds into multiple requests.This can set if request pdu is very big.
 java.lang.String getContextID()
          Gets the SNMP V3 contextID.
 java.lang.String getContextName()
          get the SNMP V3 Context name
 boolean getDebug()
          This method returns true if debug mode is enabled and false otherwise
 int getErrorCode()
          Gets the error code for the last request.
 int getErrorIndex()
          To get the error index corresponding to the errored oid in the pdu.
 java.lang.String getErrorString()
          Gets the error string for the request sent.
 int getExceptionCode()
          Gets the exception code for the last request.
 boolean getIgnoreSpecificControlCodes()
          Gets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values.
 int getMaxNumRows()
          Gets the maximum number of rows that can be processed, default value is 1000.
 int getMaxRepetitions()
          Gets the SNMP target max repetitions value for a getbulk request.
 java.lang.String getMibModules()
          This method returns all the MIBs that are loaded in this applet/application.
 MibOperations getMibOperations()
          get the MibOperations object reference.
 int getNonRepeaters()
          Gets the SNMP target non-repeaters value for a getbulk request Default is 0.
 java.lang.String getObjectID()
          This method returns the first object ID as a string
 java.lang.String getObjectID(int index)
          This method returns the object ID at index as a string
 java.lang.String[] getObjectIDList()
          This method returns the list of object IDs as a string array or null, if no OIDs is set previously.
 java.lang.String getPrincipal()
          Gets the SNMP V3 Principal
 java.lang.String getPrivPassword()
          Gets the SNMP V3 PrivPassword
 int getRetries()
          Gets the SNMP target retries value.
 java.lang.String getSecurityLevel()
          Gets the SNMP V3 SecurityLevel
 int getSecurityModel()
          Gets the SNMP V3 securityModel
 boolean getSendTimeoutEvents()
          Returns the boolean state of whether this target will send timeout events to a registered listener.
 SnmpOID getSnmpOID()
          This method returns the first SnmpOID from the list of object IDs or null, if no OID is set previously.
 SnmpOID[] getSnmpOIDList()
          This method returns the list of object IDs as an array of SnmpOID or null if no OID is set previously.
 int getSnmpVersion()
          Gets the SNMP target SNMP Version.
 java.lang.String getTargetHost()
          Gets the SNMP target hostname
 int getTargetPort()
          get the SNMP target port number
 int getTimeout()
          Gets the SNMP target timeout value
 int getVarBindCount()
          Returns the number of varbinds used with the splitted pdu.
 java.lang.String getWriteCommunity()
          Gets the SNMP target write Community to be used for set requests
static boolean isInSubTree(SnmpOID rootoid, SnmpOID objid)
          Check if objid has rootoid as an ancestor.
 boolean isSerialize()
          Returns the status of Serialization of v3 tables ( USMUserTable and SnmpEngineTable )
 void loadMibs(java.lang.String mibs)
          Load the mibs specified by white-space separated list of mibs.
 void releaseResources()
          Though the resources will be cleaned up by the garbage collector, if the application is no more using the SnmpTarget bean instance, this method can be used to immediately release the resources.
 void removeLogClient()
          Removes the Log client for which the target has been registered to redirect the log Messages.
 void removeResultListener(ResultListener l)
          Removes a listener for events from this target.
 void removeSnmpPropertyListener(SnmpPropertyListener l)
          Removes the SnmpPropertyListener from the list maintained by this target.
 void removeV3HandShakeListener(V3HandShakeResultListener l)
          Removes the listener registered for getting events.
 void setAttemptComplete(boolean flag)
          Enables the flag to get the complete data from the agent by splitting the varbinds into multiple request.This can set if request pdu is very big.
 void setAttemptPartial(boolean b)
          Sets the boolean state of whether this target will try to get a partial data from an agent if the request is a multi variable request.
 void setAuthPassword(java.lang.String password)
          Sets the SNMP V3 AuthPassword
 void setAuthProtocol(int protocol)
          Sets the SNMP V3 AuthProtocol
 void setCommunity(java.lang.String s)
          Sets the SNMP target Community
 void setContextID(java.lang.String ctxtID)
          Sets the SNMP V3 contextID.
 void setContextName(java.lang.String cName)
          set the SNMP V3 Context name
 void setDebug(boolean debug)
          This method determines if debug output will be printed
 void setIgnoreSpecificControlCodes(boolean specConCode)
          Sets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values.
 void setMaxNumRows(int maxRows)
          Sets the maximum number of rows that can be processed, default value is 1000.
 void setMaxRepetitions(int i)
          Sets the SNMP target max repetitions value for a getbulk request.
 void setMibModules(java.lang.String mibs)
          This method sets the MIB to be loaded in this applet/application.
 void setNonRepeaters(int i)
          Sets the SNMP target non-repeaters value for a getbulk request Default is 0.
 void setObjectID(int index, java.lang.String s)
          This method sets the object ID value at index based on specified string
 void setObjectID(java.lang.String s)
          This method sets the object ID specified by the String value.
 void setObjectIDList(java.lang.String[] s)
          This method sets the list of object IDs based on the specified string array.
 void setParams(java.lang.String host, java.lang.String port, java.lang.String community, java.lang.String mib, java.lang.String oid)
          To set Multiple parameters like TargetHost,Port,Community,MibModule and OID.
 void setParams(java.lang.String host, java.lang.String port, java.lang.String community, java.lang.String mib, java.lang.String[] oidlist)
          To set Multiple parameters like TargetHost,Port,Community,MibModule and OIDList.
 void setPrincipal(java.lang.String s)
          Sets the SNMP V3 Principal
 void setPrivPassword(java.lang.String password)
          Sets the SNMP V3 PrivPassword
 void setRetries(int i)
          Sets the SNMP target retries value.
 void setSecurityLevel(byte sLevel)
          Sets the SNMP V3 SecurityLevel.The value will be 0 ,1 or 3.
 void setSecurityModel(int securityModel)
          Sets the SNMP V3 SecurityModel
 void setSendTimeoutEvents(boolean b)
          This should be set to true if the listener should be notified of the timeout events in case if the request timesout.
 void setSnmpOID(SnmpOID oid)
          This method sets the SnmpOID
 void setSnmpOIDList(SnmpOID[] list)
          This method sets the list of object IDs as the given array of SnmpOID
 void setSnmpVersion(int i)
          Sets the SNMP target SNMP Version.
 void setTargetHost(java.lang.String s)
          This method sets the SNMP target hostname
 void setTargetPort(int i)
          set the SNMP target port number
 void setTimeout(int i)
          Sets the SNMP target timeout value
 void setVarBindCount(int count)
          Set the number of varbinds per request to get the complete data from the agent by splitting the varbinds into multiple request in case if the request pdu is very big.
 void setWriteCommunity(java.lang.String s)
          Sets the SNMP target write Community to be used for set requests
 java.lang.String snmpGet()
          Queries the target and returns as a string the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVar snmpGet(SnmpOID oid)
          Gets the SNMP variable identified by specified Object Identifier.
 java.lang.String[][] snmpGetAllList()
          Gets all instances of variables in the OID list.
 SnmpVarBind[][] snmpGetAllVariableBindings()
          Gets all instances of variables in the OID list.
 SnmpVar[][] snmpGetAllVariables()
          Gets all instances of variables in the OID list.
 java.lang.String[][] snmpGetBulkList()
          Get bulk on list of variables in the OID list.
 SnmpVarBind[][] snmpGetBulkVariableBindings()
          Get bulk on list of variables in the OID list.
 SnmpVar[][] snmpGetBulkVariables()
          Get bulk on list of variables in the OID list.
 java.lang.String[] snmpGetList()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar[] snmpGetList(SnmpOID[] oids)
          Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance.
 java.lang.String snmpGetNext()
          Queries the target and returns as a string the next SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVar snmpGetNext(SnmpOID oid)
          Gets the SNMP variable identified by specified Object Identifier.
 java.lang.String[] snmpGetNextList()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar[] snmpGetNextList(SnmpOID[] oids)
          Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance.
 SnmpVar snmpGetNextVariable()
          Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVarBind snmpGetNextVariableBinding()
          Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVarBind[] snmpGetNextVariableBindings()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar[] snmpGetNextVariables()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar snmpGetVariable()
          Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVarBind snmpGetVariableBinding()
          Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVarBind[] snmpGetVariableBindings()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar[] snmpGetVariables()
          Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance.
 void snmpSendInformAcknowledgement(long uptime, SnmpOID oid, SnmpVar[] values, int reqID)
           
 SnmpVarBind[] snmpSendInformRequest(long uptime, SnmpOID trapOid, SnmpVar[] values)
          This method is used to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 java.lang.String[] snmpSendInformRequest(long uptime, java.lang.String trapOid, java.lang.String[] values)
          This method is to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 void snmpSendNotification(long uptime, SnmpOID trapOid, SnmpVar[] values)
          This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 void snmpSendNotification(long uptime, java.lang.String trapOid, java.lang.String[] values)
          This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 void snmpSendTrap(SnmpOID enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, SnmpVar[] values)
          This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 void snmpSendTrap(java.lang.String enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, java.lang.String[] values)
          This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified.
 java.lang.String snmpSet(java.lang.String value)
          This method is used to do an SNMP set to the target using value specified of the first variable on the variable list.
 java.lang.String snmpSet(java.lang.String value, byte type)
          This method is used to do an SNMP set to the target of the first variable on the variable list using value specified.
 java.lang.String[] snmpSetList(java.lang.String[] values)
          This method sets the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpTarget instance.
 SnmpVar snmpSetVariable(SnmpVar var)
          This method is used to do an SNMP set with specified value to the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance.
 SnmpVar[] snmpSetVariables(SnmpVar[] values)
          This method is used to do an SNMP set, with values specified, the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpTarget instance.
 void vetoableChange(java.beans.PropertyChangeEvent e)
          This method is called when a vetoableChange event is fired from the propertySetting bean.
 
Methods inherited from class com.adventnet.snmp.beans.SnmpServer
async_create_v3_tables, create_v3_tables, finalize, genEvent, getCharacterEncoding, getHostAddress, getLocalAddresses, getMibPath, getOverwriteCMI, getSecLevelForTimeSync, getSecurityProvider, getSecurityTable, getSerializedMibFileName, getSnmpEngineID, getSnmpEngineTable, getTimeoutInMilliSec, getTimeToWait, getUSMTable, getV3ConfigTable, initJdbcParams, initSecurityProvider, isLoadFromCompiledMibs, isLoadFromSerializedMibs, isLoadMibsFromDatabase, isOverwriteCMI, isOverwriteMibsInDatabase, isReadDesc, isSendPDUByGroup, isSerializeMibs, isSetAutoInformResponse, isSupportedSecurityModel, isV3DatabaseFlag, manage_v3_tables, managing_v3_tables, setAutoInformResponse, setCharacterEncoding, setLoadFromCompiledMibs, setLoadFromSerializedMibs, setLoadMibsFromDatabase, setMibOperations, setMibPath, setOverwriteCMI, setOverwriteMibsInDatabase, setReadDesc, setReceiveBufferSize, setSecLevelForTimeSync, setSendPDUByGroup, setSerializedMibFileName, setSerializeMibs, setSnmpEngineID, setTimeoutInMilliSec, setTimeToWait, setV3ConfigTable, setV3DatabaseFlag
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.adventnet.snmp.beans.CustomizerTemplate
create_v3_tables, getSnmpEngineTable, getUSMTable, initSecurityProvider, isSupportedSecurityModel, manage_v3_tables
 

Field Detail

SNMPGET

public static final byte SNMPGET
Constant for SNMP get request.

SNMPGETNEXT

public static final byte SNMPGETNEXT
Constant for SNMP get next request.

SNMPRESPONSE

public static final byte SNMPRESPONSE
Constant for SNMP response request

SNMPSET

public static final byte SNMPSET
Constant for SNMP set request.

SNMPTRAP

public static final byte SNMPTRAP
Constant for SNMP trap request.

SNMPGETBULK

public static final byte SNMPGETBULK
Constant for SNMP V2 Get Bulk request.

SNMPINFORM

public static final byte SNMPINFORM
Constant for SNMP V2 INFORM request.

SNMPV2TRAP

public static final byte SNMPV2TRAP
Constant for SNMP V2 Trap request.

SNMPREPORT

public static final byte SNMPREPORT
Constant for SNMP V2 Report request.

VERSION1

public static final int VERSION1
Constant for SNMP Version 1.

VERSION2C

public static final int VERSION2C
Constant for SNMP Version 2C.

VERSION3

public static final int VERSION3
Constant for SNMP Version 3.

serialize

public boolean serialize
based on this flag v3 table like USMUserTable and SnmpEngineTable will be serialized
Constructor Detail

SnmpTarget

public SnmpTarget()
This constructor is used in applications.

SnmpTarget

public SnmpTarget(int protocol,
                  ProtocolOptions options)
This constructor is used for applications which use protocol other than UDP/IP.

SnmpTarget

public SnmpTarget(int port,
                  java.lang.String session)
This constructor is used for creating a new session for this application. If the session name is same the targets will share the same session. If the port is 0 it will use the available free port.

SnmpTarget

public SnmpTarget(java.applet.Applet applet)
Use this constructor for applets. Applets will try and use SAS, and if unsuccessful, will use local sockets. MIB loading from applets may fail from this SnmpTarget instance if you use this constructor. This matters only for the first SnmpTarget instance, and subsequent instances will use the same SNMP mechanisms.

SnmpTarget

public SnmpTarget(java.applet.Applet applet,
                  int port,
                  java.lang.String session)
Use this constructor for creating a new session for this applet. If the session name is same, the targets will share the same session. If the port is 0 it will use the available free port. Applets will try and use SAS, and if unsuccessful, will use local sockets. MIB loading from applets may fail from this SnmpTarget instance, if you use this constructor. This matters only for the first SnmpTarget instance, and subsequent instances will use the same SNMP mechanisms.

SnmpTarget

public SnmpTarget(java.lang.String[] localAddrs,
                  java.lang.String sessionName)
Use this constructor for applications in which the session needs to be bound to some local address. Usually, the session will be shared across different instances of this class. If seperate session needs to be used, then specify unique sessionNames for the instances created.
Parameters:
localAddrs - The local addresses to which the session needs to be bound.
sessionName - Specify unique sessionNames for the instances which need to use different SnmpSession instances to send data.
Method Detail

loadMibs

public void loadMibs(java.lang.String mibs)
              throws MibException,
                     java.io.IOException,
                     java.io.FileNotFoundException
Load the mibs specified by white-space separated list of mibs. If first SnmpTarget has been opened with applet parameter, then URLs will be used. MIB loading applies across all the beans in this package, i.e. MIBs can be loaded in any of the bean instances, and will be available across all the beans in this package, across the VM.
Throws:
MibException - is thrown while parser error occurs.
java.io.IOException - is thrown when IO error occurs.
java.io.FileNotFoundException - is thrown if the file is not found.

snmpGet

public java.lang.String snmpGet()
Queries the target and returns as a string the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: errorCodes SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetVariable

public SnmpVar snmpGetVariable()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetVariableBinding

public SnmpVarBind snmpGetVariableBinding()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGet

public SnmpVar snmpGet(SnmpOID oid)
Gets the SNMP variable identified by specified Object Identifier. The following errorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetList

public java.lang.String[] snmpGetList()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetVariables

public SnmpVar[] snmpGetVariables()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetVariableBindings

public SnmpVarBind[] snmpGetVariableBindings()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetList

public SnmpVar[] snmpGetList(SnmpOID[] oids)
Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance. Return null if no OIDs specified earlier or in case of errors. See error data for details, i.e. use getErrorString() to see the reason for failure. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Parameters:
oids - - an Array of SnmpOID
Returns:
an Array of SnmpVar if oids is not null, else returns null
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNext

public java.lang.String snmpGetNext()
Queries the target and returns as a string the next SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextVariable

public SnmpVar snmpGetNextVariable()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextVariableBinding

public SnmpVarBind snmpGetNextVariableBinding()
Queries the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNext

public SnmpVar snmpGetNext(SnmpOID oid)
Gets the SNMP variable identified by specified Object Identifier. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextList

public java.lang.String[] snmpGetNextList()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextVariables

public SnmpVar[] snmpGetNextVariables()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextVariableBindings

public SnmpVarBind[] snmpGetNextVariableBindings()
Queries the agent and returns the list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR,SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetNextList

public SnmpVar[] snmpGetNextList(SnmpOID[] oids)
Gets the list of SNMP variables identified by the Object Identifier list stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSet

public java.lang.String snmpSet(java.lang.String value)
                         throws DataException
This method is used to do an SNMP set to the target using value specified of the first variable on the variable list. This method will fail if MIB with this variable is not loaded of this is not a leaf node in the MIB. Throws DataException if no OID is specified earlier or in case of errors. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR,MIB_NODE_UNAVAIL, OID_NOT_LEAF, ERR_CREATING_VARIABLE, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
as a string the value returned by the target.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSet

public java.lang.String snmpSet(java.lang.String value,
                                byte type)
                         throws DataException
This method is used to do an SNMP set to the target of the first variable on the variable list using value specified. Throws DataException if no OID is specified earlier or in case of errors.i The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, ERR_CREATING_VARIABLE, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
as a string the value that is set.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSetVariable

public SnmpVar snmpSetVariable(SnmpVar var)
                        throws DataException
This method is used to do an SNMP set with specified value to the target and returns the SNMP variable identified by the first Object Identifier stored in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSetList

public java.lang.String[] snmpSetList(java.lang.String[] values)
                               throws DataException
This method sets the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST,UNKNOWN_ERR, MIB_NODE_UNAVAIL OID_NOT_LEAF ERR_CREATING_VARIABLE ILLEGAL_ARG,SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSetVariables

public SnmpVar[] snmpSetVariables(SnmpVar[] values)
                           throws DataException
This method is used to do an SNMP set, with values specified, the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpTarget instance. The following ErrorCodes can be set:SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR,SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendTrap

public void snmpSendTrap(java.lang.String enterprise,
                         java.lang.String agenthost,
                         int genericType,
                         int specificType,
                         long uptime,
                         java.lang.String[] values)
                  throws DataException
This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. It will send a notification with appropriate changes if version is not v1. The following ErrorCodes can be set: INVALID_GENERIC_TYPE, INVALID_VERSION, REQ_TIMEDOUT, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendTrap

public void snmpSendTrap(SnmpOID enterprise,
                         java.lang.String agenthost,
                         int genericType,
                         int specificType,
                         long uptime,
                         SnmpVar[] values)
                  throws DataException
This method is used to send an SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. It will send a notification with appropriate changes if version is not v1 The following ErrorCodes can be set: INVALID_GENERIC_TYPE, INVALID_VERSION, REQ_TIMEDOUT,IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
null, if no OID is specified earlier or in case of errors.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendNotification

public void snmpSendNotification(long uptime,
                                 SnmpOID trapOid,
                                 SnmpVar[] values)
                          throws DataException
This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. The following ErrorCodes can be set: INVALID_VERSION, REQ_TIMEDOUT, IP_ADDR_NOT_SPECIFIED SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST UNKNOWN_ERR, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Parameters:
uptime - The sysUptime value. This is the first oid sent with the notification. The corresponding oid need not be present in the oidList.
values - It contains an array of SnmpVar values corresponding to the oids in the oidList.
trapOid - This should contain the oid corresponding to the snmpTrapOID.
Throws:
DataException - is thrown for invalid values.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendNotification

public void snmpSendNotification(long uptime,
                                 java.lang.String trapOid,
                                 java.lang.String[] values)
                          throws DataException
This method is used to send an SNMPV2 notification pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. The following ErrorCodes can be set: OID_NOT_SPECIFIED INVALID_VERSION, REQ_TIMEDOUT, IP_ADDR_NOT_SPECIFIED SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR , SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Parameters:
uptime - The sysUptime value. This is the first oid sent with the notification. The corresponding oid need not be present in the oidList.
values - Contains an array of string values corresponding to the oids in the oidList.
trapOid - This should contain the oid string corresponding to the snmpTrapOID.
Throws:
DataException - is thrown for invalid values.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendInformRequest

public java.lang.String[] snmpSendInformRequest(long uptime,
                                                java.lang.String trapOid,
                                                java.lang.String[] values)
                                         throws DataException
This method is to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. The following ErrorCodes can be set: OID_NOT_SPECIFIED INVALID_VERSION, REQ_TIMEDOUT, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, EMPTY_VAR_BIND, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Parameters:
uptime - The sysUptime value. This is the first oid sent with the notification. The corresponding oid need not be present in the oidList.
values - Contains an array of string values corresponding to the oids in the oidList.
trapOid - This should contain the oid string corresponding to the snmpTrapOID.
Throws:
DataException - is thrown for invalid values.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpSendInformAcknowledgement

public void snmpSendInformAcknowledgement(long uptime,
                                          SnmpOID oid,
                                          SnmpVar[] values,
                                          int reqID)
                                   throws DataException

snmpSendInformRequest

public SnmpVarBind[] snmpSendInformRequest(long uptime,
                                           SnmpOID trapOid,
                                           SnmpVar[] values)
                                    throws DataException
This method is used to send an SNMPV2 inform pdu with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpTarget instance, and the values specified. The following ErrorCodes can be set: INVALID_VERSION, REQ_TIMEDOUT, IP_ADDR_NOT_SPECIFIED SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST UNKNOWN_ERR EMPTY_VAR_BIND,SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Parameters:
uptime - The sysUptime value. This is the first oid sent with the notification. The corresponding oid need not be present in the oidList.
values - Contains an array of SnmpVar values corresponding to the oids in the oidList.
trapOid - This should contain the oid corresponding to the snmpTrapOID.
Throws:
DataException - is thrown for invalid values.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

addObjectID

public int addObjectID(java.lang.String s)
This method adds an SnmpOID specified by string to the SnmpOID list.
Parameters:
s - - the string may be in any format like 1.5.0 or sysName
Returns:
the index of the added entry in the oidList

addSnmpOID

public int addSnmpOID(SnmpOID oid)
This method adds an SnmpOID to the previously set list of SnmpOID
Parameters:
oid - SnmpOID to be added.
Returns:
the index of the added entry in the oidList

getObjectID

public java.lang.String getObjectID(int index)
This method returns the object ID at index as a string
Parameters:
index - index in the oidlist whose value is looked up.
Returns:
an object ID as a string in format like iso.org.dod.internet.. if mibs loaded or as a string in format like .1.3.6.1.. if mibs is not loaded or null if no oid is set previously in that index.

getObjectID

public java.lang.String getObjectID()
This method returns the first object ID as a string
Returns:
the first object ID as a string in format like iso.org.dod.internet.. if mibs loaded or as a string in format like .1.3.6.1.. if mibs is not loaded or null if no oid is set previously.

setObjectID

public void setObjectID(java.lang.String s)
This method sets the object ID specified by the String value.
Parameters:
s - the oid to be set.

setObjectID

public void setObjectID(int index,
                        java.lang.String s)
This method sets the object ID value at index based on specified string
Parameters:
index - index where the oid is to be set in the oidlist
s - oid to be set.

getObjectIDList

public java.lang.String[] getObjectIDList()
This method returns the list of object IDs as a string array or null, if no OIDs is set previously.
Returns:
String[] of oids.

setObjectIDList

public void setObjectIDList(java.lang.String[] s)
This method sets the list of object IDs based on the specified string array.
Parameters:
s - a String array of OIDs.

getSnmpOID

public SnmpOID getSnmpOID()
This method returns the first SnmpOID from the list of object IDs or null, if no OID is set previously.
Returns:
the first SnmpOID.

getDebug

public boolean getDebug()
This method returns true if debug mode is enabled and false otherwise

setDebug

public void setDebug(boolean debug)
This method determines if debug output will be printed
Parameters:
debug - true to get the debug message and false otherwise.

getMibModules

public java.lang.String getMibModules()
This method returns all the MIBs that are loaded in this applet/application.
Returns:
a white-space separated list of mib files.

setMibModules

public void setMibModules(java.lang.String mibs)
This method sets the MIB to be loaded in this applet/application.
Parameters:
mibs - white-space seperated list of mib file to be loaded.

setSnmpOID

public void setSnmpOID(SnmpOID oid)
This method sets the SnmpOID
Parameters:
oid - instance of SnmpOID.

getSnmpOIDList

public SnmpOID[] getSnmpOIDList()
This method returns the list of object IDs as an array of SnmpOID or null if no OID is set previously.
Returns:
an array of SnmpOIDs.

setSnmpOIDList

public void setSnmpOIDList(SnmpOID[] list)
This method sets the list of object IDs as the given array of SnmpOID
Parameters:
list - array of SnmpOIDs.

getTargetHost

public java.lang.String getTargetHost()
Gets the SNMP target hostname
Specified by:
getTargetHost in interface CustomizerTemplate

setTargetHost

public void setTargetHost(java.lang.String s)
This method sets the SNMP target hostname
Specified by:
setTargetHost in interface CustomizerTemplate

getTargetPort

public int getTargetPort()
get the SNMP target port number
Specified by:
getTargetPort in interface CustomizerTemplate

setTargetPort

public void setTargetPort(int i)
set the SNMP target port number
Specified by:
setTargetPort in interface CustomizerTemplate

getContextName

public java.lang.String getContextName()
get the SNMP V3 Context name

setContextName

public void setContextName(java.lang.String cName)
set the SNMP V3 Context name

getContextID

public java.lang.String getContextID()
Gets the SNMP V3 contextID.
Returns:
the contextID set on this target.

setContextID

public void setContextID(java.lang.String ctxtID)
Sets the SNMP V3 contextID. The ContextID is internally stored as an array of bytes. The String <--> byte[] conversion is done using 8859_1 character encoding scheme. If you want to use any other character encoding, then you can set the encoding to be used by using the method setCharacterEncoding in SnmpServer (super class of this).
Parameters:
ctxtID - The contextID to be set on this target.

getPrincipal

public java.lang.String getPrincipal()
Gets the SNMP V3 Principal

setPrincipal

public void setPrincipal(java.lang.String s)
Sets the SNMP V3 Principal
Specified by:
setPrincipal in interface CustomizerTemplate

getSecurityModel

public int getSecurityModel()
Gets the SNMP V3 securityModel

setSecurityModel

public void setSecurityModel(int securityModel)
Sets the SNMP V3 SecurityModel

getAuthProtocol

public int getAuthProtocol()
Gets the SNMP V3 AuthProtocol

setAuthProtocol

public void setAuthProtocol(int protocol)
Sets the SNMP V3 AuthProtocol
Specified by:
setAuthProtocol in interface CustomizerTemplate

getAuthPassword

public java.lang.String getAuthPassword()
Gets the SNMP V3 AuthPassword

setAuthPassword

public void setAuthPassword(java.lang.String password)
Sets the SNMP V3 AuthPassword
Specified by:
setAuthPassword in interface CustomizerTemplate

getPrivPassword

public java.lang.String getPrivPassword()
Gets the SNMP V3 PrivPassword

setPrivPassword

public void setPrivPassword(java.lang.String password)
Sets the SNMP V3 PrivPassword
Specified by:
setPrivPassword in interface CustomizerTemplate

getCommunity

public java.lang.String getCommunity()
Gets the SNMP target Community

setCommunity

public void setCommunity(java.lang.String s)
Sets the SNMP target Community

getWriteCommunity

public java.lang.String getWriteCommunity()
Gets the SNMP target write Community to be used for set requests

setWriteCommunity

public void setWriteCommunity(java.lang.String s)
Sets the SNMP target write Community to be used for set requests

getIgnoreSpecificControlCodes

public boolean getIgnoreSpecificControlCodes()
Gets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values.
Overrides:
getIgnoreSpecificControlCodes in class SnmpServer
Returns:
true indicates that they are printed as they are false indicates that their hex value is printed.

setIgnoreSpecificControlCodes

public void setIgnoreSpecificControlCodes(boolean specConCode)
Sets the value determining whether the new-line characters, tabs and carriage returns are printed or their hex values.
Overrides:
setIgnoreSpecificControlCodes in class SnmpServer
Parameters:
specConCode - true implies that they are printed as they are false implies that their hex value is printed.

getTimeout

public int getTimeout()
Gets the SNMP target timeout value
Returns:
timeout value in Seconds. Default is 5Secs.

setTimeout

public void setTimeout(int i)
Sets the SNMP target timeout value
Parameters:
value - in Seconds. Default is 5Secs.

getRetries

public int getRetries()
Gets the SNMP target retries value. Default is 0.

setRetries

public void setRetries(int i)
Sets the SNMP target retries value. Default is 0.

getMaxRepetitions

public int getMaxRepetitions()
Gets the SNMP target max repetitions value for a getbulk request. Default is 50

setMaxRepetitions

public void setMaxRepetitions(int i)
Sets the SNMP target max repetitions value for a getbulk request. Default is 50

getNonRepeaters

public int getNonRepeaters()
Gets the SNMP target non-repeaters value for a getbulk request Default is 0.

setNonRepeaters

public void setNonRepeaters(int i)
Sets the SNMP target non-repeaters value for a getbulk request Default is 0.

getSnmpVersion

public int getSnmpVersion()
Gets the SNMP target SNMP Version. 0 is Version 1 (default) and 1 is Version V2C.

setSnmpVersion

public void setSnmpVersion(int i)
Sets the SNMP target SNMP Version. 0 is Version 1 (default) and 1 is Version V2C.
Specified by:
setSnmpVersion in interface CustomizerTemplate

getErrorString

public java.lang.String getErrorString()
Gets the error string for the request sent. Before sending any request the error string will be "No Error Code Registered". The Error index which is the index of the error in the PDU will be appended to this Error String.
Returns:
the error string that gets set in case of error and "No Error" if there is no error.

getErrorCode

public int getErrorCode()
Gets the error code for the last request. Before sending any request the error code will be -1.
Returns:
the error code in case of error and 0 if there is no error.

getExceptionCode

public int getExceptionCode()
Gets the exception code for the last request. Before sending any request the exception code will be -1.
Returns:
the exception code in case of exception and 0 if there is no exception.

getErrorIndex

public int getErrorIndex()
To get the error index corresponding to the errored oid in the pdu.
Returns:
the error index in case of error and 0 if there is no error.

getAttemptPartial

public boolean getAttemptPartial()
Returns the boolean state of whether this target will try to get partial data from an agent if the request is a multiple variable request.

setAttemptPartial

public void setAttemptPartial(boolean b)
Sets the boolean state of whether this target will try to get a partial data from an agent if the request is a multi variable request.

getAttemptComplete

public boolean getAttemptComplete()
Returns if the splitting pdu is enabled to get the complete data by splitting the varbinds into multiple request. By default pdu splitting is disabled.

setAttemptComplete

public void setAttemptComplete(boolean flag)
Enables the flag to get the complete data from the agent by splitting the varbinds into multiple request.This can set if request pdu is very big. The number of varbinds that should to be sent per request can be set using setVarBindCount() method. By default pdu splitting is disabled.

getVarBindCount

public int getVarBindCount()
Returns the number of varbinds used with the splitted pdu. Default value is 0.

setVarBindCount

public void setVarBindCount(int count)
Set the number of varbinds per request to get the complete data from the agent by splitting the varbinds into multiple request in case if the request pdu is very big. Default value is 0.

getSendTimeoutEvents

public boolean getSendTimeoutEvents()
Returns the boolean state of whether this target will send timeout events to a registered listener.

setSendTimeoutEvents

public void setSendTimeoutEvents(boolean b)
This should be set to true if the listener should be notified of the timeout events in case if the request timesout.

addSnmpPropertyListener

public void addSnmpPropertyListener(SnmpPropertyListener l)
Adds SnmpPropertyListener to the SnmpPropertyListener list. Whenever the value of target parameters like targetHostName, targetPort is changed, a event of SnmpPropertyChangeEvent will be thrown to the listeners in this list
See Also:

removeSnmpPropertyListener

public void removeSnmpPropertyListener(SnmpPropertyListener l)
Removes the SnmpPropertyListener from the list maintained by this target.

addResultListener

public void addResultListener(ResultListener l)
Adds a listener for events from this target. The listener listens for events from any or all SNMP requests.

removeResultListener

public void removeResultListener(ResultListener l)
Removes a listener for events from this target.

addV3HandShakeResultListener

public void addV3HandShakeResultListener(V3HandShakeResultListener l)
Adds a listener to receive the events when SnmpEngineID discovery and time Synchronization is performed by the method async_create_v3_tables.
Parameters:
V3HandShakeResultListener - the Listener to be registered for getting ebents.

removeV3HandShakeListener

public void removeV3HandShakeListener(V3HandShakeResultListener l)
Removes the listener registered for getting events.
Parameters:
V3HandShakeResultListener - the listener to be removed.

getMibOperations

public MibOperations getMibOperations()
get the MibOperations object reference. This allows using additonal MibOperations functions if needed.

genTimeoutEvent

protected void genTimeoutEvent(SnmpPDU pdu)
Generates the events to the listeners
Overrides:
genTimeoutEvent in class SnmpServer

genEvent

protected void genEvent(SnmpPDU pdu)
Generates the events to the listeners
Overrides:
genEvent in class SnmpServer

snmpGetAllList

public java.lang.String[][] snmpGetAllList()
Gets all instances of variables in the OID list. Used for columnar OIDs, mainly for SNMP Table Column. If the OID list contains more than one table column OIDs then each table column OID will be queried consecutively for each row. The OID list must contain the OIDs of the Table column without instances. setMaxNumRows method sets the maximum number of rows that can be requested for all the table column specified in the OID list. The maximum number of rows that can be processed by default is 1000. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
variables as a two dimensional array of strings Useful for small tables. Returns null if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetAllVariables

public SnmpVar[][] snmpGetAllVariables()
Gets all instances of variables in the OID list. The maximum number of rows that can be processed by default is 1000. To increase the number of rows to be processed use setMaxNumRows(). The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
variables as a two dimensional array of SnmpVar's Useful for small tables. Return null if no OIDs specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetAllVariableBindings

public SnmpVarBind[][] snmpGetAllVariableBindings()
Gets all instances of variables in the OID list. The maximum number of rows that can be processed by default is 1000. To increase the number of rows to be processed use setMaxNumRows(). The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.
Returns:
variables as a two dimensional array of SnmpVarBind's Useful for small tables. Returns null, if no OID is specified earlier or in case of errors.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

snmpGetBulkList

public java.lang.String[][] snmpGetBulkList()
Get bulk on list of variables in the OID list. Available in SNMPv2c and SNMPv3 cases.
Returns:
String-valued variables as a two dimensional array of String's. Returns null if no OIDs specified earlier or in case of errors.
See Also:
data for details, i.e. use getErrorString() to see the reason for failure.

Please see RFC 1905 if you're not familiar with getbulk. Beyond the first set of non-repeater OIDS, i.e. OIDs that want only a single next value, the data can be viewed as a table, where we're getting rows upto "max repetitions" rows. The returned data is composed of a two-dimensional array where the first "nonRepeaters" columns have only the first data element filled in. The remaining have the rows filled in as expected. Typically, non-repeaters is 0, and we'd be returning a completely filled-in 2-D array of values.

The OID List after this request is set to the last set of OIDs in the returned bulk data, except for the initial non-repeaters for which it is set to the first and only returned OID. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, INVALID_NON_REP SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID., ErrorMessages, getErrorCode(), getErrorString()


snmpGetBulkVariables

public SnmpVar[][] snmpGetBulkVariables()
Get bulk on list of variables in the OID list. Available in SNMPv2c and SNMPv3 cases.
See Also:
data for details, i.e. use getErrorString() to see the reason for failure.

Please see RFC 1905 if you're not familiar with getbulk. Beyond the first set of non-repeater OIDS, i.e. OIDs that want only a single next value, the data can be viewed as a table, where we're getting rows upto "max repetitions" rows. The returned data is composed of a two-dimensional array where the first "nonRepeaters" columns have only the first data element filled in. The remaining have the rows filled in as expected. Typically, non-repeaters is 0, and we'd be returning a completely filled-in 2-D array of values.

The OID List after this request is set to the last set of OIDs in the returned bulk data, except for the initial non-repeaters for which it is set to the first and only returned OID. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT, EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN,SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, INVALID_NON_REP SNMP error's defined in ErrorMessages INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID., ErrorMessages, getErrorCode(), getErrorString()


snmpGetBulkVariableBindings

public SnmpVarBind[][] snmpGetBulkVariableBindings()
Get bulk on list of variables in the OID list. Available in SNMPv2c and SNMPv3 cases.
Returns:
variable bindings as a two dimensional array of SnmpVarBind's. Returns null if no OID is specified earlier or in case of errors.
See Also:
data for details, i.e. use getErrorString() to see the reason for failure.

Please see RFC 1905 if you're not familiar with getbulk. Beyond the first set of non-repeater OIDS, i.e. OIDs that want only a single next value, the data can be viewed as a table, where we're getting rows upto "max repetitions" rows. The returned data is composed of a two-dimensional array where the first "nonRepeaters" columns have only the first data element filled in. The remaining have the rows filled in as expected. Typically, non-repeaters is 0, and we'd be returning a completely filled-in 2-D array of values.

The OID List after this request is set to the last set of OIDs in the returned bulk data, except for the initial non-repeaters for which it is set to the first and only returned OID. The following ErrorCodes can be set: SNMP_NOT_INIT, INVALID_VERSION, OID_NOT_SPECIFIED, REQ_TIMEDOUT,EMPTY_VAR_BIND, IP_ADDR_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, UNKNOWN_ERR, INVALID_NON_REP, SNMP error's defined in ErrorMessages. INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID., ErrorMessages, getErrorCode(), getErrorString()


isInSubTree

public static boolean isInSubTree(SnmpOID rootoid,
                                  SnmpOID objid)
Check if objid has rootoid as an ancestor. Return true if it does. This performs a straightforward comparison to see if the object-id starts with the rootoid. It is useful for walking through a column in which a walk could be terminated when the returned object id is not in the sub-tree of the column oid.

getSecurityLevel

public java.lang.String getSecurityLevel()
Gets the SNMP V3 SecurityLevel

setSecurityLevel

public void setSecurityLevel(byte sLevel)
Sets the SNMP V3 SecurityLevel.The value will be 0 ,1 or 3. For other values, warning message will be given and it will take value as 0.
Specified by:
setSecurityLevel in interface CustomizerTemplate

isSerialize

public boolean isSerialize()
Returns the status of Serialization of v3 tables ( USMUserTable and SnmpEngineTable )
Specified by:
isSerialize in interface CustomizerTemplate

vetoableChange

public void vetoableChange(java.beans.PropertyChangeEvent e)
This method is called when a vetoableChange event is fired from the propertySetting bean. Creates new users if required
Specified by:
vetoableChange in interface java.beans.VetoableChangeListener

setMaxNumRows

public void setMaxNumRows(int maxRows)
Sets the maximum number of rows that can be processed, default value is 1000.

getMaxNumRows

public int getMaxNumRows()
Gets the maximum number of rows that can be processed, default value is 1000.

setParams

public void setParams(java.lang.String host,
                      java.lang.String port,
                      java.lang.String community,
                      java.lang.String mib,
                      java.lang.String oid)
To set Multiple parameters like TargetHost,Port,Community,MibModule and OID. If any of these parameters need not be set,then it should be given as null.
Parameters:
host - target host
port - target port
community - community name
mib - mib file
oid - OID

setParams

public void setParams(java.lang.String host,
                      java.lang.String port,
                      java.lang.String community,
                      java.lang.String mib,
                      java.lang.String[] oidlist)
To set Multiple parameters like TargetHost,Port,Community,MibModule and OIDList. If any of these parameters need not be set,then it should be given as null.
Parameters:
host - target host
port - target port
community - community name
mib - mib file
oidlist - a String array of OIDs

addLogClient

public void addLogClient(LogInterface client)
Add the Log client for which the target has to redirect the log messages
Parameters:
client- - LogInterface

removeLogClient

public void removeLogClient()
Removes the Log client for which the target has been registered to redirect the log Messages.

getCompleteResponse

public SnmpResultObject getCompleteResponse()
Gets the complete data from the agent by splitting the varbinds into multiple requests.This can set if request pdu is very big. The number of varbinds that should be sent per request can be set using setVarBindCount() method. Also, if there is any errored varbind, it will be removed and the response for the rest of the varbind will be obtained. The errored index with the corresponding error, the successful responses and the success code (SUCCESS, PARTIAL or NOSUCCESS) can be obtained from SnmpResultObject returned.
Returns:
SnmpResultObject containing the error, successful responses and the success code.

addLogClient

public void addLogClient(LoggerProperties loggerProps)
                  throws LogException
Adds the Log client for which the target has to redirect the log messages. This method can be called when advanced method level logging mechanism needs to be used. This method is used to create a new Logger. The properties of the module are specified in the loggerProps.
Parameters:
loggerProps - - A LoggerProperties instance having the properties of the Logger such as loggingLevel.

releaseResources

public void releaseResources()
Though the resources will be cleaned up by the garbage collector, if the application is no more using the SnmpTarget bean instance, this method can be used to immediately release the resources. Close the session and api if number of targets sharing it becomes zero. Otherwise decrement the targets count for that session and api.
Overrides:
releaseResources in class SnmpServer


Copyright (c)AdventNet Inc., 1996-2004