SNMP Stack 4_12

uk.co.westhawk.snmp.pdu
Class InterfaceGetNextPdu

java.lang.Object
  |
  +--java.util.Observable
        |
        +--uk.co.westhawk.snmp.stack.Pdu
              |
              +--uk.co.westhawk.snmp.stack.GetNextPdu
                    |
                    +--uk.co.westhawk.snmp.pdu.GetNextPdu_vec
                          |
                          +--uk.co.westhawk.snmp.pdu.InterfaceGetNextPdu

public class InterfaceGetNextPdu
extends GetNextPdu_vec

The InterfaceGetNextPdu class can be used collect information off all current interfaces.

To get the successor (GetNext) of a request, the application must build the new request with the previous one. This is done by calling addOids(InterfaceGetNextPdu) before sending it.

This class can best be used inOctets a loop. To start the loop, build the Pdu with addOids(), when the answer is received, request the next interface by building the Pdu with addOids(InterfaceGetNextPdu). The loops ends when the errorStatus equals AsnObject.SNMP_ERR_NOSUCHNAME

The requested OID are from the RFC 2863.

Version:
$Revision: 3.14 $ $Date: 2002/10/29 14:44:40 $
Author:
Birgit Arkesteijn
See Also:
addOids(), addOids(InterfaceGetNextPdu)

Field Summary
static java.lang.String DESCR
          ifDescr A textual string containing information about the interface.
static java.lang.String DOWN
          The current operational state is down
static java.lang.String IFNUMBER
          ifNumber The number of network interfaces (regardless of their current state) present on this system.
static java.lang.String IN_OCTETS
          ifInOctets The total number of octets received on the interface, including framing characters.
static java.lang.String INDEX
          ifIndex A unique value for each interface.
static java.lang.String OPR_STATUS
          ifOperStatus The current operational state of the interface.
static java.lang.String OUT_OCTETS
          ifOutOctets The total number of octets transmitted outOctets of the interface, including framing characters.
static java.lang.String SYS_UPTIME
          sysUpTime The time (inOctets hundredths of a second) since the network management portion of the system was last re-initialized.
static java.lang.String TESTING
          The current operational state is testing
static java.lang.String UNKNOWN
          The current operational state is unknown
static java.lang.String UP
          The current operational state is up
 
Fields inherited from class uk.co.westhawk.snmp.stack.Pdu
added, answered, context, encodedPacket, errind, errstat, msg_type, reqVarbinds, respVarbinds
 
Constructor Summary
InterfaceGetNextPdu(SnmpContextBasisFace con)
          Constructor.
 
Method Summary
 boolean addOids()
          This method should be used when the variables are asked for the first time, the start of the loop.
 void addOids(InterfaceGetNextPdu old)
          The method addOids is the basic for the GetNext functionality.
 java.lang.String getDescription()
          Returns the description of the interface.
 int getIndex()
          Returns the index of the interface.
static int getNumIfs(SnmpContextBasisFace con)
          Method to discover how many interfaces are present.
 int getOperStatus()
          Returns the operational state of the interface.
 java.lang.String getOperStatusString()
          Returns the string representation of the operational state of the interface.
 java.lang.String getOperStatusString(int status)
          Returns the string representation of a operational state.
 long getSpeed()
          Returns the speed of the interface.
 long getSpeed(InterfaceGetNextPdu old)
          Calculates the speed of the interface.
protected  void new_value(int n, varbind res)
          The value of the request is set.
 java.lang.String toString()
          Returns the string represenation of this request.
 
Methods inherited from class uk.co.westhawk.snmp.pdu.GetNextPdu_vec
tell_them
 
Methods inherited from class uk.co.westhawk.snmp.stack.Pdu
addOid, addOid, addOid, addOid, addOid, addToTrans, getContext, getErrorIndex, getErrorStatus, getErrorStatusString, getMsgType, getReqId, getRequestVarbinds, getResponseVarbinds, isTimedOut, notifyObservers, send, send, send, sendme, setErrorIndex, setErrorStatus, setErrorStatus, setMsgType, setRetryIntervals, toString, waitForSelf
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IFNUMBER

public static final java.lang.String IFNUMBER
ifNumber The number of network interfaces (regardless of their current state) present on this system.

SYS_UPTIME

public static final java.lang.String SYS_UPTIME
sysUpTime The time (inOctets hundredths of a second) since the network management portion of the system was last re-initialized.

INDEX

public static final java.lang.String INDEX
ifIndex A unique value for each interface. Its value ranges between 1 and the value of ifNumber. The value for each interface must remain constant at least from one re-initialization of the entity's network management system to the next re- initialization.

DESCR

public static final java.lang.String DESCR
ifDescr A textual string containing information about the interface. This string should include the name of the manufacturer, the product name and the version of the hardware interface.

OPR_STATUS

public static final java.lang.String OPR_STATUS
ifOperStatus The current operational state of the interface. The testing(3) state indicates that no operational packets can be passed.

IN_OCTETS

public static final java.lang.String IN_OCTETS
ifInOctets The total number of octets received on the interface, including framing characters.

OUT_OCTETS

public static final java.lang.String OUT_OCTETS
ifOutOctets The total number of octets transmitted outOctets of the interface, including framing characters.

UP

public static final java.lang.String UP
The current operational state is up

DOWN

public static final java.lang.String DOWN
The current operational state is down

TESTING

public static final java.lang.String TESTING
The current operational state is testing

UNKNOWN

public static final java.lang.String UNKNOWN
The current operational state is unknown
Constructor Detail

InterfaceGetNextPdu

public InterfaceGetNextPdu(SnmpContextBasisFace con)
Constructor.
Parameters:
con - The context of the request
Method Detail

getIndex

public int getIndex()
Returns the index of the interface.
Returns:
the index
See Also:
INDEX

getDescription

public java.lang.String getDescription()
Returns the description of the interface.
Returns:
the description
See Also:
DESCR

getOperStatus

public int getOperStatus()
Returns the operational state of the interface.
Returns:
the operational state
See Also:
OPR_STATUS

getOperStatusString

public java.lang.String getOperStatusString()
Returns the string representation of the operational state of the interface.
Returns:
the operational state as string
See Also:
getOperStatus(), getOperStatusString(int)

getOperStatusString

public java.lang.String getOperStatusString(int status)
Returns the string representation of a operational state.
See Also:
getOperStatusString()

getSpeed

public long getSpeed()
Returns the speed of the interface.
Returns:
the speed
See Also:
getSpeed(InterfaceGetNextPdu)

getSpeed

public long getSpeed(InterfaceGetNextPdu old)
Calculates the speed of the interface. This is done by providing the method with the previous value of this interface. An interface is marked by its index. Do not confuse it with the previous interface inOctets the MIB.
Parameters:
old - The previous value of this interface

addOids

public boolean addOids()
This method should be used when the variables are asked for the first time, the start of the loop.
See Also:
addOids(InterfaceGetNextPdu)

addOids

public void addOids(InterfaceGetNextPdu old)
The method addOids is the basic for the GetNext functionality. It copies the old reqVarbinds, except for SYS_UPTIME, so the request continues where the previous one left.
See Also:
addOids()

new_value

protected void new_value(int n,
                         varbind res)
The value of the request is set. This will be called by Pdu.fillin(). I check if the variables are still in range. I do this because I'm only interessed in a part of the MIB. If I would not do this check, I'll get the whole MIB from the starting point, instead of the variables in the ifTable.
Overrides:
new_value in class GetNextPdu_vec
Parameters:
n - the index of the value
a_var - the value
See Also:
Pdu.new_value(int, uk.co.westhawk.snmp.stack.varbind)

toString

public java.lang.String toString()
Returns the string represenation of this request.
Overrides:
toString in class Pdu
Returns:
the string

getNumIfs

public static int getNumIfs(SnmpContextBasisFace con)
                     throws PduException,
                            java.io.IOException
Method to discover how many interfaces are present.
Returns:
the number of interfaces

SNMP Stack 4_12