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
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCreates a PDU factory for thePDU.GETPDU type.DefaultPDUFactory(int pduType) Creates a PDU factory for the specified PDU type.DefaultPDUFactory(int pduType, OctetString contextEngineID, OctetString contextName) Creates aPDUFactorywith type and context information. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidSets context engine ID and context name members on the given PDU if that PDU is aScopedPDU.static PDUcreatePDU(int targetVersion) Creates aPDUinstance for the specified SNMP version.createPDU(MessageProcessingModel messageProcessingModel) Creates aPDUinstance for the specifiedMessageProcessingModel.static PDUcreatePDU(MessageProcessingModel messageProcessingModel, int pduType) Creates aPDUinstance for the specifiedMessageProcessingModeland PDU type.Create aPDUinstance for the supplied target.static PDUCreate aPDUinstance for the supplied target.static PDUCreate aPDUinstance for the supplied target.Gets the context engine ID forScopedPDUinstances created by this factory.Gets the context name forScopedPDUinstances created by this factory.intGets the maximum number of repetitions for the repetitions variable bindings forPDU.GETBULKPDUs.intGets the number of non repeater variable bindings forPDU.GETBULKPDUs.intvoidsetContextEngineID(OctetString contextEngineID) Sets the context engine ID forScopedPDUinstances created by this factory.voidsetContextName(OctetString contextName) Sets the context name forScopedPDUinstances created by this factory.voidsetMaxRepetitions(int maxRepetitions) Sets the max repetitions parameter value for GETBULK PDUs created by this factory.voidsetNonRepeaters(int nonRepeaters) Sets the non repeaters parameter value for GETBULK PDUs created by this factory.voidsetPduType(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.GETPDU type. -
DefaultPDUFactory
public DefaultPDUFactory(int pduType) Creates a PDU factory for the specified PDU type. Context engine ID and name will be set to emptyOctetStringinstances.- Parameters:
pduType- a PDU type as specified byPDU.
-
DefaultPDUFactory
Creates aPDUFactorywith type and context information.
-
-
Method Details
-
setPduType
public void setPduType(int pduType) -
getPduType
public int getPduType() -
createPDU
Create aPDUinstance for the supplied target.- Specified by:
createPDUin interfacePDUFactory- Parameters:
target- theTargetwhere 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 aPDUinstance for the supplied target. For GETBULK PDUs, the default max repetitions and non repeaters are used. SeeGETBULK_DEFAULT_MAX_REPETITIONSandGETBULK_DEFAULT_NON_REPEATERS.- Parameters:
target- theTargetwhere 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 aPDUinstance for the supplied target.- Parameters:
target- theTargetwhere 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 aPDUinstance 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 aPDUinstance for the specifiedMessageProcessingModel.- Specified by:
createPDUin 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 aPDUinstance for the specifiedMessageProcessingModeland 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.GETBULKPDUs. 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.GETBULKPDUs. 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 forScopedPDUinstances created by this factory.- Returns:
- the context engine ID or
nullif context engine ID is the same as authoritative engine ID. - Since:
- 2.2
-
setContextEngineID
Sets the context engine ID forScopedPDUinstances created by this factory.- Parameters:
contextEngineID- the context engine ID ornullif context engine ID is the same as authoritative engine ID.- Since:
- 2.2
-
getContextName
Gets the context name forScopedPDUinstances created by this factory.- Returns:
- the context name or
nullfor the default context. - Since:
- 2.2
-
setContextName
Sets the context name forScopedPDUinstances created by this factory.- Parameters:
contextName- the context name ornullfor the default context.- Since:
- 2.2
-