snmp
Class SNMPPDU

java.lang.Object
  |
  +--snmp.SNMPObject
        |
        +--snmp.SNMPSequence
              |
              +--snmp.SNMPPDU

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


Fields inherited from class snmp.SNMPSequence
sequence, type
 
Constructor Summary
SNMPPDU(byte[] enc, int pduType)
          Create a new PDU of the specified type from the supplied BER encoding.
SNMPPDU(int 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().
 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, setValue, size, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SNMPPDU

public SNMPPDU(int 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

public SNMPPDU(byte[] enc,
               int 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.