vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 1 | |
vlm | 6e1b13e | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 2 | /*** <<< INCLUDES [PrimitiveType] >>> ***/ |
vlm | 3df7966 | 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 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 11 | /*** <<< FUNC-DECLS [PrimitiveType] >>> ***/ |
| 12 | |
| 13 | extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType; |
| 14 | asn_constr_check_f PrimitiveType_constraint; |
| 15 | ber_type_decoder_f PrimitiveType_decode_ber; |
| 16 | der_type_encoder_f PrimitiveType_encode_der; |
| 17 | asn_struct_print_f PrimitiveType_print; |
| 18 | asn_struct_free_f PrimitiveType_free; |
| 19 | |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 20 | /*** <<< CODE [PrimitiveType] >>> ***/ |
| 21 | |
| 22 | int |
| 23 | PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 24 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 25 | |
| 26 | /* Make the underlying type checker permanent */ |
| 27 | td->check_constraints = asn1_DEF_OCTET_STRING.check_constraints; |
| 28 | return td->check_constraints |
| 29 | (td, sptr, app_errlog, app_key); |
| 30 | } |
| 31 | |
| 32 | /* |
| 33 | * This type is implemented using OCTET_STRING, |
| 34 | * so adjust the DEF appropriately. |
| 35 | */ |
| 36 | static void |
| 37 | PrimitiveType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 38 | td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder; |
| 39 | td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder; |
| 40 | td->free_struct = asn1_DEF_OCTET_STRING.free_struct; |
| 41 | td->print_struct = asn1_DEF_OCTET_STRING.print_struct; |
| 42 | td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form; |
| 43 | td->elements = asn1_DEF_OCTET_STRING.elements; |
| 44 | td->elements_count = asn1_DEF_OCTET_STRING.elements_count; |
| 45 | td->specifics = asn1_DEF_OCTET_STRING.specifics; |
| 46 | } |
| 47 | |
| 48 | ber_dec_rval_t |
| 49 | PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td, |
| 50 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 51 | PrimitiveType_inherit_TYPE_descriptor(td); |
vlm | 1308d2b | 2004-09-10 15:49:15 +0000 | [diff] [blame] | 52 | return td->ber_decoder(td, structure, bufptr, size, tag_mode); |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | der_enc_rval_t |
| 56 | PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td, |
| 57 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 58 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 59 | PrimitiveType_inherit_TYPE_descriptor(td); |
| 60 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 61 | } |
| 62 | |
| 63 | int |
| 64 | PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 65 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 66 | PrimitiveType_inherit_TYPE_descriptor(td); |
| 67 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 68 | } |
| 69 | |
| 70 | void |
| 71 | PrimitiveType_free(asn1_TYPE_descriptor_t *td, |
| 72 | void *struct_ptr, int contents_only) { |
| 73 | PrimitiveType_inherit_TYPE_descriptor(td); |
| 74 | td->free_struct(td, struct_ptr, contents_only); |
| 75 | } |
| 76 | |
| 77 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 78 | /*** <<< STAT-DEFS [PrimitiveType] >>> ***/ |
| 79 | |
| 80 | static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = { |
| 81 | (ASN_TAG_CLASS_UNIVERSAL | (4 << 2)) |
| 82 | }; |
| 83 | asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = { |
| 84 | "PrimitiveType", |
| 85 | PrimitiveType_constraint, |
| 86 | PrimitiveType_decode_ber, |
| 87 | PrimitiveType_encode_der, |
| 88 | PrimitiveType_print, |
| 89 | PrimitiveType_free, |
| 90 | 0, /* Use generic outmost tag fetcher */ |
| 91 | asn1_DEF_PrimitiveType_tags, |
| 92 | sizeof(asn1_DEF_PrimitiveType_tags) |
vlm | 6e73a04 | 2004-08-11 07:17:22 +0000 | [diff] [blame] | 93 | /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */ |
vlm | 72425de | 2004-09-13 08:31:01 +0000 | [diff] [blame] | 94 | asn1_DEF_PrimitiveType_tags, /* Same as above */ |
| 95 | sizeof(asn1_DEF_PrimitiveType_tags) |
| 96 | /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 97 | -0, /* Unknown yet */ |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 98 | 0, 0, /* No members */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 99 | 0 /* No specifics */ |
| 100 | }; |
| 101 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 102 | |
vlm | 6e1b13e | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 103 | /*** <<< INCLUDES [ConstructedType] >>> ***/ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 104 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 105 | #include <PrimitiveType.h> |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 106 | #include <constr_SEQUENCE.h> |
| 107 | |
vlm | 6e1b13e | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 108 | /*** <<< DEPS [ConstructedType] >>> ***/ |
| 109 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 110 | extern asn1_TYPE_descriptor_t asn1_DEF_ConstructedType; |
| 111 | |
| 112 | /*** <<< TYPE-DECLS [ConstructedType] >>> ***/ |
| 113 | |
| 114 | |
| 115 | typedef struct ConstructedType { |
| 116 | PrimitiveType_t field; |
| 117 | |
| 118 | /* Context for parsing across buffer boundaries */ |
| 119 | ber_dec_ctx_t _ber_dec_ctx; |
| 120 | } ConstructedType_t; |
| 121 | |
| 122 | /*** <<< STAT-DEFS [ConstructedType] >>> ***/ |
| 123 | |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 124 | static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = { |
vlm | ddd5a7d | 2004-09-10 09:18:20 +0000 | [diff] [blame] | 125 | { ATF_NOFLAGS, 0, offsetof(struct ConstructedType, field), |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 126 | .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)), |
| 127 | .tag_mode = -1, /* IMPLICIT tag at current level */ |
| 128 | .type = (void *)&asn1_DEF_PrimitiveType, |
| 129 | .memb_constraints = 0, /* Defer to actual type */ |
| 130 | .name = "field" |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 131 | }, |
| 132 | }; |
| 133 | static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = { |
| 134 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
| 135 | }; |
| 136 | static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = { |
| 137 | { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */ |
| 138 | }; |
| 139 | static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = { |
| 140 | sizeof(struct ConstructedType), |
| 141 | offsetof(struct ConstructedType, _ber_dec_ctx), |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 142 | asn1_DEF_ConstructedType_tag2el, |
| 143 | 1, /* Count of tags in the map */ |
| 144 | -1, /* Start extensions */ |
| 145 | -1 /* Stop extensions */ |
| 146 | }; |
| 147 | asn1_TYPE_descriptor_t asn1_DEF_ConstructedType = { |
| 148 | "ConstructedType", |
| 149 | SEQUENCE_constraint, |
| 150 | SEQUENCE_decode_ber, |
| 151 | SEQUENCE_encode_der, |
| 152 | SEQUENCE_print, |
| 153 | SEQUENCE_free, |
| 154 | 0, /* Use generic outmost tag fetcher */ |
| 155 | asn1_DEF_ConstructedType_tags, |
| 156 | sizeof(asn1_DEF_ConstructedType_tags) |
vlm | 6e73a04 | 2004-08-11 07:17:22 +0000 | [diff] [blame] | 157 | /sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */ |
vlm | 72425de | 2004-09-13 08:31:01 +0000 | [diff] [blame] | 158 | asn1_DEF_ConstructedType_tags, /* Same as above */ |
| 159 | sizeof(asn1_DEF_ConstructedType_tags) |
| 160 | /sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 161 | 1, /* Whether CONSTRUCTED */ |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 162 | asn1_MBR_ConstructedType, |
| 163 | 1, /* Elements count */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 164 | &asn1_DEF_ConstructedType_specs /* Additional specs */ |
| 165 | }; |
| 166 | |
| 167 | |
vlm | 6e1b13e | 2004-08-11 05:25:47 +0000 | [diff] [blame] | 168 | /*** <<< INCLUDES [T] >>> ***/ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 169 | |
| 170 | #include <ConstructedType.h> |
| 171 | |
| 172 | /*** <<< TYPE-DECLS [T] >>> ***/ |
| 173 | |
| 174 | |
| 175 | typedef ConstructedType_t T_t; |
| 176 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 177 | /*** <<< FUNC-DECLS [T] >>> ***/ |
| 178 | |
| 179 | extern asn1_TYPE_descriptor_t asn1_DEF_T; |
| 180 | asn_constr_check_f T_constraint; |
| 181 | ber_type_decoder_f T_decode_ber; |
| 182 | der_type_encoder_f T_encode_der; |
| 183 | asn_struct_print_f T_print; |
| 184 | asn_struct_free_f T_free; |
| 185 | |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 186 | /*** <<< CODE [T] >>> ***/ |
| 187 | |
| 188 | int |
| 189 | T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr, |
| 190 | asn_app_consume_bytes_f *app_errlog, void *app_key) { |
| 191 | |
| 192 | /* Make the underlying type checker permanent */ |
| 193 | td->check_constraints = asn1_DEF_ConstructedType.check_constraints; |
| 194 | return td->check_constraints |
| 195 | (td, sptr, app_errlog, app_key); |
| 196 | } |
| 197 | |
| 198 | /* |
| 199 | * This type is implemented using ConstructedType, |
| 200 | * so adjust the DEF appropriately. |
| 201 | */ |
| 202 | static void |
| 203 | T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) { |
| 204 | td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder; |
| 205 | td->der_encoder = asn1_DEF_ConstructedType.der_encoder; |
| 206 | td->free_struct = asn1_DEF_ConstructedType.free_struct; |
| 207 | td->print_struct = asn1_DEF_ConstructedType.print_struct; |
| 208 | td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form; |
| 209 | td->elements = asn1_DEF_ConstructedType.elements; |
| 210 | td->elements_count = asn1_DEF_ConstructedType.elements_count; |
| 211 | td->specifics = asn1_DEF_ConstructedType.specifics; |
| 212 | } |
| 213 | |
| 214 | ber_dec_rval_t |
| 215 | T_decode_ber(asn1_TYPE_descriptor_t *td, |
| 216 | void **structure, void *bufptr, size_t size, int tag_mode) { |
| 217 | T_inherit_TYPE_descriptor(td); |
vlm | 1308d2b | 2004-09-10 15:49:15 +0000 | [diff] [blame] | 218 | return td->ber_decoder(td, structure, bufptr, size, tag_mode); |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | der_enc_rval_t |
| 222 | T_encode_der(asn1_TYPE_descriptor_t *td, |
| 223 | void *structure, int tag_mode, ber_tlv_tag_t tag, |
| 224 | asn_app_consume_bytes_f *cb, void *app_key) { |
| 225 | T_inherit_TYPE_descriptor(td); |
| 226 | return td->der_encoder(td, structure, tag_mode, tag, cb, app_key); |
| 227 | } |
| 228 | |
| 229 | int |
| 230 | T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr, |
| 231 | int ilevel, asn_app_consume_bytes_f *cb, void *app_key) { |
| 232 | T_inherit_TYPE_descriptor(td); |
| 233 | return td->print_struct(td, struct_ptr, ilevel, cb, app_key); |
| 234 | } |
| 235 | |
| 236 | void |
| 237 | T_free(asn1_TYPE_descriptor_t *td, |
| 238 | void *struct_ptr, int contents_only) { |
| 239 | T_inherit_TYPE_descriptor(td); |
| 240 | td->free_struct(td, struct_ptr, contents_only); |
| 241 | } |
| 242 | |
| 243 | |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 244 | /*** <<< STAT-DEFS [T] >>> ***/ |
| 245 | |
| 246 | static ber_tlv_tag_t asn1_DEF_T_tags[] = { |
vlm | 72425de | 2004-09-13 08:31:01 +0000 | [diff] [blame] | 247 | (ASN_TAG_CLASS_CONTEXT | (3 << 2)), |
| 248 | (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)) |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 249 | }; |
| 250 | asn1_TYPE_descriptor_t asn1_DEF_T = { |
| 251 | "T", |
| 252 | T_constraint, |
| 253 | T_decode_ber, |
| 254 | T_encode_der, |
| 255 | T_print, |
| 256 | T_free, |
| 257 | 0, /* Use generic outmost tag fetcher */ |
| 258 | asn1_DEF_T_tags, |
| 259 | sizeof(asn1_DEF_T_tags) |
vlm | 72425de | 2004-09-13 08:31:01 +0000 | [diff] [blame] | 260 | /sizeof(asn1_DEF_T_tags[0]) - 1, /* 1 */ |
| 261 | asn1_DEF_T_tags, /* Same as above */ |
| 262 | sizeof(asn1_DEF_T_tags) |
| 263 | /sizeof(asn1_DEF_T_tags[0]), /* 2 */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 264 | -0, /* Unknown yet */ |
vlm | 21e4600 | 2004-08-20 13:36:32 +0000 | [diff] [blame] | 265 | 0, 0, /* Defined elsewhere */ |
vlm | 3df7966 | 2004-06-28 21:13:22 +0000 | [diff] [blame] | 266 | 0 /* No specifics */ |
| 267 | }; |
| 268 | |