Package org.snmp4j.util
Class DefaultPDUFactory
java.lang.Object
org.snmp4j.util.DefaultPDUFactory
- All Implemented Interfaces:
PDUFactory
The
DefaultPDUFactory
is a default implementation of the
PDUFactory
interface. It creates PDUs depending on the
target's message processing model. That is, a PDUv1
instance is
created for a SNMPv1 target whereas a ScopedPDU
is created
for a SNMPv3 target. In all other cases a PDU
instance is created.- Since:
- 1.0.4
- Version:
- 2.5.1
- Author:
- Frank Fock
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
-
Constructor Summary
ConstructorDescriptionCreates a PDU factory for thePDU.GET
PDU type.DefaultPDUFactory
(int pduType) Creates a PDU factory for the specified PDU type.DefaultPDUFactory
(int pduType, OctetString contextEngineID, OctetString contextName) Creates aPDUFactory
with type and context information. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Sets context engine ID and context name members on the given PDU if that PDU is aScopedPDU
.static PDU
createPDU
(int targetVersion) Creates aPDU
instance for the specified SNMP version.createPDU
(MessageProcessingModel messageProcessingModel) Creates aPDU
instance for the specifiedMessageProcessingModel
.static PDU
createPDU
(MessageProcessingModel messageProcessingModel, int pduType) Creates aPDU
instance for the specifiedMessageProcessingModel
and PDU type.Create aPDU
instance for the supplied target.static PDU
Create aPDU
instance for the supplied target.static PDU
Create aPDU
instance for the supplied target.Gets the context engine ID forScopedPDU
instances created by this factory.Gets the context name forScopedPDU
instances created by this factory.int
Gets the maximum number of repetitions for the repetitions variable bindings forPDU.GETBULK
PDUs.int
Gets the number of non repeater variable bindings forPDU.GETBULK
PDUs.int
void
setContextEngineID
(OctetString contextEngineID) Sets the context engine ID forScopedPDU
instances created by this factory.void
setContextName
(OctetString contextName) Sets the context name forScopedPDU
instances created by this factory.void
setMaxRepetitions
(int maxRepetitions) Sets the max repetitions parameter value for GETBULK PDUs created by this factory.void
setNonRepeaters
(int nonRepeaters) Sets the non repeaters parameter value for GETBULK PDUs created by this factory.void
setPduType
(int pduType)
-
Field Details
-
GETBULK_DEFAULT_MAX_REPETITIONS
public static final int GETBULK_DEFAULT_MAX_REPETITIONS- See Also:
-
GETBULK_DEFAULT_NON_REPEATERS
public static final int GETBULK_DEFAULT_NON_REPEATERS- See Also:
-
-
Constructor Details
-
DefaultPDUFactory
public DefaultPDUFactory()Creates a PDU factory for thePDU.GET
PDU type. -
DefaultPDUFactory
public DefaultPDUFactory(int pduType) Creates a PDU factory for the specified PDU type. Context engine ID and name will be set to emptyOctetString
instances.- Parameters:
pduType
- a PDU type as specified byPDU
.
-
DefaultPDUFactory
Creates aPDUFactory
with type and context information.
-
-
Method Details
-
setPduType
public void setPduType(int pduType) -
getPduType
public int getPduType() -
createPDU
Create aPDU
instance for the supplied target.- Specified by:
createPDU
in interfacePDUFactory
- Parameters:
target
- theTarget
where the PDU to be created will be sent.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
-
applyContextInfoToScopedPDU
Sets context engine ID and context name members on the given PDU if that PDU is aScopedPDU
. -
createPDU
Create aPDU
instance for the supplied target. For GETBULK PDUs, the default max repetitions and non repeaters are used. SeeGETBULK_DEFAULT_MAX_REPETITIONS
andGETBULK_DEFAULT_NON_REPEATERS
.- Parameters:
target
- theTarget
where the PDU to be created will be sent.pduType
- a PDU type as specified byPDU
.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
-
createPDU
Create aPDU
instance for the supplied target.- Parameters:
target
- theTarget
where the PDU to be created will be sent.pduType
- a PDU type as specified byPDU
.maxRepetitions
- the maximum number of repetitions for GETBULK PDUs created by this factory.nonRepeaters
- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.- Returns:
- PDU a PDU instance that is compatible with the supplied target.
- Since:
- 2.2
-
createPDU
Creates aPDU
instance for the specified SNMP version.- Parameters:
targetVersion
- a SNMP version as defined bySnmpConstants
.- Returns:
- a PDU instance that is compatible with the supplied target SNMP version.
- Since:
- 1.7.3
-
createPDU
Creates aPDU
instance for the specifiedMessageProcessingModel
.- Specified by:
createPDU
in interfacePDUFactory
- Parameters:
messageProcessingModel
- a message processing model instance.- Returns:
- a PDU that is compatible with the specified message processing model.
- Since:
- 2.2
-
createPDU
Creates aPDU
instance for the specifiedMessageProcessingModel
and PDU type.- Parameters:
messageProcessingModel
- a message processing model instance.pduType
- the type for the new PDU.- Returns:
- a PDU that is compatible with the specified message processing model.
- Since:
- 2.2
-
getMaxRepetitions
public int getMaxRepetitions()Gets the maximum number of repetitions for the repetitions variable bindings forPDU.GETBULK
PDUs. Default isGETBULK_DEFAULT_MAX_REPETITIONS
- Returns:
- the maximum number of repetitions for GETBULK PDUs created by this factory.
- Since:
- 2.2
-
setMaxRepetitions
public void setMaxRepetitions(int maxRepetitions) Sets the max repetitions parameter value for GETBULK PDUs created by this factory.- Parameters:
maxRepetitions
- the maximum number of repetitions for GETBULK PDUs created by this factory.- Since:
- 2.2
-
getNonRepeaters
public int getNonRepeaters()Gets the number of non repeater variable bindings forPDU.GETBULK
PDUs. Default isGETBULK_DEFAULT_NON_REPEATERS
.- Returns:
- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.
- Since:
- 2.2
-
setNonRepeaters
public void setNonRepeaters(int nonRepeaters) Sets the non repeaters parameter value for GETBULK PDUs created by this factory.- Parameters:
nonRepeaters
- the number of non-repeater variable bindings (processed like GETNEXT) for GETBULK PDUs created by this factory.- Since:
- 2.2
-
getContextEngineID
Gets the context engine ID forScopedPDU
instances created by this factory.- Returns:
- the context engine ID or
null
if context engine ID is the same as authoritative engine ID. - Since:
- 2.2
-
setContextEngineID
Sets the context engine ID forScopedPDU
instances created by this factory.- Parameters:
contextEngineID
- the context engine ID ornull
if context engine ID is the same as authoritative engine ID.- Since:
- 2.2
-
getContextName
Gets the context name forScopedPDU
instances created by this factory.- Returns:
- the context name or
null
for the default context. - Since:
- 2.2
-
setContextName
Sets the context name forScopedPDU
instances created by this factory.- Parameters:
contextName
- the context name ornull
for the default context.- Since:
- 2.2
-