Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating code for CONTAINING keyword #53

Open
nikhil2209 opened this issue Aug 25, 2022 · 2 comments
Open

Generating code for CONTAINING keyword #53

nikhil2209 opened this issue Aug 25, 2022 · 2 comments

Comments

@nikhil2209
Copy link

Hello,

I'm using ESNACC for compiling multiple ASN source files to C code. For ease of understanding, I will explain the scenario here as succintly as possible:-

FileA.asn1 contains the following:-

FileA DEFINITIONS ::= 
BEGIN
  A ::= SEQUENCE       
  {  
        AContent   [0] OCTET STRING (CONTAINING FileB.B) 
  }                                                     
END

FileB.asn1 contains the following:-

FileB DEFINITIONS ::= 
BEGIN
  B ::= SEQUENCE       
  {  
        BElem1   [0]  INTEGER,
        BElem2   [1]  INTEGER
  }                                                     
END

I used ESNACC to compile both files in one command. Upon analysing the C source files generated, I observed that the AContent field will be decoded as a constructed OCTET STRING (the data being received in the application guarantees that the field will be specified as constructed). This means that FileB does not come into the picture at all. I was hoping that AContent would be further decoded with a structure of FileB being filled, so that I can easily access the elements within. This does not seem to be the case.

I'm fairly new with ASN1, so please let me know if my understanding is wrong in any way.

  1. Is ESNACC not capable of generating code for supporting CONTAINING keyword properly?
  2. Are there other compilers that are able to do this?
  3. Can this be done by using ESNACC in any way?
  4. If this cannot be done using ESNACC, and I don't want to use any other compiler, how would I access the contents within AContent at runtime easily?
@apconole
Copy link
Member

Sorry for the late response. I don't believe this syntax would be correct. I think you can achieve this, however.

Something like:

FileA DEFINITIONS ::= BEGIN

    IMPORT B from FileB;

    A ::= SEQUENCE {
        AContent [0] OCTET STRING (CONTAINING B)
    }

END

Then I think you'll get a proper definition. Otherwise, you can always treat the object bits as containing B anyway (but it is programmatically enforced rather than being compiler enforced, in that case).

@apconole
Copy link
Member

Can we close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants