org.opennms.test
Class trapd

java.lang.Object
  |
  +--org.opennms.test.trapd
All Implemented Interfaces:
SnmpTrapHandler

public class trapd
extends Object
implements SnmpTrapHandler

Implements a sample SNMP trap daemon that listens and prints traps received from remote agents on port 162.

Version:
$Revision: 1.1 $
Author:
Shivakumar C. Patil, Brian Weaver, OpenNMS

Constructor Summary
trapd()
           
 
Method Summary
static void main(String[] args)
          The main routine.
 void snmpReceivedTrap(SnmpTrapSession session, InetAddress agent, int port, SnmpOctetString community, SnmpPduPacket pdu)
          Receives and prints information about SNMPv2c traps.
 void snmpReceivedTrap(SnmpTrapSession session, InetAddress agent, int port, SnmpOctetString community, SnmpPduTrap pdu)
          Receives and prints information about SNMPv1 traps.
 void snmpTrapSessionError(SnmpTrapSession session, int error, Object ref)
          Process session errors.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

trapd

public trapd()
Method Detail

main

public static void main(String[] args)
The main routine. All arguments are ignored. The program will terminate if any error in the trap session occur. However, malformed packets will be discarded in the error handling method of this class.
Parameters:
args - The command line arguments -- IGNORED.

snmpReceivedTrap

public void snmpReceivedTrap(SnmpTrapSession session,
                             InetAddress agent,
                             int port,
                             SnmpOctetString community,
                             SnmpPduPacket pdu)
Receives and prints information about SNMPv2c traps.
Specified by:
snmpReceivedTrap in interface SnmpTrapHandler
Parameters:
session - The Trap Session that received the PDU.
agent - The address of the remote sender.
port - The remote port where the pdu was transmitted from.
community - The decoded community string.
pdu - The decoded V2 trap pdu.

snmpReceivedTrap

public void snmpReceivedTrap(SnmpTrapSession session,
                             InetAddress agent,
                             int port,
                             SnmpOctetString community,
                             SnmpPduTrap pdu)
Receives and prints information about SNMPv1 traps.
Specified by:
snmpReceivedTrap in interface SnmpTrapHandler
Parameters:
session - The Trap Session that received the PDU.
agent - The address of the remote sender.
port - The remote port where the pdu was transmitted from.
community - The decoded community string.
pdu - The decoded V1 trap pdu.

snmpTrapSessionError

public void snmpTrapSessionError(SnmpTrapSession session,
                                 int error,
                                 Object ref)
Process session errors.
Specified by:
snmpTrapSessionError in interface SnmpTrapHandler
Parameters:
session - The trap session in error.
error - The error condition.
ref - The reference object, if any.