NAME
mavcod
SYNOPSIS
mavcod
[ asn1_file] [ \-srce asn1_file][ \-load asn1_files][ \-head header_file][ \-mvr mvr_file][ \-init C_file][ \-macros text_file][ \-static] [ \-compat] [ \-iapl_V1] [ \-iapl_transview] [ \-seqofsize number][ \-octetsize number][ \-nochars] [ \-noflags] [ \-keep] [ \-ser] [ \-windows] [ \-indent string ][ \-asn1 pretty_file][ \-umac asn1_file][ \-check] [ \-ll lisp_file]DESCRIPTION
MAVCOD is the first pass of the ASN.1 compiler, MAVROS. It takes as input
a file containing the description of an ASN.1 module, and produces:
-
A header file containing the C description of the data types necessary
to encode the structures defined in ASN.1,
-
An annotated ASN.1 file, suitable as an input to the MAVROS compiler,
-
A C module containing the initialization of the C variables corresponding
to the ASN.1 values declared in the module.
-
A text file capturing the relation between types and values specified in ASN.1
"MACROS".
Optionnally, MAVCOD can be used as an ASN.1
pretty printer,
or to remove "MACRO" definitions from an ASN.1 source.
OPTIONS
Several command line arguments enable the users to parametrize the actions
of MAVCOD. They fall in the following categories:
-
Specifying the name of the input file,
-
Specifying the file location of modules refered to by the input,
-
Specifying non default names for the output file,
-
Parametrizing the C mappings,
-
Requesting specific inputs.
The name of the input file can be either:
-
Specified as the first argument to MAVCOD, as in:
"mavcod Module.asn1"
-
or specified by using the
-srce
command line parameter, as in
"mavcod -srce Module.asn1"
Note that MAVCOD suppose that the input files:
-
Contain exactly one ASN.1 module definition,
-
Have a file name composed of the module name and the suffix ".asn1".
If these conditions are not verified, MAVCOD will signal an error.
ASN.1 is a modular language. A module may contain reference to types, values
and macros defined in other modules. In order to compile properly the input
module, MAVCOD must be able to read the specifications contained in the
"imported" modules. This can be achieved by using the
"-load asn1_files"option, as in:
-
"mavcod Module.asn1 -load Imported-1.asn1 other-dir/Imported-2.asn1"
If this option is specified, MAVCOD will load in memory the content of the
imported modules before loading the input file itself. If the input file
refers to a module that is not explicitely loaded, e.g. if the first lines of
the input file contain:
Module DEFINITIONS ::= BEGIN
IMPORTS
Type-1 FROM Imported-1
Type-2 FROM Imported-2
Type-3 FROM Imported-3;
and we have only loaded the first two imported modules, MAVCOD will build a
file name by appending the "asn1" suffix to the required module name, as e.g.
"Imported-3.asn1"
and try to find that file in the current working directory. It will signal an
error if the file cannot be found, and will then try to take default actions
for handling the imported types and values. In some cases, e.g. if the
imported type is used to produce a local value, the default actions cannot be
applied succesfully and an error will be reported.
Note that if a module imports a MACRO definition, which by definition alters
the regular ASN.1 syntax, the corresponding module must be explicitely loaded.
Failure to do so would result in various "syntax error" reports.
By default, the names of the output files are constructed from the name of the
module defined in the input file, e.g.
"Module."
The following options can be used to override
this default behaviour:
- "-head header_name"
Use the name
header_name
for the header file. By default, the name of the header file is constructed
by appending the string
_mvr.h
to the name of the module, e.g.
Module_mvr.h
- "-init c_file"
Use the name
c_file
for the C file that will contain the initialization of ASN.1 values.
By default, the name of the initialization file is
constructed by appending the string
_init.c
to the name of the module, e.g.
Module_init.c
- "-mvr mvr_name"
Use the name
mvr_name
for the mavros input. By default, then name of the MAVROS input file is
constructed by appending the string
.mvr
to the name of the module, e.g.
Module.mvr
- "-macros text_file"
Use the name
text_file
for the text file that will contain the "knowledge" extracted from the MACRO
instantiations present in the module. By default, the name of this file is
constructed by appending the string
.macros
to the name of the module, e.g.
Module.macros
The header file describes the mapping into C of the types defined in the ASN.1
input. This mapping is done according to simple rules, explained in the
general MAVROS documentation. This rules can be parametrized by the following
options:
- "-seqofsize number"
By default, MAVCOD maps each ASN.1 list declaration (using the SEQUENCE OF or
SET OF) construct to "length + pointer" C structure:
struct {
asn1_int32 n; /* number of elements */
* v; }
-
The pointer
v
will be allocated at decoding time to match the exact size required by the
received message. However, as memory allocation is often a painful process,
MAVCOD tries to replace this by a static declaration when the maximum size of
the list is specified by use of a SIZE constraint, as in "SET SIZE(0..32) OF
Foo", which would be mapped to:
struct {
asn1_int32 n; /* number of elements */
Foo v[32]; }
-
Some programmers have observed that this could result in very inefficient
memory allocations when the maximum size is a very large number. By using the
-seqofsize
option, one can request that dynamic allocation be applied to lists which have
a size greater than
number.
By specifying a value of 0, one can request that all list be dynamically
allocated.
- "-octetsize n"
This parameter plays for OCTETS STRING, BITS STRING and their subtypes, the
same role that
-seqofsize
plays for lists.
- "-static"
By default, MAVCOD uses dynamic memory allocation for optional components in
a SET or SEQUENCE and for large components in a CHOICE. By specifying this
parameter, one requests MAVCOD to use a static memory allocation whenever
possible. For components of a SET or SEQUENCE, this static declaration will be
complemented by the declaration of a boolean variable which will be set to
TRUE (i.e. to a non null value) when the component is present.
- "-noflags"
By default, MAVCOD represent BIT STRINGS wich have named elements, e.g.
ColorsInHand ::= BIT STRING {
Spade(0), Heart(1), Diamond(2), Club(3)}
-
by a 32 bits integer variable where each bit can represent one of the elements
of the string. By using the
-noflags
option, one can request that named
bits strings be represented exactly as standard bits strings, i.e. by a
length and a pointer field.
- nochars
By default, MAVCOD represent character strings of known size by using the "null
terminated string" convention of C. By using the
-nochars
option, one can request that these strings be represented exactly as
standard octets strings, i.e by a length and a pointer field.
- keep
This option is equivalent to the combination of
-noflags
and
-nochars.
- compat
This option instruct MAVCOD to use memory allocation procedures and octet
string representations compatible with that used in the original version. It
should be used when one wants to use the new version of the compiler and
retain compatibility with previously developed software.
- iapl_V1
This option instruct MAVCOD to use type generation algorithms compatible with
the initial release of this compiler. This is useful for developpers which have
been using MAVCOD for a long time, may need to update existing ASN.1 modules,
but don't want to update all their existing "C" interfaces.
- iapl_transview
This option is similar to te previous one. It is used for maintaining
compatibility with an intermediate release of the MAVCOD compiler.
- ser
Prepare the generation by MAVROS of code for the "special encoding rules"
defined by SNI.
- windows
Generate an header file and an initialisation file which will be suitable for
compiling under Microsoft's "Windows".
The following options can be requested to perform special editions, or to
parametrize the editions:
- "-asn1 asn1_file"
Produce a pretty printing of the input, and place it in the named file. When
this argument is used, MAVCOD will not generate the regular output files,
unless they be explicitely requested.
- "-umac asn1_file"
Remove all macro references from the input, and place a pretty printing of the
resulting specification in the named file.
- "-indent string"
Insert the string
string
instead of each tabulation mark in the various output files.
The option
-ll
can be used to generate a "LISP" description of the ASN.1 data types and
values.
The MAVCOD program also supports a
-check
option, that is used for test programs. It produces on the standard output a
concatenation of several pretty printings of the input at various stages of
the analysis, of the header file, of the MAVROS input file, of the
initialization file and of macro knowledge file.
"SEE ALSO"
mavros (9x),
C. Huitema,
"General Presentation of the MAVROS Compiler" ,INRIA, 1990
DIAGNOSTIC
The diagnostics produced by MAVCOD are intended to be self explanatory.
BUGS
The cross referencing of modules is hasardous: it supposes that exactly the
same "C parametrization", e.g. that
-static
or
-noflags
were used in the different modules. One should be able to look at
the definitions in the MAVROS inputs for these modules (*.mvr files), in
order to extract the correct typing of the attributes.
Please report the other bugs to the authors..