OpenNMS API 1.2.9

## org.opennms.netmgt.trapd
Class TrapQueueProcessor

    java.lang.Object
      org.opennms.netmgt.trapd.TrapQueueProcessor

All Implemented Interfaces:
  Fiber, PausableFiber, java.lang.Runnable

class TrapQueueProcessor
extends java.lang.Object
implements java.lang.Runnable, PausableFiber

The TrapQueueProcessor handles the conversion of V1 and V2 traps to events and sending them out the JSDT channel that eventd is listening on

Author:
  Brian Weaver , Sowmya Nataraj , Lawrence Karnowski , Mike Davidson , Tarus Balog , OpenNMS.org

Field Summary
`private static char` `DOT_CHAR` The dot separator in an OID
`private static java.lang.String` `EXTREME_SNMP_SYSUPTIME_OID` The sysUpTimeOID, which should be the first varbind in a V2 trap, but in the case of Extreme Networks only mostly
`private static java.util.ArrayList` `GENERIC_TRAPS` The standard traps list
`private FifoQueue` `m_backlogQ` The input queue
`private java.lang.String` `m_localAddr` The name of the local host.
`private boolean` `m_newSuspect` Whether or not a newSuspect event should be generated with a trap from an unknown IP address
`private int` `m_status` Current status of the fiber
`private java.lang.Thread` `m_worker` The thread that is executing the `run` method on behalf of the fiber.
`private static java.lang.String` `SNMP_SYSUPTIME_OID` The sysUpTimeOID, which should be the first varbind in a V2 trap
`private static int` `SNMP_SYSUPTIME_OID_INDEX` The snmp sysUpTime OID is the first varbind
`private static java.lang.String` `SNMP_TRAP_ENTERPRISE_ID` The snmp trap enterprise OID, which if present in a V2 trap is the last varbind.
`private static java.lang.String` `SNMP_TRAP_OID` The snmpTrapOID, which should be the second varbind in a V2 trap
`private static int` `SNMP_TRAP_OID_INDEX` The snmp trap OID is the second varbind
`private static java.lang.String` `SNMP_TRAPS` The snmpTraps value to be used in case a standard trap comes in without the SNMP_TRAP_ENTERPRISE_ID as the last varbind.
`private static java.lang.String` `SNORT_ATTACK_TARGET`
`private static java.lang.String` `SNORT_OID` OID For snort, to trick the interface settings, varbind 13 will be the address for the event
`private static java.lang.String` `SNORT_PROTO`
`private static java.lang.String` `SNORT_SCAN_TARGET`
`private static java.lang.String` `SNORT_SENSOR`

Fields inherited from interface org.opennms.core.fiber.PausableFiber
`PAUSE_PENDING, PAUSED, RESUME_PENDING`

Fields inherited from interface org.opennms.core.fiber.Fiber
`RUNNING, START_PENDING, STARTING, STATUS_NAMES, STOP_PENDING, STOPPED`

Constructor Summary
`(package private)` `TrapQueueProcessor(FifoQueue backlog, boolean newSuspect)` The constructor

Method Summary
`java.lang.String` `getName()` Returns the name of the fiber.
`int` `getStatus()` Returns the current status of the fiber
`void` `pause()` Pauses the current fiber.
`private void` `process(Trapd.V1TrapInformation info)` Process a V1 trap and convert it to an event.
`private void` `process(Trapd.V2TrapInformation info)` Process a V2 trap and convert it to an event for transmission.
`void` `resume()` Resumes the currently paused fiber.
`void` `run()` Reads off of the input queue and depending on the type (V1 or V2 trap) of object read, process the traps to convert them to events and send them out
`private void` `sendNewSuspectEvent(java.lang.String trapInterface)` Send a newSuspect event for the interface
`void` `start()` Starts the current fiber.
`private boolean` `statusOK()` Returns true if the status is ok and the thread should continue running.
`void` `stop()` Stops this fiber.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### SNMP_SYSUPTIME_OID

    private static final java.lang.String SNMP_SYSUPTIME_OID

  The sysUpTimeOID, which should be the first varbind in a V2 trap

  See Also:
    Constant Field Values

### EXTREME_SNMP_SYSUPTIME_OID

    private static final java.lang.String EXTREME_SNMP_SYSUPTIME_OID

  The sysUpTimeOID, which should be the first varbind in a V2 trap, but in the case of Extreme Networks only mostly

  See Also:
    Constant Field Values

### SNMP_TRAP_OID

    private static final java.lang.String SNMP_TRAP_OID

  The snmpTrapOID, which should be the second varbind in a V2 trap

  See Also:
    Constant Field Values

### SNORT_OID

    private static final java.lang.String SNORT_OID

  OID For snort, to trick the interface settings, varbind 13 will be the address for the event

  See Also:
    Constant Field Values

### SNORT_SENSOR

    private static final java.lang.String SNORT_SENSOR

See Also:
  Constant Field Values

### SNORT_SCAN_TARGET

    private static final java.lang.String SNORT_SCAN_TARGET

See Also:
  Constant Field Values

### SNORT_ATTACK_TARGET

    private static final java.lang.String SNORT_ATTACK_TARGET

See Also:
  Constant Field Values

### SNORT_PROTO

    private static final java.lang.String SNORT_PROTO

See Also:
  Constant Field Values

### SNMP_TRAP_ENTERPRISE_ID

    private static final java.lang.String SNMP_TRAP_ENTERPRISE_ID

  The snmp trap enterprise OID, which if present in a V2 trap is the last varbind. ref - book 'SNMP, SNMPv2, SNMPv3..' by William Stallings, third edition, section 13.1.3

  See Also:
    Constant Field Values

### SNMP_TRAPS

    private static final java.lang.String SNMP_TRAPS

  The snmpTraps value to be used in case a standard trap comes in without the SNMP_TRAP_ENTERPRISE_ID as the last varbind.

  See Also:
    Constant Field Values

### GENERIC_TRAPS

    private static final java.util.ArrayList GENERIC_TRAPS

  The standard traps list

### SNMP_SYSUPTIME_OID_INDEX

    private static final int SNMP_SYSUPTIME_OID_INDEX

  The snmp sysUpTime OID is the first varbind

  See Also:
    Constant Field Values

### SNMP_TRAP_OID_INDEX

    private static final int SNMP_TRAP_OID_INDEX

  The snmp trap OID is the second varbind

  See Also:
    Constant Field Values

### DOT_CHAR

    private static final char DOT_CHAR

  The dot separator in an OID

  See Also:
    Constant Field Values

### m_backlogQ

    private FifoQueue m_backlogQ

  The input queue

### m_localAddr

    private java.lang.String m_localAddr

  The name of the local host.

### m_status

    private int m_status

  Current status of the fiber

### m_worker

    private java.lang.Thread m_worker

  The thread that is executing the `run` method on behalf of the fiber.

### m_newSuspect

    private boolean m_newSuspect

  Whether or not a newSuspect event should be generated with a trap from an unknown IP address

Constructor Detail

### TrapQueueProcessor

    TrapQueueProcessor(FifoQueue backlog,
                       boolean newSuspect)

  The constructor

Method Detail

### process

    private void process(Trapd.V2TrapInformation info)

  Process a V2 trap and convert it to an event for transmission.

  From RFC2089 ('Mapping SNMPv2 onto SNMPv1'), section 3.3 ('Processing an outgoing SNMPv2 TRAP')

  2b

  If the snmpTrapOID.0 value is one of the standard traps the specific-trap field is set to zero and the generic trap field is set according to this mapping:

             value of snmpTrapOID.0                generic-trap
             ===============================       ============
             1.3.6.1.6.3.1.1.5.1 (coldStart)                  0
             1.3.6.1.6.3.1.1.5.2 (warmStart)                  1
             1.3.6.1.6.3.1.1.5.3 (linkDown)                   2
             1.3.6.1.6.3.1.1.5.4 (linkUp)                     3
             1.3.6.1.6.3.1.1.5.5 (authenticationFailure)      4
             1.3.6.1.6.3.1.1.5.6 (egpNeighborLoss)            5

  The enterprise field is set to the value of snmpTrapEnterprise.0 if this varBind is present, otherwise it is set to the value snmpTraps as defined in RFC1907 [4].

  2c.

  If the snmpTrapOID.0 value is not one of the standard traps, then the generic-trap field is set to 6 and the specific-trap field is set to the last subid of the snmpTrapOID.0 value.

  If the next to last subid of snmpTrapOID.0 is zero, then the enterprise field is set to snmpTrapOID.0 value and the last 2 subids are truncated from that value. If the next to last subid of snmpTrapOID.0 is not zero, then the enterprise field is set to snmpTrapOID.0 value and the last 1 subid is truncated from that value.

  In any event, the snmpTrapEnterprise.0 varBind (if present) is ignored in this case.

  Parameters:
    `info` - V2 trap

### process

    private void process(Trapd.V1TrapInformation info)

  Process a V1 trap and convert it to an event. Once the event is formatted, send it to eventd.

  Parameters:
    `info` - V1 trap

### sendNewSuspectEvent

    private void sendNewSuspectEvent(java.lang.String trapInterface)

  Send a newSuspect event for the interface

  Parameters:
    `trapInterface` - The interface for which the newSuspect event is to be generated

### statusOK

    private boolean statusOK()

  Returns true if the status is ok and the thread should continue running. If the status returend is false then the thread should exit.

### start

    public void start()

  Starts the current fiber. If the fiber has already been started, regardless of it's current state, then an IllegalStateException is thrown.

  Specified by:
    `start` in interface `Fiber`
  Throws:
    `java.lang.IllegalStateException` - Thrown if the fiber has already been started.

### pause

    public void pause()

  Pauses the current fiber.

  Specified by:
    `pause` in interface `PausableFiber`

### resume

    public void resume()

  Resumes the currently paused fiber.

  Specified by:
    `resume` in interface `PausableFiber`

### stop

    public void stop()

  Stops this fiber. If the fiber has never been started then an `IllegalStateExceptio` is generated.

  Specified by:
    `stop` in interface `Fiber`
  Throws:
    `java.lang.IllegalStateException` - Thrown if the fiber has never been started.

### getName

    public java.lang.String getName()

  Returns the name of the fiber.

  Specified by:
    `getName` in interface `Fiber`
  Returns:
    The name of the Fiber.

### getStatus

    public int getStatus()

  Returns the current status of the fiber

  Specified by:
    `getStatus` in interface `Fiber`
  Returns:
    The status of the Fiber.

### run

    public void run()

  Reads off of the input queue and depending on the type (V1 or V2 trap) of object read, process the traps to convert them to events and send them out

  Specified by:
    `run` in interface `java.lang.Runnable`

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.