com.adventnet.snmp.snmp2.agent
Class PduRequestHandler

java.lang.Object
  extended by com.adventnet.snmp.snmp2.agent.PduRequestHandler
All Implemented Interfaces:
RegistrationListener, SnmpPduRequestListener, AgentEventListener, java.io.Serializable

public class PduRequestHandler
extends java.lang.Object
implements SnmpPduRequestListener, RegistrationListener, java.io.Serializable

This class handles all the SnmpPDU 's got to SnmpAgent retrieves appropriate VarBindRequestListener for a varbind and gives the pdu from the SnmpAgent as VarBindRequestEvent to the appropriate listener.

It is the source for all VarBindRequestEvents. VarBindRequestListener components will register with this class by triggering RegistrationEvents

See Also:
VarBindRequestListener, VarBindRequestEvent, Serialized Form

Field Summary
(package private)  BaseSnmpAgent agent
           
 boolean isRollBack
          boolean specifying the RollBack Support.
(package private)  VarBindRequestListenerManager manager
           
(package private)  java.lang.String presentRoot
           
(package private)  java.lang.String rootOid
           
(package private)  java.util.Vector unProcessedListeners
          Helps support for multi-varbind Events.
(package private)  boolean validCommand
           
 
Constructor Summary
PduRequestHandler()
          No arg Constructor for PduRequestHandler.
 
Method Summary
 void addVarBindRequestListener(VarBindRequestListener pde, java.lang.String key)
          Adds a VarBindRequestListener with a particular OID.
 void addVarBindRequestListener(VarBindRequestListener pde, java.lang.String key, int[] subidList)
          Adds a VarBindRequestListener with a particular OID(key).
(package private)  void cleanMultiVarbindListenerTable(AgentResource agentSource)
           
(package private)  SnmpPDU getBulkRequest(java.util.Vector varbindList, AgentResource agentSource)
           
(package private) static int getMinSize(int[] oid1, int[] oid2)
           
(package private)  SnmpPDU getNextRequest(java.util.Vector varbindList, AgentResource agentSource)
          Handles the GETNEXT_REQ message
(package private)  VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(SnmpVarBind varbind, AgentResource agentSource)
          Get The next VarBindRequestListener Holder for the SnmpVarBind
(package private)  SnmpPDU getRequest(SnmpPDU commingPdu, java.util.Vector varbindList, byte command, AgentResource agentSource)
          The getRequest method handles the getRequest PDU
 java.util.Vector getVarBindRequestListeners()
          This method returns the Vector of VarBindRequestListeners registered with the PduRequestHandler.
 boolean isRootOidChange(java.lang.String commingOID)
          Method to support the RootOID change.
(package private)  boolean isValidErrValue(byte val)
           
(package private)  boolean isValidOid(java.lang.String key)
           
(package private)  void processFailedVarBind(VarBindAndFailure vbFail1, byte command, AgentResource agentSource)
           
(package private)  SnmpVarBind processGetBulk(SnmpVarBind varb, AgentResource agentSource)
          processes the GetBulk Request
(package private)  SnmpVarBind processGetBulkRequest(SnmpVarBind varb, AgentResource agentSource)
           
(package private)  SnmpPDU processGetNextReqMesg(SnmpPDU newPdu, AgentResource agentSource)
          This is where actual processing is done
(package private)  void processGetNextVarBinds(SnmpPDU newPdu, VarBindRequestListenerHolder holder, java.util.Vector varbindList, AgentResource agentSource, boolean forProxyGetNext)
          Process the SNMP GETNEXT request.
(package private)  SnmpPDU processGetReqMesg(SnmpPDU newPdu, AgentResource agentSource)
          This is where actual processing is done
(package private)  SnmpPDU processSetReqMesg(SnmpPDU newPdu, AgentResource agentSource)
          Processes the SNMP Set Request
 void processSnmpPduRequest(SnmpPduRequestEvent p1)
          This method is called by the callback thread of SnmpAgent.
 void registrationPerformed(RegistrationEvent re)
          Method of interface RegistrationListener.
 void removeVarBindRequestListener(java.lang.String oid)
          Removes the VarBindRequestListener with the specified oid.
(package private)  void setErrindex(int err, AgentResource agentSource)
          Setter for errstat used by VarBindRequestListenerHolder
(package private)  void setErrstat(int err, AgentResource agentSource)
          Setter for errstat used by VarBindRequestListenerHolder
(package private)  void setErrstatAndErrIndex(int errstat, int index, AgentResource agentSource)
           
(package private)  void setErrstatAndErrindexForPdu(SnmpPDU pdu, int errstat, int index, AgentResource agentSource)
           
(package private)  void setErrvalue(SnmpVarBind varb1, byte errval)
          Utility method to setErrvalue
(package private)  SnmpPDU setRequest(SnmpPDU commingPdu, java.util.Vector varbindList, byte command, AgentResource agentSource)
           
 void setRollBackEnabled(boolean isRollBack)
          The method for enabling or disabling the rollback functionality.
 void setRootOid(java.lang.String requiredRoot, java.lang.String existingRoot)
          Method to set a User's own OID as the RootOID.
(package private)  void setVarBind(SnmpVarBind varb, int index, SnmpPDU newPdu)
          Accessed mostly PduRequestListenerHolder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

agent

transient BaseSnmpAgent agent

manager

transient VarBindRequestListenerManager manager

unProcessedListeners

java.util.Vector unProcessedListeners
Helps support for multi-varbind Events.

these listeners are processed at the end


isRollBack

public boolean isRollBack
boolean specifying the RollBack Support.


rootOid

java.lang.String rootOid

presentRoot

java.lang.String presentRoot

validCommand

boolean validCommand
Constructor Detail

PduRequestHandler

public PduRequestHandler()
No arg Constructor for PduRequestHandler. Initialises the Varbind registration tree .

Method Detail

registrationPerformed

public void registrationPerformed(RegistrationEvent re)
Method of interface RegistrationListener. Used to register/ unregister a oid(listener) with PduRequestHandler. VarBindRequestListeners interested in subtrees must throw a RegistrationEvent to register for the OIDS received by the dispatcher.

Specified by:
registrationPerformed in interface RegistrationListener
Parameters:
re - the RegistrationEvent to register
See Also:
RegistrationEvent

addVarBindRequestListener

public void addVarBindRequestListener(VarBindRequestListener pde,
                                      java.lang.String key)
                               throws RegistrationListenerException
Adds a VarBindRequestListener with a particular OID.

Parameters:
pde - the listener for the OID.
key - the OID to listen .
Throws:
java.util.TooManyListenersException - if more than one listener try to register the same OID.
RegistrationListenerException

addVarBindRequestListener

public void addVarBindRequestListener(VarBindRequestListener pde,
                                      java.lang.String key,
                                      int[] subidList)
                               throws RegistrationListenerException
Adds a VarBindRequestListener with a particular OID(key).

Parameters:
pde - VarBindRequestListener to be added.
key - String representation of the OID the listener is interested in.
subidlist - int[] of the subidlist under the key are also registered for the same listener.
Throws:
java.util.TooManyListenersException - if there is a listener already registered for this key.
RegistrationListenerException

removeVarBindRequestListener

public void removeVarBindRequestListener(java.lang.String oid)
Removes the VarBindRequestListener with the specified oid.

Parameters:
oid - the OID to remove the listener.

getVarBindRequestListeners

public java.util.Vector getVarBindRequestListeners()
This method returns the Vector of VarBindRequestListeners registered with the PduRequestHandler.

Specified by:
getVarBindRequestListeners in interface SnmpPduRequestListener
Returns:
The Vector of VarBindRequestListeners.
See Also:
VarBindRequestListener

processSnmpPduRequest

public void processSnmpPduRequest(SnmpPduRequestEvent p1)
This method is called by the callback thread of SnmpAgent. After the processing has been done, this method routes the pdu to other methods which handle get and Set commands etc.

In case of multiple agents registered for the this same SnmpPduRequestListener. The flow from this method is made asynchronous such that calls from different agents are not blocked.This is done inorder to facilitate multiple agent in the same JVM.

Specified by:
processSnmpPduRequest in interface SnmpPduRequestListener
Parameters:
p1 - the SnmpPduRequestEvent from SnmpAgent

getRequest

SnmpPDU getRequest(SnmpPDU commingPdu,
                   java.util.Vector varbindList,
                   byte command,
                   AgentResource agentSource)
The getRequest method handles the getRequest PDU


processSetReqMesg

SnmpPDU processSetReqMesg(SnmpPDU newPdu,
                          AgentResource agentSource)
                    throws AgentSnmpException
Processes the SNMP Set Request

Throws:
AgentSnmpException

processGetReqMesg

SnmpPDU processGetReqMesg(SnmpPDU newPdu,
                          AgentResource agentSource)
                    throws AgentSnmpException
This is where actual processing is done

Throws:
AgentSnmpException

processGetNextReqMesg

SnmpPDU processGetNextReqMesg(SnmpPDU newPdu,
                              AgentResource agentSource)
                        throws AgentSnmpException
This is where actual processing is done

Throws:
AgentSnmpException

processGetNextVarBinds

void processGetNextVarBinds(SnmpPDU newPdu,
                            VarBindRequestListenerHolder holder,
                            java.util.Vector varbindList,
                            AgentResource agentSource,
                            boolean forProxyGetNext)
                      throws AgentSnmpException
Process the SNMP GETNEXT request.

Throws:
AgentSnmpException

processGetBulkRequest

SnmpVarBind processGetBulkRequest(SnmpVarBind varb,
                                  AgentResource agentSource)
                            throws AgentSnmpException
Throws:
AgentSnmpException

getNextRequest

SnmpPDU getNextRequest(java.util.Vector varbindList,
                       AgentResource agentSource)
Handles the GETNEXT_REQ message

Parameters:
SnmpPDU -
Returns:
outgoing pdu

getNextVarBindRequestListenerHolder

VarBindRequestListenerHolder getNextVarBindRequestListenerHolder(SnmpVarBind varbind,
                                                                 AgentResource agentSource)
Get The next VarBindRequestListener Holder for the SnmpVarBind


getBulkRequest

SnmpPDU getBulkRequest(java.util.Vector varbindList,
                       AgentResource agentSource)

setRequest

SnmpPDU setRequest(SnmpPDU commingPdu,
                   java.util.Vector varbindList,
                   byte command,
                   AgentResource agentSource)

isValidOid

boolean isValidOid(java.lang.String key)

processGetBulk

SnmpVarBind processGetBulk(SnmpVarBind varb,
                           AgentResource agentSource)
                     throws AgentSnmpException
processes the GetBulk Request

Returns:
Next SnmpVarBind
Throws:
AgentSnmpException - if there is no next Object

isValidErrValue

boolean isValidErrValue(byte val)

processFailedVarBind

void processFailedVarBind(VarBindAndFailure vbFail1,
                          byte command,
                          AgentResource agentSource)

setVarBind

void setVarBind(SnmpVarBind varb,
                int index,
                SnmpPDU newPdu)
Accessed mostly PduRequestListenerHolder


setErrstatAndErrindexForPdu

void setErrstatAndErrindexForPdu(SnmpPDU pdu,
                                 int errstat,
                                 int index,
                                 AgentResource agentSource)

setErrstatAndErrIndex

void setErrstatAndErrIndex(int errstat,
                           int index,
                           AgentResource agentSource)

setErrstat

void setErrstat(int err,
                AgentResource agentSource)
Setter for errstat used by VarBindRequestListenerHolder


setErrindex

void setErrindex(int err,
                 AgentResource agentSource)
Setter for errstat used by VarBindRequestListenerHolder


setErrvalue

void setErrvalue(SnmpVarBind varb1,
                 byte errval)
Utility method to setErrvalue


cleanMultiVarbindListenerTable

void cleanMultiVarbindListenerTable(AgentResource agentSource)

setRollBackEnabled

public void setRollBackEnabled(boolean isRollBack)
The method for enabling or disabling the rollback functionality.

Specified by:
setRollBackEnabled in interface SnmpPduRequestListener
Parameters:
isRollBack - The boolean to enable or disable Rollback.

setRootOid

public void setRootOid(java.lang.String requiredRoot,
                       java.lang.String existingRoot)
Method to set a User's own OID as the RootOID. This is to provide an oppurtunity to use other enterprise MIBS

The required root will be set for the ExistingRoot. The RequiredRoot and the ExistingRoot should be of same length. Requires restart of the SnmpAgent.

Parameters:
requiredRoot - The RootOID required e.g., .1.3.6.1.4.1.2345
existingRoot - The RootOID present e.g., .1.3.6.1.4.1.2162

If the params are as given in the example the RootOID will be changed from .1.3.6.1.4.1.2162 to .1.3.6.1.4.1.2345


isRootOidChange

public boolean isRootOidChange(java.lang.String commingOID)
Method to support the RootOID change. This Method will called while processing any request.

Parameters:
commingOID - The OID for which the Request is received.
Returns:
boolean true if there is a RootOID change set else a false.

getMinSize

static int getMinSize(int[] oid1,
                      int[] oid2)