| java.lang.Object snmp.SNMPTrapReceiverInterface
SNMPTrapReceiverInterface | public class SNMPTrapReceiverInterface implements Runnable(Code) | | The class SNMPTrapListenerInterface implements a server which listens for trap and inform request
messages sent from remote SNMP entities. The approach is that from version 1 and 2c of SNMP, using no
encryption of data. Communication occurs via UDP, using port 162, the standard SNMP trap port, or an
alternate (non-standard) port supplied in the constructor. This interface can handle both SNMPv1 and
SNMPv2 traps (which have different PDU types), and SNMPv2 Inform Requests.
Applications utilize this class with classes which implement the SNMPTrapListener or SNMPv2TrapListener or
SNMPv2InformRequestListener interfaces. These must provide a processTrap(), processv2Trap() or processInformRequest()
method, and are registered/unregistered with this class through its addv1TrapListener()/removev1TrapListener(),
addv2TrapListener()/removev2TrapListener(), or addv2InformRequestListener()/removev2InformRequestListener()
methods.
|
Constructor Summary | |
public | SNMPTrapReceiverInterface() Construct a new trap receiver object to receive traps from remote SNMP hosts. | public | SNMPTrapReceiverInterface(PrintWriter errorReceiver) Construct a new trap receiver object to receive traps from remote SNMP hosts. | public | SNMPTrapReceiverInterface(int trapReceivePort) Construct a new trap receiver object to receive traps from remote SNMP hosts. | public | SNMPTrapReceiverInterface(PrintWriter errorReceiver, int trapReceivePort) Construct a new trap receiver object to receive traps from remote SNMP hosts.
This version will accept messages from all hosts using any community name. |
SNMP_TRAP_PORT | final public static int SNMP_TRAP_PORT(Code) | | |
SNMPTrapReceiverInterface | public SNMPTrapReceiverInterface() throws SocketException(Code) | | Construct a new trap receiver object to receive traps from remote SNMP hosts.
Uses the standard SNMP trap reception port 162, and System.out to report errors.
|
SNMPTrapReceiverInterface | public SNMPTrapReceiverInterface(PrintWriter errorReceiver) throws SocketException(Code) | | Construct a new trap receiver object to receive traps from remote SNMP hosts.
Uses the specified Writer to deliver error messages, and the standard SNMP trap
port 162.
|
SNMPTrapReceiverInterface | public SNMPTrapReceiverInterface(int trapReceivePort) throws SocketException(Code) | | Construct a new trap receiver object to receive traps from remote SNMP hosts.
Uses the specified port for trap reception, and System.out to report errors.
|
SNMPTrapReceiverInterface | public SNMPTrapReceiverInterface(PrintWriter errorReceiver, int trapReceivePort) throws SocketException(Code) | | Construct a new trap receiver object to receive traps from remote SNMP hosts.
This version will accept messages from all hosts using any community name. Uses the
specified Writer to deliver error messages and the specified port to listen on.
|
getReceiveBufferSize | public int getReceiveBufferSize()(Code) | | Returns the current size of the buffer used to receive packets.
|
run | public void run()(Code) | | The run() method for the trap interface's listener. Just waits for trap or inform messages to
come in on port 162, then dispatches the recieved PDUs to each of the registered
listeners by calling their processTrap() or processInform() methods.
|
setErrorReceiver | public void setErrorReceiver(PrintWriter errorReceiver)(Code) | | Set the specified PrintWriter to receive error messages.
|
setReceiveBufferSize | public void setReceiveBufferSize(int receiveBufferSize)(Code) | | Set the size of the buffer used to receive response packets. RFC 1157 stipulates that an SNMP
implementation must be able to receive packets of at least 484 bytes, so if you try to set the
size to a value less than this, the receive buffer size will be set to 484 bytes. In addition,
the maximum size of a UDP packet payload is 65535 bytes, so setting the buffer to a larger size
will just waste memory. The default value is 512 bytes. The value may need to be increased if
get-requests are issued for multiple OIDs.
|
startReceiving | public void startReceiving()(Code) | | Start listening for trap and inform messages.
|
stopReceiving | public void stopReceiving() throws SocketException(Code) | | Stop listening for trap and inform messages.
|
|
|