MySnmpCrawler API

snmp.message
Class SnmpMessageHeader

java.lang.Object
  |
  +--snmp.message.SnmpMessageHeader

public class SnmpMessageHeader
extends java.lang.Object

This class provides SNMP message header information. It contains the protocol version number and the community string.

Version:
$Revision: 0.1 $ $Date: 2004/03/09 06:03:51 $
Author:
Scott Cheng

Field Summary
private  MySnmpCrawlerOctetString community
           
private  java.lang.String strCommunity
           
private  MySnmpCrawlerInt32 version
           
 
Constructor Summary
SnmpMessageHeader()
          The default Constructor
SnmpMessageHeader(MySnmpCrawlerInt32 version, MySnmpCrawlerOctetString community)
          Constructs the SnmpMessageHeader object with the version number and the community string.
 
Method Summary
 int decode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Decodes the SNMP header information from the passed buffer.
 int encode(byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Encodes the header information including the version number and the community string.
 java.lang.String getCommunity()
          Gets the SNMP community string.
 int getVersion()
          Gets the SNMP version number.
 void setCommunity(java.lang.String strCommunity)
          Sets the SNMP community string.
 void setVersion(int iversion)
          Sets the SNMP version number.
 java.lang.String toString()
          Gets the string representation of the SnmpMessageHeader object.
 int validateSnmpPacket(java.net.DatagramPacket packet, byte[] buf, int offset, org.opennms.protocols.snmp.asn1.BerEncoder encoder)
          Validates the SNMP packet to see if it complies with ASN.1 standard.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

version

private MySnmpCrawlerInt32 version

community

private MySnmpCrawlerOctetString community

strCommunity

private java.lang.String strCommunity
Constructor Detail

SnmpMessageHeader

public SnmpMessageHeader()
The default Constructor


SnmpMessageHeader

public SnmpMessageHeader(MySnmpCrawlerInt32 version,
                         MySnmpCrawlerOctetString community)
Constructs the SnmpMessageHeader object with the version number and the community string.

Parameters:
version - The version number
Method Detail

validateSnmpPacket

public int validateSnmpPacket(java.net.DatagramPacket packet,
                              byte[] buf,
                              int offset,
                              org.opennms.protocols.snmp.asn1.BerEncoder encoder)
                       throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                              org.opennms.protocols.snmp.asn1.AsnDecodingException
Validates the SNMP packet to see if it complies with ASN.1 standard.

Throws:
org.opennms.protocols.snmp.SnmpPduEncodingException - thrown when ASN.1 Type is not compatible.
org.opennms.protocols.snmp.asn1.AsnDecodingException - thrown when insufficient data in packet.

decode

public int decode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnDecodingException
Decodes the SNMP header information from the passed buffer.

Parameters:
buf - The data to decode
offset - The position to start decoding
encoder - The encoder used for "encode" and "decode"
Throws:
org.opennms.protocols.snmp.asn1.AsnEncodingException - Thrown if the encoder finds an error in the passed buffer.
org.opennms.protocols.snmp.SnmpPduEncodingException
org.opennms.protocols.snmp.asn1.AsnDecodingException

encode

public int encode(byte[] buf,
                  int offset,
                  org.opennms.protocols.snmp.asn1.BerEncoder encoder)
           throws org.opennms.protocols.snmp.SnmpPduEncodingException,
                  org.opennms.protocols.snmp.asn1.AsnEncodingException
Encodes the header information including the version number and the community string.

Parameters:
buf - The data to decode
offset - The position to start decoding
encoder - The encoder used for "encode" and "decode"
org.opennms.protocols.snmp.SnmpPduEncodingException
org.opennms.protocols.snmp.asn1.AsnEncodingException

getVersion

public int getVersion()
Gets the SNMP version number.

Returns:
The version number.

setVersion

public void setVersion(int iversion)
Sets the SNMP version number.

Parameters:
iversion - The version number.

getCommunity

public java.lang.String getCommunity()
Gets the SNMP community string.

Returns:
The community string.

setCommunity

public void setCommunity(java.lang.String strCommunity)
Sets the SNMP community string.

Parameters:
strCommunity - The community string.

toString

public java.lang.String toString()
Gets the string representation of the SnmpMessageHeader object.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of the SnmpMessageHeader object.

MySnmpCrawler API