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).
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.
The
By this option the Distinguished Encoding Rules (DER) is chosen.
DER is regarded as a specialized variant of the BER encoding
rule, therefore the
Makes it possible to use a compact notation for values of the BIT STRING type in Erlang. The notation:
BitString = {Unused, Binary}, Unused = integer(), Binary = binary()
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
This option is only valid together with one of the
As of R15B this means the same as the
Option valid together with
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
Compiling with this option gives one output module
containing all asn1 run-time functionality. The asn1 specs
are provided in a target module Module.set.asn as described
When used together with
It is also possible to use the sole argument
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