MySnmpCrawler API

snmp.message.pdu
Class SnmpPdu

java.lang.Object
  |
  +--org.opennms.protocols.snmp.SnmpPduPacket
        |
        +--org.opennms.protocols.snmp.SnmpPduRequest
              |
              +--snmp.message.pdu.SnmpPdu
All Implemented Interfaces:
java.lang.Cloneable, org.opennms.protocols.snmp.SnmpSyntax

public class SnmpPdu
extends org.opennms.protocols.snmp.SnmpPduRequest

The SnmpPdu class contains ASN.1 common constructs such as: RequestID, ErrorStatus, ErrorIndex, and VariableBindList. The class extends from "org.opennms.protocols.snmp.SnmpPduRequest" to obtain the list of bind variables. Each bind variable is presented by the SnmpVariable class.

Version:
$Revision: 0.1 $ $Date: 2004/03/09 06:03:52 $
Author:
Scott Cheng

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
SnmpPdu()
          The default Constructor.
SnmpPdu(int command)
          Constructs the SnmpPdu object with the PDU command.
SnmpPdu(int command, SnmpVariable[] vars)
          Constructs the SnmpPdu object with the PDU command and the variable bind list.
SnmpPdu(SnmpPdu second)
          The copy Constructor constructs the SnmpPdu object that is identical to the passed object.
 
Method Summary
 void addSnmpVariable(SnmpVariable var)
          Adds the SnmpVariable object to the end of the bind list.
 int decode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Decodes the protocol data unit from the passed buffer.
 int encode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Encodes the protocol data unit using the passed encoder and stores the results in the passed buffer.
 int getErrorIndex()
          Gets the ErrorIndex in the PDU.
 int getErrorStatus()
          Gets the ErrorStatus in the PDU.
 int getRequestID()
          Gets the RequestID in the PUD.
 SnmpVariable getSnmpVariableAt(int index)
          Gets the SnmpVariable object at the specific index.
 void setErrorIndex(int errorIndex)
          Sets the ErrorIndex in the PDU.
 void setErrorStatus(int errorStatus)
          Sets the ErrorStatus in the PDU.
 void setGetNextRequestPdu()
          Sets the PDU command as "GETNEXT".
 void setGetRequestPdu()
          Sets the PDU command as "GET".
 void setGetResponsePdu()
          Sets the PDU command as "RESPONSE".
 void setRequestID(int requestID)
          Sets the RequestID in the PUD.
 void setSetRequestPdu()
          Sets the PDU command as "SET".
 void setSnmpVariableAt(int index, SnmpVariable var)
          Sets the SnmpVariable object at the specific index.
 java.lang.String toString()
          Gets the string representation of the SnmpPdu object.
 
Methods inherited from class org.opennms.protocols.snmp.SnmpPduRequest
clone, duplicate, fix
 
Methods inherited from class org.opennms.protocols.snmp.SnmpPduPacket
addVarBind, addVarBindAt, decodeASN, encodeASN, getCommand, getLength, getRequestId, getVarBindAt, nextSequence, removeVarBindAt, setCommand, setRequestId, setVarBindAt, toVarBindArray, typeId
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SnmpPdu

public SnmpPdu()
The default Constructor.


SnmpPdu

public SnmpPdu(SnmpPdu second)
The copy Constructor constructs the SnmpPdu object that is identical to the passed object.

Parameters:
second - The object to be copied from.

SnmpPdu

public SnmpPdu(int command)
Constructs the SnmpPdu object with the PDU command.

Parameters:
command - The PDU command.

SnmpPdu

public SnmpPdu(int command,
               SnmpVariable[] vars)
Constructs the SnmpPdu object with the PDU command and the variable bind list.

Parameters:
command - The PDU command.
vars - The variable bind list.
Method Detail

getRequestID

public int getRequestID()
Gets the RequestID in the PUD.

Returns:
The RequestID in the PUD.

setRequestID

public void setRequestID(int requestID)
Sets the RequestID in the PUD.

Parameters:
requestID - The RequestID in the PUD.

getErrorStatus

public int getErrorStatus()
Gets the ErrorStatus in the PDU.

Overrides:
getErrorStatus in class org.opennms.protocols.snmp.SnmpPduRequest
Returns:
The errror status in the PDU.

setErrorStatus

public void setErrorStatus(int errorStatus)
Sets the ErrorStatus in the PDU.

Overrides:
setErrorStatus in class org.opennms.protocols.snmp.SnmpPduRequest
Parameters:
errorStatus - The error status.

getErrorIndex

public int getErrorIndex()
Gets the ErrorIndex in the PDU.

Overrides:
getErrorIndex in class org.opennms.protocols.snmp.SnmpPduRequest
Returns:
The error index in the PDU.

setErrorIndex

public void setErrorIndex(int errorIndex)
Sets the ErrorIndex in the PDU.

Overrides:
setErrorIndex in class org.opennms.protocols.snmp.SnmpPduRequest
Parameters:
errorIndex - The error index number.

getSnmpVariableAt

public SnmpVariable getSnmpVariableAt(int index)
Gets the SnmpVariable object at the specific index.

Parameters:
index - The index number.
Returns:
The SnmpVariable object at the specific index.

setSnmpVariableAt

public void setSnmpVariableAt(int index,
                              SnmpVariable var)
Sets the SnmpVariable object at the specific index.

Parameters:
index - The index number.
var - The SnmpVariable object.

addSnmpVariable

public void addSnmpVariable(SnmpVariable var)
Adds the SnmpVariable object to the end of the bind list.

Parameters:
var - The SnmpVariable object.

setGetRequestPdu

public void setGetRequestPdu()
Sets the PDU command as "GET".


setGetNextRequestPdu

public void setGetNextRequestPdu()
Sets the PDU command as "GETNEXT".


setSetRequestPdu

public void setSetRequestPdu()
Sets the PDU command as "SET".


setGetResponsePdu

public void setGetResponsePdu()
Sets the PDU command as "RESPONSE".


decode

public int decode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnDecodingException
Decodes the protocol data unit from the passed buffer. If an error occurs during the decoding sequence then an AsnDecodingException is thrown by the method. The value is decoded using the AsnEncoder passed to the object.

Parameters:
buf - The encode buffer
offset - The offset byte to begin decoding
encoder - The decoder object.
Returns:
The index of the byte immediantly after the last decoded byte of information.
Throws:
org.opennms.protocols.snmp.asn1.AsnDecodingException - Thrown by the encoder if an error occurs trying to decode the data buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException

encode

public int encode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnEncodingException
Encodes the protocol data unit using the passed encoder and stores the results in the passed buffer. An exception is thrown if an error occurs with the encoding of the information.

Parameters:
buf - The buffer to write the encoded information.
offset - The offset to start writing information
encoder - The encoder object.
Returns:
The offset of the byte immediantly after the last encoded byte.
Throws:
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown if the encoder finds an error in the buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException

toString

public java.lang.String toString()
Gets the string representation of the SnmpPdu object.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the SnmpPdu object.

MySnmpCrawler API