ONC+ Developer's Guide

Variable-Length Opaque Data

Description

The standard also provides for variable-length (counted) opaque data, defined as a sequence of n (numbered 0 through n-1) arbitrary bytes to be the number n encoded as an unsigned integer (as described subsequently), and followed by the n bytes of the sequence.

Byte b of the sequence always precedes byte b+1 of the sequence, and byte 0 of the sequence always follows the sequence's length (count). The n bytes are followed by enough (0 to 3) residual zero bytes, r, to make the total byte count a multiple of four.

Declaration

Variable-length opaque data is declared in the following way:

opaque identifier<m>; 

or

opaque identifier<>;; 

The constant m denotes an upper bound of the number of bytes that the sequence may contain. If m is not specified, as in the second declaration, it is assumed to be (2**32) - 1, the maximum length. For example, a filing protocol may state that the maximum data transfer size is 8192 bytes, as follows:

opaque filedata<8192>;

Encoding

Variable-Length Opaque

Graphic

It is an error to encode a length greater than the maximum described in the specification.