diff options
author | Bi-Ruei, Chiu <biruei.chiu@gmail.com> | 2017-08-20 01:25:45 +0800 |
---|---|---|
committer | Bi-Ruei, Chiu <biruei.chiu@gmail.com> | 2017-08-24 14:09:28 +0800 |
commit | 1f87ac0058bdf5345cc8dff5d98df09405e3dd2c (patch) | |
tree | 03f0e3f57b698d7b0f0d8dcc9a71e7c1041b305f /skeletons | |
parent | fadb26aaf14e07accdee7b656bda36644a91d7ad (diff) |
Move type operations to another structure
Every type has free, print, check_constraints, ber_decoder, der_encoder,
xer_decoder, xer_encoder, uper_decoder, uper_encoder and outmost_tag
operations. We move them out to a separate structure asn_TYPE_operation_t.
Combined with previous logic simplification, these operations are based
on ASN.1 basic types, constructed types and string types. So we can
reduce the space occupied by asn_TYPE_descriptor_t variables.
Diffstat (limited to 'skeletons')
87 files changed, 595 insertions, 307 deletions
diff --git a/skeletons/ANY.c b/skeletons/ANY.c index 082f3dfd..2742aadb 100644 --- a/skeletons/ANY.c +++ b/skeletons/ANY.c @@ -11,9 +11,7 @@ asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs = { offsetof(ANY_t, _asn_ctx), ASN_OSUBV_ANY }; -asn_TYPE_descriptor_t asn_DEF_ANY = { - "ANY", - "ANY", +asn_TYPE_operation_t asn_OP_ANY = { OCTET_STRING_free, OCTET_STRING_print, OCTET_STRING_compare, @@ -32,10 +30,16 @@ asn_TYPE_descriptor_t asn_DEF_ANY = { #ifdef ASN_DISABLE_PER_SUPPORT 0, 0, #else - ANY_decode_uper, - ANY_encode_uper, + ANY_decode_uper, + ANY_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_ANY = { + "ANY", + "ANY", + &asn_OP_ANY, + asn_generic_no_constraint, 0, 0, 0, 0, 0, /* No OER visible constraints */ 0, /* No PER visible constraints */ diff --git a/skeletons/ANY.h b/skeletons/ANY.h index 9cc09561..7d5f369c 100644 --- a/skeletons/ANY.h +++ b/skeletons/ANY.h @@ -19,6 +19,7 @@ typedef struct ANY { } ANY_t; extern asn_TYPE_descriptor_t asn_DEF_ANY; +extern asn_TYPE_operation_t asn_OP_ANY; extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs; asn_struct_free_f ANY_free; diff --git a/skeletons/BIT_STRING.c b/skeletons/BIT_STRING.c index d87f0d46..7e9b82c4 100644 --- a/skeletons/BIT_STRING.c +++ b/skeletons/BIT_STRING.c @@ -17,9 +17,7 @@ asn_OCTET_STRING_specifics_t asn_SPC_BIT_STRING_specs = { offsetof(BIT_STRING_t, _asn_ctx), ASN_OSUBV_BIT }; -asn_TYPE_descriptor_t asn_DEF_BIT_STRING = { - "BIT STRING", - "BIT_STRING", +asn_TYPE_operation_t asn_OP_BIT_STRING = { OCTET_STRING_free, /* Implemented in terms of OCTET STRING */ BIT_STRING_print, BIT_STRING_compare, @@ -42,7 +40,13 @@ asn_TYPE_descriptor_t asn_DEF_BIT_STRING = { OCTET_STRING_decode_uper, /* Unaligned PER decoder */ OCTET_STRING_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_BIT_STRING = { + "BIT STRING", + "BIT_STRING", + &asn_OP_BIT_STRING, + BIT_STRING_constraint, asn_DEF_BIT_STRING_tags, sizeof(asn_DEF_BIT_STRING_tags) / sizeof(asn_DEF_BIT_STRING_tags[0]), diff --git a/skeletons/BIT_STRING.h b/skeletons/BIT_STRING.h index d66c88ec..ed3d108b 100644 --- a/skeletons/BIT_STRING.h +++ b/skeletons/BIT_STRING.h @@ -21,6 +21,7 @@ typedef struct BIT_STRING_s { } BIT_STRING_t; extern asn_TYPE_descriptor_t asn_DEF_BIT_STRING; +extern asn_TYPE_operation_t asn_OP_BIT_STRING; extern asn_OCTET_STRING_specifics_t asn_SPC_BIT_STRING_specs; asn_struct_print_f BIT_STRING_print; /* Human-readable output */ diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c index 5fffc786..5af66a1e 100644 --- a/skeletons/BMPString.c +++ b/skeletons/BMPString.c @@ -23,9 +23,7 @@ static asn_per_constraints_t asn_DEF_BMPString_per_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_BMPString = { - "BMPString", - "BMPString", +asn_TYPE_operation_t asn_OP_BMPString = { OCTET_STRING_free, /* Implemented in terms of OCTET STRING */ BMPString_print, OCTET_STRING_compare, @@ -48,7 +46,13 @@ asn_TYPE_descriptor_t asn_DEF_BMPString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_BMPString = { + "BMPString", + "BMPString", + &asn_OP_BMPString, + asn_generic_no_constraint, /* No constraint by default */ asn_DEF_BMPString_tags, sizeof(asn_DEF_BMPString_tags) / sizeof(asn_DEF_BMPString_tags[0]) - 1, diff --git a/skeletons/BMPString.h b/skeletons/BMPString.h index a3c5ef6a..198b9e5e 100644 --- a/skeletons/BMPString.h +++ b/skeletons/BMPString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t BMPString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_BMPString; +extern asn_TYPE_operation_t asn_OP_BMPString; extern asn_OCTET_STRING_specifics_t asn_SPC_BMPString_specs; asn_struct_print_f BMPString_print; /* Human-readable output */ diff --git a/skeletons/BOOLEAN.c b/skeletons/BOOLEAN.c index ffad24eb..7ef75da6 100644 --- a/skeletons/BOOLEAN.c +++ b/skeletons/BOOLEAN.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_BOOLEAN_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_BOOLEAN = { - "BOOLEAN", - "BOOLEAN", +asn_TYPE_operation_t asn_OP_BOOLEAN = { BOOLEAN_free, BOOLEAN_print, BOOLEAN_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_BOOLEAN = { BOOLEAN_decode_uper, /* Unaligned PER decoder */ BOOLEAN_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_BOOLEAN = { + "BOOLEAN", + "BOOLEAN", + &asn_OP_BOOLEAN, + asn_generic_no_constraint, asn_DEF_BOOLEAN_tags, sizeof(asn_DEF_BOOLEAN_tags) / sizeof(asn_DEF_BOOLEAN_tags[0]), asn_DEF_BOOLEAN_tags, /* Same as above */ diff --git a/skeletons/BOOLEAN.h b/skeletons/BOOLEAN.h index a35e7995..b399b3e1 100644 --- a/skeletons/BOOLEAN.h +++ b/skeletons/BOOLEAN.h @@ -19,6 +19,7 @@ extern "C" { typedef int BOOLEAN_t; extern asn_TYPE_descriptor_t asn_DEF_BOOLEAN; +extern asn_TYPE_operation_t asn_OP_BOOLEAN; asn_struct_free_f BOOLEAN_free; asn_struct_print_f BOOLEAN_print; diff --git a/skeletons/ENUMERATED.c b/skeletons/ENUMERATED.c index 153ce150..1785b92e 100644 --- a/skeletons/ENUMERATED.c +++ b/skeletons/ENUMERATED.c @@ -14,9 +14,7 @@ static const ber_tlv_tag_t asn_DEF_ENUMERATED_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_ENUMERATED = { - "ENUMERATED", - "ENUMERATED", +asn_TYPE_operation_t asn_OP_ENUMERATED = { ASN__PRIMITIVE_TYPE_free, INTEGER_print, /* Implemented in terms of INTEGER */ INTEGER_compare, /* Implemented in terms of INTEGER */ @@ -39,7 +37,13 @@ asn_TYPE_descriptor_t asn_DEF_ENUMERATED = { ENUMERATED_decode_uper, /* Unaligned PER decoder */ ENUMERATED_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_ENUMERATED = { + "ENUMERATED", + "ENUMERATED", + &asn_OP_ENUMERATED, + asn_generic_no_constraint, asn_DEF_ENUMERATED_tags, sizeof(asn_DEF_ENUMERATED_tags) / sizeof(asn_DEF_ENUMERATED_tags[0]), asn_DEF_ENUMERATED_tags, /* Same as above */ diff --git a/skeletons/ENUMERATED.h b/skeletons/ENUMERATED.h index daa6211c..e4df29b4 100644 --- a/skeletons/ENUMERATED.h +++ b/skeletons/ENUMERATED.h @@ -14,6 +14,7 @@ extern "C" { typedef INTEGER_t ENUMERATED_t; /* Implemented via INTEGER */ extern asn_TYPE_descriptor_t asn_DEF_ENUMERATED; +extern asn_TYPE_operation_t asn_OP_ENUMERATED; per_type_decoder_f ENUMERATED_decode_uper; per_type_encoder_f ENUMERATED_encode_uper; diff --git a/skeletons/GeneralString.c b/skeletons/GeneralString.c index 805adcb6..cc2c292a 100644 --- a/skeletons/GeneralString.c +++ b/skeletons/GeneralString.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_GeneralString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (27 << 2)), /* [UNIVERSAL 27] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_GeneralString = { - "GeneralString", - "GeneralString", +asn_TYPE_operation_t asn_OP_GeneralString = { OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_GeneralString = { OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_GeneralString = { + "GeneralString", + "GeneralString", + &asn_OP_GeneralString, + asn_generic_unknown_constraint, asn_DEF_GeneralString_tags, sizeof(asn_DEF_GeneralString_tags) / sizeof(asn_DEF_GeneralString_tags[0]) - 1, diff --git a/skeletons/GeneralString.h b/skeletons/GeneralString.h index bb56c1f0..55b994fa 100644 --- a/skeletons/GeneralString.h +++ b/skeletons/GeneralString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t GeneralString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_GeneralString; +extern asn_TYPE_operation_t asn_OP_GeneralString; #define GeneralString_free OCTET_STRING_free #define GeneralString_print OCTET_STRING_print diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c index 90be7cdf..a421c25e 100644 --- a/skeletons/GeneralizedTime.c +++ b/skeletons/GeneralizedTime.c @@ -171,9 +171,7 @@ static asn_per_constraints_t asn_DEF_GeneralizedTime_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { - "GeneralizedTime", - "GeneralizedTime", +asn_TYPE_operation_t asn_OP_GeneralizedTime = { OCTET_STRING_free, GeneralizedTime_print, OCTET_STRING_compare, /* Does not normalize time zones! */ @@ -196,7 +194,13 @@ asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_GeneralizedTime = { + "GeneralizedTime", + "GeneralizedTime", + &asn_OP_GeneralizedTime, + GeneralizedTime_constraint, /* Check validity of time */ asn_DEF_GeneralizedTime_tags, sizeof(asn_DEF_GeneralizedTime_tags) / sizeof(asn_DEF_GeneralizedTime_tags[0]) - 2, diff --git a/skeletons/GeneralizedTime.h b/skeletons/GeneralizedTime.h index fa261bbe..ace9c027 100644 --- a/skeletons/GeneralizedTime.h +++ b/skeletons/GeneralizedTime.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t GeneralizedTime_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_GeneralizedTime; +extern asn_TYPE_operation_t asn_OP_GeneralizedTime; asn_struct_print_f GeneralizedTime_print; asn_constr_check_f GeneralizedTime_constraint; diff --git a/skeletons/GraphicString.c b/skeletons/GraphicString.c index 4cd17182..88b3734e 100644 --- a/skeletons/GraphicString.c +++ b/skeletons/GraphicString.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_GraphicString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (25 << 2)), /* [UNIVERSAL 25] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_GraphicString = { - "GraphicString", - "GraphicString", +asn_TYPE_operation_t asn_OP_GraphicString = { OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_GraphicString = { OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_GraphicString = { + "GraphicString", + "GraphicString", + &asn_OP_GraphicString, + asn_generic_unknown_constraint, asn_DEF_GraphicString_tags, sizeof(asn_DEF_GraphicString_tags) / sizeof(asn_DEF_GraphicString_tags[0]) - 1, diff --git a/skeletons/GraphicString.h b/skeletons/GraphicString.h index 13da1e6f..420521d7 100644 --- a/skeletons/GraphicString.h +++ b/skeletons/GraphicString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t GraphicString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_GraphicString; +extern asn_TYPE_operation_t asn_OP_GraphicString; #define GraphicString_free OCTET_STRING_free #define GraphicString_print OCTET_STRING_print diff --git a/skeletons/IA5String.c b/skeletons/IA5String.c index ec40d949..94578691 100644 --- a/skeletons/IA5String.c +++ b/skeletons/IA5String.c @@ -17,9 +17,7 @@ static asn_per_constraints_t asn_DEF_IA5String_per_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_IA5String = { - "IA5String", - "IA5String", +asn_TYPE_operation_t asn_OP_IA5String = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* ASCII subset */ OCTET_STRING_compare, @@ -42,7 +40,13 @@ asn_TYPE_descriptor_t asn_DEF_IA5String = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_IA5String = { + "IA5String", + "IA5String", + &asn_OP_IA5String, + IA5String_constraint, /* Constraint on the alphabet */ asn_DEF_IA5String_tags, sizeof(asn_DEF_IA5String_tags) / sizeof(asn_DEF_IA5String_tags[0]) - 1, diff --git a/skeletons/IA5String.h b/skeletons/IA5String.h index 0c6f0189..fa9f7ac0 100644 --- a/skeletons/IA5String.h +++ b/skeletons/IA5String.h @@ -17,6 +17,7 @@ typedef OCTET_STRING_t IA5String_t; /* Implemented via OCTET STRING */ * IA5String ASN.1 type definition. */ extern asn_TYPE_descriptor_t asn_DEF_IA5String; +extern asn_TYPE_operation_t asn_OP_IA5String; asn_constr_check_f IA5String_constraint; diff --git a/skeletons/INTEGER.c b/skeletons/INTEGER.c index 86202b7b..a930b0a6 100644 --- a/skeletons/INTEGER.c +++ b/skeletons/INTEGER.c @@ -14,9 +14,7 @@ static const ber_tlv_tag_t asn_DEF_INTEGER_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_INTEGER = { - "INTEGER", - "INTEGER", +asn_TYPE_operation_t asn_OP_INTEGER = { INTEGER_free, INTEGER_print, INTEGER_compare, @@ -39,7 +37,13 @@ asn_TYPE_descriptor_t asn_DEF_INTEGER = { INTEGER_decode_uper, /* Unaligned PER decoder */ INTEGER_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_INTEGER = { + "INTEGER", + "INTEGER", + &asn_OP_INTEGER, + asn_generic_no_constraint, asn_DEF_INTEGER_tags, sizeof(asn_DEF_INTEGER_tags) / sizeof(asn_DEF_INTEGER_tags[0]), asn_DEF_INTEGER_tags, /* Same as above */ diff --git a/skeletons/INTEGER.h b/skeletons/INTEGER.h index a8b1658a..2754b4b0 100644 --- a/skeletons/INTEGER.h +++ b/skeletons/INTEGER.h @@ -16,6 +16,7 @@ extern "C" { typedef ASN__PRIMITIVE_TYPE_t INTEGER_t; extern asn_TYPE_descriptor_t asn_DEF_INTEGER; +extern asn_TYPE_operation_t asn_OP_INTEGER; /* Map with <tag> to integer value association */ typedef struct asn_INTEGER_enum_map_s { diff --git a/skeletons/ISO646String.c b/skeletons/ISO646String.c index 30a5459e..eef0284a 100644 --- a/skeletons/ISO646String.c +++ b/skeletons/ISO646String.c @@ -17,9 +17,7 @@ static asn_per_constraints_t asn_DEF_ISO646String_per_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_ISO646String = { - "ISO646String", - "ISO646String", +asn_TYPE_operation_t asn_OP_ISO646String = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* ASCII subset */ OCTET_STRING_compare, @@ -42,7 +40,13 @@ asn_TYPE_descriptor_t asn_DEF_ISO646String = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_ISO646String = { + "ISO646String", + "ISO646String", + &asn_OP_ISO646String, + VisibleString_constraint, asn_DEF_ISO646String_tags, sizeof(asn_DEF_ISO646String_tags) / sizeof(asn_DEF_ISO646String_tags[0]) - 1, diff --git a/skeletons/ISO646String.h b/skeletons/ISO646String.h index 683ff0f5..49483154 100644 --- a/skeletons/ISO646String.h +++ b/skeletons/ISO646String.h @@ -15,6 +15,7 @@ extern "C" { typedef VisibleString_t ISO646String_t; /* Implemented using VisibleString */ extern asn_TYPE_descriptor_t asn_DEF_ISO646String; +extern asn_TYPE_operation_t asn_OP_ISO646String; #define ISO646String_free OCTET_STRING_free #define ISO646String_print OCTET_STRING_print_utf8 diff --git a/skeletons/NULL.c b/skeletons/NULL.c index b5991b8e..b465ee9c 100644 --- a/skeletons/NULL.c +++ b/skeletons/NULL.c @@ -13,9 +13,7 @@ static const ber_tlv_tag_t asn_DEF_NULL_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (5 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_NULL = { - "NULL", - "NULL", +asn_TYPE_operation_t asn_OP_NULL = { BOOLEAN_free, NULL_print, NULL_compare, @@ -38,7 +36,13 @@ asn_TYPE_descriptor_t asn_DEF_NULL = { NULL_decode_uper, /* Unaligned PER decoder */ NULL_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_NULL = { + "NULL", + "NULL", + &asn_OP_NULL, + asn_generic_no_constraint, asn_DEF_NULL_tags, sizeof(asn_DEF_NULL_tags) / sizeof(asn_DEF_NULL_tags[0]), asn_DEF_NULL_tags, /* Same as above */ diff --git a/skeletons/NULL.h b/skeletons/NULL.h index 6b2537c8..18a3beae 100644 --- a/skeletons/NULL.h +++ b/skeletons/NULL.h @@ -19,6 +19,7 @@ extern "C" { typedef int NULL_t; extern asn_TYPE_descriptor_t asn_DEF_NULL; +extern asn_TYPE_operation_t asn_OP_NULL; asn_struct_print_f NULL_print; asn_struct_compare_f NULL_compare; @@ -28,7 +29,7 @@ xer_type_encoder_f NULL_encode_xer; per_type_decoder_f NULL_decode_uper; per_type_encoder_f NULL_encode_uper; -#define NULL_free BOOLEAN_free +#define NULL_free BOOLEAN_free #define NULL_decode_ber BOOLEAN_decode_ber #define NULL_constraint asn_generic_no_constraint diff --git a/skeletons/NativeEnumerated.c b/skeletons/NativeEnumerated.c index 4bd9ec9f..18c9f178 100644 --- a/skeletons/NativeEnumerated.c +++ b/skeletons/NativeEnumerated.c @@ -18,9 +18,7 @@ static const ber_tlv_tag_t asn_DEF_NativeEnumerated_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = { - "ENUMERATED", /* The ASN.1 type is still ENUMERATED */ - "ENUMERATED", +asn_TYPE_operation_t asn_OP_NativeEnumerated = { NativeInteger_free, NativeInteger_print, NativeInteger_compare, @@ -43,7 +41,13 @@ asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = { NativeEnumerated_decode_uper, NativeEnumerated_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_NativeEnumerated = { + "ENUMERATED", /* The ASN.1 type is still ENUMERATED */ + "ENUMERATED", + &asn_OP_NativeEnumerated, + asn_generic_no_constraint, asn_DEF_NativeEnumerated_tags, sizeof(asn_DEF_NativeEnumerated_tags) / sizeof(asn_DEF_NativeEnumerated_tags[0]), asn_DEF_NativeEnumerated_tags, /* Same as above */ diff --git a/skeletons/NativeEnumerated.h b/skeletons/NativeEnumerated.h index c89ac348..3e6d542c 100644 --- a/skeletons/NativeEnumerated.h +++ b/skeletons/NativeEnumerated.h @@ -20,6 +20,7 @@ extern "C" { #endif extern asn_TYPE_descriptor_t asn_DEF_NativeEnumerated; +extern asn_TYPE_operation_t asn_OP_NativeEnumerated; xer_type_encoder_f NativeEnumerated_encode_xer; per_type_decoder_f NativeEnumerated_decode_uper; diff --git a/skeletons/NativeInteger.c b/skeletons/NativeInteger.c index fd686150..9c61faf8 100644 --- a/skeletons/NativeInteger.c +++ b/skeletons/NativeInteger.c @@ -19,9 +19,7 @@ static const ber_tlv_tag_t asn_DEF_NativeInteger_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_NativeInteger = { - "INTEGER", /* The ASN.1 type is still INTEGER */ - "INTEGER", +asn_TYPE_operation_t asn_OP_NativeInteger = { NativeInteger_free, NativeInteger_print, NativeInteger_compare, @@ -44,7 +42,13 @@ asn_TYPE_descriptor_t asn_DEF_NativeInteger = { NativeInteger_decode_uper, /* Unaligned PER decoder */ NativeInteger_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_NativeInteger = { + "INTEGER", /* The ASN.1 type is still INTEGER */ + "INTEGER", + &asn_OP_NativeInteger, + asn_generic_no_constraint, asn_DEF_NativeInteger_tags, sizeof(asn_DEF_NativeInteger_tags) / sizeof(asn_DEF_NativeInteger_tags[0]), asn_DEF_NativeInteger_tags, /* Same as above */ diff --git a/skeletons/NativeInteger.h b/skeletons/NativeInteger.h index 1816bd39..19ff2c87 100644 --- a/skeletons/NativeInteger.h +++ b/skeletons/NativeInteger.h @@ -20,6 +20,7 @@ extern "C" { #endif extern asn_TYPE_descriptor_t asn_DEF_NativeInteger; +extern asn_TYPE_operation_t asn_OP_NativeInteger; asn_struct_free_f NativeInteger_free; asn_struct_print_f NativeInteger_print; diff --git a/skeletons/NativeReal.c b/skeletons/NativeReal.c index f305d8bd..af71027b 100644 --- a/skeletons/NativeReal.c +++ b/skeletons/NativeReal.c @@ -21,9 +21,7 @@ static const ber_tlv_tag_t asn_DEF_NativeReal_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_NativeReal = { - "REAL", /* The ASN.1 type is still REAL */ - "REAL", +asn_TYPE_operation_t asn_OP_NativeReal = { NativeReal_free, NativeReal_print, NativeReal_compare, @@ -46,7 +44,13 @@ asn_TYPE_descriptor_t asn_DEF_NativeReal = { NativeReal_decode_uper, NativeReal_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_NativeReal = { + "REAL", /* The ASN.1 type is still REAL */ + "REAL", + &asn_OP_NativeReal, + asn_generic_no_constraint, asn_DEF_NativeReal_tags, sizeof(asn_DEF_NativeReal_tags) / sizeof(asn_DEF_NativeReal_tags[0]), asn_DEF_NativeReal_tags, /* Same as above */ diff --git a/skeletons/NativeReal.h b/skeletons/NativeReal.h index a307722a..cfdd1bd1 100644 --- a/skeletons/NativeReal.h +++ b/skeletons/NativeReal.h @@ -18,6 +18,7 @@ extern "C" { #endif extern asn_TYPE_descriptor_t asn_DEF_NativeReal; +extern asn_TYPE_operation_t asn_OP_NativeReal; asn_struct_free_f NativeReal_free; asn_struct_print_f NativeReal_print; diff --git a/skeletons/NumericString.c b/skeletons/NumericString.c index a314e51c..d08ec965 100644 --- a/skeletons/NumericString.c +++ b/skeletons/NumericString.c @@ -37,9 +37,7 @@ static asn_per_constraints_t asn_DEF_NumericString_per_constraints = { asn_DEF_NumericString_v2c, asn_DEF_NumericString_c2v }; -asn_TYPE_descriptor_t asn_DEF_NumericString = { - "NumericString", - "NumericString", +asn_TYPE_operation_t asn_OP_NumericString = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* ASCII subset */ OCTET_STRING_compare, @@ -62,7 +60,13 @@ asn_TYPE_descriptor_t asn_DEF_NumericString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_NumericString = { + "NumericString", + "NumericString", + &asn_OP_NumericString, + NumericString_constraint, asn_DEF_NumericString_tags, sizeof(asn_DEF_NumericString_tags) / sizeof(asn_DEF_NumericString_tags[0]) - 1, diff --git a/skeletons/NumericString.h b/skeletons/NumericString.h index d805561d..8e4f7ec9 100644 --- a/skeletons/NumericString.h +++ b/skeletons/NumericString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t NumericString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_NumericString; +extern asn_TYPE_operation_t asn_OP_NumericString; asn_constr_check_f NumericString_constraint; diff --git a/skeletons/OBJECT_IDENTIFIER.c b/skeletons/OBJECT_IDENTIFIER.c index 18a23db8..7110b0bd 100644 --- a/skeletons/OBJECT_IDENTIFIER.c +++ b/skeletons/OBJECT_IDENTIFIER.c @@ -15,9 +15,7 @@ static const ber_tlv_tag_t asn_DEF_OBJECT_IDENTIFIER_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = { - "OBJECT IDENTIFIER", - "OBJECT_IDENTIFIER", +asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER = { ASN__PRIMITIVE_TYPE_free, OBJECT_IDENTIFIER_print, OCTET_STRING_compare, /* Implemented in terms of a string comparison */ @@ -40,7 +38,13 @@ asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER = { + "OBJECT IDENTIFIER", + "OBJECT_IDENTIFIER", + &asn_OP_OBJECT_IDENTIFIER, + OBJECT_IDENTIFIER_constraint, asn_DEF_OBJECT_IDENTIFIER_tags, sizeof(asn_DEF_OBJECT_IDENTIFIER_tags) / sizeof(asn_DEF_OBJECT_IDENTIFIER_tags[0]), diff --git a/skeletons/OBJECT_IDENTIFIER.h b/skeletons/OBJECT_IDENTIFIER.h index 527cd97c..2501a54c 100644 --- a/skeletons/OBJECT_IDENTIFIER.h +++ b/skeletons/OBJECT_IDENTIFIER.h @@ -17,6 +17,7 @@ extern "C" { typedef ASN__PRIMITIVE_TYPE_t OBJECT_IDENTIFIER_t; extern asn_TYPE_descriptor_t asn_DEF_OBJECT_IDENTIFIER; +extern asn_TYPE_operation_t asn_OP_OBJECT_IDENTIFIER; asn_struct_print_f OBJECT_IDENTIFIER_print; asn_constr_check_f OBJECT_IDENTIFIER_constraint; diff --git a/skeletons/OCTET_STRING.c b/skeletons/OCTET_STRING.c index 57a0c1eb..64be97e3 100644 --- a/skeletons/OCTET_STRING.c +++ b/skeletons/OCTET_STRING.c @@ -24,9 +24,7 @@ static asn_per_constraints_t asn_DEF_OCTET_STRING_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { - "OCTET STRING", /* Canonical name */ - "OCTET_STRING", /* XML tag name */ +asn_TYPE_operation_t asn_OP_OCTET_STRING = { OCTET_STRING_free, OCTET_STRING_print, /* OCTET STRING generally means a non-ascii sequence */ OCTET_STRING_compare, @@ -49,7 +47,13 @@ asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { OCTET_STRING_decode_uper, /* Unaligned PER decoder */ OCTET_STRING_encode_uper, /* Unaligned PER encoder */ #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_OCTET_STRING = { + "OCTET STRING", /* Canonical name */ + "OCTET_STRING", /* XML tag name */ + &asn_OP_OCTET_STRING, + asn_generic_no_constraint, asn_DEF_OCTET_STRING_tags, sizeof(asn_DEF_OCTET_STRING_tags) / sizeof(asn_DEF_OCTET_STRING_tags[0]), diff --git a/skeletons/OCTET_STRING.h b/skeletons/OCTET_STRING.h index fa40a0d3..211bc14f 100644 --- a/skeletons/OCTET_STRING.h +++ b/skeletons/OCTET_STRING.h @@ -19,6 +19,7 @@ typedef struct OCTET_STRING { } OCTET_STRING_t; extern asn_TYPE_descriptor_t asn_DEF_OCTET_STRING; +extern asn_TYPE_operation_t asn_OP_OCTET_STRING; asn_struct_free_f OCTET_STRING_free; asn_struct_print_f OCTET_STRING_print; diff --git a/skeletons/OPEN_TYPE.c b/skeletons/OPEN_TYPE.c index 7a53ac31..9c4c8e63 100644 --- a/skeletons/OPEN_TYPE.c +++ b/skeletons/OPEN_TYPE.c @@ -8,6 +8,20 @@ #include <per_opentype.h> #include <errno.h> +asn_TYPE_operation_t asn_OP_OPEN_TYPE = { + OPEN_TYPE_free, + OPEN_TYPE_print, + OPEN_TYPE_compare, + OPEN_TYPE_constraint, + OPEN_TYPE_decode_ber, + OPEN_TYPE_encode_der, + OPEN_TYPE_decode_xer, + OPEN_TYPE_encode_xer, + 0, 0, /* No OER support, use "-gen-OER" to enable */ + OPEN_TYPE_decode_uper, + OPEN_TYPE_encode_uper, + 0, /* Use generic outmost tag fetcher */ +}; asn_dec_rval_t OPEN_TYPE_uper_get(asn_codec_ctx_t *opt_codec_ctx, diff --git a/skeletons/OPEN_TYPE.h b/skeletons/OPEN_TYPE.h index cddb4017..060675a6 100644 --- a/skeletons/OPEN_TYPE.h +++ b/skeletons/OPEN_TYPE.h @@ -22,6 +22,7 @@ extern "C" { #define OPEN_TYPE_decode_uper NULL #define OPEN_TYPE_encode_uper CHOICE_encode_uper +extern asn_TYPE_operation_t asn_OP_OPEN_TYPE; /* * Decode an Open Type which is potentially constraiend diff --git a/skeletons/ObjectDescriptor.c b/skeletons/ObjectDescriptor.c index b80b69e0..2e9a76d4 100644 --- a/skeletons/ObjectDescriptor.c +++ b/skeletons/ObjectDescriptor.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_ObjectDescriptor_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (7 << 2)), /* [UNIVERSAL 7] IMPLICIT ... */ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_ObjectDescriptor = { - "ObjectDescriptor", - "ObjectDescriptor", +asn_TYPE_operation_t asn_OP_ObjectDescriptor = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* Treat as ASCII subset (it's not) */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_ObjectDescriptor = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_ObjectDescriptor = { + "ObjectDescriptor", + "ObjectDescriptor", + &asn_OP_ObjectDescriptor, + asn_generic_unknown_constraint, asn_DEF_ObjectDescriptor_tags, sizeof(asn_DEF_ObjectDescriptor_tags) / sizeof(asn_DEF_ObjectDescriptor_tags[0]) - 1, diff --git a/skeletons/ObjectDescriptor.h b/skeletons/ObjectDescriptor.h index d88e7611..24234698 100644 --- a/skeletons/ObjectDescriptor.h +++ b/skeletons/ObjectDescriptor.h @@ -14,6 +14,7 @@ extern "C" { typedef GraphicString_t ObjectDescriptor_t; /* Implemented via GraphicString */ extern asn_TYPE_descriptor_t asn_DEF_ObjectDescriptor; +extern asn_TYPE_operation_t asn_OP_ObjectDescriptor; #define ObjectDescriptor_free OCTET_STRING_free #define ObjectDescriptor_print OCTET_STRING_print_utf8 diff --git a/skeletons/PrintableString.c b/skeletons/PrintableString.c index 5e0e4b7a..10a3edd2 100644 --- a/skeletons/PrintableString.c +++ b/skeletons/PrintableString.c @@ -47,9 +47,7 @@ static asn_per_constraints_t asn_DEF_PrintableString_per_constraints = { asn_DEF_PrintableString_v2c, asn_DEF_PrintableString_c2v }; -asn_TYPE_descriptor_t asn_DEF_PrintableString = { - "PrintableString", - "PrintableString", +asn_TYPE_operation_t asn_OP_PrintableString = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* ASCII subset */ OCTET_STRING_compare, @@ -72,7 +70,13 @@ asn_TYPE_descriptor_t asn_DEF_PrintableString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_PrintableString = { + "PrintableString", + "PrintableString", + &asn_OP_PrintableString, + PrintableString_constraint, asn_DEF_PrintableString_tags, sizeof(asn_DEF_PrintableString_tags) / sizeof(asn_DEF_PrintableString_tags[0]) - 1, diff --git a/skeletons/PrintableString.h b/skeletons/PrintableString.h index 70f07b7b..d7889445 100644 --- a/skeletons/PrintableString.h +++ b/skeletons/PrintableString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t PrintableString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_PrintableString; +extern asn_TYPE_operation_t asn_OP_PrintableString; asn_constr_check_f PrintableString_constraint; diff --git a/skeletons/REAL.c b/skeletons/REAL.c index c510db5d..e31e1ad9 100644 --- a/skeletons/REAL.c +++ b/skeletons/REAL.c @@ -41,41 +41,45 @@ static volatile double real_zero GCC_NOTUSED = 0.0; static const ber_tlv_tag_t asn_DEF_REAL_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (9 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_REAL = { - "REAL", - "REAL", - ASN__PRIMITIVE_TYPE_free, - REAL_print, - REAL_compare, - asn_generic_no_constraint, - ber_decode_primitive, - der_encode_primitive, - REAL_decode_xer, - REAL_encode_xer, +asn_TYPE_operation_t asn_OP_REAL = { + ASN__PRIMITIVE_TYPE_free, + REAL_print, + REAL_compare, + asn_generic_no_constraint, + ber_decode_primitive, + der_encode_primitive, + REAL_decode_xer, + REAL_encode_xer, #ifdef ASN_DISABLE_OER_SUPPORT - 0, - 0, + 0, + 0, #else - 0, - 0, + 0, + 0, #endif /* ASN_DISABLE_OER_SUPPORT */ #ifdef ASN_DISABLE_PER_SUPPORT - 0, - 0, + 0, + 0, #else - REAL_decode_uper, - REAL_encode_uper, + REAL_decode_uper, + REAL_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ - asn_DEF_REAL_tags, - sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), - asn_DEF_REAL_tags, /* Same as above */ - sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), - 0, /* No OER visible constraints */ - 0, /* No PER visible constraints */ - 0, - 0, /* No members */ - 0 /* No specifics */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_REAL = { + "REAL", + "REAL", + &asn_OP_REAL, + asn_generic_no_constraint, + asn_DEF_REAL_tags, + sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), + asn_DEF_REAL_tags, /* Same as above */ + sizeof(asn_DEF_REAL_tags) / sizeof(asn_DEF_REAL_tags[0]), + 0, /* No OER visible constraints */ + 0, /* No PER visible constraints */ + 0, + 0, /* No members */ + 0 /* No specifics */ }; typedef enum specialRealValue { diff --git a/skeletons/REAL.h b/skeletons/REAL.h index 227c4b47..8bc06230 100644 --- a/skeletons/REAL.h +++ b/skeletons/REAL.h @@ -15,6 +15,7 @@ extern "C" { typedef ASN__PRIMITIVE_TYPE_t REAL_t; extern asn_TYPE_descriptor_t asn_DEF_REAL; +extern asn_TYPE_operation_t asn_OP_REAL; asn_struct_print_f REAL_print; asn_struct_compare_f REAL_compare; diff --git a/skeletons/RELATIVE-OID.c b/skeletons/RELATIVE-OID.c index 9efd90de..cb763a6b 100644 --- a/skeletons/RELATIVE-OID.c +++ b/skeletons/RELATIVE-OID.c @@ -16,9 +16,7 @@ static const ber_tlv_tag_t asn_DEF_RELATIVE_OID_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (13 << 2)) }; -asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID = { - "RELATIVE-OID", - "RELATIVE_OID", +asn_TYPE_operation_t asn_OP_RELATIVE_OID = { ASN__PRIMITIVE_TYPE_free, RELATIVE_OID_print, OCTET_STRING_compare, /* Implemented in terms of opaque comparison */ @@ -41,7 +39,13 @@ asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID = { + "RELATIVE-OID", + "RELATIVE_OID", + &asn_OP_RELATIVE_OID, + asn_generic_no_constraint, asn_DEF_RELATIVE_OID_tags, sizeof(asn_DEF_RELATIVE_OID_tags) / sizeof(asn_DEF_RELATIVE_OID_tags[0]), diff --git a/skeletons/RELATIVE-OID.h b/skeletons/RELATIVE-OID.h index 2863896b..4a73d278 100644 --- a/skeletons/RELATIVE-OID.h +++ b/skeletons/RELATIVE-OID.h @@ -15,6 +15,7 @@ extern "C" { typedef OBJECT_IDENTIFIER_t RELATIVE_OID_t; extern asn_TYPE_descriptor_t asn_DEF_RELATIVE_OID; +extern asn_TYPE_operation_t asn_OP_RELATIVE_OID; asn_struct_print_f RELATIVE_OID_print; xer_type_decoder_f RELATIVE_OID_decode_xer; diff --git a/skeletons/T61String.c b/skeletons/T61String.c index 694d2a09..ae09e8b9 100644 --- a/skeletons/T61String.c +++ b/skeletons/T61String.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_T61String_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (20 << 2)), /* [UNIVERSAL 20] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_T61String = { - "T61String", - "T61String", +asn_TYPE_operation_t asn_OP_T61String = { OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_T61String = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_T61String = { + "T61String", + "T61String", + &asn_OP_T61String, + asn_generic_unknown_constraint, asn_DEF_T61String_tags, sizeof(asn_DEF_T61String_tags) / sizeof(asn_DEF_T61String_tags[0]) - 1, diff --git a/skeletons/T61String.h b/skeletons/T61String.h index 3c2d72f1..27f7cc6d 100644 --- a/skeletons/T61String.h +++ b/skeletons/T61String.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t T61String_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_T61String; +extern asn_TYPE_operation_t asn_OP_T61String; #define T61String_free OCTET_STRING_free #define T61String_print OCTET_STRING_print diff --git a/skeletons/TeletexString.c b/skeletons/TeletexString.c index 15969b1e..5e6aeaf2 100644 --- a/skeletons/TeletexString.c +++ b/skeletons/TeletexString.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_TeletexString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (20 << 2)), /* [UNIVERSAL 20] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_TeletexString = { - "TeletexString", - "TeletexString", +asn_TYPE_operation_t asn_OP_TeletexString = { OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_TeletexString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_TeletexString = { + "TeletexString", + "TeletexString", + &asn_OP_TeletexString, + asn_generic_unknown_constraint, asn_DEF_TeletexString_tags, sizeof(asn_DEF_TeletexString_tags) / sizeof(asn_DEF_TeletexString_tags[0]) - 1, diff --git a/skeletons/TeletexString.h b/skeletons/TeletexString.h index 5a756fbb..59d0ef79 100644 --- a/skeletons/TeletexString.h +++ b/skeletons/TeletexString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t TeletexString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_TeletexString; +extern asn_TYPE_operation_t asn_OP_TeletexString; #define TeletexString_free OCTET_STRING_free #define TeletexString_print OCTET_STRING_print diff --git a/skeletons/UTCTime.c b/skeletons/UTCTime.c index 04776d71..61caf2ea 100644 --- a/skeletons/UTCTime.c +++ b/skeletons/UTCTime.c @@ -28,9 +28,7 @@ static asn_per_constraints_t asn_DEF_UTCTime_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_UTCTime = { - "UTCTime", - "UTCTime", +asn_TYPE_operation_t asn_OP_UTCTime = { OCTET_STRING_free, UTCTime_print, OCTET_STRING_compare, /* Does not deal with time zones. */ @@ -53,7 +51,13 @@ asn_TYPE_descriptor_t asn_DEF_UTCTime = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_UTCTime = { + "UTCTime", + "UTCTime", + &asn_OP_UTCTime, + UTCTime_constraint, asn_DEF_UTCTime_tags, sizeof(asn_DEF_UTCTime_tags) / sizeof(asn_DEF_UTCTime_tags[0]) - 2, diff --git a/skeletons/UTCTime.h b/skeletons/UTCTime.h index ed3af5a5..55370201 100644 --- a/skeletons/UTCTime.h +++ b/skeletons/UTCTime.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t UTCTime_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_UTCTime; +extern asn_TYPE_operation_t asn_OP_UTCTime; asn_struct_print_f UTCTime_print; asn_constr_check_f UTCTime_constraint; diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c index de78c5e6..a89a89e7 100644 --- a/skeletons/UTF8String.c +++ b/skeletons/UTF8String.c @@ -13,9 +13,7 @@ static const ber_tlv_tag_t asn_DEF_UTF8String_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), /* [UNIVERSAL 12] IMPLICIT ...*/ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)), /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_UTF8String = { - "UTF8String", - "UTF8String", +asn_TYPE_operation_t asn_OP_UTF8String = { OCTET_STRING_free, UTF8String_print, OCTET_STRING_compare, @@ -38,7 +36,13 @@ asn_TYPE_descriptor_t asn_DEF_UTF8String = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_UTF8String = { + "UTF8String", + "UTF8String", + &asn_OP_UTF8String, + UTF8String_constraint, /* Check for invalid codes, etc. */ asn_DEF_UTF8String_tags, sizeof(asn_DEF_UTF8String_tags) / sizeof(asn_DEF_UTF8String_tags[0]) - 1, diff --git a/skeletons/UTF8String.h b/skeletons/UTF8String.h index ca2f0e54..1853573a 100644 --- a/skeletons/UTF8String.h +++ b/skeletons/UTF8String.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t UTF8String_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_UTF8String; +extern asn_TYPE_operation_t asn_OP_UTF8String; asn_struct_print_f UTF8String_print; asn_constr_check_f UTF8String_constraint; diff --git a/skeletons/UniversalString.c b/skeletons/UniversalString.c index 3f0344e0..1879ecfd 100644 --- a/skeletons/UniversalString.c +++ b/skeletons/UniversalString.c @@ -23,9 +23,7 @@ static asn_per_constraints_t asn_DEF_UniversalString_per_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_UniversalString = { - "UniversalString", - "UniversalString", +asn_TYPE_operation_t asn_OP_UniversalString = { OCTET_STRING_free, UniversalString_print, /* Convert into UTF8 and print */ OCTET_STRING_compare, @@ -48,7 +46,13 @@ asn_TYPE_descriptor_t asn_DEF_UniversalString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_UniversalString = { + "UniversalString", + "UniversalString", + &asn_OP_UniversalString, + asn_generic_no_constraint, asn_DEF_UniversalString_tags, sizeof(asn_DEF_UniversalString_tags) / sizeof(asn_DEF_UniversalString_tags[0]) - 1, diff --git a/skeletons/UniversalString.h b/skeletons/UniversalString.h index 885e5ab9..ff225373 100644 --- a/skeletons/UniversalString.h +++ b/skeletons/UniversalString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t UniversalString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_UniversalString; +extern asn_TYPE_operation_t asn_OP_UniversalString; extern asn_OCTET_STRING_specifics_t asn_SPC_UniversalString_specs; asn_struct_print_f UniversalString_print; /* Human-readable output */ diff --git a/skeletons/VideotexString.c b/skeletons/VideotexString.c index f377e2e9..c3de329e 100644 --- a/skeletons/VideotexString.c +++ b/skeletons/VideotexString.c @@ -12,9 +12,7 @@ static const ber_tlv_tag_t asn_DEF_VideotexString_tags[] = { (ASN_TAG_CLASS_UNIVERSAL | (21 << 2)), /* [UNIVERSAL 21] IMPLICIT */ (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) /* ... OCTET STRING */ }; -asn_TYPE_descriptor_t asn_DEF_VideotexString = { - "VideotexString", - "VideotexString", +asn_TYPE_operation_t asn_OP_VideotexString = { OCTET_STRING_free, OCTET_STRING_print, /* non-ascii string */ OCTET_STRING_compare, @@ -37,7 +35,13 @@ asn_TYPE_descriptor_t asn_DEF_VideotexString = { OCTET_STRING_decode_uper, /* Implemented in terms of OCTET STRING */ OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_VideotexString = { + "VideotexString", + "VideotexString", + &asn_OP_VideotexString, + asn_generic_unknown_constraint, asn_DEF_VideotexString_tags, sizeof(asn_DEF_VideotexString_tags) / sizeof(asn_DEF_VideotexString_tags[0]) - 1, diff --git a/skeletons/VideotexString.h b/skeletons/VideotexString.h index f8befb73..1227f581 100644 --- a/skeletons/VideotexString.h +++ b/skeletons/VideotexString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t VideotexString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_VideotexString; +extern asn_TYPE_operation_t asn_OP_VideotexString; #define VideotexString_free OCTET_STRING_free #define VideotexString_print OCTET_STRING_print diff --git a/skeletons/VisibleString.c b/skeletons/VisibleString.c index 9a74a835..214848ad 100644 --- a/skeletons/VisibleString.c +++ b/skeletons/VisibleString.c @@ -17,9 +17,7 @@ static asn_per_constraints_t asn_DEF_VisibleString_constraints = { { APC_SEMI_CONSTRAINED, -1, -1, 0, 0 }, /* Size */ 0, 0 }; -asn_TYPE_descriptor_t asn_DEF_VisibleString = { - "VisibleString", - "VisibleString", +asn_TYPE_operation_t asn_OP_VisibleString = { OCTET_STRING_free, OCTET_STRING_print_utf8, /* ASCII subset */ OCTET_STRING_compare, @@ -42,7 +40,13 @@ asn_TYPE_descriptor_t asn_DEF_VisibleString = { OCTET_STRING_decode_uper, OCTET_STRING_encode_uper, #endif /* ASN_DISABLE_PER_SUPPORT */ - 0, /* Use generic outmost tag fetcher */ + 0 /* Use generic outmost tag fetcher */ +}; +asn_TYPE_descriptor_t asn_DEF_VisibleString = { + "VisibleString", + "VisibleString", + &asn_OP_VisibleString, + VisibleString_constraint, asn_DEF_VisibleString_tags, sizeof(asn_DEF_VisibleString_tags) / sizeof(asn_DEF_VisibleString_tags[0]) - 1, diff --git a/skeletons/VisibleString.h b/skeletons/VisibleString.h index e16ae496..a8d278be 100644 --- a/skeletons/VisibleString.h +++ b/skeletons/VisibleString.h @@ -14,6 +14,7 @@ extern "C" { typedef OCTET_STRING_t VisibleString_t; /* Implemented via OCTET STRING */ extern asn_TYPE_descriptor_t asn_DEF_VisibleString; +extern asn_TYPE_operation_t asn_OP_VisibleString; asn_constr_check_f VisibleString_constraint; diff --git a/skeletons/ber_decoder.c b/skeletons/ber_decoder.c index 63c65bc3..919dea6f 100644 --- a/skeletons/ber_decoder.c +++ b/skeletons/ber_decoder.c @@ -51,7 +51,7 @@ ber_decode(asn_codec_ctx_t *opt_codec_ctx, /* * Invoke type-specific decoder. */ - return type_descriptor->ber_decoder(opt_codec_ctx, type_descriptor, + return type_descriptor->op->ber_decoder(opt_codec_ctx, type_descriptor, struct_ptr, /* Pointer to the destination structure */ ptr, size, /* Buffer and its size */ 0 /* Default tag mode is 0 */ diff --git a/skeletons/constr_CHOICE.c b/skeletons/constr_CHOICE.c index 86b3601c..a50bede2 100644 --- a/skeletons/constr_CHOICE.c +++ b/skeletons/constr_CHOICE.c @@ -264,7 +264,7 @@ CHOICE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Invoke the member fetch routine according to member's type */ - rval = elm->type->ber_decoder(opt_codec_ctx, elm->type, + rval = elm->type->op->ber_decoder(opt_codec_ctx, elm->type, memb_ptr2, ptr, LEFT, elm->tag_mode); switch(rval.code) { case RC_OK: @@ -420,7 +420,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, ssize_t ret; /* Encode member with its tag */ - erval = elm->type->der_encoder(elm->type, memb_ptr, + erval = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(erval.encoded == -1) return erval; @@ -436,7 +436,7 @@ CHOICE_encode_der(asn_TYPE_descriptor_t *td, void *sptr, /* * Encode the single underlying member. */ - erval = elm->type->der_encoder(elm->type, memb_ptr, + erval = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(erval.encoded == -1) return erval; @@ -618,7 +618,7 @@ CHOICE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, } /* Start/Continue decoding the inner member */ - tmprval = elm->type->xer_decoder(opt_codec_ctx, + tmprval = elm->type->op->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); @@ -813,7 +813,7 @@ CHOICE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!(flags & XER_F_CANONICAL)) ASN__TEXT_INDENT(1, ilevel); ASN__CALLBACK3("<", 1, mname, mlen, ">", 1); - tmper = elm->type->xer_encoder(elm->type, memb_ptr, + tmper = elm->type->op->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; @@ -898,7 +898,7 @@ CHOICE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, ASN_DEBUG("Discovered CHOICE %s encodes %s", td->name, elm->name); if(ct && ct->range_bits >= 0) { - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, + rv = elm->type->op->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, memb_ptr2, pd); } else { rv = uper_open_type_get(opt_codec_ctx, elm->type, @@ -915,7 +915,7 @@ asn_enc_rval_t CHOICE_encode_uper(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; + asn_CHOICE_specifics_t *specs = (asn_CHOICE_specifics_t *)td->specifics; asn_TYPE_member_t *elm; /* CHOICE's element */ const asn_per_constraint_t *ct; void *memb_ptr; @@ -930,9 +930,9 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, else if(td->per_constraints) ct = &td->per_constraints->value; else ct = 0; - present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); + present = _fetch_present_idx(sptr, specs->pres_offset, specs->pres_size); - /* + /* * If the structure was not initialized properly, it cannot be encoded: * can't deduce what to encode in the choice type. */ @@ -978,7 +978,7 @@ CHOICE_encode_uper(asn_TYPE_descriptor_t *td, if(per_put_few_bits(po, present_enc, ct->range_bits)) ASN__ENCODE_FAILED; - return elm->type->uper_encoder(elm->type, elm->per_constraints, + return elm->type->op->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); } else { asn_enc_rval_t rval; @@ -1029,7 +1029,7 @@ CHOICE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, return -1; } - return elm->type->print_struct(elm->type, memb_ptr, ilevel, + return elm->type->op->print_struct(elm->type, memb_ptr, ilevel, cb, app_key); } else { return (cb("<absent>", 8, app_key) < 0) ? -1 : 0; @@ -1173,7 +1173,7 @@ CHOICE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bp if(amember && bmember) { if(apresent == bpresent) { assert(aelm == belm); - return aelm->type->compare_struct(aelm->type, amember, bmember); + return aelm->type->op->compare_struct(aelm->type, amember, bmember); } else if(apresent < bpresent) { return -1; } else { @@ -1232,3 +1232,28 @@ CHOICE_variant_set_presence(const asn_TYPE_descriptor_t *td, void *sptr, return 0; } +asn_TYPE_operation_t asn_OP_CHOICE = { + CHOICE_free, + CHOICE_print, + CHOICE_compare, + CHOICE_constraint, + CHOICE_decode_ber, + CHOICE_encode_der, + CHOICE_decode_xer, + CHOICE_encode_xer, +#ifdef ASN_DISABLE_OER_SUPPORT + 0, + 0, +#else + 0, + 0, +#endif /* ASN_DISABLE_OER_SUPPORT */ +#ifdef ASN_DISABLE_PER_SUPPORT + 0, + 0, +#else + CHOICE_decode_uper, + CHOICE_encode_uper, +#endif /* ASN_DISABLE_PER_SUPPORT */ + CHOICE_outmost_tag +}; diff --git a/skeletons/constr_CHOICE.h b/skeletons/constr_CHOICE.h index 0aedcf79..6af1805a 100644 --- a/skeletons/constr_CHOICE.h +++ b/skeletons/constr_CHOICE.h @@ -13,27 +13,27 @@ extern "C" { #endif typedef const struct asn_CHOICE_specifics_s { - /* - * Target structure description. - */ - unsigned struct_size; /* Size of the target structure. */ - unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */ - unsigned pres_offset; /* Identifier of the present member */ - unsigned pres_size; /* Size of the identifier (enum) */ + /* + * Target structure description. + */ + unsigned struct_size; /* Size of the target structure. */ + unsigned ctx_offset; /* Offset of the asn_codec_ctx_t member */ + unsigned pres_offset; /* Identifier of the present member */ + unsigned pres_size; /* Size of the identifier (enum) */ - /* - * Tags to members mapping table. - */ - const asn_TYPE_tag2member_t *tag2el; - unsigned tag2el_count; + /* + * Tags to members mapping table. + */ + const asn_TYPE_tag2member_t *tag2el; + unsigned tag2el_count; - /* Canonical ordering of CHOICE elements, for PER */ - const unsigned *canonical_order; + /* Canonical ordering of CHOICE elements, for PER */ + const unsigned *canonical_order; - /* - * Extensions-related stuff. - */ - signed ext_start; /* First member of extensions, or -1 */ + /* + * Extensions-related stuff. + */ + signed ext_start; /* First member of extensions, or -1 */ } asn_CHOICE_specifics_t; /* @@ -50,6 +50,7 @@ xer_type_encoder_f CHOICE_encode_xer; per_type_decoder_f CHOICE_decode_uper; per_type_encoder_f CHOICE_encode_uper; asn_outmost_tag_f CHOICE_outmost_tag; +extern asn_TYPE_operation_t asn_OP_CHOICE; /* * Return the 1-based choice variant presence index. diff --git a/skeletons/constr_SEQUENCE.c b/skeletons/constr_SEQUENCE.c index e1c57d3c..ad779829 100644 --- a/skeletons/constr_SEQUENCE.c +++ b/skeletons/constr_SEQUENCE.c @@ -410,7 +410,7 @@ SEQUENCE_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Invoke the member fetch routine according to member's type */ - rval = elements[edx].type->ber_decoder(opt_codec_ctx, + rval = elements[edx].type->op->ber_decoder(opt_codec_ctx, elements[edx].type, memb_ptr2, ptr, LEFT, elements[edx].tag_mode); @@ -538,7 +538,7 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - erval = elm->type->der_encoder(elm->type, memb_ptr, + erval = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(erval.encoded == -1) @@ -573,7 +573,7 @@ SEQUENCE_encode_der(asn_TYPE_descriptor_t *td, } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - tmperval = elm->type->der_encoder(elm->type, memb_ptr, + tmperval = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(tmperval.encoded == -1) @@ -673,7 +673,7 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, } /* Invoke the inner type decoder, m.b. multiple times */ - tmprval = elm->type->xer_decoder(opt_codec_ctx, + tmprval = elm->type->op->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); @@ -776,8 +776,8 @@ SEQUENCE_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Search which member corresponds to this tag. */ - size_t n; - size_t edx_end = edx + elements[edx].optional + 1; + size_t n; + size_t edx_end = edx + elements[edx].optional + 1; if(edx_end > td->elements_count) edx_end = td->elements_count; for(n = edx; n < edx_end; n++) { @@ -885,7 +885,7 @@ SEQUENCE_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, ASN__CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ - tmper = elm->type->xer_encoder(elm->type, memb_ptr, + tmper = elm->type->op->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; @@ -937,7 +937,7 @@ SEQUENCE_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, return -1; /* Print the member itself */ - ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, + ret = elm->type->op->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } @@ -1031,7 +1031,7 @@ asn_dec_rval_t SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; + asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; void *st = *sptr; /* Target structure. */ int extpresent; /* Extension additions are present */ uint8_t *opres; /* Presence of optional root members */ @@ -1082,7 +1082,7 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, */ for(edx = 0; edx < td->elements_count; edx++) { asn_TYPE_member_t *elm = &td->elements[edx]; - void *memb_ptr; /* Pointer to the member */ + void *memb_ptr; /* Pointer to the member */ void **memb_ptr2; /* Pointer to that pointer */ if(IN_EXTENSION_GROUP(specs, edx)) @@ -1121,13 +1121,13 @@ SEQUENCE_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* Fetch the member from the stream */ ASN_DEBUG("Decoding member \"%s\" in %s", elm->name, td->name); - if((elm->flags & ATF_OPEN_TYPE) && elm->type_selector) { - rv = OPEN_TYPE_uper_get(opt_codec_ctx, td, st, elm, pd); - } else { - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, - elm->per_constraints, memb_ptr2, pd); - } - if(rv.code != RC_OK) { + if((elm->flags & ATF_OPEN_TYPE) && elm->type_selector) { + rv = OPEN_TYPE_uper_get(opt_codec_ctx, td, st, elm, pd); + } else { + rv = elm->type->op->uper_decoder(opt_codec_ctx, elm->type, + elm->per_constraints, memb_ptr2, pd); + } + if(rv.code != RC_OK) { ASN_DEBUG("Failed decode %s in %s", elm->name, td->name); FREEMEM(opres); @@ -1304,7 +1304,7 @@ asn_enc_rval_t SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - asn_SEQUENCE_specifics_t *specs + asn_SEQUENCE_specifics_t *specs = (asn_SEQUENCE_specifics_t *)td->specifics; asn_enc_rval_t er; int n_extensions; @@ -1327,7 +1327,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, */ if(specs->ext_before >= 0) { n_extensions = SEQUENCE_handle_extensions(td, sptr, 0, 0); - if(n_extensions < 0) + if(n_extensions < 0) ASN__ENCODE_FAILED; if(per_put_few_bits(po, n_extensions ? 1 : 0, 1)) ASN__ENCODE_FAILED; @@ -1405,7 +1405,7 @@ SEQUENCE_encode_uper(asn_TYPE_descriptor_t *td, continue; ASN_DEBUG("Encoding %s->%s", td->name, elm->name); - er = elm->type->uper_encoder(elm->type, elm->per_constraints, + er = elm->type->op->uper_encoder(elm->type, elm->per_constraints, *memb_ptr2, po); if(er.encoded == -1) return er; @@ -1460,10 +1460,36 @@ SEQUENCE_compare(const asn_TYPE_descriptor_t *td, const void *aptr, bmemb = (const void *)((const char *)bptr + elm->memb_offset); } - ret = elm->type->compare_struct(elm->type, amemb, bmemb); + ret = elm->type->op->compare_struct(elm->type, amemb, bmemb); if(ret != 0) return ret; } return 0; } +asn_TYPE_operation_t asn_OP_SEQUENCE = { + SEQUENCE_free, + SEQUENCE_print, + SEQUENCE_compare, + SEQUENCE_constraint, + SEQUENCE_decode_ber, + SEQUENCE_encode_der, + SEQUENCE_decode_xer, + SEQUENCE_encode_xer, +#ifdef ASN_DISABLE_OER_SUPPORT + 0, + 0, +#else + SEQUENCE_decode_oer, + SEQUENCE_encode_oer, +#endif /* ASN_DISABLE_OER_SUPPORT */ +#ifdef ASN_DISABLE_PER_SUPPORT + 0, + 0, +#else + SEQUENCE_decode_uper, + SEQUENCE_encode_uper, +#endif /* ASN_DISABLE_PER_SUPPORT */ + 0 /* Use generic outmost tag fetcher */ +}; + diff --git a/skeletons/constr_SEQUENCE.h b/skeletons/constr_SEQUENCE.h index 747b34e2..e4d3801b 100644 --- a/skeletons/constr_SEQUENCE.h +++ b/skeletons/constr_SEQUENCE.h @@ -22,21 +22,21 @@ typedef const struct asn_SEQUENCE_specifics_s { * Tags to members mapping table (sorted). */ const asn_TYPE_tag2member_t *tag2el; - unsigned tag2el_count; + unsigned tag2el_count; - /* + /* * Optional members of the extensions root (roms) or additions (aoms). * Meaningful for PER. */ - const int *oms; /* Optional MemberS */ - unsigned roms_count; /* Root optional members count */ - unsigned aoms_count; /* Additions optional members count */ + const int *oms; /* Optional MemberS */ + unsigned roms_count; /* Root optional members count */ + unsigned aoms_count; /* Additions optional members count */ - /* + /* * Description of an extensions group. */ - signed ext_after; /* Extensions start after this member */ - signed ext_before; /* Extensions stop before this member */ + signed ext_after; /* Extensions start after this member */ + signed ext_before; /* Extensions stop before this member */ } asn_SEQUENCE_specifics_t; @@ -55,6 +55,7 @@ oer_type_decoder_f SEQUENCE_decode_oer; oer_type_encoder_f SEQUENCE_encode_oer; per_type_decoder_f SEQUENCE_decode_uper; per_type_encoder_f SEQUENCE_encode_uper; +extern asn_TYPE_operation_t asn_OP_SEQUENCE; #ifdef __cplusplus } diff --git a/skeletons/constr_SEQUENCE_OF.c b/skeletons/constr_SEQUENCE_OF.c index 73a72585..617dc2eb 100644 --- a/skeletons/constr_SEQUENCE_OF.c +++ b/skeletons/constr_SEQUENCE_OF.c @@ -29,7 +29,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; if(!memb_ptr) continue; - erval = elm->type->der_encoder(elm->type, memb_ptr, + erval = elm->type->op->der_encoder(elm->type, memb_ptr, 0, elm->tag, 0, 0); if(erval.encoded == -1) @@ -63,7 +63,7 @@ SEQUENCE_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, for(edx = 0; edx < list->count; edx++) { void *memb_ptr = list->array[edx]; if(!memb_ptr) continue; - erval = elm->type->der_encoder(elm->type, memb_ptr, + erval = elm->type->op->der_encoder(elm->type, memb_ptr, 0, elm->tag, cb, app_key); if(erval.encoded == -1) @@ -115,7 +115,7 @@ SEQUENCE_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, ASN__CALLBACK3("<", 1, mname, mlen, ">", 1); } - tmper = elm->type->xer_encoder(elm->type, memb_ptr, + tmper = elm->type->op->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; if(tmper.encoded == 0 && specs->as_XMLValueList) { @@ -144,7 +144,7 @@ asn_enc_rval_t SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void *sptr, asn_per_outp_t *po) { - asn_anonymous_sequence_ *list; + asn_anonymous_sequence_ *list; const asn_per_constraint_t *ct; asn_enc_rval_t er; asn_TYPE_member_t *elm = td->elements; @@ -197,7 +197,7 @@ SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, while(mayEncode--) { void *memb_ptr = list->array[seq++]; if(!memb_ptr) ASN__ENCODE_FAILED; - er = elm->type->uper_encoder(elm->type, + er = elm->type->op->uper_encoder(elm->type, elm->per_constraints, memb_ptr, po); if(er.encoded == -1) ASN__ENCODE_FAILED; @@ -207,3 +207,29 @@ SEQUENCE_OF_encode_uper(asn_TYPE_descriptor_t *td, ASN__ENCODED_OK(er); } +asn_TYPE_operation_t asn_OP_SEQUENCE_OF = { + SEQUENCE_OF_free, + SEQUENCE_OF_print, + SEQUENCE_OF_compare, + SEQUENCE_OF_constraint, + SEQUENCE_OF_decode_ber, + SEQUENCE_OF_encode_der, + SEQUENCE_OF_decode_xer, + SEQUENCE_OF_encode_xer, +#ifdef ASN_DISABLE_OER_SUPPORT + 0, + 0, +#else + 0, + 0, +#endif /* ASN_DISABLE_OER_SUPPORT */ +#ifdef ASN_DISABLE_PER_SUPPORT + 0, + 0, +#else + SEQUENCE_OF_decode_uper, + SEQUENCE_OF_encode_uper, +#endif /* ASN_DISABLE_PER_SUPPORT */ + 0 /* Use generic outmost tag fetcher */ +}; + diff --git a/skeletons/constr_SEQUENCE_OF.h b/skeletons/constr_SEQUENCE_OF.h index cc7f3701..d0a09ebb 100644 --- a/skeletons/constr_SEQUENCE_OF.h +++ b/skeletons/constr_SEQUENCE_OF.h @@ -18,7 +18,7 @@ extern "C" { */ #define SEQUENCE_OF_free SET_OF_free #define SEQUENCE_OF_print SET_OF_print -#define SEQUENCE_OF_compare SET_OF_compare +#define SEQUENCE_OF_compare SET_OF_compare #define SEQUENCE_OF_constraint SET_OF_constraint #define SEQUENCE_OF_decode_ber SET_OF_decode_ber #define SEQUENCE_OF_decode_xer SET_OF_decode_xer @@ -26,6 +26,7 @@ extern "C" { der_type_encoder_f SEQUENCE_OF_encode_der; xer_type_encoder_f SEQUENCE_OF_encode_xer; per_type_encoder_f SEQUENCE_OF_encode_uper; +extern asn_TYPE_operation_t asn_OP_SEQUENCE_OF; #ifdef __cplusplus } diff --git a/skeletons/constr_SEQUENCE_oer.c b/skeletons/constr_SEQUENCE_oer.c index 7f162ae7..91e4ac3c 100644 --- a/skeletons/constr_SEQUENCE_oer.c +++ b/skeletons/constr_SEQUENCE_oer.c @@ -201,7 +201,7 @@ SEQUENCE_decode_oer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, memb_ptr2 = &memb_tmpptr; /* Ensure remains in scope! */ } - rval = elm->type->oer_decoder(opt_codec_ctx, elm->type, + rval = elm->type->op->oer_decoder(opt_codec_ctx, elm->type, elm->oer_constraints, memb_ptr2, ptr, size); } @@ -458,11 +458,11 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td, /* Mandatory element is missing */ ASN__ENCODE_FAILED; } - if(!elm->type->oer_encoder) { + if(!elm->type->op->oer_encoder) { ASN_DEBUG("OER encoder is not defined for type %s", elm->type->name); ASN__ENCODE_FAILED; } - er = elm->type->oer_encoder(elm->type, elm->oer_constraints, memb_ptr, + er = elm->type->op->oer_encoder(elm->type, elm->oer_constraints, memb_ptr, cb, app_key); if(er.encoded == -1) { ASN_DEBUG("... while encoding %s member \"%s\"\n", td->name, @@ -517,7 +517,7 @@ SEQUENCE_encode_oer(asn_TYPE_descriptor_t *td, void *memb_ptr = element_ptr(sptr, elm); if(memb_ptr) { - asn_enc_rval_t er = elm->type->oer_encoder( + asn_enc_rval_t er = elm->type->op->oer_encoder( elm->type, elm->oer_constraints, memb_ptr, cb, app_key); if(er.encoded == -1) { return er; diff --git a/skeletons/constr_SET.c b/skeletons/constr_SET.c index 4f370bf0..2f91d0eb 100644 --- a/skeletons/constr_SET.c +++ b/skeletons/constr_SET.c @@ -296,7 +296,7 @@ SET_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Invoke the member fetch routine according to member's type */ - rval = elements[edx].type->ber_decoder(opt_codec_ctx, + rval = elements[edx].type->op->ber_decoder(opt_codec_ctx, elements[edx].type, memb_ptr2, ptr, LEFT, elements[edx].tag_mode); @@ -488,7 +488,7 @@ SET_encode_der(asn_TYPE_descriptor_t *td, } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - tmper = elm->type->der_encoder(elm->type, memb_ptr, + tmper = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, 0, 0); if(tmper.encoded == -1) @@ -555,7 +555,7 @@ SET_encode_der(asn_TYPE_descriptor_t *td, } else { memb_ptr = (void *)((char *)sptr + elm->memb_offset); } - tmper = elm->type->der_encoder(elm->type, memb_ptr, + tmper = elm->type->op->der_encoder(elm->type, memb_ptr, elm->tag_mode, elm->tag, cb, app_key); if(tmper.encoded == -1) @@ -658,7 +658,7 @@ SET_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, } /* Invoke the inner type decoder, m.b. multiple times */ - tmprval = elm->type->xer_decoder(opt_codec_ctx, + tmprval = elm->type->op->xer_decoder(opt_codec_ctx, elm->type, memb_ptr2, elm->name, buf_ptr, size); XER_ADVANCE(tmprval.consumed); @@ -846,7 +846,7 @@ SET_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, ASN__CALLBACK3("<", 1, mname, mlen, ">", 1); /* Print the member itself */ - tmper = elm->type->xer_encoder(elm->type, memb_ptr, + tmper = elm->type->op->xer_encoder(elm->type, memb_ptr, ilevel + 1, flags, cb, app_key); if(tmper.encoded == -1) return tmper; @@ -898,7 +898,7 @@ SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, return -1; /* Print the member itself */ - ret = elm->type->print_struct(elm->type, memb_ptr, ilevel + 1, + ret = elm->type->op->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } @@ -911,7 +911,7 @@ SET_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, void SET_free(const asn_TYPE_descriptor_t *td, void *ptr, int contents_only) { - size_t edx; + size_t edx; if(!td || !ptr) return; @@ -997,7 +997,7 @@ SET_compare(const asn_TYPE_descriptor_t *td, const void *aptr, asn_TYPE_member_t *elm = &td->elements[edx]; const void *amemb; const void *bmemb; - int ret; + int ret; if(elm->flags & ATF_POINTER) { amemb = @@ -1015,10 +1015,25 @@ SET_compare(const asn_TYPE_descriptor_t *td, const void *aptr, bmemb = (const void *)((const char *)bptr + elm->memb_offset); } - ret = elm->type->compare_struct(elm->type, amemb, bmemb); + ret = elm->type->op->compare_struct(elm->type, amemb, bmemb); if(ret != 0) return ret; } return 0; } + +asn_TYPE_operation_t asn_OP_SET = { + SET_free, + SET_print, + SET_compare, + SET_constraint, + SET_decode_ber, + SET_encode_der, + SET_decode_xer, + SET_encode_xer, + 0, /* SET_decode_uper */ + 0, /* SET_encode_uper */ + 0 /* Use generic outmost tag fetcher */ +}; + diff --git a/skeletons/constr_SET.h b/skeletons/constr_SET.h index 4bafffef..eb61b5a3 100644 --- a/skeletons/constr_SET.h +++ b/skeletons/constr_SET.h @@ -13,33 +13,33 @@ extern "C" { typedef const struct asn_SET_specifics_s { - /* - * Target structure description. - */ - unsigned struct_size; /* Size of the target structure. */ - unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */ - unsigned pres_offset; /* Offset of _presence_map member */ + /* + * Target structure description. + */ + unsigned struct_size; /* Size of the target structure. */ + unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */ + unsigned pres_offset; /* Offset of _presence_map member */ - /* - * Tags to members mapping table (sorted). - * Sometimes suitable for DER encoding (untagged CHOICE is present); - * if so, tag2el_count will be greater than td->elements_count. - */ - const asn_TYPE_tag2member_t *tag2el; - unsigned tag2el_count; + /* + * Tags to members mapping table (sorted). + * Sometimes suitable for DER encoding (untagged CHOICE is present); + * if so, tag2el_count will be greater than td->elements_count. + */ + const asn_TYPE_tag2member_t *tag2el; + unsigned tag2el_count; - /* - * Tags to members mapping table, second edition. - * Suitable for CANONICAL-XER encoding. - */ - const asn_TYPE_tag2member_t *tag2el_cxer; - unsigned tag2el_cxer_count; + /* + * Tags to members mapping table, second edition. + * Suitable for CANONICAL-XER encoding. + */ + const asn_TYPE_tag2member_t *tag2el_cxer; + unsigned tag2el_cxer_count; - /* - * Extensions-related stuff. - */ - int extensible; /* Whether SET is extensible */ - const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ + /* + * Extensions-related stuff. + */ + int extensible; /* Whether SET is extensible */ + const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ } asn_SET_specifics_t; /* @@ -55,6 +55,7 @@ xer_type_decoder_f SET_decode_xer; xer_type_encoder_f SET_encode_xer; per_type_decoder_f SET_decode_uper; per_type_encoder_f SET_encode_uper; +extern asn_TYPE_operation_t asn_OP_SET; /*********************** * Some handy helpers. * diff --git a/skeletons/constr_SET_OF.c b/skeletons/constr_SET_OF.c index 1a268dfd..6033ff8b 100644 --- a/skeletons/constr_SET_OF.c +++ b/skeletons/constr_SET_OF.c @@ -205,7 +205,7 @@ SET_OF_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Invoke the member fetch routine according to member's type */ - rval = elm->type->ber_decoder(opt_codec_ctx, + rval = elm->type->op->ber_decoder(opt_codec_ctx, elm->type, &ctx->ptr, ptr, LEFT, 0); ASN_DEBUG("In %s SET OF %s code %d consumed %d", td->name, elm->type->name, @@ -315,7 +315,7 @@ SET_OF_encode_der(asn_TYPE_descriptor_t *td, void *ptr, asn_app_consume_bytes_f *cb, void *app_key) { asn_TYPE_member_t *elm = td->elements; asn_TYPE_descriptor_t *elm_type = elm->type; - der_type_encoder_f *der_encoder = elm_type->der_encoder; + der_type_encoder_f *der_encoder = elm_type->op->der_encoder; asn_anonymous_set_ *list = _A_SET_FROM_VOID(ptr); size_t computed_size = 0; ssize_t encoding_size = 0; @@ -526,7 +526,7 @@ SET_OF_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* Invoke the inner type decoder, m.b. multiple times */ ASN_DEBUG("XER/SET OF element [%s]", elm_tag); - tmprval = element->type->xer_decoder(opt_codec_ctx, + tmprval = element->type->op->xer_decoder(opt_codec_ctx, element->type, &ctx->ptr, elm_tag, buf_ptr, size); if(tmprval.code == RC_OK) { @@ -697,7 +697,7 @@ SET_OF_encode_xer(asn_TYPE_descriptor_t *td, void *sptr, if(!xcan && specs->as_XMLValueList == 1) ASN__TEXT_INDENT(1, ilevel + 1); - tmper = elm->type->xer_encoder(elm->type, memb_ptr, + tmper = elm->type->op->xer_encoder(elm->type, memb_ptr, ilevel + (specs->as_XMLValueList != 2), flags, cb, app_key); if(tmper.encoded == -1) { @@ -776,7 +776,7 @@ SET_OF_print(asn_TYPE_descriptor_t *td, const void *sptr, int ilevel, _i_INDENT(1); - ret = elm->type->print_struct(elm->type, memb_ptr, + ret = elm->type->op->print_struct(elm->type, memb_ptr, ilevel + 1, cb, app_key); if(ret) return ret; } @@ -868,7 +868,7 @@ asn_dec_rval_t SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void **sptr, asn_per_data_t *pd) { - asn_dec_rval_t rv; + asn_dec_rval_t rv; asn_SET_OF_specifics_t *specs = (asn_SET_OF_specifics_t *)td->specifics; asn_TYPE_member_t *elm = td->elements; /* Single one */ void *st = *sptr; @@ -924,7 +924,7 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, for(i = 0; i < nelems; i++) { void *ptr = 0; ASN_DEBUG("SET OF %s decoding", elm->type->name); - rv = elm->type->uper_decoder(opt_codec_ctx, elm->type, + rv = elm->type->op->uper_decoder(opt_codec_ctx, elm->type, elm->per_constraints, &ptr, pd); ASN_DEBUG("%s SET OF %s decoded %d, %p", td->name, elm->type->name, rv.code, ptr); @@ -956,9 +956,31 @@ SET_OF_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, int SET_OF_compare(const asn_TYPE_descriptor_t *td, const void *aptr, const void *bptr) { - (void)td; - (void)aptr; - (void)bptr; - /* Not implemented yet. */ - return 0; + (void)td; + (void)aptr; + (void)bptr; + /* Not implemented yet. */ + return 0; } + + +asn_TYPE_operation_t asn_OP_SET_OF = { + SET_OF_free, + SET_OF_print, + SET_OF_compare, + SET_OF_constraint, + SET_OF_decode_ber, + SET_OF_encode_der, + SET_OF_decode_xer, + SET_OF_encode_xer, + 0, + 0, +#ifdef ASN_DISABLE_PER_SUPPORT + 0, + 0, +#else + SET_OF_decode_uper, + 0, /* SET_OF_encode_uper */ +#endif /* ASN_DISABLE_PER_SUPPORT */ + 0 /* Use generic outmost tag fetcher */ +}; diff --git a/skeletons/constr_SET_OF.h b/skeletons/constr_SET_OF.h index a77931d3..a6bfb3c6 100644 --- a/skeletons/constr_SET_OF.h +++ b/skeletons/constr_SET_OF.h @@ -35,6 +35,7 @@ xer_type_decoder_f SET_OF_decode_xer; xer_type_encoder_f SET_OF_encode_xer; per_type_decoder_f SET_OF_decode_uper; per_type_encoder_f SET_OF_encode_uper; +extern asn_TYPE_operation_t asn_OP_SET_OF; #ifdef __cplusplus } diff --git a/skeletons/constr_TYPE.c b/skeletons/constr_TYPE.c index 322f68c8..7a135ce2 100644 --- a/skeletons/constr_TYPE.c +++ b/skeletons/constr_TYPE.c @@ -26,7 +26,7 @@ asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor, if(type_descriptor->tags_count) return type_descriptor->tags[0]; - return type_descriptor->outmost_tag(type_descriptor, struct_ptr, 0, 0); + return type_descriptor->op->outmost_tag(type_descriptor, struct_ptr, 0, 0); } /* @@ -41,7 +41,7 @@ asn_fprint(FILE *stream, asn_TYPE_descriptor_t *td, const void *struct_ptr) { } /* Invoke type-specific printer */ - if(td->print_struct(td, struct_ptr, 1, _print2fp, stream)) + if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) return -1; /* Terminate the output */ diff --git a/skeletons/constr_TYPE.h b/skeletons/constr_TYPE.h index a7db7b0b..8ae27a77 100644 --- a/skeletons/constr_TYPE.h +++ b/skeletons/constr_TYPE.h @@ -55,9 +55,9 @@ typedef struct asn_struct_ctx_s { typedef void (asn_struct_free_f)( const struct asn_TYPE_descriptor_s *type_descriptor, void *struct_ptr, int free_contents_only); -#define ASN_STRUCT_FREE(asn_DEF, ptr) (asn_DEF).free_struct(&(asn_DEF),ptr,0) +#define ASN_STRUCT_FREE(asn_DEF, ptr) (asn_DEF).op->free_struct(&(asn_DEF),ptr,0) #define ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF, ptr) \ - (asn_DEF).free_struct(&(asn_DEF),ptr,1) + (asn_DEF).op->free_struct(&(asn_DEF),ptr,1) /* * Print the structure according to its specification. @@ -104,16 +104,10 @@ typedef asn_type_selector_result_t(asn_type_selector_f)( const void *parent_structure_ptr); /* - * The definitive description of the destination language's structure. + * Generalized functions for dealing with the speciic type. + * May be directly invoked by applications. */ -typedef struct asn_TYPE_descriptor_s { - const char *name; /* A name of the ASN.1 type. "" in some cases. */ - const char *xml_tag; /* Name used in XML tag */ - - /* - * Generalized functions for dealing with the specific type. - * May be directly invoked by applications. - */ +typedef struct asn_TYPE_operation_s { asn_struct_free_f *free_struct; /* Free the structure */ asn_struct_print_f *print_struct; /* Human readable output */ asn_struct_compare_f *compare_struct; /* Compare two structures */ @@ -126,6 +120,22 @@ typedef struct asn_TYPE_descriptor_s { oer_type_encoder_f *oer_encoder; /* Canonical OER encoder */ per_type_decoder_f *uper_decoder; /* Unaligned PER decoder */ per_type_encoder_f *uper_encoder; /* Unaligned PER encoder */ + asn_outmost_tag_f *outmost_tag; /* <optional, internal> */ +} asn_TYPE_operation_t; + +/* + * The definitive description of the destination language's structure. + */ +typedef struct asn_TYPE_descriptor_s { + const char *name; /* A name of the ASN.1 type. "" in some cases. */ + const char *xml_tag; /* Name used in XML tag */ + + /* + * Generalized functions for dealing with the specific type. + * May be directly invoked by applications. + */ + asn_TYPE_operation_t *op; + asn_constr_check_f *check_constraints; /* Constraints validator */ /*********************************************************************** * Internally useful members. Not to be used by applications directly. * @@ -134,7 +144,6 @@ typedef struct asn_TYPE_descriptor_s { /* * Tags that are expected to occur. */ - asn_outmost_tag_f *outmost_tag; /* <optional, internal> */ const ber_tlv_tag_t *tags; /* Effective tags sequence for this type */ unsigned tags_count; /* Number of tags which are expected */ const ber_tlv_tag_t *all_tags; /* Every tag for BER/containment */ diff --git a/skeletons/converter-sample.c b/skeletons/converter-sample.c index 70087dc9..8c870306 100644 --- a/skeletons/converter-sample.c +++ b/skeletons/converter-sample.c @@ -94,9 +94,9 @@ main(int ac, char *av[]) { int ch; /* Figure out if specialty decoder needs to be default */ - if(pduType->oer_decoder) + if(pduType->op->oer_decoder) iform = INP_OER; - else if(pduType->uper_decoder) + else if(pduType->op->uper_decoder) iform = INP_PER; /* @@ -107,18 +107,18 @@ main(int ac, char *av[]) { case 'i': if(optarg[0] == 'b') { iform = INP_BER; break; } if(optarg[0] == 'x') { iform = INP_XER; break; } - if(pduType->oer_decoder + if(pduType->op->oer_decoder && optarg[0] == 'o') { iform = INP_OER; break; } - if(pduType->uper_decoder + if(pduType->op->uper_decoder && optarg[0] == 'p') { iform = INP_PER; break; } fprintf(stderr, "-i<format>: '%s': improper format selector\n", optarg); exit(EX_UNAVAILABLE); case 'o': if(optarg[0] == 'd') { oform = OUT_DER; break; } - if(pduType->oer_encoder + if(pduType->op->oer_encoder && optarg[0] == 'o') { oform = OUT_OER; break; } - if(pduType->uper_encoder + if(pduType->op->uper_encoder && optarg[0] == 'p') { oform = OUT_PER; break; } if(optarg[0] == 'x') { oform = OUT_XER; break; } if(optarg[0] == 't') { oform = OUT_TEXT; break; } @@ -215,11 +215,11 @@ main(int ac, char *av[]) { #endif fprintf(stderr, "Usage: %s [options] <data.ber> ...\n", av[0]); fprintf(stderr, "Where options are:\n"); - if(pduType->oer_decoder) + if(pduType->op->oer_decoder) fprintf(stderr, " -ioer Input is in OER (Octet Encoding Rules)%s\n", iform == INP_OER ? " (DEFAULT)" : ""); - if(pduType->uper_decoder) + if(pduType->op->uper_decoder) fprintf(stderr, " -iper Input is in Unaligned PER (Packed Encoding Rules)%s\n", iform == INP_PER ? " (DEFAULT)" : ""); @@ -228,10 +228,10 @@ main(int ac, char *av[]) { iform == INP_BER ? " (DEFAULT)" : ""); fprintf(stderr, " -ixer Input is in XER (XML Encoding Rules)\n"); - if(pduType->oer_encoder) + if(pduType->op->oer_encoder) fprintf(stderr, " -ooer Output in Canonical OER (Octet Encoding Rules)\n"); - if(pduType->uper_encoder) + if(pduType->op->uper_encoder) fprintf(stderr, " -oper Output in Unaligned PER (Packed Encoding Rules)\n"); fprintf(stderr, @@ -239,7 +239,7 @@ main(int ac, char *av[]) { " -oxer Output in XER (XML Encoding Rules) (DEFAULT)\n" " -otext Output in plain semi-structured text (dump)\n" " -onull Verify (decode) input, but do not output\n"); - if(pduType->uper_decoder) + if(pduType->op->uper_decoder) fprintf(stderr, " -per-nopad Assume PER PDUs are not padded (-iper)\n"); #ifdef ASN_PDU_COLLECTION diff --git a/skeletons/der_encoder.c b/skeletons/der_encoder.c index 1e2668e0..8673a31c 100644 --- a/skeletons/der_encoder.c +++ b/skeletons/der_encoder.c @@ -21,7 +21,7 @@ der_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr, /* * Invoke type-specific encoder. */ - return type_descriptor->der_encoder(type_descriptor, + return type_descriptor->op->der_encoder(type_descriptor, struct_ptr, /* Pointer to the destination structure */ 0, 0, consume_bytes, app_key); @@ -59,7 +59,7 @@ der_encode_to_buffer(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr, arg.buffer = buffer; arg.left = buffer_size; - ec = type_descriptor->der_encoder(type_descriptor, + ec = type_descriptor->op->der_encoder(type_descriptor, struct_ptr, /* Pointer to the destination structure */ 0, 0, encode_to_buffer_cb, &arg); if(ec.encoded != -1) { diff --git a/skeletons/oer_decoder.c b/skeletons/oer_decoder.c index e179ae21..2e6d2791 100644 --- a/skeletons/oer_decoder.c +++ b/skeletons/oer_decoder.c @@ -32,7 +32,7 @@ oer_decode(asn_codec_ctx_t *opt_codec_ctx, /* * Invoke type-specific decoder. */ - return type_descriptor->oer_decoder(opt_codec_ctx, type_descriptor, 0, + return type_descriptor->op->oer_decoder(opt_codec_ctx, type_descriptor, 0, struct_ptr, /* Pointer to the destination structure */ ptr, size /* Buffer and its size */ ); @@ -80,7 +80,7 @@ oer_open_type_get(asn_codec_ctx_t *opt_codec_ctx, return 0; } - dr = td->oer_decoder(opt_codec_ctx, td, constraints, struct_ptr, + dr = td->op->oer_decoder(opt_codec_ctx, td, constraints, struct_ptr, (const uint8_t *)bufptr + len_len, container_len); if(dr.code == RC_OK) { return len_len + container_len; diff --git a/skeletons/oer_encoder.c b/skeletons/oer_encoder.c index 490043cd..af3c7d1c 100644 --- a/skeletons/oer_encoder.c +++ b/skeletons/oer_encoder.c @@ -17,7 +17,7 @@ oer_encode(asn_TYPE_descriptor_t *type_descriptor, void *struct_ptr, /* * Invoke type-specific encoder. */ - return type_descriptor->oer_encoder(type_descriptor, 0, + return type_descriptor->op->oer_encoder(type_descriptor, 0, struct_ptr, /* Pointer to the destination structure */ consume_bytes, app_key); } @@ -58,14 +58,14 @@ oer_encode_to_buffer(struct asn_TYPE_descriptor_s *type_descriptor, arg.buffer = buffer; arg.left = buffer_size; - if(type_descriptor->oer_encoder == NULL) { + if(type_descriptor->op->oer_encoder == NULL) { ec.encoded = -1; ec.failed_type = type_descriptor; ec.structure_ptr = struct_ptr; ASN_DEBUG("OER encoder is not defined for %s", type_descriptor->name); } else { - ec = type_descriptor->oer_encoder( + ec = type_descriptor->op->oer_encoder( type_descriptor, constraints, struct_ptr, /* Pointer to the destination structure */ encode_to_buffer_cb, &arg); diff --git a/skeletons/per_decoder.c b/skeletons/per_decoder.c index 461b7262..a31fe8eb 100644 --- a/skeletons/per_decoder.c +++ b/skeletons/per_decoder.c @@ -74,9 +74,9 @@ uper_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **sp /* * Invoke type-specific decoder. */ - if(!td->uper_decoder) + if(!td->op->uper_decoder) ASN__DECODE_FAILED; /* PER is not compiled in */ - rval = td->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd); + rval = td->op->uper_decoder(opt_codec_ctx, td, 0, sptr, &pd); if(rval.code == RC_OK) { /* Return the number of consumed bits */ rval.consumed = ((pd.buffer - (const uint8_t *)buffer) << 3) diff --git a/skeletons/per_encoder.c b/skeletons/per_encoder.c index 2ccfdf04..5e3a77a2 100644 --- a/skeletons/per_encoder.c +++ b/skeletons/per_encoder.c @@ -121,13 +121,13 @@ static asn_enc_rval_t uper_encode_internal(asn_TYPE_descriptor_t *td, const asn_per_constraints_t *constraints, void *sptr, asn_app_consume_bytes_f *cb, void *app_key) { - asn_per_outp_t po; + asn_per_outp_t po; asn_enc_rval_t er; /* * Invoke type-specific encoder. */ - if(!td || !td->uper_encoder) + if(!td || !td->op->uper_encoder) ASN__ENCODE_FAILED; /* PER is not compiled in */ po.buffer = po.tmpspace; @@ -137,7 +137,7 @@ uper_encode_internal(asn_TYPE_descriptor_t *td, po.op_key = app_key; po.flushed_bytes = 0; - er = td->uper_encoder(td, constraints, sptr, &po); + er = td->op->uper_encoder(td, constraints, sptr, &po); if(er.encoded != -1) { size_t bits_to_flush; diff --git a/skeletons/per_opentype.c b/skeletons/per_opentype.c index 589bb4a1..2ccaf39f 100644 --- a/skeletons/per_opentype.c +++ b/skeletons/per_opentype.c @@ -103,7 +103,7 @@ uper_open_type_get_simple(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, spd.nbits = bufLen << 3; ASN_DEBUG_INDENT_ADD(+4); - rv = td->uper_decoder(ctx, td, constraints, sptr, &spd); + rv = td->op->uper_decoder(ctx, td, constraints, sptr, &spd); ASN_DEBUG_INDENT_ADD(-4); if(rv.code == RC_OK) { @@ -155,7 +155,7 @@ uper_open_type_get_complex(asn_codec_ctx_t *ctx, asn_TYPE_descriptor_t *td, pd->moved = 0; /* This now counts the open type size in bits */ ASN_DEBUG_INDENT_ADD(+4); - rv = td->uper_decoder(ctx, td, constraints, sptr, pd); + rv = td->op->uper_decoder(ctx, td, constraints, sptr, pd); ASN_DEBUG_INDENT_ADD(-4); #define UPDRESTOREPD do { \ @@ -257,7 +257,7 @@ uper_open_type_skip(asn_codec_ctx_t *ctx, asn_per_data_t *pd) { asn_dec_rval_t rv; s_td.name = "<unknown extension>"; - s_td.uper_decoder = uper_sot_suck; + s_td.op->uper_decoder = uper_sot_suck; rv = uper_open_type_get(ctx, &s_td, 0, 0, pd); if(rv.code != RC_OK) diff --git a/skeletons/tests/check-INTEGER.c b/skeletons/tests/check-INTEGER.c index 8c4496cb..543ae549 100644 --- a/skeletons/tests/check-INTEGER.c +++ b/skeletons/tests/check-INTEGER.c @@ -166,7 +166,7 @@ check_xer(int tofail, char *xmldata, long orig_value) { assert(value == orig_value); - asn_DEF_INTEGER.free_struct(&asn_DEF_INTEGER, st, 0); + ASN_STRUCT_FREE(asn_DEF_INTEGER, st); } int diff --git a/skeletons/tests/check-OER-INTEGER.c b/skeletons/tests/check-OER-INTEGER.c index ca35823c..91a9f1ed 100644 --- a/skeletons/tests/check-OER-INTEGER.c +++ b/skeletons/tests/check-OER-INTEGER.c @@ -40,7 +40,7 @@ check_decode(int lineno, enum asn_dec_rval_code_e code, intmax_t control, const (void)dummy; - ret = asn_DEF_INTEGER.oer_decoder(0, &asn_DEF_INTEGER, constraints, + ret = asn_DEF_INTEGER.op->oer_decoder(0, &asn_DEF_INTEGER, constraints, (void **)&st, buf, size); if(ret.code != RC_OK) { /* Basic OER decode does not work */ @@ -124,7 +124,7 @@ check_roundtrip(int lineno, intmax_t value, intmax_t lower_bound, intmax_t upper dump_data(lineno, tmpbuf, tmpbuf_size); - ret = asn_DEF_INTEGER.oer_decoder(0, &asn_DEF_INTEGER, constraints, + ret = asn_DEF_INTEGER.op->oer_decoder(0, &asn_DEF_INTEGER, constraints, (void **)&stIn, tmpbuf, tmpbuf_size); if(ret.code != RC_OK) { /* Basic OER decode does not work */ diff --git a/skeletons/tests/check-OIDs.c b/skeletons/tests/check-OIDs.c index fbb09489..92c27d5c 100644 --- a/skeletons/tests/check-OIDs.c +++ b/skeletons/tests/check-OIDs.c @@ -246,7 +246,7 @@ static void check_xer(int expect_arcs, char *xer) { int i; printf("[%s] => ", xer); fflush(stdout); - rc = asn_DEF_RELATIVE_OID.xer_decoder(0, + rc = asn_DEF_RELATIVE_OID.op->xer_decoder(0, &asn_DEF_RELATIVE_OID, (void **)stp, "t", xer, strlen(xer)); if(expect_arcs == -1) { diff --git a/skeletons/tests/check-length.c b/skeletons/tests/check-length.c index aa73b2c9..d09e5817 100644 --- a/skeletons/tests/check-length.c +++ b/skeletons/tests/check-length.c @@ -74,8 +74,8 @@ check(size_t size) { } - asn_DEF_OCTET_STRING.free_struct(&asn_DEF_OCTET_STRING, os, 0); - asn_DEF_OCTET_STRING.free_struct(&asn_DEF_OCTET_STRING, nos, 0); + ASN_STRUCT_FREE(asn_DEF_OCTET_STRING, os); + ASN_STRUCT_FREE(asn_DEF_OCTET_STRING, nos); } int diff --git a/skeletons/xer_decoder.c b/skeletons/xer_decoder.c index 299a7c1e..fb10bfdb 100644 --- a/skeletons/xer_decoder.c +++ b/skeletons/xer_decoder.c @@ -34,7 +34,7 @@ xer_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, /* * Invoke type-specific decoder. */ - return td->xer_decoder(opt_codec_ctx, td, struct_ptr, 0, buffer, size); + return td->op->xer_decoder(opt_codec_ctx, td, struct_ptr, 0, buffer, size); } diff --git a/skeletons/xer_encoder.c b/skeletons/xer_encoder.c index e52ee158..25b3bfac 100644 --- a/skeletons/xer_encoder.c +++ b/skeletons/xer_encoder.c @@ -25,7 +25,7 @@ xer_encode(asn_TYPE_descriptor_t *td, void *sptr, ASN__CALLBACK3("<", 1, mname, mlen, ">", 1); - tmper = td->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); + tmper = td->op->xer_encoder(td, sptr, 1, xer_flags, cb, app_key); if(tmper.encoded == -1) return tmper; ASN__CALLBACK3("</", 2, mname, mlen, ">\n", xcan); |