org.snmp4j
Interface TransportMapping<A extends Address>

All Known Subinterfaces:
ConnectionOrientedTransportMapping<A>
All Known Implementing Classes:
AbstractTransportMapping, DefaultSshTransportMapping, DefaultTcpTransportMapping, DefaultUdpTransportMapping, DummyTransport, DummyTransport.DummyTransportResponder, TcpTransportMapping, TLSTM, UdpTransportMapping

public interface TransportMapping<A extends Address>

The TransportMapping defines the common interface for SNMP transport mappings. A transport mapping can only support a single transport protocol.

Version:
2.0
Author:
Frank Fock

Method Summary
 void addTransportListener(TransportListener transportListener)
          Adds a transport listener to the transport.
 void close()
          Closes the transport an releases all bound resources synchronously.
 A getListenAddress()
          Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.
 int getMaxInboundMessageSize()
          Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.
 java.lang.Class<? extends Address> getSupportedAddressClass()
          Gets the Address class that is supported by this transport mapping.
 boolean isListening()
          Returns true if the transport mapping is listening for incoming messages.
 void listen()
          Listen for incoming messages.
 void removeTransportListener(TransportListener transportListener)
          Removes a transport listener.
 void sendMessage(A address, byte[] message, TransportStateReference tmStateReference)
          Sends a message to the supplied address using this transport.
 

Method Detail

getSupportedAddressClass

java.lang.Class<? extends Address> getSupportedAddressClass()
Gets the Address class that is supported by this transport mapping.

Returns:
a subclass of Address.

getListenAddress

A getListenAddress()
Returns the address that represents the incoming address this transport mapping uses to listen for incoming packets.

Returns:
the address for incoming packets or null this transport mapping is not configured to listen for incoming packets.
Since:
1.6

sendMessage

void sendMessage(A address,
                 byte[] message,
                 TransportStateReference tmStateReference)
                 throws java.io.IOException
Sends a message to the supplied address using this transport.

Parameters:
address - an Address instance denoting the target address.
message - the whole message as an array of bytes.
tmStateReference - the (optional) transport model state reference as defined by RFC 5590 section 6.1.
Throws:
java.io.IOException - if any underlying IO operation fails.

addTransportListener

void addTransportListener(TransportListener transportListener)
Adds a transport listener to the transport. Normally, at least one transport listener needs to be added to process incoming messages.

Parameters:
transportListener - a TransportListener instance.
Since:
1.6

removeTransportListener

void removeTransportListener(TransportListener transportListener)
Removes a transport listener. Incoming messages will no longer be propagated to the supplied TransportListener.

Parameters:
transportListener - a TransportListener instance.
Since:
1.6

close

void close()
           throws java.io.IOException
Closes the transport an releases all bound resources synchronously.

Throws:
java.io.IOException - if any IO operation for the close fails.

listen

void listen()
            throws java.io.IOException
Listen for incoming messages. For connection oriented transports, this method needs to be called before sendMessage(A, byte[], org.snmp4j.TransportStateReference) is called for the first time.

Throws:
java.io.IOException - if an IO operation exception occurs while starting the listener.

isListening

boolean isListening()
Returns true if the transport mapping is listening for incoming messages. For connection oriented transport mappings this is a prerequisite to be able to send SNMP messages. For connectionless transport mappings it is a prerequisite to be able to receive responses.

Returns:
true if this transport mapping is listening for messages.
Since:
1.1

getMaxInboundMessageSize

int getMaxInboundMessageSize()
Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.

Returns:
an integer > 484.

Copyright 2005-2011 Frank Fock (SNMP4J.org)

Copyright © 2011 SNMP4J.org. All Rights Reserved.