Commit 9d87fa20 authored by Eugene Seliverstov's avatar Eugene Seliverstov

Adopted and repackaged. Version 0.9.21.dfsg1-1

parent be6c82fc
Lev Walkin <vlm@lionet.info>
0. ASN.1 grammar parser is written mostly with respect to constructing a tree,
so a tree destruction is not fully supported and certain memory leaks are
known. Not a huge problem for run-once programs like a compiler.
NOTE: This statement does not apply to the target code _produced_
by the compiler.
1. For purposes of compilation, INTEGER type is modelled using a large
static type (asn_integer_t), but defined as any positive or negative value
by ASN.1. Not a problem as most specifications use very small values anyway.
NOTE: This statement does not apply to the target code _produced_
by the compiler.
2. A MACRO facility is part of obsolete ASN.1 standard, and is not supported.
3. Multiple tags applied at the same level are not supported:
BadTags ::= [0] EXPLICIT [2] IMPLICIT OtherType
The same thing could be achieved by using the indirection:
GoodTags ::= [0] EXPLICIT OtherTypePtr
OtherTypePtr ::= [2] IMPLICIT OtherType
4. Mixed definite/indefinite length in a _single_ BER tags sequence is not
supported. Should not be a problem in the real world. Please note that it
is still possible, for example, to encode a wrapper structure using definite
length, and encode its substructure member using indefinite length. The BER
decoder is perfectly capable of decoding such sequences.
5. Encoding or decoding of structures with combined length greater than 16MB
is not tested.
6. XER codec does not support integer (INTEGER, ENUMERATED) values
outside the signed long range.
/*-
* Copyright (c) 2003, 2004, 2005, 2006 Lev Walkin <vlm@lionet.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: COPYING,v 1.3 2006/03/18 07:23:52 vlm Exp $
*/
This diff is collapsed.
1.Q: Is it possible to build the asn1c compiler on Win32?
1.A:
At this point, the asn1c source code is tied to GCC-specific
extensions in several key places. The CYGWIN environment with
gcc compiler may be what are you looking for.
Please also consider using the Online ASN.1 compiler at
http://lionet.info/asn1c
which generates platform-independent code.
2.Q: How to build a simplest BER (XER) encoder or decoder?
2.A:
Please check the "Quick Start Guide" on ./doc/asn1c-quick.pdf
Please check the "Examples" section of ./doc/asn1c-usage.pdf
Also, try the following to build the X.509v3 parser:
cd ./samples/sample.source.PKIX1
make
./x509dump -h
3.Q: Your compiler supplies a der_encode() procedure. How do I encode BER?
3.A:
The DER (and CER) are stricter subsets of a more generic BER encoding
method. If you encode data with DER or CER, all BER-conformant decoders
will easily understand that. Hence, to encode data in the BER format,
simply use the DER encoder, der_encode().
See also: ISO/IEC 8825-1 / X.690:
"ASN.1 encoding rules: Specification of
Basic Encoding Rules (BER),
Canonical Encoding Rules (CER) and
Distinguished Encoding Rules (DER)"
--
Lev Walkin
vlm@lionet.info
QUICK START INSTALLATION
========================
./configure # Configure the build infrastructure for your platform
make # Build the libraries and the compiler
make check # Ensure that the code is still behaving well
# after compiling on your platform
# PLEASE CONTACT ME IF THIS FAILS ON YOUR PLATFORM!
make install # Install the compiler into standard location
man asn1c # Display the asn1c manual page
QUICK USAGE GUIDE
=================
For usage guide and more information please refer to the README file.
In case of any difficulties with installing the compiler, consider using
the Online ASN.1 Compiler at
http://lionet.info/asn1c
--
Lev Walkin
vlm@lionet.info
libasn1compiler
libasn1parser
libasn1print
libasn1fix
skeletons
samples
tests
asn1c
doc
SUBDIRS = \
libasn1parser libasn1fix \
libasn1print libasn1compiler \
skeletons samples tests \
doc asn1c
docsdir = $(datadir)/doc/asn1c
docs_DATA = README FAQ COPYING ChangeLog BUGS TODO
EXTRA_DIST = asn1c.spec.in FAQ BUGS MANIFEST
CLEANFILES = asn1c.spec
This diff is collapsed.
WHAT TO READ?
=============
If you haven't installed the asn1c yet, read the INSTALL file for
a short installation guide.
For the list of asn1c command line options, see `asn1c -h` or `man asn1c`.
For more complete documentation on this compiler and on using the
results of compilation phase, please look into asn1c-quick.pdf and
asn1c-usage.{pdf,html}.
If you are building the compiler from the sources, these documents reside
in the ./doc directory, otherwise they lie nearby the README file you're
reading right now.
Please also read the FAQ file.
An excellent book on ASN.1 is written by Olivier Dubuisson:
"ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0.
QUICK START (also check out asn1c-quick.pdf)
============================================
After building [and installing] the compiler (see INSTALL), you may use
the asn1c command to compile the ASN.1 specification:
asn1c <module.asn1> # Compile module
If several specifications contain interdependencies, all of them must be
specified:
asn1c <module1.asn1> <module2.asn1> ... # Compile interdependent modules
If you are building the asn1c from the sources, the ./samples directory
contains several ASN.1 modules and a script to extract the ASN.1 modules
from RFC documents. Refer to the README file in that directory.
To compile the X.509 PKI module:
./asn1c/asn1c -P ./samples/rfc3280-*.asn1 # Compile-n-print
In this example, -P option is used to instruct the compiler to print the
compiled text on the standard output instead of creating multiple .c
and .h files for every ASN.1 type found inside the specified ASN.1 modules.
This is useful for debugging and test automation.
The compiler -E and -EF options are used for testing the parser and
the semantic fixer, respectively. These options will instruct the compiler
to dump out the parsed (and fixed) ASN.1 specification as it was
"understood" by the compiler. It might be useful for checking
whether a particular syntactic construction is properly supported
by the compiler.
asn1c -EF <module-to-test.asn1> # Check semantic validity
MODEL OF OPERATION
==================
The asn1c compiler works by processing the ASN.1 module specification
in several stages:
1. In the first stage, the ASN.1 file is parsed.
(Parsing produces an ASN.1 syntax tree for the subsequent levels)
2. In the second stage, the syntax tree is "fixed".
(Fixing is a process of checking the tree for semantic errors,
accompanied by the tree transformation into the canonical form)
3. In the third stage, the syntax tree is compiled into the target language.
There are several command-line options reserved for printing the results
after each stage of operation:
<parser> => print (-E)
<parser> => <fixer> => print (-E -F)
<parser> => <fixer> => <compiler> => print (-P)
<parser> => <fixer> => <compiler> => save-compiled [default]
--
Lev Walkin
vlm@lionet.info
1. MAJOR:
1.1 Support for PER encoding. PER decoding is already supported.
1.2 Support for Information Object Classes.
Status: Support for parsing IOCs is mostly present.
Support for slicing the IOCs to produce "views"
is not yet designed.
2. MEDIUM:
2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
Requires something from 1.2 (Information Object Classes).
This diff is collapsed.
#
# $Id: asn1c.spec.in,v 1.5 2006/09/19 01:07:24 vlm Exp $
#
Name: @PACKAGE@
Version: @VERSION@
Release: 2
Copyright: Lev Walkin <vlm@lionet.info>
Source: %{name}-%{version}.tar.gz
Url: http://asn1c.sourceforge.net/
BuildRoot: /var/tmp/%{name}-root
Group: Development/Languages
Summary: The ASN.1 to C compiler
%description
The asn1c compiler turns ASN.1 specifications into C language
source files containing the BER/CER/DER/PER/XER encoders and decoders
for the given abstract notation.
%prep
%setup -q
%build
./configure
%{_make} DESTDIR=$RPM_BUILD_ROOT
%install
rm -rf $RPM_BUILD_ROOT
%{__make} install-exec DESTDIR=$RPM_BUILD_ROOT
(cd skeletons && %{__make} install-data DESTDIR=$RPM_BUILD_ROOT)
(cd asn1c && %{__make} install-man DESTDIR=$RPM_BUILD_ROOT)
%clean
rm -rf $RPM_BUILD_ROOT
%files
%doc README FAQ COPYING ChangeLog BUGS TODO
%doc doc/asn1c-usage.pdf doc/asn1c-usage.html
%attr(755,root,root) %{_bindir}
%attr(644,root,root) %{_datadir}/asn1c
%{_mandir}/man1
%changelog
* Sun Sep 18 2006 Lev Walkin <vlm@lionet.info>
- Mentioned PER support
* Sun Sep 26 2004 Lev Walkin <vlm@lionet.info>
- All manuals are now getting installed, including new ones: unber.1 and enber.1
* Tue Sep 18 2004 Lev Walkin <vlm@lionet.info>
- First version of asn1c.spec
SUBDIRS = . webcgi tests
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
-I${top_srcdir}/libasn1compiler \
-I${top_srcdir}/libasn1parser \
-I${top_srcdir}/libasn1print \
-I${top_srcdir}/libasn1fix \
-I${top_srcdir}/skeletons \
-DDATADIR=\"$(pkgdatadir)\"
asn1c_LDADD = \
$(top_builddir)/libasn1parser/libasn1parser.la \
$(top_builddir)/libasn1print/libasn1print.la \
$(top_builddir)/libasn1fix/libasn1fix.la \
$(top_builddir)/libasn1compiler/libasn1compiler.la
bin_PROGRAMS = asn1c unber enber
noinst_HEADERS = sys-common.h
dist_man1_MANS = asn1c.1 unber.1 enber.1
check_SCRIPTS = check-xxber.sh check-parsing.sh
TESTS = $(check_SCRIPTS)
EXTRA_DIST = $(check_SCRIPTS)
CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp
This diff is collapsed.
asn1c - The ASN.1 Compiler
unber - The ASN.1 BER Decoder
enber - Reverse unber(1) output back into BER
.TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler"
.SH NAME
asn1c \- ASN.1 Compiler
.SH SYNOPSIS
asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR]
[\fB\-S\fR\fIdir\fR] [\fB-X\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR] [\fB\-gen-\fR\fIoption\fR] [\fB\-pdu=\fR\fIoption\fR]
[\fB\-print-\fR\fIoption\fR]
\fIinfile\fR...
.SH DESCRIPTION
asn1c compiles ASN.1 specifications into a set of
target language (C/C++) encoders and decoders for BER, DER, XER
and other encoding standards.
.SH OPTIONS
.TP
\fIOverall Options\fR
\fB\-E \-F \-P \-R\fR
.BI "\-S " directory
\fB\-X
.TP
\fIWarning Options\fR
.br
\fB\-Werror \-Wdebug-lexer \-Wdebug-fixer \-Wdebug-compiler\fR
.TP
\fILanguage Options\fR
.br
\fB\-fbless-SIZE \-fcompound-names \-findirect-choice
.BI "\-fknown-extern-type="<name>
\fB\-fnative-types \-fno-constraints \-fno-include-deps \-funnamed-unions \-fskeletons-copy
.TP
\fICodecs Generation Options\fR
.br
.B \-gen-PER \-pdu=auto
.TP
\fIOutput Options\fR
.br
.B \-print-constraints \-print-lines
.SH OVERALL OPTIONS
.TP
.B \-E
Stop after the parsing stage and print the reconstructed ASN.1
specification code to the standard output.
.TP
.B \-F
Used together with \c
.B \-E\c
, instructs the compiler to stop after the ASN.1 syntax
tree fixing stage and dump the reconstructed ASN.1 specification
to the standard output.
.TP
.B \-P
Dump the compiled output to the standard output instead of creating the
target language files on disk.
.TP
.B \-R
Restrict the compiler to generate only the ASN.1 tables,
omitting the usual support code.
.TP
\fB\-S\fR \fIdirectory\fR
Use the specified directory with ASN.1 skeleton files.
.TP
.B \-X
Generate an XML DTD schema for the specified ASN.1 files.
.SH WARNING OPTIONS
.TP
.B \-Werror
Treat warnings as errors; abort if any warning is produced.
.TP
.B \-Wdebug-lexer
Enable lexer debugging during the ASN.1 parsing stage.
.TP
.B \-Wdebug-fixer
Enable ASN.1 syntax tree fixer debugging during the fixing stage.
.TP
.B \-Wdebug-compiler
Enable debugging during the actual compile time.
.SH LANGUAGE OPTIONS
.TP
.B \-fbless-SIZE
Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which this
constraint is normally prohibited by the standard. This is a violation of
ASN.1 standard, and the compiler may fail to produce a meaningful code.
.TP
.B \-fcompound-names
Using this option prevents name collisions in the target source code
by using complex names for target language structures. (Name collisions
may occur if the ASN.1 module reuses the same identifiers in multiple
contexts).
.TP
.B \-findirect-choice
When generating code for a CHOICE type, compile the CHOICE members as indirect
pointers instead of declaring them inline. Consider using this option
together with
.B \-fno-include-deps
to prevent circular references.
.TP
.BI "\-fknown-extern-type="<name>
Pretend the specified type is known. The compiler will assume the target
language source files for the given type have been provided manually.
.TP
.B \-fnative-types
Use the native machine's data types (int, double) whenever possible,
instead of the compound INTEGER_t, ENUMERATED_t and REAL_t types.
.TP
.B \-fno-constraints
Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable.
.TP
.B \-fno-include-deps
Do not generate courtesy #include lines for non-critical type dependencies.
Helps prevent namespace collisions.
.TP
.B \-funnamed-unions
Enable unnamed unions in the definitions of target language's structures.
.TP
.B \-fskeletons-copy
Copy support files (skeletons) rather than symlink them.