|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.snmp4j.PDU
public class PDU
The PDU
class represents a SNMP protocol data unit. The PDU
version supported by the BER decoding and encoding methods of this class
is v2.
The default PDU type is GET.
PDUv1
,
ScopedPDU
,
Serialized FormField Summary | |
---|---|
static int |
authorizationError
Unauthorized access, see error index. |
static int |
badValue
Bad value in variable binding, see error index. |
static int |
commitFailed
Unable to commit a value, see error index. |
protected Integer32 |
errorIndex
|
protected Integer32 |
errorStatus
|
static int |
genErr
An unspecific error caused by a variable binding, see error index. |
static int |
GET
Denotes a get PDU. |
static int |
GETBULK
Denotes a SNMPv2c/v3 getbulk PDU. |
static int |
GETNEXT
Denotes a getnext (search) PDU. |
static int |
inconsistentName
The specified object does not exists and presently it cannot be created, see error index. |
static int |
inconsistentValue
The variable binding's value is presently inconsistent with the current state of the target object, see error index. |
static int |
INFORM
Denotes a SNMPv2c/v3 inform PDU (unprecisely also known as a confirmed notification). |
static int |
noAccess
The variable binding is not accessible by the current MIB view, see error index. |
static int |
noCreation
The specified object does not exists and cannot be created, see error index. |
static int |
noError
Operation success (no error). |
static int |
noSuchName
No such variable binding name, see error index. |
static int |
NOTIFICATION
Denotes a SNMPv2c/v3 notification PDU (undistinguishable from NOTIFICATION ). |
static int |
notWritable
The variable's value cannot be modified, see error index. |
static int |
readOnly
The variable binding is read-only, see error index. |
static int |
REPORT
Denotes a SNMPv3 report PDU. |
protected Integer32 |
requestID
|
static int |
resourceUnavailable
The resource needed to assign a variable binding's value is presently unavailable, see error index. |
static int |
RESPONSE
Denotes a response PDU. |
static int |
SET
Denotes a set PDU. |
static int |
tooBig
PDU encoding is too big for the transport used. |
static int |
TRAP
Denotes a SNMPv2c/v3 notification PDU (undistinguishable from TRAP ). |
protected int |
type
|
static int |
undoFailed
Unable to undo a committed value, see error index. |
static int |
V1TRAP
Denotes a SNMPv1 trap PDU. |
protected java.util.Vector |
variableBindings
|
static int |
wrongEncoding
The variable binding's value has the wrong encoding, see error index. |
static int |
wrongLength
The variable binding's value has the wrong length, see error index. |
static int |
wrongType
The variable binding's value has the wrong type, see error index. |
static int |
wrongValue
The variable binding's value has a value that could under no circumstances be assigned, see error index. |
Constructor Summary | |
---|---|
PDU()
Default constructor. |
|
PDU(PDU other)
Copy constructor. |
Method Summary | |
---|---|
void |
add(VariableBinding vb)
Adds a variable binding to this PDU. |
void |
addAll(VariableBinding[] vbs)
Adds an array of variable bindings to this PDU (see add(VariableBinding vb) ). |
void |
addAllOIDs(VariableBinding[] vbs)
Adds new VariableBindings each with the OID of the
corresponding variable binding of the supplied array to this PDU (see
addOID(VariableBinding vb) ). |
void |
addOID(VariableBinding vb)
Adds a new variable binding to this PDU by using the OID of the supplied VariableBinding . |
void |
clear()
Removes all variable bindings from the PDU and sets the request ID to zero. |
java.lang.Object |
clone()
|
void |
decodeBER(BERInputStream inputStream)
Decodes a Variable from an InputStream . |
void |
encodeBER(java.io.OutputStream outputStream)
Encodes a Variable to an OutputStream . |
VariableBinding |
get(int index)
Gets the variable binding at the specified position. |
int |
getBERLength()
Returns the length of this BERSerializable object
in bytes when encoded according to the Basic Encoding Rules (BER). |
int |
getBERPayloadLength()
Returns the length of the payload of this BERSerializable object
in bytes when encoded according to the Basic Encoding Rules (BER). |
protected int |
getBERPayloadLengthPDU()
|
int |
getErrorIndex()
Gets the error index. |
int |
getErrorStatus()
Gets the error status of the PDU. |
java.lang.String |
getErrorStatusText()
Gets a textual description of the error status. |
int |
getMaxRepetitions()
Gets the maximum repetitions of repeatable variable bindings in GETBULK requests. |
int |
getNonRepeaters()
Gets the number of non repeater variable bindings in a GETBULK PDU. |
Integer32 |
getRequestID()
Gets the request ID associated with this PDU. |
int |
getType()
Gets the PDU type. |
static int |
getTypeFromString(java.lang.String type)
Gets the PDU type identifier for a string representation of the type. |
static java.lang.String |
getTypeString(int type)
Gets a string representation of the supplied PDU type. |
java.util.Vector |
getVariableBindings()
Gets the variable binding vector. |
boolean |
isConfirmedPdu()
Checks whether this PDU is a confirmed class PDU. |
void |
remove(int index)
Removes the variable binding at the supplied position. |
VariableBinding |
set(int index,
VariableBinding vb)
Sets the variable binding at the specified position. |
void |
setErrorIndex(int errorIndex)
Sets the error index. |
void |
setErrorStatus(int errorStatus)
Sets the error status of the PDU. |
void |
setMaxRepetitions(int maxRepetitions)
Sets the maximum repetitions of repeatable variable bindings in GETBULK requests. |
void |
setNonRepeaters(int nonRepeaters)
Sets the number of non repeater variable bindings in a GETBULK PDU. |
void |
setRequestID(Integer32 requestID)
Sets the request ID for this PDU. |
void |
setType(int type)
Sets the PDU type. |
int |
size()
Gets the number of variable bindings in the PDU. |
VariableBinding[] |
toArray()
Returns an array with the variable bindings of this PDU. |
static java.lang.String |
toErrorStatusText(int errorStatus)
Returns textual description for the supplied error status value. |
java.lang.String |
toString()
Returns a string representation of the object. |
void |
trim()
Remove the last variable binding from the PDU, if such an element exists. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GET
public static final int GETNEXT
public static final int RESPONSE
public static final int SET
public static final int V1TRAP
PDUv1
class.
public static final int GETBULK
public static final int INFORM
public static final int TRAP
TRAP
).
public static final int NOTIFICATION
NOTIFICATION
).
public static final int REPORT
public static final int noError
public static final int tooBig
public static final int noSuchName
public static final int badValue
public static final int readOnly
public static final int genErr
public static final int noAccess
public static final int wrongType
public static final int wrongLength
public static final int wrongValue
public static final int wrongEncoding
public static final int noCreation
public static final int inconsistentValue
public static final int resourceUnavailable
public static final int commitFailed
public static final int undoFailed
public static final int authorizationError
public static final int notWritable
public static final int inconsistentName
protected java.util.Vector variableBindings
protected Integer32 errorStatus
protected Integer32 errorIndex
protected Integer32 requestID
protected int type
Constructor Detail |
---|
public PDU()
public PDU(PDU other)
other
- the PDU
to copy from.Method Detail |
---|
public void add(VariableBinding vb)
NullPointerException
is thrown if VariableBinding
or its Variable
is
null
.
vb
- a VariableBinding
instance.public void addOID(VariableBinding vb)
VariableBinding
. The value portion is thus set to
null
.
This method should be used for GET type requests. For SET, TRAP and INFORM
requests, the add(org.snmp4j.smi.VariableBinding)
method should be used instead.
vb
- a VariableBinding
instance.public void addAll(VariableBinding[] vbs)
add(VariableBinding vb)
).
vbs
- an array of VariableBinding
instances. The instances in the
array will be appended to the current list of variable bindings in the
PDU.public void addAllOIDs(VariableBinding[] vbs)
VariableBindings
each with the OID of the
corresponding variable binding of the supplied array to this PDU (see
addOID(VariableBinding vb)
).
vbs
- an array of VariableBinding
instances. For each instance
in the supplied array, a new VariableBinding created by
new VariableBinding(OID)
will be appended to the current
list of variable bindings in the PDU.public VariableBinding get(int index)
index
- a zero based positive integer (0 <= index < size()
)
index
is out of bounds
an exception is thrown.public VariableBinding set(int index, VariableBinding vb)
index
- a zero based positive integer (0 <= index < size()
)
If index
is out of bounds
an exception is thrown.vb
- a VariableBinding instance (null
is not allowed).
public void remove(int index)
index
- a position >= 0 and < size()
.public int size()
public java.util.Vector getVariableBindings()
Vector
containing the PDU's variable bindings.public void trim()
public void setErrorStatus(int errorStatus)
errorStatus
- a SNMP error status.SnmpConstants
public int getErrorStatus()
SnmpConstants
public java.lang.String getErrorStatusText()
SnmpConstants.SNMP_ERROR_MESSAGES
array for a valid error status.
"Unknown error: public static final java.lang.String toErrorStatusText(int errorStatus)
errorStatus
- an error status.
SnmpConstants.SNMP_ERROR_MESSAGES
array for a valid error status.
"Unknown error: public void setErrorIndex(int errorIndex)
errorIndex
- an integer value >= 0 where 1 denotes the first variable binding.public int getErrorIndex()
public boolean isConfirmedPdu()
public int getBERLength()
BERSerializable
BERSerializable
object
in bytes when encoded according to the Basic Encoding Rules (BER).
getBERLength
in interface BERSerializable
public int getBERPayloadLength()
BERSerializable
BERSerializable
object
in bytes when encoded according to the Basic Encoding Rules (BER).
getBERPayloadLength
in interface BERSerializable
public void decodeBER(BERInputStream inputStream) throws java.io.IOException
BERSerializable
Variable
from an InputStream
.
decodeBER
in interface BERSerializable
inputStream
- an InputStream
containing a BER encoded byte stream.
java.io.IOException
- if the stream could not be decoded by using BER rules.protected int getBERPayloadLengthPDU()
public void encodeBER(java.io.OutputStream outputStream) throws java.io.IOException
BERSerializable
Variable
to an OutputStream
.
encodeBER
in interface BERSerializable
outputStream
- an OutputStream
.
java.io.IOException
- if an error occurs while writing to the stream.public void clear()
public void setType(int type)
type
- the type of the PDU (e.g. GETNEXT, SET, etc.)public int getType()
GETNEXT
.
public java.lang.Object clone()
clone
in class java.lang.Object
public Integer32 getRequestID()
Integer32
instance.public void setRequestID(Integer32 requestID)
PDU
when sent.
requestID
- a unique request ID.public static java.lang.String getTypeString(int type)
type
- a PDU type.
type
, for example "GET".public static int getTypeFromString(java.lang.String type)
type
- the string representation of a PDU type: GET, GETNEXT, GETBULK,
SET, INFORM, RESPONSE, REPORT, TRAP, V1TRAP)
.
Integer.MIN_VALUE
of the supplied type is unknown.public java.lang.String toString()
toString
in class java.lang.Object
public int getMaxRepetitions()
public void setMaxRepetitions(int maxRepetitions)
maxRepetitions
- an integer value >= 0.public int getNonRepeaters()
size()
public void setNonRepeaters(int nonRepeaters)
nonRepeaters
- an integer value >= 0 and <= size()
public VariableBinding[] toArray()
VariableBinding
instances of this PDU in the
same order as in the PDU.
|
Copyright 2005-2010 Frank Fock (SNMP4J.org) | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |