com.sun.jaw.snmp.common
Interface SnmpPduFactoryIf

All Known Implementing Classes:
SnmpPduFactory

public abstract interface SnmpPduFactoryIf

The SnmpPduFactoryIf defines the interface of the object in charge of encoding and decoding SNMP packets.

You normally don't need to use this interface except if you decide to replace the default implementation SnmpPduFactory.

An SnmpPduFactoryIf object is attached to an AdaptorServerImpl or an SnmpPeer. It is used each time an SNMP packet needs to be encoded or decoded. SnmpPduFactory is the default implementation. It simply applies the standard ASN.1 encoding and decoding on the bytes of the SNMP packet.

It's possible to implement its own SnmpPduFactoryIf object and to add authentication and/or encryption to the default encoding/decoding process.

See Also:
SnmpPduFactory, SnmpPduPacket, SnmpMessage

Method Summary
 SnmpPduPacket decodePdu(SnmpMessage msg)
          Decodes the specified SnmpMessage and returns the resulting SnpmPduPacket.
 SnmpMessage encodePdu(SnmpPduPacket pdu, int maxPktSize)
          Encodes the specified SnmpPduPacket and returns the resulting SnmpMessage.
 

Method Detail

decodePdu

public SnmpPduPacket decodePdu(SnmpMessage msg)
                        throws SnmpStatusException
Decodes the specified SnmpMessage and returns the resulting SnpmPduPacket. If this method returns null, the message will be considered unsafe and will be drop.
Parameters:
msg - The SnmpMessage to be decoded.
Returns:
Null or a fully initialized SnmpPduPacket.
Throws:
SnmpStatusException - If the encoding is invalid.

encodePdu

public SnmpMessage encodePdu(SnmpPduPacket pdu,
                             int maxPktSize)
                      throws SnmpStatusException,
                             SnmpTooBigException
Encodes the specified SnmpPduPacket and returns the resulting SnmpMessage. If this method returns null, the specified SnmpPduPacket will be dropped and the current SNMP request will be aborted.
Parameters:
pdu - The SnmpPduPacket to be encoded.
maxPktSize - The size limit of the resulting encoding.
Returns:
Null or a fully encoded SnmpMessage.
Throws:
SnmpStatusException - If pdu contains illegal values and cannot be encoded.
SnmpTooBigException - If the resulting encoding does not fit in maxPktSize bytes.