SourceForge.net Logo

org.netsnmp
Class PDU

java.lang.Object
  |
  +--org.netsnmp.PDU
All Implemented Interfaces:
Serializable

public class PDU
extends Object
implements Serializable

Primary Data Unit A message that sent to or received from a remote SNMP agent.


  import org.netsnmp.* ;

  class mySysRequest {

    NetSNMPSession sess = new org.netsnmp.NetSNMPSession("remotehost", "community") ;
    PDU pdu = new PDU(NetSNMP.MSG_SET) ;
    final OID oid = new DefaultOID("iso.org.dod.internet.mgmt.mib-2.system.sysDescr.0") ;

    NetSNMPAction  l = new NetSNMPAction {
       public boolean actionPerformed(int result, NetSNMPSession sess,  PDU receivedPDU, Object o) {

       }
     }
   }
   
   
   sess.addListener(l) ;
   pdu.addNullEntry(oid) ;

   sess.send(pdu, null) ;

  

See Also:
Serialized Form

Nested Class Summary
static class PDU.entry
          Entry of an individual data item.
static class PDU.PDU_COMMAND
          Typesafe enum for specific PDU_COMMANDS
 
Field Summary
 byte[] agent_addr
           
static int ASN_CONSTRUCTOR
           
static int ASN_CONTEXT
           
 OID enterprise
           
 PDU.entry[] entries
           
 int errIndex
           
 int errStatus
           
 int maxRepetitions
           
 int nonRepeaters
           
protected  int requestID
           
static PDU.PDU_COMMAND SNMP_MSG_GET
          Command type to request values from a remote agent
static PDU.PDU_COMMAND SNMP_MSG_GETBULK
          Command type to get 'bulk' repsonses from remote agents
static PDU.PDU_COMMAND SNMP_MSG_GETNEXT
          Command type to request the next object from a remote agent
static PDU.PDU_COMMAND SNMP_MSG_INFORM
           
static PDU.PDU_COMMAND SNMP_MSG_REPORT
           
static PDU.PDU_COMMAND SNMP_MSG_RESPONSE
           
static PDU.PDU_COMMAND SNMP_MSG_SET
          Command type to set values from a remote agent
static PDU.PDU_COMMAND SNMP_MSG_TRAP
           
static PDU.PDU_COMMAND SNMP_MSG_TRAP2
           
 int specific_type
           
 int time
           
 int trap_type
           
 PDU.PDU_COMMAND type
           
 
Constructor Summary
PDU()
           
PDU(PDU.PDU_COMMAND t)
           
 
Method Summary
 void addEntry(int[] oidDescr, ASNValue v)
           
 void addEntry(OID o, ASNValue v)
           
 OID addEntry(String desc, ASNValue v)
          Add an entry into the PDU
 void addNullEntries(OID[] oids)
          Allows you to add a large ammount of oids all at once rather than one at a time
 void addNullEntry(OID desc)
          Add a null entry to the PDU
 void addNullEntry(OID desc, int instance)
          Add a null entry to the PDU
 OID addNullEntry(String desc)
          Adds a new null entry to the PDU
 void addNullEntry(String desc, int instance)
          Adds a new null entry to the PDU
 void append(PDU pdu)
          Append the entries from pdu to this one.
 String errString()
           
 ASNValue findValue(OID oid)
          Retrieve a value from the pdu corresponding to the oid
 ASNValue findValue(OID oid, int inst)
          Retrieives a value from the pdu corresponding to the oid and the instance
 int nValues()
           
 int requestID()
           
 void setEntries(OID[] oids, ASNValue[] values)
           
 void setEntries(PDU.entry[] new_entries)
           
 void setValue(OID oid, ASNValue value)
          Replaces the existing value corresponding to oid in the pdu.
 int size()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

agent_addr

public byte[] agent_addr

enterprise

public OID enterprise

entries

public PDU.entry[] entries

errStatus

public int errStatus

errIndex

public int errIndex

maxRepetitions

public int maxRepetitions

nonRepeaters

public int nonRepeaters

requestID

protected int requestID

specific_type

public int specific_type

time

public int time

trap_type

public int trap_type

type

public PDU.PDU_COMMAND type

ASN_CONSTRUCTOR

public static int ASN_CONSTRUCTOR

ASN_CONTEXT

public static int ASN_CONTEXT

SNMP_MSG_GET

public static final PDU.PDU_COMMAND SNMP_MSG_GET
Command type to request values from a remote agent


SNMP_MSG_GETBULK

public static final PDU.PDU_COMMAND SNMP_MSG_GETBULK
Command type to get 'bulk' repsonses from remote agents


SNMP_MSG_GETNEXT

public static final PDU.PDU_COMMAND SNMP_MSG_GETNEXT
Command type to request the next object from a remote agent


SNMP_MSG_INFORM

public static final PDU.PDU_COMMAND SNMP_MSG_INFORM

SNMP_MSG_REPORT

public static final PDU.PDU_COMMAND SNMP_MSG_REPORT

SNMP_MSG_RESPONSE

public static final PDU.PDU_COMMAND SNMP_MSG_RESPONSE

SNMP_MSG_SET

public static final PDU.PDU_COMMAND SNMP_MSG_SET
Command type to set values from a remote agent


SNMP_MSG_TRAP

public static final PDU.PDU_COMMAND SNMP_MSG_TRAP

SNMP_MSG_TRAP2

public static final PDU.PDU_COMMAND SNMP_MSG_TRAP2
Constructor Detail

PDU

public PDU()

PDU

public PDU(PDU.PDU_COMMAND t)
Method Detail

addEntry

public void addEntry(int[] oidDescr,
                     ASNValue v)

addEntry

public void addEntry(OID o,
                     ASNValue v)
Parameters:
o - OID of the object being added
v - the value associated with the oid

addEntry

public OID addEntry(String desc,
                    ASNValue v)
             throws MIBItemNotFound
Add an entry into the PDU

Parameters:
desc - object ID descriptor
Returns:
OID of the object added
MIBItemNotFound

addNullEntries

public void addNullEntries(OID[] oids)
Allows you to add a large ammount of oids all at once rather than one at a time


addNullEntry

public void addNullEntry(OID desc)
Add a null entry to the PDU

Parameters:
desc - OID of the entry

addNullEntry

public void addNullEntry(OID desc,
                         int instance)
Add a null entry to the PDU

Parameters:
desc - descriptor of the object
instance - instance of the object

addNullEntry

public OID addNullEntry(String desc)
                 throws MIBItemNotFound
Adds a new null entry to the PDU

Parameters:
desc - symbolic descriptor of the object
Returns:
OID of the added object
Throws:
MIBItemNotFound - if the Item was not found in the currently loaded MIBs

addNullEntry

public void addNullEntry(String desc,
                         int instance)
                  throws MIBItemNotFound
Adds a new null entry to the PDU

Parameters:
desc - symbolc descriptor of the object
instance - instance of the object
Throws:
MIBItemNotFound - if the item was not found in the currently loaded MIBs

append

public void append(PDU pdu)
Append the entries from pdu to this one.

Parameters:
pdu - PDU to append

errString

public String errString()
Returns:
error status of the PDU represented as a string

findValue

public ASNValue findValue(OID oid)
Retrieve a value from the pdu corresponding to the oid

Parameters:
oid - corresponding to the value within the PDU
Returns:
value correpsonding to oid, null if no such entry

findValue

public ASNValue findValue(OID oid,
                          int inst)
Retrieives a value from the pdu corresponding to the oid and the instance

Parameters:
oid - specifier for the object
inst - particular instance of the object
Returns:
value correpsonding to oid and instance, null if no such entry

nValues

public int nValues()
Returns:
number of values in this PDU

requestID

public int requestID()

setEntries

public void setEntries(PDU.entry[] new_entries)
Parameters:
new_entries - entries to replace the current entries with

setEntries

public void setEntries(OID[] oids,
                       ASNValue[] values)
Parameters:
oids - OIDs of the entries to replace the current entries with
values - values of the entries to replace the current entries with

setValue

public void setValue(OID oid,
                     ASNValue value)
Replaces the existing value corresponding to oid in the pdu. if the entry doesn't exist it is added to the end

Parameters:
oid - object identifier for the value
value - to set

size

public int size()

toString

public String toString()
Overrides:
toString in class Object
Returns:
string representation of the PDU to a string detailing its contents

SourceForge.net Logo