com.adventnet.snmp.beans
Class SnmpRequestServer

java.lang.Object
  |
  +--com.adventnet.snmp.beans.SnmpServer
        |
        +--com.adventnet.snmp.beans.SnmpRequestServer
All Implemented Interfaces:
CustomizerTemplate, java.util.EventListener, RequestListener, java.io.Serializable, SnmpClient, java.beans.VetoableChangeListener

public class SnmpRequestServer
extends SnmpServer
implements RequestListener, SnmpClient, java.beans.VetoableChangeListener, CustomizerTemplate

This class is an SNMP Server bean for performing asynchronous SNMP requests on a list of variables. It supports event generation per the JDK 1.1 event model. It allows sending request events to it or invoking its asynchronous request methods and receiving response events, i.e. ResultEvent objects, from it when responses arrive or timeout.

See the requestServerDemo.java applet example in the applications directory.

To use in an application, instantiate the server, and register to receive results. For example, the following is a trivial listener that prints the return value.

    SnmpRequestServer server = new SnmpRequestServer();
    
    ResultListener listener = new ResultListener() {
        public void setResult(ResultEvent evt) {
            System.err.println("Response: "+evt.getValue());
        }
    };
    
server.addResultListener(listener);
Then use the asynchronous methods to make requests, or you can generate events, e.g.
       RequestEvent evt = 
           new RequestEvent(b1, getParameter("OID"), RequestEvent.GET);
       server.addRequest(evt);
  
The above is a somewhat simplified example for event generation.

To receive timeout events,use setSendTimeoutEvents(true). Otherwise if the request times out,then the timeout events will not be sent to the listener.

Normally, you would allow registration of RequestListener objects, and send events to all registered listeners. The advantage of generating events really lies in being able to write components that do not know at build time the request server they will send events to.

Major difference between this and SnmpRequestServer is the ability to use the RequestEvent objects to send requests to the SnmpRequestServer. The benefit of this feature is that event connections between sources of request events, and SnmpRequestServer instances can be more readily be defined, in bean builders for example. So a button that generates a request event can be flexibly connected to the appropriate SnmpRequestServer instance in a bean builder. The SnmpRequestServer provides a convenience object for many of the common operations you do with an SNMP agent.

For garbagecollection of the resources used, releaseResources() method should be invoked. Different SnmpRequestServer 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 SnmpRequestServer instance created and when this method is called on the final instance of SnmpRequestServer, these will be garbage collected.

Supply the applet in the constructor if using applets and may need to use SAS.

See Also:
RequestEvent, ResultEvent, Serialized Form

Field Summary
 boolean serialize
          v3 only based on this flag the v3 tables ( USMUserTable and SnmpEngineTable ) will be serialized.
 
Fields inherited from class com.adventnet.snmp.beans.SnmpServer
AUTH_NO_PRIV, AUTH_PRIV, CBC_3DES, CBC_DES, CFB_AES_128, CFB_AES_192, CFB_AES_256, MD5_AUTH, NO_AUTH, NO_AUTH_NO_PRIV, NO_PRIV, oidList, SHA_AUTH, SNMPGET, SNMPGETBULK, SNMPGETNEXT, SNMPINFORM, SNMPREPORT, SNMPRESPONSE, SNMPSET, SNMPTRAP, SNMPV2TRAP, VERSION1, VERSION2C, VERSION3
 
Constructor Summary
SnmpRequestServer()
          Use this constructor for applications.
SnmpRequestServer(java.applet.Applet applet)
          Use this constructor for applets.
SnmpRequestServer(java.applet.Applet applet, int localPort, java.lang.String sessionName)
          Use this constructor for appletswhich will create a session with name and in specific localport..
SnmpRequestServer(int protocol, ProtocolOptions options)
          Use this constructor for applications which uses protocols other than UDP/IP.
SnmpRequestServer(int localPort, java.lang.String sessionName)
          Use this constructor for applications which will create a session with name and in specific localport.
SnmpRequestServer(SnmpSession ses, MibOperations mib)
          Use this constructor for applications which uses given Session and MibOperations instance and not to use the default session and mibOps instance.
SnmpRequestServer(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 SnmpRequestServer has to redirect the log messages
 int addObjectID(java.lang.String s)
          Adds an ObjectID specified by string to the existing OID list.
 int addRequest(RequestEvent e)
          To add a request to the already existing requests.
 void addResultListener(ResultListener l)
          Adds a Listener to the list that is notified each time when a response arrives.
 int addSnmpOID(SnmpOID oid)
          Adds an SnmpOID to the existing list of OIDs.
 void addSnmpPropertyListener(SnmpPropertyListener l)
          Adds SnmpPropertyListener to the Listeners list.
 void addUserError(int errorCode, java.lang.String errorString)
          This method is used to add user defined error codes and the corresponding error string.
 void addV3HandShakeResultListener(V3HandShakeResultListener l)
          v3 only Adds a listener to receive the events when SnmpEngineID discovery and time Synchronization is performed by the method async_create_v3_tables.
 boolean authenticate(SnmpPDU pdu, java.lang.String community)
          This is the SnmpClient method implementation used to authenticate a PDU.
 boolean callback(SnmpSession session, SnmpPDU pdu, int requestID)
          This is the SnmpClient method implementation method that processes and forwards the result.The response returned by the RequestServer will be received by this method.
 void debugPrint(java.lang.String debugOutput)
          This is the SnmpClient method implementation that prints the standard error.
 void deSerializeUSM()
          v3 only This will deserialize the v3 tables like USMUserTable and SnmpEngineTable from serialized file if the serilaized file already exists
protected  void genEvent(SnmpPDU pdu)
          Generate the response event to the listeners
protected  void genTimeoutEvent(SnmpPDU pdu)
          Generate the timeout events to the listeners
 boolean getAttemptPartial()
          Deprecated. SnmpRequestServer cannot get the partial data. It is specifically for SnmpTarget bean which does synchronous comm..
 java.lang.String getAuthPassword()
          v3 only To get the SNMP V3 AuthPassword
 int getAuthProtocol()
          v3 only To get the SNMP V3 AuthProtocol
 java.lang.String getCommunity()
          To get the SNMP target Community
 java.lang.String getContextID()
          v3 only To get the SNMP V3 contextID
 java.lang.String getContextName()
          v3 only To get the SNMP V3 Context name
 boolean getDebug()
          To check if Debug mode is enabled or not
 byte[] getEngineID()
          v3 only To get the SNMP V3 engineID value for v3
 int getErrorCode()
          To get the error code from the last request.
 java.lang.String getErrorResultString(SnmpPDU pdu)
          To get the error string associated with the response PDU
 java.lang.String getErrorString()
          To get the error string from the last request.
 int getMaxRepetitions()
          v2c and v3 only To get the SNMP target max repetitions value for a getbulk request.
 java.lang.String getMibModules()
          To get the MIBs (/white-space separated list of mib files)that is(/are) loaded in this applet/application
 MibOperations getMibOperations()
          To get the MibOperations object reference.
 int getNonRepeaters()
          v2c and v3 only To get the SNMP target non-repeaters value for a getbulk request.
 java.lang.String getObjectID()
          To get the first object ID from a list of ObjectIDs.
 java.lang.String getObjectID(int index)
          To get the object ID at the specified index
 java.lang.String[] getObjectIDList()
          To get the list of object IDs.
 java.lang.String getPrincipal()
          v3 only To get the SNMP V3 username
 java.lang.String getPrivPassword()
          v3 only To get the SNMP V3 PrivPassword
 int getPrivProtocol()
          v3 only Gets the SNMP V3 privProtocol
 int getRetries()
          To get the SNMP target retries value.
 java.lang.String getSecurityLevel()
          v3 only To get the SNMP V3 SecurityLevel
 int getSecurityModel()
          v3 only To get the SNMP V3 securityModel
 boolean getSendTimeoutEvents()
          To check if the target will send timeout events to registered listeners.
 SnmpOID getSnmpOID()
          To get the first SnmpOID from the list of object IDs.
 SnmpOID[] getSnmpOIDList()
          To get the list of object IDs as an array of SnmpOID instances
 int getSnmpVersion()
          v3 only To get the SNMP target SNMP Version.
 java.lang.String getTargetHost()
          To get the SNMP target hostname
 int getTargetPort()
          To get the SNMP target port number
 int getTimeout()
          To get the SNMP target timeout value in Seconds.
 int getUserErrorCode()
          Gets the user defined error code for the last request.
 java.lang.String getUserErrorString()
          This method is used to get the user defined error string to a specific error code.
 java.lang.String getWriteCommunity()
          To get the SNMP target write Community to be used for set requests
 boolean isBroadCastEnabled()
          Returns the current status as to whether broadcasting is enabled/disabled.
 boolean isSerialize()
          v3 only To check the status of Serialization of v3 tables (USMUserTable and SnmpEngineTable)
 void loadMibs(java.lang.String mibs)
          Loads the specified mib.
 void readFromDatabase()
          v3 only This will read the v3table like USmUserTable and SnmpEngineTable from Database after establishing connection
 void releaseResources()
          Though the resources will be cleaned up by the garbage collector, if the application is no more using the SnmpRequestServer bean instance, this method can be used to immediately release the resources.
 void removeLogClient()
          Removes the Log client that has been registered to redirect the log Messages for this instance.
 void removeResultListener(ResultListener l)
          Removes a listener for response events from the list of listeners.
 void removeSnmpPropertyListener(SnmpPropertyListener l)
          Removes the SnmpPropertyListener from the list.
 void removeV3HandShakeListener(V3HandShakeResultListener l)
          v3 only Removes the listener registered for getting events.
 int sendGetBulkRequestList()
          v2c and v3 only To send a GetBulk request to get a list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendGetNextRequest()
          To send a getnext request for the SNMP variable identified by the first Object Identifier set in this SnmpRequestServer instance.
 int sendGetNextRequest(SnmpOID oid)
          To send a getnext request for the SNMP variable identified by specified Object Identifier.
 int sendGetNextRequestList()
          To send a getnext request for a list of SNMP variable bindings identified by the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendGetNextRequestList(SnmpOID[] oids)
          To send a getnext request for a list of SNMP variables identified by the Object Identifier list stored in this SnmpRequestServer instance.
 int sendGetRequest()
          To send a get request for the the SNMP variable identified by the first Object Identifier stored in the SnmpRequestServer instance.
 int sendGetRequest(SnmpOID oid)
          To send a get request for the the SNMP variable identified by specified Object Identifier.
 int sendGetRequestList()
          To send a get request for the list of SNMP variable bindings identified by the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendGetRequestList(SnmpOID[] oids)
          To send a get request for a list of SNMP variables identified by the Object Identifier list.
 int sendSetRequest(java.lang.String value)
          To send a set request with the value to be set for the ObjectID This method will fail if MIB with this variable is not loaded or this is not a leaf node in the MIB.
 int sendSetRequest(java.lang.String value, byte type)
          To send a set request with the value to be set and the type of the variable Throws DataException if no OID specified earlier or in case of errors.
 int sendSetRequestList(java.lang.String[] values)
          To set the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendSetRequestList(java.lang.String[] values, java.lang.String[] oidLists)
          To set the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendSetRequestVariable(SnmpVar var)
          To send a set request to set the specified SnmpVar value for the OID that is set in the SnmpRequestServer instance.
 int sendSetRequestVariables(SnmpVar[] values)
          To send a set request to set the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpRequestServer instance.
 int sendSetRequestVariables(SnmpVar[] values, java.lang.String[] oidsList)
          To send a set request to set the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpRequestServer instance.
 void sendTrap(SnmpOID enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, SnmpVar[] values)
          To send a SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpRequestServer instance, and the values specified.
 void sendTrap(java.lang.String enterprise, java.lang.String agenthost, int genericType, int specificType, long uptime, java.lang.String[] values)
          To send a SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpRequestServer instance, and the values specified.
 void setAttemptPartial(boolean b)
          Deprecated. SnmpRequestServer cannot get partial data by enabling the flag. It is specific for SnmpTarget bean which does synchronous comm..
 void setAuthPassword(java.lang.String password)
          v3 only To set the SNMP V3 AuthPassword
 void setAuthProtocol(int protocol)
          v3 only To set the SNMP V3 AuthProtocol
 void setBroadCastEnable(boolean broadcast)
          Calling this method with a "true" value will indicate that the request is to be sent as a broadcast request.
 void setCommunity(java.lang.String s)
          To set the SNMP target Community
 void setContextID(java.lang.String ctxtID)
          v3 only To set the SNMP V3 contextID
 void setContextName(java.lang.String cName)
          v3 only To set the SNMP V3 Context name
 void setDebug(boolean debug)
          To enable or disable the Debug mode.
 void setEngineID(byte[] engID)
          v3 only To set the SNMP V3 engineID value for v3
 void setMaxRepetitions(int i)
          v2c and v3 only To set the SNMP target max repetitions value for a getbulk request.
 void setMibModules(java.lang.String mibs)
          To load the MIB in this applet/application.
 void setNonRepeaters(int i)
          v2c and v3 only To set the SNMP target non-repeaters value for a getbulk request.
 void setObjectID(int index, java.lang.String s)
          Sets the object ID value specified the string at the given index
 void setObjectID(java.lang.String s)
          Sets the object ID value specified by the string
 void setObjectIDList(java.lang.String[] s)
          Sets the list of object IDs specified by the 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 uName)
          v3 only To set the SNMP V3 username
 void setPrivPassword(java.lang.String password)
          v3 only To set the SNMP V3 PrivPassword
 void setPrivProtocol(int privprotocol)
          v3 only Sets the SNMP V3 PrivProtocol
 void setRetries(int i)
          To Set the SNMP target retries value.
 void setSecurityLevel(byte sLevel)
          v3 only To set the SNMP V3 SecurityLevel.The value will be 0 ,1 or 3.
 void setSecurityModel(int securityModel)
          v3 only To set the SNMP V3 SecurityModel
 void setSendTimeoutEvents(boolean b)
          To set the boolean state of whether this target will send timeout events to registered listeners or not
 void setSnmpOID(SnmpOID oid)
          Sets the SnmpOID.
 void setSnmpOIDList(SnmpOID[] list)
          To set the list of object IDs given as an array of SnmpOIDs
 void setSnmpVersion(int i)
          v3 only To set the SNMP target SNMP Version.
 void setTargetHost(java.lang.String s)
          To set the SNMP target hostname
 void setTargetPort(int i)
          To set the SNMP target port number
 void setTimeout(int i)
          To Set the SNMP target timeout value in Seconds.
 void setWriteCommunity(java.lang.String s)
          To set the SNMP target write Community to be used for set requests
 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, getIgnoreSpecificControlCodes, getLocalAddresses, getMibPath, getOverwriteCMI, getPacketBufferSize, getSecLevelForTimeSync, getSecurityProvider, getSecurityTable, getSerializedMibFileName, getSimpleDateFormat, getSnmpEngineID, getSnmpEngineTable, getTimeoutInMilliSec, getTimeToWait, getUSMTable, getV3ConfigTable, getV3MsgMaxSize, initJdbcParams, initSecurityProvider, isBroadcastFeatureEnable, isLoadFromCompiledMibs, isLoadFromSerializedMibs, isLoadMibsFromDatabase, isOverwriteCMI, isOverwriteMibsInDatabase, isReadDesc, isSendPDUByGroup, isSerializeMibs, isSetAutoInformResponse, isSupportedSecurityModel, isV3DatabaseFlag, isValidateUser, manage_v3_tables, managing_v3_tables, reestablish, restoreDefaultTimeoutPolicy, setAutoInformResponse, setBroadcastFeatureEnable, setCharacterEncoding, setErrorFlagEnable, setIgnoreSpecificControlCodes, setLoadFromCompiledMibs, setLoadFromSerializedMibs, setLoadMibsFromDatabase, setMibOperations, setMibPath, setOverwriteCMI, setOverwriteMibsInDatabase, setPacketBufferSize, setReadDesc, setReceiveBufferSize, setSecLevelForTimeSync, setSendPDUByGroup, setSerializedMibFileName, setSerializeMibs, setSimpleDateFormat, setSnmpEngineBoots, setSnmpEngineID, setTimeoutInMilliSec, setTimeoutPolicy, setTimeToWait, setV3ConfigTable, setV3DatabaseFlag, setV3MsgMaxSize, setWaitTimeToRetry, validateUser
 
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

serialize

public boolean serialize
v3 only based on this flag the v3 tables ( USMUserTable and SnmpEngineTable ) will be serialized.

Constructor Detail

SnmpRequestServer

public SnmpRequestServer()
Use this constructor for applications. Use for applets only if you want to prevent the use of SAS. MIB loading from applets may fail from this SnmpRequestServer instance if you use this constructor. This matters only for the first SnmpRequestServer instance, and subsequent instances will use the same SNMP mechanisms for the same port.


SnmpRequestServer

public SnmpRequestServer(int localPort,
                         java.lang.String sessionName)
Use this constructor for applications which will create a session with name and in specific localport. Use for applets only if you want to prevent use of SAS. MIB loading from applets may fail from this SnmpRequestServer instance if you use this constructor. This matters only for the first SnmpRequestServer instance, and subsequent instances will use the same SNMP mechanisms for the same port.


SnmpRequestServer

public SnmpRequestServer(int protocol,
                         ProtocolOptions options)
Use this constructor for applications which uses protocols other than UDP/IP.


SnmpRequestServer

public SnmpRequestServer(java.applet.Applet applet,
                         int localPort,
                         java.lang.String sessionName)
Use this constructor for appletswhich will create a session with name and in specific localport.. Applets will try and use SAS, and if unsuccessful will use local sockets.


SnmpRequestServer

public SnmpRequestServer(SnmpSession ses,
                         MibOperations mib)
Use this constructor for applications which uses given Session and MibOperations instance and not to use the default session and mibOps instance.


SnmpRequestServer

public SnmpRequestServer(java.applet.Applet applet)
Use this constructor for applets. Applets will try and use SAS, and if unsuccessful will use local sockets.


SnmpRequestServer

public SnmpRequestServer(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
Loads the specified mib. If first SnmpRequestServer has been opened with applet parameter, then URLs will be used. MIB loading applies across all beans in this package, i.e. MIBs can be loaded in any of the bean instances, and will be available to all beans in this package, across the VM. The files can be seperated by a space, tab, new line, carriage return and pipe symbol.
for example, server.loadMibs("../mibs/RFC1213-MIB ../mibs/IF-MIB");
MIBs can also be loaded from string URLs.

In case of loading the files from space seperated directories, the whole String should be given within the double quotes.
for example, if the MIB file is present in the directory 'Program Files',
server.loadMibs("\"../../mibs/Program Files/RFC1213-MIB\"")

Overrides:
loadMibs in class SnmpServer
Throws:
MibException - is thrown while parser error ocurs.
java.io.IOException - is thrown while upon IO error occurs.
java.io.FileNotFoundException - is thrown if the file is not found.

addResultListener

public void addResultListener(ResultListener l)
Adds a Listener to the list that is notified each time when a response arrives. The Listeners will receive Result Events from any or all SNMP requests. Targeting responses to specific listeners, requires using RequestEvent and the setDestination method while creating the request.

Parameters:
l - an instance of ResultListener.
See Also:
ResultEvent, ResultListener

removeResultListener

public void removeResultListener(ResultListener l)
Removes a listener for response events from the list of listeners.

Parameters:
l - ResultListener to be removed.
See Also:
ResultListener

addSnmpPropertyListener

public void addSnmpPropertyListener(SnmpPropertyListener l)
Adds SnmpPropertyListener to the Listeners list. Whenever the value of target parameters like HostName, targetPort gets changed,SnmpPropertyChangeEvent will be sent to all the registered listeners in this list.

Parameters:
l - an instance of SnmpPropertyListener to be added.
See Also:
SnmpPropertyChangeEvent, SnmpPropertyListener

removeSnmpPropertyListener

public void removeSnmpPropertyListener(SnmpPropertyListener l)
Removes the SnmpPropertyListener from the list.

Parameters:
l - SnmpPropertyListener to be removed.
See Also:
SnmpPropertyListener

addV3HandShakeResultListener

public void addV3HandShakeResultListener(V3HandShakeResultListener l)
v3 only Adds a listener to receive the events when SnmpEngineID discovery and time Synchronization is performed by the method async_create_v3_tables.

Parameters:
l - the V3HandShakeResultListener to be registered for getting events.
See Also:
V3HandShakeResultListener, V3HandShakeResultEvent

removeV3HandShakeListener

public void removeV3HandShakeListener(V3HandShakeResultListener l)
v3 only Removes the listener registered for getting events.

Parameters:
l - the V3HandShakeResultListener to be removed.
See Also:
V3HandShakeResultListener

readFromDatabase

public void readFromDatabase()
                      throws java.sql.SQLException
v3 only This will read the v3table like USmUserTable and SnmpEngineTable from Database after establishing connection

Throws:
java.sql.SQLException - incase of any error during reading from database.

deSerializeUSM

public void deSerializeUSM()
v3 only This will deserialize the v3 tables like USMUserTable and SnmpEngineTable from serialized file if the serilaized file already exists


authenticate

public boolean authenticate(SnmpPDU pdu,
                            java.lang.String community)
This is the SnmpClient method implementation used to authenticate a PDU. Always returns true. Needs to be implemented for callbacks.

Specified by:
authenticate in interface SnmpClient

callback

public boolean callback(SnmpSession session,
                        SnmpPDU pdu,
                        int requestID)
This is the SnmpClient method implementation method that processes and forwards the result.The response returned by the RequestServer will be received by this method. The following ErrorCodes can be set: REQ_TIMEDOUT, SNMP error's defined in ErrorMessages

Specified by:
callback in interface SnmpClient
See Also:
ErrorMessages, getErrorCode(), getErrorString()

debugPrint

public void debugPrint(java.lang.String debugOutput)
This is the SnmpClient method implementation that prints the standard error.

Specified by:
debugPrint in interface SnmpClient

genTimeoutEvent

protected void genTimeoutEvent(SnmpPDU pdu)
Generate the timeout events to the listeners

Overrides:
genTimeoutEvent in class SnmpServer

genEvent

protected void genEvent(SnmpPDU pdu)
Generate the response event to the listeners

Overrides:
genEvent in class SnmpServer

addObjectID

public int addObjectID(java.lang.String s)
Adds an ObjectID specified by string to the existing OID list.

Parameters:
s - the OID to be added
Returns:
the index of the entry added for later reference.

addSnmpOID

public int addSnmpOID(SnmpOID oid)
Adds an SnmpOID to the existing list of OIDs.

Parameters:
oid - SnmpOID to be added.
Returns:
the index of the entry added for later reference.

getObjectID

public java.lang.String getObjectID(int index)
To get the object ID at the specified index

Parameters:
index - the index of the oid in the oidlist array
Returns:
an ObjectID as a string in the format iso.org.dod.internet.. if mibs loaded or as a string in the format .1.3.6.1.. if mibs is not loaded.

getObjectID

public java.lang.String getObjectID()
To get the first object ID from a list of ObjectIDs.

Returns:
the ObjectID as a string

setObjectID

public void setObjectID(java.lang.String s)
Sets the object ID value specified by the string

Parameters:
s - the oid to be set

setObjectID

public void setObjectID(int index,
                        java.lang.String s)
Sets the object ID value specified the string at the given index

Parameters:
index - index in the oidlist where the oid has to be set.
s - the oid that has to be set.

getObjectIDList

public java.lang.String[] getObjectIDList()
To get the list of object IDs.

Returns:
the list of OIDs as a String array.

setObjectIDList

public void setObjectIDList(java.lang.String[] s)
Sets the list of object IDs specified by the string array


getSnmpOID

public SnmpOID getSnmpOID()
To get the first SnmpOID from the list of object IDs.

Returns:
the ObjectID as an SnmpOID.

setSnmpOID

public void setSnmpOID(SnmpOID oid)
Sets the SnmpOID.

Parameters:
oid - SnmpOID to be set.

getSnmpOIDList

public SnmpOID[] getSnmpOIDList()
To get the list of object IDs as an array of SnmpOID instances

Returns:
an array of SnmpOIDs.

setSnmpOIDList

public void setSnmpOIDList(SnmpOID[] list)
To set the list of object IDs given as an array of SnmpOIDs


getTargetHost

public java.lang.String getTargetHost()
To get the SNMP target hostname

Specified by:
getTargetHost in interface CustomizerTemplate
Returns:
the hostname as a String

setTargetHost

public void setTargetHost(java.lang.String s)
To set the SNMP target hostname

Specified by:
setTargetHost in interface CustomizerTemplate
Parameters:
s - target hostname as a String

getTargetPort

public int getTargetPort()
To get the SNMP target port number

Specified by:
getTargetPort in interface CustomizerTemplate
Returns:
the target port.

setTargetPort

public void setTargetPort(int i)
To set the SNMP target port number

Specified by:
setTargetPort in interface CustomizerTemplate
Parameters:
i - the target port number

getCommunity

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

Returns:
the community as a String

setCommunity

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

Parameters:
s - community name

getWriteCommunity

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

Returns:
the write community

setWriteCommunity

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

Parameters:
s - write community to be set.

getTimeout

public int getTimeout()
To get the SNMP target timeout value in Seconds. Default value is 5 seconds.

Returns:
the timeout value in seconds.

setTimeout

public void setTimeout(int i)
To Set the SNMP target timeout value in Seconds. Default value is 5 seconds.


getRetries

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

Returns:
the retries value

setRetries

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

Parameters:
i - retries value

getMaxRepetitions

public int getMaxRepetitions()
v2c and v3 only To get the SNMP target max repetitions value for a getbulk request. Default is 50.

Returns:
the max repetitions value

setMaxRepetitions

public void setMaxRepetitions(int i)
v2c and v3 only To set the SNMP target max repetitions value for a getbulk request. Default is 50.

Parameters:
i - max repetitions

getNonRepeaters

public int getNonRepeaters()
v2c and v3 only To get the SNMP target non-repeaters value for a getbulk request. Default is 0.

Returns:
the non-repeaters value

setNonRepeaters

public void setNonRepeaters(int i)
v2c and v3 only To set the SNMP target non-repeaters value for a getbulk request. Default is 0.

Parameters:
i - non-repeaters value.

getSnmpVersion

public int getSnmpVersion()
v3 only To get the SNMP target SNMP Version. 0 for Version 1 (default) and 1 for Version V2C, 3 for Version 3.

Returns:
the SNMP version

setSnmpVersion

public void setSnmpVersion(int i)
v3 only To set the SNMP target SNMP Version. 0 for Version 1 (default) and 1 for Version V2C, 3 for Version 3.

Specified by:
setSnmpVersion in interface CustomizerTemplate
Parameters:
i - version number

getContextName

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

Returns:
the Context name

setContextName

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

Parameters:
cName - context name to be set

getContextID

public java.lang.String getContextID()
v3 only To get the SNMP V3 contextID

Returns:
the ContextID

setContextID

public void setContextID(java.lang.String ctxtID)
v3 only To set the SNMP V3 contextID

Parameters:
ctxtID - ContextID to be set

getSecurityModel

public int getSecurityModel()
v3 only To get the SNMP V3 securityModel

Returns:
the Security Model

setSecurityModel

public void setSecurityModel(int securityModel)
v3 only To set the SNMP V3 SecurityModel

Parameters:
securityModel - SecurityModel in integer

getPrincipal

public java.lang.String getPrincipal()
v3 only To get the SNMP V3 username

Returns:
the UserName

setPrincipal

public void setPrincipal(java.lang.String uName)
v3 only To set the SNMP V3 username

Specified by:
setPrincipal in interface CustomizerTemplate
Parameters:
uName - UserName to be set

getAuthProtocol

public int getAuthProtocol()
v3 only To get the SNMP V3 AuthProtocol

Returns:
the Authentication Protocol.

setAuthProtocol

public void setAuthProtocol(int protocol)
v3 only To set the SNMP V3 AuthProtocol

Specified by:
setAuthProtocol in interface CustomizerTemplate
Parameters:
protocol - the Authentication Protocol to be set

getAuthPassword

public java.lang.String getAuthPassword()
v3 only To get the SNMP V3 AuthPassword

Returns:
the Authentication Password.

setAuthPassword

public void setAuthPassword(java.lang.String password)
v3 only To set the SNMP V3 AuthPassword

Specified by:
setAuthPassword in interface CustomizerTemplate
Parameters:
password - Authentication Password

getPrivProtocol

public int getPrivProtocol()
v3 only Gets the SNMP V3 privProtocol

Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

setPrivProtocol

public void setPrivProtocol(int privprotocol)
v3 only Sets the SNMP V3 PrivProtocol

Since:
AdventNet SNMP API 4 SP4 ( Release 4.0.4 )

getPrivPassword

public java.lang.String getPrivPassword()
v3 only To get the SNMP V3 PrivPassword

Returns:
the Privacy Password

setPrivPassword

public void setPrivPassword(java.lang.String password)
v3 only To set the SNMP V3 PrivPassword

Specified by:
setPrivPassword in interface CustomizerTemplate
Parameters:
password - Privacy Password

getEngineID

public byte[] getEngineID()
v3 only To get the SNMP V3 engineID value for v3

Returns:
the SNMPV3 engineID as an array of bytes.

setEngineID

public void setEngineID(byte[] engID)
v3 only To set the SNMP V3 engineID value for v3


getSecurityLevel

public java.lang.String getSecurityLevel()
v3 only To get the SNMP V3 SecurityLevel

Returns:
the SecurityLevel

setSecurityLevel

public void setSecurityLevel(byte sLevel)
v3 only To set the SNMP V3 SecurityLevel.The value will be 0 ,1 or 3. For other values, Warning message will be given and it will take the SecurityLevel as 0.

Specified by:
setSecurityLevel in interface CustomizerTemplate
Parameters:
sLevel - the SecurityLevel as a byte value

getErrorString

public java.lang.String getErrorString()
To get the error string from the last request.

Returns:
the error message that gets set during an error

getErrorCode

public int getErrorCode()
To get the error code from the last request.

Returns:
the Error code that gets set during an error

getUserErrorCode

public int getUserErrorCode()
Gets the user defined error code for the last request. The user error code returns the pdu error only if the corresponding user error string is set.

Returns:
the pdu error status in case of error and 0 in case of no pdu error or no error string is added.
Since:
AdventNet SNMP API 4 SP2 ( Release 4.0.2 )

addUserError

public void addUserError(int errorCode,
                         java.lang.String errorString)
This method is used to add user defined error codes and the corresponding error string. If the specified error code already exists then the method overwrites the previous error string with the one currently provided.

Since:
AdventNet SNMP API 4 SP2 ( Release 4.0.2 )

getUserErrorString

public java.lang.String getUserErrorString()
This method is used to get the user defined error string to a specific error code. If the user has not defined any error string to a specific error code then it will return AdventNet specific error string or standard error. If AdventNet specific error code is not available then it returns null.

Since:
AdventNet SNMP API 4 SP2 ( Release 4.0.2 )

getAttemptPartial

public boolean getAttemptPartial()
Deprecated. SnmpRequestServer cannot get the partial data. It is specifically for SnmpTarget bean which does synchronous comm..

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


setAttemptPartial

public void setAttemptPartial(boolean b)
Deprecated. SnmpRequestServer cannot get partial data by enabling the flag. It is specific for SnmpTarget bean which does synchronous comm..

sets the boolean state of whether this target will try to get partial data from an agent if a multiple variable request.


getSendTimeoutEvents

public boolean getSendTimeoutEvents()
To check if the target will send timeout events to registered listeners.

Returns:
boolean value true if Timeout events will be sent to the listeners and false otherwise

setSendTimeoutEvents

public void setSendTimeoutEvents(boolean b)
To set the boolean state of whether this target will send timeout events to registered listeners or not

Parameters:
b - true to send timeout events to listeners and false otherwise

getDebug

public boolean getDebug()
To check if Debug mode is enabled or not

Returns:
true if Debug Mode is enabled and false otherwise

setDebug

public void setDebug(boolean debug)
To enable or disable the Debug mode. If the Debug mode is enabled,then Debug message will get printed and if it is disabled,debug message will not be printed.

Parameters:
debug - true to enable and false to disable.

getMibModules

public java.lang.String getMibModules()
To get the MIBs (/white-space separated list of mib files)that is(/are) loaded in this applet/application

Returns:
the loaded Mib file

setMibModules

public void setMibModules(java.lang.String mibs)
To load the MIB in this applet/application. More than one Mib can be loaded by giving them as a space seperated list.

Parameters:
mibs - Mib to be loaded

getMibOperations

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

Returns:
an instance of MibOperations

addRequest

public int addRequest(RequestEvent e)
To add a request to the already existing requests.

Specified by:
addRequest in interface RequestListener
Parameters:
e - an instance of RequestEvent.
Returns:
the request ID which will be used. The request ID will be generated and managed by the library if you do not speficy it in the event.
See Also:
RequestEvent

sendGetRequest

public int sendGetRequest()
To send a get request for the the SNMP variable identified by the first Object Identifier stored in the SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT,OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if no OID specified earlier or in case of errors. This method returns immediately after sending the Request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetRequest

public int sendGetRequest(SnmpOID oid)
To send a get request for the the SNMP variable identified by specified Object Identifier. The following ErrorCodes can be set: SNMP_NOT_INIT,OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if no OID specified earlier or in case of errors. This method returns immediately after sending the request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetRequestList

public int sendGetRequestList()
To send a get request for the list of SNMP variable bindings identified by the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT, OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. This method returns immediately after sending the request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetRequestList

public int sendGetRequestList(SnmpOID[] oids)
To send a get request for a list of SNMP variables identified by the Object Identifier list. The following ErrorCodes can be set: SNMP_NOT_INIT,OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. This method returns immediately after sending the request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetNextRequest

public int sendGetNextRequest()
To send a getnext request for the SNMP variable identified by the first Object Identifier set in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT, OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. This method returns immediately after sending the request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetNextRequest

public int sendGetNextRequest(SnmpOID oid)
To send a getnext request for the SNMP variable identified by specified Object Identifier. The following ErrorCodes can be set: SNMP_NOT_INIT, OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the Request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetNextRequestList

public int sendGetNextRequestList()
To send a getnext request for a list of SNMP variable bindings identified by the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set SNMP_NOT_INIT, OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the Request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetNextRequestList

public int sendGetNextRequestList(SnmpOID[] oids)
To send a getnext request for a list of SNMP variables identified by the Object Identifier list stored in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT,OID_NOT_SPECIFIED, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the Request.
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequest

public int sendSetRequest(java.lang.String value)
                   throws DataException
To send a set request with the value to be set for the ObjectID This method will fail if MIB with this variable is not loaded or this is not a leaf node in the MIB. Throws DataException if no OID specified earlier or in case of errors. The following ErrorCodes can be set: OID_NOT_SPECIFIED, MIB_NODE_UNAVAIL, OID_NOT_LEAF, ERR_CREATING_VARIABLE, SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the Request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequest

public int sendSetRequest(java.lang.String value,
                          byte type)
                   throws DataException
To send a set request with the value to be set and the type of the variable Throws DataException if no OID specified earlier or in case of errors. The following ErrorCodes can be set: ERR_CREATING_VARIABLE, SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED, SNMP error's defined in ErrorMessages v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the Request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequestVariable

public int sendSetRequestVariable(SnmpVar var)
                           throws DataException
To send a set request to set the specified SnmpVar value for the OID that is set in the SnmpRequestServer instance. The following ErrorCodes can be set SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED,SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
-1 if no OID specified earlier or in case of errors. Returns immediately after sending the Request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequestList

public int sendSetRequestList(java.lang.String[] values)
                       throws DataException
To set the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: ERR_CREATING_VARIABLE, SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED, MIB_NODE_UNAVAIL, OID_NOT_LEAF, ILLEGAL_ARG, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
-1 if no OIDs specified earlier or in case of errors. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequestList

public int sendSetRequestList(java.lang.String[] values,
                              java.lang.String[] oidLists)
                       throws DataException
To set the list of SNMP variable bindings on the agent using the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: ERR_CREATING_VARIABLE, SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED, MIB_NODE_UNAVAIL, OID_NOT_LEAF, ILLEGAL_ARG, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
-1 if no OIDs specified earlier or in case of errors. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequestVariables

public int sendSetRequestVariables(SnmpVar[] values)
                            throws DataException
To send a set request to set the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED,SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
-1 if no OIDs specified earlier or in case of errors. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendSetRequestVariables

public int sendSetRequestVariables(SnmpVar[] values,
                                   java.lang.String[] oidsList)
                            throws DataException
To send a set request to set the list of SNMP variable bindings on the agent, using the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED,SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
-1 if no OIDs specified earlier or in case of errors. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendGetBulkRequestList

public int sendGetBulkRequestList()
v2c and v3 only To send a GetBulk request to get a list of SNMP variable bindings from the agent using the Object Identifier list previously set in this SnmpRequestServer instance. The following ErrorCodes can be set: SNMP_NOT_INIT,SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR,IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED, INVALID_V1_REQ, SNMP error's defined in ErrorMessages v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID. v2c and v3 only @return the request ID, or return -1 if there's an error sending request. Returns immediately after sending the request.

See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendTrap

public void sendTrap(java.lang.String enterprise,
                     java.lang.String agenthost,
                     int genericType,
                     int specificType,
                     long uptime,
                     java.lang.String[] values)
              throws DataException
To send a SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpRequestServer instance, and the values specified. The following ErrorCodes can be set: ERR_CREATING_VARIABLE, SNMP_NOT_INIT, SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR, IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED,MIB_NODE_UNAVAIL, OID_NOT_LEAF, SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

sendTrap

public void sendTrap(SnmpOID enterprise,
                     java.lang.String agenthost,
                     int genericType,
                     int specificType,
                     long uptime,
                     SnmpVar[] values)
              throws DataException
To send a SNMP trap, with parameters specified and variable bindings using object ids from the Object Identifier list previously set in this SnmpRequestServer instance, and the values specified. The following Error Codes can be set: SNMP_NOT_INIT,SESSION_REMOTE_HOST_UNKNOWN, SECURITYEXP_CONNECTING_REMOTE_HOST, IO_ERROR,IP_ADDR_NOT_SPECIFIED, UNKNOWN_ERR, OID_NOT_SPECIFIED,SNMP error's defined in ErrorMessages. v3 only INVALID_CONTEXT_NAME ,INVALID_CONTEXT_ID.

Returns:
the request ID, or return -1 if there's an error sending request. Returns immediately after sending the request.
Throws:
DataException - is thrown if data is invalid
See Also:
ErrorMessages, getErrorCode(), getErrorString()

isSerialize

public boolean isSerialize()
v3 only To check the status of Serialization of v3 tables (USMUserTable and SnmpEngineTable)

Specified by:
isSerialize in interface CustomizerTemplate
Returns:
true if the v3 tables will be serialized and false otherwise.

getErrorResultString

public java.lang.String getErrorResultString(SnmpPDU pdu)
To get the error string associated with the response PDU

Parameters:
pdu - SnmpPDU
Returns:
the Error String

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
Parameters:
e - an instance of PropertyChangeEvent

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 SnmpRequestServer has to redirect the log messages


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.
LogException

removeLogClient

public void removeLogClient()
Removes the Log client that has been registered to redirect the log Messages for this instance.


setBroadCastEnable

public void setBroadCastEnable(boolean broadcast)
Calling this method with a "true" value will indicate that the request is to be sent as a broadcast request.

Parameters:
broadcast - the boolean value which says, whether the request is broadcast.

isBroadCastEnabled

public boolean isBroadCastEnabled()
Returns the current status as to whether broadcasting is enabled/disabled.

Returns:
true if broadcast is enabled, otherwise false.

releaseResources

public void releaseResources()
Though the resources will be cleaned up by the garbage collector, if the application is no more using the SnmpRequestServer 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 object count for that session and api.

Overrides:
releaseResources in class SnmpServer


Copyright (c)ZOHO Corp. 1996-2012