|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.opennms.protocols.snmp.SnmpTrapSession
The trap session is used to send and receives SNMPv1 & v2 trap messages. The messages are received on the configured port, or the default(162) port and then decoded using the set ASN.1 codec. When messages are sent they are encoded using the passed SnmpParameters object that is part of the SnmpPeer object.
A trap message handler must be bound to the session in order to send or receive messages.
SnmpTrapHandler| Field Summary | |
static int |
DEFAULT_PORT
This is the default port where traps should be sent and received as defined by the RFC. |
static int |
ERROR_EXCEPTION
Defines a error due to a thown exception. |
static int |
ERROR_INVALID_PDU
Defines an error condition with an invalid PDU. |
| Constructor Summary | |
SnmpTrapSession(SnmpTrapHandler handler)
The default SnmpTrapSession constructor. |
|
SnmpTrapSession(SnmpTrapHandler handler,
int port)
The default SnmpTrapSession constructor that takes a packet handler as parameter. |
|
| Method Summary | |
void |
close()
Used to close the session. |
org.opennms.protocols.snmp.asn1.AsnEncoder |
getAsnEncoder()
Gets the AsnEncoder for the session. |
SnmpTrapHandler |
getHandler()
Returns the trap handler for this trap session. |
boolean |
isClosed()
Returns true if the close method has
been called. |
void |
raise()
If an exception occurs in the SNMP receiver thread then raise() will rethrow the exception. |
void |
send(SnmpPeer peer,
SnmpPduPacket pdu)
Transmits the specified SnmpRequest to the SnmpPeer defined. |
void |
send(SnmpPeer peer,
SnmpPduTrap trap)
Transmits the specified SnmpPduTrap to the SnmpPeer defined The SnmpPduTrap is encoded using the peer AsnEncoder, as defined by the SnmpParameters. |
void |
setAsnEncoder(org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
Sets the default encoder. |
void |
setHandler(SnmpTrapHandler hdl)
Sets the trap handler for the session. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final int ERROR_EXCEPTION
Defines a error due to a thown exception. When the snmpTrapSessionError method is invoked in the trap handler, the exception object is passed as the ref parameter.
SnmpTrapHandler.snmpTrapSessionError(org.opennms.protocols.snmp.SnmpTrapSession, int, java.lang.Object),
Constant Field Valuespublic static final int ERROR_INVALID_PDU
Defines an error condition with an invalid PDU. For the moment this is not actually used, but reserved for future use. When the session trap handler error method is invoke the pdu in error should be passed as the ref parameters
SnmpTrapHandler.snmpTrapSessionError(org.opennms.protocols.snmp.SnmpTrapSession, int, java.lang.Object),
Constant Field Valuespublic static final int DEFAULT_PORT
| Constructor Detail |
public SnmpTrapSession(SnmpTrapHandler handler)
throws java.net.SocketException
handler - The handler associated for message processing.
java.net.SocketException - If thrown it is from the creation
of a DatagramSocket.
java.lang.SecurityException - Thrown if the security manager
disallows the creation of the handler.
public SnmpTrapSession(SnmpTrapHandler handler,
int port)
throws java.net.SocketException
java.net.SocketException - If thrown it is from the creation
of a DatagramSocket.| Method Detail |
public SnmpTrapHandler getHandler()
public void setHandler(SnmpTrapHandler hdl)
hdl - The new packet handlerpublic void setAsnEncoder(org.opennms.protocols.snmp.asn1.AsnEncoder encoder)
encoder - The new encoderpublic org.opennms.protocols.snmp.asn1.AsnEncoder getAsnEncoder()
public boolean isClosed()
close method has
been called. The session cannot be used to send
request after close has been executed.
public void close()
java.lang.IllegalStateException - Thrown if the session was already closed.
public void raise()
throws java.lang.Throwable
java.lang.Throwable - The base for thrown
exceptions.
public void send(SnmpPeer peer,
SnmpPduTrap trap)
throws SnmpPduEncodingException,
org.opennms.protocols.snmp.asn1.AsnEncodingException,
java.io.IOException
peer - The remote peer to send to.trap - The SnmpPduTrap to transmit
SnmpPduEncodingException - Thrown if an encoding exception
occurs at the session level
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown
if an encoding exception occurs in the AsnEncoder object.
java.io.IOException - Thrown if an error occurs sending the
encoded datagram
java.lang.IllegalStateException - Thrown if the session has been closed.SnmpRequest,
SnmpParameters,
SnmpPeer
public void send(SnmpPeer peer,
SnmpPduPacket pdu)
throws SnmpPduEncodingException,
org.opennms.protocols.snmp.asn1.AsnEncodingException,
java.io.IOException
peer - The remote peer to send to.pdu - The pdu to transmit
SnmpPduEncodingException - Thrown if an encoding exception
occurs at the session level
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown
if an encoding exception occurs in the AsnEncoder object.
java.io.IOException - Thrown if an error occurs sending the
encoded datagram
java.lang.IllegalStateException - Thrown if the session has been closed.SnmpRequest,
SnmpParameters,
SnmpPeer
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||