Objective Systems, Inc.  
Home
About ASN.1
Products
Free Software
Open Source
Documents
Services
Resources
Resellers
Customers
Careers
About Us
Contact Us
 

Google


Objective Systems, Inc.

Asn1PerEncodeBuffer Class Reference

Inheritance diagram for Asn1PerEncodeBuffer:

Asn1EncodeBuffer Asn1PerMessageBuffer Asn1MessageBuffer List of all members.

Detailed Description

This class handles the encoding of ASN.1 messages as specified in the Packed Encoding Rules (PER) ITU-T X.691 standard.


Public Member Functions

 Asn1PerEncodeBuffer (bool aligned, int sizeIncrement)
 Asn1PerEncodeBuffer (bool aligned)
override void BinDump (System.IO.StreamWriter outs, System.String varName)
virtual void ByteAlign ()
override void Copy (byte[] value)
override void Copy (byte value)
virtual void EncodeBit (bool value)
virtual void EncodeBit (bool value, System.String ident)
virtual void EncodeBits (byte[] value, int offset, int nbits)
virtual void EncodeBits (byte[] value, int offset, int nbits, System.String ident)
virtual void EncodeBits (byte value, int nbits)
virtual void EncodeCharString (System.String value, int nchars, int offset, int abpc, int ubpc, Asn1CharSet charSet)
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue)
virtual void EncodeConsWholeNumber (long adjustedValue, long rangeValue, System.String ident)
virtual void EncodeInt (long value, bool encodeLen, bool signExtend)
virtual void EncodeInt (long value, bool encodeLen, bool signExtend, System.String ident)
virtual void EncodeInt (long value, int nbits)
virtual void EncodeInt (long value, int nbits, System.String ident)
virtual void EncodeLength (long value, long lower, long upper)
virtual long EncodeLength (long value)
virtual void EncodeLengthEOM (long value)
virtual void EncodeOctetString (byte[] value, int offset, int nbytes)
virtual void EncodeOIDLengthAndValue (int[] value)
virtual void EncodeOpenType (Asn1PerEncodeBuffer buffer, System.String elemName)
virtual void EncodeOpenType (byte[] value, int offset, int nbytes)
virtual void EncodeRelOIDLengthAndValue (int[] value)
virtual void EncodeSmallNonNegWholeNumber (int value)
override System.IO.Stream GetInputStream ()
override void HexDump ()
virtual bool IsAligned ()
override void Reset ()
virtual void ReverseBytes (int offset, int nbytes)
virtual void SetAligned (bool value)
override System.String ToString ()
override void Write (System.IO.Stream outs)

Protected Member Functions

internal override void CheckSize (int bytesRequired)

Properties

virtual byte[] Buffer
virtual System.IO.MemoryStream ByteArrayInputStream
virtual int ByteIndex
virtual int MsgBitCnt
virtual int MsgByteCnt
override byte[] MsgCopy
override int MsgLength
internal Asn1PerTraceHandler mTraceHandler
virtual Asn1PerTraceHandler TraceHandler


Constructor & Destructor Documentation

Asn1PerEncodeBuffer bool  aligned  ) 
 

This constructor creates a PER encode buffer object with the default size increment. Whenever the buffer becomes full, the buffer will be expanded by the sizeIncrement size.

Parameters:
aligned true for PER aligned or false for PER unaligned encoding.

Asn1PerEncodeBuffer bool  aligned,
int  sizeIncrement
 

This constructor creates a PER encode buffer object with the given size increment. Whenever the buffer becomes full, the buffer will be expanded by the sizeIncrement size. This size should be large enough to prevent resizing in normal operation.

Parameters:
aligned true for PER aligned or false for PER unaligned encoding.
sizeIncrement The initial size in bytes of an encode buffer. If the buffer becomes full, it will be expanded by the amount.


Member Function Documentation

override void BinDump System.IO.StreamWriter  outs,
System.String  varName
[virtual]
 

This method dumps the encoded message in a human-readable format showing a bit trace of all fields to the given print output stream.

Parameters:
outs StreamWriter object to which output should be written
varName Name of top-level message object variable

Implements Asn1EncodeBuffer.

virtual void ByteAlign  )  [virtual]
 

This methods byte-aligns the buffer.

Implements Asn1PerMessageBuffer.

internal override void CheckSize int  bytesRequired  )  [protected, virtual]
 

This method determines if the encode buffer can hold the requested number of bytes. If not, the buffer is expanded.

Parameters:
bytesRequired Number of required bytes.

Reimplemented from Asn1EncodeBuffer.

override void Copy byte[]  value  )  [virtual]
 

This method copies multiple bytes to the encode buffer

Parameters:
value Array of bytes to copy to the encode buffer

Implements Asn1EncodeBuffer.

override void Copy byte  value  )  [virtual]
 

This method is used to copy a single byte to the encode buffer.

Parameters:
value The byte value to copy

Implements Asn1EncodeBuffer.

virtual void EncodeBit bool  value  )  [virtual]
 

This method encodes a single bit value. The ident argument which is used for tracing is defaulted to 'value'.

Parameters:
value Boolean value of bit to be encoded.

virtual void EncodeBit bool  value,
System.String  ident
[virtual]
 

This method encodes a single bit value.

Parameters:
value Boolean value of bit to be encoded.
ident Bit field identifier name for tracing.

virtual void EncodeBits byte[]  value,
int  offset,
int  nbits
[virtual]
 

This method encodes bit values from an array of octets. The ident argument which is used for tracing is defaulted to 'value'.

Parameters:
value Octet array containing bits to be encoded
offset Starting byte offset in value
nbits Number of bits to encode

virtual void EncodeBits byte[]  value,
int  offset,
int  nbits,
System.String  ident
[virtual]
 

This method encodes bit values from an array of octets.

Parameters:
value Octet array containing bits to be encoded
offset Starting byte offset in value
nbits Number of bits to encode
ident Bit field identifier name for tracing.

virtual void EncodeBits byte  value,
int  nbits
[virtual]
 

This method encodes bit values from an octet. The most significant bits from the octet are encoded.

Parameters:
value Octet containing bits to be encoded
nbits Number of bits to encode

virtual void EncodeCharString System.String  value,
int  nchars,
int  offset,
int  abpc,
int  ubpc,
Asn1CharSet  charSet
[virtual]
 

This method encodes the contents of a known-multiplier character string type. This version assumes a permitted alphabet constraint was specified.

Parameters:
value String containing characters to encode
nchars Number of characters from string to encode
offset Offset to first char in string to encode
abpc Number of bits per character (aligned)
ubpc Number of bits per character (unaligned)
charSet Object representing permitted alphabet constraint character set (optional)

virtual void EncodeConsWholeNumber long  adjustedValue,
long  rangeValue
[virtual]
 

This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard. The ident argument which is used for tracing is defaulted to 'value'.

Parameters:
adjustedValue Adjusted value to be encoded = value - lower range endpoint value
rangeValue lower - upper + 1

virtual void EncodeConsWholeNumber long  adjustedValue,
long  rangeValue,
System.String  ident
[virtual]
 

This method implements the rules to encode a constrained whole number as specified in section 10.5 of the X.691 standard.

Parameters:
adjustedValue Adjusted value to be encoded = value - lower range endpoint value
rangeValue lower - upper + 1
ident Tracing identifier

virtual void EncodeInt long  value,
bool  encodeLen,
bool  signExtend
[virtual]
 

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard. The ident argument which is used for tracing is defaulted to 'value'.

Parameters:
value Integer value to be encoded
encodeLen Flag indicating length determinant should be encoded before encoding integer value.
signExtend Flag indicating if sign extension should be performed.

virtual void EncodeInt long  value,
bool  encodeLen,
bool  signExtend,
System.String  ident
[virtual]
 

This method implements the rules to encode either a non-negative binary integer as specified in section 10.3 or a two's complement binary integer as specified in section 10.4 of the X.691 standard.

Parameters:
value Integer value to be encoded
encodeLen Flag indicating length determinant should be encoded before encoding integer value.
signExtend Flag indicating if sign extension should be performed.
ident Tracing identifier

virtual void EncodeInt long  value,
int  nbits
[virtual]
 

This method encodes bit values from an integer value. The least significant bits from the integer are encoded. The ident argument which is used for tracing is defaulted to 'value'.

Parameters:
value Integer containing bits to be encoded
nbits Number of bits to encode

virtual void EncodeInt long  value,
int  nbits,
System.String  ident
[virtual]
 

This method encodes bit values from an integer value. The least significant bits from the integer are encoded.

Parameters:
value Integer containing bits to be encoded
nbits Number of bits to encode
ident Tracing identifier

virtual void EncodeLength long  value,
long  lower,
long  upper
[virtual]
 

This method encodes a constrained length determinant value.

Parameters:
value Length value to be encoded
lower Lower bound (inclusive) of length value range
upper Upper bound (inclusive) of length value range

virtual long EncodeLength long  value  )  [virtual]
 

This method encodes a general (unconstrained) length determinant value as described in section 10.9 or the X.691 standard.

Parameters:
value Length value to be encoded
Returns:
Value that was actually encoded. This may be less than the value that was passed in if fragementation was done (i.e the value was >= 16k).

virtual void EncodeLengthEOM long  value  )  [virtual]
 

This method checks to see if a zero byte needs to be added after a fragmented length has been encoded. It will add it to the byte stream if necessary.

Parameters:
value Original length value that was encoded.

virtual void EncodeOctetString byte[]  value,
int  offset,
int  nbytes
[virtual]
 

This method encodes the given array of bytes as an unconstrained octet string value.

Parameters:
value Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset Starting offset in byte array value
nbytes Number of bytes to encode

virtual void EncodeOIDLengthAndValue int[]  value  )  [virtual]
 

This method encodes the length and contents of an object identifier value.

Parameters:
value Integer array containing arcs to encode

virtual void EncodeOpenType Asn1PerEncodeBuffer  buffer,
System.String  elemName
[virtual]
 

This overloaded version of encodeOpenType will encode the componet in the given PER encode buffer into this PER encode buffer.

Parameters:
buffer PER encode buffer containing encoded message component.
elemName Name of element being encoded.

virtual void EncodeOpenType byte[]  value,
int  offset,
int  nbytes
[virtual]
 

This method encodes the given array of bytes as an open type.

Parameters:
value Byte array containing data to encode. This is assumed to contain a previously encoded PER component.
offset Starting offset in byte array value
nbytes Number of bytes to encode

virtual void EncodeRelOIDLengthAndValue int[]  value  )  [virtual]
 

This method encodes the length and contents of a relative object identifier value.

Parameters:
value Integer array containing arcs to encode

virtual void EncodeSmallNonNegWholeNumber int  value  )  [virtual]
 

This method implements the rules to encode a small non-negative whole number as specified in section 10.6 of the X.691 standard.

Parameters:
value Value to be encoded

override System.IO.Stream GetInputStream  ) 
 

This method returns an input stream representing the encoded message. This method is defined as abstract in the base class and must be implemented by all derived classes. In this case, a byte array input stream is returned.

Returns:
Input stream containing encoded message

Implements Asn1PerMessageBuffer.

override void HexDump  )  [virtual]
 

This method dumps the encoded message in hex/ascii format to the standard output stream.

Reimplemented from Asn1EncodeBuffer.

virtual bool IsAligned  )  [virtual]
 

This method is used to test if PER aligned encoding has been specified.

Returns:
true for PER aligned encoding or false for unaligned encoding.

Implements Asn1PerMessageBuffer.

override void Reset  )  [virtual]
 

This method resets the buffer object so that it can be reused to encode another PER message. Any previously encoded data is lost.

Implements Asn1EncodeBuffer.

virtual void ReverseBytes int  offset,
int  nbytes
[virtual]
 

This method reverses a series of bytes at a given offset within the encode buffer.

Parameters:
offset Starting byte offset within the buffer
nbytes Number of bytes to reverse

virtual void SetAligned bool  value  )  [virtual]
 

This method is used to turn PER aligned encoding on or off

Parameters:
value true for PER aligned encoding or false for unaligned encoding.

override System.String ToString  ) 
 

This method will return a string representation of the data in the encode buffer. The format is hex characters.

Returns:
Stringified representation of the value

override void Write System.IO.Stream  outs  )  [virtual]
 

This method writes the encoded record to the given output stream.

Parameters:
outs Output stream to which record is to be written

Implements Asn1EncodeBuffer.


Property Documentation

virtual byte [] Buffer [get]
 

Gets a reference to the byte buffer used to hold the encoded message.

Value: Byte buffer reference

virtual System.IO.MemoryStream ByteArrayInputStream [get]
 

Gets a reference to a byte array input stream representing the encoded message. This is the preferred way to access the contents of the encoded message as it is the most efficient.

Value: byte array input stream containing encoded message

virtual int ByteIndex [get]
 

Gets the current byte index into the encode buffer.

Value: Byte index value

virtual int MsgBitCnt [get]
 

Gets the number of bits in the encoded PER message.

Value: Count of bits in encoded message

Implements Asn1PerMessageBuffer.

virtual int MsgByteCnt [get]
 

Gets the number of bytes in the encoded PER message. The number is rounded up to include the last byte if one or more bits have been set in that byte.

Value: Count of bytes in encoded message

override byte [] MsgCopy [get]
 

Gets the encoded message in a byte array. This is less efficient than the ByteArrayInputStream property because the message contents must be copied to a newly created byte array.

Value: byte array containing encoded message

Reimplemented from Asn1EncodeBuffer.

override int MsgLength [get]
 

Gets the length (in bytes) of the encoded message component.

Value: length of encoded message component

Reimplemented from Asn1EncodeBuffer.

internal Asn1PerTraceHandler mTraceHandler [protected]
 

Variable holds the PER message trace handler

virtual Asn1PerTraceHandler TraceHandler [get]
 

Gets a reference to the internal trace handler object used to trace the bit fields within a PER message.

Value: Asn1PerTraceHandler object

Implements Asn1PerMessageBuffer.


Copyright © 1997-2005 Objective Systems,Inc.
All Rights Reserved.
This document may be distributed in any form, electronic
or otherwise, provided that it is distributed in its entirety
and that the copyright and this notice are included.

This file was last modified on 18 Nov 2005.
ASN1C C# Runtime Library, 5.8