- java.lang.Object
-
- org.snmp4j.PDU
-
- org.snmp4j.PDUv1
-
- All Implemented Interfaces:
java.io.Serializable
,BERSerializable
public class PDUv1 extends PDU
ThePDUv1
represents SNMPv1 PDUs. The behavior of this class is identical to its superclassPDU
for the PDU typePDU.GET
,PDU.GETNEXT
, andPDU.SET
. The other SNMPv2 PDU types implemented byPDU
are not supported. In contrast to its super class,PDUv1
implements thePDU.V1TRAP
type. 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
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private IpAddress
agentAddress
static int
AUTHENTICATIONFAILURE
An authenticationFailure(4) trap signifies that the SNMP entity has received a protocol message that is not properly authenticated.static 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.private OID
enterprise
static int
ENTERPRISE_SPECIFIC
If the generic trap identifier isENTERPRISE_SPECIFIC
(6), then the enterprise specific trap ID is given by the specificTrap member field.private Integer32
genericTrap
static 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).static 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).private static java.lang.String
OPERATION_NOT_SUPPORTED
private static long
serialVersionUID
private Integer32
specificTrap
private TimeTicks
timestamp
static 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.-
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 void
checkNull(Variable parameter)
Checks for null parameters.private void
checkV1TRAP()
java.lang.Object
clone()
void
decodeBER(BERInputStream inputStream)
Decodes aVariable
from anBERInputStream
.void
encodeBER(java.io.OutputStream outputStream)
Encodes aVariable
to anOutputStream
.boolean
equals(java.lang.Object obj)
IpAddress
getAgentAddress()
Gets the IP address of the originator system of this SNMPv1 trap.protected int
getBERPayloadLengthPDU()
OID
getEnterprise()
Gets the "enterprise" OID of the SNMPv1 trap.int
getGenericTrap()
Gets the generic trap ID.int
getMaxRepetitions()
This method is not supported for SNMPv1 PDUs and will throw aUnsupportedOperationException
int
getSpecificTrap()
Gets the specific trap ID.long
getTimestamp()
Gets theTimeTicks
value of the trap sender's notion of its sysUpTime value when this trap has been generated.protected boolean
isVariableV1(Variable v)
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.java.lang.String
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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
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
-
OPERATION_NOT_SUPPORTED
private static final java.lang.String OPERATION_NOT_SUPPORTED
- See Also:
- Constant Field Values
-
enterprise
private OID enterprise
-
agentAddress
private IpAddress agentAddress
-
genericTrap
private Integer32 genericTrap
-
specificTrap
private Integer32 specificTrap
-
timestamp
private TimeTicks timestamp
-
-
Constructor Detail
-
PDUv1
public PDUv1()
-
PDUv1
public PDUv1(PDUv1 other)
Copy constructor.- Parameters:
other
- thePDUv1
to copy from.- Since:
- 1.9.1c
-
-
Method Detail
-
decodeBER
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
Decodes aVariable
from anBERInputStream
.- Specified by:
decodeBER
in interfaceBERSerializable
- Overrides:
decodeBER
in classPDU
- Parameters:
inputStream
- anInputStream
containing 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.IOException
Encodes aVariable
to anOutputStream
.- Specified by:
encodeBER
in interfaceBERSerializable
- Overrides:
encodeBER
in 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:
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:
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:
setMaxRepetitions
in 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:
setNonRepeaters
in classPDU
- Parameters:
nonRepeaters
- int- Throws:
java.lang.UnsupportedOperationException
- is always thrown.
-
checkV1TRAP
private void checkV1TRAP()
-
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 theTarget
object 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
- aIpAddress
instance.- 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 theTimeTicks
value 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 theTimeTicks
value 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
- ifparameter
is null.
-
toString
public java.lang.String toString()
Description copied from class:PDU
Returns a string representation of the object.
-
-