com.mccrory.scott.spumoni
Class SnmpD

java.lang.Object
  |
  +--com.mccrory.scott.spumoni.SnmpD
All Implemented Interfaces:
org.opennms.protocols.snmp.SnmpAgentHandler

public class SnmpD
extends java.lang.Object
implements org.opennms.protocols.snmp.SnmpAgentHandler

SnmpD implements a sample SNMP daemon. It listens for messages received from remote agents on (default) port 161. It is based on Bob Snider's adaptation of JoeSNMP's TrapD test class, which is a part of the OpenNMS project. Thanks go out to Bob, Brian and the rest of the OpenNMS crew for their excellent work.

Version:
CVS $Id: SnmpD.java,v 1.12 2002/08/04 22:04:53 smccrory Exp $
Author:
Shivakumar C. Patil
, Brian Weaver , OpenNMS , Bob Snider , Scott McCrory

Constructor Summary
SnmpD()
           
 
Method Summary
static void main(java.lang.String[] args)
          The main routine.
 void registerOidHandler(java.lang.String oid, OidHandler oidHandler)
          Register an oid handler to our lookup map.
 void SnmpAgentSessionError(org.opennms.protocols.snmp.SnmpAgentSession session, int error, java.lang.Object ref)
          Process session errors.
 void snmpReceivedPdu(org.opennms.protocols.snmp.SnmpAgentSession session, java.net.InetAddress manager, int port, org.opennms.protocols.snmp.SnmpOctetString community, org.opennms.protocols.snmp.SnmpPduPacket pdu)
          The main method which receives SNMPv2c PDUs and forwards them to their specific handler methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SnmpD

public SnmpD()
Method Detail

main

public static void main(java.lang.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.

registerOidHandler

public void registerOidHandler(java.lang.String oid,
                               OidHandler oidHandler)
Register an oid handler to our lookup map. The oid should be an end value node number.

Parameters:
oid - The oid
oidHandler - The handler for this oid

SnmpAgentSessionError

public void SnmpAgentSessionError(org.opennms.protocols.snmp.SnmpAgentSession session,
                                  int error,
                                  java.lang.Object ref)
Process session errors.

Specified by:
SnmpAgentSessionError in interface org.opennms.protocols.snmp.SnmpAgentHandler
Parameters:
session - The trap session in error.
error - The error condition.
ref - The reference object, if any.

snmpReceivedPdu

public void snmpReceivedPdu(org.opennms.protocols.snmp.SnmpAgentSession session,
                            java.net.InetAddress manager,
                            int port,
                            org.opennms.protocols.snmp.SnmpOctetString community,
                            org.opennms.protocols.snmp.SnmpPduPacket pdu)
The main method which receives SNMPv2c PDUs and forwards them to their specific handler methods.

Specified by:
snmpReceivedPdu in interface org.opennms.protocols.snmp.SnmpAgentHandler
Parameters:
session - The Session that received the PDU.
manager - 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 pdu.


Copyright © 2002 Scott McCrory as part of the Spumoni project. All Rights Reserved.