com.adventnet.snmp.snmp2.agent
Class BaseSnmpAgent

java.lang.Object
  extended by com.adventnet.snmp.snmp2.agent.Cache
      extended by com.adventnet.snmp.snmp2.agent.BaseSnmpStore
          extended by com.adventnet.snmp.snmp2.agent.BaseSnmpAgent
All Implemented Interfaces:
PropertyRegistrationListener, SnmpClient, AgentEventListener, java.io.Serializable
Direct Known Subclasses:
SnmpAgent

public class BaseSnmpAgent
extends BaseSnmpStore
implements PropertyRegistrationListener, SnmpClient, java.io.Serializable

This class handles all the SNMP requests by forwarding the requests to SnmpPduRequestListeners which is registered with the Agent

This class implements SnmpClient and adds itself as client to the SnmpSession.Hence if any pdu is received at the session,its clients authenticate is called.If the authenticate passes,then its SnmpClient callback method is called where the SnmpPDU is given for agents processing.

For sending back the response the send method in BaseSnmpAgent is called.

Both SnmpAgent and MicroSnmpAgent extend this class.

See Also:
SnmpAgent, MicroSnmpAgent, #SnmpSession, #SnmpAPI, #SnmpStore, #SnmpClient, Serialized Form

Field Summary
 BaseAclTable aclTable
          The Authentication Control Table associated with this BaseSnmpAgent.
protected  ThreadScheduler AgentScheduler
           
protected  SnmpAPI api
          The API thread associated with the BaseSnmpAgent
(package private)  boolean asyncMode
           
(package private)  AuthenticationListener authListener
           
(package private)  boolean callbackThread
          Used to facilitate CallBacks
(package private)  java.util.Vector communityVector
           
(package private)  UpdateListener communityWriter
           
 AgentSnmpDecoder decoder
           
static int ENABLE_SNMP_AUTHEN_TRAPS
          Static field to enable the Authentication Failure Traps.
(package private)  int errstat
           
(package private)  boolean isAuthTrapsDisabled
           
(package private)  boolean isStartUpTrapDisabled
           
(package private)  int outTraps
           
protected  SnmpPduRequestListener pduRequestHdlr
          listener for the pdu's we receive
protected  int port
           
(package private)  SnmpPDU recdPdu
           
(package private)  RegistrationListener registrationlistener
           
protected static java.util.Hashtable schedulerHash
           
(package private)  SystemGroupInstrument sgl
           
protected  Log snmpLog
           
protected  java.lang.String snmpVersion
           
protected  boolean started
           
 long startTime
          The starttime of the agent
protected  StatusListener statusListener
           
(package private)  BaseSysORTableRequestHandler sysORTableListener
           
(package private)  SystemGroupHandler systemGroupHandler
           
static int TRANSPORT_PROVIDER
          Constant for using the transport provider framework
 BaseSnmpTrapService trapListener
          The BaseSnmpTrapService associated with this BaseSnmpAgent.
(package private)  boolean trapSourceDefault
           
protected  AgentUtil utilities
           
(package private)  boolean v1v2AccessControl
           
protected  int versionInInt
           
(package private)  boolean viewBasedFlag
           
 
Fields inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore
debugLevel, localAddress, oldAddress, oldPort, protocol, session
 
Fields inherited from class com.adventnet.snmp.snmp2.agent.Cache
cache, debug
 
Constructor Summary
BaseSnmpAgent()
          Constructor which initialises the session parameters with default values of
BaseSnmpAgent(int port)
          One argument (port) Constructor which initialises the session parameters with default values of
BaseSnmpAgent(java.lang.String ipAddress)
          One Argument(ipAddress) Constructor which initialises the session parameters with default values of
BaseSnmpAgent(java.lang.String ipAddress, int port)
          Two argument (ipAddress, port) Constructor which initialises the session parameters with default values of
 
Method Summary
 void addAccessListener(AccessListener accessListener)
           
 void addAuthenticationListener(AuthenticationListener authListener)
          This method gets the reference of the SnmpGroup to the BaseSnmpAgent.
protected  boolean addClientAndOpenSession()
           
 void addRegistrationListener(RegistrationListener listener)
          This method registers the RegistrationListener with the BaseSnmpAgent.
 void addSnmpPduRequestListener(SnmpPduRequestListener p1)
          adds a Listener to which the pdu is forwarded.
 void addSnmpSetGroupListener(SnmpSetRequestHandler snmpSetGroupListener)
          The method to hook SnmpSetGroup listener for SNMP V2 compliance
 void addSysORTableListener(BaseSysORTableRequestHandler sysORTableHandler)
          This method registers the BaseSysORTableRequestHandler with the BaseSnmpAgent.
 void addSystemGroupListener(SystemGroupInstrument sysgroupinstru)
          This method registers the SystemGroupInstrument implemented by the user.
 void addTrapRequestListener(TrapRequestListener trapListener)
          This method passes the reference of the BaseSnmpTrapService to the BaseSnmpAgent to send authentication traps under SnmpBasicNotifications Group.
 boolean authenticate(SnmpPDU pdu, java.lang.String community)
          This method is called before the callback and related processing methods are called has a simple checks based on the community of the pdu which has been received.
protected  boolean authenticateReceivedCommunity(SnmpPDU pdu, java.lang.String community)
           
 boolean callback(SnmpSession session, SnmpPDU pdu, int reqid)
          The callback of SnmpClient interface for incoming PDUs which is implemented by this agent.
(package private)  boolean checkManagerAccess(java.lang.String community, java.net.InetAddress pduAddress)
           
protected  boolean checkVersion(SnmpPDU pdu)
           
 ProtocolOptions createProtocolOptions(java.lang.String remoteHost, int remotePort, int localPort)
          This method will be called when by the SnmpSession to get the ProtocolOptions for the transport provider.
protected  StatusEvent createStatusEvent(java.lang.String mes)
          Deprecated.  
 void debugPrint(java.lang.String s)
          To print errors in Error Output stream for debug.
protected  void decodePdu(SnmpPDU pdu)
           
 void disableAuthTraps(boolean disableAuthTraps)
          Method to disable the Authentication Failure Traps Generation when this Agent receives a Request with an invalid community.
 void disableStartUpTrap(boolean disableStartUpTrap)
          Method to disable the StartUp Trap Generation when this Agent Starts.
 void genPort()
          ADDED TO SUPPORT LISTENING ON SPECIFIC ADDRS
 AccessListener getAccessListener()
           
 boolean getAsyncMode()
          Getter of the current process mode .
 java.util.Vector getCommunityVector()
          Getter of the Community Vector
 int getDebugLevel()
          Getter for LoggingLevel.
(package private)  java.util.Vector getInetAddresses(java.lang.String community, java.net.InetAddress pduAddress)
           
 java.lang.String getLocalAddress()
          The localAddress on which the agent is running
 int getMaxThreads()
          Getter of the max threads started for Asynchronous processing.
(package private)  java.lang.String[] getNoAccessCommunities()
          gets the NoAccessCommunities for this agent.
 int getPort()
          The port on which the agent is running
 java.lang.String[] getReadCommunities()
          gets the ReadCommunities for this agent.
 java.lang.String getReadCommunity()
          Getter for the ReadCommunity all the read Communities for this agent
(package private)  RegistrationListener getRegistrationListener()
           
 java.lang.String getSerializeFileName()
          Gets the name of the serialized file which the SnmpAgent uses to configure the V3 settings.
 SnmpGroup getSnmpGroup()
          Getter for the SnmpGroup instance for this agent.
 SnmpVacm getSnmpVacm()
          Gets the VACM information of the v3 snmp agent.
 java.lang.String getSnmpVersion()
          The version on which the agent is running
 SystemGroupInstrument getSystemGroupListener()
          Getter for the SystemGroupInstrument.
 long getUpTime()
          gets the up time of the agent
 boolean getV1v2AccessControl()
          Getter for the v1v2AccessControl boolean.
 java.util.Hashtable getV1v2AccessControlTable()
          Getter for the v1v2AccessControl table.
 boolean getWindowsSubAgent()
          Gets whether the agent is running as standalone agent or as a WindowsSubAgent.
 java.lang.String[] getWriteCommunities()
          gets the WriteCommunities for this agent.
 java.lang.String getWriteCommunity()
          Getter for writeCommunity
(package private)  java.lang.String[] handleGetCommunities(boolean flag)
           
(package private)  java.lang.String[] handleGetCommunities(int access)
           
 boolean handleInformRequest(SnmpSession session, SnmpPDU pdu, int reqid)
          Handler of Inform-request PDU.API users may override this method if they have any particular implementation for inform-request messages.This method here will just print out the inform request message.
(package private)  void handleSetCommunity(java.lang.String community, boolean flag, java.lang.String[] coms)
           
 void incrementSnmpOutTraps()
          This method increments the snmpOutTraps counter whenever a trap is sent.
 boolean isCallbackThread()
          getter for Callback Thread
 boolean isStarted()
          Getter of the agent status.
 boolean isTrapSourceDefault()
          Getter of the TrapSourceDefault flag.
static void killSnmpAgent()
          Method to kill this Agent.
 void removeAuthenticationListener()
          Removes the reference of the SnmpGroup from the agent.
 void removeSnmpClient(SnmpClient client)
          removes the SnmpClient.
 void removeSnmpPduRequestListener(SnmpPduRequestListener p1)
          Removes the Listener registered for this uni-cast bean.
 void removeSysORTableListener()
          Removes the BaseSysORTableRequestHandler from the agent.
 void restartSnmpAgent()
          Restarts the receiver Thread for receiving requests
 boolean restartSnmpAgent(int agentPort)
          Restarts the receiver Thread for receiving requests
protected  boolean scheduleAndProcessRequestEvent(java.lang.Object agent, SnmpPDU pdu)
           
 void send(SnmpPDU newPdu)
          Sends the PDU out from the agent.
 void sendAuthenticationFailureTrap(java.util.Vector varbindVector, boolean isBadCommunity)
          This method is used to send AuthenticationFailureTraps from the SnmpAgent.
 void sendGenericTrap(int trapType, java.util.Vector varbindVector)
          Method to send generic traps.
 boolean setAgentScheduler(ThreadScheduler agent)
          setter for ThreadScheduler , used for sceduling the threads.
 boolean setAsyncMode(boolean mode)
          Allows agent to process the requests asynchronously.
 void setCallbackThread(boolean callbackThread)
          setter for Callback Thread.
 void setCommunityVector(java.util.Vector communityVector)
          Setter for the Communtity Vector
 void setDebugLevel(int debugLevel)
          Setter for debugLevel.
 void setDefaultTrap(boolean isDefault)
          This method switches the trapSource (DEFAULT/TFTABLE) ie, specifies whether the manager to which the trap to be sent must be taken from TFTABLE / DEFAULT.
protected  void setEnableAuthenTraps()
          Method added to enable the Authentication Failure traps in the SnmpGroup.
 void setLocalAddress(java.lang.String localAddress)
          The localAddress on which the agent is going to listen for requests on.
 boolean setMaxThreads(int noOfThreads)
          Setter for the number of threads to be started for asynchronous processing .
 void setPort(int port)
          The port on which the agent is going to run.
 void setPort(int port, boolean restart)
          The port on which the agent is going to run.
 void setProtocol(int protocol)
          To set the protocol to be used by the session.
 void setReadCommunities(java.lang.String[] communities)
          sets the ReadCommunities for this agent
 void setReadCommunity(java.lang.String community)
          sets the ReadCommunity for this agent
 void setSerializeFileName(java.lang.String filename)
          Sets the name of the serialized file which the SnmpAgent uses to configure the V3 settings.
 void setSnmpVersion(java.lang.String snmpVersion)
          The version in which the agent is going to run.
 void setSnmpVersion(java.lang.String snmpVersion, boolean restart)
          The version in which the agent is going to run.
 void setStarted(boolean flag)
          Setter of the agent status.
 void setV1v2AccessControl(boolean v1v2AccessControl)
          Setter for the v1v2 View Based AccessControl boolean.
 void setV1v2AccessControlTable(java.util.Hashtable v1v2AccessControlTable)
          Setter for the v1v2AccessControl table.
 void setWarmStart(boolean warmStart)
          Hook method to send warmStart trap.
 void setWriteCommunities(java.lang.String[] communities)
          set the WriteCommunities for this agent
 void setWriteCommunity(java.lang.String community)
          set the WriteCommunity all the read Communities for this agent
 void stopSnmpAgent()
          Stops the receiver Thread and closes the socket used by this agent.
 
Methods inherited from class com.adventnet.snmp.snmp2.agent.BaseSnmpStore
closeAll, finalize, getSnmpAPI, getSnmpSession, getSnmpSession, initSession, initSnmpStore, isAlive, isDebug, setDebug
 
Methods inherited from class com.adventnet.snmp.snmp2.agent.Cache
getFromCache, getMibOperations, putInCache, setMibOperations
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

api

protected transient SnmpAPI api
The API thread associated with the BaseSnmpAgent


decoder

public AgentSnmpDecoder decoder

ENABLE_SNMP_AUTHEN_TRAPS

public static final int ENABLE_SNMP_AUTHEN_TRAPS
Static field to enable the Authentication Failure Traps.

See Also:
Constant Field Values

isStartUpTrapDisabled

boolean isStartUpTrapDisabled

isAuthTrapsDisabled

boolean isAuthTrapsDisabled

asyncMode

boolean asyncMode

AgentScheduler

protected ThreadScheduler AgentScheduler

schedulerHash

protected static java.util.Hashtable schedulerHash

startTime

public long startTime
The starttime of the agent


aclTable

public BaseAclTable aclTable
The Authentication Control Table associated with this BaseSnmpAgent.


snmpLog

protected Log snmpLog

errstat

int errstat

recdPdu

transient SnmpPDU recdPdu

versionInInt

protected int versionInInt

snmpVersion

protected java.lang.String snmpVersion

callbackThread

boolean callbackThread
Used to facilitate CallBacks


utilities

protected AgentUtil utilities

pduRequestHdlr

protected SnmpPduRequestListener pduRequestHdlr
listener for the pdu's we receive


started

protected boolean started

TRANSPORT_PROVIDER

public static final int TRANSPORT_PROVIDER
Constant for using the transport provider framework

See Also:
Constant Field Values

port

protected int port

communityVector

java.util.Vector communityVector

communityWriter

UpdateListener communityWriter

statusListener

protected StatusListener statusListener

authListener

AuthenticationListener authListener

trapListener

public BaseSnmpTrapService trapListener
The BaseSnmpTrapService associated with this BaseSnmpAgent.


trapSourceDefault

boolean trapSourceDefault

systemGroupHandler

SystemGroupHandler systemGroupHandler

registrationlistener

RegistrationListener registrationlistener

sgl

SystemGroupInstrument sgl

sysORTableListener

BaseSysORTableRequestHandler sysORTableListener

outTraps

int outTraps

viewBasedFlag

boolean viewBasedFlag

v1v2AccessControl

boolean v1v2AccessControl
Constructor Detail

BaseSnmpAgent

public BaseSnmpAgent()
Constructor which initialises the session parameters with default values of

Read/Write Community = "public"

It starts agent at a random port.

See Also:
BaseSnmpAgent(String ipAddress, int port), BaseSnmpAgent(String ipAddress), BaseSnmpAgent(int port), BaseSnmpStore()

BaseSnmpAgent

public BaseSnmpAgent(java.lang.String ipAddress)
One Argument(ipAddress) Constructor which initialises the session parameters with default values of

Read/Write Community = "public"

It starts agent at a random port and a given ipAddress.

See Also:
BaseSnmpAgent(), BaseSnmpAgent(int port), BaseSnmpAgent(String ipAddress, int port), BaseSnmpStore(String ipAddress)

BaseSnmpAgent

public BaseSnmpAgent(int port)
One argument (port) Constructor which initialises the session parameters with default values of

Read/Write Community = "public"

It starts the agent at the specified port and address.

See Also:
BaseSnmpAgent(), BaseSnmpAgent(String ipAddress), BaseSnmpAgent(String ipAddress, int port), BaseSnmpStore(int port)

BaseSnmpAgent

public BaseSnmpAgent(java.lang.String ipAddress,
                     int port)
Two argument (ipAddress, port) Constructor which initialises the session parameters with default values of

Read/Write Community = "public"

It starts the agent at the specified port and address.

See Also:
BaseSnmpAgent(), BaseSnmpAgent(int port), BaseSnmpAgent(String ipAddress), BaseSnmpStore(String ipAddress, int port)
Method Detail

setAsyncMode

public boolean setAsyncMode(boolean mode)
Allows agent to process the requests asynchronously. To change the mode of process.

Parameters:
mode - process mode(true for asynchronous).
Returns:
process mode
See Also:
getAsyncMode()

setMaxThreads

public boolean setMaxThreads(int noOfThreads)
Setter for the number of threads to be started for asynchronous processing .

Parameters:
int - The number of threads(0 to 20 ).
Returns:
boolean true if number of threads with in the limit.
See Also:
getMaxThreads()

getMaxThreads

public int getMaxThreads()
Getter of the max threads started for Asynchronous processing.

Returns:
the total no of threads started.
See Also:
setMaxThreads(int a)

getAsyncMode

public boolean getAsyncMode()
Getter of the current process mode .

Returns:
true for asynchronous, false for synchronous.
See Also:
setAsyncMode(boolean mode)

setAgentScheduler

public boolean setAgentScheduler(ThreadScheduler agent)
setter for ThreadScheduler , used for sceduling the threads. Used only when Agent is run with Asynchronous Mode.

Parameters:
agent - The ThreadScheduler

getSnmpGroup

public SnmpGroup getSnmpGroup()
Getter for the SnmpGroup instance for this agent.

This object gives the SnmpGroup counter values in RFC1213-MIB instrumented by this agent.

Specified by:
getSnmpGroup in interface PropertyRegistrationListener
Returns:
The SnmpGroup requested.
See Also:
SnmpGroup

getUpTime

public long getUpTime()
gets the up time of the agent

Specified by:
getUpTime in interface PropertyRegistrationListener
Returns:
The uptime of the agent.

setCallbackThread

public void setCallbackThread(boolean callbackThread)
setter for Callback Thread.

When the callbackThread is set to false, the callback method is called in the context of the SnmpSession receiver thread. When callbackThread is set to true, the callback method is invoked in the context of a separate callback thread. API users can set the value of callbackThread based on whether they want callback's to be invoked from a seperate thread or from the SnmpSession receiver thread itself.

Specified by:
setCallbackThread in interface PropertyRegistrationListener
Parameters:
callbackThread - the value to set enable or false the Callback Thread.
See Also:
isCallbackThread(), SnmpCallback

isCallbackThread

public boolean isCallbackThread()
getter for Callback Thread

Specified by:
isCallbackThread in interface PropertyRegistrationListener
Returns:
true if Callback thread is set otherwise false.
See Also:
()

setDebugLevel

public void setDebugLevel(int debugLevel)
Setter for debugLevel.

Used to set the Logging level for agent with different levels defined in Logging.

Parameters:
debugLevel - the value of various Logging level's are.
  • "0" - Disable Logging.
  • "1" - FATAL messages.
  • "2" - ERROR messages.
  • "3" - WARN messages.
  • "4" - INFO messages.
  • "5" - DEBUG messages.
  • "6" - TRACE messages.
    See Also:
    getDebugLevel(), com.adventnet.utilities.logging

  • getDebugLevel

    public int getDebugLevel()
    Getter for LoggingLevel. Used to get the debug level of agent.

    Returns:
    the value of debug level.
    See Also:
    setDebugLevel(int debugLevel)

    debugPrint

    public void debugPrint(java.lang.String s)
    To print errors in Error Output stream for debug.

    Specified by:
    debugPrint in interface SnmpClient
    Parameters:
    s - the debug message

    getRegistrationListener

    RegistrationListener getRegistrationListener()

    send

    public void send(SnmpPDU newPdu)
              throws SnmpException
    Sends the PDU out from the agent. This is an asynchronous send which SnmpPduRequestListeners could use to send back responses.

    Parameters:
    newPdu - the response PDU.
    Throws:
    SnmpException - on send errors or if the session is not alive

    removeSnmpClient

    public void removeSnmpClient(SnmpClient client)
    removes the SnmpClient. Removes the mentioned SnmpClient. These methods are helpful when you decide to have a containment relation (contaning SnmpAgent) in your applications and would like your authenticate or callback to be invoked. For eg:


    class CollectorApp implements SnmpClient {
        BaseSnmpAgent agent ;
        // Rest of initialisation code ommitted for brevity
        public boolean callback(SnmpSession session,SnmpPDU pdu, int reqid){
            collectorProcessing ();
            agent.callback(session,pdu,reqid);
        }
    }


    handleInformRequest

    public boolean handleInformRequest(SnmpSession session,
                                       SnmpPDU pdu,
                                       int reqid)
    Handler of Inform-request PDU.API users may override this method if they have any particular implementation for inform-request messages.This method here will just print out the inform request message.

    Parameters:
    session - The session on which the agent is communicating
    pdu - The received Inform Request SNMP PDU
    reqid - The request ID

    callback

    public boolean callback(SnmpSession session,
                            SnmpPDU pdu,
                            int reqid)
    The callback of SnmpClient interface for incoming PDUs which is implemented by this agent.

    When a pdu reached at the session for which this SnmpAgent is registered as SnmpClient, then the client(here BaseSnmpAgent) callback is called.

    Specified by:
    callback in interface SnmpClient
    Parameters:
    session - the session on which agent is communicating.
    pdu - the Snmp PDU.
    reqid - the value of reqid.

    scheduleAndProcessRequestEvent

    protected boolean scheduleAndProcessRequestEvent(java.lang.Object agent,
                                                     SnmpPDU pdu)

    checkManagerAccess

    boolean checkManagerAccess(java.lang.String community,
                               java.net.InetAddress pduAddress)

    getInetAddresses

    java.util.Vector getInetAddresses(java.lang.String community,
                                      java.net.InetAddress pduAddress)

    decodePdu

    protected void decodePdu(SnmpPDU pdu)

    authenticate

    public boolean authenticate(SnmpPDU pdu,
                                java.lang.String community)
    This method is called before the callback and related processing methods are called has a simple checks based on the community of the pdu which has been received.

    Specified by:
    authenticate in interface SnmpClient
    Parameters:
    pdu - the Snmp PDU.
    community - the value of the community.
    Returns:
    false if the PDU doesnt satisfy authentication mechanism
    See Also:
    SnmpClient

    authenticateReceivedCommunity

    protected boolean authenticateReceivedCommunity(SnmpPDU pdu,
                                                    java.lang.String community)

    addClientAndOpenSession

    protected boolean addClientAndOpenSession()
                                       throws AgentRuntimeException
    Throws:
    AgentRuntimeException

    isStarted

    public boolean isStarted()
    Getter of the agent status.

    Returns:
    true if agent is started otherwise false.
    See Also:
    restartSnmpAgent(), stopSnmpAgent(), setStarted(boolean flag)

    setStarted

    public void setStarted(boolean flag)
    Setter of the agent status.

    Parameters:
    flag - the value to set the agent status.
    See Also:
    restartSnmpAgent(), stopSnmpAgent(), isStarted()

    setProtocol

    public void setProtocol(int protocol)
    To set the protocol to be used by the session. By default is UDP transport. If the protocol value is BaseSnmpAgent.TRANSPORT_PROVIDER then user specified transport protocol provider will be used for SNMP entity communication.

    Parameters:
    protocol - the protocol to be used for transport. To use the user specifed transport layer this param value should be SnmpAgent.TRANSPORT_PROVIDER

    createProtocolOptions

    public ProtocolOptions createProtocolOptions(java.lang.String remoteHost,
                                                 int remotePort,
                                                 int localPort)
    This method will be called when by the SnmpSession to get the ProtocolOptions for the transport provider. This method will be called only when the
    protocol = SnmpAgent.TRANSPORT_PROVIDER.
    API user may override this method to provide their own protocol options. Default implementation is com.adventnet.snmp.snmp2.agent.AgentTcpProtocolOptionsImpl class

    Overrides:
    createProtocolOptions in class BaseSnmpStore
    Parameters:
    remoteHost - the remoteHost name. For agent session this value will be null. For BaseSnmpTrapService session, this has the manager's host name.
    remotePort - the remotePort value. For agent session this value will be 0. For BaseSnmpTrapService session, this has the manager's port number.
    localPort - the port number of the session by which the agent will be started.

    restartSnmpAgent

    public boolean restartSnmpAgent(int agentPort)
                             throws AgentRuntimeException
    Restarts the receiver Thread for receiving requests

    Parameters:
    agentPort - the port number on which the BaseSnmpAgent will run.
    Returns:
    false if unsuccessful
    Throws:
    AgentRuntimeException - if the specified port is already in use.
    See Also:
    BaseSnmpStore.isAlive(), restartSnmpAgent()

    restartSnmpAgent

    public void restartSnmpAgent()
                          throws AgentRuntimeException
    Restarts the receiver Thread for receiving requests

    Throws:
    AgentRuntimeException - if the specified port is already in use.

    stopSnmpAgent

    public void stopSnmpAgent()
    Stops the receiver Thread and closes the socket used by this agent.

    This thread doesn't kill all the threads and sessions.

    See Also:
    BaseSnmpStore

    genPort

    public void genPort()
    ADDED TO SUPPORT LISTENING ON SPECIFIC ADDRS


    setPort

    public void setPort(int port)
                 throws AgentRuntimeException
    The port on which the agent is going to run.

    Parameters:
    port - the udp port number to whcih the SnmpSession is start.
    Throws:
    AgentRuntimeException - if the specified port is already in use.
    See Also:
    getPort()

    setPort

    public void setPort(int port,
                        boolean restart)
                 throws AgentRuntimeException
    The port on which the agent is going to run.

    Parameters:
    port - the udp port number to whcih the SnmpSession is start.
    restart - specifies whether the agent needs to be restarted after setting the port.
    Throws:
    AgentRuntimeException - if the specified port is already in use.
    See Also:
    getPort(), setPort(int port)

    getPort

    public int getPort()
    The port on which the agent is running

    Specified by:
    getPort in interface PropertyRegistrationListener
    Returns:
    the port number
    See Also:
    setPort(int port), setPort(int port, boolean restart)

    setLocalAddress

    public void setLocalAddress(java.lang.String localAddress)
                         throws AgentRuntimeException
    The localAddress on which the agent is going to listen for requests on.

    Parameters:
    localAddress - the udp localAddress number to which the SnmpSession is started.
    Throws:
    AgentRuntimeException - if the specified port is already in use.
    See Also:
    getLocalAddress()

    getLocalAddress

    public java.lang.String getLocalAddress()
    The localAddress on which the agent is running

    Specified by:
    getLocalAddress in interface PropertyRegistrationListener
    Returns:
    the localAddress String
    See Also:
    setLocalAddress(String localAddress)

    setSnmpVersion

    public void setSnmpVersion(java.lang.String snmpVersion)
    The version in which the agent is going to run.

    The values could be either v1,v2 or v2c restart the Agent to get this change into effect.

    Parameters:
    snmpVersion - the version number.
    See Also:
    getSnmpVersion(), setSnmpVersion(String snmpVersion, boolean restart)

    setSnmpVersion

    public void setSnmpVersion(java.lang.String snmpVersion,
                               boolean restart)
    The version in which the agent is going to run.

    The values could be either v1,v2,v2c or v3. restart the Agent to get this change into effect.

    Parameters:
    snmpVersion - the version number.
    restart - specifies whether the agent needs to be restarted after setting the version.
    See Also:
    getSnmpVersion(), setSnmpVersion(String snmpVersion)

    createStatusEvent

    protected StatusEvent createStatusEvent(java.lang.String mes)
    Deprecated. 


    getSnmpVersion

    public java.lang.String getSnmpVersion()
    The version on which the agent is running

    Returns:
    the version number
    See Also:
    setSnmpVersion(String snmpVersion,boolean restart), setSnmpVersion(String snmpVersion)

    checkVersion

    protected boolean checkVersion(SnmpPDU pdu)

    getCommunityVector

    public java.util.Vector getCommunityVector()
    Getter of the Community Vector

    Returns:
    The Community Vector of AclEntryInterface objects.
    See Also:
    setCommunityVector(Vector communityVector)

    setCommunityVector

    public void setCommunityVector(java.util.Vector communityVector)
    Setter for the Communtity Vector

    Parameters:
    communityVector - The Community Vector of AclEntryInterface objects.
    See Also:
    getCommunityVector()

    setReadCommunity

    public void setReadCommunity(java.lang.String community)
    sets the ReadCommunity for this agent

    default value is "public"

    Parameters:
    community - The value for ReadCommunity
    See Also:
    getReadCommunity()

    handleSetCommunity

    void handleSetCommunity(java.lang.String community,
                            boolean flag,
                            java.lang.String[] coms)
                      throws AgentException
    Throws:
    AgentException

    getReadCommunity

    public java.lang.String getReadCommunity()
    Getter for the ReadCommunity all the read Communities for this agent

    Returns:
    the value of ReadCommunity
    See Also:
    setReadCommunity(String community)

    setReadCommunities

    public void setReadCommunities(java.lang.String[] communities)
    sets the ReadCommunities for this agent

    default value is an array of single read community "public"

    Parameters:
    community - the values for ReadCommunities
    See Also:
    getReadCommunities()

    getReadCommunities

    public java.lang.String[] getReadCommunities()
    gets the ReadCommunities for this agent.

    Returns:
    String[] of read communities.

    See Also:
    setWriteCommunities(String[] communities)

    handleGetCommunities

    java.lang.String[] handleGetCommunities(boolean flag)

    handleGetCommunities

    java.lang.String[] handleGetCommunities(int access)

    setWriteCommunity

    public void setWriteCommunity(java.lang.String community)
    set the WriteCommunity all the read Communities for this agent

    default value is "public"

    Parameters:
    writeCommunity - the value for WriteCommunity
    See Also:
    getWriteCommunity()

    getWriteCommunity

    public java.lang.String getWriteCommunity()
    Getter for writeCommunity

    Returns:
    the value of WriteCommunity
    See Also:
    setWriteCommunity(String community)

    setWriteCommunities

    public void setWriteCommunities(java.lang.String[] communities)
    set the WriteCommunities for this agent

    default value is an array of single write community "public"

    Parameters:
    community - the values for WriteCommunities
    See Also:
    getWriteCommunities()

    getWriteCommunities

    public java.lang.String[] getWriteCommunities()
    gets the WriteCommunities for this agent.

    Returns:
    String[] of write communities.

    See Also:
    setWriteCommunities(String[] communities)

    getNoAccessCommunities

    java.lang.String[] getNoAccessCommunities()
    gets the NoAccessCommunities for this agent.

    Returns:
    String[] of NoAccess communities.


    addSnmpPduRequestListener

    public void addSnmpPduRequestListener(SnmpPduRequestListener p1)
                                   throws RegistrationListenerException
    adds a Listener to which the pdu is forwarded.

    Throws:
    RegistrationListenerException - if already there is a SnmpPduRequestListener is registered.

    removeSnmpPduRequestListener

    public void removeSnmpPduRequestListener(SnmpPduRequestListener p1)
    Removes the Listener registered for this uni-cast bean.

    Parameters:
    p1 - The Snmp PDU listener

    addAuthenticationListener

    public void addAuthenticationListener(AuthenticationListener authListener)
    This method gets the reference of the SnmpGroup to the BaseSnmpAgent. It is used to support the authentication trap SnmpBasicNotifications Group.

    Parameters:
    authListener - instance of SnmpGroup.
    See Also:
    removeAuthenticationListener()

    removeAuthenticationListener

    public void removeAuthenticationListener()
    Removes the reference of the SnmpGroup from the agent. The agent will no longer support the authentication traps.

    See Also:
    addAuthenticationListener(AuthenticationListener authListener)

    setDefaultTrap

    public void setDefaultTrap(boolean isDefault)
    This method switches the trapSource (DEFAULT/TFTABLE) ie, specifies whether the manager to which the trap to be sent must be taken from TFTABLE / DEFAULT. In the case of default, the traps can be sent to only one manager and by default , it is Users should set this flag to false to use the TrapForwardingTable. localhost - port number 162.

    Parameters:
    value - The Default option flag, if true the Default option is taken.
    See Also:
    isTrapSourceDefault()

    isTrapSourceDefault

    public boolean isTrapSourceDefault()
    Getter of the TrapSourceDefault flag.

    Returns:
    true if TrapListener uses Default option, false if not.

    addTrapRequestListener

    public void addTrapRequestListener(TrapRequestListener trapListener)
    This method passes the reference of the BaseSnmpTrapService to the BaseSnmpAgent to send authentication traps under SnmpBasicNotifications Group.

    Parameters:
    trapListener - The TrapRequestListener

    addRegistrationListener

    public void addRegistrationListener(RegistrationListener listener)
    This method registers the RegistrationListener with the BaseSnmpAgent. If user wants to add his/her RegistrationListener , this method has to be called to register the RegistrationListener.

    Parameters:
    listener - The Registration Listener

    addSystemGroupListener

    public void addSystemGroupListener(SystemGroupInstrument sysgroupinstru)
    This method registers the SystemGroupInstrument implemented by the user. This method has to be called from the agent if the user wants to implement for the SystemGroup variables.

    Parameters:
    sysgroupinstru - The System Group Instrument
    See Also:
    getSystemGroupListener()

    getSystemGroupListener

    public SystemGroupInstrument getSystemGroupListener()
    Getter for the SystemGroupInstrument.

    Returns:
    the SystemGroupInstrument implemented by the user.
    See Also:
    addSystemGroupListener(SystemGroupInstrument sysgroupinstru)

    addSysORTableListener

    public void addSysORTableListener(BaseSysORTableRequestHandler sysORTableHandler)
    This method registers the BaseSysORTableRequestHandler with the BaseSnmpAgent. Used to support the sysORTable under SystemGroup for Snmp V2/V2c compliance

    Parameters:
    BasesysORTableHandler - The SysORTable RequestHandler
    See Also:
    removeSysORTableListener()

    removeSysORTableListener

    public void removeSysORTableListener()
    Removes the BaseSysORTableRequestHandler from the agent.

    See Also:
    addSysORTableListener(BaseSysORTableRequestHandler sysORTableHandler)

    incrementSnmpOutTraps

    public void incrementSnmpOutTraps()
                               throws AgentSnmpException
    This method increments the snmpOutTraps counter whenever a trap is sent.

    Throws:
    AgentSnmpException - when the increment fails.

    sendAuthenticationFailureTrap

    public void sendAuthenticationFailureTrap(java.util.Vector varbindVector,
                                              boolean isBadCommunity)
    This method is used to send AuthenticationFailureTraps from the SnmpAgent. It also takes care of incrementing the respective SnmpCounter in the API.

    Parameters:
    varbindVector - Vector or trapVarbinds.
    isBadCommunity -

    true - if the agent has been configured for that community.

    false - if there is no such Community in the agent.


    sendGenericTrap

    public void sendGenericTrap(int trapType,
                                java.util.Vector varbindVector)
    Method to send generic traps. Please use sendAuthenticationFailureTrap method to send Authentication Failure Trap.

    Parameters:
    trapType - The generic TrapType.
    varbindVector - The Varbind of the Trap.
    Since:
    AdventNet Agent Toolkit (Java Edition) 4.2 release.
    See Also:
    sendAuthenticationFailureTrap(Vector varbindVector, boolean isBadCommunity)

    setWarmStart

    public void setWarmStart(boolean warmStart)
    Hook method to send warmStart trap. call this method with true before calling restartSnmpAgent.

    Parameters:
    warmStart - The warmStart trap flag.
    Since:
    AdventNet Agent Toolkit (Java Edition) 4.2 release.

    addSnmpSetGroupListener

    public void addSnmpSetGroupListener(SnmpSetRequestHandler snmpSetGroupListener)
    The method to hook SnmpSetGroup listener for SNMP V2 compliance

    Parameters:
    snmpSetGroupListener - The SnmpSetGroup Listener

    killSnmpAgent

    public static void killSnmpAgent()
    Method to kill this Agent. This method clears all the Threads spawned by this Agent.


    setEnableAuthenTraps

    protected void setEnableAuthenTraps()
    Method added to enable the Authentication Failure traps in the SnmpGroup.


    disableStartUpTrap

    public void disableStartUpTrap(boolean disableStartUpTrap)
    Method to disable the StartUp Trap Generation when this Agent Starts. By default StartUp Trap will be sent. Make sure you are calling this before restartSnmpAgent call.

    Parameters:
    disableStartUpTrap - set this flag to true to disable the StartUp Trap generation.

    disableAuthTraps

    public void disableAuthTraps(boolean disableAuthTraps)
    Method to disable the Authentication Failure Traps Generation when this Agent receives a Request with an invalid community. This method will work only if you have not added an AuthenticationListener to this Agent. By default Authentication Traps will be sent.

    Parameters:
    disableAuthTraps - set this flag to true to disable the StartUp Trap generation.

    addAccessListener

    public void addAccessListener(AccessListener accessListener)

    getAccessListener

    public AccessListener getAccessListener()

    getV1v2AccessControl

    public boolean getV1v2AccessControl()
    Getter for the v1v2AccessControl boolean. Specifies whether access control is valid for v1/v2c agent. This flag is used in the View Based Access Control implementation.

    Returns:
    The V1/V2 Access Control Flag
    See Also:
    setV1v2AccessControl(boolean v1v2AccessControl)

    setV1v2AccessControl

    public void setV1v2AccessControl(boolean v1v2AccessControl)
    Setter for the v1v2 View Based AccessControl boolean. User can specify whether access control is valid for v1/v2c agent. This flag is used in the View Based Access Control implementation.
    Example usage :
     super.setV1v2AccessControl(true);
     Hashtable table = new Hashtable();
     table.put("public", new String[]{".1.3.6.1.2.1.1", ".1.3.6.1.4.1.2162.4"});
     super.setV1v2AccessControlTable(table);

    Parameters:
    v1v2AccessControl - boolean spcifying the V1/V2 View Based Access Control
    See Also:
    getV1v2AccessControl()

    getV1v2AccessControlTable

    public java.util.Hashtable getV1v2AccessControlTable()
    Getter for the v1v2AccessControl table. This table key will be the community name and value will be array of String objects(snmp oid). This is used in the View Based Access Control.

    Returns:
    The Hashtable with the V1/V2 Access Control values
    See Also:
    setV1v2AccessControlTable(Hashtable v1v2AccessControlTable)

    setV1v2AccessControlTable

    public void setV1v2AccessControlTable(java.util.Hashtable v1v2AccessControlTable)
    Setter for the v1v2AccessControl table. This table key will be the community name and value will be array of String objects(snmp oid). This Hashtable is used in the View Based Access Control implementation.

    Parameters:
    v1v2AccessControlTable - Hashtable specifying the V1/V2 Access Control values
    See Also:
    getV1v2AccessControlTable()

    getWindowsSubAgent

    public boolean getWindowsSubAgent()
    Description copied from interface: PropertyRegistrationListener
    Gets whether the agent is running as standalone agent or as a WindowsSubAgent.

    Specified by:
    getWindowsSubAgent in interface PropertyRegistrationListener
    Returns:
    True If the agent is a Sub Agent for Windows Agent else False.

    getSerializeFileName

    public java.lang.String getSerializeFileName()
    Description copied from interface: PropertyRegistrationListener
    Gets the name of the serialized file which the SnmpAgent uses to configure the V3 settings.

    Specified by:
    getSerializeFileName in interface PropertyRegistrationListener
    Returns:
    The Serialize File Name.

    setSerializeFileName

    public void setSerializeFileName(java.lang.String filename)
                              throws SnmpException
    Description copied from interface: PropertyRegistrationListener
    Sets the name of the serialized file which the SnmpAgent uses to configure the V3 settings.

    Specified by:
    setSerializeFileName in interface PropertyRegistrationListener
    Parameters:
    filename - The file Name specification.
    Throws:
    SnmpException - This Wraps all the Types of exception thrown while processing this Request.

    getSnmpVacm

    public SnmpVacm getSnmpVacm()
    Description copied from interface: PropertyRegistrationListener
    Gets the VACM information of the v3 snmp agent.

    Specified by:
    getSnmpVacm in interface PropertyRegistrationListener
    Returns:
    The Snmp Vacm Information of the Agent.