IP*Works!

ipworks
Class Snmp

java.lang.Object
  |
  +--ipworks.Snmp

public class Snmp
extends java.lang.Object

The SNMP control is used to implement SNMP Management Applications and SNMP Agent Applications.

The SNMP control implements a standard SNMP Manager and/or Agent as specified in the SNMP RFCs. Both SNMP v1 and SNMP v2c are supported.

The control provides both encoding/decoding and transport capabilities, making the task of developing a custom SNMP agent or manager as simple as setting a few key properties and handling a few events. SNMP data, such as for instance SNMP object id-s (OID-s) are exchanged as text strings, thus further simplifying the task of handling them.

The control is activated/deactivated by first setting the LocalPort to 161 or 162, depending on whether you want to implement an SNMP agent or SNMP manager, and then setting the Active property. This property enables or disables sending or receiving. It operates completely asynchronously. Messages are sent to other agents or managers by using control's methods or the Action property, and are recieved through events such as GetRequest , GetResponse , or Trap .

SNMP object ids, types, and values are provided in arrays such as ObjId , ObjType , and ObjValue , for both sent and received packets. ObjCount provides the number of elements in each of the arrays. Other packet information is provided through corresponding properties, such as Community , or RequestId , or similarly named parameters in events.

The control may behave as an SNMP agent or SNMP manager, depending on the value of the LocalPort property. If the control listens to port 161 it may act as an SNMP agent by responding to SNMP requests from SNMP managers, and sending traps through the Action property. If the LocalPort is set to 162, the control listens for SNMP traps, and may send requests to SNMP agents listening on port 161.

SNMP Traps are received through the Trap event, and may be sent through the Action property by specifying appropriate values in the various trap properties, such as TrapAgentAddress , TrapEnterprise , TrapGenericType , TrapSpecificType , and TrapTimeStamp .


Field Summary
static int otCounter32
           
static int otCounter64
           
static int otGauge32
           
static int otInteger
           
static int otIPAddress
           
static int otNSAP
           
static int otNull
           
static int otObjectId
           
static int otOctetString
           
static int otOpaque
           
static int otTimeTicks
           
static int otUnsignedInteger32
           
static int snmpReset
           
static int snmpSendGetBulkRequest
           
static int snmpSendGetNextRequest
           
static int snmpSendGetRequest
           
static int snmpSendGetResponse
           
static int snmpSendInformRequest
           
static int snmpSendSetRequest
           
static int snmpSendTrap
           
static int snmpverDefault
           
static int snmpverV1
           
static int snmpverV2c
           
static int tgtAuthenticationFailure
           
static int tgtColdStart
           
static int tgtEGPNeighborLoss
           
static int tgtEnterpriseSpecific
           
static int tgtLinkDown
           
static int tgtLinkUp
           
static int tgtWarmStart
           
 
Constructor Summary
Snmp()
           
 
Method Summary
 void addSnmpEventListener(SnmpEventListener l)
           
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void fireGetBulkRequest(int requestId, java.lang.String community, int nonRepeaters, int maxRepetitions, java.lang.String sourceAddress, int sourcePort)
          Fired when a GetBulkRequest packet is received.
 void fireGetNextRequest(int requestId, java.lang.String community, java.lang.String sourceAddress, int sourcePort)
          Fired when a GetNextRequest packet is received.
 void fireGetRequest(int requestId, java.lang.String community, java.lang.String sourceAddress, int sourcePort)
          Fired when a GetRequest packet is received.
 void fireGetResponse(int requestId, java.lang.String community, int errorStatus, int errorIndex, java.lang.String sourceAddress, int sourcePort)
          Fired when a GetResponse packet is received.
 void fireInformRequest(int requestId, java.lang.String community, int errorStatus, int errorIndex, java.lang.String sourceAddress, int sourcePort)
          Fired when a SetRequest packet is received.
 void firePDUTrace(byte[] PDU, java.lang.String sourceAddress)
          Fired for every packet sent or received.
 void fireReadyToSend()
          Fired when the component is ready to send data.
 void fireSetRequest(int requestId, java.lang.String community, java.lang.String sourceAddress, int sourcePort)
          Fired when a SetRequest packet is received.
 void fireTrap(java.lang.String community, java.lang.String enterprise, java.lang.String agentAddress, int genericType, int specificType, int timeStamp, java.lang.String sourceAddress, int sourcePort)
          Fired when a SNMP trap packet is received.
 int getAction()
          An action code for the component.
 java.lang.String getCommunity()
          The community string used to authenticate SNMP packets.
 int getErrorIndex()
          Index of the first variable (object) that caused an error.
 int getErrorStatus()
          Status code for outgoing 'GET RESPONSE' packets.
 int getInBufferSize()
          The size in bytes of the incoming queue of the socket.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 int getLocalPort()
          The UDP port in the local host where the SNMP component listens to.
 int getMaxRepetitions()
          Used by 'BULK REQUEST' packets.
 int getNonRepeaters()
          Used by 'BULK REQUEST' packets.
 int getObjCount()
          Number of objects in the current request.
 java.lang.String getObjId(int objIndex)
          Array of OIDs encoded as strings.
 int getObjType(int objIndex)
          Array of object types.
 byte[] getObjValue(int objIndex)
          Array of object values.
 int getOutBufferSize()
          The size in bytes of the outgoing queue of the socket.
 java.lang.String getRemoteHost()
          The address of the remote host.
 int getRemotePort()
          The UDP port where the remote SNMP agent is listening.
 int getRequestId()
          The request-id to mark outgoing packets with.
 int getSNMPVersion()
          Version of SNMP used for outgoing packets.
 java.lang.String getTrapAgentAddress()
          The address of the object generating the trap.
 java.lang.String getTrapEnterprise()
          The type of the object generating the trap.
 int getTrapGenericType()
          The generic type of the trap being sent.
 int getTrapSpecificType()
          The specific type of the trap being sent.
 int getTrapTimeStamp()
          Time passed since the agent was initialized (in hundredths of a second).
 boolean isAcceptData()
          Enables or disables data reception.
 boolean isActive()
          Enables or disables sending and receiving of SNMP packets.
 boolean isShareLocalPort()
          If set to True, allows more than one instance of the component to be Active on the same LocalPort .
 void removeSnmpEventListener(SnmpEventListener l)
           
 void reset()
          Clears the object arrays.
 void sendGetBulkRequest()
          Send a GetBulkRequest packet.
 void sendGetNextRequest()
          Send GetNextRequest packet.
 void sendGetRequest()
          Send GetRequest packet.
 void sendGetResponse()
          Send Get Response packet.
 void sendInformRequest()
          Send an InformRequest packet.
 void sendSetRequest()
          Send Set Request packet.
 void sendTrap()
          Send Trap packet.
 void setAcceptData(boolean acceptData)
          Enables or disables data reception.
 void setAction(int action)
          An action code for the component.
 void setActive(boolean active)
          Enables or disables sending and receiving of SNMP packets.
 void setCommunity(java.lang.String community)
          The community string used to authenticate SNMP packets.
 void setErrorIndex(int errorIndex)
          Index of the first variable (object) that caused an error.
 void setErrorStatus(int errorStatus)
          Status code for outgoing 'GET RESPONSE' packets.
 void setInBufferSize(int inBufferSize)
          The size in bytes of the incoming queue of the socket.
 void setLocalHost(java.lang.String localHost)
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 void setLocalPort(int localPort)
          The UDP port in the local host where the SNMP component listens to.
 void setMaxRepetitions(int maxRepetitions)
          Used by 'BULK REQUEST' packets.
 void setNonRepeaters(int nonRepeaters)
          Used by 'BULK REQUEST' packets.
 void setObjCount(int objCount)
          Number of objects in the current request.
 void setObjId(int objIndex, java.lang.String objId)
          Array of OIDs encoded as strings.
 void setObjType(int objIndex, int objType)
          Array of object types.
 void setObjValue(int objIndex, byte[] objValue)
          Array of object values.
 void setOutBufferSize(int outBufferSize)
          The size in bytes of the outgoing queue of the socket.
 void setRemoteHost(java.lang.String remoteHost)
          The address of the remote host.
 void setRemotePort(int remotePort)
          The UDP port where the remote SNMP agent is listening.
 void setRequestId(int requestId)
          The request-id to mark outgoing packets with.
 void setShareLocalPort(boolean shareLocalPort)
          If set to True, allows more than one instance of the component to be Active on the same LocalPort .
 void setSNMPVersion(int SNMPVersion)
          Version of SNMP used for outgoing packets.
 void setTrapAgentAddress(java.lang.String trapAgentAddress)
          The address of the object generating the trap.
 void setTrapEnterprise(java.lang.String trapEnterprise)
          The type of the object generating the trap.
 void setTrapGenericType(int trapGenericType)
          The generic type of the trap being sent.
 void setTrapSpecificType(int trapSpecificType)
          The specific type of the trap being sent.
 void setTrapTimeStamp(int trapTimeStamp)
          Time passed since the agent was initialized (in hundredths of a second).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

snmpReset

public static final int snmpReset

snmpSendGetRequest

public static final int snmpSendGetRequest

snmpSendGetNextRequest

public static final int snmpSendGetNextRequest

snmpSendSetRequest

public static final int snmpSendSetRequest

snmpSendGetResponse

public static final int snmpSendGetResponse

snmpSendTrap

public static final int snmpSendTrap

snmpSendGetBulkRequest

public static final int snmpSendGetBulkRequest

snmpSendInformRequest

public static final int snmpSendInformRequest

otInteger

public static final int otInteger

otOctetString

public static final int otOctetString

otNull

public static final int otNull

otObjectId

public static final int otObjectId

otIPAddress

public static final int otIPAddress

otCounter32

public static final int otCounter32

otGauge32

public static final int otGauge32

otTimeTicks

public static final int otTimeTicks

otOpaque

public static final int otOpaque

otNSAP

public static final int otNSAP

otCounter64

public static final int otCounter64

otUnsignedInteger32

public static final int otUnsignedInteger32

snmpverDefault

public static final int snmpverDefault

snmpverV1

public static final int snmpverV1

snmpverV2c

public static final int snmpverV2c

tgtColdStart

public static final int tgtColdStart

tgtWarmStart

public static final int tgtWarmStart

tgtLinkDown

public static final int tgtLinkDown

tgtLinkUp

public static final int tgtLinkUp

tgtAuthenticationFailure

public static final int tgtAuthenticationFailure

tgtEGPNeighborLoss

public static final int tgtEGPNeighborLoss

tgtEnterpriseSpecific

public static final int tgtEnterpriseSpecific
Constructor Detail

Snmp

public Snmp()
Method Detail

isAcceptData

public boolean isAcceptData()
Enables or disables data reception. Setting the property to False, temporarily disables data reception. Setting the property to True, reenables data reception.


setAcceptData

public void setAcceptData(boolean acceptData)
                   throws IPWorksException
Enables or disables data reception. Setting the property to False, temporarily disables data reception. Setting the property to True, reenables data reception.


getAction

public int getAction()
An action code for the component. Setting the Action property to a valid action code makes the control perform the associated action. If the action completes successfully, execution continues normally, and Action is reset to 0 (Idle). If an error happens, then an IPWorksException exception is raised.

For every action except snmpReset the control creates an SNMP packet based on the values provided in the correspoding properties (described below), and attempts to send it to RemoteHost at the port specified by RemotePort .

The control attempts to send the packet as a complete message. If the socket buffer is full, or the message cannot be delivered for any other reason, an error is returned, and no portion of the packet is sent. You may then try to resend the packet later.

The same thing may happend if you are sending packets to the remote host faster than it can process them, or faster than the network's bandwidth allows. If this is the case, the assignment to Action

The following are the possible values for the Action property:

snmpReset (0)
Clears the object arrays, and sets the trap and error properties to their default values. This is useful for reinitializing the all the properties that are used to create outgoing packets before building a new packet.
snmpSendGetRequest (1)
Sends a GetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .
snmpSendGetNextRequest (2)
Sends a GetNextRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .
snmpSendSetRequest (3)
Sends a SetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .
snmpSendGetResponse (4)
Sends a GetResponse packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .
snmpSendTrap (5)
Sends a Trap packet. The properties used to build the packet are the following: Community , TrapEnterprise , TrapAgentAddress , TrapGenericType , TrapSpecificType , TrapTimeStamp , ObjId , ObjType , ObjValue , ObjCount . Depending upon the value of SNMPVersion , the packet is constructed as an SNMPv1 or SNMPv2 Trap.
snmpSendGetBulkRequest (6)
Sends a GetBulkRequest packet. The properties used to build the packet are the following: RequestId , Community , NonRepeaters , MaxRepetitions , ObjId , ObjType , ObjCount .
snmpSendInformRequest (7)
Sends an InformRequest packet. The properties used to build the packet are the following: RequestId , Community , ObjId , ObjType , ObjCount .


setAction

public void setAction(int action)
               throws IPWorksException
An action code for the component. Setting the Action property to a valid action code makes the control perform the associated action. If the action completes successfully, execution continues normally, and Action is reset to 0 (Idle). If an error happens, then an IPWorksException exception is raised.

For every action except snmpReset the control creates an SNMP packet based on the values provided in the correspoding properties (described below), and attempts to send it to RemoteHost at the port specified by RemotePort .

The control attempts to send the packet as a complete message. If the socket buffer is full, or the message cannot be delivered for any other reason, an error is returned, and no portion of the packet is sent. You may then try to resend the packet later.

The same thing may happend if you are sending packets to the remote host faster than it can process them, or faster than the network's bandwidth allows. If this is the case, the assignment to Action

The following are the possible values for the Action property:

snmpReset (0)
Clears the object arrays, and sets the trap and error properties to their default values. This is useful for reinitializing the all the properties that are used to create outgoing packets before building a new packet.
snmpSendGetRequest (1)
Sends a GetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .
snmpSendGetNextRequest (2)
Sends a GetNextRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .
snmpSendSetRequest (3)
Sends a SetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .
snmpSendGetResponse (4)
Sends a GetResponse packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .
snmpSendTrap (5)
Sends a Trap packet. The properties used to build the packet are the following: Community , TrapEnterprise , TrapAgentAddress , TrapGenericType , TrapSpecificType , TrapTimeStamp , ObjId , ObjType , ObjValue , ObjCount . Depending upon the value of SNMPVersion , the packet is constructed as an SNMPv1 or SNMPv2 Trap.
snmpSendGetBulkRequest (6)
Sends a GetBulkRequest packet. The properties used to build the packet are the following: RequestId , Community , NonRepeaters , MaxRepetitions , ObjId , ObjType , ObjCount .
snmpSendInformRequest (7)
Sends an InformRequest packet. The properties used to build the packet are the following: RequestId , Community , ObjId , ObjType , ObjCount .


isActive

public boolean isActive()
Enables or disables sending and receiving of SNMP packets. The Active property must be set to True before any SNMP requests or traps may be sent through the Action property. or received through the respective events.


setActive

public void setActive(boolean active)
               throws IPWorksException
Enables or disables sending and receiving of SNMP packets. The Active property must be set to True before any SNMP requests or traps may be sent through the Action property. or received through the respective events.


getCommunity

public java.lang.String getCommunity()
The community string used to authenticate SNMP packets. Must match the community name that is specified on the agent.

Typical values are "public" or "private".

This property is used when SNMP packets are sent via the Action property. When a packet is received through events such as Trap , GetRequest etc.., the corresponding value is provided through the respective event parameter.


setCommunity

public void setCommunity(java.lang.String community)
                  throws IPWorksException
The community string used to authenticate SNMP packets. Must match the community name that is specified on the agent.

Typical values are "public" or "private".

This property is used when SNMP packets are sent via the Action property. When a packet is received through events such as Trap , GetRequest etc.., the corresponding value is provided through the respective event parameter.


getErrorIndex

public int getErrorIndex()
Index of the first variable (object) that caused an error. This property is used in conjunction with the ErrorStatus property and is used to construct outgoing 'GET RESPONSE' packets. For 'GET RESPONSE' packets received through the GetResponse event, the corresponding value is provided as an event parameter.

Variable indexes start with 0. The ErrorIndex property has no meaning when the ErrorStatus property is 0 (no error).


setErrorIndex

public void setErrorIndex(int errorIndex)
                   throws IPWorksException
Index of the first variable (object) that caused an error. This property is used in conjunction with the ErrorStatus property and is used to construct outgoing 'GET RESPONSE' packets. For 'GET RESPONSE' packets received through the GetResponse event, the corresponding value is provided as an event parameter.

Variable indexes start with 0. The ErrorIndex property has no meaning when the ErrorStatus property is 0 (no error).


getErrorStatus

public int getErrorStatus()
Status code for outgoing 'GET RESPONSE' packets. This property is used in conjunction with the ErrorIndex property and is used to construct outgoing 'GET RESPONSE' packets. For 'GET RESPONSE' packets received through the GetResponse event, the corresponding value is provided as an event parameter.

Possible values include:

0 (noError)
No error.
1 (tooBig)
The response cannot fit in a single SNMP message.
2 (noSuchName)
Variable does not exist.
3 (badValue)
Invalid value or syntax.
4 (readOnly)
Variable is read-only.
5 (genError)
Other error (SNMPv1).
6 (noAccess)
Access denied.
7 (wrongType)
Wrong object type.
8 (wrongLength)
Wrong length.
9 (wrongEncoding)
Wrong encoding.
10 (wrongValue)
Wrong value.
11 (noCreation)
No creation.
12 (inconsistentValue)
Inconsistent value.
13 (resourceUnavailable)
Resource unavailable.
14 (commitFailed)
Commit failed.
15 (undoFailed)
Undo failed.
16 (authorizationError)
Authorization error.
17 (notWritable)
Variable is not writable.
18 (inconsistentName)
Inconsistent name.

The default value is 0 (no error).


setErrorStatus

public void setErrorStatus(int errorStatus)
                    throws IPWorksException
Status code for outgoing 'GET RESPONSE' packets. This property is used in conjunction with the ErrorIndex property and is used to construct outgoing 'GET RESPONSE' packets. For 'GET RESPONSE' packets received through the GetResponse event, the corresponding value is provided as an event parameter.

Possible values include:

0 (noError)
No error.
1 (tooBig)
The response cannot fit in a single SNMP message.
2 (noSuchName)
Variable does not exist.
3 (badValue)
Invalid value or syntax.
4 (readOnly)
Variable is read-only.
5 (genError)
Other error (SNMPv1).
6 (noAccess)
Access denied.
7 (wrongType)
Wrong object type.
8 (wrongLength)
Wrong length.
9 (wrongEncoding)
Wrong encoding.
10 (wrongValue)
Wrong value.
11 (noCreation)
No creation.
12 (inconsistentValue)
Inconsistent value.
13 (resourceUnavailable)
Resource unavailable.
14 (commitFailed)
Commit failed.
15 (undoFailed)
Undo failed.
16 (authorizationError)
Authorization error.
17 (notWritable)
Variable is not writable.
18 (inconsistentName)
Inconsistent name.

The default value is 0 (no error).


getInBufferSize

public int getInBufferSize()
The size in bytes of the incoming queue of the socket. This is the size of an internal queue in the Winsock stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the InBufferSize property can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when control is activated the InBufferSize property reverts to its defined size. The same happens if you attempt to make it too large or too small.


setInBufferSize

public void setInBufferSize(int inBufferSize)
                     throws IPWorksException
The size in bytes of the incoming queue of the socket. This is the size of an internal queue in the Winsock stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the InBufferSize property can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when control is activated the InBufferSize property reverts to its defined size. The same happens if you attempt to make it too large or too small.


getLocalHost

public java.lang.String getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


setLocalHost

public void setLocalHost(java.lang.String localHost)
                  throws IPWorksException
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. The LocalHost property contains the name of the local host as obtained by the gethostname() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multihomed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


getLocalPort

public int getLocalPort()
The UDP port in the local host where the SNMP component listens to. The LocalPort property must be set before the SNMP control is activated ( Active is set to True). It instructs the control to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) allows Winsock to choose a port at random. The value chosen is provided via the $rpLocalPort; property after the control is activated through the Active property.

If you are implementing an SNMP Agent, then LocalPort must be set to 161 to listen for SNMP requests, or 162 to listen for SNMP traps. Note that only one application on the machine may bind to a particular port, so use this property carefully.

LocalPort cannot be changed once the control is Active . Any attempt to set the LocalPort property when the control is Active will generate an error.


setLocalPort

public void setLocalPort(int localPort)
                  throws IPWorksException
The UDP port in the local host where the SNMP component listens to. The LocalPort property must be set before the SNMP control is activated ( Active is set to True). It instructs the control to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) allows Winsock to choose a port at random. The value chosen is provided via the $rpLocalPort; property after the control is activated through the Active property.

If you are implementing an SNMP Agent, then LocalPort must be set to 161 to listen for SNMP requests, or 162 to listen for SNMP traps. Note that only one application on the machine may bind to a particular port, so use this property carefully.

LocalPort cannot be changed once the control is Active . Any attempt to set the LocalPort property when the control is Active will generate an error.


getMaxRepetitions

public int getMaxRepetitions()
Used by 'BULK REQUEST' packets. Used by 'BULK REQUEST' packets, the MaxRepetitions property specifies the number of lexicographic successors to be returned for variables other than those in the NonRepeaters list.


setMaxRepetitions

public void setMaxRepetitions(int maxRepetitions)
                       throws IPWorksException
Used by 'BULK REQUEST' packets. Used by 'BULK REQUEST' packets, the MaxRepetitions property specifies the number of lexicographic successors to be returned for variables other than those in the NonRepeaters list.


getNonRepeaters

public int getNonRepeaters()
Used by 'BULK REQUEST' packets. Used by 'BULK REQUEST' packets, the NonRepeaters property specifies the number of variables for which a single lexicographic successor is to be returned.


setNonRepeaters

public void setNonRepeaters(int nonRepeaters)
                     throws IPWorksException
Used by 'BULK REQUEST' packets. Used by 'BULK REQUEST' packets, the NonRepeaters property specifies the number of variables for which a single lexicographic successor is to be returned.


getObjCount

public int getObjCount()
Number of objects in the current request. The ObjCount property provides the number of elements in the various Obj arrays ( ObjId , ObjType , ObjValue ).

The arrays may be cleared at any time by setting the ObjCount to 0.


setObjCount

public void setObjCount(int objCount)
                 throws IPWorksException
Number of objects in the current request. The ObjCount property provides the number of elements in the various Obj arrays ( ObjId , ObjType , ObjValue ).

The arrays may be cleared at any time by setting the ObjCount to 0.


getObjId

public java.lang.String getObjId(int objIndex)
                          throws IPWorksException
Array of OIDs encoded as strings. The object id-s are encoded as strings of numbers separated by "."-s, for instance: "1.3.6.1.2.1.1.1.0" (OID for "system description").

The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set.

The corresponding object type and value (if any) are specified by the ObjType and ObjValue property arrays.


setObjId

public void setObjId(int objIndex,
                     java.lang.String objId)
              throws IPWorksException
Array of OIDs encoded as strings. The object id-s are encoded as strings of numbers separated by "."-s, for instance: "1.3.6.1.2.1.1.1.0" (OID for "system description").

The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set.

The corresponding object type and value (if any) are specified by the ObjType and ObjValue property arrays.


getObjType

public int getObjType(int objIndex)
               throws IPWorksException
Array of object types. The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set. The default type is NULL (5).

The corresponding object id and value are specified by the ObjId and ObjValue property arrays.

Possible values include:

otInteger (2)
2
otOctetString (4)
4
otNull (5)
5
otObjectID (6)
6
otIPAddress (64)
64
otCounter32 (65)
65
otGauge32 (66)
66
otTimeTicks (67)
67
otOpaque (68)
68
otNSAP (69)
69
otCounter64 (70)
70
otUnsignedInteger32 (71)
71


setObjType

public void setObjType(int objIndex,
                       int objType)
                throws IPWorksException
Array of object types. The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set. The default type is NULL (5).

The corresponding object id and value are specified by the ObjId and ObjValue property arrays.

Possible values include:

otInteger (2)
2
otOctetString (4)
4
otNull (5)
5
otObjectID (6)
6
otIPAddress (64)
64
otCounter32 (65)
65
otGauge32 (66)
66
otTimeTicks (67)
67
otOpaque (68)
68
otNSAP (69)
69
otCounter64 (70)
70
otUnsignedInteger32 (71)
71


getObjValue

public byte[] getObjValue(int objIndex)
                   throws IPWorksException
Array of object values. The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set.

The corresponding object id and type are specified by the ObjId and ObjType property arrays.


setObjValue

public void setObjValue(int objIndex,
                        byte[] objValue)
                 throws IPWorksException
Array of object values. The size of the array is determined by the ObjCount property. Element indexes start at 1.

The array is populated and its size is set every time an SNMP packet is received. It is also used to create an outgoing SNMP packet when the Action is set.

The corresponding object id and type are specified by the ObjId and ObjType property arrays.


getOutBufferSize

public int getOutBufferSize()
The size in bytes of the outgoing queue of the socket. This is the size of an internal queue in the Winsock stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the OutBufferSize property can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the control is activated the OutBufferSize property reverts to its defined size. The same happens if you attempt to make it too large or too small.


setOutBufferSize

public void setOutBufferSize(int outBufferSize)
                      throws IPWorksException
The size in bytes of the outgoing queue of the socket. This is the size of an internal queue in the Winsock stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the OutBufferSize property can provide significant improvements in performance in some cases.

Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the control is activated the OutBufferSize property reverts to its defined size. The same happens if you attempt to make it too large or too small.


getRemoteHost

public java.lang.String getRemoteHost()
The address of the remote host. Domain names are resolved to IP addresses. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the host SNMP requests or traps are sent to.

If RemoteHost is set to 255.255.255.255, the control broadcasts data on the local subnet.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws IPWorksException
The address of the remote host. Domain names are resolved to IP addresses. The RemoteHost property specifies the IP address (IP number in dotted internet format) or Domain Name of the host SNMP requests or traps are sent to.

If RemoteHost is set to 255.255.255.255, the control broadcasts data on the local subnet.

If the RemoteHost property is set to a Domain Name, a DNS request is initiated and upon successful termination of the request, the RemoteHost property is set to the corresponding address. If the search is not successful, an error is returned.


getRemotePort

public int getRemotePort()
The UDP port where the remote SNMP agent is listening. The RemotePort is the UDP port on the RemoteHost where to send SNMP requests to.

A valid port number (a value between 1 and 65535) is required. The special value 0 directs control to automatically select 161 for SNMP requests and 162 for SNMP traps.


setRemotePort

public void setRemotePort(int remotePort)
                   throws IPWorksException
The UDP port where the remote SNMP agent is listening. The RemotePort is the UDP port on the RemoteHost where to send SNMP requests to.

A valid port number (a value between 1 and 65535) is required. The special value 0 directs control to automatically select 161 for SNMP requests and 162 for SNMP traps.


getRequestId

public int getRequestId()
The request-id to mark outgoing packets with. If a custom value is needed for RequestId , the property must be set before setting Action . The control increments RequestId automatically after sending each packet.


setRequestId

public void setRequestId(int requestId)
                  throws IPWorksException
The request-id to mark outgoing packets with. If a custom value is needed for RequestId , the property must be set before setting Action . The control increments RequestId automatically after sending each packet.


isShareLocalPort

public boolean isShareLocalPort()
If set to True, allows more than one instance of the component to be Active on the same LocalPort . This option must be set before the control is activated through the Active property or it will have no effect.


setShareLocalPort

public void setShareLocalPort(boolean shareLocalPort)
                       throws IPWorksException
If set to True, allows more than one instance of the component to be Active on the same LocalPort . This option must be set before the control is activated through the Active property or it will have no effect.


getSNMPVersion

public int getSNMPVersion()
Version of SNMP used for outgoing packets. When an SNMP packet is received through an event, the SNMPVersion property changes to display the version of the received packet.
snmpverV1 (1)
SNMP Version 1.
snmpverV2c (2)
SNMP Version 2c.


setSNMPVersion

public void setSNMPVersion(int SNMPVersion)
                    throws IPWorksException
Version of SNMP used for outgoing packets. When an SNMP packet is received through an event, the SNMPVersion property changes to display the version of the received packet.
snmpverV1 (1)
SNMP Version 1.
snmpverV2c (2)
SNMP Version 2c.


getTrapAgentAddress

public java.lang.String getTrapAgentAddress()
The address of the object generating the trap. Defaults to the address of the localhost.

This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


setTrapAgentAddress

public void setTrapAgentAddress(java.lang.String trapAgentAddress)
                         throws IPWorksException
The address of the object generating the trap. Defaults to the address of the localhost.

This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


getTrapEnterprise

public java.lang.String getTrapEnterprise()
The type of the object generating the trap. The TrapEnterprise property is equal to the OID (object id) of the sending agent.

This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


setTrapEnterprise

public void setTrapEnterprise(java.lang.String trapEnterprise)
                       throws IPWorksException
The type of the object generating the trap. The TrapEnterprise property is equal to the OID (object id) of the sending agent.

This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


getTrapGenericType

public int getTrapGenericType()
The generic type of the trap being sent. This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.

Possible values of TrapGenericType include:

tgtColdStart (0)
The agent is initializing itself.
tgtWarmStart (1)
The agent is reinitializing itself.
tgtLinkDown (2)
An interface has gone down.
tgtLinkUp (3)
An interface has gone up.
tgtAuthenticationFailure (4)
A message was received from an SNMP manager with an invalid community.
tgtEGPNeighborLoss (5)
An EGP peer has gone down.
tgtEnterpriseSpecific (6)
Specific to the local SNMP implementation.


setTrapGenericType

public void setTrapGenericType(int trapGenericType)
                        throws IPWorksException
The generic type of the trap being sent. This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.

Possible values of TrapGenericType include:

tgtColdStart (0)
The agent is initializing itself.
tgtWarmStart (1)
The agent is reinitializing itself.
tgtLinkDown (2)
An interface has gone down.
tgtLinkUp (3)
An interface has gone up.
tgtAuthenticationFailure (4)
A message was received from an SNMP manager with an invalid community.
tgtEGPNeighborLoss (5)
An EGP peer has gone down.
tgtEnterpriseSpecific (6)
Specific to the local SNMP implementation.


getTrapSpecificType

public int getTrapSpecificType()
The specific type of the trap being sent. This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


setTrapSpecificType

public void setTrapSpecificType(int trapSpecificType)
                         throws IPWorksException
The specific type of the trap being sent. This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


getTrapTimeStamp

public int getTrapTimeStamp()
Time passed since the agent was initialized (in hundredths of a second). This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


setTrapTimeStamp

public void setTrapTimeStamp(int trapTimeStamp)
                      throws IPWorksException
Time passed since the agent was initialized (in hundredths of a second). This property is used when traps are sent via the Action property. When a trap is received through the Trap event, the corresponding value is provided through the respective event parameter.


fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
SnmpErrorEvent

fireGetBulkRequest

public void fireGetBulkRequest(int requestId,
                               java.lang.String community,
                               int nonRepeaters,
                               int maxRepetitions,
                               java.lang.String sourceAddress,
                               int sourcePort)
Fired when a GetBulkRequest packet is received. (Called internally to dispatch the event.)
See Also:
SnmpGetBulkRequestEvent

fireGetNextRequest

public void fireGetNextRequest(int requestId,
                               java.lang.String community,
                               java.lang.String sourceAddress,
                               int sourcePort)
Fired when a GetNextRequest packet is received. (Called internally to dispatch the event.)
See Also:
SnmpGetNextRequestEvent

fireGetRequest

public void fireGetRequest(int requestId,
                           java.lang.String community,
                           java.lang.String sourceAddress,
                           int sourcePort)
Fired when a GetRequest packet is received. (Called internally to dispatch the event.)
See Also:
SnmpGetRequestEvent

fireGetResponse

public void fireGetResponse(int requestId,
                            java.lang.String community,
                            int errorStatus,
                            int errorIndex,
                            java.lang.String sourceAddress,
                            int sourcePort)
Fired when a GetResponse packet is received. (Called internally to dispatch the event.)
See Also:
SnmpGetResponseEvent

fireInformRequest

public void fireInformRequest(int requestId,
                              java.lang.String community,
                              int errorStatus,
                              int errorIndex,
                              java.lang.String sourceAddress,
                              int sourcePort)
Fired when a SetRequest packet is received. (Called internally to dispatch the event.)
See Also:
SnmpInformRequestEvent

firePDUTrace

public void firePDUTrace(byte[] PDU,
                         java.lang.String sourceAddress)
Fired for every packet sent or received. (Called internally to dispatch the event.)
See Also:
SnmpPDUTraceEvent

fireReadyToSend

public void fireReadyToSend()
Fired when the component is ready to send data. (Called internally to dispatch the event.)
See Also:
SnmpReadyToSendEvent

fireSetRequest

public void fireSetRequest(int requestId,
                           java.lang.String community,
                           java.lang.String sourceAddress,
                           int sourcePort)
Fired when a SetRequest packet is received. (Called internally to dispatch the event.)
See Also:
SnmpSetRequestEvent

fireTrap

public void fireTrap(java.lang.String community,
                     java.lang.String enterprise,
                     java.lang.String agentAddress,
                     int genericType,
                     int specificType,
                     int timeStamp,
                     java.lang.String sourceAddress,
                     int sourcePort)
Fired when a SNMP trap packet is received. (Called internally to dispatch the event.)
See Also:
SnmpTrapEvent

reset

public void reset()
           throws IPWorksException
Clears the object arrays. Clears the object arrays, and sets the trap and error properties to their default values. This is useful for reinitializing the all the properties that are used to create outgoing packets before building a new packet.

Calling this method is equivalent to setting the Action property to snmpReset .


sendGetBulkRequest

public void sendGetBulkRequest()
                        throws IPWorksException
Send a GetBulkRequest packet. Sends a GetBulkRequest packet. The properties used to build the packet are the following: RequestId , Community , NonRepeaters , MaxRepetitions , ObjId , ObjType , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendGetBulkRequest .


sendGetNextRequest

public void sendGetNextRequest()
                        throws IPWorksException
Send GetNextRequest packet. Sends a GetNextRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendGetNextRequest .


sendGetRequest

public void sendGetRequest()
                    throws IPWorksException
Send GetRequest packet. Sends a GetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendGetRequest .


sendGetResponse

public void sendGetResponse()
                     throws IPWorksException
Send Get Response packet. Sends a GetResponse packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendGetResponse .


sendInformRequest

public void sendInformRequest()
                       throws IPWorksException
Send an InformRequest packet. Sends a InformRequest packet. The properties used to build the packet are the following: RequestId , Community , ObjId , ObjType , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendInformRequest .


sendSetRequest

public void sendSetRequest()
                    throws IPWorksException
Send Set Request packet. Sends a SetRequest packet. The properties used to build the packet are the following: RequestId , Community , ErrorStatus , ErrorIndex , ObjId , ObjType , ObjValue , ObjCount .

Calling this method is equivalent to setting the Action property to snmpSendSetRequest .


sendTrap

public void sendTrap()
              throws IPWorksException
Send Trap packet. Sends a Trap packet. The properties used to build the packet are the following: Community , TrapEnterprise , TrapAgentAddress , TrapGenericType , TrapSpecificType , TrapTimeStamp , ObjId , ObjType , ObjValue , ObjCount .

Depending upon the value of SNMPVersion , the packet is constructed as an SNMPv1 or SNMPv2 Trap.

Calling this method is equivalent to setting the Action property to snmpSendTrap .


addSnmpEventListener

public void addSnmpEventListener(SnmpEventListener l)
                          throws java.util.TooManyListenersException

removeSnmpEventListener

public void removeSnmpEventListener(SnmpEventListener l)

IP*Works!

Copyright (c) 2001 /n software inc. - All rights reserved.