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