SNMP Stack 4_12

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, java.lang.Runnable, SnmpContextBasisFace, SnmpContextFace, SnmpContextv2cFace, TrapListener
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.9 $ $Date: 2002/10/23 11:48:01 $
Author:
Birgit Arkesteijn
See Also:
SnmpContextv2cFace, SnmpContextv2cPool

Fields inherited from class uk.co.westhawk.snmp.stack.SnmpContext
Default_Community
 
Fields inherited from class uk.co.westhawk.snmp.stack.AbstractSnmpContext
hostAddr, hostPort, isDestroyed, maxRecvSize, typeSocket
 
Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextv2cFace
version_id
 
Fields inherited from interface uk.co.westhawk.snmp.stack.SnmpContextBasisFace
DEFAULT_PORT, KVM_SOCKET, MAXPDU, MSS, NETSCAPE_SOCKET, STANDARD_SOCKET
 
Fields inherited from interface uk.co.westhawk.snmp.event.TrapListener
version_id
 
Constructor Summary
SnmpContextv2c(java.lang.String host, int port)
          Constructor.
SnmpContextv2c(java.lang.String host, int port, 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)
          Encodes a SNMP v2c pdu packet.
 int getVersion()
          Return the SNMP version of the context.
protected  void ProcessIncomingMessage(uk.co.westhawk.snmp.stack.AsnDecoder rpdu, java.io.ByteArrayInputStream in)
          Processes an incoming SNMP v2c message.
 Pdu processIncomingTrap(byte[] message)
          Processes an incoming trap.
 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, addTrapListener, destroy, getDebugString, getHost, getHostAddress, getMaxRecvSize, getPort, getTypeSocket, removePdu, removeTrapListener, run, sendPacket, setMaxRecvSize, stop, trapReceived
 
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, addTrapListener, destroy, getHost, getPort, getTypeSocket, removePdu, 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 send
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 send
port - The port where the SNMP server will be
typeSocketA - The type of socket to use.
See Also:
AbstractSnmpContext.AbstractSnmpContext(String, int, String), SnmpContextBasisFace.STANDARD_SOCKET, SnmpContextBasisFace.NETSCAPE_SOCKET, SnmpContextBasisFace.KVM_SOCKET
Method Detail

getVersion

public int getVersion()
Description copied from interface: SnmpContextBasisFace
Return the SNMP version of the context.
Specified by:
getVersion in interface SnmpContextBasisFace
Overrides:
getVersion in class SnmpContext
Following copied from interface: uk.co.westhawk.snmp.stack.SnmpContextBasisFace
Returns:
The version

encodePacket

public byte[] encodePacket(byte msg_type,
                           int rId,
                           int errstat,
                           int errind,
                           java.util.Enumeration ve)
                    throws java.io.IOException,
                           EncodingException
Encodes a SNMP v2c pdu packet.
Specified by:
encodePacket in interface SnmpContextBasisFace
Overrides:
encodePacket in class SnmpContext
Following copied from interface: uk.co.westhawk.snmp.stack.SnmpContextBasisFace
Returns:
The encoded packet

ProcessIncomingMessage

protected void ProcessIncomingMessage(uk.co.westhawk.snmp.stack.AsnDecoder rpdu,
                                      java.io.ByteArrayInputStream in)
                               throws DecodingException,
                                      java.io.IOException
Processes an incoming SNMP v2c message.
Overrides:
ProcessIncomingMessage in class SnmpContext
Following copied from class: uk.co.westhawk.snmp.stack.AbstractSnmpContext
See Also:
AbstractSnmpContext.run()

processIncomingTrap

public Pdu processIncomingTrap(byte[] message)
                        throws DecodingException,
                               java.io.IOException
Description copied from interface: SnmpContextBasisFace
Processes an incoming trap. The context will try to process the incoming trap, using the SNMP version and other security parameters. If any of these do not correspond, a DecodingException will be thrown.
Specified by:
processIncomingTrap in interface SnmpContextBasisFace
Overrides:
processIncomingTrap in class SnmpContext
Following copied from class: uk.co.westhawk.snmp.stack.AbstractSnmpContext
See Also:
AbstractSnmpContext.trapReceived(uk.co.westhawk.snmp.event.TrapEvent)

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Returns a clone of this SnmpContextv2c.
Overrides:
clone in class SnmpContext
Throws:
java.lang.CloneNotSupportedException - Thrown when the constructor generates an IOException

toString

public java.lang.String toString()
Returns a string representation of the object.
Overrides:
toString in class SnmpContext
Returns:
The string

SNMP Stack 4_12