MySnmpCrawler API

snmp.message
Class SnmpMessageUtil

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

public class SnmpMessageUtil
extends java.lang.Object

This utility class provides methods to decode and encode the SNMP data packet. Some of the code are duplicated to org.opennms.protocols.snmp.SnmpUtil.

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

Field Summary
(package private) static java.util.ArrayList m_syntaxArray
          The array of dynamically registred SnmpSyntax objects
static long UnsignedInt32Max
           
static long UnsignedInt32Min
           
 
Constructor Summary
SnmpMessageUtil()
           
 
Method Summary
(package private) static void copy(byte[] src, int srcOffset, byte[] dest, int destOffset, int count)
          Used to copy data from one buffer to another.
(package private) static void copy(int[] src, int srcOffset, int[] dest, int destOffset, int count)
          Used to copy data from one buffer to another.
static void dumpHex(java.io.PrintStream out, byte[] data, int offset, int length)
          Dumps the data to the PrintStream object.
static org.opennms.protocols.snmp.SnmpSyntax getSyntaxObject(byte asnType)
          Used to dynamically lookup registered SnmpSyntax objects
static boolean registerSyntax(org.opennms.protocols.snmp.SnmpSyntax obj)
          Used to register a SnmpSyntax object with the SnmpUtil class.
static void rotate(byte[] buf, int begin, int pivot, int end)
          Rotates a give buffer area marked by begin, pivot, and end.
static void rotate(int[] buf, int begin, int pivot, int end)
          Rotates a give buffer area marked by begin, pivot, and end.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UnsignedInt32Min

public static final long UnsignedInt32Min
See Also:
Constant Field Values

UnsignedInt32Max

public static final long UnsignedInt32Max
See Also:
Constant Field Values

m_syntaxArray

static java.util.ArrayList m_syntaxArray
The array of dynamically registred SnmpSyntax objects

Constructor Detail

SnmpMessageUtil

public SnmpMessageUtil()
Method Detail

copy

static void copy(byte[] src,
                 int srcOffset,
                 byte[] dest,
                 int destOffset,
                 int count)
Used to copy data from one buffer to another. The method has the flexability to allow the caller to specify an offset in each buffer and the total number of bytes to copy

Parameters:
src - The source buffer
srcOffset - The offset of the first byte in the source buffer
dest - The destination buffer
destOffset - The offset of the first byte in the destination buffer
count - The number of elements to copy

copy

static void copy(int[] src,
                 int srcOffset,
                 int[] dest,
                 int destOffset,
                 int count)
Used to copy data from one buffer to another. The method has the flexability to allow the caller to specify an offset in each buffer and the total number of bytes to copy

Parameters:
src - The source buffer
srcOffset - The offset of the first byte in the source buffer
dest - The destination buffer
destOffset - The offset of the first byte in the destination buffer
count - The number of elements to copy

rotate

public static void rotate(byte[] buf,
                          int begin,
                          int pivot,
                          int end)
Rotates a give buffer area marked by begin, pivot, and end. The pivot marks the point where the bytes between [pivot..end) are moved to the position marked by begin. The bytes between [begin..pivot) are shifted such that begin is at [begin+(end-pivot)].

Parameters:
buf - The buffer containing the data to rotate
begin - The start of the rotation
pivot - The pivot point for the rotation
end - The end of the rotational buffer

rotate

public static void rotate(int[] buf,
                          int begin,
                          int pivot,
                          int end)
Rotates a give buffer area marked by begin, pivot, and end. The pivot marks the point where the bytes between [pivot..end) are moved to the position marked by begin. The bytes between [begin..pivot) are shifted such that begin is at [begin+(end-pivot)].

Parameters:
buf - The buffer containing the data to rotate
begin - The start of the rotation
pivot - The pivot point for the rotation
end - The end of the rotational buffer

registerSyntax

public static boolean registerSyntax(org.opennms.protocols.snmp.SnmpSyntax obj)
Used to register a SnmpSyntax object with the SnmpUtil class. Once registered it can be dynamically found based on it's typeId().

Parameters:
obj - The SnmpSyntax object to add
Returns:
True if the object is successfully added

getSyntaxObject

public static org.opennms.protocols.snmp.SnmpSyntax getSyntaxObject(byte asnType)
Used to dynamically lookup registered SnmpSyntax objects

Parameters:
asnType - The ASN.1 type to search for
Returns:
A new SnmpSyntax object of the appropiate type

dumpHex

public static void dumpHex(java.io.PrintStream out,
                           byte[] data,
                           int offset,
                           int length)
Dumps the data to the PrintStream object.


MySnmpCrawler API