- Type Parameters:
A
- anAddress
class that is the super class for the addresses supported by this transport mapping.
- All Superinterfaces:
AutoCloseable
,Closeable
- All Known Subinterfaces:
ConnectionOrientedTransportMapping<A>
- All Known Implementing Classes:
AbstractConnectionOrientedTransportMapping
,AbstractTransportMapping
,DefaultTcpTransportMapping
,DefaultUdpTransportMapping
,DTLSTM
,DummyTransport
,DummyTransport.DummyTransportResponder
,TcpTransportMapping
,TLSTM
,UdpTransportMapping
The
TransportMapping
defines the common interface for SNMP
transport mappings. A transport mapping can only support a single
transport protocol.- Version:
- 3.2.0
- Author:
- Frank Fock
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTransportListener
(TransportListener transportListener) Adds a transport listener to the transport.void
close()
Closes the transport an releases all bound resources synchronously.Returns the address that represents the actual incoming address this transport mapping uses to listen for incoming packets.int
Gets the maximum length of an incoming message that can be successfully processed by this transport mapping implementation.default int
Gets the maximum length of an outgoing message that can be successfully send by this transport mapping implementation.Gets the primaryAddress
class that is supported by this transport mapping.Return allAddress
classes supported by this transport mapping.default TransportType
Gets theTransportType
thisTransportMapping
supports.default boolean
isAddressSupported
(Address addressType) Checks if the provided address can be used with this transport mapping.default boolean
isAddressSupported
(Address addressType, boolean exactMatch) Checks if the provided address can be used with this transport mapping.boolean
Returnstrue
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, long timeoutMillis, int maxRetries) Sends a message to the supplied address using this transport.
-
Method Details
-
getSupportedAddressClass
Gets the primaryAddress
class that is supported by this transport mapping.- Returns:
- a subclass of
Address
.
-
getSupportedAddressClasses
Return allAddress
classes supported by this transport mapping. For example, ifDtlsAddress
is supported as primary address class this will also returnUdpAddress
as secondary supported address class.- Returns:
- a set of address classes with at least one element (see
getSupportedAddressClass()
.
-
isAddressSupported
Checks if the provided address can be used with this transport mapping.- Parameters:
addressType
- anAddress
instance representing a target address.- Returns:
true
if the specified address can be used as target address with thisTransportMapping
.- Since:
- 3.1.0
-
isAddressSupported
Checks if the provided address can be used with this transport mapping.- Parameters:
addressType
- anAddress
instance representing a target address.exactMatch
- iftrue
this method returnstrue
only if the given addressType's class equals the address class returned bygetSupportedAddressClass()
.- Returns:
true
if the specified address can be used as target address with thisTransportMapping
.- Since:
- 3.2.1
-
getListenAddress
A getListenAddress()Returns the address that represents the actual 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, long timeoutMillis, int maxRetries) throws IOException Sends a message to the supplied address using this transport.- Parameters:
address
- anAddress
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.timeoutMillis
- maximum number of milli seconds the connection creation might take (if connection based).maxRetries
- maximum retries during connection creation.- Throws:
IOException
- if any underlying IO operation fails.
-
addTransportListener
Adds a transport listener to the transport. Normally, at least one transport listener needs to be added to process incoming messages.- Parameters:
transportListener
- aTransportListener
instance.- Since:
- 1.6
-
removeTransportListener
Removes a transport listener. Incoming messages will no longer be propagated to the suppliedTransportListener
.- Parameters:
transportListener
- aTransportListener
instance.- Since:
- 1.6
-
close
Closes the transport an releases all bound resources synchronously.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if any IO operation for the close fails.
-
listen
Listen for incoming messages. For connection oriented transports, this method needs to be called beforesendMessage(A, byte[], org.snmp4j.TransportStateReference, long, int)
is called for the first time.- Throws:
IOException
- if an IO operation exception occurs while starting the listener.
-
isListening
boolean isListening()Returnstrue
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.
-
getMaxOutboundMessageSize
default int getMaxOutboundMessageSize()Gets the maximum length of an outgoing message that can be successfully send by this transport mapping implementation. By default,getMaxInboundMessageSize()
is returned.- Returns:
- an integer > 484.
- Since:
- 3.7.4
-
getSupportedTransportType
Gets theTransportType
thisTransportMapping
supports.- Returns:
TransportType.receiver
if command responder applications are supported andTransportType.sender
if command generator and notification generator applications are supported andTransportType.any
if any type of applications are supported with this instance.- Since:
- 3.2.0
-