public class SnmpContextv3 extends SnmpContextv3Basis
Now that the stack can send traps and receive requests, it needs to be able to act as an authoritative SNMP engine. This is done via the interface UsmAgent. The DefaultUsmAgent is not guaranteed to work; agents (or rather authoritative engines) should provide a better implementation.
This class adds a UsmBeingDiscoveredBean as listener. This bean handles any incoming discovery PDU. Only when acting as authoritative engine should there be any discovery PDU.
SnmpContextv3Face
,
SnmpContextv3Pool
,
TimeWindow
,
DefaultUsmAgent
,
UsmAgent
,
SnmpContextv3Basis.setUsmAgent(UsmAgent)
,
UsmDiscoveryBean
authenticationProtocol, contextEngineId, contextName, privacyProtocol, useAuthentication, usePrivacy, userAuthenticationPassword, userAuthKeyMD5, userAuthKeySHA1, userName, userPrivacyPassword, userPrivKeyMD5, userPrivKeySHA1, usmAgent
anyPduExpectingResponse, bindAddr, hostname, hostPort, isDestroyed, maxRecvSize, pduSupport, trapSupport, typeSocket
AES_ENCRYPT, Default_ContextName, Default_UserName, DES_ENCRYPT, MD5_PROTOCOL, ProtocolNames, SHA1_PROTOCOL, SNMPv1_Security_Model, SNMPv2c_Security_Model, USM_Security_Model
DEFAULT_PORT, MAXPDU, MSS, STANDARD_SOCKET, TCP_SOCKET
Constructor and Description |
---|
SnmpContextv3(java.lang.String host,
int port)
Constructor.
|
SnmpContextv3(java.lang.String host,
int port,
java.lang.String typeSocketA)
Constructor.
|
SnmpContextv3(java.lang.String host,
int port,
java.lang.String bindAddress,
java.lang.String typeSocketA)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addRequestPduListener(RequestPduListener l,
ListeningContextPool lcontext)
Makes sure the UsmBeingDiscoveredBean is added as RequestPduListener,
so that discovery requests are handled.
|
java.lang.Object |
clone()
Returns a clone of this SnmpContextv3.
|
Pdu |
processIncomingPdu(byte[] message)
Processes an incoming PDU, that is not a Discovery PDU.
|
Pdu |
processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu,
uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq,
byte[] message)
Processes an incoming PDU, to see if it is a Request.
|
Pdu |
processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu,
uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq,
byte[] message)
Processes an incoming PDU, to see if it is a Trap.
|
void |
removeRequestPduListener(RequestPduListener l,
ListeningContextPool lcontext)
Removes the UsmBeingDiscoveredBean as listener.
|
actualEncodePacket, addDiscoveryPdu, addPdu, addPdu, checkContextSanity, cloneParameters, createUsmAgent, encodeDiscoveryPacket, encodePacket, getAuthenticationProtocol, getContextEngineId, getContextName, getHashKey, getPrivacyProtocol, getUserAuthenticationPassword, getUserName, getUserPrivacyPassword, getUsmAgent, getVersion, isAuthoritative, isUseAuthentication, isUsePrivacy, processIncomingResponse, removePdu, setAuthenticationProtocol, setContextEngineId, setContextName, setPrivacyProtocol, setUseAuthentication, setUsePrivacy, setUserAuthenticationPassword, setUserName, setUserPrivacyPassword, setUsmAgent, toString
activate, addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, freeTransmitters, getBindAddress, getDebugString, getHost, getHostAddress, getMaxRecvSize, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, rawPduReceived, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, run, sendPacket, setMaxRecvSize, stop
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, getBindAddress, getHost, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, sendPacket
public SnmpContextv3(java.lang.String host, int port) throws java.io.IOException
host
- The host to which the PDU will be sentport
- The port where the SNMP server will bejava.io.IOException
AbstractSnmpContext.AbstractSnmpContext(String, int)
public SnmpContextv3(java.lang.String host, int port, java.lang.String typeSocketA) throws java.io.IOException
host
- The host to which the Pdu will be sentport
- The port where the SNMP server will betypeSocketA
- The local address the server will bind tojava.io.IOException
AbstractSnmpContext.AbstractSnmpContext(String, int, String)
public SnmpContextv3(java.lang.String host, int port, java.lang.String bindAddress, java.lang.String typeSocketA) throws java.io.IOException
host
- The host to which the PDU will be sentport
- The port where the SNMP server will bebindAddress
- The local address the server will bind totypeSocketA
- The type of socket to use.java.io.IOException
AbstractSnmpContext.AbstractSnmpContext(String, int, String, String)
,
SnmpContextBasisFace.STANDARD_SOCKET
,
SnmpContextBasisFace.TCP_SOCKET
public void addRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws java.io.IOException
Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.
addRequestPduListener
in interface SnmpContextBasisFace
addRequestPduListener
in class SnmpContextv3Basis
l
- The request PDU listenerlcontext
- The listening contextjava.io.IOException
removeRequestPduListener(RequestPduListener, ListeningContextPool)
,
UsmBeingDiscoveredBean
,
SnmpContextv3Basis.setUsmAgent(UsmAgent)
public void removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws java.io.IOException
removeRequestPduListener
in interface SnmpContextBasisFace
removeRequestPduListener
in class AbstractSnmpContext
l
- The request PDU listenerlcontext
- The listening contextjava.io.IOException
addRequestPduListener(RequestPduListener, ListeningContextPool)
public Pdu processIncomingPdu(byte[] message) throws DecodingException, java.io.IOException
This method calls first processPotentialTrap and then processPotentialRequest. The reason this code is split up is because in one case the stack acts as authoritative engine and as non authoritative engine in the other..
processIncomingPdu
in interface SnmpContextBasisFace
processIncomingPdu
in class AbstractSnmpContext
DecodingException
java.io.IOException
AbstractSnmpContext.rawPduReceived(uk.co.westhawk.snmp.event.RawPduEvent)
,
processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])
,
processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])
public Pdu processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu, uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq, byte[] message) throws DecodingException, java.io.IOException
DecodingException
java.io.IOException
processIncomingPdu(byte[])
,
processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])
public Pdu processPotentialRequest(uk.co.westhawk.snmp.stack.AsnDecoderv3 rpdu, uk.co.westhawk.snmp.stack.AsnSequence asnTopSeq, byte[] message) throws DecodingException, java.io.IOException
DecodingException
java.io.IOException
processIncomingPdu(byte[])
,
processPotentialTrap(uk.co.westhawk.snmp.stack.AsnDecoderv3, uk.co.westhawk.snmp.stack.AsnSequence, byte[])
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in interface SnmpContextBasisFace
clone
in class AbstractSnmpContext
java.lang.CloneNotSupportedException
- Thrown when the constructor
generates an IOException