-1

I would like to use CONTAINING in asn1c (http://lionet.info/asn1c/blog/). I don't know how can i give values for the CONTAINING structures.

In my example i would like to give values in the Octasd SEQUENCE for version and tsapolicy. I thought i can do it like any other asn1 types.

Other types for example the INTGER you can use functions to give values. I can give the contentType value with asn_long2INTEGER function:

 EncapsulatedContentInfo_t *encapcontinfo;
 asn_long2INTEGER(&encapcontinfo->contentType, 32);

In code for example: EncapsulatedContentInfo->eContent.octasd.version But i don't "see" behind octasd.

Is there any way to reach an encapsulated structure?

Part of my asn1:

EncapsulatedContentInfo ::= SEQUENCE {
  contentType INTEGER,
  eContent [0] IMPLICIT SEQUENCE {
       octasd Octasd
  }
}

Octasd ::= OCTET STRING (CONTAINING SEQUENCE {
   version INTEGER,
   tsapolicy OBJECT IDENTIFIER
} )

Any advice appreciated.

1 Answers1

0

Lev Walkin's compiler doesn't appear to support code generation for CONTAINING clauses (at least not embedded ones). I'm not very familiar with it, though.

What you might consider doing if you really need to use the CONTAINING keyword is to separate the types, e.g.:

Octasd ::= OCTET STRING -- (CONTAINING OctasdSeq)

OctasdSeq ::= SEQEUENCE {
   version    INTEGER,
   tsapolicy  OBJECT IDENTIFIER
}

This might all you to treat Octasd as a simple octet string and pass its bytes (the value bytes, anyway) to the decoder for OctasdSeq. I'm guessing this could be a little harder if you were using PER instead of BER/CER/DER because of potential alignment concerns.

Ethan
  • 252
  • 2
  • 8