Package org.opennms.protocols.snmp
Class SnmpPduRequest
- java.lang.Object
-
- org.opennms.protocols.snmp.SnmpPduPacket
-
- org.opennms.protocols.snmp.SnmpPduRequest
-
- All Implemented Interfaces:
Cloneable
,SnmpSyntax
public class SnmpPduRequest extends SnmpPduPacket
The SnmpPduRequest defines the SNMPv1 and SNMPv2 Protocol Data Unit (PDU) for certain message types. The types include: GetRequest, GetNextRequest, SetRequest, SNMPv2-Trap, InformRequest, and Response. By default the class is constructed as a SNMP GetRequest, but can be defined to any of the accepted types. For more information see [Stallings99] page 368.- Author:
- Brian Weaver
-
-
Field Summary
-
Fields inherited from class org.opennms.protocols.snmp.SnmpPduPacket
ErrAuthorizationError, ErrBadValue, ErrCommitFailed, ErrGenError, ErrInconsistentName, ErrInconsistentValue, ErrNoAccess, ErrNoCreation, ErrNoError, ErrNoSuchName, ErrNotWritable, ErrReadOnly, ErrResourceUnavailable, ErrTooBig, ErrUndoFailed, ErrWrongEncoding, ErrWrongLength, ErrWrongType, ErrWrongValue, GET, GETBULK, GETNEXT, INFORM, m_errIndex, m_errStatus, REPORT, RESPONSE, SET, V2TRAP
-
-
Constructor Summary
Constructors Constructor Description SnmpPduRequest()
Default class constructor.SnmpPduRequest(int command)
Constructs a new PDU Request with the specified command.SnmpPduRequest(int command, SnmpVarBind[] vars)
Constructs the PDU with the specified command and the passed variables.SnmpPduRequest(SnmpPduRequest second)
Class copy constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Used to get a duplicate of self.SnmpSyntax
duplicate()
Used to get a duplicate of self.void
fix()
Fixes a PDU in error.int
getErrorIndex()
Returns the index of the variable in error if the error status is non-zero.int
getErrorStatus()
Returns the error status for the request.void
setErrorIndex(int ndx)
Sets the current error index in the PDU.void
setErrorStatus(int status)
Used to set the value of the error status member.-
Methods inherited from class org.opennms.protocols.snmp.SnmpPduPacket
addVarBind, addVarBindAt, decodeASN, encodeASN, getCommand, getLength, getPeer, getRequestId, getVarBindAt, nextSequence, removeVarBindAt, setCommand, setPeer, setRequestId, setVarBindAt, toVarBindArray, typeId
-
-
-
-
Constructor Detail
-
SnmpPduRequest
public SnmpPduRequest()
Default class constructor. By default the request is a SNMP GetRequest.
-
SnmpPduRequest
public SnmpPduRequest(SnmpPduRequest second)
Class copy constructor. Constructs a new object that is an identical to the passed object.- Parameters:
second
- The object to make a duplicate of.
-
SnmpPduRequest
public SnmpPduRequest(int command)
Constructs a new PDU Request with the specified command.- Parameters:
command
- The type of PDU to construct- See Also:
SnmpPduPacket.GET
,SnmpPduPacket.GETNEXT
,SnmpPduPacket.SET
,SnmpPduPacket.RESPONSE
,SnmpPduPacket.INFORM
,SnmpPduPacket.V2TRAP
,SnmpPduPacket.REPORT
-
SnmpPduRequest
public SnmpPduRequest(int command, SnmpVarBind[] vars)
Constructs the PDU with the specified command and the passed variables.- Parameters:
command
- The type of PDU to constructvars
- The SNMP variables for the PDU.- See Also:
SnmpPduPacket.GET
,SnmpPduPacket.GETNEXT
,SnmpPduPacket.SET
,SnmpPduPacket.RESPONSE
,SnmpPduPacket.INFORM
,SnmpPduPacket.V2TRAP
,SnmpPduPacket.REPORT
-
-
Method Detail
-
getErrorStatus
public int getErrorStatus()
Returns the error status for the request. This is only value on RESPONSE pdu's. Otherwise the value should be equal to zero. For information on error conditions see the SnmpPduPacket class.- Returns:
- The error status of the pdu
- See Also:
SnmpPduPacket
-
setErrorStatus
public void setErrorStatus(int status)
Used to set the value of the error status member. This should normally be equal to zero, except for RESPONSE pdu's- Parameters:
status
- The new error status for the pdu.
-
getErrorIndex
public int getErrorIndex()
Returns the index of the variable in error if the error status is non-zero. The index is base one, not zero. Thus an error index equal to one is the first variable in the PDU. An index equal to zero is not valid.- Returns:
- The index of the bad variable.
-
setErrorIndex
public void setErrorIndex(int ndx)
Sets the current error index in the PDU. the index must be in the range (0..#variables] unless there is no error. If there is no error then the index should be equal to zero.- Parameters:
ndx
- The new error index.
-
fix
public void fix()
Fixes a PDU in error. If the error index and error status is non-zero then the variable in error is removed from the PDU. Once the variable is removed the error index and error status are reset to zero.
-
duplicate
public SnmpSyntax duplicate()
Used to get a duplicate of self. The duplicate is identical to self but shares no common data.- Specified by:
duplicate
in interfaceSnmpSyntax
- Specified by:
duplicate
in classSnmpPduPacket
- Returns:
- A newly created copy of self.
-
clone
public Object clone()
Used to get a duplicate of self. The duplicate is identical to self but shares no common data.- Specified by:
clone
in classSnmpPduPacket
- Returns:
- A newly created copy of self.
-
-