public interface MessageProcessingModel
The
MessageProcessingModel
interface defines common methods to all SNMP message processing models.
Note: The read counter of the BERInputStream
parameters in this
interface should not be reset while those methods are executed.
- Version:
- 3.1.0
- Author:
- Frank Fock
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getID()
Gets the numerical ID of the message processing model as defined by the constants in this interface or by an appropriate constant in the class implementing this interface.boolean
isProtocolVersionSupported
(int snmpProtocolVersion) Checks whether the supplied SNMP protocol version is supported by this message processing model.<A extends Address>
intprepareDataElements
(MessageDispatcher messageDispatcher, A transportAddress, BERInputStream wholeMsg, TransportStateReference tmStateReference, Integer32 messageProcessingModel, Integer32 securityModel, OctetString securityName, Integer32 securityLevel, MutablePDU pdu, PduHandle sendPduHandle, Integer32 maxSizeResponseScopedPDU, StatusInformation statusInformation, MutableStateReference<A> mutableStateReference) Prepare data elements from an incoming SNMP message as described in RFC3412 §7.2.<A extends Address>
intprepareOutgoingMessage
(A transportAddress, int maxMsgSize, int messageProcessingModel, int securityModel, byte[] securityName, int securityLevel, PDU pdu, boolean expectResponse, PduHandle sendPduHandle, BEROutputStream outgoingMessage, TransportStateReference tmStateReference) Prepares an outgoing message as defined in RFC3412 §7.1.<A extends Address>
intprepareResponseMessage
(int messageProcessingModel, int maxMsgSize, int securityModel, byte[] securityName, int securityLevel, PDU pdu, int maxSizeResponseScopedPDU, StateReference<A> stateReference, StatusInformation statusInformation, BEROutputStream outgoingMessage) Prepares a response message as defined in RFC3412 §7.1.void
releaseStateReference
(PduHandle pduHandle) Release the state reference associated with the suppliedPduHandle
.
-
Field Details
-
MPv1
static final int MPv1- See Also:
-
MPv2c
static final int MPv2c- See Also:
-
MPv2u
static final int MPv2u- See Also:
-
MPv3
static final int MPv3- See Also:
-
-
Method Details
-
getID
int getID()Gets the numerical ID of the message processing model as defined by the constants in this interface or by an appropriate constant in the class implementing this interface.- Returns:
- a positive integer value.
-
prepareOutgoingMessage
<A extends Address> int prepareOutgoingMessage(A transportAddress, int maxMsgSize, int messageProcessingModel, int securityModel, byte[] securityName, int securityLevel, PDU pdu, boolean expectResponse, PduHandle sendPduHandle, BEROutputStream outgoingMessage, TransportStateReference tmStateReference) throws IOException Prepares an outgoing message as defined in RFC3412 §7.1.- Type Parameters:
A
- the targetAddress
type.- Parameters:
transportAddress
- the destination transportAddress
.maxMsgSize
- the maximum message size the transport mapping for the destination address is capable of.messageProcessingModel
- theMessageProcessingModel
ID (typically, the SNMP version).securityModel
- the security model ID (seeSecurityModel
) to use.securityName
- the principal on behalf the message is to be sent.securityLevel
- the level of security requested (seeSecurityLevel
).pdu
- thePDU
to send. For a SNMPv1 trappdu
has to be aPDUv1
instance, for SNMPv3 messages it has to be aScopedPDU
instance.expectResponse
- indicates if a message expects a response. This has to betrue
for confirmed class PDUs andfalse
otherwise.sendPduHandle
- thePduHandle
that uniquely identifies the sent message.outgoingMessage
- returns the message to send.tmStateReference
- the transport model state reference as defined by RFC 5590.- Returns:
- the status of the message preparation.
SnmpConstants.SNMP_MP_OK
is returned if on success, otherwise any of theSnmpConstants.SNMP_MP_*
values may be returned. - Throws:
IOException
- if the supplied PDU could not be encoded to theoutgoingMessage
-
prepareResponseMessage
<A extends Address> int prepareResponseMessage(int messageProcessingModel, int maxMsgSize, int securityModel, byte[] securityName, int securityLevel, PDU pdu, int maxSizeResponseScopedPDU, StateReference<A> stateReference, StatusInformation statusInformation, BEROutputStream outgoingMessage) throws IOException Prepares a response message as defined in RFC3412 §7.1.- Type Parameters:
A
- the targetAddress
type.- Parameters:
messageProcessingModel
- int theMessageProcessingModel
ID (typically, the SNMP version).maxMsgSize
- the maximum message size the transport mapping for the destination address is capable of.securityModel
- the security model ID (seeSecurityModel
) to use.securityName
- the principal on behalf the message is to be sent.securityLevel
- the level of security requested (seeSecurityLevel
).pdu
- thePDU
to send. For a SNMPv1 trappdu
has to be aPDUv1
instance, for SNMPv3 messages it has to be aScopedPDU
instance.maxSizeResponseScopedPDU
- the maximum size of the scoped PDU the sender (of the request) can accept.stateReference
- reference to state information presented with the request.statusInformation
- returns success or error indication. When an error occured, the error counter OID and value are included.outgoingMessage
- returns the message to send.- Returns:
- the status of the message preparation.
SnmpConstants.SNMP_MP_OK
is returned if on success, otherwise any of theSnmpConstants.SNMP_MP_*
values may be returned. - Throws:
IOException
- if an internal error or a resource exception occured.
-
prepareDataElements
<A extends Address> int prepareDataElements(MessageDispatcher messageDispatcher, A transportAddress, BERInputStream wholeMsg, TransportStateReference tmStateReference, Integer32 messageProcessingModel, Integer32 securityModel, OctetString securityName, Integer32 securityLevel, MutablePDU pdu, PduHandle sendPduHandle, Integer32 maxSizeResponseScopedPDU, StatusInformation statusInformation, MutableStateReference<A> mutableStateReference) throws IOException Prepare data elements from an incoming SNMP message as described in RFC3412 §7.2.- Type Parameters:
A
- the targetAddress
type.- Parameters:
messageDispatcher
- theMessageDispatcher
instance to be used to send reports. Thus,messageDispatcher
is typically the calling module.transportAddress
- the origin transport address.wholeMsg
- the whole message as received from the network.tmStateReference
- the transport model state reference as defined by RFC 5590.messageProcessingModel
- returns the message processing model (typically the SNMP version).securityModel
- returns the security model ID (seeSecurityModel
.securityName
- returns the principal.securityLevel
- returns the requested security level (seeSecurityLevel
).pdu
- returns SNMP protocol data unit (the payload of the received message).sendPduHandle
- returns the handle to match request.maxSizeResponseScopedPDU
- returns the maximum size of the scoped PDU the sender can accept.statusInformation
- returns success or error indication. When an error occured, the error counter OID and value are included.mutableStateReference
- returns the state reference to be used for a possible response. On input the stateReference may contain information about the transport mapping of the incoming request. This allows theMessageProcessingModel
to send reports over the same transport as it received them.- Returns:
- int the status of the message preparation.
SnmpConstants.SNMP_MP_OK
is returned on success, otherwise any of theSnmpConstants.SNMP_MP_*
values may be returned. - Throws:
IOException
- if the decoding of the message failed.
-
isProtocolVersionSupported
boolean isProtocolVersionSupported(int snmpProtocolVersion) Checks whether the supplied SNMP protocol version is supported by this message processing model.- Parameters:
snmpProtocolVersion
- the SNMP protocol version.- Returns:
true
if the supplied SNMP protocol is supported,false
otherwise.
-
releaseStateReference
Release the state reference associated with the suppliedPduHandle
.- Parameters:
pduHandle
- aPduHandle
.
-