Skip to main content

Module length

Module length 

Source
Expand description

The EN 50221 length_field — the ASN.1-style length used by every PDU at the Transport, Session and Application layers — ETSI EN 50221 §7, Table 1 (PDF p. 11).

Coding:

  • the first (MSB) bit is the size_indicator;
  • size_indicator == 0: the data-field length is the remaining 7 bits — any length 0..=127 fits in one byte;
  • size_indicator == 1: the remaining 7 bits (length_field_size) code how many subsequent bytes carry the length, MSB-first. The spec caps any length at 65535, i.e. at most three length bytes.

The indefinite-length ASN.1 form is NOT used.

Constants§

SIZE_INDICATOR_MASK
The size_indicator bit (the MSB of the first length_field byte): set when the field is the multi-byte form.

Functions§

decode
Decode a length_field from the front of bytes.
encode_into
Encode value as a length_field into buf, returning the bytes written.
encoded_len
Number of bytes encode_into will write for value.