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 352122a6c..1ee434c16 100644 --- a/asn1c/tests/Makefile.am +++ b/asn1c/tests/Makefile.am @@ -14,6 +14,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-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..600f70ef7 100644 --- a/libasn1parser/asn1p_l.l +++ b/libasn1parser/asn1p_l.l @@ -296,7 +296,7 @@ EXCEPT return TOK_EXCEPT; EXPLICIT return TOK_EXPLICIT; EXPORTS return TOK_EXPORTS; EXTENSIBILITY return TOK_EXTENSIBILITY; -EXTERNAL return TOK_EXTERNAL; + /*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 f502e8bb0..344dfa325 100644 --- a/libasn1parser/asn1p_y.y +++ b/libasn1parser/asn1p_y.y @@ -174,7 +174,7 @@ static asn1p_module_t *currentModule; %token TOK_EXPLICIT %token TOK_EXPORTS %token TOK_EXTENSIBILITY -%token TOK_EXTERNAL +/*%token TOK_EXTERNAL*/ %token TOK_FALSE %token TOK_FROM %token TOK_GeneralizedTime @@ -1607,7 +1607,7 @@ 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_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 281ad16ca..2e2c8a704 100644 --- a/tests/03-enum-OK.asn1.-Pfwide-types +++ b/tests/03-enum-OK.asn1.-Pfwide-types @@ -816,3 +816,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 50e33bafd..9fe5fbeaf 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 7ac005b3f..42b5f1770 100644 --- a/tests/105-param-2-OK.asn1.-Pfwide-types +++ b/tests/105-param-2-OK.asn1.-Pfwide-types @@ -462,3 +462,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 ac9be6305..4e5fbcabe 100644 --- a/tests/106-param-constr-OK.asn1.-P +++ b/tests/106-param-constr-OK.asn1.-P @@ -316,3 +316,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 017d2ec24..44ce04410 100644 --- a/tests/108-param-constr-3-OK.asn1.-Pfwide-types +++ b/tests/108-param-constr-3-OK.asn1.-Pfwide-types @@ -300,3 +300,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 dd7df4c49..4db3ce2c8 100644 --- a/tests/110-param-3-OK.asn1.-Pfwide-types +++ b/tests/110-param-3-OK.asn1.-Pfwide-types @@ -565,3 +565,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 9dcacaf65..1ec500bc3 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, 0l, 2l } /* (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 be32e0eb2..06b0acd10 100644 --- a/tests/125-bitstring-constraint-OK.asn1.-P +++ b/tests/125-bitstring-constraint-OK.asn1.-P @@ -148,3 +148,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 399b87559..4d5f967c7 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, 0l, 2l } /* (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 9ecad4791..05a02ba0e 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, 0l, 2l } /* (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..287c10d1f 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, 0l, 2l } /* (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 4eed86b09..f4fd953da 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, 0l, 2l } /* (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 3937b11ca..b82df6fc1 100644 --- a/tests/19-param-OK.asn1.-Pfwide-types +++ b/tests/19-param-OK.asn1.-Pfwide-types @@ -530,3 +530,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 dcd881d3f..3d6a619af 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 1ee3aeb28..54e207397 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 0e02f823e..f5738b396 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 86e6e3c3d..975a9bd88 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 db445d11a..e3cf6c658 100644 --- a/tests/37-indirect-choice-OK.asn1.-Pfwide-types +++ b/tests/37-indirect-choice-OK.asn1.-Pfwide-types @@ -836,3 +836,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 7a645e782..7070db9e9 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 7e2463c63..6b87e3228 100644 --- a/tests/42-real-life-OK.asn1.-PR +++ b/tests/42-real-life-OK.asn1.-PR @@ -946,3 +946,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 4376e0f58..2b1bd16ad 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 c1a83dacf..c222faa88 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 350654e3b..25e4f2e72 100644 --- a/tests/46-redefine-OK.asn1.-PR +++ b/tests/46-redefine-OK.asn1.-PR @@ -327,3 +327,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 01477b07c..e25ca800a 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 bc2b50c20..498d5bf2a 100644 --- a/tests/50-constraint-OK.asn1.-Pfwide-types +++ b/tests/50-constraint-OK.asn1.-Pfwide-types @@ -4566,3 +4566,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 725543465..bd3e22d72 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, 0l, 2l } /* (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 efe57a9ca..f6b3e0394 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 ac007c196..0f9bd4f64 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 cc2541748..8f49ee34d 100644 --- a/tests/65-multi-tag-OK.asn1.-Pfnative-types +++ b/tests/65-multi-tag-OK.asn1.-Pfnative-types @@ -1022,3 +1022,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 ae083179b..f137c4ef0 100644 --- a/tests/65-multi-tag-OK.asn1.-Pfwide-types +++ b/tests/65-multi-tag-OK.asn1.-Pfwide-types @@ -1022,3 +1022,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 f8c4f800d..9f7901d2c 100644 --- a/tests/66-ref-simple-OK.asn1.-Pfwide-types +++ b/tests/66-ref-simple-OK.asn1.-Pfwide-types @@ -219,3 +219,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 5e65ca492..88f1f7c44 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 230d1ce46..db5923ac1 100644 --- a/tests/70-xer-test-OK.asn1.-Pfwide-types +++ b/tests/70-xer-test-OK.asn1.-Pfwide-types @@ -1938,3 +1938,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 47923c3fe..3f55d890a 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 bb42973f0..3c38f2462 100644 --- a/tests/73-circular-OK.asn1.-Pfwide-types +++ b/tests/73-circular-OK.asn1.-Pfwide-types @@ -865,3 +865,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 9efa77a89..f33b8955d 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 945ede0f8..efc5737c3 100644 --- a/tests/88-integer-enum-OK.asn1.-Pfwide-types +++ b/tests/88-integer-enum-OK.asn1.-Pfwide-types @@ -133,3 +133,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 adb8d81da..06b7f0316 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 3d38ecde2..550153318 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 661662281..7181a3023 100644 --- a/tests/90-cond-int-type-OK.asn1.-P +++ b/tests/90-cond-int-type-OK.asn1.-P @@ -2596,3 +2596,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 7b91663a5..ff38bd87e 100644 --- a/tests/90-cond-int-type-OK.asn1.-Pfwide-types +++ b/tests/90-cond-int-type-OK.asn1.-Pfwide-types @@ -2615,3 +2615,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 1fb41ae24..ce18dc284 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, 0l, 2l } /* (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 220076c35..f33b2fcbb 100644 --- a/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE +++ b/tests/91-cond-int-blessSize-OK.asn1.-Pfbless-SIZE @@ -703,3 +703,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 b986dfdbb..507a6dd8b 100644 --- a/tests/92-circular-loops-OK.asn1.-Pfindirect-choice +++ b/tests/92-circular-loops-OK.asn1.-Pfindirect-choice @@ -1698,3 +1698,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 6d45e55f6..e0fe7f3fc 100644 --- a/tests/92-circular-loops-OK.asn1.-Pfwide-types +++ b/tests/92-circular-loops-OK.asn1.-Pfwide-types @@ -1697,3 +1697,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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 7b20d16db..8ba9c4cce 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 483d77021..901008502 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 a1884c4a0..a8c9be17d 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 d6f123daa..0e7525a99 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, 0l, 2l } /* (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 547fc4ed9..dd0760791 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 UPER support, use "-gen-PER" to enable */ + 0, 0, /* No APER support, use "-gen-PER" to enable */ + 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 */ +}; +