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
Interface SnmpContextBasisFace

All Known Subinterfaces:
  SnmpContextFace, SnmpContextv2cFace, SnmpContextv3Face

All Known Implementing Classes:
  AbstractSnmpContext, SnmpContext, SnmpContextPool, SnmpContextv2c, SnmpContextv2cPool, SnmpContextv3Basis, 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.8 $ $Date: 2006/02/09 14:30:19 $
Author:
  Tim Panton
See Also:
  `SnmpContext`, `SnmpContextv2c`, `SnmpContextv3`

Field Summary
`static int` | `DEFAULT_PORT` The default port number where SNMP requests are sent to (161).
`static java.lang.String` | `KVM_SOCKET` The KVM Socket type.
`static int` | `MAXPDU` The Maximum number of outstanding PDUs one context can handle at a given moment in time.
`static int` | `MSS` The Maximum size of a message in octets (1300).
`static java.lang.String` | `NETSCAPE_SOCKET` The Netscape Socket type.
`static java.lang.String` | `STANDARD_SOCKET` The Standard Socket type.
`static java.lang.String` | `TCP_SOCKET` The TCP Socket type.
`static java.lang.String` | `version_id`

Method Summary
`boolean` | `addPdu(Pdu pdu)` Adds a PDU to the context.
`void` | `addRequestPduListener(RequestPduListener l)` Adds the specified request pdu listener to receive PDUs on the default request pdu port 161 from the host that matches this context.
`void` | `addRequestPduListener(RequestPduListener l, int port)` Adds the specified request pdu listener to receive PDUs on the specified port from the host that matches this context.
`void` | `addRequestPduListener(RequestPduListener l, ListeningContextPool lcontext)` Adds the specified request pdu listener to receive PDUs on the specified listening context that matches this context.
`void` | `addTrapListener(TrapListener l)` Adds the specified trap listener to receive traps on the default trap port 162 from the host that matches this context.
`void` | `addTrapListener(TrapListener l, int port)` Adds the specified trap listener to receive traps on the specified port from the host that matches this context.
`void` | `addTrapListener(TrapListener l, ListeningContextPool lcontext)` Adds the specified trap listener to receive traps on the specified listening context that matches this context.
`java.lang.Object` | `clone()` Returns a clone of this SnmpContext.
`void` | `destroy()` Removes the resouces held by this context.
`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` | `getBindAddress()` Returns the local bind address.
`java.lang.String` | `getHashKey()` Returns the hash key.
`java.lang.String` | `getHost()` Returns the host.
`int` | `getPort()` Returns the port number.
`java.lang.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.
`java.lang.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.
`java.lang.String` | `getTypeSocket()` Returns the type of socket.
`int` | `getVersion()` Returns the SNMP version of the context.
`boolean` | `isDestroyed()` Returns whether or not this context has been destroyed.
`Pdu` | `processIncomingPdu(byte[] message)` Processes an incoming PDU.
`boolean` | `removePdu(int requestId)` Removes a PDU from the context.
`void` | `removeRequestPduListener(RequestPduListener l)` Removes the specified request pdu listener from listening for packets on the default request pdu port 161.
`void` | `removeRequestPduListener(RequestPduListener l, int port)` Removes the specified request pdu listener from listening for packets on the specified port.
`void` | `removeRequestPduListener(RequestPduListener l, ListeningContextPool lcontext)` Removes the specified request pdu listener from listening for packets on the specified listening context.
`void` | `removeTrapListener(TrapListener l)` Removes the specified trap listener from listening for packets on the default trap port 162.
`void` | `removeTrapListener(TrapListener l, int port)` Removes the specified trap listener from listening for packets on the specified port.
`void` | `removeTrapListener(TrapListener l, ListeningContextPool lcontext)` Removes the specified trap listener from listening for packets on the specified listening context.
`void` | `sendPacket(byte[] packet)` Sends an encoded PDU.

Field Detail

### version_id

    public static final java.lang.String version_id

See Also:
  Constant Field Values

### DEFAULT_PORT

    public static final int DEFAULT_PORT

  The default port number where SNMP requests are sent to (161).

  See Also:
    Constant Field Values

### STANDARD_SOCKET

    public static final java.lang.String STANDARD_SOCKET

  The Standard Socket type.

  See Also:
    Constant Field Values

### TCP_SOCKET

    public static final java.lang.String TCP_SOCKET

  The TCP Socket type.

  See Also:
    Constant Field Values

### NETSCAPE_SOCKET

    public static final java.lang.String NETSCAPE_SOCKET

  The Netscape Socket type.

  See Also:
    Constant Field Values

### KVM_SOCKET

    public static final java.lang.String KVM_SOCKET

  The KVM Socket type.

  See Also:
    Constant Field Values

### MAXPDU

    public static final int MAXPDU

  The Maximum number of outstanding PDUs one context can handle at a given moment in time.

  See Also:
    Constant Field Values

### MSS

    public static final int MSS

  The Maximum size of a message in octets (1300).

  See Also:
    Constant Field Values

Method Detail

### getVersion

    public int getVersion()

  Returns the SNMP version of the context.

  Returns:
    The version
  See Also:
    `SnmpConstants.SNMP_VERSION_1`, `SnmpConstants.SNMP_VERSION_2c`, `SnmpConstants.SNMP_VERSION_3`

### getHost

    public java.lang.String getHost()

  Returns the host.

  Returns:
    The host

### getPort

    public int getPort()

  Returns the port number.

  Returns:
    The port no

### getBindAddress

    public java.lang.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

    public java.lang.String getTypeSocket()

  Returns the type of socket.

  Returns:
    The type of socket
  See Also:
    `STANDARD_SOCKET`, `TCP_SOCKET`, `NETSCAPE_SOCKET`, `KVM_SOCKET`

### getSendToHostAddress

    public java.lang.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:
    `ContextSocketFace.getSendToHostAddress()`

### getReceivedFromHostAddress

    public java.lang.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:
    `ContextSocketFace.getReceivedFromHostAddress()`

### addPdu

    public boolean addPdu(Pdu pdu)
                   throws java.io.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
    `java.io.IOException`
    `PduException`

### removePdu

    public 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.

  Returns:
    whether the PDU has been successfully removed

### 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

  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
    `java.io.IOException`
    `EncodingException`

### sendPacket

    public 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

    public void destroy()

  Removes the resouces held by this context. Should be called by the user/developer when the context is no longer needed.

### isDestroyed

    public boolean isDestroyed()

  Returns whether or not this context has been destroyed.

  Since:
    4_14

### addTrapListener

    public void addTrapListener(TrapListener l)
                         throws java.io.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
    `java.io.IOException`
  See Also:
    `addTrapListener(TrapListener, int)`, `ListeningContextFace.DEFAULT_TRAP_PORT`

### removeTrapListener

    public void removeTrapListener(TrapListener l)
                            throws java.io.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
    `java.io.IOException`
  See Also:
    `removeTrapListener(TrapListener, int)`, `ListeningContextFace.DEFAULT_TRAP_PORT`

### addTrapListener

    public void addTrapListener(TrapListener l,
                                int port)
                         throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.addRawPduListener(RawPduListener)`

### removeTrapListener

    public void removeTrapListener(TrapListener l,
                                   int port)
                            throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.removeRawPduListener(RawPduListener)`, `ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)`

### addTrapListener

    public void addTrapListener(TrapListener l,
                                ListeningContextPool lcontext)
                         throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.addRawPduListener(RawPduListener)`

### removeTrapListener

    public void removeTrapListener(TrapListener l,
                                   ListeningContextPool lcontext)
                            throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.removeRawPduListener(RawPduListener)`, `ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)`

### addRequestPduListener

    public void addRequestPduListener(RequestPduListener l)
                               throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `addRequestPduListener(RequestPduListener, int)`, `DEFAULT_PORT`

### removeRequestPduListener

    public void removeRequestPduListener(RequestPduListener l)
                                  throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `removeRequestPduListener(RequestPduListener, int)`, `DEFAULT_PORT`

### addRequestPduListener

    public void addRequestPduListener(RequestPduListener l,
                                      int port)
                               throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.addRawPduListener(RawPduListener)`

### removeRequestPduListener

    public void removeRequestPduListener(RequestPduListener l,
                                         int port)
                                  throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.removeRawPduListener(RawPduListener)`, `ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)`

### addRequestPduListener

    public void addRequestPduListener(RequestPduListener l,
                                      ListeningContextPool lcontext)
                               throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.addRawPduListener(RawPduListener)`

### removeRequestPduListener

    public void removeRequestPduListener(RequestPduListener l,
                                         ListeningContextPool lcontext)
                                  throws java.io.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
    `java.io.IOException`
  Since:
    4_14
  See Also:
    `ListeningContextPool.ListeningContextPool(int, String, String)`, `ListeningContextPool.removeRawPduListener(RawPduListener)`, `ListeningContextPool.removeRawPduListenerFromPool(RawPduListener)`

### processIncomingPdu

    public Pdu processIncomingPdu(byte[] message)
                           throws DecodingException,
                                  java.io.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.

    `DecodingException`
    `java.io.IOException`

### clone

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

  Returns a clone of this SnmpContext.

  Throws:
    `java.lang.CloneNotSupportedException` - Thrown when the constructor generates an IOException or when in one of the Pool classes.
  Since:
    4_14

### getHashKey

    public java.lang.String getHashKey()

  Returns the hash key. This key is built out of all properties.

  Returns:
    The hash key
  Since:
    4_14

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