NAME
asn1_oid
asn1_oid_decl
asn1_oid_put
asn1_oid_xput
asn1_oid_get
asn1_oid_copy
asn1_oid_free
asn1_oid_int
asn1_int_oid
SYNOPSIS
#include "asn1.h"
asn1_oid_decl(s,oid)
char * s;
asn1_oid oid;
char * asn1_oid_put(s,oid)
char * s;
asn1_oid oid;
char * asn1_oid_xput(s,oid,mode)
char * s;
asn1_oid oid;
int mode;
asn1_oid asn1_oid_get(s,er)
char * s;
int * er;
asn1_oid asn1_oid_copy(oid)
asn1_oid oid;
int asn1_oid_free(v,l)
asn1 v;
int l;
int asn1_oid_int(l,v,x)
int l;
unsigned long *x;
asn1 v;
asn1 asn1_int_oid(v,x,l)
int l;
unsigned long *x;
asn1 v;
DESCRIPTION
The abstract
syntax of an object identifier is a sequence of integers, each of which
identifying a branch in the object identification tree, e.g.:
-
joint-iso-ccitt ds(5) attributeType(4)
Is represented by the sequence of arcs
But, in fact, that syntax
is only used when the element is built, in order to guarantee its unicity.
ASN.1 specifies that it should be transmitted as an octet string, encoding
the value of the successive integers in a compact form, e.g.:
The object identifiers are handled by MAVROS as short octet strings. An
object
oid
of type
asn1_oid
will contain a pointer to an octet area,
oid.v,
and the length of that octet string,
oid.l.
The octet string
contains in fact the compact form used by ASN.1, which is easy to use for
comparisons and sort operations.
A set of routine is provided for handling the conversion between this
representation and the textual format:
-
asn1_oid_decl
declares in the oid table the oid value
oid
as being equivalent
to the textual representation
s.
-
asn1_oid_xput
prints the object id
oid
in the buffer
buffer.
returns the
pointer to
buffer.
Depending on the
mode
flag, the transformation follows one of three modes:
- "mode = 0:"
the object id is printed in the shortest possible
form compatible with the declarations, e.g.
.
- "mode = 1:"
the object id is printed in a context independant numeric form, e.g.
.
- "mode = 2:"
the object id is printed in a context independant numeric form, completed
with comments derived from the declarations, e.g.
.
-
asn1_oid_put
is equivalent to
asn1_oid_xput
with
mode
set to 0.
-
asn1_oid_get
Transforms the string
s
into an object id. The value of the object
id will point to a static buffer, and will be overwrited by the next
call. The routine
asn1_oid_copy
can be used to create allocate the
necessary memory, and the macro
asn1_oid_create
do to so in a
single pass.. In case of error, the length and value components of
oid
are set to zero, and the return argument
er
contains the
number of the error; it can be explained by the function
asn1_ermes.
-
asn1_oid_copy
produces an independant copy of an object identifier. This copy can be freed
by calling
asn1_oid_free
with the parameters
oid.v
and
oid.l.
The following routines convert the internal
representation from a compact octet string to a table of integers
and vice versa:
-
asn1_oid_int
converts an identifer value of expressed on
l
bytes starting at address
v
into a table of unsigned long integers
x.
Returns the length of
the table
x.
-
asn1_int_oid
converts an object identifier value
described as a table
x
of
l
unsigned long integers
into an octet string starting at location
v.
Returns the address of
the first byte following the encoding of the object identifier.
Neither of these routines performs memory allocation.
asn1_oid_int
will use at most
l
long integers;
asn1_int_oid
at most 5 times
l
bytes.
"SEE ALSO"
mavcod (9x),
mavros (9x),
mavros-output (9x),
asn1_time(9x),
asn1_malloc(9x)
C. Huitema,
"General Presentation of the MAVROS Compiler" ,INRIA, 1990