public class PDUv1 extends PDU
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
.Modifier and Type | Field and Description |
---|---|
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.
|
static int |
ENTERPRISE_SPECIFIC
If the generic trap identifier is
ENTERPRISE_SPECIFIC (6), then
the enterprise specific trap ID is given by the specificTrap member field. |
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).
|
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.
|
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 and Description |
---|
PDUv1() |
PDUv1(PDUv1 other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
checkNull(Variable parameter)
Checks for null parameters.
|
Object |
clone() |
void |
decodeBER(BERInputStream inputStream)
Decodes a
Variable from an BERInputStream . |
void |
encodeBER(OutputStream outputStream)
Encodes a
Variable to an OutputStream . |
boolean |
equals(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 a
UnsupportedOperationException |
int |
getSpecificTrap()
Gets the specific trap ID.
|
long |
getTimestamp()
Gets the
TimeTicks 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 a
UnsupportedOperationException |
void |
setMaxSizeScopedPDU(int maxSizeScopedPDU)
This method is not supported for SNMPv1 PDUs and will throw a
UnsupportedOperationException |
void |
setNonRepeaters(int nonRepeaters)
This method is not supported for SNMPv1 PDUs and will throw a
UnsupportedOperationException |
void |
setSpecificTrap(int specificTrap)
Sets the specific trap ID.
|
void |
setTimestamp(long timeStamp)
Sets the
TimeTicks value of the trap sender's notion of
its sysUpTime value when this trap has been generated. |
String |
toString()
Returns a string representation of the object.
|
add, addAll, addAll, addAllOIDs, addOID, clear, 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
public static final int COLDSTART
public static final int WARMSTART
public static final int LINKDOWN
public static final int LINKUP
public static final int AUTHENTICATIONFAILURE
public static final int ENTERPRISE_SPECIFIC
ENTERPRISE_SPECIFIC
(6), then
the enterprise specific trap ID is given by the specificTrap member field.public PDUv1()
public PDUv1(PDUv1 other)
other
- the PDUv1
to copy from.public void decodeBER(BERInputStream inputStream) throws IOException
Variable
from an BERInputStream
.decodeBER
in interface BERSerializable
decodeBER
in class PDU
inputStream
- an InputStream
containing a BER encoded
byte stream.IOException
- if there is an encoding error in the BER stream.public void encodeBER(OutputStream outputStream) throws IOException
Variable
to an OutputStream
.encodeBER
in interface BERSerializable
encodeBER
in class PDU
outputStream
- an OutputStream
.IOException
- if an error occurs while writing to the stream.protected boolean isVariableV1(Variable v)
v
- a variable value (must not be null
).true
if the variable is SNMPv1 compatible (or
SNMP4JSettings.isAllowSNMPv2InV1()
is true),
false
otherwise, i.e. if v
is an instance of
Counter64
.protected int getBERPayloadLengthPDU()
getBERPayloadLengthPDU
in class PDU
public int getMaxRepetitions()
UnsupportedOperationException
getMaxRepetitions
in class PDU
UnsupportedOperationException
- is always thrown.public void setMaxRepetitions(int maxRepetitions)
UnsupportedOperationException
setMaxRepetitions
in class PDU
maxRepetitions
- the number of repetitions for SNMPv2c or later SNMP version. Ignored by this PDUv1.UnsupportedOperationException
- is always thrown.public void setMaxSizeScopedPDU(int maxSizeScopedPDU)
UnsupportedOperationException
maxSizeScopedPDU
- intUnsupportedOperationException
- is always thrown.public void setNonRepeaters(int nonRepeaters)
UnsupportedOperationException
setNonRepeaters
in class PDU
nonRepeaters
- intUnsupportedOperationException
- is always thrown.public OID getEnterprise()
UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public void setEnterprise(OID enterprise)
enterprise
- an OID instance.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public IpAddress getAgentAddress()
Target
object associated with this PDU.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public void setAgentAddress(IpAddress agentAddress)
agentAddress
- a IpAddress
instance.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public int getGenericTrap()
getSpecificTrap()
will return the trap ID of the enterprise
specific trap.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public void setGenericTrap(int genericTrap)
setSpecificTrap(int)
must be used to set the trap ID of the enterprise
specific trap.genericTrap
- an integer value >= 0 and <= 6.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public int getSpecificTrap()
getGenericTrap()
must return ENTERPRISE_SPECIFIC(6).UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public void setSpecificTrap(int specificTrap)
setGenericTrap(int genericTrap)
must be called with value
ENTERPRISE_SPECIFIC
.specificTrap
- an integer value > 0.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public long getTimestamp()
TimeTicks
value of the trap sender's notion of
its sysUpTime value when this trap has been generated.UnsupportedOperationException
- if the type of this PDU is not
PDU.V1TRAP
.public void setTimestamp(long timeStamp)
TimeTicks
value of the trap sender's notion of
its sysUpTime value when this trap has been generated.timeStamp
- a long value.protected void checkNull(Variable parameter)
parameter
- an Object instance.NullPointerException
- if parameter
is null.public String toString()
PDU
Copyright © 2020 SNMP4J.org. All rights reserved.