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),
UsmDiscoveryBeanauthenticationProtocol, contextEngineId, contextName, privacyProtocol, useAuthentication, usePrivacy, userAuthenticationPassword, userAuthKeyMD5, userAuthKeySHA1, userName, userPrivacyPassword, userPrivKeyMD5, userPrivKeySHA1, usmAgentanyPduExpectingResponse, bindAddr, hostname, hostPort, isDestroyed, maxRecvSize, pduSupport, trapSupport, typeSocketAES_ENCRYPT, Default_ContextName, Default_UserName, DES_ENCRYPT, MD5_PROTOCOL, ProtocolNames, SHA1_PROTOCOL, SNMPv1_Security_Model, SNMPv2c_Security_Model, USM_Security_ModelDEFAULT_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, toStringactivate, 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, stopequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, getBindAddress, getHost, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, sendPacketpublic 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.IOExceptionAbstractSnmpContext.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.IOExceptionAbstractSnmpContext.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.IOExceptionAbstractSnmpContext.AbstractSnmpContext(String, int, String, String),
SnmpContextBasisFace.STANDARD_SOCKET,
SnmpContextBasisFace.TCP_SOCKETpublic 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 SnmpContextBasisFaceaddRequestPduListener in class SnmpContextv3Basisl - The request PDU listenerlcontext - The listening contextjava.io.IOExceptionremoveRequestPduListener(RequestPduListener, ListeningContextPool),
UsmBeingDiscoveredBean,
SnmpContextv3Basis.setUsmAgent(UsmAgent)public void removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws java.io.IOException
removeRequestPduListener in interface SnmpContextBasisFaceremoveRequestPduListener in class AbstractSnmpContextl - The request PDU listenerlcontext - The listening contextjava.io.IOExceptionaddRequestPduListener(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 SnmpContextBasisFaceprocessIncomingPdu in class AbstractSnmpContextDecodingExceptionjava.io.IOExceptionAbstractSnmpContext.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
DecodingExceptionjava.io.IOExceptionprocessIncomingPdu(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
DecodingExceptionjava.io.IOExceptionprocessIncomingPdu(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 SnmpContextBasisFaceclone in class AbstractSnmpContextjava.lang.CloneNotSupportedException - Thrown when the constructor
generates an IOException