com.tivoli.twg.snmp
Class SNMP

java.lang.Object
  extended byjava.util.Observable
      extended bycom.tivoli.twg.snmp.SNMP
All Implemented Interfaces:
java.lang.Runnable

public class SNMP
extends java.util.Observable
implements java.lang.Runnable

This class represents an instance of the SNMP stack. It is required for all SNMP transactions.

See Also:
SNMPContext, SNMPPDU, SNMPEntity

Constructor Summary
SNMP()
          Construct An SNMP Session to be used for all SNMP Transactions.
SNMP(java.util.Observer Trapper)
          Construct An SNMP Session to be used for all SNMP Transactions.
 
Method Summary
static boolean isNative()
          This method will return whether the native (WinSNMP) stack is in use for the class (static)
 int Level()
          Deprecated. always returns zero
 int MajorVersion()
          Deprecated. always returns zero
 int MinorVersion()
          Deprecated. always returns zero
 void RequestNetMask(com.tivoli.twg.snmp.SubNetRequester subnetRequester)
          Deprecated. does nothing
 void RequestNetMask(TWGSNMPDevice Device)
          Deprecated. does nothing
 void RequestPing(com.tivoli.twg.snmp.PingRequester pingRequester)
          This method will submit a Ping Request to the TWGIPDevice.
 void RequestPing(TWGSNMPDevice snmpDevice)
          This method will submit a Ping Request to the TWGSNMPDevice.
 long ResponseCount()
          This method will return the number of Response PDUs received.
 int RetransmitMode()
          Deprecated. always returns zero
 void run()
          INTERNAL USE ONLY Processes asynchronous events for SNMP stack traps
 void ShutDown()
          INTERNAL USE ONLY
 int SubmitPDU(SNMPEntity sourceEntity, SNMPEntity destEntity, SNMPContext context, SNMPPDU PDU)
          This method will submit a PDU (Get, Set, Getnext, Trap) to the stack for transmition.
 long TimeoutCount()
          This method will return the number of PDUs that have timed out.
 int TranslateMode()
          Deprecated. always returns zero
 long TransmitCount()
          This method will return the number of PDUs that have been transmitted.
 long TrapCount()
          This method will return the number of Trap PDUs received.
 int TrapRegister(SNMPEntity Source, SNMPEntity Dest, SNMPContext Context, java.lang.String TrapOID)
          This method will set up a registration to receive traps.
 int TrapUnregister(SNMPEntity Source, SNMPEntity Dest, SNMPContext Context, java.lang.String TrapOID)
          This method will set up a un-registration for the receipt traps.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SNMP

public SNMP()
     throws TWGSNMPException
Construct An SNMP Session to be used for all SNMP Transactions. This is required to issue requests, and to receive traps of any kind. It is also required to create and manage ANY of the following classes in this package: SNMPEntity, SNMPContext, SNMPPDU. This version of the constructor will create a session that can issue requests, but will only be capable of receiving traps if owner does an an explicit: addObserver(Observer); call, to register for notification of trap receipt.

Throws:
TWGSNMPException

SNMP

public SNMP(java.util.Observer Trapper)
     throws TWGSNMPException
Construct An SNMP Session to be used for all SNMP Transactions. This is required to issue requests, and to receive traps of any kind. It is also required to create and manage ANY of the following classes in this package: SNMPEntity, SNMPContext, SNMPPDU. This version of the constructor will create a session that can issue requests, as well as notify an owner of trap receipt. Note, that additional Observers can still be added to this instance, but an explicit call to addObserver(Observer); will be required to do that.

Parameters:
Trapper -
Throws:
TWGSNMPException
Method Detail

TransmitCount

public final long TransmitCount()
This method will return the number of PDUs that have been transmitted.

Returns:
long Returns the number of PDUs transmitted.

ResponseCount

public final long ResponseCount()
This method will return the number of Response PDUs received.

Returns:
long Returns the number of response PDUs.

TimeoutCount

public final long TimeoutCount()
This method will return the number of PDUs that have timed out.

Returns:
long Returns the number of PDUs that have timeout.

TrapCount

public final long TrapCount()
This method will return the number of Trap PDUs received.

Returns:
long Returns the number of Trap PDUs received.

MajorVersion

public final int MajorVersion()
Deprecated. always returns zero

This method will return the Major version number for the underlying WinSNMP implementation. (WinSNMP stack only)

Returns:
int Returns an integer value indicating the major version of WinSnmp supported by the underlying implementation.

MinorVersion

public final int MinorVersion()
Deprecated. always returns zero

This method will return the Minor version number for the underlying WinSNMP implementation. (WinSNMP stack only)

Returns:
int Returns an integer value indicating the minor version of WinSnmp supported by the underlying implementation:

Level

public final int Level()
Deprecated. always returns zero

This method will return the Level supported by the underlying WinSNMP implementation. (WinSNMP stack only)

Returns:
int Returns an integer value indicating the Level of WinSnmp supported by the underlying implementation.

TranslateMode

public final int TranslateMode()
Deprecated. always returns zero

This method will return the Translation mode currently in operation. (WinSNMP stack only)

Returns:
int Returns an integer value indicating the mode currently in use. It can be one of the the following:
  • 0 - Version 1 and Version 2 entity/contexts are transalted by the support stack
  • 1 - Version 1 entity/contexts ONLY
  • 2 - Version 2 entity/contexts ONLY

RetransmitMode

public final int RetransmitMode()
Deprecated. always returns zero

This method will return the Retransmition mode currently in operation. (WinSNMP stack only)

Returns:
int Returns an integer value indicating the retransmition mode currently in use. It can be one of the the following:
  • 0 - Retry/timeout is disabled
  • 1 - Retry/timeout is enabled
If enabled, then the stack will perform retries and timeouts based on the settings provided in each PDU.

RequestNetMask

public final void RequestNetMask(com.tivoli.twg.snmp.SubNetRequester subnetRequester)
Deprecated. does nothing

This method will submit a Subnet mask request to the supporting JNI code for transmition to the intended target. This version of the method is ONLY for use by the SNMPDisc class. It is for use on stations that do not yet exist as a full fledged TWGSNMPDevice class yet. This condition ONLY exists during discovery.


RequestNetMask

public final void RequestNetMask(TWGSNMPDevice Device)
Deprecated. does nothing

This method will submit a Subnet mask request to the supporting JNI code for transmition to the intended target. Completion is indicated asyncronously to the instance of TWGSNMPDevice that is passed into this method.


RequestPing

public final void RequestPing(TWGSNMPDevice snmpDevice)
This method will submit a Ping Request to the TWGSNMPDevice. Upon completion (either a timeout, or a successful response) the asyncronous callback operation will update the operational state of this device. If the state is changed, the change will be reflected to the rest of the platform. Note: used by TWGSNMPDevice class only when stack is in native mode


RequestPing

public final void RequestPing(com.tivoli.twg.snmp.PingRequester pingRequester)
This method will submit a Ping Request to the TWGIPDevice. Upon completion (either a timeout, or a successful response) the asyncronous callback operation will update the operational state of this device. If the state is changed, the change will be reflected to the rest of the platform. Note: used by TWGIPDevice class only when stack is in native mode

Parameters:
pingRequester - - Instance of this class indicates to what station this request should be sent.

isNative

public static final boolean isNative()
This method will return whether the native (WinSNMP) stack is in use for the class (static)

Returns:
always false

SubmitPDU

public final int SubmitPDU(SNMPEntity sourceEntity,
                           SNMPEntity destEntity,
                           SNMPContext context,
                           SNMPPDU PDU)
This method will submit a PDU (Get, Set, Getnext, Trap) to the stack for transmition. Note, that the PDU that is being submitted for transmission (if it is NOT a Trap), MUST have a registered Observer, or the method will fail. All non-trap commands are completed by notifying the PDUs registered oberserver.

Parameters:
sourceEntity - source SNMPEntity
destEntity - destination SNMPEntity
context - SNMPContext for this pdu
PDU - Instance of the PDU class that contains the request data.
Returns:
int Returns the status of the operation

ShutDown

public final void ShutDown()
INTERNAL USE ONLY

This method will terminate the SNMP stack with malice! All outstanding requests will be terminated. That includes any pending Ping/mask requests. This should be used ONLY when you are shutting down the system.


TrapRegister

public final int TrapRegister(SNMPEntity Source,
                              SNMPEntity Dest,
                              SNMPContext Context,
                              java.lang.String TrapOID)
This method will set up a registration to receive traps.

Parameters:
Source - Source of the registration, ie. this station. This is useful if this station has more then one address entity active (IP) if you wish to receive from all of them, simply register with the NULL address: "0.0.0.0".
Dest - Destination of the registration, ie. the stations we would like to receive traps from. Can be either a specific address, or a null class, to receive all traps sent to this address.
Context - The Context of the device we would like to receive traps from. Can also be set to null to indicate that anything will be received.
TrapOID - The type of trap we would like to register for. Can be set to either a specific trap OID, or to null to indicate all traps.
Returns:
int Returns the status of the operation.

TrapUnregister

public final int TrapUnregister(SNMPEntity Source,
                                SNMPEntity Dest,
                                SNMPContext Context,
                                java.lang.String TrapOID)
This method will set up a un-registration for the receipt traps.

Returns:
int Returns the status of the operation.

run

public void run()
INTERNAL USE ONLY Processes asynchronous events for SNMP stack traps

Specified by:
run in interface java.lang.Runnable