com.adventnet.snmp.snmp2
Class SnmpMessage

java.lang.Object
  |
  +--com.adventnet.snmp.snmp2.SnmpMessage
Direct Known Subclasses:
Snmp3Message

public class SnmpMessage
extends java.lang.Object
implements java.io.Serializable

This class encapsulates a v1 or v2c Snmp Message. when a SnmpPDU is instantiated, it instantiates the appropriate message object along with it. Applications must not instantiate SnmpMessage objects and should always use SnmpPDU. An instance of this is created everytime when an SnmpPDU is instantiated. It provides default authentication routines.

See Also:
Serialized Form

Field Summary
(package private)  boolean alwaysEncode
          boolean to control ASN.1 encoding (default true).
(package private)  ASN1Parser asnParser
           
(package private)  java.lang.String community
           
(package private)  java.lang.String communityEnc
          The encoding to use for community string.
(package private)  boolean isDebug
           
(package private)  int messageVersion
           
(package private)  int msgVersion
          SNMP Version number in PDU
(package private)  SnmpPDU pdu
           
(package private)  java.lang.String writeCommunity
          writeCommunity string received/sent
 
Constructor Summary
(package private) SnmpMessage()
           
  SnmpMessage(byte[] message)
          Constructs an SnmpMessage initialized with SNMP packet message byte array data.
(package private) SnmpMessage(SnmpPDU p)
           
 
Method Summary
(package private)  int authenticate(SnmpSession session)
           
(package private)  boolean authenticate(SnmpSession session, SnmpClient client)
          A client based authentication routine.
(package private)  void copy(SnmpMessage copyMsg)
           
(package private)  boolean encode(SnmpSession sess)
           
(package private)  void encodeCommunity()
           
(package private)  void encodeMsgVersion()
           
(package private)  java.lang.String getCommunity()
          Get community string received/sent
(package private)  java.lang.String getCommunityEncoding()
          Get the encoding to use for community string.
(package private)  int getMsgVersion()
          Get snmp Version number in PDU
 SnmpPDU getPDU()
          Returns the SnmpPDU instance associated with this message.
(package private)  java.lang.String getWriteCommunity()
          Get writeCommunity string received/sent
(package private)  void setCommunity(java.lang.String t)
          Set community string received/sent
(package private)  void setCommunityEncoding(java.lang.String enc)
          Set the encoding to use for community string.
(package private)  void setDebug(boolean isDbg)
           
 void setMsgVersion(int v)
          Sets snmp Version number in PDU
(package private)  void setReEncode(boolean reEncode)
           
(package private)  void setWriteCommunity(java.lang.String t)
          Set writeCommunity string received/sent
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgVersion

int msgVersion
SNMP Version number in PDU

messageVersion

int messageVersion

community

java.lang.String community

writeCommunity

java.lang.String writeCommunity
writeCommunity string received/sent

communityEnc

java.lang.String communityEnc
The encoding to use for community string. Default is 8-bit ASCII

isDebug

boolean isDebug

alwaysEncode

boolean alwaysEncode
boolean to control ASN.1 encoding (default true). Set to false to only encode if not already encoded. Normally a message is ASN.1 encoded during every send process. If you have a message that you send (unchanged) repeatedly, you can save time on subsequent resends by setting this to false.

pdu

SnmpPDU pdu

asnParser

ASN1Parser asnParser
Constructor Detail

SnmpMessage

SnmpMessage()

SnmpMessage

SnmpMessage(SnmpPDU p)

SnmpMessage

public SnmpMessage(byte[] message)
            throws SnmpException
Constructs an SnmpMessage initialized with SNMP packet message byte array data. The API user should not use this method.
Throws:
SnmpException - is thrown whenever an error occurs.
Method Detail

getMsgVersion

int getMsgVersion()
Get snmp Version number in PDU

setMsgVersion

public void setMsgVersion(int v)
Sets snmp Version number in PDU

getCommunity

java.lang.String getCommunity()
Get community string received/sent

setCommunity

void setCommunity(java.lang.String t)
Set community string received/sent

getWriteCommunity

java.lang.String getWriteCommunity()
Get writeCommunity string received/sent

setWriteCommunity

void setWriteCommunity(java.lang.String t)
Set writeCommunity string received/sent

setCommunityEncoding

void setCommunityEncoding(java.lang.String enc)
Set the encoding to use for community string. Default is jdk1.0.2 encoding

getCommunityEncoding

java.lang.String getCommunityEncoding()
Get the encoding to use for community string. Default is null

setDebug

void setDebug(boolean isDbg)

setReEncode

void setReEncode(boolean reEncode)

getPDU

public SnmpPDU getPDU()
Returns the SnmpPDU instance associated with this message.
Returns:
the SnmpPDU instance associated with this message.

copy

void copy(SnmpMessage copyMsg)

encode

boolean encode(SnmpSession sess)

encodeMsgVersion

void encodeMsgVersion()

encodeCommunity

void encodeCommunity()

authenticate

int authenticate(SnmpSession session)

authenticate

boolean authenticate(SnmpSession session,
                     SnmpClient client)
A client based authentication routine. This will always return true for v3 requests. For v1/v2c it will authenticate the request with the corresponding client. Callback for the client is invoked only if the authentication succeeds with that client.