blob: ea256a82a83214dbb3f2b4d131159ae85d73aefb [file] [log] [blame]
vlm3df79662004-06-28 21:13:22 +00001
vlm6e1b13e2004-08-11 05:25:47 +00002/*** <<< INCLUDES [PrimitiveType] >>> ***/
vlm3df79662004-06-28 21:13:22 +00003
4#include <OCTET_STRING.h>
5
6/*** <<< TYPE-DECLS [PrimitiveType] >>> ***/
7
8
9typedef OCTET_STRING_t PrimitiveType_t;
10
vlm3df79662004-06-28 21:13:22 +000011/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
12
13extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType;
14asn_constr_check_f PrimitiveType_constraint;
15ber_type_decoder_f PrimitiveType_decode_ber;
16der_type_encoder_f PrimitiveType_encode_der;
17asn_struct_print_f PrimitiveType_print;
18asn_struct_free_f PrimitiveType_free;
19
vlm21e46002004-08-20 13:36:32 +000020/*** <<< CODE [PrimitiveType] >>> ***/
21
22int
23PrimitiveType_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 */
36static void
37PrimitiveType_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
48ber_dec_rval_t
49PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
50 void **structure, void *bufptr, size_t size, int tag_mode) {
51 PrimitiveType_inherit_TYPE_descriptor(td);
vlm1308d2b2004-09-10 15:49:15 +000052 return td->ber_decoder(td, structure, bufptr, size, tag_mode);
vlm21e46002004-08-20 13:36:32 +000053}
54
55der_enc_rval_t
56PrimitiveType_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
63int
64PrimitiveType_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
70void
71PrimitiveType_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
vlm3df79662004-06-28 21:13:22 +000078/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
79
80static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
81 (ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
82};
83asn1_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)
vlm6e73a042004-08-11 07:17:22 +000093 /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +000094 -0, /* Unknown yet */
vlm21e46002004-08-20 13:36:32 +000095 0, 0, /* No members */
vlm3df79662004-06-28 21:13:22 +000096 0 /* No specifics */
97};
98
vlm3df79662004-06-28 21:13:22 +000099
vlm6e1b13e2004-08-11 05:25:47 +0000100/*** <<< INCLUDES [ConstructedType] >>> ***/
vlm3df79662004-06-28 21:13:22 +0000101
vlm3df79662004-06-28 21:13:22 +0000102#include <PrimitiveType.h>
vlm3df79662004-06-28 21:13:22 +0000103#include <constr_SEQUENCE.h>
104
vlm6e1b13e2004-08-11 05:25:47 +0000105/*** <<< DEPS [ConstructedType] >>> ***/
106
vlm3df79662004-06-28 21:13:22 +0000107extern asn1_TYPE_descriptor_t asn1_DEF_ConstructedType;
108
109/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
110
111
112typedef struct ConstructedType {
113 PrimitiveType_t field;
114
115 /* Context for parsing across buffer boundaries */
116 ber_dec_ctx_t _ber_dec_ctx;
117} ConstructedType_t;
118
119/*** <<< STAT-DEFS [ConstructedType] >>> ***/
120
vlm21e46002004-08-20 13:36:32 +0000121static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = {
vlmddd5a7d2004-09-10 09:18:20 +0000122 { ATF_NOFLAGS, 0, offsetof(struct ConstructedType, field),
vlm21e46002004-08-20 13:36:32 +0000123 .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
124 .tag_mode = -1, /* IMPLICIT tag at current level */
125 .type = (void *)&asn1_DEF_PrimitiveType,
126 .memb_constraints = 0, /* Defer to actual type */
127 .name = "field"
vlm3df79662004-06-28 21:13:22 +0000128 },
129};
130static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
131 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
132};
133static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
134 { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */
135};
136static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
137 sizeof(struct ConstructedType),
138 offsetof(struct ConstructedType, _ber_dec_ctx),
vlm3df79662004-06-28 21:13:22 +0000139 asn1_DEF_ConstructedType_tag2el,
140 1, /* Count of tags in the map */
141 -1, /* Start extensions */
142 -1 /* Stop extensions */
143};
144asn1_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)
vlm6e73a042004-08-11 07:17:22 +0000154 /sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +0000155 1, /* Whether CONSTRUCTED */
vlm21e46002004-08-20 13:36:32 +0000156 asn1_MBR_ConstructedType,
157 1, /* Elements count */
vlm3df79662004-06-28 21:13:22 +0000158 &asn1_DEF_ConstructedType_specs /* Additional specs */
159};
160
161
vlm6e1b13e2004-08-11 05:25:47 +0000162/*** <<< INCLUDES [T] >>> ***/
vlm3df79662004-06-28 21:13:22 +0000163
164#include <ConstructedType.h>
165
166/*** <<< TYPE-DECLS [T] >>> ***/
167
168
169typedef ConstructedType_t T_t;
170
vlm3df79662004-06-28 21:13:22 +0000171/*** <<< FUNC-DECLS [T] >>> ***/
172
173extern asn1_TYPE_descriptor_t asn1_DEF_T;
174asn_constr_check_f T_constraint;
175ber_type_decoder_f T_decode_ber;
176der_type_encoder_f T_encode_der;
177asn_struct_print_f T_print;
178asn_struct_free_f T_free;
179
vlm21e46002004-08-20 13:36:32 +0000180/*** <<< CODE [T] >>> ***/
181
182int
183T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
184 asn_app_consume_bytes_f *app_errlog, void *app_key) {
185
186 /* Make the underlying type checker permanent */
187 td->check_constraints = asn1_DEF_ConstructedType.check_constraints;
188 return td->check_constraints
189 (td, sptr, app_errlog, app_key);
190}
191
192/*
193 * This type is implemented using ConstructedType,
194 * so adjust the DEF appropriately.
195 */
196static void
197T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
198 td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
199 td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
200 td->free_struct = asn1_DEF_ConstructedType.free_struct;
201 td->print_struct = asn1_DEF_ConstructedType.print_struct;
202 td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
203 td->elements = asn1_DEF_ConstructedType.elements;
204 td->elements_count = asn1_DEF_ConstructedType.elements_count;
205 td->specifics = asn1_DEF_ConstructedType.specifics;
206}
207
208ber_dec_rval_t
209T_decode_ber(asn1_TYPE_descriptor_t *td,
210 void **structure, void *bufptr, size_t size, int tag_mode) {
211 T_inherit_TYPE_descriptor(td);
vlm1308d2b2004-09-10 15:49:15 +0000212 return td->ber_decoder(td, structure, bufptr, size, tag_mode);
vlm21e46002004-08-20 13:36:32 +0000213}
214
215der_enc_rval_t
216T_encode_der(asn1_TYPE_descriptor_t *td,
217 void *structure, int tag_mode, ber_tlv_tag_t tag,
218 asn_app_consume_bytes_f *cb, void *app_key) {
219 T_inherit_TYPE_descriptor(td);
220 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
221}
222
223int
224T_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
225 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
226 T_inherit_TYPE_descriptor(td);
227 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
228}
229
230void
231T_free(asn1_TYPE_descriptor_t *td,
232 void *struct_ptr, int contents_only) {
233 T_inherit_TYPE_descriptor(td);
234 td->free_struct(td, struct_ptr, contents_only);
235}
236
237
vlm3df79662004-06-28 21:13:22 +0000238/*** <<< STAT-DEFS [T] >>> ***/
239
240static ber_tlv_tag_t asn1_DEF_T_tags[] = {
241 (ASN_TAG_CLASS_CONTEXT | (3 << 2))
242};
243asn1_TYPE_descriptor_t asn1_DEF_T = {
244 "T",
245 T_constraint,
246 T_decode_ber,
247 T_encode_der,
248 T_print,
249 T_free,
250 0, /* Use generic outmost tag fetcher */
251 asn1_DEF_T_tags,
252 sizeof(asn1_DEF_T_tags)
vlm6e73a042004-08-11 07:17:22 +0000253 /sizeof(asn1_DEF_T_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +0000254 -0, /* Unknown yet */
vlm21e46002004-08-20 13:36:32 +0000255 0, 0, /* Defined elsewhere */
vlm3df79662004-06-28 21:13:22 +0000256 0 /* No specifics */
257};
258