OpenNMS API 1.2.3

org.opennms.protocols.snmp.asn1
Interface AsnEncoder

All Known Implementing Classes:
BerEncoder

public interface AsnEncoder

The AsnEncoder interface defines the contract that objects for encoding/decoding ASN.1 SNMP values must fulfill. The encoder must be able to encode and decode integers (unsigned and signed), object identifier, strings, and null values. To support the SNMPv2 the AsnEncoder class must also support encoding/decoding 64-bit integers. Currently the AsnEncoder interface only supports SNMPv1 types.

Version:
1.1.1.1
Author:
OpenNMS ,
Method Summary
 int buildHeader(byte[] buf, int startOffset, byte asnType, int asnLength)
          The buildHeader() method is used to encode an ASN.1 header into the specified byte buffer.
 int buildInteger32(byte[] buf, int startOffset, byte asnType, int asnInt32)
          The buildInteger32() method is used to encode an ASN.1 32-bit signed integer into the specified byte buffer.
 int buildLength(byte[] buf, int startOffset, int asnLength)
          The buildLength() method is used to encode an ASN.1 length into the specified byte buffer.
 int buildNull(byte[] buf, int startOffset, byte asnType)
          The buildNull() method is used to encode an ASN.1 NULL value into the specified byte buffer.
 int buildObjectId(byte[] buf, int startOffset, byte asnType, int[] oids)
          The buildObjectId() method is used to encode an ASN.1 object id value into the specified byte buffer.
 int buildString(byte[] buf, int startOffset, byte asnType, byte[] opaque)
          The buildString() method is used to encode an ASN.1 string value into the specified byte buffer.
 int buildUInteger32(byte[] buf, int startOffset, byte asnType, long asnUInt32)
          The buildUInteger32() method is used to encode an ASN.1 32-bit unsigned integer into the specified byte buffer.
 int buildUInteger64(byte[] buf, int startOffset, byte asnType, java.math.BigInteger asnUInt64)
          The buildUInteger64() method is used to encode an ASN.1 64-bit unsigned integer into the specified byte buffer.
 java.lang.Object[] parseHeader(byte[] buf, int startOffset)
          The parseHeader() method is used to decode an ASN.1 header from the specified buffer.
 java.lang.Object[] parseInteger32(byte[] buf, int startOffset)
          The parseInteger32() method is used to decode an ASN.1 32-bit signed integer from the specified buffer.
 java.lang.Object[] parseLength(byte[] buf, int startOffset)
          The parseLength() method is used to decode an ASN.1 length from the specified buffer.
 java.lang.Object[] parseNull(byte[] buf, int startOffset)
          The parseNull() method is used to decode an ASN.1 Null value from the specified buffer.
 java.lang.Object[] parseObjectId(byte[] buf, int startOffset)
          The parseObjectId() method is used to decode an ASN.1 Object Identifer from the specified buffer.
 java.lang.Object[] parseString(byte[] buf, int startOffset)
          The parseString() method is used to decode an ASN.1 opaque string from the specified buffer.
 java.lang.Object[] parseUInteger32(byte[] buf, int startOffset)
          The parseUInteger32() method is used to decode an ASN.1 32-bit unsigned integer from the specified buffer.
 java.lang.Object[] parseUInteger64(byte[] buf, int startOffset)
          The parseUInteger64() method is used to decode an ASN.1 64-bit unsigned integer from the specified buffer.
 

Method Detail

buildLength

public int buildLength(byte[] buf,
                       int startOffset,
                       int asnLength)
                throws AsnEncodingException
The buildLength() method is used to encode an ASN.1 length into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnLength - The length to be encoded.
Returns:
Returns the new offset for the next encoding routine. If the startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseLength

public java.lang.Object[] parseLength(byte[] buf,
                                      int startOffset)
                               throws AsnDecodingException
The parseLength() method is used to decode an ASN.1 length from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset and the decoded length. The first object is an Integer object and contains the new offset for the next object in buf. The second object is an Integer and contains the actual decoded length.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildHeader

public int buildHeader(byte[] buf,
                       int startOffset,
                       byte asnType,
                       int asnLength)
                throws AsnEncodingException
The buildHeader() method is used to encode an ASN.1 header into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
asnLength - The length to be encoded.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseHeader

public java.lang.Object[] parseHeader(byte[] buf,
                                      int startOffset)
                               throws AsnDecodingException
The parseHeader() method is used to decode an ASN.1 header from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset, ASN.1 type, and decoded length. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is an Integer and contains the actual decoded length.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildInteger32

public int buildInteger32(byte[] buf,
                          int startOffset,
                          byte asnType,
                          int asnInt32)
                   throws AsnEncodingException
The buildInteger32() method is used to encode an ASN.1 32-bit signed integer into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
asnInt32 - The 32-bit signed integer to encode.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseInteger32

public java.lang.Object[] parseInteger32(byte[] buf,
                                         int startOffset)
                                  throws AsnDecodingException
The parseInteger32() method is used to decode an ASN.1 32-bit signed integer from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset, ASN.1 type, and value. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is an Integer and contains the actual decoded value.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildUInteger32

public int buildUInteger32(byte[] buf,
                           int startOffset,
                           byte asnType,
                           long asnUInt32)
                    throws AsnEncodingException
The buildUInteger32() method is used to encode an ASN.1 32-bit unsigned integer into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
asnUInt32 - The 32-bit unsigned integer to encode.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseUInteger32

public java.lang.Object[] parseUInteger32(byte[] buf,
                                          int startOffset)
                                   throws AsnDecodingException
The parseUInteger32() method is used to decode an ASN.1 32-bit unsigned integer from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset, ASN.1 type, and value. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is a Long object and contains the actual decoded value.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildUInteger64

public int buildUInteger64(byte[] buf,
                           int startOffset,
                           byte asnType,
                           java.math.BigInteger asnUInt64)
                    throws AsnEncodingException
The buildUInteger64() method is used to encode an ASN.1 64-bit unsigned integer into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
asnUInt64 - The 64-bit unsigned integer to encode.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseUInteger64

public java.lang.Object[] parseUInteger64(byte[] buf,
                                          int startOffset)
                                   throws AsnDecodingException
The parseUInteger64() method is used to decode an ASN.1 64-bit unsigned integer from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset, ASN.1 type, and value. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is a BigInteger object and contains the actual decoded value.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildNull

public int buildNull(byte[] buf,
                     int startOffset,
                     byte asnType)
              throws AsnEncodingException
The buildNull() method is used to encode an ASN.1 NULL value into the specified byte buffer. The encoding used is dependant on the implementor of the interface.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseNull

public java.lang.Object[] parseNull(byte[] buf,
                                    int startOffset)
                             throws AsnDecodingException
The parseNull() method is used to decode an ASN.1 Null value from the specified buffer. The encoding used is depandant on the implemetor of the interface. Since there is no "null" value only the new offset and ASN.1 type are returned.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset and the ASN.1 type. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildString

public int buildString(byte[] buf,
                       int startOffset,
                       byte asnType,
                       byte[] opaque)
                throws AsnEncodingException
The buildString() method is used to encode an ASN.1 string value into the specified byte buffer.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
opaque - An array of bytes to encode into the string.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseString

public java.lang.Object[] parseString(byte[] buf,
                                      int startOffset)
                               throws AsnDecodingException
The parseString() method is used to decode an ASN.1 opaque string from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset and ASN.1 type, and byte array. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is an array of primitive bytes.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

buildObjectId

public int buildObjectId(byte[] buf,
                         int startOffset,
                         byte asnType,
                         int[] oids)
                  throws AsnEncodingException
The buildObjectId() method is used to encode an ASN.1 object id value into the specified byte buffer.

Parameters:
buf - The output buffer of encoded bytes.
startOffset - The offset from the start of the buffer where the method should start writing the encoded data.
asnType - The ASN.1 type to place in the buffer
oids - An array of integers to encode.
Returns:
Returns the new offset for the next encoding routine. If startOffset is subtracted from the return value then the length of the encoded data can be determined.
Throws:
AsnEncodingException - Thrown if an error occurs encoding the datatype.

parseObjectId

public java.lang.Object[] parseObjectId(byte[] buf,
                                        int startOffset)
                                 throws AsnDecodingException
The parseObjectId() method is used to decode an ASN.1 Object Identifer from the specified buffer. The encoding used is depandant on the implemetor of the interface.

Parameters:
buf - The input buffer
startOffset - The offset to start decoding in the buffer
Returns:
Returns an Object array that contains the new offset and ASN.1 type, and ObjectId array. The first object is an Integer object and contains the new offset for the next object in buf. The second object is a Byte object that represents the decoded ASN.1 Type. The third object is an array of primitive integers.
Throws:
AsnDecodingException - Thrown if an error occurs decoding the buffer.

OpenNMS API 1.2.3

Generated by eevans on May 29 2005 2015.