|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opennms.netmgt.capsd.snmp.IpAddrTable
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.
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 |
private static java.lang.String IP_ADDR_IF_INDEX
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 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.
private SnmpObjectId m_stopAt
This will be the OID where the information should cut off from the return packet from the GETBULK command.
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 |
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.
java.lang.UnsupportedOperationException
- Always thrown from this method since it is not supported.IpAddrTable(SnmpSession, Signaler)
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.
session
- The session with the remote agent.signaler
- The object to notify waiters.IpAddrTableEntry
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.
session
- The session with the remote agent.signaler
- The object to notify waiters.IpAddrTableEntry
Method Detail |
public boolean failed()
Returns the success or failure code for collection of the data.
public java.util.List getEntries()
Returns the list of entry maps that can be used to access all the information about the interface table.
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.
snmpReceivedPdu
in interface SnmpHandler
session
- The SNMP Session that received the PDUcommand
- The command contained in the received pdupdu
- The actual received PDU.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.
snmpInternalError
in interface SnmpHandler
session
- The session that had an unexpected errorerror
- The error conditionpdu
- The PDU being sent when the error occuredsnmpTimeoutError(org.opennms.protocols.snmp.SnmpSession, org.opennms.protocols.snmp.SnmpSyntax)
,
SnmpHandler
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.
snmpTimeoutError
in interface SnmpHandler
session
- The session invoking the error handlerpdu
- The PDU that the remote failed to respond to.SnmpHandler
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.
ipAddrEntries
- List of IpAddrTableEntry objects to searchifIndex
- The interface index to search for
public static java.util.List getIpAddresses(java.util.List ipAddrEntries, int ifIndex)
ipAddrEntries
- List of IpAddrTableEntry objects to searchifIndex
- The index to search for.
public static java.util.List getIpAddresses(java.util.List ipAddrEntries)
ipAddrEntries
- List of IpAddrTableEntry objects to search
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.
ipAddrEntries
- List of IpAddrTableEntry objects to searchipAddress
- The IP address to search for
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.
ipAddrEntries
- List of IpAddrTableEntry objects to searchifIndex
- The interface index to search for.
|
OpenNMS API 1.2.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |