com.sun.jaw.impl.adaptor.snmp
Class AdaptorServerImpl

java.lang.Object
  |
  +--com.sun.jaw.impl.adaptor.generic.AdaptorServer
        |
        +--com.sun.jaw.impl.adaptor.snmp.AdaptorServerImpl

public class AdaptorServerImpl
extends AdaptorServer
implements SnmpDefinitions, SnmpMibHandlerSrvIf

The AdaptorServerImpl class implements an adaptor on top of the SNMP protocol.

When this adaptor is started it creates a datagram socket and is able to receive requests and send traps. When it is stopped, the socket is closed and no requests and no traps are processed.

The default port number of the socket is 161. This default value can be changed by specifying a port number in :

For instance, if you want to use port 44450, you can specify the following object name:

The SNMP adaptor supports versions 1 and 2 of the SNMP protocol in a stateless way : when it receives an v1 request, it replies with a v1 response, when it receives a v2 request it replies with a v2 response. The method sendTrap sends traps using SNMP v1 format. The method sendV2Trapsends traps using SNMP v2 format.

To receive data packets, the SNMP adaptor uses a buffer whose size can be configured using the property bufferSize (default value is 1024). Packets which does not fit in buffer are rejected. Increasing bufferSize allows to exchange bigger packets. However the underlying networking system may impose a limit on the size of UDP packets. Packets bigger than this limit will rejected too, no matter the value of bufferSize.

See Also:
Serialized Form

Fields inherited from class com.sun.jaw.impl.adaptor.generic.AdaptorServer
cmf, maxActiveClientCount, objectName, OFFLINE, ONLINE, port, STARTING, state, STOPPING
 
Constructor Summary
AdaptorServerImpl()
          Initializes this AdaptorServerImpl using the default port (161).
AdaptorServerImpl(int p)
          Initializes this AdaptorServerImpl using the specified port.
AdaptorServerImpl(IPAclSrvIf acl)
          Initializes this AdaptorServerImpl using the default port (161)and the specified IPAclSrvIf implementation.
AdaptorServerImpl(IPAclSrvIf acl, int p)
          Initializes this AdaptorServerImpl using the specified port and the specified IPAclSrvIf implementation.
 
Method Summary
 boolean getAuthRespEnabled()
          Returns true if this AdaptorServerImpl sends a response in case of authentication failure.
 boolean getAuthTrapEnabled()
          Returns true if authentication traps are enabled.
 java.lang.Integer getBufferSize()
          Returns the buffer size of this AdaptorServerImpl.
 java.lang.String getClassVersion()
          Returns the version of this class.
 java.lang.String getEnterpriseOid()
          Returns the enterprise oid.
 java.lang.String[] getMibs()
          Returns the names of the MIB available in the adaptor.
 java.lang.Integer getPort()
          Returns the port used by this AdaptorServerImpl.
 java.lang.String getProtocol()
          Returns the protocol of this AdaptorServerImpl.
 java.lang.Long getSnmpInASNParseErrs()
           
 java.lang.Long getSnmpInBadCommunityNames()
           
 java.lang.Long getSnmpInBadCommunityUses()
           
 java.lang.Long getSnmpInBadVersions()
           
 java.lang.Long getSnmpInGetNexts()
           
 java.lang.Long getSnmpInGetRequests()
           
 java.lang.Long getSnmpInPkts()
           
 java.lang.Long getSnmpInSetRequests()
           
 java.lang.Long getSnmpInTotalReqVars()
           
 java.lang.Long getSnmpInTotalSetVars()
           
 java.lang.Long getSnmpOutBadValues()
           
 java.lang.Long getSnmpOutGenErrs()
           
 java.lang.Long getSnmpOutGetResponses()
           
 java.lang.Long getSnmpOutNoSuchNames()
           
 java.lang.Long getSnmpOutPkts()
           
 java.lang.Long getSnmpOutTooBigs()
           
 java.lang.Long getSnmpOutTraps()
           
 java.lang.Integer getTrapPort()
          Returns the port used by this AdaptorServerImpl for sending traps.
 void initCmf(Framework f, ObjectName name, boolean db, ModificationList list)
          For Java DMK internal use only.
 boolean isAuthRespEnabled()
          Returns true if this AdaptorServerImpl sends a response in case of authentication failure.
 boolean isAuthTrapEnabled()
          Returns true if authentication traps are enabled.
 void sendTrap(int generic, int specific, java.util.Vector varBindList)
          Sends a trap using SNMP V1 trap format.
 void sendV2Trap(SnmpOid trapOid, java.util.Vector varBindList)
          Sends a trap using SNMP V2 trap format.
 void setAuthRespEnabled(boolean enabled)
          Enables sending of responses in case of authentication failure.
 void setAuthTrapEnabled(boolean enabled)
          Enables sending of traps in case of authentication failure.
 void setBufferSize(java.lang.Integer s)
          Set the buffer size of this AdaptorServerImpl (default 1024).
 void setEnterpriseOid(java.lang.String oid)
          Sets the enterprise oid.
 void setTrapPort(java.lang.Integer v)
          Sets the port used by this AdaptorServerImpl for sending traps.
 void usePduFactory(SnmpPduFactoryIf factory)
          Set the message factory of this AdaptorServerImpl.
 
Methods inherited from class com.sun.jaw.impl.adaptor.generic.AdaptorServer
addAdaptorListener, deleteCmf, getActiveClientCount, getMaxActiveClientCount, getServedClientCount, getState, getStateString, isActive, performStart, performStop, performWaitState, removeAdaptorListener, setMaxActiveClientCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdaptorServerImpl

public AdaptorServerImpl()
Initializes this AdaptorServerImpl using the default port (161).

AdaptorServerImpl

public AdaptorServerImpl(int p)
Initializes this AdaptorServerImpl using the specified port.

AdaptorServerImpl

public AdaptorServerImpl(IPAclSrvIf acl)
Initializes this AdaptorServerImpl using the default port (161)and the specified IPAclSrvIf implementation.

AdaptorServerImpl

public AdaptorServerImpl(IPAclSrvIf acl,
                         int p)
Initializes this AdaptorServerImpl using the specified port and the specified IPAclSrvIf implementation.
Method Detail

getClassVersion

public java.lang.String getClassVersion()
Returns the version of this class.
Returns:
the version of this class.

getPort

public java.lang.Integer getPort()
Returns the port used by this AdaptorServerImpl. This is the port used when creating the UDP socket. Its value is specified at creation time. But it can be changed by initCmf if the ObjectName assigned to the adaptor contains a 'port' key.
Returns:
The port number.
Overrides:
getPort in class AdaptorServer

getTrapPort

public java.lang.Integer getTrapPort()
Returns the port used by this AdaptorServerImpl for sending traps. By default, port 162 is used.
Returns:
The port number.

setTrapPort

public void setTrapPort(java.lang.Integer v)
Sets the port used by this AdaptorServerImpl for sending traps. By default, port 162 is used.

getProtocol

public java.lang.String getProtocol()
Returns the protocol of this AdaptorServerImpl.
Returns:
The string "snmp".
Overrides:
getProtocol in class AdaptorServer

getBufferSize

public java.lang.Integer getBufferSize()
Returns the buffer size of this AdaptorServerImpl.

setBufferSize

public void setBufferSize(java.lang.Integer s)
Set the buffer size of this AdaptorServerImpl (default 1024).

usePduFactory

public void usePduFactory(SnmpPduFactoryIf factory)
Set the message factory of this AdaptorServerImpl.
Parameters:
factory - the factory object (null means the default factory).

isAuthTrapEnabled

public boolean isAuthTrapEnabled()
Returns true if authentication traps are enabled.

When this feature is enabled, the AdaptorServerImpl sends an authenticationFailure trap each time an authentication fails.

The default behaviour is to send authentication traps.

Returns:
true if authentication traps are enable.

getAuthTrapEnabled

public boolean getAuthTrapEnabled()
Returns true if authentication traps are enabled.

When this feature is enabled, the AdaptorServerImpl sends an authenticationFailure trap each time an authentication fails.

The default behaviour is to send authentication traps.

Returns:
true if authentication traps are enable.

setAuthTrapEnabled

public void setAuthTrapEnabled(boolean enabled)
Enables sending of traps in case of authentication failure.
Parameters:
enabled - true if traps need to be sent.
See Also:
isAuthTrapEnabled()

isAuthRespEnabled

public boolean isAuthRespEnabled()
Returns true if this AdaptorServerImpl sends a response in case of authentication failure.

When this feature is enabled, the adaptor sends a response with noSuchName or readOnly when the authentication failed. If the flag is disable, the adaptor trashes the pdu silently.

The default behavior is to send responses.

Returns:
true if responses are sent

getAuthRespEnabled

public boolean getAuthRespEnabled()
Returns true if this AdaptorServerImpl sends a response in case of authentication failure.

When this feature is enabled, the adaptor sends a response with noSuchName or readOnly when the authentication failed. If the flag is disable, the adaptor trashes the pdu silently.

The default behavior is to send responses.

Returns:
true if responses are sent

setAuthRespEnabled

public void setAuthRespEnabled(boolean enabled)
Enables sending of responses in case of authentication failure.
Returns:
true if responses must be sent

getMibs

public java.lang.String[] getMibs()
Returns the names of the MIB available in the adaptor.
Returns:
An array of MIB names.

sendTrap

public void sendTrap(int generic,
                     int specific,
                     java.util.Vector varBindList)
              throws java.io.IOException,
                     SnmpStatusException
Sends a trap using SNMP V1 trap format. The trap is sent to each destination defined in the ACL file (if available). If no ACL file or no destinations are available, the trap is sent to the local host.
Specified by:
sendTrap in interface SnmpMibHandlerSrvIf
Parameters:
generic - The generic number of the trap.
specific - The specific number of the trap.
varBindList - A vector of SnmpVarBind instances or null.
Throws:
java.io.IOException - An I/O error occured while sending the traps
SnmpStatusException - If the trap exceeds the limit defined by bufferSize

sendV2Trap

public void sendV2Trap(SnmpOid trapOid,
                       java.util.Vector varBindList)
                throws java.io.IOException,
                       SnmpStatusException
Sends a trap using SNMP V2 trap format. The trap is sent to each destination defined in the ACL file (if available). If no ACL file or no destinations are available, the trap is sent to the local host. The variable list included in the outgoing trap is composed of the following items:
Parameters:
trapOid - The OID identifying the trap.
varBindList - A vector of SnmpVarBind instances or null.
Throws:
java.io.IOException - An I/O error occured while sending the traps
SnmpStatusException - If the trap exceeds the limit defined by bufferSize

getEnterpriseOid

public java.lang.String getEnterpriseOid()
Returns the enterprise oid. It is used by sendTrap to fill the 'enterprise' field of the trap request.
Returns:
The oid in string format "x.x.x.x"

setEnterpriseOid

public void setEnterpriseOid(java.lang.String oid)
                      throws java.lang.IllegalArgumentException
Sets the enterprise oid.
Parameters:
oid - The oid in string format "x.x.x.x"
Throws:
java.lang.IllegalArgumentException - The string format is incorrect

getSnmpOutTraps

public java.lang.Long getSnmpOutTraps()

getSnmpOutGetResponses

public java.lang.Long getSnmpOutGetResponses()

getSnmpOutGenErrs

public java.lang.Long getSnmpOutGenErrs()

getSnmpOutBadValues

public java.lang.Long getSnmpOutBadValues()

getSnmpOutNoSuchNames

public java.lang.Long getSnmpOutNoSuchNames()

getSnmpOutTooBigs

public java.lang.Long getSnmpOutTooBigs()

getSnmpInASNParseErrs

public java.lang.Long getSnmpInASNParseErrs()

getSnmpInBadCommunityUses

public java.lang.Long getSnmpInBadCommunityUses()

getSnmpInBadCommunityNames

public java.lang.Long getSnmpInBadCommunityNames()

getSnmpInBadVersions

public java.lang.Long getSnmpInBadVersions()

getSnmpOutPkts

public java.lang.Long getSnmpOutPkts()

getSnmpInPkts

public java.lang.Long getSnmpInPkts()

getSnmpInGetRequests

public java.lang.Long getSnmpInGetRequests()

getSnmpInGetNexts

public java.lang.Long getSnmpInGetNexts()

getSnmpInSetRequests

public java.lang.Long getSnmpInSetRequests()

getSnmpInTotalSetVars

public java.lang.Long getSnmpInTotalSetVars()

getSnmpInTotalReqVars

public java.lang.Long getSnmpInTotalReqVars()

initCmf

public void initCmf(Framework f,
                    ObjectName name,
                    boolean db,
                    ModificationList list)
             throws InstanceAlreadyExistException
For Java DMK internal use only.

This method add SNMP specific processing to the ancestor initCmf(). It parses the object name to find a port key: if this key is found, its value supersedes the current port number.

Throws:
InstanceAlreadyExistException - The m-bean is already registered in the repository.
Overrides:
initCmf in class AdaptorServer