Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 1 | |
Lev Walkin | b47ddce | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 2 | /*** <<< INCLUDES [PrimitiveType] >>> ***/ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 3 | |
| 4 | #include <OCTET_STRING.h> |
| 5 | |
| 6 | /*** <<< TYPE-DECLS [PrimitiveType] >>> ***/ |
| 7 | |
| 8 | |
| 9 | typedef OCTET_STRING_t PrimitiveType_t; |
| 10 | |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 11 | /*** <<< FUNC-DECLS [PrimitiveType] >>> ***/ |
| 12 | |
Lev Walkin | 154aa18 | 2004-09-26 13:12:56 +0000 | [diff] [blame] | 13 | /* This type is equivalent to OCTET_STRING */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 14 | #define asn_DEF_PrimitiveType asn_DEF_OCTET_STRING |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 15 | |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 16 | /*** <<< CODE [PrimitiveType] >>> ***/ |
| 17 | |
Lev Walkin | 154aa18 | 2004-09-26 13:12:56 +0000 | [diff] [blame] | 18 | /* This type is equivalent to OCTET_STRING */ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 19 | |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 20 | |
Lev Walkin | b47ddce | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 21 | /*** <<< INCLUDES [ConstructedType] >>> ***/ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 22 | |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 23 | #include <PrimitiveType.h> |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 24 | #include <constr_SEQUENCE.h> |
| 25 | |
Lev Walkin | b47ddce | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 26 | /*** <<< DEPS [ConstructedType] >>> ***/ |
| 27 | |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 28 | extern asn_TYPE_descriptor_t asn_DEF_ConstructedType; |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 29 | |
| 30 | /*** <<< TYPE-DECLS [ConstructedType] >>> ***/ |
| 31 | |
| 32 | |
| 33 | typedef struct ConstructedType { |
| 34 | PrimitiveType_t field; |
| 35 | |
| 36 | /* Context for parsing across buffer boundaries */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 37 | asn_struct_ctx_t _asn_ctx; |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 38 | } ConstructedType_t; |
| 39 | |
| 40 | /*** <<< STAT-DEFS [ConstructedType] >>> ***/ |
| 41 | |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 42 | static asn_TYPE_member_t asn_MBR_ConstructedType[] = { |
Lev Walkin | cc93b0f | 2004-09-10 09:18:20 +0000 | [diff] [blame] | 43 | { ATF_NOFLAGS, 0, offsetof(struct ConstructedType, field), |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 44 | .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
| 45 | .tag_mode = -1, /* IMPLICIT tag at current level */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 46 | .type = (void *)&asn_DEF_PrimitiveType, |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 47 | .memb_constraints = 0, /* Defer to actual type */ |
| 48 | .name = "field" |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 49 | }, |
| 50 | }; |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 51 | static ber_tlv_tag_t asn_DEF_ConstructedType_tags[] = { |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 52 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 53 | }; |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 54 | static asn_TYPE_tag2member_t asn_DEF_ConstructedType_tag2el[] = { |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 55 | { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */ |
| 56 | }; |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 57 | static asn_SEQUENCE_specifics_t asn_DEF_ConstructedType_specs = { |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 58 | sizeof(struct ConstructedType), |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 59 | offsetof(struct ConstructedType, _asn_ctx), |
| 60 | asn_DEF_ConstructedType_tag2el, |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 61 | 1, /* Count of tags in the map */ |
| 62 | -1, /* Start extensions */ |
| 63 | -1 /* Stop extensions */ |
| 64 | }; |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 65 | asn_TYPE_descriptor_t asn_DEF_ConstructedType = { |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 66 | "ConstructedType", |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 67 | SEQUENCE_free, |
| 68 | SEQUENCE_print, |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 69 | SEQUENCE_constraint, |
| 70 | SEQUENCE_decode_ber, |
| 71 | SEQUENCE_encode_der, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 72 | 0, /* Not implemented yet */ |
| 73 | SEQUENCE_encode_xer, |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 74 | 0, /* Use generic outmost tag fetcher */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 75 | asn_DEF_ConstructedType_tags, |
| 76 | sizeof(asn_DEF_ConstructedType_tags) |
| 77 | /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */ |
| 78 | asn_DEF_ConstructedType_tags, /* Same as above */ |
| 79 | sizeof(asn_DEF_ConstructedType_tags) |
| 80 | /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */ |
| 81 | asn_MBR_ConstructedType, |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 82 | 1, /* Elements count */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 83 | &asn_DEF_ConstructedType_specs /* Additional specs */ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
| 86 | |
Lev Walkin | b47ddce | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 87 | /*** <<< INCLUDES [T] >>> ***/ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 88 | |
| 89 | #include <ConstructedType.h> |
| 90 | |
| 91 | /*** <<< TYPE-DECLS [T] >>> ***/ |
| 92 | |
| 93 | |
| 94 | typedef ConstructedType_t T_t; |
| 95 | |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 96 | /*** <<< FUNC-DECLS [T] >>> ***/ |
| 97 | |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 98 | extern asn_TYPE_descriptor_t asn_DEF_T; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 99 | asn_struct_free_f T_free; |
| 100 | asn_struct_print_f T_print; |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 101 | asn_constr_check_f T_constraint; |
| 102 | ber_type_decoder_f T_decode_ber; |
| 103 | der_type_encoder_f T_encode_der; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 104 | xer_type_encoder_f T_encode_xer; |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 105 | |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 106 | /*** <<< CODE [T] >>> ***/ |
| 107 | |
| 108 | int |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 109 | T_constraint(asn_TYPE_descriptor_t *td, const void *sptr, |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 110 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
Lev Walkin | 154aa18 | 2004-09-26 13:12:56 +0000 | [diff] [blame] | 111 | /* Replace with underlying type checker */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 112 | td->check_constraints = asn_DEF_ConstructedType.check_constraints; |
Lev Walkin | 154aa18 | 2004-09-26 13:12:56 +0000 | [diff] [blame] | 113 | return td->check_constraints(td, sptr, app_errlog, app_key); |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /* |
| 117 | * This type is implemented using ConstructedType, |
Lev Walkin | c3808c1 | 2004-09-23 22:14:58 +0000 | [diff] [blame] | 118 | * so here we adjust the DEF accordingly. |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 119 | */ |
| 120 | static void |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 121 | T_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) { |
| 122 | td->free_struct = asn_DEF_ConstructedType.free_struct; |
| 123 | td->print_struct = asn_DEF_ConstructedType.print_struct; |
| 124 | td->ber_decoder = asn_DEF_ConstructedType.ber_decoder; |
| 125 | td->der_encoder = asn_DEF_ConstructedType.der_encoder; |
| 126 | td->xer_decoder = asn_DEF_ConstructedType.xer_decoder; |
| 127 | td->xer_encoder = asn_DEF_ConstructedType.xer_encoder; |
| 128 | td->elements = asn_DEF_ConstructedType.elements; |
| 129 | td->elements_count = asn_DEF_ConstructedType.elements_count; |
| 130 | td->specifics = asn_DEF_ConstructedType.specifics; |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 131 | } |
| 132 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 133 | void |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 134 | T_free(asn_TYPE_descriptor_t *td, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 135 | void *struct_ptr, int contents_only) { |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 136 | T_inherit_TYPE_descriptor(td); |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 137 | td->free_struct(td, struct_ptr, contents_only); |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | int |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 141 | T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr, |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 142 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 143 | T_inherit_TYPE_descriptor(td); |
| 144 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 145 | } |
| 146 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 147 | ber_dec_rval_t |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 148 | T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 149 | void **structure, void *bufptr, size_t size, int tag_mode) { |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 150 | T_inherit_TYPE_descriptor(td); |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 151 | return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode); |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | asn_enc_rval_t |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 155 | T_encode_der(asn_TYPE_descriptor_t *td, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 156 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 157 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 158 | T_inherit_TYPE_descriptor(td); |
| 159 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 160 | } |
| 161 | |
| 162 | asn_enc_rval_t |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 163 | T_encode_xer(asn_TYPE_descriptor_t *td, void *structure, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 164 | int ilevel, enum xer_encoder_flags_e flags, |
| 165 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 166 | T_inherit_TYPE_descriptor(td); |
| 167 | return td->xer_encoder(td, structure, ilevel, flags, cb, app_key); |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 171 | /*** <<< STAT-DEFS [T] >>> ***/ |
| 172 | |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 173 | static ber_tlv_tag_t asn_DEF_T_tags[] = { |
Lev Walkin | 188ed2c | 2004-09-13 08:31:01 +0000 | [diff] [blame] | 174 | (ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
| 175 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 176 | }; |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 177 | asn_TYPE_descriptor_t asn_DEF_T = { |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 178 | "T", |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 179 | T_free, |
| 180 | T_print, |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 181 | T_constraint, |
| 182 | T_decode_ber, |
| 183 | T_encode_der, |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 184 | 0, /* Not implemented yet */ |
| 185 | T_encode_xer, |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 186 | 0, /* Use generic outmost tag fetcher */ |
Lev Walkin | dfae975 | 2004-09-29 13:19:37 +0000 | [diff] [blame] | 187 | asn_DEF_T_tags, |
| 188 | sizeof(asn_DEF_T_tags) |
| 189 | /sizeof(asn_DEF_T_tags[0]) - 1, /* 1 */ |
| 190 | asn_DEF_T_tags, /* Same as above */ |
| 191 | sizeof(asn_DEF_T_tags) |
| 192 | /sizeof(asn_DEF_T_tags[0]), /* 2 */ |
Lev Walkin | 2e3055d | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 193 | 0, 0, /* Defined elsewhere */ |
Lev Walkin | 5bbff1e | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 194 | 0 /* No specifics */ |
| 195 | }; |
| 196 | |