diff --git a/tests/19-param-OK.asn1 b/tests/19-param-OK.asn1 index 37d7c448e6bc3f9403bfffd1bc3b1fcb24e38103..cd132d22d3a2f6d4520fadec433ad683d89e815e 100644 --- a/tests/19-param-OK.asn1 +++ b/tests/19-param-OK.asn1 @@ -25,6 +25,7 @@ BEGIN Name ::= SEQUENCE OF RelativeDistinguishedName - RelativeDistinguishedName ::= SET SIZE (1..MAX) OF IA5String + RelativeDistinguishedName ::= SET SIZE (1..MAX) OF + IA5String (FROM("A".."Z"|"a".."z"|"0-9"|",-.")) END diff --git a/tests/39-sequence-of-OK.asn1.-P b/tests/39-sequence-of-OK.asn1.-P index 383cafc4b124b8ea5d4647a6dac277f071423414..6a8553b9aa723983514ba0377c8d8d8284525817 100644 --- a/tests/39-sequence-of-OK.asn1.-P +++ b/tests/39-sequence-of-OK.asn1.-P @@ -29,46 +29,54 @@ typedef struct T { /*** <<< STAT-DEFS [T] >>> ***/ - static asn1_SET_OF_element_t asn1_DEF_collection_elements[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - (void *)&asn1_DEF_T2 }, - }; - static ber_tlv_tag_t asn1_DEF_collection_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) - }; - static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = { - sizeof(struct collection), - offsetof(struct collection, _ber_dec_ctx), - asn1_DEF_collection_elements - }; - asn1_TYPE_descriptor_t asn1_DEF_collection = { - "collection", - SEQUENCE_OF_constraint, - SEQUENCE_OF_decode_ber, - SEQUENCE_OF_encode_der, - SEQUENCE_OF_print, - SEQUENCE_OF_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_collection_tags, - sizeof(asn1_DEF_collection_tags) - /sizeof(asn1_DEF_collection_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_collection_specs /* Additional specs */ - }; - -static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = { - { offsetof(struct T, int), 0, - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - (void *)&asn1_DEF_INTEGER, - "int" +static asn1_TYPE_member_t asn1_MBR_collection[] = { + { 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_T2, + .memb_constraints = 0, /* Defer to actual type */ + .name = "" }, - { offsetof(struct T, collection), 0, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_collection, - "collection" +}; +static ber_tlv_tag_t asn1_DEF_collection_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SET_OF_specifics_t asn1_DEF_collection_specs = { + sizeof(struct collection), + offsetof(struct collection, _ber_dec_ctx), +}; +asn1_TYPE_descriptor_t asn1_DEF_collection = { + "collection", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_collection_tags, + sizeof(asn1_DEF_collection_tags) + /sizeof(asn1_DEF_collection_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_collection, + 1, /* Single element */ + &asn1_DEF_collection_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_T[] = { + { 0, offsetof(struct T, int), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_INTEGER, + .memb_constraints = 0, /* Defer to actual type */ + .name = "int" + }, + { 0, offsetof(struct T, collection), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_collection, + .memb_constraints = 0, /* Defer to actual type */ + .name = "collection" }, }; static ber_tlv_tag_t asn1_DEF_T_tags[] = { @@ -81,8 +89,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = { sizeof(struct T), offsetof(struct T, _ber_dec_ctx), - asn1_DEF_T_elements, - 2, /* Elements count */ asn1_DEF_T_tag2el, 2, /* Count of tags in the map */ -1, /* Start extensions */ @@ -101,6 +107,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = { /sizeof(asn1_DEF_T_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T, + 2, /* Elements count */ &asn1_DEF_T_specs /* Additional specs */ }; @@ -128,18 +136,20 @@ typedef struct T2 { /*** <<< STAT-DEFS [T2] >>> ***/ -static asn1_SEQUENCE_element_t asn1_DEF_T2_elements[] = { - { offsetof(struct T2, flag), 0, - (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), - 0, - (void *)&asn1_DEF_BOOLEAN, - "flag" +static asn1_TYPE_member_t asn1_MBR_T2[] = { + { 0, offsetof(struct T2, flag), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_BOOLEAN, + .memb_constraints = 0, /* Defer to actual type */ + .name = "flag" }, - { offsetof(struct T2, str), 0, - (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), - 0, - (void *)&asn1_DEF_UTF8String, - "str" + { 0, offsetof(struct T2, str), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_UTF8String, + .memb_constraints = 0, /* Defer to actual type */ + .name = "str" }, }; static ber_tlv_tag_t asn1_DEF_T2_tags[] = { @@ -152,8 +162,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T2_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_T2_specs = { sizeof(struct T2), offsetof(struct T2, _ber_dec_ctx), - asn1_DEF_T2_elements, - 2, /* Elements count */ asn1_DEF_T2_tag2el, 2, /* Count of tags in the map */ -1, /* Start extensions */ @@ -172,6 +180,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = { /sizeof(asn1_DEF_T2_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T2, + 2, /* Elements count */ &asn1_DEF_T2_specs /* Additional specs */ }; diff --git a/tests/42-real-life-OK.asn1 b/tests/42-real-life-OK.asn1 index 33802c211d3907a74bd007f65eeaf9e1ef8a8314..8c1d59e1c060099136dffb269af219145ad0be26 100644 --- a/tests/42-real-life-OK.asn1 +++ b/tests/42-real-life-OK.asn1 @@ -21,7 +21,7 @@ BEGIN */ LogLine ::= SEQUENCE { line-digest IA5String, -- Log line normal form - varsets SEQUENCE (1..MAX) OF VariablePartSet + varsets SEQUENCE SIZE(1..MAX) OF VariablePartSet } /* @@ -30,7 +30,7 @@ BEGIN * or a range between two samples. */ VariablePartSet ::= SEQUENCE { - vparts SEQUENCE (0..MAX) OF VariablePart, -- {123,321} + vparts SEQUENCE SIZE(0..MAX) OF VariablePart, -- {123,321} resolution ActionItem } @@ -39,7 +39,7 @@ BEGIN */ VariablePart ::= CHOICE { -- A set of acceptable values - vset SET (1..MAX) OF VisibleString, + vset SET SIZE(1..MAX) OF VisibleString, -- A range of acceptable values vrange SEQUENCE { from VisibleString, diff --git a/tests/42-real-life-OK.asn1.-EF b/tests/42-real-life-OK.asn1.-EF index 7b3a89da0f130a57e073e807aa72aabcac28fd62..14492fa8daff10a823ea09006964c2a361b578db 100644 --- a/tests/42-real-life-OK.asn1.-EF +++ b/tests/42-real-life-OK.asn1.-EF @@ -7,18 +7,18 @@ BEGIN LogLine ::= SEQUENCE { line-digest IA5String, - varsets SEQUENCE OF VariablePartSet, + varsets SEQUENCE SIZE(1..MAX) OF VariablePartSet, ... } VariablePartSet ::= SEQUENCE { - vparts SEQUENCE OF VariablePart, + vparts SEQUENCE SIZE(0..MAX) OF VariablePart, resolution ActionItem, ... } VariablePart ::= CHOICE { - vset SET OF VisibleString, + vset SET SIZE(1..MAX) OF VisibleString, vrange SEQUENCE { from VisibleString, to VisibleString, diff --git a/tests/42-real-life-OK.asn1.-PR b/tests/42-real-life-OK.asn1.-PR index ece1127a36d1395235cae347f7d35c2eaf3a9432..2bd4579e76e668d1856d7cd363b633abaa29606d 100644 --- a/tests/42-real-life-OK.asn1.-PR +++ b/tests/42-real-life-OK.asn1.-PR @@ -31,48 +31,86 @@ typedef struct LogLine { ber_dec_ctx_t _ber_dec_ctx; } LogLine_t; -/*** <<< STAT-DEFS [LogLine] >>> ***/ +/*** <<< CODE [LogLine] >>> ***/ - static asn1_SET_OF_element_t asn1_DEF_varsets_elements[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - (void *)&asn1_DEF_VariablePartSet }, - }; - static ber_tlv_tag_t asn1_DEF_varsets_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) - }; - static asn1_SET_OF_specifics_t asn1_DEF_varsets_specs = { - sizeof(struct varsets), - offsetof(struct varsets, _ber_dec_ctx), - asn1_DEF_varsets_elements - }; - asn1_TYPE_descriptor_t asn1_DEF_varsets = { - "varsets", - SEQUENCE_OF_constraint, - SEQUENCE_OF_decode_ber, - SEQUENCE_OF_encode_der, - SEQUENCE_OF_print, - SEQUENCE_OF_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_varsets_tags, - sizeof(asn1_DEF_varsets_tags) - /sizeof(asn1_DEF_varsets_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_varsets_specs /* Additional specs */ - }; +static int +memb_varsets_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + size_t size; + + if(!sptr) { + _ASN_ERRLOG(app_errlog, app_key, + "%s: value not given", td->name); + return -1; + } -static asn1_SEQUENCE_element_t asn1_DEF_LogLine_elements[] = { - { offsetof(struct LogLine, line_digest), 0, - (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), - 0, - (void *)&asn1_DEF_IA5String, - "line-digest" + { /* Determine the number of elements */ + const A_SEQUENCE_OF(void) *list; + (const void *)list = sptr; + size = list->count; + } + + if((size >= 1)) { + /* Constraint check succeeded */ + return 1; + } else { + _ASN_ERRLOG(app_errlog, app_key, + "%s: constraint failed", td->name); + return -1; + } +} + + +/*** <<< STAT-DEFS [LogLine] >>> ***/ + +static asn1_TYPE_member_t asn1_MBR_varsets[] = { + { 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_VariablePartSet, + .memb_constraints = 0, /* Defer to actual type */ + .name = "" + }, +}; +static ber_tlv_tag_t asn1_DEF_varsets_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SET_OF_specifics_t asn1_DEF_varsets_specs = { + sizeof(struct varsets), + offsetof(struct varsets, _ber_dec_ctx), +}; +asn1_TYPE_descriptor_t asn1_DEF_varsets = { + "varsets", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_varsets_tags, + sizeof(asn1_DEF_varsets_tags) + /sizeof(asn1_DEF_varsets_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_varsets, + 1, /* Single element */ + &asn1_DEF_varsets_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_LogLine[] = { + { 0, offsetof(struct LogLine, line_digest), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_IA5String, + .memb_constraints = 0, /* Defer to actual type */ + .name = "line-digest" }, - { offsetof(struct LogLine, varsets), 0, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_varsets, - "varsets" + { 0, offsetof(struct LogLine, varsets), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_varsets, + .memb_constraints = memb_varsets_constraint, + .name = "varsets" }, }; static ber_tlv_tag_t asn1_DEF_LogLine_tags[] = { @@ -85,8 +123,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_LogLine_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_LogLine_specs = { sizeof(struct LogLine), offsetof(struct LogLine, _ber_dec_ctx), - asn1_DEF_LogLine_elements, - 2, /* Elements count */ asn1_DEF_LogLine_tag2el, 2, /* Count of tags in the map */ 1, /* Start extensions */ @@ -105,6 +141,8 @@ asn1_TYPE_descriptor_t asn1_DEF_LogLine = { /sizeof(asn1_DEF_LogLine_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_LogLine, + 2, /* Elements count */ &asn1_DEF_LogLine_specs /* Additional specs */ }; @@ -141,48 +179,78 @@ typedef struct VariablePartSet { ber_dec_ctx_t _ber_dec_ctx; } VariablePartSet_t; -/*** <<< STAT-DEFS [VariablePartSet] >>> ***/ +/*** <<< CODE [VariablePartSet] >>> ***/ - static asn1_SET_OF_element_t asn1_DEF_vparts_elements[] = { - { -1 /* Ambiguous tag (CHOICE?) */, - (void *)&asn1_DEF_VariablePart }, - }; - static ber_tlv_tag_t asn1_DEF_vparts_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) - }; - static asn1_SET_OF_specifics_t asn1_DEF_vparts_specs = { - sizeof(struct vparts), - offsetof(struct vparts, _ber_dec_ctx), - asn1_DEF_vparts_elements - }; - asn1_TYPE_descriptor_t asn1_DEF_vparts = { - "vparts", - SEQUENCE_OF_constraint, - SEQUENCE_OF_decode_ber, - SEQUENCE_OF_encode_der, - SEQUENCE_OF_print, - SEQUENCE_OF_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_vparts_tags, - sizeof(asn1_DEF_vparts_tags) - /sizeof(asn1_DEF_vparts_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_vparts_specs /* Additional specs */ - }; +static int +memb_vparts_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + + if(!sptr) { + _ASN_ERRLOG(app_errlog, app_key, + "%s: value not given", td->name); + return -1; + } + + + if(1 /* No applicable constraints whatsoever */) { + /* Nothing is here. See below */ + } -static asn1_SEQUENCE_element_t asn1_DEF_VariablePartSet_elements[] = { - { offsetof(struct VariablePartSet, vparts), 0, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_vparts, - "vparts" + return td->check_constraints + (td, sptr, app_errlog, app_key); +} + + +/*** <<< STAT-DEFS [VariablePartSet] >>> ***/ + +static asn1_TYPE_member_t asn1_MBR_vparts[] = { + { 0, 0, + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = (void *)&asn1_DEF_VariablePart, + .memb_constraints = 0, /* Defer to actual type */ + .name = "" }, - { offsetof(struct VariablePartSet, resolution), 0, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_ActionItem, - "resolution" +}; +static ber_tlv_tag_t asn1_DEF_vparts_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_SET_OF_specifics_t asn1_DEF_vparts_specs = { + sizeof(struct vparts), + offsetof(struct vparts, _ber_dec_ctx), +}; +asn1_TYPE_descriptor_t asn1_DEF_vparts = { + "vparts", + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_print, + SEQUENCE_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vparts_tags, + sizeof(asn1_DEF_vparts_tags) + /sizeof(asn1_DEF_vparts_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_vparts, + 1, /* Single element */ + &asn1_DEF_vparts_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_VariablePartSet[] = { + { 0, offsetof(struct VariablePartSet, vparts), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_vparts, + .memb_constraints = memb_vparts_constraint, + .name = "vparts" + }, + { 0, offsetof(struct VariablePartSet, resolution), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_ActionItem, + .memb_constraints = 0, /* Defer to actual type */ + .name = "resolution" }, }; static ber_tlv_tag_t asn1_DEF_VariablePartSet_tags[] = { @@ -195,8 +263,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_VariablePartSet_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_VariablePartSet_specs = { sizeof(struct VariablePartSet), offsetof(struct VariablePartSet, _ber_dec_ctx), - asn1_DEF_VariablePartSet_elements, - 2, /* Elements count */ asn1_DEF_VariablePartSet_tag2el, 2, /* Count of tags in the map */ 1, /* Start extensions */ @@ -215,6 +281,8 @@ asn1_TYPE_descriptor_t asn1_DEF_VariablePartSet = { /sizeof(asn1_DEF_VariablePartSet_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_VariablePartSet, + 2, /* Elements count */ &asn1_DEF_VariablePartSet_specs /* Additional specs */ }; @@ -270,95 +338,135 @@ typedef struct VariablePart { ber_dec_ctx_t _ber_dec_ctx; } VariablePart_t; +/*** <<< CODE [VariablePart] >>> ***/ + +static int +memb_vset_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + size_t size; + + if(!sptr) { + _ASN_ERRLOG(app_errlog, app_key, + "%s: value not given", td->name); + return -1; + } + + { /* Determine the number of elements */ + const A_SET_OF(void) *list; + (const void *)list = sptr; + size = list->count; + } + + if((size >= 1)) { + /* Constraint check succeeded */ + return 1; + } else { + _ASN_ERRLOG(app_errlog, app_key, + "%s: constraint failed", td->name); + return -1; + } +} + + /*** <<< STAT-DEFS [VariablePart] >>> ***/ - static asn1_SET_OF_element_t asn1_DEF_vset_elements[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), - (void *)&asn1_DEF_VisibleString }, - }; - static ber_tlv_tag_t asn1_DEF_vset_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) - }; - static asn1_SET_OF_specifics_t asn1_DEF_vset_specs = { - sizeof(struct vset), - offsetof(struct vset, _ber_dec_ctx), - asn1_DEF_vset_elements - }; - asn1_TYPE_descriptor_t asn1_DEF_vset = { - "vset", - SET_OF_constraint, - SET_OF_decode_ber, - SET_OF_encode_der, - SET_OF_print, - SET_OF_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_vset_tags, - sizeof(asn1_DEF_vset_tags) - /sizeof(asn1_DEF_vset_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_vset_specs /* Additional specs */ - }; - - static asn1_SEQUENCE_element_t asn1_DEF_vrange_elements[] = { - { offsetof(struct vrange, from), 0, - (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), - 0, - (void *)&asn1_DEF_VisibleString, - "from" - }, - { offsetof(struct vrange, to), 0, - (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), - 0, - (void *)&asn1_DEF_VisibleString, - "to" - }, - }; - static ber_tlv_tag_t asn1_DEF_vrange_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) - }; - static asn1_TYPE_tag2member_t asn1_DEF_vrange_tag2el[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), 0, 0, 1 }, /* from at 45 */ - { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), 1, -1, 0 }, /* to at 46 */ - }; - static asn1_SEQUENCE_specifics_t asn1_DEF_vrange_specs = { - sizeof(struct vrange), - offsetof(struct vrange, _ber_dec_ctx), - asn1_DEF_vrange_elements, - 2, /* Elements count */ - asn1_DEF_vrange_tag2el, - 2, /* Count of tags in the map */ - 1, /* Start extensions */ - 3 /* Stop extensions */ - }; - asn1_TYPE_descriptor_t asn1_DEF_vrange = { - "vrange", - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_print, - SEQUENCE_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_vrange_tags, - sizeof(asn1_DEF_vrange_tags) - /sizeof(asn1_DEF_vrange_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_vrange_specs /* Additional specs */ - }; - -static asn1_CHOICE_element_t asn1_DEF_VariablePart_elements[] = { - { offsetof(struct VariablePart, choice.vset), 0, - (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), - 0, - (void *)&asn1_DEF_vset, - "vset" +static asn1_TYPE_member_t asn1_MBR_vset[] = { + { 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_VisibleString, + .memb_constraints = 0, /* Defer to actual type */ + .name = "" + }, +}; +static ber_tlv_tag_t asn1_DEF_vset_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) +}; +static asn1_SET_OF_specifics_t asn1_DEF_vset_specs = { + sizeof(struct vset), + offsetof(struct vset, _ber_dec_ctx), +}; +asn1_TYPE_descriptor_t asn1_DEF_vset = { + "vset", + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_print, + SET_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vset_tags, + sizeof(asn1_DEF_vset_tags) + /sizeof(asn1_DEF_vset_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_vset, + 1, /* Single element */ + &asn1_DEF_vset_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_vrange[] = { + { 0, offsetof(struct vrange, from), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_VisibleString, + .memb_constraints = 0, /* Defer to actual type */ + .name = "from" }, - { offsetof(struct VariablePart, choice.vrange), 0, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_vrange, - "vrange" + { 0, offsetof(struct vrange, to), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_VisibleString, + .memb_constraints = 0, /* Defer to actual type */ + .name = "to" + }, +}; +static ber_tlv_tag_t asn1_DEF_vrange_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_TYPE_tag2member_t asn1_DEF_vrange_tag2el[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), 0, 0, 1 }, /* from at 45 */ + { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), 1, -1, 0 }, /* to at 46 */ +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_vrange_specs = { + sizeof(struct vrange), + offsetof(struct vrange, _ber_dec_ctx), + asn1_DEF_vrange_tag2el, + 2, /* Count of tags in the map */ + 1, /* Start extensions */ + 3 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_vrange = { + "vrange", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_vrange_tags, + sizeof(asn1_DEF_vrange_tags) + /sizeof(asn1_DEF_vrange_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_vrange, + 2, /* Elements count */ + &asn1_DEF_vrange_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_VariablePart[] = { + { 0, offsetof(struct VariablePart, choice.vset), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_vset, + .memb_constraints = memb_vset_constraint, + .name = "vset" + }, + { 0, offsetof(struct VariablePart, choice.vrange), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_vrange, + .memb_constraints = 0, /* Defer to actual type */ + .name = "vrange" }, }; static asn1_TYPE_tag2member_t asn1_DEF_VariablePart_tag2el[] = { @@ -370,8 +478,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_VariablePart_specs = { offsetof(struct VariablePart, _ber_dec_ctx), offsetof(struct VariablePart, present), sizeof(((struct VariablePart *)0)->present), - asn1_DEF_VariablePart_elements, - 2, /* Elements count */ asn1_DEF_VariablePart_tag2el, 2, /* Count of tags in the map */ 1 /* Whether extensible */ @@ -388,6 +494,8 @@ asn1_TYPE_descriptor_t asn1_DEF_VariablePart = { 0, /* No explicit tags (count) */ 0, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_VariablePart, + 2, /* Elements count */ &asn1_DEF_VariablePart_specs /* Additional specs */ }; @@ -403,14 +511,14 @@ asn1_TYPE_descriptor_t asn1_DEF_VariablePart = { /*** <<< DEPS [ActionItem] >>> ***/ - typedef enum accept_as { - accept_as_unknown = 0, - accept_as_safe = 1, - accept_as_unsafe = 2, - /* - * Enumeration is extensible - */ - } accept_as_e; +typedef enum accept_as { + accept_as_unknown = 0, + accept_as_safe = 1, + accept_as_unsafe = 2, + /* + * Enumeration is extensible + */ +} accept_as_e; extern asn1_TYPE_descriptor_t asn1_DEF_ActionItem; /*** <<< TYPE-DECLS [ActionItem] >>> ***/ @@ -445,93 +553,103 @@ typedef struct ActionItem { /*** <<< STAT-DEFS [ActionItem] >>> ***/ - static asn1_SET_OF_element_t asn1_DEF_email_elements[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), - (void *)&asn1_DEF_VisibleString }, - }; - static ber_tlv_tag_t asn1_DEF_email_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) - }; - static asn1_SET_OF_specifics_t asn1_DEF_email_specs = { - sizeof(struct email), - offsetof(struct email, _ber_dec_ctx), - asn1_DEF_email_elements - }; - asn1_TYPE_descriptor_t asn1_DEF_email = { - "email", - SET_OF_constraint, - SET_OF_decode_ber, - SET_OF_encode_der, - SET_OF_print, - SET_OF_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_email_tags, - sizeof(asn1_DEF_email_tags) - /sizeof(asn1_DEF_email_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_email_specs /* Additional specs */ - }; - - static asn1_SEQUENCE_element_t asn1_DEF_notify_elements[] = { - { offsetof(struct notify, critical), 0, - (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), - 0, - (void *)&asn1_DEF_BOOLEAN, - "critical" - }, - { offsetof(struct notify, email), 0, - (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), - 0, - (void *)&asn1_DEF_email, - "email" - }, - }; - static ber_tlv_tag_t asn1_DEF_notify_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) - }; - static asn1_TYPE_tag2member_t asn1_DEF_notify_tag2el[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 }, /* critical at 61 */ - { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 1, 0, 0 }, /* email at 62 */ - }; - static asn1_SEQUENCE_specifics_t asn1_DEF_notify_specs = { - sizeof(struct notify), - offsetof(struct notify, _ber_dec_ctx), - asn1_DEF_notify_elements, - 2, /* Elements count */ - asn1_DEF_notify_tag2el, - 2, /* Count of tags in the map */ - 1, /* Start extensions */ - 3 /* Stop extensions */ - }; - asn1_TYPE_descriptor_t asn1_DEF_notify = { - "notify", - SEQUENCE_constraint, - SEQUENCE_decode_ber, - SEQUENCE_encode_der, - SEQUENCE_print, - SEQUENCE_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_notify_tags, - sizeof(asn1_DEF_notify_tags) - /sizeof(asn1_DEF_notify_tags[0]), /* 1 */ - 1, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_notify_specs /* Additional specs */ - }; - -static asn1_SEQUENCE_element_t asn1_DEF_ActionItem_elements[] = { - { offsetof(struct ActionItem, accept_as), 0, - (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)), - 0, - (void *)&asn1_DEF_ENUMERATED, - "accept-as" +static asn1_TYPE_member_t asn1_MBR_email[] = { + { 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (26 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_VisibleString, + .memb_constraints = 0, /* Defer to actual type */ + .name = "" + }, +}; +static ber_tlv_tag_t asn1_DEF_email_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) +}; +static asn1_SET_OF_specifics_t asn1_DEF_email_specs = { + sizeof(struct email), + offsetof(struct email, _ber_dec_ctx), +}; +asn1_TYPE_descriptor_t asn1_DEF_email = { + "email", + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_print, + SET_OF_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_email_tags, + sizeof(asn1_DEF_email_tags) + /sizeof(asn1_DEF_email_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_email, + 1, /* Single element */ + &asn1_DEF_email_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_notify[] = { + { 0, offsetof(struct notify, critical), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_BOOLEAN, + .memb_constraints = 0, /* Defer to actual type */ + .name = "critical" }, - { offsetof(struct ActionItem, notify), 1, - (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), - 0, - (void *)&asn1_DEF_notify, - "notify" + { 0, offsetof(struct notify, email), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_email, + .memb_constraints = 0, /* Defer to actual type */ + .name = "email" + }, +}; +static ber_tlv_tag_t asn1_DEF_notify_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn1_TYPE_tag2member_t asn1_DEF_notify_tag2el[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 }, /* critical at 61 */ + { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 1, 0, 0 }, /* email at 62 */ +}; +static asn1_SEQUENCE_specifics_t asn1_DEF_notify_specs = { + sizeof(struct notify), + offsetof(struct notify, _ber_dec_ctx), + asn1_DEF_notify_tag2el, + 2, /* Count of tags in the map */ + 1, /* Start extensions */ + 3 /* Stop extensions */ +}; +asn1_TYPE_descriptor_t asn1_DEF_notify = { + "notify", + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_print, + SEQUENCE_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_notify_tags, + sizeof(asn1_DEF_notify_tags) + /sizeof(asn1_DEF_notify_tags[0]), /* 1 */ + 1, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_notify, + 2, /* Elements count */ + &asn1_DEF_notify_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_ActionItem[] = { + { 0, offsetof(struct ActionItem, accept_as), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_ENUMERATED, + .memb_constraints = 0, /* Defer to actual type */ + .name = "accept-as" + }, + { 1, offsetof(struct ActionItem, notify), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_notify, + .memb_constraints = 0, /* Defer to actual type */ + .name = "notify" }, }; static ber_tlv_tag_t asn1_DEF_ActionItem_tags[] = { @@ -544,8 +662,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_ActionItem_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_ActionItem_specs = { sizeof(struct ActionItem), offsetof(struct ActionItem, _ber_dec_ctx), - asn1_DEF_ActionItem_elements, - 2, /* Elements count */ asn1_DEF_ActionItem_tag2el, 2, /* Count of tags in the map */ 1, /* Start extensions */ @@ -564,6 +680,8 @@ asn1_TYPE_descriptor_t asn1_DEF_ActionItem = { /sizeof(asn1_DEF_ActionItem_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_ActionItem, + 2, /* Elements count */ &asn1_DEF_ActionItem_specs /* Additional specs */ }; diff --git a/tests/44-choice-in-sequence-OK.asn1.-P b/tests/44-choice-in-sequence-OK.asn1.-P index 0c65871f5005f71641cf0511443d445050431ea7..3a12ecfcb380ebec5d7176ac03cb0f5bd13b0679 100644 --- a/tests/44-choice-in-sequence-OK.asn1.-P +++ b/tests/44-choice-in-sequence-OK.asn1.-P @@ -7,23 +7,23 @@ /*** <<< DEPS [T] >>> ***/ - typedef enum b_PR { - b_PR_NOTHING, /* No components present */ - b_PR_c, - b_PR_d, - b_PR_e, - b_PR_h, - } b_PR; - typedef enum e_PR { - e_PR_NOTHING, /* No components present */ - e_PR_f, - e_PR_g, - } e_PR; - typedef enum h_PR { - h_PR_NOTHING, /* No components present */ - h_PR_i, - h_PR_j, - } h_PR; +typedef enum b_PR { + b_PR_NOTHING, /* No components present */ + b_PR_c, + b_PR_d, + b_PR_e, + b_PR_h, +} b_PR; +typedef enum e_PR { + e_PR_NOTHING, /* No components present */ + e_PR_f, + e_PR_g, +} e_PR; +typedef enum h_PR { + h_PR_NOTHING, /* No components present */ + h_PR_i, + h_PR_j, +} h_PR; extern asn1_TYPE_descriptor_t asn1_DEF_T; /*** <<< TYPE-DECLS [T] >>> ***/ @@ -68,165 +68,175 @@ typedef struct T { /*** <<< STAT-DEFS [T] >>> ***/ - static asn1_CHOICE_element_t asn1_DEF_e_elements[] = { - { offsetof(struct e, choice.f), 0, - (ASN_TAG_CLASS_PRIVATE | (7 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "f" - }, - { offsetof(struct e, choice.g), 0, - (ASN_TAG_CLASS_PRIVATE | (8 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "g" - }, - }; - static asn1_TYPE_tag2member_t asn1_DEF_e_tag2el[] = { - { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 0, 0, 0 }, /* f at 20 */ - { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g at 21 */ - }; - static asn1_CHOICE_specifics_t asn1_DEF_e_specs = { - sizeof(struct e), - offsetof(struct e, _ber_dec_ctx), - offsetof(struct e, present), - sizeof(((struct e *)0)->present), - asn1_DEF_e_elements, - 2, /* Elements count */ - asn1_DEF_e_tag2el, - 2, /* Count of tags in the map */ - 0 /* Whether extensible */ - }; - asn1_TYPE_descriptor_t asn1_DEF_e = { - "e", - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_print, - CHOICE_free, - CHOICE_outmost_tag, - 0, /* No explicit tags (pointer) */ - 0, /* No explicit tags (count) */ - 0, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_e_specs /* Additional specs */ - }; - - static asn1_CHOICE_element_t asn1_DEF_h_elements[] = { - { offsetof(struct h, choice.i), 0, - (ASN_TAG_CLASS_PRIVATE | (1 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "i" - }, - { offsetof(struct h, choice.j), 0, - (ASN_TAG_CLASS_PRIVATE | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "j" - }, - }; - static asn1_TYPE_tag2member_t asn1_DEF_h_tag2el[] = { - { (ASN_TAG_CLASS_PRIVATE | (1 << 2)), 0, 0, 0 }, /* i at 24 */ - { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 1, 0, 0 }, /* j at 25 */ - }; - static asn1_CHOICE_specifics_t asn1_DEF_h_specs = { - sizeof(struct h), - offsetof(struct h, _ber_dec_ctx), - offsetof(struct h, present), - sizeof(((struct h *)0)->present), - asn1_DEF_h_elements, - 2, /* Elements count */ - asn1_DEF_h_tag2el, - 2, /* Count of tags in the map */ - 0 /* Whether extensible */ - }; - asn1_TYPE_descriptor_t asn1_DEF_h = { - "h", - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_print, - CHOICE_free, - CHOICE_outmost_tag, - 0, /* No explicit tags (pointer) */ - 0, /* No explicit tags (count) */ - 0, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_h_specs /* Additional specs */ - }; - - static asn1_CHOICE_element_t asn1_DEF_b_elements[] = { - { offsetof(struct b, choice.c), 0, - (ASN_TAG_CLASS_PRIVATE | (5 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "c" - }, - { offsetof(struct b, choice.d), 0, - (ASN_TAG_CLASS_PRIVATE | (6 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "d" - }, - { offsetof(struct b, choice.e), 0, - -1 /* Ambiguous tag (CHOICE?) */, - 0, - (void *)&asn1_DEF_e, - "e" - }, - { offsetof(struct b, choice.h), 0, - (ASN_TAG_CLASS_PRIVATE | (9 << 2)), - +1, /* EXPLICIT tag at current level */ - (void *)&asn1_DEF_h, - "h" - }, - }; - static asn1_TYPE_tag2member_t asn1_DEF_b_tag2el[] = { - { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 0, 0, 0 }, /* c at 17 */ - { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d at 18 */ - { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 2, 0, 0 }, /* f at 20 */ - { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 2, 0, 0 }, /* g at 21 */ - { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 3, 0, 0 }, /* h at 24 */ - }; - static asn1_CHOICE_specifics_t asn1_DEF_b_specs = { - sizeof(struct b), - offsetof(struct b, _ber_dec_ctx), - offsetof(struct b, present), - sizeof(((struct b *)0)->present), - asn1_DEF_b_elements, - 4, /* Elements count */ - asn1_DEF_b_tag2el, - 5, /* Count of tags in the map */ - 0 /* Whether extensible */ - }; - asn1_TYPE_descriptor_t asn1_DEF_b = { - "b", - CHOICE_constraint, - CHOICE_decode_ber, - CHOICE_encode_der, - CHOICE_print, - CHOICE_free, - CHOICE_outmost_tag, - 0, /* No explicit tags (pointer) */ - 0, /* No explicit tags (count) */ - 0, /* Tags to skip */ - 1, /* Whether CONSTRUCTED */ - &asn1_DEF_b_specs /* Additional specs */ - }; - -static asn1_SEQUENCE_element_t asn1_DEF_T_elements[] = { - { offsetof(struct T, a), 0, - (ASN_TAG_CLASS_PRIVATE | (2 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_NULL, - "a" +static asn1_TYPE_member_t asn1_MBR_e[] = { + { 0, offsetof(struct e, choice.f), + .tag = (ASN_TAG_CLASS_PRIVATE | (7 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "f" }, - { offsetof(struct T, b), 0, - -1 /* Ambiguous tag (CHOICE?) */, - 0, - (void *)&asn1_DEF_b, - "b" + { 0, offsetof(struct e, choice.g), + .tag = (ASN_TAG_CLASS_PRIVATE | (8 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "g" + }, +}; +static asn1_TYPE_tag2member_t asn1_DEF_e_tag2el[] = { + { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 0, 0, 0 }, /* f at 20 */ + { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 1, 0, 0 }, /* g at 21 */ +}; +static asn1_CHOICE_specifics_t asn1_DEF_e_specs = { + sizeof(struct e), + offsetof(struct e, _ber_dec_ctx), + offsetof(struct e, present), + sizeof(((struct e *)0)->present), + asn1_DEF_e_tag2el, + 2, /* Count of tags in the map */ + 0 /* Whether extensible */ +}; +asn1_TYPE_descriptor_t asn1_DEF_e = { + "e", + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_print, + CHOICE_free, + CHOICE_outmost_tag, + 0, /* No explicit tags (pointer) */ + 0, /* No explicit tags (count) */ + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_e, + 2, /* Elements count */ + &asn1_DEF_e_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_h[] = { + { 0, offsetof(struct h, choice.i), + .tag = (ASN_TAG_CLASS_PRIVATE | (1 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "i" + }, + { 0, offsetof(struct h, choice.j), + .tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "j" + }, +}; +static asn1_TYPE_tag2member_t asn1_DEF_h_tag2el[] = { + { (ASN_TAG_CLASS_PRIVATE | (1 << 2)), 0, 0, 0 }, /* i at 24 */ + { (ASN_TAG_CLASS_PRIVATE | (2 << 2)), 1, 0, 0 }, /* j at 25 */ +}; +static asn1_CHOICE_specifics_t asn1_DEF_h_specs = { + sizeof(struct h), + offsetof(struct h, _ber_dec_ctx), + offsetof(struct h, present), + sizeof(((struct h *)0)->present), + asn1_DEF_h_tag2el, + 2, /* Count of tags in the map */ + 0 /* Whether extensible */ +}; +asn1_TYPE_descriptor_t asn1_DEF_h = { + "h", + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_print, + CHOICE_free, + CHOICE_outmost_tag, + 0, /* No explicit tags (pointer) */ + 0, /* No explicit tags (count) */ + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_h, + 2, /* Elements count */ + &asn1_DEF_h_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_b[] = { + { 0, offsetof(struct b, choice.c), + .tag = (ASN_TAG_CLASS_PRIVATE | (5 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "c" + }, + { 0, offsetof(struct b, choice.d), + .tag = (ASN_TAG_CLASS_PRIVATE | (6 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "d" + }, + { 0, offsetof(struct b, choice.e), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = (void *)&asn1_DEF_e, + .memb_constraints = 0, /* Defer to actual type */ + .name = "e" + }, + { 0, offsetof(struct b, choice.h), + .tag = (ASN_TAG_CLASS_PRIVATE | (9 << 2)), + .tag_mode = +1, /* EXPLICIT tag at current level */ + .type = (void *)&asn1_DEF_h, + .memb_constraints = 0, /* Defer to actual type */ + .name = "h" + }, +}; +static asn1_TYPE_tag2member_t asn1_DEF_b_tag2el[] = { + { (ASN_TAG_CLASS_PRIVATE | (5 << 2)), 0, 0, 0 }, /* c at 17 */ + { (ASN_TAG_CLASS_PRIVATE | (6 << 2)), 1, 0, 0 }, /* d at 18 */ + { (ASN_TAG_CLASS_PRIVATE | (7 << 2)), 2, 0, 0 }, /* f at 20 */ + { (ASN_TAG_CLASS_PRIVATE | (8 << 2)), 2, 0, 0 }, /* g at 21 */ + { (ASN_TAG_CLASS_PRIVATE | (9 << 2)), 3, 0, 0 }, /* h at 24 */ +}; +static asn1_CHOICE_specifics_t asn1_DEF_b_specs = { + sizeof(struct b), + offsetof(struct b, _ber_dec_ctx), + offsetof(struct b, present), + sizeof(((struct b *)0)->present), + asn1_DEF_b_tag2el, + 5, /* Count of tags in the map */ + 0 /* Whether extensible */ +}; +asn1_TYPE_descriptor_t asn1_DEF_b = { + "b", + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_print, + CHOICE_free, + CHOICE_outmost_tag, + 0, /* No explicit tags (pointer) */ + 0, /* No explicit tags (count) */ + 0, /* Tags to skip */ + 1, /* Whether CONSTRUCTED */ + asn1_MBR_b, + 4, /* Elements count */ + &asn1_DEF_b_specs /* Additional specs */ +}; + +static asn1_TYPE_member_t asn1_MBR_T[] = { + { 0, offsetof(struct T, a), + .tag = (ASN_TAG_CLASS_PRIVATE | (2 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_NULL, + .memb_constraints = 0, /* Defer to actual type */ + .name = "a" + }, + { 0, offsetof(struct T, b), + .tag = -1 /* Ambiguous tag (CHOICE?) */, + .tag_mode = 0, + .type = (void *)&asn1_DEF_b, + .memb_constraints = 0, /* Defer to actual type */ + .name = "b" }, }; static ber_tlv_tag_t asn1_DEF_T_tags[] = { @@ -243,8 +253,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_T_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_T_specs = { sizeof(struct T), offsetof(struct T, _ber_dec_ctx), - asn1_DEF_T_elements, - 2, /* Elements count */ asn1_DEF_T_tag2el, 6, /* Count of tags in the map */ -1, /* Start extensions */ @@ -263,6 +271,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T = { /sizeof(asn1_DEF_T_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T, + 2, /* Elements count */ &asn1_DEF_T_specs /* Additional specs */ }; diff --git a/tests/46-redefine-OK.asn1.-PR b/tests/46-redefine-OK.asn1.-PR index 639ded028f045e5a86e40b80abe485d77d2f84a9..ee7aceb42b9ee7af68a110310f54b45e0568fe56 100644 --- a/tests/46-redefine-OK.asn1.-PR +++ b/tests/46-redefine-OK.asn1.-PR @@ -18,26 +18,7 @@ der_type_encoder_f PrimitiveType_encode_der; asn_struct_print_f PrimitiveType_print; asn_struct_free_f PrimitiveType_free; -/*** <<< STAT-DEFS [PrimitiveType] >>> ***/ - -static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = { - (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) -}; -asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = { - "PrimitiveType", - PrimitiveType_constraint, - PrimitiveType_decode_ber, - PrimitiveType_encode_der, - PrimitiveType_print, - PrimitiveType_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_PrimitiveType_tags, - sizeof(asn1_DEF_PrimitiveType_tags) - /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */ - 1, /* Tags to skip */ - -0, /* Unknown yet */ - 0 /* No specifics */ -}; +/*** <<< CODE [PrimitiveType] >>> ***/ int PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, @@ -54,19 +35,21 @@ PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, * so adjust the DEF appropriately. */ static void -inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { - td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder; - td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder; - td->free_struct = asn1_DEF_OCTET_STRING.free_struct; - td->print_struct = asn1_DEF_OCTET_STRING.print_struct; - td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form; - td->specifics = asn1_DEF_OCTET_STRING.specifics; +PrimitiveType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { + td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder; + td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder; + td->free_struct = asn1_DEF_OCTET_STRING.free_struct; + td->print_struct = asn1_DEF_OCTET_STRING.print_struct; + td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form; + td->elements = asn1_DEF_OCTET_STRING.elements; + td->elements_count = asn1_DEF_OCTET_STRING.elements_count; + td->specifics = asn1_DEF_OCTET_STRING.specifics; } ber_dec_rval_t PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td, void **structure, void *bufptr, size_t size, int tag_mode) { - inherit_TYPE_descriptor(td); + PrimitiveType_inherit_TYPE_descriptor(td); return td->ber_decoder(td, structure, bufptr, size, tag_mode); } @@ -75,25 +58,48 @@ der_enc_rval_t PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { - inherit_TYPE_descriptor(td); + PrimitiveType_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } int PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - inherit_TYPE_descriptor(td); + PrimitiveType_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } void PrimitiveType_free(asn1_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { - inherit_TYPE_descriptor(td); + PrimitiveType_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } +/*** <<< STAT-DEFS [PrimitiveType] >>> ***/ + +static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = { + (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = { + "PrimitiveType", + PrimitiveType_constraint, + PrimitiveType_decode_ber, + PrimitiveType_encode_der, + PrimitiveType_print, + PrimitiveType_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_PrimitiveType_tags, + sizeof(asn1_DEF_PrimitiveType_tags) + /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */ + 1, /* Tags to skip */ + -0, /* Unknown yet */ + 0, 0, /* No members */ + 0 /* No specifics */ +}; + + /*** <<< INCLUDES [ConstructedType] >>> ***/ #include <PrimitiveType.h> @@ -115,12 +121,13 @@ typedef struct ConstructedType { /*** <<< STAT-DEFS [ConstructedType] >>> ***/ -static asn1_SEQUENCE_element_t asn1_DEF_ConstructedType_elements[] = { - { offsetof(struct ConstructedType, field), 0, - (ASN_TAG_CLASS_CONTEXT | (5 << 2)), - -1, /* IMPLICIT tag at current level */ - (void *)&asn1_DEF_PrimitiveType, - "field" +static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = { + { 0, offsetof(struct ConstructedType, field), + .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)), + .tag_mode = -1, /* IMPLICIT tag at current level */ + .type = (void *)&asn1_DEF_PrimitiveType, + .memb_constraints = 0, /* Defer to actual type */ + .name = "field" }, }; static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = { @@ -132,8 +139,6 @@ static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = { static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = { sizeof(struct ConstructedType), offsetof(struct ConstructedType, _ber_dec_ctx), - asn1_DEF_ConstructedType_elements, - 1, /* Elements count */ asn1_DEF_ConstructedType_tag2el, 1, /* Count of tags in the map */ -1, /* Start extensions */ @@ -152,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = { /sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_ConstructedType, + 1, /* Elements count */ &asn1_DEF_ConstructedType_specs /* Additional specs */ }; @@ -175,26 +182,7 @@ der_type_encoder_f T_encode_der; asn_struct_print_f T_print; asn_struct_free_f T_free; -/*** <<< STAT-DEFS [T] >>> ***/ - -static ber_tlv_tag_t asn1_DEF_T_tags[] = { - (ASN_TAG_CLASS_CONTEXT | (3 << 2)) -}; -asn1_TYPE_descriptor_t asn1_DEF_T = { - "T", - T_constraint, - T_decode_ber, - T_encode_der, - T_print, - T_free, - 0, /* Use generic outmost tag fetcher */ - asn1_DEF_T_tags, - sizeof(asn1_DEF_T_tags) - /sizeof(asn1_DEF_T_tags[0]), /* 1 */ - 1, /* Tags to skip */ - -0, /* Unknown yet */ - 0 /* No specifics */ -}; +/*** <<< CODE [T] >>> ***/ int T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, @@ -211,19 +199,21 @@ T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, * so adjust the DEF appropriately. */ static void -inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { - td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder; - td->der_encoder = asn1_DEF_ConstructedType.der_encoder; - td->free_struct = asn1_DEF_ConstructedType.free_struct; - td->print_struct = asn1_DEF_ConstructedType.print_struct; - td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form; - td->specifics = asn1_DEF_ConstructedType.specifics; +T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { + td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder; + td->der_encoder = asn1_DEF_ConstructedType.der_encoder; + td->free_struct = asn1_DEF_ConstructedType.free_struct; + td->print_struct = asn1_DEF_ConstructedType.print_struct; + td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form; + td->elements = asn1_DEF_ConstructedType.elements; + td->elements_count = asn1_DEF_ConstructedType.elements_count; + td->specifics = asn1_DEF_ConstructedType.specifics; } ber_dec_rval_t T_decode_ber(asn1_TYPE_descriptor_t *td, void **structure, void *bufptr, size_t size, int tag_mode) { - inherit_TYPE_descriptor(td); + T_inherit_TYPE_descriptor(td); return td->ber_decoder(td, structure, bufptr, size, tag_mode); } @@ -232,21 +222,44 @@ der_enc_rval_t T_encode_der(asn1_TYPE_descriptor_t *td, void *structure, int tag_mode, ber_tlv_tag_t tag, asn_app_consume_bytes_f *cb, void *app_key) { - inherit_TYPE_descriptor(td); + T_inherit_TYPE_descriptor(td); return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); } int T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { - inherit_TYPE_descriptor(td); + T_inherit_TYPE_descriptor(td); return td->print_struct(td, struct_ptr, ilevel, cb, app_key); } void T_free(asn1_TYPE_descriptor_t *td, void *struct_ptr, int contents_only) { - inherit_TYPE_descriptor(td); + T_inherit_TYPE_descriptor(td); td->free_struct(td, struct_ptr, contents_only); } + +/*** <<< STAT-DEFS [T] >>> ***/ + +static ber_tlv_tag_t asn1_DEF_T_tags[] = { + (ASN_TAG_CLASS_CONTEXT | (3 << 2)) +}; +asn1_TYPE_descriptor_t asn1_DEF_T = { + "T", + T_constraint, + T_decode_ber, + T_encode_der, + T_print, + T_free, + 0, /* Use generic outmost tag fetcher */ + asn1_DEF_T_tags, + sizeof(asn1_DEF_T_tags) + /sizeof(asn1_DEF_T_tags[0]), /* 1 */ + 1, /* Tags to skip */ + -0, /* Unknown yet */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + diff --git a/tests/47-set-ext-OK.asn1.-P b/tests/47-set-ext-OK.asn1.-P index e945ccfec00d5bea2f6e569022d6054ecf964668..9991cf5701ed21d01fd971e209ac1a684a13fed7 100644 --- a/tests/47-set-ext-OK.asn1.-P +++ b/tests/47-set-ext-OK.asn1.-P @@ -35,12 +35,13 @@ typedef struct T1 { /*** <<< STAT-DEFS [T1] >>> ***/ -static asn1_SET_element_t asn1_DEF_T1_elements[] = { - { offsetof(struct T1, i), 0, - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - (void *)&asn1_DEF_INTEGER, - "i" +static asn1_TYPE_member_t asn1_MBR_T1[] = { + { 0, offsetof(struct T1, i), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_INTEGER, + .memb_constraints = 0, /* Defer to actual type */ + .name = "i" }, }; static ber_tlv_tag_t asn1_DEF_T1_tags[] = { @@ -56,8 +57,6 @@ static asn1_SET_specifics_t asn1_DEF_T1_specs = { sizeof(struct T1), offsetof(struct T1, _ber_dec_ctx), offsetof(struct T1, _presence_map), - asn1_DEF_T1_elements, - 1, /* Elements count */ asn1_DEF_T1_tag2el, 1, /* Count of tags in the map */ 1, /* Whether extensible */ @@ -76,6 +75,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T1 = { /sizeof(asn1_DEF_T1_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T1, + 1, /* Elements count */ &asn1_DEF_T1_specs /* Additional specs */ }; @@ -116,12 +117,13 @@ typedef struct T2 { /*** <<< STAT-DEFS [T2] >>> ***/ -static asn1_SET_element_t asn1_DEF_T2_elements[] = { - { offsetof(struct T2, i), 0, - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - (void *)&asn1_DEF_INTEGER, - "i" +static asn1_TYPE_member_t asn1_MBR_T2[] = { + { 0, offsetof(struct T2, i), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_INTEGER, + .memb_constraints = 0, /* Defer to actual type */ + .name = "i" }, }; static ber_tlv_tag_t asn1_DEF_T2_tags[] = { @@ -137,8 +139,6 @@ static asn1_SET_specifics_t asn1_DEF_T2_specs = { sizeof(struct T2), offsetof(struct T2, _ber_dec_ctx), offsetof(struct T2, _presence_map), - asn1_DEF_T2_elements, - 1, /* Elements count */ asn1_DEF_T2_tag2el, 1, /* Count of tags in the map */ 1, /* Whether extensible */ @@ -157,6 +157,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T2 = { /sizeof(asn1_DEF_T2_tags[0]), /* 1 */ 1, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T2, + 1, /* Elements count */ &asn1_DEF_T2_specs /* Additional specs */ }; @@ -194,12 +196,13 @@ typedef struct T3 { /*** <<< STAT-DEFS [T3] >>> ***/ -static asn1_CHOICE_element_t asn1_DEF_T3_elements[] = { - { offsetof(struct T3, choice.i), 0, - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - (void *)&asn1_DEF_INTEGER, - "i" +static asn1_TYPE_member_t asn1_MBR_T3[] = { + { 0, offsetof(struct T3, choice.i), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_INTEGER, + .memb_constraints = 0, /* Defer to actual type */ + .name = "i" }, }; static asn1_TYPE_tag2member_t asn1_DEF_T3_tag2el[] = { @@ -210,8 +213,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T3_specs = { offsetof(struct T3, _ber_dec_ctx), offsetof(struct T3, present), sizeof(((struct T3 *)0)->present), - asn1_DEF_T3_elements, - 1, /* Elements count */ asn1_DEF_T3_tag2el, 1, /* Count of tags in the map */ 1 /* Whether extensible */ @@ -228,6 +229,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T3 = { 0, /* No explicit tags (count) */ 0, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T3, + 1, /* Elements count */ &asn1_DEF_T3_specs /* Additional specs */ }; @@ -265,12 +268,13 @@ typedef struct T4 { /*** <<< STAT-DEFS [T4] >>> ***/ -static asn1_CHOICE_element_t asn1_DEF_T4_elements[] = { - { offsetof(struct T4, choice.i), 0, - (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), - 0, - (void *)&asn1_DEF_INTEGER, - "i" +static asn1_TYPE_member_t asn1_MBR_T4[] = { + { 0, offsetof(struct T4, choice.i), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = (void *)&asn1_DEF_INTEGER, + .memb_constraints = 0, /* Defer to actual type */ + .name = "i" }, }; static asn1_TYPE_tag2member_t asn1_DEF_T4_tag2el[] = { @@ -281,8 +285,6 @@ static asn1_CHOICE_specifics_t asn1_DEF_T4_specs = { offsetof(struct T4, _ber_dec_ctx), offsetof(struct T4, present), sizeof(((struct T4 *)0)->present), - asn1_DEF_T4_elements, - 1, /* Elements count */ asn1_DEF_T4_tag2el, 1, /* Count of tags in the map */ 1 /* Whether extensible */ @@ -299,6 +301,8 @@ asn1_TYPE_descriptor_t asn1_DEF_T4 = { 0, /* No explicit tags (count) */ 0, /* Tags to skip */ 1, /* Whether CONSTRUCTED */ + asn1_MBR_T4, + 1, /* Elements count */ &asn1_DEF_T4_specs /* Additional specs */ }; diff --git a/tests/50-constraint-OK.asn1 b/tests/50-constraint-OK.asn1 index 27af95d19c57d5775e0ddf6092f5e5febc803a20..0ae7689cdb31595363ee291cb4f3d863a7f1fa54 100644 --- a/tests/50-constraint-OK.asn1 +++ b/tests/50-constraint-OK.asn1 @@ -39,4 +39,8 @@ BEGIN SIZE-and-FROM ::= PER-Visible (SIZE(1..4) ^ FROM("ABCD")) Neither-SIZE-nor-FROM ::= PER-Visible (SIZE(1..4) | FROM("ABCD",...)) + Utf8-3 ::= Utf8-2 (FROM("A".."Z"|"a".."z")) + Utf8-2 ::= Utf8-1 (SIZE(1..2)) + Utf8-1 ::= UTF8String + END diff --git a/tests/50-constraint-OK.asn1.-EFprint-constraints b/tests/50-constraint-OK.asn1.-EFprint-constraints index 694f7766fb54b2625813f6029830feb4134e110e..11e8d3d304a396a1401cf3f8011c71cf404ce954 100644 Binary files a/tests/50-constraint-OK.asn1.-EFprint-constraints and b/tests/50-constraint-OK.asn1.-EFprint-constraints differ