- java.lang.Object
-
- org.snmp4j.PDU
-
- org.snmp4j.PDUv1
-
- All Implemented Interfaces:
java.io.Serializable,BERSerializable
public class PDUv1 extends PDU
ThePDUv1represents SNMPv1 PDUs. The behavior of this class is identical to its superclassPDUfor the PDU typePDU.GET,PDU.GETNEXT, andPDU.SET. The other SNMPv2 PDU types implemented byPDUare not supported. In contrast to its super class,PDUv1implements thePDU.V1TRAPtype. To support this type, access methods are provided to get and set the enterpriseOID, generic, specific, and timestamp of a SNMPv1 trap PDU. The constants defined for generic SNMPv1 traps are included in this class. The descriptions are taken from the SNMPv2-MIB (RFC 3418). The corresponding OIDs are defined inSnmpConstants.- Version:
- 1.7.3
- Author:
- Frank Fock
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intAUTHENTICATIONFAILUREAn authenticationFailure(4) trap signifies that the SNMP entity has received a protocol message that is not properly authenticated.static intCOLDSTARTA coldStart(0) trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself and that its configuration may have been altered.static intENTERPRISE_SPECIFICIf the generic trap identifier isENTERPRISE_SPECIFIC(6), then the enterprise specific trap ID is given by the specificTrap member field.static intLINKDOWNA linkDown(2) trap signifies that the SNMP entity, acting in an agent role, has detected that the ifOperStatus object for one of its communication links is about to enter the down state from some other state (but not from the notPresent state).static intLINKUPA linkUp(3) trap signifies that the SNMP entity, acting in an agent role, has detected that the ifOperStatus object for one of its communication links left the down state and transitioned into some other state (but not into the notPresent state).static intWARMSTARTA warmStart(1) trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself such that its configuration is unaltered.-
Fields inherited from class org.snmp4j.PDU
authorizationError, badValue, commitFailed, errorIndex, errorStatus, genErr, GET, GETBULK, GETNEXT, inconsistentName, inconsistentValue, INFORM, noAccess, noCreation, noError, noSuchName, NOTIFICATION, notWritable, readOnly, REPORT, requestID, resourceUnavailable, RESPONSE, SET, tooBig, TRAP, type, undoFailed, V1TRAP, variableBindings, wrongEncoding, wrongLength, wrongType, wrongValue
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcheckNull(Variable parameter)Checks for null parameters.java.lang.Objectclone()voiddecodeBER(BERInputStream inputStream)Decodes aVariablefrom anBERInputStream.voidencodeBER(java.io.OutputStream outputStream)Encodes aVariableto anOutputStream.booleanequals(java.lang.Object obj)IpAddressgetAgentAddress()Gets the IP address of the originator system of this SNMPv1 trap.protected intgetBERPayloadLengthPDU()OIDgetEnterprise()Gets the "enterprise" OID of the SNMPv1 trap.intgetGenericTrap()Gets the generic trap ID.intgetMaxRepetitions()This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationExceptionintgetSpecificTrap()Gets the specific trap ID.longgetTimestamp()Gets theTimeTicksvalue of the trap sender's notion of its sysUpTime value when this trap has been generated.protected booleanisVariableV1(Variable v)Check if the given variable can be encoded into a SNMPv1 PDU.voidsetAgentAddress(IpAddress agentAddress)Sets the IP address of the originator system of this SNMPv1 trap.voidsetEnterprise(OID enterprise)Sets the "enterprise" OID of the SNMPv1 trap.voidsetGenericTrap(int genericTrap)Sets the generic trap ID.voidsetMaxRepetitions(int maxRepetitions)This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationExceptionvoidsetMaxSizeScopedPDU(int maxSizeScopedPDU)This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationExceptionvoidsetNonRepeaters(int nonRepeaters)This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationExceptionvoidsetSpecificTrap(int specificTrap)Sets the specific trap ID.voidsetTimestamp(long timeStamp)Sets theTimeTicksvalue of the trap sender's notion of its sysUpTime value when this trap has been generated.java.lang.StringtoString()Returns a string representation of the object.-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from class org.snmp4j.PDU
add, addAll, addAll, addAllOIDs, addOID, clear, decodeVariableBindings, encodeVariableBindings, get, getBERLength, getBERLength, getBERPayloadLength, getBindingList, getErrorIndex, getErrorStatus, getErrorStatusText, getNonRepeaters, getRequestID, getType, getTypeFromString, getTypeString, getVariable, getVariableBindings, hashCode, isConfirmedPdu, isResponsePdu, remove, set, setErrorIndex, setErrorStatus, setRequestID, setType, setVariableBindings, size, toArray, toErrorStatusText, trim
-
-
-
-
Field Detail
-
COLDSTART
public static final int COLDSTART
A coldStart(0) trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself and that its configuration may have been altered.- See Also:
- Constant Field Values
-
WARMSTART
public static final int WARMSTART
A warmStart(1) trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself such that its configuration is unaltered.- See Also:
- Constant Field Values
-
LINKDOWN
public static final int LINKDOWN
A linkDown(2) trap signifies that the SNMP entity, acting in an agent role, has detected that the ifOperStatus object for one of its communication links is about to enter the down state from some other state (but not from the notPresent state). This other state is indicated by the included value of ifOperStatus.- See Also:
- Constant Field Values
-
LINKUP
public static final int LINKUP
A linkUp(3) trap signifies that the SNMP entity, acting in an agent role, has detected that the ifOperStatus object for one of its communication links left the down state and transitioned into some other state (but not into the notPresent state). This other state is indicated by the included value of ifOperStatus.- See Also:
- Constant Field Values
-
AUTHENTICATIONFAILURE
public static final int AUTHENTICATIONFAILURE
An authenticationFailure(4) trap signifies that the SNMP entity has received a protocol message that is not properly authenticated. While all implementations of SNMP entities MAY be capable of generating this trap, the snmpEnableAuthenTraps object indicates whether this trap will be generated.- See Also:
- Constant Field Values
-
ENTERPRISE_SPECIFIC
public static final int ENTERPRISE_SPECIFIC
If the generic trap identifier isENTERPRISE_SPECIFIC(6), then the enterprise specific trap ID is given by the specificTrap member field.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PDUv1
public PDUv1()
-
PDUv1
public PDUv1(PDUv1 other)
Copy constructor.- Parameters:
other- thePDUv1to copy from.- Since:
- 1.9.1c
-
-
Method Detail
-
decodeBER
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
Decodes aVariablefrom anBERInputStream.- Specified by:
decodeBERin interfaceBERSerializable- Overrides:
decodeBERin classPDU- Parameters:
inputStream- anInputStreamcontaining a BER encoded byte stream.- Throws:
java.io.IOException- if there is an encoding error in the BER stream.
-
encodeBER
public void encodeBER(java.io.OutputStream outputStream) throws java.io.IOExceptionEncodes aVariableto anOutputStream.- Specified by:
encodeBERin interfaceBERSerializable- Overrides:
encodeBERin classPDU- Parameters:
outputStream- anOutputStream.- Throws:
java.io.IOException- if an error occurs while writing to the stream.
-
isVariableV1
protected boolean isVariableV1(Variable v)
Check if the given variable can be encoded into a SNMPv1 PDU.- Parameters:
v- a variable value (must not benull).- Returns:
trueif the variable is SNMPv1 compatible (orSNMP4JSettings.isAllowSNMPv2InV1()is true),falseotherwise, i.e. ifvis an instance ofCounter64.- Since:
- 1.9.1c
-
getBERPayloadLengthPDU
protected int getBERPayloadLengthPDU()
- Overrides:
getBERPayloadLengthPDUin classPDU
-
getMaxRepetitions
public int getMaxRepetitions()
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException- Overrides:
getMaxRepetitionsin classPDU- Returns:
- nothing
- Throws:
java.lang.UnsupportedOperationException- is always thrown.
-
setMaxRepetitions
public void setMaxRepetitions(int maxRepetitions)
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException- Overrides:
setMaxRepetitionsin classPDU- Parameters:
maxRepetitions- the number of repetitions for SNMPv2c or later SNMP version. Ignored by this PDUv1.- Throws:
java.lang.UnsupportedOperationException- is always thrown.
-
setMaxSizeScopedPDU
public void setMaxSizeScopedPDU(int maxSizeScopedPDU)
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException- Parameters:
maxSizeScopedPDU- int- Throws:
java.lang.UnsupportedOperationException- is always thrown.
-
setNonRepeaters
public void setNonRepeaters(int nonRepeaters)
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException- Overrides:
setNonRepeatersin classPDU- Parameters:
nonRepeaters- int- Throws:
java.lang.UnsupportedOperationException- is always thrown.
-
getEnterprise
public OID getEnterprise()
Gets the "enterprise" OID of the SNMPv1 trap. The enterprise OID could be any OID although the name could lead to the assumption that the enterprise OID has to be an OID under the iso(1).org(3).dod(6).internet(1).private(4).enterprises(1) node, but that's not true.- Returns:
- an OID instance.
- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
setEnterprise
public void setEnterprise(OID enterprise)
Sets the "enterprise" OID of the SNMPv1 trap. The enterprise OID could be any OID although the name could lead to the assumption that the enterprise OID has to be an OID under the iso(1).org(3).dod(6).internet(1).private(4).enterprises(1) node, but that's not true.- Parameters:
enterprise- an OID instance.- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
getAgentAddress
public IpAddress getAgentAddress()
Gets the IP address of the originator system of this SNMPv1 trap. If this value is 0.0.0.0 (the recommended default), then the address of the peer SNMP entity should be extracted from theTargetobject associated with this PDU.- Returns:
- an IpAddress instance.
- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
setAgentAddress
public void setAgentAddress(IpAddress agentAddress)
Sets the IP address of the originator system of this SNMPv1 trap. The default value is 0.0.0.0, which should be only overriden in special cases, for example when forwarding SNMPv1 traps through a SNMP proxy.- Parameters:
agentAddress- aIpAddressinstance.- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
getGenericTrap
public int getGenericTrap()
Gets the generic trap ID. If this value is ENTERPRISE_SPECIFIC(6), thengetSpecificTrap()will return the trap ID of the enterprise specific trap.- Returns:
- an Integer32 instance with a value between 0 and 6.
- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
setGenericTrap
public void setGenericTrap(int genericTrap)
Sets the generic trap ID. If this value is ENTERPRISE_SPECIFIC(6), thensetSpecificTrap(int)must be used to set the trap ID of the enterprise specific trap.- Parameters:
genericTrap- an integer value >= 0 and <= 6.- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
getSpecificTrap
public int getSpecificTrap()
Gets the specific trap ID. If this value is set,getGenericTrap()must return ENTERPRISE_SPECIFIC(6).- Returns:
- an integer value > 0.
- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
setSpecificTrap
public void setSpecificTrap(int specificTrap)
Sets the specific trap ID. If this value is set,setGenericTrap(int genericTrap)must be called with valueENTERPRISE_SPECIFIC.- Parameters:
specificTrap- an integer value > 0.- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
getTimestamp
public long getTimestamp()
Gets theTimeTicksvalue of the trap sender's notion of its sysUpTime value when this trap has been generated.- Returns:
- a long value.
- Throws:
java.lang.UnsupportedOperationException- if the type of this PDU is notPDU.V1TRAP.
-
setTimestamp
public void setTimestamp(long timeStamp)
Sets theTimeTicksvalue of the trap sender's notion of its sysUpTime value when this trap has been generated.- Parameters:
timeStamp- a long value.
-
checkNull
protected void checkNull(Variable parameter)
Checks for null parameters.- Parameters:
parameter- an Object instance.- Throws:
java.lang.NullPointerException- ifparameteris null.
-
toString
public java.lang.String toString()
Description copied from class:PDUReturns a string representation of the object.
-
-