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
-
address
- Source or destination address.
-
community
- Community name
-
data
- Encoding of the PDU.
-
dataLength
- Number of useful bytes in the
data field.
-
port
- Source or destination port.
-
version
- The protocol version.
-
SnmpMessage()
-
-
decodeMessage(byte[], int)
- For Java DMK internal use only.
-
decodePdu()
- Gets the pdu encoded in this message.
-
dumpHexBuffer(byte[], int, int)
- Dump the content of a byte buffer using hexadecimal form.
-
encodeMessage(byte[])
- For Java DMK internal use only.
-
encodePdu(SnmpPduPacket, int)
- Initializes this message with the specified pdu.
-
printMessage()
- Dump this message in a string
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).
community
public byte community[]
- Community name
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).
dataLength
public int dataLength
- Number of useful bytes in the
data field.
address
public InetAddress address
- Source or destination address.
For an incoming message it's the source.
For an outgoing message it's the destination.
port
public int port
- Source or destination port.
For an incoming message it's the source.
For an outgoing message it's the destination.
SnmpMessage
public SnmpMessage()
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.
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..
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..
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
printMessage
public String printMessage()
- Dump this message in a string
- Returns:
- the string containing the dump
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