public class MPv1 extends Object implements MessageProcessingModel
MPv1
is the message processing model for SNMPv1.Modifier and Type | Field and Description |
---|---|
static int |
ID |
protected PDUFactory |
incomingPDUFactory |
MPv1, MPv2c, MPv2u, MPv3
Constructor and Description |
---|
MPv1()
Creates a SNMPv1 message processing model with a PDU factory for incoming
messages that uses
PDUv1 . |
MPv1(PDUFactory incomingPDUFactory)
Creates a SNMPv1 message processing model with a custom PDU factory that
must ignore the target parameter when creating a PDU for parsing incoming
messages.
|
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
isProtocolVersionSupported(int snmpProtocolVersion)
Checks whether the supplied SNMP protocol version is supported by this
message processing model.
|
int |
prepareDataElements(MessageDispatcher messageDispatcher,
Address transportAddress,
BERInputStream wholeMsg,
TransportStateReference tmStateReference,
Integer32 messageProcessingModel,
Integer32 securityModel,
OctetString securityName,
Integer32 securityLevel,
MutablePDU pdu,
PduHandle sendPduHandle,
Integer32 maxSizeResponseScopedPDU,
StatusInformation statusInformation,
MutableStateReference mutableStateReference)
Prepare data elements from an incoming SNMP message as described in
RFC3412 §7.2.
|
int |
prepareOutgoingMessage(Address transportAddress,
int maxMessageSize,
int messageProcessingModel,
int securityModel,
byte[] securityName,
int securityLevel,
PDU pdu,
boolean expectResponse,
PduHandle sendPduHandle,
Address destTransportAddress,
BEROutputStream outgoingMessage,
TransportStateReference tmStateReference)
Prepares an outgoing message as defined in RFC3412 §7.1.
|
int |
prepareResponseMessage(int messageProcessingModel,
int maxMessageSize,
int securityModel,
byte[] securityName,
int securityLevel,
PDU pdu,
int maxSizeResponseScopedPDU,
StateReference 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 supplied
PduHandle . |
public static final int ID
protected PDUFactory incomingPDUFactory
public MPv1()
PDUv1
.public MPv1(PDUFactory incomingPDUFactory)
incomingPDUFactory
- a PDUFactory
. If null
the default factory will be
used which creates ScopedPDU
instances.public int getID()
MessageProcessingModel
getID
in interface MessageProcessingModel
public int prepareOutgoingMessage(Address transportAddress, int maxMessageSize, int messageProcessingModel, int securityModel, byte[] securityName, int securityLevel, PDU pdu, boolean expectResponse, PduHandle sendPduHandle, Address destTransportAddress, BEROutputStream outgoingMessage, TransportStateReference tmStateReference) throws IOException
MessageProcessingModel
prepareOutgoingMessage
in interface MessageProcessingModel
transportAddress
- the destination transport Address
.maxMessageSize
- the maximum message size the transport mapping for the destination
address is capable of.messageProcessingModel
- the MessageProcessingModel
ID (typically, the SNMP version).securityModel
- the security model ID (see SecurityModel
) to use.securityName
- the principal on behalf the message is to be sent.securityLevel
- the level of security requested (see SecurityLevel
).pdu
- the PDU
to send. For a SNMPv1 trap pdu
has
to be a PDUv1
instance, for SNMPv3 messages it has to be a
ScopedPDU
instance.expectResponse
- indicates if a message expects a response. This has to be
true
for confirmed class PDUs and false
otherwise.sendPduHandle
- the PduHandle
that uniquely identifies the sent message.destTransportAddress
- returns the destination transport address (currently set always set to
transportAddress
.outgoingMessage
- returns the message to send.tmStateReference
- the transport model state reference as defined by RFC 5590.SnmpConstants.SNMP_MP_OK
is returned if on success, otherwise any of the
SnmpConstants.SNMP_MP_*
values may be returned.IOException
- if the supplied PDU could not be encoded to the
outgoingMessage
public int prepareResponseMessage(int messageProcessingModel, int maxMessageSize, int securityModel, byte[] securityName, int securityLevel, PDU pdu, int maxSizeResponseScopedPDU, StateReference stateReference, StatusInformation statusInformation, BEROutputStream outgoingMessage) throws IOException
MessageProcessingModel
prepareResponseMessage
in interface MessageProcessingModel
messageProcessingModel
- int
the MessageProcessingModel
ID (typically, the SNMP version).maxMessageSize
- the maximum message size the transport mapping for the destination
address is capable of.securityModel
- the security model ID (see SecurityModel
) to use.securityName
- the principal on behalf the message is to be sent.securityLevel
- the level of security requested (see SecurityLevel
).pdu
- the PDU
to send. For a SNMPv1 trap pdu
has
to be a PDUv1
instance, for SNMPv3 messages it has to be a
ScopedPDU
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.SnmpConstants.SNMP_MP_OK
is returned if on success, otherwise any of the
SnmpConstants.SNMP_MP_*
values may be returned.IOException
- if an internal error or a resource exception occured.public int prepareDataElements(MessageDispatcher messageDispatcher, Address transportAddress, BERInputStream wholeMsg, TransportStateReference tmStateReference, Integer32 messageProcessingModel, Integer32 securityModel, OctetString securityName, Integer32 securityLevel, MutablePDU pdu, PduHandle sendPduHandle, Integer32 maxSizeResponseScopedPDU, StatusInformation statusInformation, MutableStateReference mutableStateReference) throws IOException
MessageProcessingModel
prepareDataElements
in interface MessageProcessingModel
messageDispatcher
- the MessageDispatcher
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 (see SecurityModel
.securityName
- returns the principal.securityLevel
- returns the requested security level (see SecurityLevel
).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 the
MessageProcessingModel
to send reports over the same
transport as it received them.SnmpConstants.SNMP_MP_OK
is returned on success, otherwise any of the
SnmpConstants.SNMP_MP_*
values may be returned.IOException
- if the decoding of the message failed.public boolean isProtocolVersionSupported(int snmpProtocolVersion)
MessageProcessingModel
isProtocolVersionSupported
in interface MessageProcessingModel
snmpProtocolVersion
- the SNMP protocol version.true
if the supplied SNMP protocol is supported,
false
otherwise.public void releaseStateReference(PduHandle pduHandle)
MessageProcessingModel
PduHandle
.releaseStateReference
in interface MessageProcessingModel
pduHandle
- a PduHandle
.Copyright © 2022 SNMP4J.org. All rights reserved.