blob: ee7aceb42b9ee7af68a110310f54b45e0568fe56 [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
11
12/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
13
14extern asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType;
15asn_constr_check_f PrimitiveType_constraint;
16ber_type_decoder_f PrimitiveType_decode_ber;
17der_type_encoder_f PrimitiveType_encode_der;
18asn_struct_print_f PrimitiveType_print;
19asn_struct_free_f PrimitiveType_free;
20
vlm21e46002004-08-20 13:36:32 +000021/*** <<< CODE [PrimitiveType] >>> ***/
22
23int
24PrimitiveType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
25 asn_app_consume_bytes_f *app_errlog, void *app_key) {
26
27 /* Make the underlying type checker permanent */
28 td->check_constraints = asn1_DEF_OCTET_STRING.check_constraints;
29 return td->check_constraints
30 (td, sptr, app_errlog, app_key);
31}
32
33/*
34 * This type is implemented using OCTET_STRING,
35 * so adjust the DEF appropriately.
36 */
37static void
38PrimitiveType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
39 td->ber_decoder = asn1_DEF_OCTET_STRING.ber_decoder;
40 td->der_encoder = asn1_DEF_OCTET_STRING.der_encoder;
41 td->free_struct = asn1_DEF_OCTET_STRING.free_struct;
42 td->print_struct = asn1_DEF_OCTET_STRING.print_struct;
43 td->last_tag_form = asn1_DEF_OCTET_STRING.last_tag_form;
44 td->elements = asn1_DEF_OCTET_STRING.elements;
45 td->elements_count = asn1_DEF_OCTET_STRING.elements_count;
46 td->specifics = asn1_DEF_OCTET_STRING.specifics;
47}
48
49ber_dec_rval_t
50PrimitiveType_decode_ber(asn1_TYPE_descriptor_t *td,
51 void **structure, void *bufptr, size_t size, int tag_mode) {
52 PrimitiveType_inherit_TYPE_descriptor(td);
53 return td->ber_decoder(td, structure,
54 bufptr, size, tag_mode);
55}
56
57der_enc_rval_t
58PrimitiveType_encode_der(asn1_TYPE_descriptor_t *td,
59 void *structure, int tag_mode, ber_tlv_tag_t tag,
60 asn_app_consume_bytes_f *cb, void *app_key) {
61 PrimitiveType_inherit_TYPE_descriptor(td);
62 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
63}
64
65int
66PrimitiveType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
67 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
68 PrimitiveType_inherit_TYPE_descriptor(td);
69 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
70}
71
72void
73PrimitiveType_free(asn1_TYPE_descriptor_t *td,
74 void *struct_ptr, int contents_only) {
75 PrimitiveType_inherit_TYPE_descriptor(td);
76 td->free_struct(td, struct_ptr, contents_only);
77}
78
79
vlm3df79662004-06-28 21:13:22 +000080/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
81
82static ber_tlv_tag_t asn1_DEF_PrimitiveType_tags[] = {
83 (ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
84};
85asn1_TYPE_descriptor_t asn1_DEF_PrimitiveType = {
86 "PrimitiveType",
87 PrimitiveType_constraint,
88 PrimitiveType_decode_ber,
89 PrimitiveType_encode_der,
90 PrimitiveType_print,
91 PrimitiveType_free,
92 0, /* Use generic outmost tag fetcher */
93 asn1_DEF_PrimitiveType_tags,
94 sizeof(asn1_DEF_PrimitiveType_tags)
vlm6e73a042004-08-11 07:17:22 +000095 /sizeof(asn1_DEF_PrimitiveType_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +000096 1, /* Tags to skip */
97 -0, /* Unknown yet */
vlm21e46002004-08-20 13:36:32 +000098 0, 0, /* No members */
vlm3df79662004-06-28 21:13:22 +000099 0 /* No specifics */
100};
101
vlm3df79662004-06-28 21:13:22 +0000102
vlm6e1b13e2004-08-11 05:25:47 +0000103/*** <<< INCLUDES [ConstructedType] >>> ***/
vlm3df79662004-06-28 21:13:22 +0000104
vlm3df79662004-06-28 21:13:22 +0000105#include <PrimitiveType.h>
vlm3df79662004-06-28 21:13:22 +0000106#include <constr_SEQUENCE.h>
107
vlm6e1b13e2004-08-11 05:25:47 +0000108/*** <<< DEPS [ConstructedType] >>> ***/
109
vlm3df79662004-06-28 21:13:22 +0000110extern asn1_TYPE_descriptor_t asn1_DEF_ConstructedType;
111
112/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
113
114
115typedef 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
vlm21e46002004-08-20 13:36:32 +0000124static asn1_TYPE_member_t asn1_MBR_ConstructedType[] = {
125 { 0, offsetof(struct ConstructedType, field),
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"
vlm3df79662004-06-28 21:13:22 +0000131 },
132};
133static ber_tlv_tag_t asn1_DEF_ConstructedType_tags[] = {
134 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
135};
136static asn1_TYPE_tag2member_t asn1_DEF_ConstructedType_tag2el[] = {
137 { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */
138};
139static asn1_SEQUENCE_specifics_t asn1_DEF_ConstructedType_specs = {
140 sizeof(struct ConstructedType),
141 offsetof(struct ConstructedType, _ber_dec_ctx),
vlm3df79662004-06-28 21:13:22 +0000142 asn1_DEF_ConstructedType_tag2el,
143 1, /* Count of tags in the map */
144 -1, /* Start extensions */
145 -1 /* Stop extensions */
146};
147asn1_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)
vlm6e73a042004-08-11 07:17:22 +0000157 /sizeof(asn1_DEF_ConstructedType_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +0000158 1, /* Tags to skip */
159 1, /* Whether CONSTRUCTED */
vlm21e46002004-08-20 13:36:32 +0000160 asn1_MBR_ConstructedType,
161 1, /* Elements count */
vlm3df79662004-06-28 21:13:22 +0000162 &asn1_DEF_ConstructedType_specs /* Additional specs */
163};
164
165
vlm6e1b13e2004-08-11 05:25:47 +0000166/*** <<< INCLUDES [T] >>> ***/
vlm3df79662004-06-28 21:13:22 +0000167
168#include <ConstructedType.h>
169
170/*** <<< TYPE-DECLS [T] >>> ***/
171
172
173typedef ConstructedType_t T_t;
174
175
176/*** <<< FUNC-DECLS [T] >>> ***/
177
178extern asn1_TYPE_descriptor_t asn1_DEF_T;
179asn_constr_check_f T_constraint;
180ber_type_decoder_f T_decode_ber;
181der_type_encoder_f T_encode_der;
182asn_struct_print_f T_print;
183asn_struct_free_f T_free;
184
vlm21e46002004-08-20 13:36:32 +0000185/*** <<< CODE [T] >>> ***/
186
187int
188T_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
189 asn_app_consume_bytes_f *app_errlog, void *app_key) {
190
191 /* Make the underlying type checker permanent */
192 td->check_constraints = asn1_DEF_ConstructedType.check_constraints;
193 return td->check_constraints
194 (td, sptr, app_errlog, app_key);
195}
196
197/*
198 * This type is implemented using ConstructedType,
199 * so adjust the DEF appropriately.
200 */
201static void
202T_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
203 td->ber_decoder = asn1_DEF_ConstructedType.ber_decoder;
204 td->der_encoder = asn1_DEF_ConstructedType.der_encoder;
205 td->free_struct = asn1_DEF_ConstructedType.free_struct;
206 td->print_struct = asn1_DEF_ConstructedType.print_struct;
207 td->last_tag_form = asn1_DEF_ConstructedType.last_tag_form;
208 td->elements = asn1_DEF_ConstructedType.elements;
209 td->elements_count = asn1_DEF_ConstructedType.elements_count;
210 td->specifics = asn1_DEF_ConstructedType.specifics;
211}
212
213ber_dec_rval_t
214T_decode_ber(asn1_TYPE_descriptor_t *td,
215 void **structure, void *bufptr, size_t size, int tag_mode) {
216 T_inherit_TYPE_descriptor(td);
217 return td->ber_decoder(td, structure,
218 bufptr, size, tag_mode);
219}
220
221der_enc_rval_t
222T_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
229int
230T_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
236void
237T_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
vlm3df79662004-06-28 21:13:22 +0000244/*** <<< STAT-DEFS [T] >>> ***/
245
246static ber_tlv_tag_t asn1_DEF_T_tags[] = {
247 (ASN_TAG_CLASS_CONTEXT | (3 << 2))
248};
249asn1_TYPE_descriptor_t asn1_DEF_T = {
250 "T",
251 T_constraint,
252 T_decode_ber,
253 T_encode_der,
254 T_print,
255 T_free,
256 0, /* Use generic outmost tag fetcher */
257 asn1_DEF_T_tags,
258 sizeof(asn1_DEF_T_tags)
vlm6e73a042004-08-11 07:17:22 +0000259 /sizeof(asn1_DEF_T_tags[0]), /* 1 */
vlm3df79662004-06-28 21:13:22 +0000260 1, /* Tags to skip */
261 -0, /* Unknown yet */
vlm21e46002004-08-20 13:36:32 +0000262 0, 0, /* Defined elsewhere */
vlm3df79662004-06-28 21:13:22 +0000263 0 /* No specifics */
264};
265