public class

SnmpMessage

extends SnmpMsg
implements SnmpDefinitions
java.lang.Object
   ↳ com.sun.jmx.snmp.SnmpMsg
     ↳ com.sun.jmx.snmp.SnmpMessage

Class Overview

Is a partially decoded representation of an SNMP packet.

You will not normally need to use this class unless you decide to implement your own SnmpPduFactory object.

The SnmpMessage class is directly mapped onto 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
 }
 

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

See Also

Summary

[Expand]
Inherited Constants
From interface com.sun.jmx.snmp.SnmpDefinitions
Fields
public byte[] community Community name.
[Expand]
Inherited Fields
From class com.sun.jmx.snmp.SnmpMsg
Public Constructors
SnmpMessage()
Public Methods
void decodeMessage(byte[] inputBytes, int byteCount)
Decodes the specified bytes and initializes this message.
SnmpPdu decodeSnmpPdu()
Gets the PDU encoded in this message.
int encodeMessage(byte[] outputBytes)
Encodes this message and puts the result in the specified byte array.
void encodeSnmpPdu(SnmpPdu pdu, int maxDataLength)
Initializes this message with the specified pdu.
int getRequestId(byte[] inputBytes)
Returns the associated request ID.
String printMessage()
Dumps this message in a string.
[Expand]
Inherited Methods
From class com.sun.jmx.snmp.SnmpMsg
From class java.lang.Object

Fields

public byte[] community

Community name.

Public Constructors

public SnmpMessage ()

Public Methods

public void decodeMessage (byte[] inputBytes, int byteCount)

Decodes the specified bytes and initializes this message. For internal use only.

Parameters
inputBytes The bytes to be decoded.
Throws
SnmpStatusException If the specified bytes are not a valid encoding.

public SnmpPdu decodeSnmpPdu ()

Gets the PDU encoded in this message.

This method decodes the data field and returns the resulting PDU.

Returns
  • The resulting PDU.
Throws
SnmpStatusException If the encoding is not valid.

public int encodeMessage (byte[] outputBytes)

Encodes this message and puts the result in the specified byte array. For internal use only.

Parameters
outputBytes An array to receive the resulting encoding.
Throws
ArrayIndexOutOfBoundsException If the result does not fit into the specified array.
SnmpTooBigException

public void encodeSnmpPdu (SnmpPdu pdu, int maxDataLength)

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.
maxDataLength The maximum length permitted for the data field.
Throws
SnmpStatusException If the specified pdu is not valid.
SnmpTooBigException If the resulting encoding does not fit into maxDataLength bytes.
ArrayIndexOutOfBoundsException If the encoding exceeds maxDataLength.

public int getRequestId (byte[] inputBytes)

Returns the associated request ID.

Parameters
inputBytes The flat message.
Returns
  • The request ID.

public String printMessage ()

Dumps this message in a string.

Returns
  • The string containing the dump.