diff options
author | Lev Walkin <vlm@lionet.info> | 2006-03-21 03:40:38 +0000 |
---|---|---|
committer | Lev Walkin <vlm@lionet.info> | 2006-03-21 03:40:38 +0000 |
commit | a00d6b371486efc2fbe6e812882d250f5a0bb75c (patch) | |
tree | 24c47f98731c42ea1df33a464c0fbca7ba760489 /tests | |
parent | 25b8f280603bc4ed70609c3aacc1ef8820b027b3 (diff) |
refactored parameterization support
Diffstat (limited to 'tests')
-rw-r--r-- | tests/104-param-1-OK.asn1 | 21 | ||||
-rw-r--r-- | tests/104-param-1-OK.asn1.-EFprint-class-matrix | 17 | ||||
-rw-r--r-- | tests/104-param-1-OK.asn1.-P | 198 | ||||
-rw-r--r-- | tests/105-param-2-OK.asn1 | 21 | ||||
-rw-r--r-- | tests/105-param-2-OK.asn1.-P | 451 | ||||
-rw-r--r-- | tests/106-param-constr-OK.asn1 | 20 | ||||
-rw-r--r-- | tests/106-param-constr-OK.asn1.-P | 222 | ||||
-rw-r--r-- | tests/19-param-OK.asn1.-EF | 8 | ||||
-rw-r--r-- | tests/19-param-OK.asn1.-P | 171 | ||||
-rw-r--r-- | tests/58-param-OK.asn1.-EF | 5 | ||||
-rw-r--r-- | tests/84-param-tags-OK.asn1.-EF | 16 | ||||
-rw-r--r-- | tests/84-param-tags-OK.asn1.-P | 377 |
12 files changed, 1294 insertions, 233 deletions
diff --git a/tests/104-param-1-OK.asn1 b/tests/104-param-1-OK.asn1 new file mode 100644 index 00000000..4ffb603b --- /dev/null +++ b/tests/104-param-1-OK.asn1 @@ -0,0 +1,21 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .104 + +ModuleParametrization1 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 104 } + DEFINITIONS ::= +BEGIN + + Collection {T} ::= SET OF T + + Bunch ::= SEQUENCE { + field-REAL Collection {REAL}, + field-IA5String Collection {IA5String} + } + +END diff --git a/tests/104-param-1-OK.asn1.-EFprint-class-matrix b/tests/104-param-1-OK.asn1.-EFprint-class-matrix new file mode 100644 index 00000000..26a81ef3 --- /dev/null +++ b/tests/104-param-1-OK.asn1.-EFprint-class-matrix @@ -0,0 +1,17 @@ +ModuleParametrization1 { iso org(3) dod(6) internet(1) private(4) + enterprise(1) spelio(9363) software(1) asn1c(5) test(1) 104 } +DEFINITIONS ::= +BEGIN + +Collection{T} ::= SET OF T +-- Specializations list has 2 entries: +-- REAL +-- IA5String + + +Bunch ::= SEQUENCE { + field-REAL Collection{ REAL}, + field-IA5String Collection{ IA5String} +} + +END diff --git a/tests/104-param-1-OK.asn1.-P b/tests/104-param-1-OK.asn1.-P new file mode 100644 index 00000000..4d741e47 --- /dev/null +++ b/tests/104-param-1-OK.asn1.-P @@ -0,0 +1,198 @@ + +/*** <<< INCLUDES [Collection] >>> ***/ + +#include <REAL.h> +#include <asn_SET_OF.h> +#include <constr_SET_OF.h> +#include <IA5String.h> + +/*** <<< TYPE-DECLS [Collection] >>> ***/ + +typedef struct Collection_16P0 { + A_SET_OF(REAL_t) list; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} Collection_16P0_t; +typedef struct Collection_16P1 { + A_SET_OF(IA5String_t) list; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} Collection_16P1_t; + +/*** <<< FUNC-DECLS [Collection] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_Collection_16P0; +extern asn_TYPE_descriptor_t asn_DEF_Collection_16P1; + +/*** <<< STAT-DEFS [Collection] >>> ***/ + +static asn_TYPE_member_t asn_MBR_Collection_16P0_1[] = { + { ATF_POINTER, 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), + .tag_mode = 0, + .type = &asn_DEF_REAL, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "" + }, +}; +static ber_tlv_tag_t asn_DEF_Collection_16P0_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) +}; +static asn_SET_OF_specifics_t asn_SPC_Collection_16P0_specs_1 = { + sizeof(struct Collection_16P0), + offsetof(struct Collection_16P0, _asn_ctx), + 0, /* XER encoding is XMLDelimitedItemList */ +}; +asn_TYPE_descriptor_t asn_DEF_Collection_16P0 = { + "Collection", + "Collection", + SET_OF_free, + SET_OF_print, + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_decode_xer, + SET_OF_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Collection_16P0_tags_1, + sizeof(asn_DEF_Collection_16P0_tags_1) + /sizeof(asn_DEF_Collection_16P0_tags_1[0]), /* 1 */ + asn_DEF_Collection_16P0_tags_1, /* Same as above */ + sizeof(asn_DEF_Collection_16P0_tags_1) + /sizeof(asn_DEF_Collection_16P0_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Collection_16P0_1, + 1, /* Single element */ + &asn_SPC_Collection_16P0_specs_1 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_Collection_16P1_3[] = { + { ATF_POINTER, 0, 0, + .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), + .tag_mode = 0, + .type = &asn_DEF_IA5String, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "" + }, +}; +static ber_tlv_tag_t asn_DEF_Collection_16P1_tags_3[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) +}; +static asn_SET_OF_specifics_t asn_SPC_Collection_16P1_specs_3 = { + sizeof(struct Collection_16P1), + offsetof(struct Collection_16P1, _asn_ctx), + 0, /* XER encoding is XMLDelimitedItemList */ +}; +asn_TYPE_descriptor_t asn_DEF_Collection_16P1 = { + "Collection", + "Collection", + SET_OF_free, + SET_OF_print, + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_decode_xer, + SET_OF_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Collection_16P1_tags_3, + sizeof(asn_DEF_Collection_16P1_tags_3) + /sizeof(asn_DEF_Collection_16P1_tags_3[0]), /* 1 */ + asn_DEF_Collection_16P1_tags_3, /* Same as above */ + sizeof(asn_DEF_Collection_16P1_tags_3) + /sizeof(asn_DEF_Collection_16P1_tags_3[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Collection_16P1_3, + 1, /* Single element */ + &asn_SPC_Collection_16P1_specs_3 /* Additional specs */ +}; + + +/*** <<< INCLUDES [Bunch] >>> ***/ + +#include <Collection.h> +#include <constr_SEQUENCE.h> + +/*** <<< TYPE-DECLS [Bunch] >>> ***/ + +typedef struct Bunch { + Collection_16P0_t field_REAL; + Collection_16P1_t field_IA5String; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} Bunch_t; + +/*** <<< FUNC-DECLS [Bunch] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_Bunch; + +/*** <<< STAT-DEFS [Bunch] >>> ***/ + +static asn_TYPE_member_t asn_MBR_Bunch_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct Bunch, field_REAL), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + .tag_mode = 0, + .type = &asn_DEF_Collection_16P0, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "field-REAL" + }, + { ATF_NOFLAGS, 0, offsetof(struct Bunch, field_IA5String), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + .tag_mode = 0, + .type = &asn_DEF_Collection_16P1, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "field-IA5String" + }, +}; +static ber_tlv_tag_t asn_DEF_Bunch_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn_TYPE_tag2member_t asn_MAP_Bunch_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0, 0, 1 }, /* field-REAL at 17 */ + { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 1, -1, 0 } /* field-IA5String at 18 */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_Bunch_specs_1 = { + sizeof(struct Bunch), + offsetof(struct Bunch, _asn_ctx), + asn_MAP_Bunch_tag2el_1, + 2, /* 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_Bunch = { + "Bunch", + "Bunch", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Bunch_tags_1, + sizeof(asn_DEF_Bunch_tags_1) + /sizeof(asn_DEF_Bunch_tags_1[0]), /* 1 */ + asn_DEF_Bunch_tags_1, /* Same as above */ + sizeof(asn_DEF_Bunch_tags_1) + /sizeof(asn_DEF_Bunch_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Bunch_1, + 2, /* Elements count */ + &asn_SPC_Bunch_specs_1 /* Additional specs */ +}; + diff --git a/tests/105-param-2-OK.asn1 b/tests/105-param-2-OK.asn1 new file mode 100644 index 00000000..eeee4c47 --- /dev/null +++ b/tests/105-param-2-OK.asn1 @@ -0,0 +1,21 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .105 + +ModuleParametrization2 + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 105 } + DEFINITIONS ::= +BEGIN + + SIGNED {Type} ::= SEQUENCE { + signed Type + } + + SignedREAL ::= SIGNED {REAL} + SignedSET ::= SIGNED { SET { a INTEGER } } + +END diff --git a/tests/105-param-2-OK.asn1.-P b/tests/105-param-2-OK.asn1.-P new file mode 100644 index 00000000..009a0773 --- /dev/null +++ b/tests/105-param-2-OK.asn1.-P @@ -0,0 +1,451 @@ + +/*** <<< INCLUDES [SIGNED] >>> ***/ + +#include <REAL.h> +#include <constr_SEQUENCE.h> +#include <INTEGER.h> +#include <constr_SET.h> + +/*** <<< DEPS [SIGNED] >>> ***/ + + +/* + * Method of determining the components presence + */ +typedef enum signed_PR { + signed_PR_a, /* Member a is present */ +} signed_PR; + +/*** <<< TYPE-DECLS [SIGNED] >>> ***/ + +typedef struct SIGNED_16P0 { + REAL_t Signed; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} SIGNED_16P0_t; +typedef struct SIGNED_16P1 { + struct Signed { + INTEGER_t a; + + /* Presence bitmask: ASN_SET_ISPRESENT(psigned, signed_PR_x) */ + unsigned int _presence_map + [((1+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))]; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; + } Signed; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} SIGNED_16P1_t; + +/*** <<< FUNC-DECLS [SIGNED] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_SIGNED_16P0; +extern asn_TYPE_descriptor_t asn_DEF_SIGNED_16P1; + +/*** <<< STAT-DEFS [SIGNED] >>> ***/ + +static asn_TYPE_member_t asn_MBR_SIGNED_16P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct SIGNED_16P0, Signed), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), + .tag_mode = 0, + .type = &asn_DEF_REAL, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "signed" + }, +}; +static ber_tlv_tag_t asn_DEF_SIGNED_16P0_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn_TYPE_tag2member_t asn_MAP_SIGNED_16P0_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)), 0, 0, 0 } /* signed at 18 */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_16P0_specs_1 = { + sizeof(struct SIGNED_16P0), + offsetof(struct SIGNED_16P0, _asn_ctx), + asn_MAP_SIGNED_16P0_tag2el_1, + 1, /* 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_SIGNED_16P0 = { + "SIGNED", + "SIGNED", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_SIGNED_16P0_tags_1, + sizeof(asn_DEF_SIGNED_16P0_tags_1) + /sizeof(asn_DEF_SIGNED_16P0_tags_1[0]), /* 1 */ + asn_DEF_SIGNED_16P0_tags_1, /* Same as above */ + sizeof(asn_DEF_SIGNED_16P0_tags_1) + /sizeof(asn_DEF_SIGNED_16P0_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_SIGNED_16P0_1, + 1, /* Elements count */ + &asn_SPC_SIGNED_16P0_specs_1 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_signed_4[] = { + { ATF_NOFLAGS, 0, offsetof(struct Signed, a), + .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 = "a" + }, +}; +static ber_tlv_tag_t asn_DEF_signed_tags_4[] = { + (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)) +}; +static asn_TYPE_tag2member_t asn_MAP_signed_tag2el_4[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* a at 19 */ +}; +static uint8_t asn_MAP_signed_mmap_4[(1 + (8 * sizeof(unsigned int)) - 1) / 8] = { + (1 << 7) +}; +static asn_SET_specifics_t asn_SPC_signed_specs_4 = { + sizeof(struct Signed), + offsetof(struct Signed, _asn_ctx), + offsetof(struct Signed, _presence_map), + asn_MAP_signed_tag2el_4, + 1, /* Count of tags in the map */ + asn_MAP_signed_tag2el_4, /* Same as above */ + 1, /* Count of tags in the CXER map */ + 0, /* Whether extensible */ + (unsigned int *)asn_MAP_signed_mmap_4 /* Mandatory elements map */ +}; +static /* Use -fall-defs-global to expose */ +asn_TYPE_descriptor_t asn_DEF_signed_4 = { + "signed", + "signed", + SET_free, + SET_print, + SET_constraint, + SET_decode_ber, + SET_encode_der, + SET_decode_xer, + SET_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_signed_tags_4, + sizeof(asn_DEF_signed_tags_4) + /sizeof(asn_DEF_signed_tags_4[0]), /* 1 */ + asn_DEF_signed_tags_4, /* Same as above */ + sizeof(asn_DEF_signed_tags_4) + /sizeof(asn_DEF_signed_tags_4[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_signed_4, + 1, /* Elements count */ + &asn_SPC_signed_specs_4 /* Additional specs */ +}; + +static asn_TYPE_member_t asn_MBR_SIGNED_16P1_3[] = { + { ATF_NOFLAGS, 0, offsetof(struct SIGNED_16P1, Signed), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), + .tag_mode = 0, + .type = &asn_DEF_signed_4, + .memb_constraints = 0, /* Defer constraints checking to the member type */ + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "signed" + }, +}; +static ber_tlv_tag_t asn_DEF_SIGNED_16P1_tags_3[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn_TYPE_tag2member_t asn_MAP_SIGNED_16P1_tag2el_3[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)), 0, 0, 0 } /* signed at 19 */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_16P1_specs_3 = { + sizeof(struct SIGNED_16P1), + offsetof(struct SIGNED_16P1, _asn_ctx), + asn_MAP_SIGNED_16P1_tag2el_3, + 1, /* 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_SIGNED_16P1 = { + "SIGNED", + "SIGNED", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_SIGNED_16P1_tags_3, + sizeof(asn_DEF_SIGNED_16P1_tags_3) + /sizeof(asn_DEF_SIGNED_16P1_tags_3[0]), /* 1 */ + asn_DEF_SIGNED_16P1_tags_3, /* Same as above */ + sizeof(asn_DEF_SIGNED_16P1_tags_3) + /sizeof(asn_DEF_SIGNED_16P1_tags_3[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_SIGNED_16P1_3, + 1, /* Elements count */ + &asn_SPC_SIGNED_16P1_specs_3 /* Additional specs */ +}; + + +/*** <<< INCLUDES [SignedREAL] >>> ***/ + +#include <SIGNED.h> + +/*** <<< TYPE-DECLS [SignedREAL] >>> ***/ + +typedef SIGNED_16P0_t SignedREAL_t; + +/*** <<< FUNC-DECLS [SignedREAL] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_SignedREAL; +asn_struct_free_f SignedREAL_free; +asn_struct_print_f SignedREAL_print; +asn_constr_check_f SignedREAL_constraint; +ber_type_decoder_f SignedREAL_decode_ber; +der_type_encoder_f SignedREAL_encode_der; +xer_type_decoder_f SignedREAL_decode_xer; +xer_type_encoder_f SignedREAL_encode_xer; + +/*** <<< CODE [SignedREAL] >>> ***/ + +int +SignedREAL_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + /* Replace with underlying type checker */ + td->check_constraints = asn_DEF_SIGNED_16P0.check_constraints; + return td->check_constraints(td, sptr, app_errlog, app_key); +} + +/* + * This type is implemented using SIGNED_16P0, + * so here we adjust the DEF accordingly. + */ +static void +SignedREAL_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { + td->free_struct = asn_DEF_SIGNED_16P0.free_struct; + td->print_struct = asn_DEF_SIGNED_16P0.print_struct; + td->ber_decoder = asn_DEF_SIGNED_16P0.ber_decoder; + td->der_encoder = asn_DEF_SIGNED_16P0.der_encoder; + td->xer_decoder = asn_DEF_SIGNED_16P0.xer_decoder; + td->xer_encoder = asn_DEF_SIGNED_16P0.xer_encoder; + td->uper_decoder = asn_DEF_SIGNED_16P0.uper_decoder; + if(!td->per_constraints) + td->per_constraints = asn_DEF_SIGNED_16P0.per_constraints; + td->elements = asn_DEF_SIGNED_16P0.elements; + td->elements_count = asn_DEF_SIGNED_16P0.elements_count; + td->specifics = asn_DEF_SIGNED_16P0.specifics; +} + +void +SignedREAL_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + SignedREAL_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +SignedREAL_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + SignedREAL_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +SignedREAL_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const void *bufptr, size_t size, int tag_mode) { + SignedREAL_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +SignedREAL_encode_der(asn_TYPE_descriptor_t *td, + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + SignedREAL_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +SignedREAL_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const char *opt_mname, const void *bufptr, size_t size) { + SignedREAL_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +SignedREAL_encode_xer(asn_TYPE_descriptor_t *td, void *structure, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + SignedREAL_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [SignedREAL] >>> ***/ + +static ber_tlv_tag_t asn_DEF_SignedREAL_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_SignedREAL = { + "SignedREAL", + "SignedREAL", + SignedREAL_free, + SignedREAL_print, + SignedREAL_constraint, + SignedREAL_decode_ber, + SignedREAL_encode_der, + SignedREAL_decode_xer, + SignedREAL_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_SignedREAL_tags_1, + sizeof(asn_DEF_SignedREAL_tags_1) + /sizeof(asn_DEF_SignedREAL_tags_1[0]), /* 1 */ + asn_DEF_SignedREAL_tags_1, /* Same as above */ + sizeof(asn_DEF_SignedREAL_tags_1) + /sizeof(asn_DEF_SignedREAL_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + + +/*** <<< INCLUDES [SignedSET] >>> ***/ + +#include <SIGNED.h> + +/*** <<< TYPE-DECLS [SignedSET] >>> ***/ + +typedef SIGNED_16P1_t SignedSET_t; + +/*** <<< FUNC-DECLS [SignedSET] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_SignedSET; +asn_struct_free_f SignedSET_free; +asn_struct_print_f SignedSET_print; +asn_constr_check_f SignedSET_constraint; +ber_type_decoder_f SignedSET_decode_ber; +der_type_encoder_f SignedSET_encode_der; +xer_type_decoder_f SignedSET_decode_xer; +xer_type_encoder_f SignedSET_encode_xer; + +/*** <<< CODE [SignedSET] >>> ***/ + +int +SignedSET_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + /* Replace with underlying type checker */ + td->check_constraints = asn_DEF_SIGNED_16P1.check_constraints; + return td->check_constraints(td, sptr, app_errlog, app_key); +} + +/* + * This type is implemented using SIGNED_16P1, + * so here we adjust the DEF accordingly. + */ +static void +SignedSET_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { + td->free_struct = asn_DEF_SIGNED_16P1.free_struct; + td->print_struct = asn_DEF_SIGNED_16P1.print_struct; + td->ber_decoder = asn_DEF_SIGNED_16P1.ber_decoder; + td->der_encoder = asn_DEF_SIGNED_16P1.der_encoder; + td->xer_decoder = asn_DEF_SIGNED_16P1.xer_decoder; + td->xer_encoder = asn_DEF_SIGNED_16P1.xer_encoder; + td->uper_decoder = asn_DEF_SIGNED_16P1.uper_decoder; + if(!td->per_constraints) + td->per_constraints = asn_DEF_SIGNED_16P1.per_constraints; + td->elements = asn_DEF_SIGNED_16P1.elements; + td->elements_count = asn_DEF_SIGNED_16P1.elements_count; + td->specifics = asn_DEF_SIGNED_16P1.specifics; +} + +void +SignedSET_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + SignedSET_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +SignedSET_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + SignedSET_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +SignedSET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const void *bufptr, size_t size, int tag_mode) { + SignedSET_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +SignedSET_encode_der(asn_TYPE_descriptor_t *td, + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + SignedSET_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +SignedSET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const char *opt_mname, const void *bufptr, size_t size) { + SignedSET_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +SignedSET_encode_xer(asn_TYPE_descriptor_t *td, void *structure, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + SignedSET_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [SignedSET] >>> ***/ + +static ber_tlv_tag_t asn_DEF_SignedSET_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_SignedSET = { + "SignedSET", + "SignedSET", + SignedSET_free, + SignedSET_print, + SignedSET_constraint, + SignedSET_decode_ber, + SignedSET_encode_der, + SignedSET_decode_xer, + SignedSET_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_SignedSET_tags_1, + sizeof(asn_DEF_SignedSET_tags_1) + /sizeof(asn_DEF_SignedSET_tags_1[0]), /* 1 */ + asn_DEF_SignedSET_tags_1, /* Same as above */ + sizeof(asn_DEF_SignedSET_tags_1) + /sizeof(asn_DEF_SignedSET_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + diff --git a/tests/106-param-constr-OK.asn1 b/tests/106-param-constr-OK.asn1 new file mode 100644 index 00000000..196b3d7d --- /dev/null +++ b/tests/106-param-constr-OK.asn1 @@ -0,0 +1,20 @@ + +-- OK: Everything is fine + +-- iso.org.dod.internet.private.enterprise (1.3.6.1.4.1) +-- .spelio.software.asn1c.test (9363.1.5.1) +-- .106 + +ModuleParametrizationWithConstraints + { iso org(3) dod(6) internet (1) private(4) enterprise(1) + spelio(9363) software(1) asn1c(5) test(1) 106 } + DEFINITIONS ::= +BEGIN + + Narrow {Type} ::= SEQUENCE { + narrower Type (2..5) + } + + NarrowInteger ::= Narrow {INTEGER (0..10)} + +END diff --git a/tests/106-param-constr-OK.asn1.-P b/tests/106-param-constr-OK.asn1.-P new file mode 100644 index 00000000..49046200 --- /dev/null +++ b/tests/106-param-constr-OK.asn1.-P @@ -0,0 +1,222 @@ + +/*** <<< INCLUDES [Narrow] >>> ***/ + +#include <NativeInteger.h> +#include <constr_SEQUENCE.h> + +/*** <<< TYPE-DECLS [Narrow] >>> ***/ + +typedef struct Narrow_16P0 { + long narrower; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} Narrow_16P0_t; + +/*** <<< FUNC-DECLS [Narrow] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_Narrow_16P0; + +/*** <<< CODE [Narrow] >>> ***/ + +static int +memb_narrower_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + long value; + + if(!sptr) { + _ASN_ERRLOG(app_errlog, app_key, + "%s: value not given (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } + + value = *(const long *)sptr; + + if((value >= 2 && value <= 5)) { + /* Constraint check succeeded */ + return 0; + } else { + _ASN_ERRLOG(app_errlog, app_key, + "%s: constraint failed (%s:%d)", + td->name, __FILE__, __LINE__); + return -1; + } +} + + +/*** <<< STAT-DEFS [Narrow] >>> ***/ + +static asn_TYPE_member_t asn_MBR_Narrow_16P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct Narrow_16P0, narrower), + .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), + .tag_mode = 0, + .type = &asn_DEF_NativeInteger, + .memb_constraints = memb_narrower_constraint_1, + .per_constraints = 0, /* PER is not compiled, use -gen-PER */ + .default_value = 0, + .name = "narrower" + }, +}; +static ber_tlv_tag_t asn_DEF_Narrow_16P0_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +static asn_TYPE_tag2member_t asn_MAP_Narrow_16P0_tag2el_1[] = { + { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* narrower at 18 */ +}; +static asn_SEQUENCE_specifics_t asn_SPC_Narrow_16P0_specs_1 = { + sizeof(struct Narrow_16P0), + offsetof(struct Narrow_16P0, _asn_ctx), + asn_MAP_Narrow_16P0_tag2el_1, + 1, /* 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_Narrow_16P0 = { + "Narrow", + "Narrow", + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_Narrow_16P0_tags_1, + sizeof(asn_DEF_Narrow_16P0_tags_1) + /sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */ + asn_DEF_Narrow_16P0_tags_1, /* Same as above */ + sizeof(asn_DEF_Narrow_16P0_tags_1) + /sizeof(asn_DEF_Narrow_16P0_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_Narrow_16P0_1, + 1, /* Elements count */ + &asn_SPC_Narrow_16P0_specs_1 /* Additional specs */ +}; + + +/*** <<< INCLUDES [NarrowInteger] >>> ***/ + +#include <Narrow.h> + +/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/ + +typedef Narrow_16P0_t NarrowInteger_t; + +/*** <<< FUNC-DECLS [NarrowInteger] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger; +asn_struct_free_f NarrowInteger_free; +asn_struct_print_f NarrowInteger_print; +asn_constr_check_f NarrowInteger_constraint; +ber_type_decoder_f NarrowInteger_decode_ber; +der_type_encoder_f NarrowInteger_encode_der; +xer_type_decoder_f NarrowInteger_decode_xer; +xer_type_encoder_f NarrowInteger_encode_xer; + +/*** <<< CODE [NarrowInteger] >>> ***/ + +int +NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + /* Replace with underlying type checker */ + td->check_constraints = asn_DEF_Narrow_16P0.check_constraints; + return td->check_constraints(td, sptr, app_errlog, app_key); +} + +/* + * This type is implemented using Narrow_16P0, + * so here we adjust the DEF accordingly. + */ +static void +NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { + td->free_struct = asn_DEF_Narrow_16P0.free_struct; + td->print_struct = asn_DEF_Narrow_16P0.print_struct; + td->ber_decoder = asn_DEF_Narrow_16P0.ber_decoder; + td->der_encoder = asn_DEF_Narrow_16P0.der_encoder; + td->xer_decoder = asn_DEF_Narrow_16P0.xer_decoder; + td->xer_encoder = asn_DEF_Narrow_16P0.xer_encoder; + td->uper_decoder = asn_DEF_Narrow_16P0.uper_decoder; + if(!td->per_constraints) + td->per_constraints = asn_DEF_Narrow_16P0.per_constraints; + td->elements = asn_DEF_Narrow_16P0.elements; + td->elements_count = asn_DEF_Narrow_16P0.elements_count; + td->specifics = asn_DEF_Narrow_16P0.specifics; +} + +void +NarrowInteger_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const void *bufptr, size_t size, int tag_mode) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +NarrowInteger_encode_der(asn_TYPE_descriptor_t *td, + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const char *opt_mname, const void *bufptr, size_t size) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + NarrowInteger_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [NarrowInteger] >>> ***/ + +static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_NarrowInteger = { + "NarrowInteger", + "NarrowInteger", + NarrowInteger_free, + NarrowInteger_print, + NarrowInteger_constraint, + NarrowInteger_decode_ber, + NarrowInteger_encode_der, + NarrowInteger_decode_xer, + NarrowInteger_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ + asn_DEF_NarrowInteger_tags_1, + sizeof(asn_DEF_NarrowInteger_tags_1) + /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ + asn_DEF_NarrowInteger_tags_1, /* Same as above */ + sizeof(asn_DEF_NarrowInteger_tags_1) + /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ +}; + diff --git a/tests/19-param-OK.asn1.-EF b/tests/19-param-OK.asn1.-EF index c5792127..da640152 100644 --- a/tests/19-param-OK.asn1.-EF +++ b/tests/19-param-OK.asn1.-EF @@ -9,15 +9,11 @@ SIGNED{ToBeSigned} ::= SEQUENCE { signature BIT STRING SIZE(0..256) } -Certificate ::= SEQUENCE { - toBeSigned SEQUENCE { +Certificate ::= SIGNED{ SEQUENCE { version INTEGER, signature OBJECT IDENTIFIER, issuer Name - }, - algorithm OBJECT IDENTIFIER, - signature BIT STRING SIZE(0..256) -} + }} Name ::= SEQUENCE OF RelativeDistinguishedName diff --git a/tests/19-param-OK.asn1.-P b/tests/19-param-OK.asn1.-P index 321e71a2..272cceec 100644 --- a/tests/19-param-OK.asn1.-P +++ b/tests/19-param-OK.asn1.-P @@ -1,5 +1,5 @@ -/*** <<< INCLUDES [Certificate] >>> ***/ +/*** <<< INCLUDES [SIGNED] >>> ***/ #include <OBJECT_IDENTIFIER.h> #include <BIT_STRING.h> @@ -7,9 +7,9 @@ #include <Name.h> #include <constr_SEQUENCE.h> -/*** <<< TYPE-DECLS [Certificate] >>> ***/ +/*** <<< TYPE-DECLS [SIGNED] >>> ***/ -typedef struct Certificate { +typedef struct SIGNED_15P0 { struct toBeSigned { INTEGER_t version; OBJECT_IDENTIFIER_t signature; @@ -23,13 +23,13 @@ typedef struct Certificate { /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; -} Certificate_t; +} SIGNED_15P0_t; -/*** <<< FUNC-DECLS [Certificate] >>> ***/ +/*** <<< FUNC-DECLS [SIGNED] >>> ***/ -extern asn_TYPE_descriptor_t asn_DEF_Certificate; +extern asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0; -/*** <<< CODE [Certificate] >>> ***/ +/*** <<< CODE [SIGNED] >>> ***/ static int memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, @@ -63,7 +63,7 @@ memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, } -/*** <<< STAT-DEFS [Certificate] >>> ***/ +/*** <<< STAT-DEFS [SIGNED] >>> ***/ static asn_TYPE_member_t asn_MBR_toBeSigned_2[] = { { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version), @@ -136,8 +136,8 @@ asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = { &asn_SPC_toBeSigned_specs_2 /* Additional specs */ }; -static asn_TYPE_member_t asn_MBR_Certificate_1[] = { - { ATF_NOFLAGS, 0, offsetof(struct Certificate, toBeSigned), +static asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, toBeSigned), .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), .tag_mode = 0, .type = &asn_DEF_toBeSigned_2, @@ -146,7 +146,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { .default_value = 0, .name = "toBeSigned" }, - { ATF_NOFLAGS, 0, offsetof(struct Certificate, algorithm), + { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, algorithm), .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), .tag_mode = 0, .type = &asn_DEF_OBJECT_IDENTIFIER, @@ -155,7 +155,7 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { .default_value = 0, .name = "algorithm" }, - { ATF_NOFLAGS, 0, offsetof(struct Certificate, signature), + { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, signature), .tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), .tag_mode = 0, .type = &asn_DEF_BIT_STRING, @@ -165,26 +165,26 @@ static asn_TYPE_member_t asn_MBR_Certificate_1[] = { .name = "signature" }, }; -static ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = { +static ber_tlv_tag_t asn_DEF_SIGNED_15P0_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; -static asn_TYPE_tag2member_t asn_MAP_Certificate_tag2el_1[] = { +static asn_TYPE_tag2member_t asn_MAP_SIGNED_15P0_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature at 17 */ { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm at 16 */ { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned at 21 */ }; -static asn_SEQUENCE_specifics_t asn_SPC_Certificate_specs_1 = { - sizeof(struct Certificate), - offsetof(struct Certificate, _asn_ctx), - asn_MAP_Certificate_tag2el_1, +static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1 = { + sizeof(struct SIGNED_15P0), + offsetof(struct SIGNED_15P0, _asn_ctx), + asn_MAP_SIGNED_15P0_tag2el_1, 3, /* 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_Certificate = { - "Certificate", - "Certificate", +asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0 = { + "SIGNED", + "SIGNED", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, @@ -194,6 +194,130 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = { SEQUENCE_encode_xer, 0, /* No PER decoder, -gen-PER to enable */ 0, /* Use generic outmost tag fetcher */ + asn_DEF_SIGNED_15P0_tags_1, + sizeof(asn_DEF_SIGNED_15P0_tags_1) + /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */ + asn_DEF_SIGNED_15P0_tags_1, /* Same as above */ + sizeof(asn_DEF_SIGNED_15P0_tags_1) + /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */ + 0, /* No PER visible constraints */ + asn_MBR_SIGNED_15P0_1, + 3, /* Elements count */ + &asn_SPC_SIGNED_15P0_specs_1 /* Additional specs */ +}; + + +/*** <<< INCLUDES [Certificate] >>> ***/ + +#include <SIGNED.h> + +/*** <<< TYPE-DECLS [Certificate] >>> ***/ + +typedef SIGNED_15P0_t Certificate_t; + +/*** <<< FUNC-DECLS [Certificate] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_Certificate; +asn_struct_free_f Certificate_free; +asn_struct_print_f Certificate_print; +asn_constr_check_f Certificate_constraint; +ber_type_decoder_f Certificate_decode_ber; +der_type_encoder_f Certificate_encode_der; +xer_type_decoder_f Certificate_decode_xer; +xer_type_encoder_f Certificate_encode_xer; + +/*** <<< CODE [Certificate] >>> ***/ + +int +Certificate_constraint(asn_TYPE_descriptor_t *td, const void *sptr, + asn_app_consume_bytes_f *app_errlog, void *app_key) { + /* Replace with underlying type checker */ + td->check_constraints = asn_DEF_SIGNED_15P0.check_constraints; + return td->check_constraints(td, sptr, app_errlog, app_key); +} + +/* + * This type is implemented using SIGNED_15P0, + * so here we adjust the DEF accordingly. + */ +static void +Certificate_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { + td->free_struct = asn_DEF_SIGNED_15P0.free_struct; + td->print_struct = asn_DEF_SIGNED_15P0.print_struct; + td->ber_decoder = asn_DEF_SIGNED_15P0.ber_decoder; + td->der_encoder = asn_DEF_SIGNED_15P0.der_encoder; + td->xer_decoder = asn_DEF_SIGNED_15P0.xer_decoder; + td->xer_encoder = asn_DEF_SIGNED_15P0.xer_encoder; + td->uper_decoder = asn_DEF_SIGNED_15P0.uper_decoder; + if(!td->per_constraints) + td->per_constraints = asn_DEF_SIGNED_15P0.per_constraints; + td->elements = asn_DEF_SIGNED_15P0.elements; + td->elements_count = asn_DEF_SIGNED_15P0.elements_count; + td->specifics = asn_DEF_SIGNED_15P0.specifics; +} + +void +Certificate_free(asn_TYPE_descriptor_t *td, + void *struct_ptr, int contents_only) { + Certificate_1_inherit_TYPE_descriptor(td); + td->free_struct(td, struct_ptr, contents_only); +} + +int +Certificate_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, + int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { + Certificate_1_inherit_TYPE_descriptor(td); + return td->print_struct(td, struct_ptr, ilevel, cb, app_key); +} + +asn_dec_rval_t +Certificate_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const void *bufptr, size_t size, int tag_mode) { + Certificate_1_inherit_TYPE_descriptor(td); + return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); +} + +asn_enc_rval_t +Certificate_encode_der(asn_TYPE_descriptor_t *td, + void *structure, int tag_mode, ber_tlv_tag_t tag, + asn_app_consume_bytes_f *cb, void *app_key) { + Certificate_1_inherit_TYPE_descriptor(td); + return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); +} + +asn_dec_rval_t +Certificate_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, + void **structure, const char *opt_mname, const void *bufptr, size_t size) { + Certificate_1_inherit_TYPE_descriptor(td); + return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size); +} + +asn_enc_rval_t +Certificate_encode_xer(asn_TYPE_descriptor_t *td, void *structure, + int ilevel, enum xer_encoder_flags_e flags, + asn_app_consume_bytes_f *cb, void *app_key) { + Certificate_1_inherit_TYPE_descriptor(td); + return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); +} + + +/*** <<< STAT-DEFS [Certificate] >>> ***/ + +static ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = { + (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) +}; +asn_TYPE_descriptor_t asn_DEF_Certificate = { + "Certificate", + "Certificate", + Certificate_free, + Certificate_print, + Certificate_constraint, + Certificate_decode_ber, + Certificate_encode_der, + Certificate_decode_xer, + Certificate_encode_xer, + 0, /* No PER decoder, -gen-PER to enable */ + 0, /* Use generic outmost tag fetcher */ asn_DEF_Certificate_tags_1, sizeof(asn_DEF_Certificate_tags_1) /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */ @@ -201,9 +325,8 @@ asn_TYPE_descriptor_t asn_DEF_Certificate = { sizeof(asn_DEF_Certificate_tags_1) /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ - asn_MBR_Certificate_1, - 3, /* Elements count */ - &asn_SPC_Certificate_specs_1 /* Additional specs */ + 0, 0, /* Defined elsewhere */ + 0 /* No specifics */ }; diff --git a/tests/58-param-OK.asn1.-EF b/tests/58-param-OK.asn1.-EF index c07b79d4..9258e5b2 100644 --- a/tests/58-param-OK.asn1.-EF +++ b/tests/58-param-OK.asn1.-EF @@ -8,10 +8,7 @@ DirectoryString{INTEGER:maxSize} ::= CHOICE { utf8String UTF8String (SIZE(1..maxSize)) } -DS1 ::= CHOICE { - teletexString TeletexString (SIZE(1..128)), - utf8String UTF8String (SIZE(1..128)) -} +DS1 ::= DirectoryString{ub-name} ub-name INTEGER ::= 128 diff --git a/tests/84-param-tags-OK.asn1.-EF b/tests/84-param-tags-OK.asn1.-EF index 0a902fb0..b5889ae1 100644 --- a/tests/84-param-tags-OK.asn1.-EF +++ b/tests/84-param-tags-OK.asn1.-EF @@ -8,12 +8,8 @@ TestType{Parameter} ::= SEQUENCE { } TestChoice ::= CHOICE { - type1 SEQUENCE { - common INTEGER (1..10) DEFAULT 0 - }, - type2 [0] IMPLICIT SEQUENCE { - common BOOLEAN DEFAULT 0 - } + type1 TestType{ INTEGER (1..10)}, + type2 [0] IMPLICIT TestType{ BOOLEAN} } END @@ -28,12 +24,8 @@ AutoType{Parameter} ::= SEQUENCE { } AutoChoice ::= CHOICE { - type1 [0] IMPLICIT SEQUENCE { - common [0] IMPLICIT INTEGER ((0..1))((0)) - }, - type2 [1] IMPLICIT SEQUENCE { - common [0] IMPLICIT BOOLEAN (0) - } + type1 [0] IMPLICIT AutoType{ INTEGER (0..1)}, + type2 [1] IMPLICIT AutoType{ BOOLEAN} } END diff --git a/tests/84-param-tags-OK.asn1.-P b/tests/84-param-tags-OK.asn1.-P index f7353dbf..8e48c258 100644 --- a/tests/84-param-tags-OK.asn1.-P +++ b/tests/84-param-tags-OK.asn1.-P @@ -1,50 +1,34 @@ -/*** <<< INCLUDES [TestChoice] >>> ***/ +/*** <<< INCLUDES [TestType] >>> ***/ #include <NativeInteger.h> #include <constr_SEQUENCE.h> #include <BOOLEAN.h> -#include <constr_CHOICE.h> -/*** <<< DEPS [TestChoice] >>> ***/ +/*** <<< TYPE-DECLS [TestType] >>> ***/ -typedef enum TestChoice_PR { - TestChoice_PR_NOTHING, /* No components present */ - TestChoice_PR_type1, - TestChoice_PR_type2, -} TestChoice_PR; - -/*** <<< TYPE-DECLS [TestChoice] >>> ***/ - -typedef struct TestChoice { - TestChoice_PR present; - union TestChoice_u { - struct type1 { - long common /* DEFAULT 0 */; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - } type1; - struct type2 { - BOOLEAN_t common /* DEFAULT 0 */; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - } type2; - } choice; +typedef struct TestType_16P0 { + long common; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; -} TestChoice_t; +} TestType_16P0_t; +typedef struct TestType_16P1 { + BOOLEAN_t common; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} TestType_16P1_t; -/*** <<< FUNC-DECLS [TestChoice] >>> ***/ +/*** <<< FUNC-DECLS [TestType] >>> ***/ -extern asn_TYPE_descriptor_t asn_DEF_TestChoice; +extern asn_TYPE_descriptor_t asn_DEF_TestType_16P0; +extern asn_TYPE_descriptor_t asn_DEF_TestType_16P1; -/*** <<< CODE [TestChoice] >>> ***/ +/*** <<< CODE [TestType] >>> ***/ static int -memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr, +memb_common_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { long value; @@ -69,50 +53,37 @@ memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr, } -/*** <<< STAT-DEFS [TestChoice] >>> ***/ +/*** <<< STAT-DEFS [TestType] >>> ***/ -static int asn_DFL_3_set_0(void **sptr) { - long *st = *sptr; - - if(!st) { - st = (*sptr = CALLOC(1, sizeof(*st))); - if(!st) return -1; - } - - /* Install default value 0 */ - *st = 0; - return 0; -} -static asn_TYPE_member_t asn_MBR_type1_2[] = { - { ATF_NOFLAGS, 1, offsetof(struct type1, common), +static asn_TYPE_member_t asn_MBR_TestType_16P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct TestType_16P0, common), .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), .tag_mode = 0, .type = &asn_DEF_NativeInteger, - .memb_constraints = memb_common_constraint_2, + .memb_constraints = memb_common_constraint_1, .per_constraints = 0, /* PER is not compiled, use -gen-PER */ - .default_value = asn_DFL_3_set_0, /* DEFAULT 0 */ + .default_value = 0, .name = "common" }, }; -static ber_tlv_tag_t asn_DEF_type1_tags_2[] = { +static ber_tlv_tag_t asn_DEF_TestType_16P0_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; -static asn_TYPE_tag2member_t asn_MAP_type1_tag2el_2[] = { +static asn_TYPE_tag2member_t asn_MAP_TestType_16P0_tag2el_1[] = { { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* common at 20 */ }; -static asn_SEQUENCE_specifics_t asn_SPC_type1_specs_2 = { - sizeof(struct type1), - offsetof(struct type1, _asn_ctx), - asn_MAP_type1_tag2el_2, +static asn_SEQUENCE_specifics_t asn_SPC_TestType_16P0_specs_1 = { + sizeof(struct TestType_16P0), + offsetof(struct TestType_16P0, _asn_ctx), + asn_MAP_TestType_16P0_tag2el_1, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; -static /* Use -fall-defs-global to expose */ -asn_TYPE_descriptor_t asn_DEF_type1_2 = { - "type1", - "type1", +asn_TYPE_descriptor_t asn_DEF_TestType_16P0 = { + "TestType", + "TestType", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, @@ -122,61 +93,47 @@ asn_TYPE_descriptor_t asn_DEF_type1_2 = { SEQUENCE_encode_xer, 0, /* No PER decoder, -gen-PER to enable */ 0, /* Use generic outmost tag fetcher */ - asn_DEF_type1_tags_2, - sizeof(asn_DEF_type1_tags_2) - /sizeof(asn_DEF_type1_tags_2[0]), /* 1 */ - asn_DEF_type1_tags_2, /* Same as above */ - sizeof(asn_DEF_type1_tags_2) - /sizeof(asn_DEF_type1_tags_2[0]), /* 1 */ + asn_DEF_TestType_16P0_tags_1, + sizeof(asn_DEF_TestType_16P0_tags_1) + /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */ + asn_DEF_TestType_16P0_tags_1, /* Same as above */ + sizeof(asn_DEF_TestType_16P0_tags_1) + /sizeof(asn_DEF_TestType_16P0_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ - asn_MBR_type1_2, + asn_MBR_TestType_16P0_1, 1, /* Elements count */ - &asn_SPC_type1_specs_2 /* Additional specs */ + &asn_SPC_TestType_16P0_specs_1 /* Additional specs */ }; -static int asn_DFL_5_set_0(void **sptr) { - BOOLEAN_t *st = *sptr; - - if(!st) { - st = (*sptr = CALLOC(1, sizeof(*st))); - if(!st) return -1; - } - - /* Install default value 0 */ - *st = 0; - return 0; -} -static asn_TYPE_member_t asn_MBR_type2_4[] = { - { ATF_NOFLAGS, 1, offsetof(struct type2, common), +static asn_TYPE_member_t asn_MBR_TestType_16P1_3[] = { + { ATF_NOFLAGS, 0, offsetof(struct TestType_16P1, common), .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), .tag_mode = 0, .type = &asn_DEF_BOOLEAN, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ - .default_value = asn_DFL_5_set_0, /* DEFAULT 0 */ + .default_value = 0, .name = "common" }, }; -static ber_tlv_tag_t asn_DEF_type2_tags_4[] = { - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), +static ber_tlv_tag_t asn_DEF_TestType_16P1_tags_3[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; -static asn_TYPE_tag2member_t asn_MAP_type2_tag2el_4[] = { +static asn_TYPE_tag2member_t asn_MAP_TestType_16P1_tag2el_3[] = { { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 } /* common at 21 */ }; -static asn_SEQUENCE_specifics_t asn_SPC_type2_specs_4 = { - sizeof(struct type2), - offsetof(struct type2, _asn_ctx), - asn_MAP_type2_tag2el_4, +static asn_SEQUENCE_specifics_t asn_SPC_TestType_16P1_specs_3 = { + sizeof(struct TestType_16P1), + offsetof(struct TestType_16P1, _asn_ctx), + asn_MAP_TestType_16P1_tag2el_3, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; -static /* Use -fall-defs-global to expose */ -asn_TYPE_descriptor_t asn_DEF_type2_4 = { - "type2", - "type2", +asn_TYPE_descriptor_t asn_DEF_TestType_16P1 = { + "TestType", + "TestType", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, @@ -186,23 +143,56 @@ asn_TYPE_descriptor_t asn_DEF_type2_4 = { SEQUENCE_encode_xer, 0, /* No PER decoder, -gen-PER to enable */ 0, /* Use generic outmost tag fetcher */ - asn_DEF_type2_tags_4, - sizeof(asn_DEF_type2_tags_4) - /sizeof(asn_DEF_type2_tags_4[0]) - 1, /* 1 */ - asn_DEF_type2_tags_4, /* Same as above */ - sizeof(asn_DEF_type2_tags_4) - /sizeof(asn_DEF_type2_tags_4[0]), /* 2 */ + asn_DEF_TestType_16P1_tags_3, + sizeof(asn_DEF_TestType_16P1_tags_3) + /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */ + asn_DEF_TestType_16P1_tags_3, /* Same as above */ + sizeof(asn_DEF_TestType_16P1_tags_3) + /sizeof(asn_DEF_TestType_16P1_tags_3[0]), /* 1 */ 0, /* No PER visible constraints */ - asn_MBR_type2_4, + asn_MBR_TestType_16P1_3, 1, /* Elements count */ - &asn_SPC_type2_specs_4 /* Additional specs */ + &asn_SPC_TestType_16P1_specs_3 /* Additional specs */ }; + +/*** <<< INCLUDES [TestChoice] >>> ***/ + +#include <TestType.h> +#include <constr_CHOICE.h> + +/*** <<< DEPS [TestChoice] >>> ***/ + +typedef enum TestChoice_PR { + TestChoice_PR_NOTHING, /* No components present */ + TestChoice_PR_type1, + TestChoice_PR_type2, +} TestChoice_PR; + +/*** <<< TYPE-DECLS [TestChoice] >>> ***/ + +typedef struct TestChoice { + TestChoice_PR present; + union TestChoice_u { + TestType_16P0_t type1; + TestType_16P1_t type2; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} TestChoice_t; + +/*** <<< FUNC-DECLS [TestChoice] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_TestChoice; + +/*** <<< STAT-DEFS [TestChoice] >>> ***/ + static asn_TYPE_member_t asn_MBR_TestChoice_1[] = { { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type1), .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), .tag_mode = 0, - .type = &asn_DEF_type1_2, + .type = &asn_DEF_TestType_16P0, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -211,7 +201,7 @@ static asn_TYPE_member_t asn_MBR_TestChoice_1[] = { { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type2), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_type2_4, + .type = &asn_DEF_TestType_16P1, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -219,8 +209,8 @@ static asn_TYPE_member_t asn_MBR_TestChoice_1[] = { }, }; static asn_TYPE_tag2member_t asn_MAP_TestChoice_tag2el_1[] = { - { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 at 16 */ - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 at 16 */ + { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 at 20 */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 at 21 */ }; static asn_CHOICE_specifics_t asn_SPC_TestChoice_specs_1 = { sizeof(struct TestChoice), @@ -255,52 +245,36 @@ asn_TYPE_descriptor_t asn_DEF_TestChoice = { }; -/*** <<< INCLUDES [AutoChoice] >>> ***/ +/*** <<< INCLUDES [AutoType] >>> ***/ #include <NativeInteger.h> #include <constr_SEQUENCE.h> #include <BOOLEAN.h> -#include <constr_CHOICE.h> -/*** <<< DEPS [AutoChoice] >>> ***/ +/*** <<< TYPE-DECLS [AutoType] >>> ***/ -typedef enum AutoChoice_PR { - AutoChoice_PR_NOTHING, /* No components present */ - AutoChoice_PR_type1, - AutoChoice_PR_type2, -} AutoChoice_PR; - -/*** <<< TYPE-DECLS [AutoChoice] >>> ***/ - -typedef struct AutoChoice { - AutoChoice_PR present; - union AutoChoice_u { - struct type1 { - long common; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - } type1; - struct type2 { - BOOLEAN_t common; - - /* Context for parsing across buffer boundaries */ - asn_struct_ctx_t _asn_ctx; - } type2; - } choice; +typedef struct AutoType_34P0 { + long common; /* Context for parsing across buffer boundaries */ asn_struct_ctx_t _asn_ctx; -} AutoChoice_t; +} AutoType_34P0_t; +typedef struct AutoType_34P1 { + BOOLEAN_t common; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} AutoType_34P1_t; -/*** <<< FUNC-DECLS [AutoChoice] >>> ***/ +/*** <<< FUNC-DECLS [AutoType] >>> ***/ -extern asn_TYPE_descriptor_t asn_DEF_AutoChoice; +extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P0; +extern asn_TYPE_descriptor_t asn_DEF_AutoType_34P1; -/*** <<< CODE [AutoChoice] >>> ***/ +/*** <<< CODE [AutoType] >>> ***/ static int -memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr, +memb_common_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { long value; @@ -325,7 +299,7 @@ memb_common_constraint_2(asn_TYPE_descriptor_t *td, const void *sptr, } static int -memb_common_constraint_4(asn_TYPE_descriptor_t *td, const void *sptr, +memb_common_constraint_3(asn_TYPE_descriptor_t *td, const void *sptr, asn_app_consume_bytes_f *app_errlog, void *app_key) { BOOLEAN_t value; @@ -350,39 +324,37 @@ memb_common_constraint_4(asn_TYPE_descriptor_t *td, const void *sptr, } -/*** <<< STAT-DEFS [AutoChoice] >>> ***/ +/*** <<< STAT-DEFS [AutoType] >>> ***/ -static asn_TYPE_member_t asn_MBR_type1_2[] = { - { ATF_NOFLAGS, 0, offsetof(struct type1, common), +static asn_TYPE_member_t asn_MBR_AutoType_34P0_1[] = { + { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P0, common), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ .type = &asn_DEF_NativeInteger, - .memb_constraints = memb_common_constraint_2, + .memb_constraints = memb_common_constraint_1, .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, .name = "common" }, }; -static ber_tlv_tag_t asn_DEF_type1_tags_2[] = { - (ASN_TAG_CLASS_CONTEXT | (0 << 2)), +static ber_tlv_tag_t asn_DEF_AutoType_34P0_tags_1[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; -static asn_TYPE_tag2member_t asn_MAP_type1_tag2el_2[] = { +static asn_TYPE_tag2member_t asn_MAP_AutoType_34P0_tag2el_1[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 37 */ }; -static asn_SEQUENCE_specifics_t asn_SPC_type1_specs_2 = { - sizeof(struct type1), - offsetof(struct type1, _asn_ctx), - asn_MAP_type1_tag2el_2, +static asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P0_specs_1 = { + sizeof(struct AutoType_34P0), + offsetof(struct AutoType_34P0, _asn_ctx), + asn_MAP_AutoType_34P0_tag2el_1, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; -static /* Use -fall-defs-global to expose */ -asn_TYPE_descriptor_t asn_DEF_type1_2 = { - "type1", - "type1", +asn_TYPE_descriptor_t asn_DEF_AutoType_34P0 = { + "AutoType", + "AutoType", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, @@ -392,49 +364,47 @@ asn_TYPE_descriptor_t asn_DEF_type1_2 = { SEQUENCE_encode_xer, 0, /* No PER decoder, -gen-PER to enable */ 0, /* Use generic outmost tag fetcher */ - asn_DEF_type1_tags_2, - sizeof(asn_DEF_type1_tags_2) - /sizeof(asn_DEF_type1_tags_2[0]) - 1, /* 1 */ - asn_DEF_type1_tags_2, /* Same as above */ - sizeof(asn_DEF_type1_tags_2) - /sizeof(asn_DEF_type1_tags_2[0]), /* 2 */ + asn_DEF_AutoType_34P0_tags_1, + sizeof(asn_DEF_AutoType_34P0_tags_1) + /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */ + asn_DEF_AutoType_34P0_tags_1, /* Same as above */ + sizeof(asn_DEF_AutoType_34P0_tags_1) + /sizeof(asn_DEF_AutoType_34P0_tags_1[0]), /* 1 */ 0, /* No PER visible constraints */ - asn_MBR_type1_2, + asn_MBR_AutoType_34P0_1, 1, /* Elements count */ - &asn_SPC_type1_specs_2 /* Additional specs */ + &asn_SPC_AutoType_34P0_specs_1 /* Additional specs */ }; -static asn_TYPE_member_t asn_MBR_type2_4[] = { - { ATF_NOFLAGS, 0, offsetof(struct type2, common), +static asn_TYPE_member_t asn_MBR_AutoType_34P1_3[] = { + { ATF_NOFLAGS, 0, offsetof(struct AutoType_34P1, common), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ .type = &asn_DEF_BOOLEAN, - .memb_constraints = memb_common_constraint_4, + .memb_constraints = memb_common_constraint_3, .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, .name = "common" }, }; -static ber_tlv_tag_t asn_DEF_type2_tags_4[] = { - (ASN_TAG_CLASS_CONTEXT | (1 << 2)), +static ber_tlv_tag_t asn_DEF_AutoType_34P1_tags_3[] = { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) }; -static asn_TYPE_tag2member_t asn_MAP_type2_tag2el_4[] = { +static asn_TYPE_tag2member_t asn_MAP_AutoType_34P1_tag2el_3[] = { { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 38 */ }; -static asn_SEQUENCE_specifics_t asn_SPC_type2_specs_4 = { - sizeof(struct type2), - offsetof(struct type2, _asn_ctx), - asn_MAP_type2_tag2el_4, +static asn_SEQUENCE_specifics_t asn_SPC_AutoType_34P1_specs_3 = { + sizeof(struct AutoType_34P1), + offsetof(struct AutoType_34P1, _asn_ctx), + asn_MAP_AutoType_34P1_tag2el_3, 1, /* Count of tags in the map */ 0, 0, 0, /* Optional elements (not needed) */ -1, /* Start extensions */ -1 /* Stop extensions */ }; -static /* Use -fall-defs-global to expose */ -asn_TYPE_descriptor_t asn_DEF_type2_4 = { - "type2", - "type2", +asn_TYPE_descriptor_t asn_DEF_AutoType_34P1 = { + "AutoType", + "AutoType", SEQUENCE_free, SEQUENCE_print, SEQUENCE_constraint, @@ -444,23 +414,56 @@ asn_TYPE_descriptor_t asn_DEF_type2_4 = { SEQUENCE_encode_xer, 0, /* No PER decoder, -gen-PER to enable */ 0, /* Use generic outmost tag fetcher */ - asn_DEF_type2_tags_4, - sizeof(asn_DEF_type2_tags_4) - /sizeof(asn_DEF_type2_tags_4[0]) - 1, /* 1 */ - asn_DEF_type2_tags_4, /* Same as above */ - sizeof(asn_DEF_type2_tags_4) - /sizeof(asn_DEF_type2_tags_4[0]), /* 2 */ + asn_DEF_AutoType_34P1_tags_3, + sizeof(asn_DEF_AutoType_34P1_tags_3) + /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */ + asn_DEF_AutoType_34P1_tags_3, /* Same as above */ + sizeof(asn_DEF_AutoType_34P1_tags_3) + /sizeof(asn_DEF_AutoType_34P1_tags_3[0]), /* 1 */ 0, /* No PER visible constraints */ - asn_MBR_type2_4, + asn_MBR_AutoType_34P1_3, 1, /* Elements count */ - &asn_SPC_type2_specs_4 /* Additional specs */ + &asn_SPC_AutoType_34P1_specs_3 /* Additional specs */ }; + +/*** <<< INCLUDES [AutoChoice] >>> ***/ + +#include <AutoType.h> +#include <constr_CHOICE.h> + +/*** <<< DEPS [AutoChoice] >>> ***/ + +typedef enum AutoChoice_PR { + AutoChoice_PR_NOTHING, /* No components present */ + AutoChoice_PR_type1, + AutoChoice_PR_type2, +} AutoChoice_PR; + +/*** <<< TYPE-DECLS [AutoChoice] >>> ***/ + +typedef struct AutoChoice { + AutoChoice_PR present; + union AutoChoice_u { + AutoType_34P0_t type1; + AutoType_34P1_t type2; + } choice; + + /* Context for parsing across buffer boundaries */ + asn_struct_ctx_t _asn_ctx; +} AutoChoice_t; + +/*** <<< FUNC-DECLS [AutoChoice] >>> ***/ + +extern asn_TYPE_descriptor_t asn_DEF_AutoChoice; + +/*** <<< STAT-DEFS [AutoChoice] >>> ***/ + static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = { { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type1), .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_type1_2, + .type = &asn_DEF_AutoType_34P0, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -469,7 +472,7 @@ static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = { { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type2), .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)), .tag_mode = -1, /* IMPLICIT tag at current level */ - .type = &asn_DEF_type2_4, + .type = &asn_DEF_AutoType_34P1, .memb_constraints = 0, /* Defer constraints checking to the member type */ .per_constraints = 0, /* PER is not compiled, use -gen-PER */ .default_value = 0, @@ -477,8 +480,8 @@ static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = { }, }; static asn_TYPE_tag2member_t asn_MAP_AutoChoice_tag2el_1[] = { - { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 at 34 */ - { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 at 34 */ + { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 at 37 */ + { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 at 38 */ }; static asn_CHOICE_specifics_t asn_SPC_AutoChoice_specs_1 = { sizeof(struct AutoChoice), |