Interface SnmpContextBasisFace

All Known Subinterfaces:
SnmpContextFace, SnmpContextv2cFace, SnmpContextv3Face
All Known Implementing Classes:
AbstractSnmpContext, PassiveSnmpContext, PassiveSnmpContextv2c, SnmpContext, SnmpContextPool, SnmpContextv2c, SnmpContextv2cPool, SnmpContextv3, SnmpContextv3Basis, SnmpContextv3Discovery, SnmpContextv3Pool

public interface SnmpContextBasisFace
This interface contains the SNMP context interface that is needed by every PDU to send a SNMP v1, v2c and v3 request. The context also provides functionality to receive incoming PDUs.
Version:
$Revision: 3.9 $ $Date: 2006/11/29 16:25:19 $
Author:
Tim Panton
See Also:
  • Field Details

  • Method Details

    • getVersion

      int getVersion()
      Returns the SNMP version of the context.
      Returns:
      The version
      See Also:
    • getHost

      String getHost()
      Returns the host.
      Returns:
      The host
    • getPort

      int getPort()
      Returns the port number.
      Returns:
      The port no
    • getBindAddress

      String getBindAddress()
      Returns the local bind address. If bindAddress is null, then the system will pick up a valid local address to bind the socket.
      Returns:
      The local bind address
      Since:
      4_14
    • getTypeSocket

      String getTypeSocket()
      Returns the type of socket.
      Returns:
      The type of socket
      See Also:
    • getSendToHostAddress

      String getSendToHostAddress()
      Returns the IP address string aaa.bbb.ccc.ddd (IPv4) or a:b:c:d:e:f:g:h (IPv6) of the host the packets where sent to.
      Returns:
      The IP address of the host the packets where sent to.
      Since:
      4_14
      See Also:
    • getReceivedFromHostAddress

      String getReceivedFromHostAddress()
      Returns the IP address string aaa.bbb.ccc.ddd (IPv4) or a:b:c:d:e:f:g:h (IPv6) of the (latest) host the packets where received from.
      Returns:
      The IP address of the (latest) host the packets where received from.
      Since:
      4_14
      See Also:
    • addPdu

      boolean addPdu(Pdu pdu) throws IOException, PduException
      Adds a PDU to the context. 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.
      Parameters:
      pdu - the PDU
      Returns:
      whether the PDU has been successfully added
      Throws:
      IOException
      PduException
    • removePdu

      boolean removePdu(int requestId)
      Removes a PDU from the context. 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.
      Parameters:
      requestId - the PDU request id
      Returns:
      whether the PDU has been successfully removed
    • encodePacket

      byte[] encodePacket(byte msg_type, int rId, int errstat, int errind, Enumeration ve, Object obj) throws IOException, EncodingException
      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.
      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
      Throws:
      IOException
      EncodingException
    • sendPacket

      void sendPacket(byte[] packet)
      Sends an encoded 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.
      Parameters:
      packet - The encoded packet
    • destroy

      void destroy()
      Removes the resouces held by this context. Should be called by the user/developer when the context is no longer needed.
    • isDestroyed

      boolean isDestroyed()
      Returns whether or not this context has been destroyed.
      Since:
      4_14
    • addTrapListener

      void addTrapListener(TrapListener l) throws IOException
      Adds the specified trap listener to receive traps on the default trap port 162 from the host that matches this context.

      The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.

      Parameters:
      l - The trap listener
      Throws:
      IOException
      See Also:
    • removeTrapListener

      void removeTrapListener(TrapListener l) throws IOException
      Removes the specified trap listener from listening for packets on the default trap port 162.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()

      Parameters:
      l - The trap listener
      Throws:
      IOException
      See Also:
    • addTrapListener

      void addTrapListener(TrapListener l, int port) throws IOException
      Adds the specified trap listener to receive traps on the specified port from the host that matches this context.

      The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.

      Parameters:
      l - The trap listener
      port - The port the traps are received on
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • removeTrapListener

      void removeTrapListener(TrapListener l, int port) throws IOException
      Removes the specified trap listener from listening for packets on the specified port.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()

      Parameters:
      l - The trap listener
      port - The port the traps are received on
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • addTrapListener

      void addTrapListener(TrapListener l, ListeningContextPool lcontext) throws IOException
      Adds the specified trap listener to receive traps on the specified listening context that matches this context.

      The ListeningContext class will do the actual listening for traps. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a trap pdu.

      Parameters:
      l - The trap listener
      lcontext - The listening context
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • removeTrapListener

      void removeTrapListener(TrapListener l, ListeningContextPool lcontext) throws IOException
      Removes the specified trap listener from listening for packets on the specified listening context.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeTrapListenerFromPool()

      Parameters:
      l - The trap listener
      lcontext - The listening context
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • addRequestPduListener

      void addRequestPduListener(RequestPduListener l) throws IOException
      Adds the specified request pdu listener to receive PDUs on the default request pdu port 161 from the host that matches this context.

      The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.

      Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.

      Parameters:
      l - The request PDU listener
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • removeRequestPduListener

      void removeRequestPduListener(RequestPduListener l) throws IOException
      Removes the specified request pdu listener from listening for packets on the default request pdu port 161.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()

      Parameters:
      l - The request PDU listener
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • addRequestPduListener

      void addRequestPduListener(RequestPduListener l, int port) throws IOException
      Adds the specified request pdu listener to receive PDUs on the specified port from the host that matches this context.

      The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.

      Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.

      Parameters:
      l - The request PDU listener
      port - The port the request PDUs are received on
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • removeRequestPduListener

      void removeRequestPduListener(RequestPduListener l, int port) throws IOException
      Removes the specified request pdu listener from listening for packets on the specified port.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()

      Parameters:
      l - The request PDU listener
      port - The port the request PDUs are received on
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • addRequestPduListener

      void addRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws IOException
      Adds the specified request pdu listener to receive PDUs on the specified listening context that matches this context.

      The ListeningContext class will do the actual listening for PDUs. This context will add itself to a ListeningContextPool object and will only pass the event to its listeners if the pdu matches this context and is a request pdu.

      Don't use the TCP_SOCKET when listening for request PDUs. It doesn't provide functionality to send a response back.

      Parameters:
      l - The request PDU listener
      lcontext - The listening context
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • removeRequestPduListener

      void removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext) throws IOException
      Removes the specified request pdu listener from listening for packets on the specified listening context.

      The listener will not be removed from all ListeningContext objects that are in the ListeningContextPool. In order to do that, use ListeningContextPool.removeRequestPduListenerFromPool()

      Parameters:
      l - The request PDU listener
      lcontext - The listening context
      Throws:
      IOException
      Since:
      4_14
      See Also:
    • processIncomingPdu

      Pdu processIncomingPdu(byte[] message) throws DecodingException, IOException
      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.
      Throws:
      DecodingException
      IOException
    • clone

      Returns a clone of this SnmpContext.
      Throws:
      CloneNotSupportedException - Thrown when the constructor generates an IOException or when in one of the Pool classes.
      Since:
      4_14
    • getHashKey

      String getHashKey()
      Returns the hash key. This key is built out of all properties.
      Returns:
      The hash key
      Since:
      4_14