com.sun.management.snmp
Class SnmpMessage

java.lang.Object
  extended by com.sun.management.snmp.SnmpMsg
      extended by com.sun.management.snmp.SnmpMessage
All Implemented Interfaces:
SnmpDefinitions

public class SnmpMessage
extends SnmpMsg
implements SnmpDefinitions

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
 }
 

Since:
Java DMK 5.1
See Also:
SnmpPduFactory, SnmpPduPacket

Field Summary
 byte[] community
          Community name.
 
Fields inherited from class com.sun.management.snmp.SnmpMsg
address, data, dataLength, port, securityParameters, version
 
Fields inherited from interface com.sun.management.snmp.SnmpDefinitions
authMask, authNoPriv, authPriv, authPrivMask, CtxtConsFlag, noAuthNoPriv, noGroupName, noSuchContext, noSuchView, notInView, pduGetBulkRequestPdu, pduGetNextRequestPdu, pduGetRequestPdu, pduGetResponsePdu, pduInformRequestPdu, pduReportPdu, pduSetRequestPdu, pduV1TrapPdu, pduV2TrapPdu, pduWalkRequest, privMask, reportableFlag, snmpAuthNotSupported, snmpBadSecurityLevel, snmpPrivNotSupported, snmpReqAborted, snmpReqEncodingError, snmpReqHandleTooBig, snmpReqInternalError, snmpReqPacketOverflow, snmpReqRefireAfterVbFix, snmpReqSocketIOError, snmpReqTimeout, snmpReqTooBigImpossible, snmpReqUnknownError, snmpRspAuthorizationError, snmpRspBadValue, snmpRspCommitFailed, snmpRspDecodingError, snmpRspEndOfTable, snmpRspGenErr, snmpRspInconsistentName, snmpRspInconsistentValue, snmpRspNoAccess, snmpRspNoCreation, snmpRspNoError, snmpRspNoSuchName, snmpRspNotWritable, snmpRspReadOnly, snmpRspResourceUnavailable, snmpRspTooBig, snmpRspUndoFailed, snmpRspWrongEncoding, snmpRspWrongLength, snmpRspWrongType, snmpRspWrongValue, snmpUnknownPrincipal, snmpUsmBadEngineId, snmpUsmInvalidTimeliness, snmpUsmSecurityModel, snmpV1AccessControlModel, snmpV1MsgProcessingModel, snmpV1SecurityModel, snmpV2AccessControlModel, snmpV2MsgProcessingModel, snmpV2SecurityModel, snmpV3AccessControlModel, snmpV3MsgProcessingModel, snmpVersionOne, snmpVersionThree, snmpVersionTwo, snmpWrongSnmpVersion, trapAuthenticationFailure, trapColdStart, trapEgpNeighborLoss, trapEnterpriseSpecific, trapLinkDown, trapLinkUp, trapWarmStart
 
Constructor Summary
SnmpMessage()
           
 
Method Summary
 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.
 
Methods inherited from class com.sun.management.snmp.SnmpMsg
decodeVarBindList, dumpHexBuffer, encodeVarBindList, getProtocolVersion
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

community

public byte[] community
Community name.

Constructor Detail

SnmpMessage

public SnmpMessage()
Method Detail

encodeMessage

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

Specified by:
encodeMessage in class SnmpMsg
Parameters:
outputBytes - An array to receive the resulting encoding.
Throws:
ArrayIndexOutOfBoundsException - If the result does not fit into the specified array.
SnmpTooBigException

getRequestId

public int getRequestId(byte[] inputBytes)
                 throws SnmpStatusException
Returns the associated request ID.

Specified by:
getRequestId in class SnmpMsg
Parameters:
inputBytes - The flat message.
Returns:
The request ID.
Throws:
SnmpStatusException

decodeMessage

public void decodeMessage(byte[] inputBytes,
                          int byteCount)
                   throws SnmpStatusException
Decodes the specified bytes and initializes this message. For internal use only.

Specified by:
decodeMessage in class SnmpMsg
Parameters:
inputBytes - The bytes to be decoded.
Throws:
SnmpStatusException - If the specified bytes are not a valid encoding.

encodeSnmpPdu

public void encodeSnmpPdu(SnmpPdu 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.

Specified by:
encodeSnmpPdu in class SnmpMsg
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.

decodeSnmpPdu

public SnmpPdu decodeSnmpPdu()
                      throws SnmpStatusException
Gets the PDU encoded in this message.

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

Specified by:
decodeSnmpPdu in class SnmpMsg
Returns:
The resulting PDU.
Throws:
SnmpStatusException - If the encoding is not valid.

printMessage

public String printMessage()
Dumps this message in a string.

Overrides:
printMessage in class SnmpMsg
Returns:
The string containing the dump.

Open Source build 02
opendmk-1.0-b02 2007.10.01_19:17:46_MEST

Copyright 1998-2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.