java.lang.Object
org.snmp4j.PDU
org.snmp4j.PDUv1
- All Implemented Interfaces:
Serializable
,BERSerializable
The
PDUv1
represents SNMPv1 PDUs. The behavior of this class
is identical to its superclass PDU
for the PDU type PDU.GET
,
PDU.GETNEXT
, and PDU.SET
. The other SNMPv2 PDU types
implemented by PDU
are not supported. In contrast to its super
class, PDUv1
implements the PDU.V1TRAP
type.
To support this type, access methods are provided to get and set the
enterprise OID
, 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 in SnmpConstants
.- Version:
- 1.7.3
- Author:
- Frank Fock
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
An authenticationFailure(4) trap signifies that the SNMP entity has received a protocol message that is not properly authenticated.static final int
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.static final int
If the generic trap identifier isENTERPRISE_SPECIFIC
(6), then the enterprise specific trap ID is given by the specificTrap member field.static final int
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).static final int
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).static final int
A 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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Checks for null parameters.clone()
void
decodeBER
(BERInputStream inputStream) Decodes aVariable
from anBERInputStream
.void
encodeBER
(OutputStream outputStream) Encodes aVariable
to anOutputStream
.boolean
Gets the IP address of the originator system of this SNMPv1 trap.protected int
Gets the "enterprise" OID of the SNMPv1 trap.int
Gets the generic trap ID.int
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
int
Gets the specific trap ID.long
Gets theTimeTicks
value of the trap sender's notion of its sysUpTime value when this trap has been generated.protected boolean
Check if the given variable can be encoded into a SNMPv1 PDU.void
setAgentAddress
(IpAddress agentAddress) Sets the IP address of the originator system of this SNMPv1 trap.void
setEnterprise
(OID enterprise) Sets the "enterprise" OID of the SNMPv1 trap.void
setGenericTrap
(int genericTrap) Sets the generic trap ID.void
setMaxRepetitions
(int maxRepetitions) This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
void
setMaxSizeScopedPDU
(int maxSizeScopedPDU) This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
void
setNonRepeaters
(int nonRepeaters) This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
void
setSpecificTrap
(int specificTrap) Sets the specific trap ID.void
setTimestamp
(long timeStamp) Sets theTimeTicks
value of the trap sender's notion of its sysUpTime value when this trap has been generated.toString()
Returns a string representation of the object.Methods inherited from class org.snmp4j.PDU
add, addAll, addAll, addAllOIDs, addOID, clear, decodeVariableBindings, encodeVariableBindings, get, get, getAll, 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 Details
-
COLDSTART
public static final int COLDSTARTA 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:
-
WARMSTART
public static final int WARMSTARTA warmStart(1) trap signifies that the SNMP entity, supporting a notification originator application, is reinitializing itself such that its configuration is unaltered.- See Also:
-
LINKDOWN
public static final int LINKDOWNA 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:
-
LINKUP
public static final int LINKUPA 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:
-
AUTHENTICATIONFAILURE
public static final int AUTHENTICATIONFAILUREAn 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:
-
ENTERPRISE_SPECIFIC
public static final int ENTERPRISE_SPECIFICIf the generic trap identifier isENTERPRISE_SPECIFIC
(6), then the enterprise specific trap ID is given by the specificTrap member field.- See Also:
-
-
Constructor Details
-
PDUv1
public PDUv1() -
PDUv1
Copy constructor.- Parameters:
other
- thePDUv1
to copy from.- Since:
- 1.9.1c
-
-
Method Details
-
clone
-
decodeBER
Decodes aVariable
from anBERInputStream
.- Specified by:
decodeBER
in interfaceBERSerializable
- Overrides:
decodeBER
in classPDU
- Parameters:
inputStream
- anInputStream
containing a BER encoded byte stream.- Throws:
IOException
- if there is an encoding error in the BER stream.
-
encodeBER
Encodes aVariable
to anOutputStream
.- Specified by:
encodeBER
in interfaceBERSerializable
- Overrides:
encodeBER
in classPDU
- Parameters:
outputStream
- anOutputStream
.- Throws:
IOException
- if an error occurs while writing to the stream.
-
isVariableV1
Check if the given variable can be encoded into a SNMPv1 PDU.- Parameters:
v
- a variable value (must not benull
).- Returns:
true
if the variable is SNMPv1 compatible (orSNMP4JSettings.isAllowSNMPv2InV1()
is true),false
otherwise, i.e. ifv
is an instance ofCounter64
.- Since:
- 1.9.1c
-
getBERPayloadLengthPDU
protected int getBERPayloadLengthPDU()- Overrides:
getBERPayloadLengthPDU
in classPDU
-
getMaxRepetitions
public int getMaxRepetitions()This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
- Overrides:
getMaxRepetitions
in classPDU
- Returns:
- nothing
- Throws:
UnsupportedOperationException
- is always thrown.
-
setMaxRepetitions
public void setMaxRepetitions(int maxRepetitions) This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
- Overrides:
setMaxRepetitions
in classPDU
- Parameters:
maxRepetitions
- the number of repetitions for SNMPv2c or later SNMP version. Ignored by this PDUv1.- Throws:
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:
UnsupportedOperationException
- is always thrown.
-
setNonRepeaters
public void setNonRepeaters(int nonRepeaters) This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
- Overrides:
setNonRepeaters
in classPDU
- Parameters:
nonRepeaters
- int- Throws:
UnsupportedOperationException
- is always thrown.
-
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:
UnsupportedOperationException
- if the type of this PDU is notPDU.V1TRAP
.
-
setEnterprise
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:
UnsupportedOperationException
- if the type of this PDU is notPDU.V1TRAP
.
-
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 theTarget
object associated with this PDU.- Returns:
- an IpAddress instance.
- Throws:
UnsupportedOperationException
- if the type of this PDU is notPDU.V1TRAP
.
-
setAgentAddress
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
- aIpAddress
instance.- Throws:
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:
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:
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:
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:
UnsupportedOperationException
- if the type of this PDU is notPDU.V1TRAP
.
-
getTimestamp
public long getTimestamp()Gets theTimeTicks
value of the trap sender's notion of its sysUpTime value when this trap has been generated.- Returns:
- a long value.
- Throws:
UnsupportedOperationException
- if the type of this PDU is notPDU.V1TRAP
.
-
setTimestamp
public void setTimestamp(long timeStamp) Sets theTimeTicks
value of the trap sender's notion of its sysUpTime value when this trap has been generated.- Parameters:
timeStamp
- a long value.
-
checkNull
Checks for null parameters.- Parameters:
parameter
- an Object instance.- Throws:
NullPointerException
- ifparameter
is null.
-
toString
Description copied from class:PDU
Returns a string representation of the object. -
equals
-