OpenNMS API 1.2.9

## org.opennms.netmgt.capsd.snmp
Class IfTable

    java.lang.Object
      org.opennms.netmgt.capsd.snmp.IfTable

All Implemented Interfaces:
  SnmpHandler

public final class IfTable
extends java.lang.Object
implements SnmpHandler

The IfTable uses a SnmpSession to collect the entries in the remote agent's interface table. It implements the SnmpHandler to receive notifications and handle errors associated with the data collection. Data is collected using a series of GETNEXT PDU request to walk multiple parts of the interface table at once. The number of SNMP packets should not exceed the number of interface + 1, assuming no lost packets or error conditions occur.

Addition by Jon Whetzel

IfTable has an extra class variable for the SNMP version setting. If this is set for SNMPv2, then a GETBULK command will be used for retrieving the necessary data. Otherwise, the method will resort to its previous implementation with GETNEXT commands.

Author:
  Sowmya , Weave , OpenNMS
See Also:
  RFC1213

Field Summary
`private java.util.List` `m_entries` The list of interfaces from the remote's interface table.
`private boolean` `m_error` Flag indicating if query was successful or if the collection failed.
`private static char[]` `m_hexDigit` Used to convert decimal to hex
`private int` `m_ifNumber` Used for storing the ifNumber variable from the MIB, the number of interfaces a device possesses.
`private int` `m_ifNumberRequestId` The request id associated with the GetNext PDU generated to retrieve the number of interfaces associated with the remote host.
`private int` `m_responses` For SNMPv1 used to keep track of the number of SNMP response packets received.
`private Signaler` `m_signal` Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.
`private SnmpObjectId` `m_stopAt` This will be the OID where the information should cut off from the return packet from the GETBULK command.
`private SnmpVarBind[]` `m_tempStorage` Used as a temporary storage space for all the data collected from the SNMP response packets for SNMP v2.
`private int` `m_version` Used to generate the proper command for fetching the SNMP data from the agent (via GETBULK for version 2 or GETNEXT for version 1.

Constructor Summary
`private` `IfTable()` The default constructor is marked as private and will always throw an exception.
`` `IfTable(SnmpSession session, Signaler signaler)` Constructs an IfTable object that is used to collect the interface elements from the remote agent.
`` `IfTable(SnmpSession session, Signaler signaler, int version)` Constructs an IfTable object that is used to collect the interface elements from the remote agent.

Method Summary
`boolean` `failed()` Returns the success or failure code for collection of the data.
`java.util.List` `getEntries()` Returns the list of entry maps that can be used to access all the information about the interface table.
`void` `snmpInternalError(SnmpSession session, int error, SnmpSyntax pdu)` This method is part of the SnmpHandler interface and called when an internal error happens in a session.
`void` `snmpReceivedPdu(SnmpSession session, int command, SnmpPduPacket pdu)` This method is used to process received SNMP PDU packets from the remote agent.
`void` `snmpTimeoutError(SnmpSession session, SnmpSyntax pdu)` This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.
`static java.lang.String` `toHexString(byte[] physAddr)` This method converts the physical address, normally six bytes, into a hexidecimal string.

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

Field Detail

### m_hexDigit

    private static final char[] m_hexDigit

  Used to convert decimal to hex

### m_entries

    private java.util.List m_entries

  The list of interfaces from the remote's interface table. The list contains a set of IfTableEntry objects that were collected from the remote host.

  See Also:
    `IfTableEntry`

### m_error

    private boolean m_error

  Flag indicating if query was successful or if the collection failed.

### m_signal

    private Signaler m_signal

  Used to synchronize the class to ensure that the session has finished collecting data before the value of success or failure is set, and control is returned to the caller.

### m_version

    private int m_version

  Used to generate the proper command for fetching the SNMP data from the agent (via GETBULK for version 2 or GETNEXT for version 1.

### m_ifNumberRequestId

    private int m_ifNumberRequestId

  The request id associated with the GetNext PDU generated to retrieve the number of interfaces associated with the remote host.

### m_stopAt

    private SnmpObjectId m_stopAt

  This will be the OID where the information should cut off from the return packet from the GETBULK command.

### m_ifNumber

    private int m_ifNumber

  Used for storing the ifNumber variable from the MIB, the number of interfaces a device possesses.

### m_tempStorage

    private SnmpVarBind[] m_tempStorage

  Used as a temporary storage space for all the data collected from the SNMP response packets for SNMP v2. After receiving all the data, the information will be sorted so that it mimics the SNMP v1 data storage; one map per interface containing all the necessary MIB values.

### m_responses

    private int m_responses

  For SNMPv1 used to keep track of the number of SNMP response packets received. For SNMPv2 used to keep track of the total number of varbinds received in SNMP response packets. For both SNMPv1 and SNMPv2 this value is used to determine when all the necessary SNMP data has been retrieved.

Constructor Detail

### IfTable

    private IfTable()
             throws java.lang.UnsupportedOperationException

  The default constructor is marked as private and will always throw an exception. This is done to disallow the constructor to be called. Since any instance of this class must have an SnmpSession and Signaler to properly work, the correct constructor must be used.

Throws:
  `java.lang.UnsupportedOperationException` - Always thrown from this method since it is not supported.
See Also:
  `IfTable(SnmpSession, Signaler)`

### IfTable

    public IfTable(SnmpSession session,
                   Signaler signaler)

  Constructs an IfTable object that is used to collect the interface elements from the remote agent. Once all the interfaces are collected, or there is an error in the collection the signaler object is notified to inform other threads.

Parameters:
  `session` - The session with the remote agent.
  `signaler` - The object to notify waiters.
See Also:
  `IfTableEntry`

### IfTable

    public IfTable(SnmpSession session,
                   Signaler signaler,
                   int version)

  Constructs an IfTable object that is used to collect the interface elements from the remote agent. Once all the interfaces are collected, or there is an error in the collection the signaler object is notified to inform other threads.

Parameters:
  `session` - The session with the remote agent.
  `signaler` - The object to notify waiters.
See Also:
  `IfTableEntry`

Method Detail

### failed

    public boolean failed()

  Returns the success or failure code for collection of the data.

### getEntries

    public java.util.List getEntries()

  Returns the list of entry maps that can be used to access all the information about the interface table.

  Returns:
    The list of ifTableEntry maps.

### snmpReceivedPdu

    public void snmpReceivedPdu(SnmpSession session,
                                int command,
                                SnmpPduPacket pdu)

  This method is used to process received SNMP PDU packets from the remote agent. The method is part of the SnmpHandler interface and will be invoked when a PDU is successfully decoded. The method is passed the receiving session, the PDU command, and the actual PDU packet.

  When all the data has been received from the session the signaler object, initialized in the constructor, is signaled. In addition, the receiving instance will call notifyAll() on itself at the same time.

  For SNMP version 2 devices, all the received data enters a temporary array. After the collecting process, the method sorts the data so that each interface has its own map.

  Specified by:
    `snmpReceivedPdu` in interface `SnmpHandler`
  Parameters:
    `session` - The SNMP Session that received the PDU
    `command` - The command contained in the received pdu
    `pdu` - The actual received PDU.

### snmpInternalError

    public void snmpInternalError(SnmpSession session,
                                  int error,
                                  SnmpSyntax pdu)

  This method is part of the SnmpHandler interface and called when an internal error happens in a session. This is usually the result of an I/O error. This method will not be called if the session times out sending a packet, see snmpTimeoutError for timeout handling.

  Specified by:
    `snmpInternalError` in interface `SnmpHandler`
  Parameters:
    `session` - The session that had an unexpected error
    `error` - The error condition
    `pdu` - The PDU being sent when the error occured
  See Also:
    `snmpTimeoutError(org.opennms.protocols.snmp.SnmpSession, org.opennms.protocols.snmp.SnmpSyntax)`, `SnmpHandler`

### snmpTimeoutError

    public void snmpTimeoutError(SnmpSession session,
                                 SnmpSyntax pdu)

  This method is part of the SnmpHandler interface and is invoked when the SnmpSession does not receive a reply after exhausting the retransmission attempts.

  Specified by:
    `snmpTimeoutError` in interface `SnmpHandler`
  Parameters:
    `session` - The session invoking the error handler
    `pdu` - The PDU that the remote failed to respond to.
  See Also:
    `SnmpHandler`

### toHexString

    public static java.lang.String toHexString(byte[] physAddr)

  This method converts the physical address, normally six bytes, into a hexidecimal string. The string is not prefixed with the traditional "0x", but is the raw hexidecimal string in upper case.

  NOTICE: The string is converted based on the starndard US-ASCII table. Each NIBBLE is converted to an integer and added to the character '0' (Zero).

  Parameters:
    `physAddr` - The physical address to convert to a string.
  Returns:
    The converted physical address as a hexidecimal string.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.