|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.jaw.snmp.common.SnmpMessage
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 }
SnmpPduFactoryIf
,
SnmpPduFactory
,
SnmpPduPacket
Field Summary | |
java.net.InetAddress |
address
Source or destination address. |
byte[] |
community
Community name. |
byte[] |
data
Encoding of the PDU. |
int |
dataLength
Number of useful bytes in the data field. |
int |
port
Source or destination port. |
int |
version
The protocol version. |
Constructor Summary | |
SnmpMessage()
|
Method Summary | |
SnmpPduPacket |
decodePdu()
Gets the pdu encoded in this message. |
static java.lang.String |
dumpHexBuffer(byte[] b,
int offset,
int len)
Dumps the content of a byte buffer using hexadecimal form. |
void |
encodePdu(SnmpPduPacket pdu,
int maxDataLength)
Initializes this message with the specified pdu. |
java.lang.String |
printMessage()
Dumps this message in a string. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public int 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).
public byte[] community
public byte[] data
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).
public int dataLength
data
field.public java.net.InetAddress address
For an incoming message it's the source. For an outgoing message it's the destination.
public int port
For an incoming message it's the source. For an outgoing message it's the destination.
Constructor Detail |
public SnmpMessage()
Method Detail |
public void encodePdu(SnmpPduPacket pdu, int maxDataLength) throws SnmpStatusException, SnmpTooBigException
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.
pdu
- The pdu to be encoded.maxDataLength
- The maximum length permitted for the data field.maxDataLength
bytes.public SnmpPduPacket decodePdu() throws SnmpStatusException
This method decodes the data field and return the resulting pdu.
public java.lang.String printMessage()
public static java.lang.String dumpHexBuffer(byte[] b, int offset, int len)
b
- The buffer to dump.offset
- The position of the first byte to be dumped.len
- The number of bytes to be dumped starting from offset.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |