Question

I am desperately searching for an ASN.1 compiler that will successfully parse a predefined ASN.1 definition I got from a customer.

None of the products (free or commercial) so far was able to parse the definition, which is XER based and has some transient RXER dependency - when I specify the relevant ASN.1-definitions manually (taken from the RFCs), the compiler also emits parser errors.

The relevant code line is (simplified):

MYMSG ::= SEQUENCE
{
  msgID [ATTRIBUTE] [250] UTF8String OPTIONAL,
  msgType UTF8String
}

Every compiler complains about the [ATTRIBUTE] token, so I found this is part of the ASN.X specification defined in RFC 4912 and also depends on support for RXER in RFC 4910, see also X.680-1.

Problem is every compiler I tried does not seem to support these encoding schemas out of the box and fails to parse the definitions mentioned in the RFCs, e.g. for RXER and all definitions that use this encoding I get:

"RXER.asn", line 20 (AdditionalBasicDefinitions): A1139W: The default encoding reference 'RXER' for the module 'AdditionalBasicDefinitions' is unknown and all encoding instructions within the module identified by this encoding reference will be ignored.
RXER INSTRUCTIONS

(Note: all dependent modules like ASN.X include the instruction "RXER INSTRUCTIONS" immediately after the "DEFINITIONS"-tag, which is not understood by any compiler I tried).

I tried openasn1 (www.openasn1.org) - funny thing is that I have some old and partially functional Java mapping objects in the code I got that was generated by openasn1! - the online compiler at http://lionet.info/asn1c/asn1c.cgi and various commercial tools like Objective Systems ASN1C v6.4.1 at http://www.obj-sys.com/Cnge641Dwld/acv64kits.php (they even have a current Eclipse plugin), Marben http://www.marben-products.com/asn.1/tce_java.html and unigone http://www.unigone.com/en/products/Asn1Compiler/description

I always get an error similar to this:

ASN.1 grammar parse error near line 13 (token "ATTRIBUTE"): parse error, unexpected TOK_capitalreference, expecting TOK_number

Am I missing something obvious like IMPORTs or other definitions/compiler flags?

Was it helpful?

Solution

I managed to compile the schema and generate the needed Java mapping classes. I had to use the commercial OSS Nokalva compiler, as all free tools I tried failed on (E)XER encoded schemata. There were also some errors in the schema I received, so here is what I had to do:

  1. first I added the XER-instructions in the DEFINITIONS-line along with the usual Tags directive:

    DEFINITIONS XER INSTRUCTIONS AUTOMATIC TAGS ::=

  2. in the footer, I added the XER encoding directive:

    ENCODING-CONTROL XER GLOBAL-DEFAULTS MODIFIED-ENCODINGS

  3. when using XER encoding, you have to explicitly specify tags to avoid ambiguities in syntax:

    [ATTRIBUTE] [TAG: 0] instead of the ambiguous definition [ATTRIBUTE] [0]

All these problems were resolved by consulting this nice writeup on EXER-encoding, definitely a good read and thanks to Nokalva for this helpful documentation!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top