All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.jaw.snmp.common.SnmpMessage

java.lang.Object
   |
   +----com.sun.jaw.snmp.common.SnmpMessage

public class SnmpMessage
extends Object
implements SnmpDefinitions
An SnmpMessage object is a partially decoded representation of an SNMP packet.

You normally don't need to use this class except if you decide to implement your own SnmpPduFactoryIf object.

The SnmpMessage class is directly mapped on the Message syntax defined in RFC1157 and RFC1902.

 Message ::= SEQUENCE {
    version       INTEGER { version(1) }, -- for SNMPv2
    community     OCTET STRING,           -- community name
    data          ANY                     -- an SNMPv2 PDU
 }
 

See Also:
SnmpPduFactoryIf, SnmpPduFactory, SnmpPduPacket

Variable Index

 o address
Source or destination address.
 o community
Community name
 o data
Encoding of the PDU.
 o dataLength
Number of useful bytes in the data field.
 o port
Source or destination port.
 o version
The protocol version.

Constructor Index

 o SnmpMessage()

Method Index

 o decodeMessage(byte[], int)
For Java DMK internal use only.
 o decodePdu()
Gets the pdu encoded in this message.
 o dumpHexBuffer(byte[], int, int)
Dump the content of a byte buffer using hexadecimal form.
 o encodeMessage(byte[])
For Java DMK internal use only.
 o encodePdu(SnmpPduPacket, int)
Initializes this message with the specified pdu.
 o printMessage()
Dump this message in a string

Variables

 o version
 public int version
The protocol version. decodeMessage and encodeMessage do not perform any check on this value. decodePdu and encodePdu accept only the values 0 (for SNMPv1) and 1 (for SNMPv2).

 o community
 public byte community[]
Community name

 o data
 public byte data[]
Encoding of the PDU. This is normally the BER encoding of the PDUs syntax defined in RFC1157 and RFC1902. However this can be authenticated or encrypted data (but you need to implemented your own SnmpPduFactoryIf class).

 o dataLength
 public int dataLength
Number of useful bytes in the data field.

 o address
 public InetAddress address
Source or destination address. For an incoming message it's the source. For an outgoing message it's the destination.

 o port
 public int port
Source or destination port. For an incoming message it's the source. For an outgoing message it's the destination.

Constructors

 o SnmpMessage
 public SnmpMessage()

Methods

 o encodeMessage
 public int encodeMessage(byte outputBytes[]) throws SnmpTooBigException
For Java DMK internal use only. Encodes this message and puts the result in the specified byte array.

Parameters:
outputBytes - an array to receive the resulting encoding.
Throws: ArrayIndexOutOfBoundsException
if the result does not fit in the specified array.
 o decodeMessage
 public void decodeMessage(byte inputBytes[],
                           int byteCount) throws SnmpStatusException
For Java DMK internal use only. Decodes the specified bytes and initializes this message.

Parameters:
inputBytes - the bytes to be decoded
Throws: SnmpStatusException
if the specified bytes are not a valid encoding..
 o encodePdu
 public void encodePdu(SnmpPduPacket pdu,
                       int maxDataLength) throws SnmpStatusException, SnmpTooBigException
Initializes this message with the specified pdu.

This method initializes the data field with an array of maxDataLength bytes. It encodes the pdu. The resulting encoding is stored in the data field and the length of the encoding is stored in dataLength.

If the encoding length exceeds maxDataLength, the method throws an exception.

Parameters:
pdu - the pdu to be encoded
pdu - the maximum length permitted for the data field
Throws: SnmpStatusException
if the specified pdu is not valid
Throws: ArrayIndexOutOfBoundsException
if the encoding exceeds maxDataLength..
 o decodePdu
 public SnmpPduPacket decodePdu() throws SnmpStatusException
Gets the pdu encoded in this message.

This method decodes the data field and return the resulting pdu.

Throws: SnmpStatusException
if the encoding is not valid
 o printMessage
 public String printMessage()
Dump this message in a string

Returns:
the string containing the dump
 o dumpHexBuffer
 public static String dumpHexBuffer(byte b[],
                                    int offset,
                                    int len)
Dump the content of a byte buffer using hexadecimal form.

Parameters:
b - the buffer to dump
offset - position of the first byte to be dumped
len - number of bytes to be dumped starting from offset
Returns:
the string containing the dump

All Packages  Class Hierarchy  This Package  Previous  Next  Index