From 9c426f0c0fe4a95d8c987e9201252be324566360 Mon Sep 17 00:00:00 2001 From: Vasil Velichkov Date: Wed, 15 Mar 2017 22:36:58 +0200 Subject: [PATCH] Add EXTERNAL support. gh-140 - Add EXTERNAL ASN.1 defintion from ITU-T X.208 in skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1 - Remove EXTERNAL from asn1p_l.l and asn1p_y.y - Add a test case: tests/135-EXTERNAL-OK.asn and asn1c/tests/check-src/check-135.c - Regeneragte all tests/*.asn1.-Pfwide-types files --- TODO | 2 +- asn1c/tests/Makefile.am | 1 + asn1c/tests/check-assembly.sh | 2 +- asn1c/tests/check-src/check-135.c | 135 +++++++++++ libasn1parser/asn1p_l.l | 1 - libasn1parser/asn1p_y.y | 2 - .../ASN1C-UsefulInformationObjectClasses.asn1 | 12 + tests/03-enum-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/104-param-1-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/105-param-2-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/106-param-constr-OK.asn1.-P | 201 ++++++++++++++++ .../108-param-constr-3-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/110-param-3-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/119-per-strings-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/125-bitstring-constraint-OK.asn1.-P | 201 ++++++++++++++++ tests/126-per-extensions-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/127-per-long-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/131-per-empty-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/134-per-long-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/135-EXTERNAL-OK.asn1 | 4 + tests/19-param-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/22-tags-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/30-set-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/31-set-of-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/32-sequence-of-OK.asn1.-P | 201 ++++++++++++++++ .../37-indirect-choice-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/39-sequence-of-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/42-real-life-OK.asn1.-PR | 201 ++++++++++++++++ tests/43-recursion-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/44-choice-in-sequence-OK.asn1.-P | 201 ++++++++++++++++ tests/46-redefine-OK.asn1.-PR | 201 ++++++++++++++++ tests/47-set-ext-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/50-constraint-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/50-constraint-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ .../59-choice-extended-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/60-any-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/65-multi-tag-OK.asn1.-Pfnative-types | 201 ++++++++++++++++ tests/65-multi-tag-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/66-ref-simple-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/69-reserved-words-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/70-xer-test-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/72-same-names-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/73-circular-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/84-param-tags-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/88-integer-enum-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ ...-bit-string-enum-OK.asn1.-Pfcompound-names | 201 ++++++++++++++++ .../89-bit-string-enum-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/90-cond-int-type-OK.asn1.-P | 201 ++++++++++++++++ tests/90-cond-int-type-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/90-cond-int-type-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ ...1-cond-int-blessSize-OK.asn1.-Pfbless-SIZE | 201 ++++++++++++++++ ...-circular-loops-OK.asn1.-Pfindirect-choice | 201 ++++++++++++++++ tests/92-circular-loops-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/93-asn1c-controls-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/94-set-optionals-OK.asn1.-P | 201 ++++++++++++++++ .../95-choice-per-order-OK.asn1.-Pfwide-types | 201 ++++++++++++++++ tests/95-choice-per-order-OK.asn1.-Pgen-PER | 215 ++++++++++++++++++ tests/98-attribute-class-OK.asn1.-P | 201 ++++++++++++++++ 58 files changed, 10316 insertions(+), 5 deletions(-) create mode 100644 asn1c/tests/check-src/check-135.c create mode 100644 tests/135-EXTERNAL-OK.asn1 diff --git a/TODO b/TODO index 58666cc63..ee6fb1d24 100644 --- a/TODO +++ b/TODO @@ -7,5 +7,5 @@ 2. MEDIUM: -2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types. +2.1 Support for EMBEDDED-PDV and CHARACTER STRING types. Requires something from 1.2 (Information Object Classes). diff --git a/asn1c/tests/Makefile.am b/asn1c/tests/Makefile.am index 3bb0f9d78..f54868539 100644 --- a/asn1c/tests/Makefile.am +++ b/asn1c/tests/Makefile.am @@ -15,6 +15,7 @@ TESTS += check-src/check-127.-gen-PER.c TESTS += check-src/check-131.-gen-PER.c TESTS += check-src/check-132.-gen-PER.c TESTS += check-src/check-133.-gen-PER.c +TESTS += check-src/check-135.c TESTS += check-src/check-19.c TESTS += check-src/check-22.-fwide-types.c TESTS += check-src/check-24.-fwide-types.c diff --git a/asn1c/tests/check-assembly.sh b/asn1c/tests/check-assembly.sh index baa433fc1..39e407784 100755 --- a/asn1c/tests/check-assembly.sh +++ b/asn1c/tests/check-assembly.sh @@ -68,7 +68,7 @@ check-executable: compiled-module *.c* # Compile the corresponding .asn1 spec. compiled-module: ${asn_module} ${abs_top_builddir}/asn1c/asn1c ${abs_top_builddir}/asn1c/asn1c \\ - -S /tmp/do/not/copy/skeletons \\ + -S ${abs_top_srcdir}/skeletons \\ -Wdebug-compiler \\ ${AFLAGS} ${asn_module} rm -f converter-sample.c diff --git a/asn1c/tests/check-src/check-135.c b/asn1c/tests/check-src/check-135.c new file mode 100644 index 000000000..00c28960f --- /dev/null +++ b/asn1c/tests/check-src/check-135.c @@ -0,0 +1,135 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include "T.h" + + +uint8_t buf1[] = { + 0x28,0x18, + 0x06,0x07,0x00,0x11,0x86,0x05,0x01,0x01,0x01, + 0xa0,0x0d, + 0x60,0x0b, + 0xa1,0x09, + 0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x05,0x03 +}; + + +uint8_t buf1_reconstr[] = { + 0x28,0x18, + 0x06,0x07,0x00,0x11,0x86,0x05,0x01,0x01,0x01, + 0xa0,0x0d, + 0x60,0x0b, + 0xa1,0x09, + 0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x05,0x03 +}; + + +static void +check(T_t *tp, uint8_t *buf, size_t size, size_t consumed) { + asn_dec_rval_t rval; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%zd)\n", buf, size); + rval = ber_decode(0, &asn_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %zd\n", + (int)rval.code, rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + const uint8_t direct_reference[] = {0x00,0x11,0x86,0x05,0x01,0x01,0x01}; + assert(tp->direct_reference); + assert(tp->direct_reference->size == sizeof(direct_reference)); + assert(memcmp(tp->direct_reference->buf, direct_reference, + sizeof(direct_reference)) == 0); + + assert(tp->indirect_reference == NULL); + assert(tp->data_value_descriptor == NULL); + + const uint8_t single_asn1_type[] = { + 0x60,0x0b,0xa1,0x09,0x06,0x07,0x04,0x00,0x00,0x01,0x00,0x05,0x03}; + assert(tp->encoding.present == encoding_PR_single_ASN1_type); + assert(tp->encoding.choice.single_ASN1_type.size == sizeof(single_asn1_type)); + assert(memcmp(tp->encoding.choice.single_ASN1_type.buf, single_asn1_type, + sizeof(single_asn1_type)) == 0); +} + +size_t buf_pos; +size_t buf_size; +uint8_t *buf; + +static int +buf_fill(const void *buffer, size_t size, void *app_key) { + + (void)app_key; /* Unused argument */ + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%zd + %zd > %zd\n", + buf_pos, size, buf_size); + return -1; + } + + memcpy(buf + buf_pos, buffer, size); + buf_pos += size; + fprintf(stderr, " written %zd (%zd)\n", size, buf_pos); + + return 0; +} + +static void +compare(T_t *tp, uint8_t *cmp_buf, ssize_t cmp_buf_size) { + asn_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buf = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%zd != %zd\n", erval.encoded, cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buf[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] + ); + } + assert(buf[i] == cmp_buf[i]); + } +} + +int +main(int ac, char **av) { + T_t t; + + (void)ac; /* Unused argument */ + (void)av; /* Unused argument */ + + /* Check exact buf1 */ + check(&t, buf1, sizeof(buf1), sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn_DEF_T, &t); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + /* Check slightly more than buf1 */ + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn_DEF_T, &t); + asn_DEF_T.free_struct(&asn_DEF_T, &t, 1); + + return 0; +} diff --git a/libasn1parser/asn1p_l.l b/libasn1parser/asn1p_l.l index 6deeca76c..56786c591 100644 --- a/libasn1parser/asn1p_l.l +++ b/libasn1parser/asn1p_l.l @@ -296,7 +296,6 @@ EXCEPT return TOK_EXCEPT; EXPLICIT return TOK_EXPLICIT; EXPORTS return TOK_EXPORTS; EXTENSIBILITY return TOK_EXTENSIBILITY; -EXTERNAL return TOK_EXTERNAL; FALSE return TOK_FALSE; FROM return TOK_FROM; GeneralizedTime return TOK_GeneralizedTime; diff --git a/libasn1parser/asn1p_y.y b/libasn1parser/asn1p_y.y index b8465cb27..b86ac79c5 100644 --- a/libasn1parser/asn1p_y.y +++ b/libasn1parser/asn1p_y.y @@ -174,7 +174,6 @@ static asn1p_module_t *currentModule; %token TOK_EXPLICIT %token TOK_EXPORTS %token TOK_EXTENSIBILITY -%token TOK_EXTERNAL %token TOK_FALSE %token TOK_FROM %token TOK_GeneralizedTime @@ -1607,7 +1606,6 @@ BasicTypeId: | TOK_OCTET TOK_STRING { $$ = ASN_BASIC_OCTET_STRING; } | TOK_OBJECT TOK_IDENTIFIER { $$ = ASN_BASIC_OBJECT_IDENTIFIER; } | TOK_RELATIVE_OID { $$ = ASN_BASIC_RELATIVE_OID; } - | TOK_EXTERNAL { $$ = ASN_BASIC_EXTERNAL; } | TOK_EMBEDDED TOK_PDV { $$ = ASN_BASIC_EMBEDDED_PDV; } | TOK_CHARACTER TOK_STRING { $$ = ASN_BASIC_CHARACTER_STRING; } | TOK_UTCTime { $$ = ASN_BASIC_UTCTime; } diff --git a/skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1 b/skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1 index 7ba2da4f0..5faa48acb 100644 --- a/skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1 +++ b/skeletons/standard-modules/ASN1C-UsefulInformationObjectClasses.asn1 @@ -28,4 +28,16 @@ DEFINITIONS ::= BEGIN &property BIT STRING { handles-invalid-encodings(0) } DEFAULT {} } WITH SYNTAX { &Type IDENTIFIED BY &id [HAS PROPERTY &property] } + -- + -- From "ITU-T Recommendation X.208", "34 The external type" + -- + EXTERNAL ::= [UNIVERSAL 8] IMPLICIT SEQUENCE + {direct-reference OBJECT IDENTIFIER OPTIONAL, + indirect-reference INTEGER OPTIONAL, + data-value-descriptor ObjectDescriptor OPTIONAL, + encoding CHOICE + {single-ASN1-type [0] ANY, + octet-aligned [1] IMPLICIT OCTET STRING, + arbitrary [2] IMPLICIT BIT STRING}} + END diff --git a/tests/03-enum-OK.asn1.-Pfwide-types b/tests/03-enum-OK.asn1.-Pfwide-types index 1b8aa1ce2..1c66250ef 100644 --- a/tests/03-enum-OK.asn1.-Pfwide-types +++ b/tests/03-enum-OK.asn1.-Pfwide-types @@ -786,3 +786,204 @@ asn_TYPE_descriptor_t asn_DEF_Enum5 = { &asn_SPC_Enum5_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/104-param-1-OK.asn1.-Pfwide-types b/tests/104-param-1-OK.asn1.-Pfwide-types index 634e528d7..30c01d320 100644 --- a/tests/104-param-1-OK.asn1.-Pfwide-types +++ b/tests/104-param-1-OK.asn1.-Pfwide-types @@ -199,3 +199,204 @@ asn_TYPE_descriptor_t asn_DEF_Bunch = { &asn_SPC_Bunch_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/105-param-2-OK.asn1.-Pfwide-types b/tests/105-param-2-OK.asn1.-Pfwide-types index e2114fe59..99480b432 100644 --- a/tests/105-param-2-OK.asn1.-Pfwide-types +++ b/tests/105-param-2-OK.asn1.-Pfwide-types @@ -450,3 +450,204 @@ asn_TYPE_descriptor_t asn_DEF_SignedSET = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/106-param-constr-OK.asn1.-P b/tests/106-param-constr-OK.asn1.-P index 2f9a18e3d..2054a0613 100644 --- a/tests/106-param-constr-OK.asn1.-P +++ b/tests/106-param-constr-OK.asn1.-P @@ -310,3 +310,204 @@ asn_TYPE_descriptor_t asn_DEF_NarrowInteger = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/108-param-constr-3-OK.asn1.-Pfwide-types b/tests/108-param-constr-3-OK.asn1.-Pfwide-types index 7f237624a..6827fe2c7 100644 --- a/tests/108-param-constr-3-OK.asn1.-Pfwide-types +++ b/tests/108-param-constr-3-OK.asn1.-Pfwide-types @@ -288,3 +288,204 @@ asn_TYPE_descriptor_t asn_DEF_ThreePlus = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/110-param-3-OK.asn1.-Pfwide-types b/tests/110-param-3-OK.asn1.-Pfwide-types index b1016efa4..70d5a1c7a 100644 --- a/tests/110-param-3-OK.asn1.-Pfwide-types +++ b/tests/110-param-3-OK.asn1.-Pfwide-types @@ -547,3 +547,204 @@ asn_TYPE_descriptor_t asn_DEF_EnumeratedColorFlag = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/119-per-strings-OK.asn1.-Pgen-PER b/tests/119-per-strings-OK.asn1.-Pgen-PER index 0a84a04e0..937af79dd 100644 --- a/tests/119-per-strings-OK.asn1.-Pgen-PER +++ b/tests/119-per-strings-OK.asn1.-Pgen-PER @@ -1584,3 +1584,218 @@ asn_TYPE_descriptor_t asn_DEF_PDU = { &asn_SPC_PDU_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/125-bitstring-constraint-OK.asn1.-P b/tests/125-bitstring-constraint-OK.asn1.-P index fb30250e4..93d1cacbe 100644 --- a/tests/125-bitstring-constraint-OK.asn1.-P +++ b/tests/125-bitstring-constraint-OK.asn1.-P @@ -142,3 +142,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/126-per-extensions-OK.asn1.-Pgen-PER b/tests/126-per-extensions-OK.asn1.-Pgen-PER index 76b02693f..d21951925 100644 --- a/tests/126-per-extensions-OK.asn1.-Pgen-PER +++ b/tests/126-per-extensions-OK.asn1.-Pgen-PER @@ -341,3 +341,218 @@ asn_TYPE_descriptor_t asn_DEF_PDU_2 = { &asn_SPC_PDU_2_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/127-per-long-OK.asn1.-Pgen-PER b/tests/127-per-long-OK.asn1.-Pgen-PER index 63c2d97f1..09e7089d4 100644 --- a/tests/127-per-long-OK.asn1.-Pgen-PER +++ b/tests/127-per-long-OK.asn1.-Pgen-PER @@ -543,3 +543,218 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/131-per-empty-OK.asn1.-Pgen-PER b/tests/131-per-empty-OK.asn1.-Pgen-PER index 8e706f0ad..34ca87b4d 100644 --- a/tests/131-per-empty-OK.asn1.-Pgen-PER +++ b/tests/131-per-empty-OK.asn1.-Pgen-PER @@ -55,3 +55,218 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/134-per-long-OK.asn1.-Pgen-PER b/tests/134-per-long-OK.asn1.-Pgen-PER index 40c8e912e..9a6b7b8ca 100644 --- a/tests/134-per-long-OK.asn1.-Pgen-PER +++ b/tests/134-per-long-OK.asn1.-Pgen-PER @@ -255,3 +255,218 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/135-EXTERNAL-OK.asn1 b/tests/135-EXTERNAL-OK.asn1 new file mode 100644 index 000000000..1ee491300 --- /dev/null +++ b/tests/135-EXTERNAL-OK.asn1 @@ -0,0 +1,4 @@ +TEST DEFINITIONS ::= +BEGIN + T ::= EXTERNAL +END diff --git a/tests/19-param-OK.asn1.-Pfwide-types b/tests/19-param-OK.asn1.-Pfwide-types index d587f7dc1..258af9844 100644 --- a/tests/19-param-OK.asn1.-Pfwide-types +++ b/tests/19-param-OK.asn1.-Pfwide-types @@ -524,3 +524,204 @@ asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName = { &asn_SPC_RelativeDistinguishedName_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/22-tags-OK.asn1.-Pfwide-types b/tests/22-tags-OK.asn1.-Pfwide-types index 2ea93009e..74da5215b 100644 --- a/tests/22-tags-OK.asn1.-Pfwide-types +++ b/tests/22-tags-OK.asn1.-Pfwide-types @@ -170,3 +170,204 @@ asn_TYPE_descriptor_t asn_DEF_T1 = { &asn_SPC_T1_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/30-set-OK.asn1.-Pfwide-types b/tests/30-set-OK.asn1.-Pfwide-types index 6d991dfe3..7978b680e 100644 --- a/tests/30-set-OK.asn1.-Pfwide-types +++ b/tests/30-set-OK.asn1.-Pfwide-types @@ -119,3 +119,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/31-set-of-OK.asn1.-Pfwide-types b/tests/31-set-of-OK.asn1.-Pfwide-types index cd58b8f08..dd653fd01 100644 --- a/tests/31-set-of-OK.asn1.-Pfwide-types +++ b/tests/31-set-of-OK.asn1.-Pfwide-types @@ -527,3 +527,204 @@ asn_TYPE_descriptor_t asn_DEF_Stuff = { &asn_SPC_Stuff_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/32-sequence-of-OK.asn1.-P b/tests/32-sequence-of-OK.asn1.-P index b9c3ae217..8f7c78c35 100644 --- a/tests/32-sequence-of-OK.asn1.-P +++ b/tests/32-sequence-of-OK.asn1.-P @@ -491,3 +491,204 @@ asn_TYPE_descriptor_t asn_DEF_SeqWithOptional = { &asn_SPC_SeqWithOptional_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/37-indirect-choice-OK.asn1.-Pfwide-types b/tests/37-indirect-choice-OK.asn1.-Pfwide-types index faad0637f..dacbf66b9 100644 --- a/tests/37-indirect-choice-OK.asn1.-Pfwide-types +++ b/tests/37-indirect-choice-OK.asn1.-Pfwide-types @@ -812,3 +812,204 @@ asn_TYPE_descriptor_t asn_DEF_Choice6 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/39-sequence-of-OK.asn1.-Pfwide-types b/tests/39-sequence-of-OK.asn1.-Pfwide-types index 57465e1d8..f4d563b98 100644 --- a/tests/39-sequence-of-OK.asn1.-Pfwide-types +++ b/tests/39-sequence-of-OK.asn1.-Pfwide-types @@ -225,3 +225,204 @@ asn_TYPE_descriptor_t asn_DEF_T2 = { &asn_SPC_T2_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR index 1f8aeb159..e98d0275d 100644 --- a/tests/42-real-life-OK.asn1.-PR +++ b/tests/42-real-life-OK.asn1.-PR @@ -940,3 +940,204 @@ asn_TYPE_descriptor_t asn_DEF_ActionItem = { &asn_SPC_ActionItem_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/43-recursion-OK.asn1.-Pfwide-types b/tests/43-recursion-OK.asn1.-Pfwide-types index a88085a3b..cc54673b4 100644 --- a/tests/43-recursion-OK.asn1.-Pfwide-types +++ b/tests/43-recursion-OK.asn1.-Pfwide-types @@ -586,3 +586,204 @@ asn_TYPE_descriptor_t asn_DEF_Test_structure_3 = { &asn_SPC_Test_structure_3_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/44-choice-in-sequence-OK.asn1.-P b/tests/44-choice-in-sequence-OK.asn1.-P index 838d5cf02..b71a2f60f 100644 --- a/tests/44-choice-in-sequence-OK.asn1.-P +++ b/tests/44-choice-in-sequence-OK.asn1.-P @@ -331,3 +331,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/46-redefine-OK.asn1.-PR b/tests/46-redefine-OK.asn1.-PR index 02ec505e7..76050032f 100644 --- a/tests/46-redefine-OK.asn1.-PR +++ b/tests/46-redefine-OK.asn1.-PR @@ -315,3 +315,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/47-set-ext-OK.asn1.-Pfwide-types b/tests/47-set-ext-OK.asn1.-Pfwide-types index 87edf16d6..e1913a609 100644 --- a/tests/47-set-ext-OK.asn1.-Pfwide-types +++ b/tests/47-set-ext-OK.asn1.-Pfwide-types @@ -356,3 +356,204 @@ asn_TYPE_descriptor_t asn_DEF_T4 = { &asn_SPC_T4_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/50-constraint-OK.asn1.-Pfwide-types b/tests/50-constraint-OK.asn1.-Pfwide-types index 0a120bf50..9b8f878d1 100644 --- a/tests/50-constraint-OK.asn1.-Pfwide-types +++ b/tests/50-constraint-OK.asn1.-Pfwide-types @@ -4404,3 +4404,204 @@ asn_TYPE_descriptor_t asn_DEF_Identifier = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/50-constraint-OK.asn1.-Pgen-PER b/tests/50-constraint-OK.asn1.-Pgen-PER index 23fcd9520..8bdc87d14 100644 --- a/tests/50-constraint-OK.asn1.-Pgen-PER +++ b/tests/50-constraint-OK.asn1.-Pgen-PER @@ -5740,3 +5740,218 @@ asn_TYPE_descriptor_t asn_DEF_Identifier = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/59-choice-extended-OK.asn1.-Pfwide-types b/tests/59-choice-extended-OK.asn1.-Pfwide-types index 256e00ea8..d40b5f0b3 100644 --- a/tests/59-choice-extended-OK.asn1.-Pfwide-types +++ b/tests/59-choice-extended-OK.asn1.-Pfwide-types @@ -118,3 +118,204 @@ asn_TYPE_descriptor_t asn_DEF_Choice = { &asn_SPC_Choice_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/60-any-OK.asn1.-Pfwide-types b/tests/60-any-OK.asn1.-Pfwide-types index 0338885d9..009992011 100644 --- a/tests/60-any-OK.asn1.-Pfwide-types +++ b/tests/60-any-OK.asn1.-Pfwide-types @@ -244,3 +244,204 @@ asn_TYPE_descriptor_t asn_DEF_T3 = { &asn_SPC_T3_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/65-multi-tag-OK.asn1.-Pfnative-types b/tests/65-multi-tag-OK.asn1.-Pfnative-types index 6b2e2e791..6f41591f3 100644 --- a/tests/65-multi-tag-OK.asn1.-Pfnative-types +++ b/tests/65-multi-tag-OK.asn1.-Pfnative-types @@ -980,3 +980,204 @@ asn_TYPE_descriptor_t asn_DEF_Ts = { &asn_SPC_Ts_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/65-multi-tag-OK.asn1.-Pfwide-types b/tests/65-multi-tag-OK.asn1.-Pfwide-types index 7de2a6db8..688509a3a 100644 --- a/tests/65-multi-tag-OK.asn1.-Pfwide-types +++ b/tests/65-multi-tag-OK.asn1.-Pfwide-types @@ -980,3 +980,204 @@ asn_TYPE_descriptor_t asn_DEF_Ts = { &asn_SPC_Ts_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/66-ref-simple-OK.asn1.-Pfwide-types b/tests/66-ref-simple-OK.asn1.-Pfwide-types index 28de20f4d..b660ec8a7 100644 --- a/tests/66-ref-simple-OK.asn1.-Pfwide-types +++ b/tests/66-ref-simple-OK.asn1.-Pfwide-types @@ -213,3 +213,204 @@ asn_TYPE_descriptor_t asn_DEF_SimpleType = { &asn_SPC_SimpleType_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/69-reserved-words-OK.asn1.-Pfwide-types b/tests/69-reserved-words-OK.asn1.-Pfwide-types index d99d454bd..281c66fe4 100644 --- a/tests/69-reserved-words-OK.asn1.-Pfwide-types +++ b/tests/69-reserved-words-OK.asn1.-Pfwide-types @@ -198,3 +198,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/70-xer-test-OK.asn1.-Pfwide-types b/tests/70-xer-test-OK.asn1.-Pfwide-types index b0b9060b1..a30336696 100644 --- a/tests/70-xer-test-OK.asn1.-Pfwide-types +++ b/tests/70-xer-test-OK.asn1.-Pfwide-types @@ -1920,3 +1920,204 @@ asn_TYPE_descriptor_t asn_DEF_SimpleChoice = { &asn_SPC_SimpleChoice_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/72-same-names-OK.asn1.-Pfwide-types b/tests/72-same-names-OK.asn1.-Pfwide-types index e7a7bf748..9b567ab61 100644 --- a/tests/72-same-names-OK.asn1.-Pfwide-types +++ b/tests/72-same-names-OK.asn1.-Pfwide-types @@ -769,3 +769,204 @@ asn_TYPE_descriptor_t asn_DEF_Type2 = { &asn_SPC_Type2_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/73-circular-OK.asn1.-Pfwide-types b/tests/73-circular-OK.asn1.-Pfwide-types index d77559234..a23bb92a8 100644 --- a/tests/73-circular-OK.asn1.-Pfwide-types +++ b/tests/73-circular-OK.asn1.-Pfwide-types @@ -853,3 +853,204 @@ asn_TYPE_descriptor_t asn_DEF_EnumType = { &asn_SPC_EnumType_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/84-param-tags-OK.asn1.-Pfwide-types b/tests/84-param-tags-OK.asn1.-Pfwide-types index 32dd7e00d..70de37dfe 100644 --- a/tests/84-param-tags-OK.asn1.-Pfwide-types +++ b/tests/84-param-tags-OK.asn1.-Pfwide-types @@ -557,3 +557,204 @@ asn_TYPE_descriptor_t asn_DEF_AutoChoice = { &asn_SPC_AutoChoice_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/88-integer-enum-OK.asn1.-Pfwide-types b/tests/88-integer-enum-OK.asn1.-Pfwide-types index ea0774d00..15bfb66a8 100644 --- a/tests/88-integer-enum-OK.asn1.-Pfwide-types +++ b/tests/88-integer-enum-OK.asn1.-Pfwide-types @@ -127,3 +127,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/89-bit-string-enum-OK.asn1.-Pfcompound-names b/tests/89-bit-string-enum-OK.asn1.-Pfcompound-names index 327d010c0..0ce61c593 100644 --- a/tests/89-bit-string-enum-OK.asn1.-Pfcompound-names +++ b/tests/89-bit-string-enum-OK.asn1.-Pfcompound-names @@ -80,3 +80,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum EXTERNAL__encoding_PR { + EXTERNAL__encoding_PR_NOTHING, /* No components present */ + EXTERNAL__encoding_PR_single_ASN1_type, + EXTERNAL__encoding_PR_octet_aligned, + EXTERNAL__encoding_PR_arbitrary +} EXTERNAL__encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct EXTERNAL__encoding { + EXTERNAL__encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL__encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL__encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL__encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct EXTERNAL__encoding), + offsetof(struct EXTERNAL__encoding, _asn_ctx), + offsetof(struct EXTERNAL__encoding, present), + sizeof(((struct EXTERNAL__encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/89-bit-string-enum-OK.asn1.-Pfwide-types b/tests/89-bit-string-enum-OK.asn1.-Pfwide-types index 4092af3ee..985876659 100644 --- a/tests/89-bit-string-enum-OK.asn1.-Pfwide-types +++ b/tests/89-bit-string-enum-OK.asn1.-Pfwide-types @@ -80,3 +80,204 @@ asn_TYPE_descriptor_t asn_DEF_T = { &asn_SPC_T_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/90-cond-int-type-OK.asn1.-P b/tests/90-cond-int-type-OK.asn1.-P index 4372c1b03..fc7f1550e 100644 --- a/tests/90-cond-int-type-OK.asn1.-P +++ b/tests/90-cond-int-type-OK.asn1.-P @@ -2488,3 +2488,204 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/90-cond-int-type-OK.asn1.-Pfwide-types b/tests/90-cond-int-type-OK.asn1.-Pfwide-types index 20b1a3fa6..c7d9d041c 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pfwide-types +++ b/tests/90-cond-int-type-OK.asn1.-Pfwide-types @@ -2507,3 +2507,204 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/90-cond-int-type-OK.asn1.-Pgen-PER b/tests/90-cond-int-type-OK.asn1.-Pgen-PER index 4741470ba..93f05fad6 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pgen-PER +++ b/tests/90-cond-int-type-OK.asn1.-Pgen-PER @@ -3364,3 +3364,218 @@ asn_TYPE_descriptor_t asn_DEF_NO_IntegerEnumerated2 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE b/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE index 7415f9b52..0f0ee7059 100644 --- a/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE +++ b/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE @@ -673,3 +673,204 @@ asn_TYPE_descriptor_t asn_DEF_NO_Integer5 = { 0 /* No specifics */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/92-circular-loops-OK.asn1.-Pfindirect-choice b/tests/92-circular-loops-OK.asn1.-Pfindirect-choice index 0896cb5d6..828055cd2 100644 --- a/tests/92-circular-loops-OK.asn1.-Pfindirect-choice +++ b/tests/92-circular-loops-OK.asn1.-Pfindirect-choice @@ -1692,3 +1692,204 @@ asn_TYPE_descriptor_t asn_DEF_ThreeOne = { &asn_SPC_ThreeOne_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/92-circular-loops-OK.asn1.-Pfwide-types b/tests/92-circular-loops-OK.asn1.-Pfwide-types index ac3e6b189..aa6775145 100644 --- a/tests/92-circular-loops-OK.asn1.-Pfwide-types +++ b/tests/92-circular-loops-OK.asn1.-Pfwide-types @@ -1691,3 +1691,204 @@ asn_TYPE_descriptor_t asn_DEF_ThreeOne = { &asn_SPC_ThreeOne_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/93-asn1c-controls-OK.asn1.-Pfwide-types b/tests/93-asn1c-controls-OK.asn1.-Pfwide-types index 6800e19b4..a30c57cb6 100644 --- a/tests/93-asn1c-controls-OK.asn1.-Pfwide-types +++ b/tests/93-asn1c-controls-OK.asn1.-Pfwide-types @@ -356,3 +356,204 @@ asn_TYPE_descriptor_t asn_DEF_Choice = { &asn_SPC_Choice_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/94-set-optionals-OK.asn1.-P b/tests/94-set-optionals-OK.asn1.-P index 723fd377e..7c79e09f4 100644 --- a/tests/94-set-optionals-OK.asn1.-P +++ b/tests/94-set-optionals-OK.asn1.-P @@ -202,3 +202,204 @@ asn_TYPE_descriptor_t asn_DEF_TestSet = { &asn_SPC_TestSet_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/95-choice-per-order-OK.asn1.-Pfwide-types b/tests/95-choice-per-order-OK.asn1.-Pfwide-types index a3ca4c020..cf30cb62a 100644 --- a/tests/95-choice-per-order-OK.asn1.-Pfwide-types +++ b/tests/95-choice-per-order-OK.asn1.-Pfwide-types @@ -285,3 +285,204 @@ asn_TYPE_descriptor_t asn_DEF_Choice2 = { &asn_SPC_Choice2_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + INTEGER_t *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_INTEGER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/95-choice-per-order-OK.asn1.-Pgen-PER b/tests/95-choice-per-order-OK.asn1.-Pgen-PER index 9ad698b47..24e1c097c 100644 --- a/tests/95-choice-per-order-OK.asn1.-Pgen-PER +++ b/tests/95-choice-per-order-OK.asn1.-Pgen-PER @@ -314,3 +314,218 @@ asn_TYPE_descriptor_t asn_DEF_Choice2 = { &asn_SPC_Choice2_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< CTDEFS [EXTERNAL] >>> ***/ + +static asn_per_constraints_t asn_PER_type_encoding_constr_5 GCC_NOTUSED = { + { APC_CONSTRAINED, 2, 2, 0, 2 } /* (0..2) */, + { APC_UNCONSTRAINED, -1, -1, 0, 0 }, + 0, 0 /* No PER value map */ +}; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + CHOICE_decode_uper, + CHOICE_encode_uper, + CHOICE_decode_aper, + CHOICE_encode_aper, + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + &asn_PER_type_encoding_constr_5, + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* No PER visible constraints */ + .default_value = 0, + .name = "encoding" + }, +}; +static const int asn_MAP_EXTERNAL_oms_1[] = { 0, 1, 2 }; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + asn_MAP_EXTERNAL_oms_1, /* Optional members */ + 3, 0, /* Root/Additions */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, + SEQUENCE_decode_aper, + SEQUENCE_encode_aper, + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; + diff --git a/tests/98-attribute-class-OK.asn1.-P b/tests/98-attribute-class-OK.asn1.-P index 29d9bdd7b..29a9c3fc5 100644 --- a/tests/98-attribute-class-OK.asn1.-P +++ b/tests/98-attribute-class-OK.asn1.-P @@ -104,3 +104,204 @@ asn_TYPE_descriptor_t asn_DEF_Attribute = { &asn_SPC_Attribute_specs_1 /* Additional specs */ }; + +/*** <<< INCLUDES [EXTERNAL] >>> ***/ + +#include +#include +#include +#include +#include +#include +#include +#include + +/*** <<< DEPS [EXTERNAL] >>> ***/ + +typedef enum encoding_PR { + encoding_PR_NOTHING, /* No components present */ + encoding_PR_single_ASN1_type, + encoding_PR_octet_aligned, + encoding_PR_arbitrary +} encoding_PR; + +/*** <<< TYPE-DECLS [EXTERNAL] >>> ***/ + +typedef struct EXTERNAL { + OBJECT_IDENTIFIER_t *direct_reference /* OPTIONAL */; + long *indirect_reference /* OPTIONAL */; + ObjectDescriptor_t *data_value_descriptor /* OPTIONAL */; + struct encoding { + encoding_PR present; + union EXTERNAL__encoding_u { + ANY_t single_ASN1_type; + OCTET_STRING_t octet_aligned; + BIT_STRING_t arbitrary; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } encoding; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} EXTERNAL_t; + +/*** <<< FUNC-DECLS [EXTERNAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_EXTERNAL; + +/*** <<< STAT-DEFS [EXTERNAL] >>> ***/ + +static asn_TYPE_member_t asn_MBR_encoding_5[] = { + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.single_ASN1_type), + .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = &asn_DEF_ANY, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "single-ASN1-type" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.octet_aligned), + .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_OCTET_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "octet-aligned" + }, + { ATF_NOFLAGS, 0, offsetof(struct encoding, choice.arbitrary), + .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = &asn_DEF_BIT_STRING, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "arbitrary" + }, +}; +static const asn_TYPE_tag2member_t asn_MAP_encoding_tag2el_5[] = { + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 } /* arbitrary */ +}; +static asn_CHOICE_specifics_t asn_SPC_encoding_specs_5 = { + sizeof(struct encoding), + offsetof(struct encoding, _asn_ctx), + offsetof(struct encoding, present), + sizeof(((struct encoding *)0)->present), + asn_MAP_encoding_tag2el_5, + 3, /* Count of tags in the map */ + .canonical_order = 0, + .ext_start = -1 /* Extensions start */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_encoding_5 = { + "encoding", + "encoding", + CHOICE_free, + CHOICE_print, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + CHOICE_outmost_tag, + 0, /* No effective tags (pointer) */ + 0, /* No effective tags (count) */ + 0, /* No tags (pointer) */ + 0, /* No tags (count) */ + 0, /* No PER visible constraints */ + asn_MBR_encoding_5, + 3, /* Elements count */ + &asn_SPC_encoding_specs_5 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_EXTERNAL_1[] = { + { ATF_POINTER, 3, offsetof(struct EXTERNAL, direct_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), + .tag_mode = 0, + .type = &asn_DEF_OBJECT_IDENTIFIER, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "direct-reference" + }, + { ATF_POINTER, 2, offsetof(struct EXTERNAL, indirect_reference), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "indirect-reference" + }, + { ATF_POINTER, 1, offsetof(struct EXTERNAL, data_value_descriptor), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), + .tag_mode = 0, + .type = &asn_DEF_ObjectDescriptor, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "data-value-descriptor" + }, + { ATF_NOFLAGS, 0, offsetof(struct EXTERNAL, encoding), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = &asn_DEF_encoding_5, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "encoding" + }, +}; +static const ber_tlv_tag_t asn_DEF_EXTERNAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (8 << 2)), + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static const asn_TYPE_tag2member_t asn_MAP_EXTERNAL_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 1, 0, 0 }, /* indirect-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 0, 0, 0 }, /* direct-reference */ + { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), 2, 0, 0 }, /* data-value-descriptor */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 3, 0, 0 }, /* single-ASN1-type */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 3, 0, 0 }, /* octet-aligned */ + { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 3, 0, 0 } /* arbitrary */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_EXTERNAL_specs_1 = { + sizeof(struct EXTERNAL), + offsetof(struct EXTERNAL, _asn_ctx), + asn_MAP_EXTERNAL_tag2el_1, + 6, /* Count of tags in the map */ + 0, 0, 0, /* Optional elements (not needed) */ + -1, /* Start extensions */ + -1 /* Stop extensions */ +}; +asn_TYPE_descriptor_t asn_DEF_EXTERNAL = { + "EXTERNAL", + "EXTERNAL", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, 0, /* No PER support, use "-gen-PER" to enable */ + 0, 0, /* No APER */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_EXTERNAL_tags_1, + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]) - 1, /* 1 */ + asn_DEF_EXTERNAL_tags_1, /* Same as above */ + sizeof(asn_DEF_EXTERNAL_tags_1) + /sizeof(asn_DEF_EXTERNAL_tags_1[0]), /* 2 */ + 0, /* No PER visible constraints */ + asn_MBR_EXTERNAL_1, + 4, /* Elements count */ + &asn_SPC_EXTERNAL_specs_1 /* Additional specs */ +}; +