com.adventnet.snmp.snmp2
Class ASNTypes

java.lang.Object
  extended by com.adventnet.snmp.snmp2.ASNTypes

 class ASNTypes
extends java.lang.Object

Container for ASN utility Functions and Parameters. API Users will not need to use this class directly. This class has all it's methods and variables static and does not need to be instantiated.


Field Summary
(package private) static byte ASN_APPLICATION
           
(package private) static byte ASN_BIT_STR
           
(package private) static byte ASN_BIT8
           
(package private) static byte ASN_BOOLEAN
           
(package private) static byte ASN_CONSTRUCTOR
           
(package private) static byte ASN_CONTEXT
           
(package private) static int ASN_EXCEPTION
           
(package private) static byte ASN_EXTENSION_ID
           
(package private) static byte ASN_INTEGER
           
(package private) static byte ASN_LONG_LEN
           
(package private) static byte ASN_NULL
           
(package private) static byte ASN_OBJECT_ID
           
(package private) static byte ASN_OCTET_STR
           
(package private) static byte ASN_PRIMITIVE
           
(package private) static byte ASN_PRIVATE
           
(package private) static byte ASN_SEQUENCE
           
(package private) static byte ASN_SET
           
(package private) static byte ASN_UNIVERSAL
           
(package private) static int MAX_OID_LEN
           
(package private) static int MAX_SUBID
           
 
Constructor Summary
ASNTypes()
           
 
Method Summary
(package private) static int byteToInt(byte b)
          Since JAVA does not support unsigned types, we need a converter from unsigned byte to int that preserves the last 8 bits.
(package private) static int encodeInt(byte[] buff, int space, int value, int id)
          Encodes a signed 32-bit integer with the specified id (tag).
(package private) static int encodeInt(byte[] buff, int space, long value, int id)
          Encodes a signed 64-bit integer with the specified id (tag).
(package private) static int encodeNull(byte[] buff, int space, int id)
          Encodes a null value with the specified id (tag).
(package private) static int encodeOctets(byte[] buff, int space, byte[] octets, int offset, int count, int id)
          Encodes an octet string with the specified id (tag).
(package private) static int encodeOid(byte[] buff, int space, int[] oid, int count, int id)
          Encodes an object identifier with the specified id (tag).
(package private) static int encodeSequence(byte[] buff, int space, int length, int id)
          Encodes a Sequence or Sequence of with the specified id (tag).
(package private) static int encodeString(byte[] buff, int space, java.lang.String string, int offset, int count, int id)
          Encodes n Java string with the specified id (tag).
(package private) static int encodeUInt(byte[] buff, int space, int value, int id)
          Encodes an unsigned 32-bit integer with the specified id (tag).
(package private) static int encodeUInt(byte[] buff, int space, long[] val, int id)
          Encodes an unsigned 64-bit integer with the specified id (tag).
(package private) static byte[] encodeVariable(SnmpVar var)
          This is a convenience routine used to get the encoding for an SnmpVar object.
(package private) static boolean IS_CONSTRUCTOR(byte b)
           
(package private) static boolean IS_EXTENSION_ID(byte b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_SUBID

static int MAX_SUBID

MAX_OID_LEN

static int MAX_OID_LEN

ASN_BOOLEAN

static final byte ASN_BOOLEAN
See Also:
Constant Field Values

ASN_INTEGER

static final byte ASN_INTEGER
See Also:
Constant Field Values

ASN_BIT_STR

static final byte ASN_BIT_STR
See Also:
Constant Field Values

ASN_OCTET_STR

static final byte ASN_OCTET_STR
See Also:
Constant Field Values

ASN_NULL

static final byte ASN_NULL
See Also:
Constant Field Values

ASN_OBJECT_ID

static final byte ASN_OBJECT_ID
See Also:
Constant Field Values

ASN_SEQUENCE

static final byte ASN_SEQUENCE
See Also:
Constant Field Values

ASN_SET

static final byte ASN_SET
See Also:
Constant Field Values

ASN_UNIVERSAL

static final byte ASN_UNIVERSAL
See Also:
Constant Field Values

ASN_APPLICATION

static final byte ASN_APPLICATION
See Also:
Constant Field Values

ASN_CONTEXT

static final byte ASN_CONTEXT
See Also:
Constant Field Values

ASN_PRIVATE

static final byte ASN_PRIVATE
See Also:
Constant Field Values

ASN_EXCEPTION

static final int ASN_EXCEPTION
See Also:
Constant Field Values

ASN_PRIMITIVE

static final byte ASN_PRIMITIVE
See Also:
Constant Field Values

ASN_CONSTRUCTOR

static final byte ASN_CONSTRUCTOR
See Also:
Constant Field Values

ASN_LONG_LEN

static final byte ASN_LONG_LEN
See Also:
Constant Field Values

ASN_EXTENSION_ID

static final byte ASN_EXTENSION_ID
See Also:
Constant Field Values

ASN_BIT8

static final byte ASN_BIT8
See Also:
Constant Field Values
Constructor Detail

ASNTypes

ASNTypes()
Method Detail

byteToInt

static int byteToInt(byte b)
Since JAVA does not support unsigned types, we need a converter from unsigned byte to int that preserves the last 8 bits.

Parameters:
b - the byte to convert
Returns:
the integer value of the byte

IS_CONSTRUCTOR

static boolean IS_CONSTRUCTOR(byte b)

IS_EXTENSION_ID

static boolean IS_EXTENSION_ID(byte b)

encodeInt

static int encodeInt(byte[] buff,
                     int space,
                     int value,
                     int id)
              throws java.lang.ArrayIndexOutOfBoundsException
Encodes a signed 32-bit integer with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
value - The integer value to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeInt

static int encodeInt(byte[] buff,
                     int space,
                     long value,
                     int id)
              throws java.lang.ArrayIndexOutOfBoundsException
Encodes a signed 64-bit integer with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
value - The integer value to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeUInt

static int encodeUInt(byte[] buff,
                      int space,
                      int value,
                      int id)
               throws java.lang.ArrayIndexOutOfBoundsException
Encodes an unsigned 32-bit integer with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
value - The unsigned integer value to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeUInt

static int encodeUInt(byte[] buff,
                      int space,
                      long[] val,
                      int id)
               throws java.lang.ArrayIndexOutOfBoundsException
Encodes an unsigned 64-bit integer with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
value - The unsigned integer value to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeOctets

static int encodeOctets(byte[] buff,
                        int space,
                        byte[] octets,
                        int offset,
                        int count,
                        int id)
                 throws java.lang.ArrayIndexOutOfBoundsException
Encodes an octet string with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
octets - The octet string to be encoded (may be null)
offset - The offset of the first byte of octets to be encoded
count - The number of bytes of octets to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeString

static int encodeString(byte[] buff,
                        int space,
                        java.lang.String string,
                        int offset,
                        int count,
                        int id)
                 throws java.lang.ArrayIndexOutOfBoundsException
Encodes n Java string with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
string - The Java string to be encoded (may be null)
offset - The offset of the first char of octets to be encoded
count - The number of chars of octets to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeOid

static int encodeOid(byte[] buff,
                     int space,
                     int[] oid,
                     int count,
                     int id)
              throws java.lang.ArrayIndexOutOfBoundsException
Encodes an object identifier with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
oid - The object identifier to be encoded
count - The number of elements of oid to be encoded
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeNull

static int encodeNull(byte[] buff,
                      int space,
                      int id)
               throws java.lang.ArrayIndexOutOfBoundsException
Encodes a null value with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeSequence

static int encodeSequence(byte[] buff,
                          int space,
                          int length,
                          int id)
                   throws java.lang.ArrayIndexOutOfBoundsException
Encodes a Sequence or Sequence of with the specified id (tag).

Parameters:
buff - The buffer into which the value is to be encoded
space - The number of free bytes in the buffer
length - The length of the sequence
id - The ASN.1 BER id (or tag)
Returns:
The number of free bytes in the buffer
Throws:
java.lang.ArrayIndexOutOfBoundsException - When there is insufficient space in buffer

encodeVariable

static byte[] encodeVariable(SnmpVar var)
This is a convenience routine used to get the encoding for an SnmpVar object. It just returns a byte array representing the encoding

Parameters:
var - The SnmpVar objet which needs to be encoded.
Returns:
the byte array corresponding to the encoding.