snmp
Class SNMPPDU

java.lang.Object
  extended bysnmp.SNMPObject
      extended bysnmp.SNMPSequence
          extended bysnmp.SNMPPDU
Direct Known Subclasses:
SNMPv2InformRequestPDU, SNMPv2TrapPDU

public class SNMPPDU
extends SNMPSequence

The SNMPPDU class represents an SNMP PDU from RFC 1157, as indicated below. This forms the payload of an SNMP message. -- protocol data units PDUs ::= CHOICE { get-request GetRequest-PDU, get-next-request GetNextRequest-PDU, get-response GetResponse-PDU, set-request SetRequest-PDU, trap Trap-PDU } -- PDUs GetRequest-PDU ::= [0] IMPLICIT PDU GetNextRequest-PDU ::= [1] IMPLICIT PDU GetResponse-PDU ::= [2] IMPLICIT PDU SetRequest-PDU ::= [3] IMPLICIT PDU PDU ::= SEQUENCE { request-id INTEGER, error-status -- sometimes ignored INTEGER { noError(0), tooBig(1), noSuchName(2), badValue(3), readOnly(4), genErr(5) }, error-index -- sometimes ignored INTEGER, variable-bindings -- values are sometimes ignored VarBindList } -- variable bindings VarBind ::= SEQUENCE { name ObjectName, value ObjectSyntax } VarBindList ::= SEQUENCE OF VarBind END


Field Summary
 
Fields inherited from class snmp.SNMPSequence
sequence, tag
 
Constructor Summary
protected SNMPPDU(byte[] enc, byte pduType)
          Create a new PDU of the specified type from the supplied BER encoding.
  SNMPPDU(byte pduType, int requestID, int errorStatus, int errorIndex, SNMPSequence varList)
          Create a new PDU of the specified type, with given request ID, error status, and error index, and containing the supplied SNMP sequence as data.
 
Method Summary
 int getErrorIndex()
          A utility method that returns the error index for this PDU, identifying the problematic variable.
 int getErrorStatus()
          A utility method that extracts the error status for this PDU; if nonzero, can get index of problematic variable using getErrorIndex().
 byte getPDUType()
          A utility method that returns the PDU type of this PDU.
 int getRequestID()
          A utility method that extracts the request ID number from this PDU.
 SNMPSequence getVarBindList()
          A utility method that extracts the variable binding list from the pdu.
 
Methods inherited from class snmp.SNMPSequence
addSNMPObject, extractFromBEREncoding, getBEREncoding, getSNMPObjectAt, getValue, insertSNMPObjectAt, setValue, size, toString
 
Methods inherited from class snmp.SNMPObject
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SNMPPDU

public SNMPPDU(byte pduType,
               int requestID,
               int errorStatus,
               int errorIndex,
               SNMPSequence varList)
        throws SNMPBadValueException
Create a new PDU of the specified type, with given request ID, error status, and error index, and containing the supplied SNMP sequence as data.


SNMPPDU

protected SNMPPDU(byte[] enc,
                  byte pduType)
           throws SNMPBadValueException
Create a new PDU of the specified type from the supplied BER encoding.

Throws:
SNMPBadValueException - Indicates invalid SNMP PDU encoding supplied in enc.
Method Detail

getVarBindList

public SNMPSequence getVarBindList()
A utility method that extracts the variable binding list from the pdu. Useful for retrieving the set of (object identifier, value) pairs returned in response to a request to an SNMP device. The variable binding list is just an SNMP sequence containing the identifier, value pairs.

See Also:
SNMPVarBindList

getRequestID

public int getRequestID()
A utility method that extracts the request ID number from this PDU.


getErrorStatus

public int getErrorStatus()
A utility method that extracts the error status for this PDU; if nonzero, can get index of problematic variable using getErrorIndex().


getErrorIndex

public int getErrorIndex()
A utility method that returns the error index for this PDU, identifying the problematic variable.


getPDUType

public byte getPDUType()
A utility method that returns the PDU type of this PDU.