Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.co.westhawk.snmp.stack
Class SnmpContextv2c

    java.lang.Object
      |
      +--uk.co.westhawk.snmp.stack.AbstractSnmpContext
            |
            +--uk.co.westhawk.snmp.stack.SnmpContext
                  |
                  +--uk.co.westhawk.snmp.stack.SnmpContextv2c

All Implemented Interfaces:
  java.lang.Cloneable, java.util.EventListener, RawPduListener, java.lang.Runnable, SnmpContextBasisFace, SnmpContextFace, SnmpContextv2cFace

Direct Known Subclasses:
  PassiveSnmpContextv2c

public class SnmpContextv2c
extends SnmpContext
implements SnmpContextv2cFace, java.lang.Cloneable

This class contains the SNMP v2c context that is needed by every PDU to send a SNMP v2c request.

`destroy()` should be called when the context is no longer used. This is the only way the threads will be stopped and garbage collected.

Version:
  $Revision: 3.14 $ $Date: 2006/02/09 14:16:36 $
Author:
  Birgit Arkesteijn
See Also:
  `SnmpContextv2cFace`, `SnmpContextv2cPool`

Field Summary

Fields inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext
`anyPduExpectingResponse, bindAddr, hostname, hostPort, isDestroyed, maxRecvSize, pduSupport, trapSupport, typeSocket`

Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextv2cFace
`version_id`

Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextFace
`DEFAULT_COMMUNITY`

Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextBasisFace
`DEFAULT_PORT, KVM_SOCKET, MAXPDU, MSS, NETSCAPE_SOCKET, STANDARD_SOCKET, TCP_SOCKET`

Fields inherited from interface uk.co.westhawk.snmp.event.RawPduListener
`version_id`

Constructor Summary
`SnmpContextv2c(java.lang.String host, int port)` Constructor.
`SnmpContextv2c(java.lang.String host, int port, java.lang.String typeSocketA)` Constructor.
`SnmpContextv2c(java.lang.String host, int port, java.lang.String bindAddress, java.lang.String typeSocketA)` Constructor.

Method Summary
`java.lang.Object` | `clone()` Returns a clone of this SnmpContextv2c.
`byte[]` | `encodePacket(byte msg_type, int rId, int errstat, int errind, java.util.Enumeration ve, java.lang.Object obj)` Encodes a PDU.
`java.lang.String` | `getHashKey()` Returns the hash key.
`int` | `getVersion()` Returns the SNMP version of the context.
`Pdu` | `processIncomingPdu(byte[] message)` Processes an incoming PDU.
`protected void` | `processIncomingResponse(java.io.ByteArrayInputStream in)` Processes an incoming SNMP v2c response.
`java.lang.String` | `toString()` Returns a string representation of the object.

Methods inherited from class uk.co.westhawk.snmp.stack.SnmpContext
`encodePacket, getCommunity, setCommunity`

Methods inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext
`activate, addPdu, addRequestPduListener, addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, freeTransmitters, getBindAddress, getDebugString, getHost, getHostAddress, getMaxRecvSize, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, rawPduReceived, removePdu, removeRequestPduListener, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, run, sendPacket, setMaxRecvSize, stop`

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

Methods inherited from interface uk.co.westhawk.snmp.stack.SnmpContextFace
`getCommunity, setCommunity`

Methods inherited from interface uk.co.westhawk.snmp.stack.SnmpContextBasisFace
`addPdu, addRequestPduListener, addRequestPduListener, addRequestPduListener, addTrapListener, addTrapListener, addTrapListener, destroy, getBindAddress, getHost, getPort, getReceivedFromHostAddress, getSendToHostAddress, getTypeSocket, isDestroyed, removePdu, removeRequestPduListener, removeRequestPduListener, removeRequestPduListener, removeTrapListener, removeTrapListener, removeTrapListener, sendPacket`

Constructor Detail

### SnmpContextv2c

    public SnmpContextv2c(java.lang.String host,
                          int port)
                   throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the PDU will be sent
  `port` - The port where the SNMP server will be
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int)`

### SnmpContextv2c

    public SnmpContextv2c(java.lang.String host,
                          int port,
                          java.lang.String typeSocketA)
                   throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the Pdu will be sent
  `port` - The port where the SNMP server will be
  `typeSocketA` - The local address the server will bind to
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int, String)`

### SnmpContextv2c

    public SnmpContextv2c(java.lang.String host,
                          int port,
                          java.lang.String bindAddress,
                          java.lang.String typeSocketA)
                   throws java.io.IOException

  Constructor.

Parameters:
  `host` - The host to which the PDU will be sent
  `port` - The port where the SNMP server will be
  `bindAddress` - The local address the server will bind to
  `typeSocketA` - The type of socket to use.
Since:
  4_14
See Also:
  `AbstractSnmpContext.AbstractSnmpContext(String, int, String, String)`, `SnmpContextBasisFace.STANDARD_SOCKET`, `SnmpContextBasisFace.TCP_SOCKET`, `SnmpContextBasisFace.NETSCAPE_SOCKET`, `SnmpContextBasisFace.KVM_SOCKET`

Method Detail

### getVersion

    public int getVersion()

  Description copied from interface: `SnmpContextBasisFace`
  Returns the SNMP version of the context.

  Specified by:
    `getVersion` in interface `SnmpContextBasisFace`
  Overrides:
    `getVersion` in class `SnmpContext`
  Returns:
    The version
  See Also:
    `SnmpConstants.SNMP_VERSION_1`, `SnmpConstants.SNMP_VERSION_2c`, `SnmpConstants.SNMP_VERSION_3`

### encodePacket

    public byte[] encodePacket(byte msg_type,
                               int rId,
                               int errstat,
                               int errind,
                               java.util.Enumeration ve,
                               java.lang.Object obj)
                        throws java.io.IOException,
                               EncodingException

  Description copied from interface: `SnmpContextBasisFace`
  Encodes a PDU. This is for internal use only and should NOT be called by the developer. This is called by the the PDU itself and is added to the interface to cover the different kind of Contexts.

  Specified by:
    `encodePacket` in interface `SnmpContextBasisFace`
  Overrides:
    `encodePacket` in class `SnmpContext`
  Parameters:
    `msg_type` - The message type
    `rId` - The message id
    `errstat` - The error status
    `errind` - The error index
    `ve` - The varbind list
    `obj` - Additional object (only used in SNMPv3)
  Returns:
    The encoded packet
    `java.io.IOException`
    `EncodingException`

### processIncomingResponse

    protected void processIncomingResponse(java.io.ByteArrayInputStream in)
                                    throws DecodingException,
                                           java.io.IOException

  Processes an incoming SNMP v2c response.

  Overrides:
    `processIncomingResponse` in class `SnmpContext`
    `DecodingException`
    `java.io.IOException`
  See Also:
    `AbstractSnmpContext.run()`

### processIncomingPdu

    public Pdu processIncomingPdu(byte[] message)
                           throws DecodingException,
                                  java.io.IOException

  Description copied from interface: `SnmpContextBasisFace`
  Processes an incoming PDU. The context will try to process the incoming PDU, using the SNMP version and other security parameters. If any of these do not correspond, a DecodingException will be thrown.

  Specified by:
    `processIncomingPdu` in interface `SnmpContextBasisFace`
  Overrides:
    `processIncomingPdu` in class `SnmpContext`
    `DecodingException`
    `java.io.IOException`
  See Also:
    `AbstractSnmpContext.rawPduReceived(uk.co.westhawk.snmp.event.RawPduEvent)`

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Returns a clone of this SnmpContextv2c.

  Specified by:
    `clone` in interface `SnmpContextBasisFace`
  Overrides:
    `clone` in class `SnmpContext`
  Throws:
    `java.lang.CloneNotSupportedException` - Thrown when the constructor generates an IOException

### getHashKey

    public java.lang.String getHashKey()

  Returns the hash key. This key is built out of all properties. It serves as key for a hashtable of (v2c) contexts.

  Specified by:
    `getHashKey` in interface `SnmpContextBasisFace`
  Overrides:
    `getHashKey` in class `SnmpContext`
  Returns:
    The hash key
  Since:
    4_14

### toString

    public java.lang.String toString()

  Returns a string representation of the object.

  Overrides:
    `toString` in class `SnmpContext`
  Returns:
    The string

Overview | Package | Class | Tree | Deprecated | Index | Help
| SNMP Stack 5_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD