The ASN.1 compiler takes an ASN.1 module as input and generates a corresponding Erlang module which can encode and decode the data-types specified. Alternatively the compiler takes a specification module (se below) specifying all input modules and generates one module with encode/decode functions. There are also some generic functions which can be used in during development of applications which handles ASN.1 data (encoded as BER or PER).
By default in OTP 17, the representation of the BIT STRING
and OCTET STRING types as Erlang terms have changed. BIT
STRING values are now Erlang bitstrings and OCTET STRING values
are binaries. For details see
To revert to the old representation of the types, use the
In R16, the options have been simplified. The back-end is chosen
using one of the options
Another change in R16 is that the generated
Compiles the ASN.1 module
If
If one wishes to compile a set of Asn1 modules into one
Erlang file with encode/decode functions one has to list all
involved files in a configuration file. This configuration
file must have a double extension ".set.asn", (".asn" can
alternatively be ".asn1" or ".py"). The input files' names
must be listed, within quotation marks (""), one at each row
in the file. If the input files are
File1.asn File2.asn File3.asn
The output files will in this case get their names from the
configuration file. If the configuration file has the name
Sometimes in a system of ASN.1 modules there are different default tag modes, e.g. AUTOMATIC, IMPLICIT or EXPLICIT. The multi file compilation resolves the default tagging as if the modules were compiled separately.
Another unwanted effect that may occur in multi file compilation is name collisions. The compiler solves this problem in two ways: If the definitions are identical then the output module keeps only one definition with the original name. But if definitions only have same name and differs in the definition, then they will be renamed. The new names will be the definition name and the original module name concatenated.
If any name collision have occurred the compiler reports a "NOTICE: ..." message that tells if a definition was renamed, and the new name that must be used to encode/decode data.
The encoding rule to be used. The supported encoding rules
are BER (Basic Encoding Rules),
PER aligned (Packed Encoding Rules) and PER unaligned.
If the encoding rule option is omitted
The generated Erlang module always gets the same name as the ASN.1 module and as a consequence of this only one encoding rule per ASN.1 module can be used at runtime.
By this option the Distinguished Encoding Rules (DER) is chosen.
DER is regarded as a specialized variant of the BER encoding
rule, therefore the
The BIT STRING type will be decoded to the "compact notation". This option is not recommended for new code.
For details see
This option implies the
The BIT STRING type will be decoded to the legacy format, i.e. a list of zeroes and ones. This option is not recommended for new code.
For details see
This option implies the
Use the same Erlang types to represent BIT STRING and
OCTET STRING as in R16. For details see
This option is not recommended for new code.
Tells the compiler to generate functions for conversion between
names (as atoms) and numbers and vice versa for the EnumTypeName specified. There can be multiple occurrences of this option in order to specify several type names. The type names must be declared as ENUMERATIONS in the ASN.1 spec.
If the EnumTypeName does not exist in the ASN.1 spec the
compilation will stop with an error code.
The generated conversion functions are named
Do not compile (i.e do not produce object code) the generated
Adds
Specifies the directory
When one of the specialized decodes, exclusive or
selective decode, is wanted one has to give instructions in
a configuration file. The option
The instructions for exclusive decode must follow the
You can also find the instructions for selective decode
in the
A buffer that holds a message, being decoded may
also have some following bytes. Now it is possible to get
those following bytes returned together with the decoded
value. If an asn1 spec is compiled with this option a tuple
If this option is given, the generated
All macro names generated by the compiler are prefixed with
All record names generated by the compiler are prefixed with
Causes more verbose information from the compiler describing what it is doing.
Causes warnings to be treated as errors.
Any additional option that is applied will be passed to the final step when the generated .erl file is compiled.
The compiler generates the following files:
Encodes
Decodes
Returns an Erlang term which is an example of a valid Erlang
representation of a value of the ASN.1 type
Performs a test of encode and decode of types in
Schematically the following happens for each type in the module:
{ok, Value} = asn1ct:value(Module, Type),
{ok, Bytes} = asn1ct:encode(Module, Type, Value),
{ok, Value} = asn1ct:decode(Module, Type, Bytes).
The