kellerkindt / asn1rs

Generates Rust Code and optionally compatible Protobuf schema files from ASN.1 definitions.
http://asn1.rs
Apache License 2.0
54 stars 19 forks source link

SIZE does not accept a Value Reference for the bounds #45

Open harmic opened 3 years ago

harmic commented 3 years ago

The asn1rs parser currently fails on this:

DRB-ToAddModList ::=                SEQUENCE (SIZE (1..maxDRB)) OF DRB-ToAddMod

with this error:

Failed to load file /home/itk/itk/src/libitk/src/3gppasn1/asn1/rrc.asn: Model(At line 263, column 47 an unexpected range value was encountered: "maxDRB"

Looking at the source I can see it is expecting an integer literal there, but the ASN1 source I am trying to parse has a 'Value Reference' (ie a name referencing a value assigned elsewhere in the file).

X.680 says this:

The ASN.1 value assignment notation enables a name to be given to a value of a specified type. This name can be used wherever a reference to that value is needed.

The name maxDRB is defined later in the ASN1 source file as:

maxDRB                      INTEGER ::= 11

It is not clear to me how 'Value References' can be implemented, because the definition of the reference apparently doesn't come before the usage of it in the source file.

kellerkindt commented 3 years ago

Yeah, 'Value References' / constants are not supported, yet. But I already plan to implement them soon-ish, because I'll need them myself as well.

kellerkindt commented 3 years ago

Out of curiosity, is the .asn file you tested publicly available? I just recently discovered forge.etis.org and 3gpp there does not seem to have any public repo?

harmic commented 3 years ago

For some reason, 3GPP don't seem to publish the ASN1 files as plain text files you can download, rather they include them embedded in the specifications (word docs). You need to download the word doc and copy/paste the ASN1 file.

The spec I was using was 36.331 (LTE RRC protocol). You can download this from the 3GPP site here. Go to the versions tab, choose a version, and click the version number to download a zip file containing a word doc.

I have not found anywhere to reliably download the raw ASN1 files.

The file I was using contains vendor extensions so unfortunately I am not at liberty to share it.