public class

SnmpPduFactoryBER

extends Object
implements SnmpPduFactory Serializable
java.lang.Object
   ↳ com.sun.jmx.snmp.SnmpPduFactoryBER

Class Overview

Default implementation of the SnmpPduFactory interface.
It uses the BER (basic encoding rules) standardized encoding scheme associated with ASN.1.

This implementation of the SnmpPduFactory is very basic: it simply calls encoding and decoding methods from SnmpMsg.

 public SnmpPdu decodeSnmpPdu(SnmpMsg msg)
 throws SnmpStatusException {
   return msg.decodeSnmpPdu() ;
 }

 public SnmpMsg encodeSnmpPdu(SnmpPdu pdu, int maxPktSize)
 throws SnmpStatusException, SnmpTooBigException {
   SnmpMsg result = new SnmpMessage() ;       // for SNMP v1/v2
 or
   SnmpMsg result = new SnmpV3Message() ;     // for SNMP v3
   result.encodeSnmpPdu(pdu, maxPktSize) ;
   return result ;
 }
 
To implement your own object, you can implement SnmpPduFactory or extend SnmpPduFactoryBER.

This API is a Sun Microsystems internal API and is subject to change without notice.

Summary

Public Constructors
SnmpPduFactoryBER()
Public Methods
SnmpPdu decodeSnmpPdu(SnmpMsg msg)
Calls SnmpMsg.decodeSnmpPdu on the specified message and returns the resulting SnmpPdu.
SnmpMsg encodeSnmpPdu(SnmpPdu p, int maxDataLength)
Encodes the specified SnmpPdu and returns the resulting SnmpMsg.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.sun.jmx.snmp.SnmpPduFactory

Public Constructors

public SnmpPduFactoryBER ()

Public Methods

public SnmpPdu decodeSnmpPdu (SnmpMsg msg)

Calls SnmpMsg.decodeSnmpPdu on the specified message and returns the resulting SnmpPdu.

Parameters
msg The SNMP message to be decoded.
Returns
  • The resulting SNMP PDU packet.
Throws
SnmpStatusException If the encoding is invalid.

public SnmpMsg encodeSnmpPdu (SnmpPdu p, int maxDataLength)

Encodes the specified SnmpPdu and returns the resulting SnmpMsg. If this method returns null, the specified SnmpPdu will be dropped and the current SNMP request will be aborted.

Parameters
p The SnmpPdu to be encoded.
maxDataLength The size limit of the resulting encoding.
Returns
  • Null or a fully encoded SnmpMsg.
Throws
SnmpStatusException If pdu contains illegal values and cannot be encoded.
SnmpTooBigException If the resulting encoding does not fit into maxPktSize bytes.