OpenNMS API 1.2.9

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

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

All Implemented Interfaces:
  SnmpHandler

public class IpAddrTable
extends java.lang.Object
implements SnmpHandler

IpAddrTable uses a SnmpSession to collect the ipAddrTable entries It implements the SnmpHandler to receive notifications when a reply is received/error occurs in the SnmpSession used to send requests /recieve replies.

Author:
  James Zuo , Sowmya , Weave , OpenNMS
See Also:
  RFC1213

Field Summary
`private static java.lang.String` `IP_ADDR_IF_INDEX` The interface to IP address table by ifIndex.
`private java.util.List` `m_entries` The list of collected IpAddrTableEntries built from the infomation collected from the remote agent.
`private boolean` `m_error` Flag indicating if query was successful.
`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 java.util.List` `m_snmpVarBindList` This list will hold each instance of the specific MIB variable listed within IpAddrTableEntry.
`private SnmpObjectId` `m_stopAt` This will be the OID where the information should cut off from the return packet from the GETBULK command.
`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` `IpAddrTable()` The default constructor is marked as private and will always throw an exception.
`` `IpAddrTable(SnmpSession session, Signaler signaler)` Constructs an IpAddrTable object that is used to collect the address elements from the remote agent.
`` `IpAddrTable(SnmpSession session, Signaler signaler, int version)` Constructs an IpAddrTable object that is used to collect the address 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.
`static int` `getIfIndex(java.util.List ipAddrEntries, java.lang.String ipAddress)` This method is used to find the ifIndex of an interface given the interface's IP address.
`static java.net.InetAddress` `getIpAddress(java.util.List ipAddrEntries, int ifIndex)` This method is used to find the corresponding IP Address for the indexed interface.
`static java.util.List` `getIpAddresses(java.util.List ipAddrEntries)` Returns all Internet addresses in the ipAddrEntry list.
`static java.util.List` `getIpAddresses(java.util.List ipAddrEntries, int ifIndex)` Returns all Internet addresses at the corresponding index.
`static java.lang.String` `getNetmask(java.util.List ipAddrEntries, int ifIndex)` This method is used to find the corresponding netmask for the indexed interface.
`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.

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

Field Detail

### IP_ADDR_IF_INDEX

    private static java.lang.String IP_ADDR_IF_INDEX

  The interface to IP address table by ifIndex.

### m_entries

    private java.util.List m_entries

  The list of collected IpAddrTableEntries built from the infomation collected from the remote agent.

### m_error

    private boolean m_error

  Flag indicating if query was successful.

### 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_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_snmpVarBindList

    private java.util.List m_snmpVarBindList

  This list will hold each instance of the specific MIB variable listed within IpAddrTableEntry. By keeping these separate, we can generate our own usable map from the variables.

Constructor Detail

### IpAddrTable

    private IpAddrTable()
                 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:
  `IpAddrTable(SnmpSession, Signaler)`

### IpAddrTable

    public IpAddrTable(SnmpSession session,
                       Signaler signaler)

  Constructs an IpAddrTable object that is used to collect the address elements from the remote agent. Once all the elements 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:
  `IpAddrTableEntry`

### IpAddrTable

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

  Constructs an IpAddrTable object that is used to collect the address elements from the remote agent. Once all the elements 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:
  `IpAddrTableEntry`

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.

  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`

### getIpAddress

    public static java.net.InetAddress getIpAddress(java.util.List ipAddrEntries,
                                                    int ifIndex)

  This method is used to find the corresponding IP Address for the indexed interface. The list of IP Address entries are searched until the first IP Address is found for the interface. The IP Address is then returned as a string. If there is no interface corresponding to the index then a null is returned to the caller.

  Parameters:
    `ipAddrEntries` - List of IpAddrTableEntry objects to search
    `ifIndex` - The interface index to search for
  Returns:
    IP Address for the indexed interface.

### getIpAddresses

    public static java.util.List getIpAddresses(java.util.List ipAddrEntries,
                                                int ifIndex)

  Returns all Internet addresses at the corresponding index. If the address cannot be resolved then a null reference is returned.

  Parameters:
    `ipAddrEntries` - List of IpAddrTableEntry objects to search
    `ifIndex` - The index to search for.
  Returns:
    list of InetAddress objects representing each of the interfaces IP addresses.

### getIpAddresses

    public static java.util.List getIpAddresses(java.util.List ipAddrEntries)

  Returns all Internet addresses in the ipAddrEntry list. If the address cannot be resolved then a null reference is returned.

  Parameters:
    `ipAddrEntries` - List of IpAddrTableEntry objects to search
  Returns:
    list of InetAddress objects representing each of the interfaces IP addresses.

### getIfIndex

    public static int getIfIndex(java.util.List ipAddrEntries,
                                 java.lang.String ipAddress)

  This method is used to find the ifIndex of an interface given the interface's IP address. The list of ipAddrTable entries are searched until an interface is found which has a matching IP address. The ifIndex of that interface is then returned. If no match is found -1 is returned.

  Parameters:
    `ipAddrEntries` - List of IpAddrTableEntry objects to search
    `ipAddress` - The IP address to search for
  Returns:
    ifIndex of the interface with the specified IP address

### getNetmask

    public static java.lang.String getNetmask(java.util.List ipAddrEntries,
                                              int ifIndex)

  This method is used to find the corresponding netmask for the indexed interface. The list of IP Address table entries are searched until the first netmask address is found for the interface. The netmask is then returned as a string. If there is no interface corresponding to the index then a null is returned.

  Parameters:
    `ipAddrEntries` - List of IpAddrTableEntry objects to search
    `ifIndex` - The interface index to search for.
  Returns:
    The netmask for the interface.

OpenNMS API 1.2.9

Generated by ranger on May 19 2007 2335.