blob: 8a3466de4bd85a7e5da0568c3aafbea6f0ec2615 [file] [log] [blame]
vlmb47f48e2004-09-17 06:32:12 +00001
2/*** <<< INCLUDES [T] >>> ***/
3
4#include <SimpleType.h>
5#include <asn_SET_OF.h>
6#include <constr_SET_OF.h>
7
8/*** <<< DEPS [T] >>> ***/
9
10extern asn1_TYPE_descriptor_t asn1_DEF_T;
11
12/*** <<< TYPE-DECLS [T] >>> ***/
13
14
15typedef struct T {
16 A_SET_OF(SimpleType_t) list;
17
18 /* Context for parsing across buffer boundaries */
19 ber_dec_ctx_t _ber_dec_ctx;
20} T_t;
21
22/*** <<< STAT-DEFS [T] >>> ***/
23
24static asn1_TYPE_member_t asn1_MBR_T[] = {
25 { ATF_NOFLAGS, 0, 0,
26 .tag = (ASN_TAG_CLASS_UNIVERSAL | (10 << 2)),
27 .tag_mode = 0,
28 .type = (void *)&asn1_DEF_SimpleType,
29 .memb_constraints = 0, /* Defer to actual type */
30 .name = ""
31 },
32};
33static ber_tlv_tag_t asn1_DEF_T_tags[] = {
34 (ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
35};
36static asn1_SET_OF_specifics_t asn1_DEF_T_specs = {
37 sizeof(struct T),
38 offsetof(struct T, _ber_dec_ctx),
39};
40asn1_TYPE_descriptor_t asn1_DEF_T = {
41 "T",
42 SET_OF_constraint,
43 SET_OF_decode_ber,
44 SET_OF_encode_der,
45 SET_OF_print,
46 SET_OF_free,
47 0, /* Use generic outmost tag fetcher */
48 asn1_DEF_T_tags,
49 sizeof(asn1_DEF_T_tags)
50 /sizeof(asn1_DEF_T_tags[0]), /* 1 */
51 asn1_DEF_T_tags, /* Same as above */
52 sizeof(asn1_DEF_T_tags)
53 /sizeof(asn1_DEF_T_tags[0]), /* 1 */
54 1, /* Whether CONSTRUCTED */
55 asn1_MBR_T,
56 1, /* Single element */
57 &asn1_DEF_T_specs /* Additional specs */
58};
59
60
61/*** <<< INCLUDES [SimpleType] >>> ***/
62
63#include <ENUMERATED.h>
64
65/*** <<< DEPS [SimpleType] >>> ***/
66
67typedef enum SimpleType {
68 SimpleType_one = 0,
69 SimpleType_two = 1,
70 SimpleType_three = 2,
71} SimpleType_e;
72
73/*** <<< TYPE-DECLS [SimpleType] >>> ***/
74
75
76typedef ENUMERATED_t SimpleType_t;
77
78/*** <<< FUNC-DECLS [SimpleType] >>> ***/
79
80extern asn1_TYPE_descriptor_t asn1_DEF_SimpleType;
81asn_constr_check_f SimpleType_constraint;
82ber_type_decoder_f SimpleType_decode_ber;
83der_type_encoder_f SimpleType_encode_der;
84asn_struct_print_f SimpleType_print;
85asn_struct_free_f SimpleType_free;
86
87/*** <<< CODE [SimpleType] >>> ***/
88
89int
90SimpleType_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,
91 asn_app_consume_bytes_f *app_errlog, void *app_key) {
92
93 /* Make the underlying type checker permanent */
94 td->check_constraints = asn1_DEF_ENUMERATED.check_constraints;
95 return td->check_constraints
96 (td, sptr, app_errlog, app_key);
97}
98
99/*
100 * This type is implemented using ENUMERATED,
101 * so adjust the DEF appropriately.
102 */
103static void
104SimpleType_inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {
105 td->ber_decoder = asn1_DEF_ENUMERATED.ber_decoder;
106 td->der_encoder = asn1_DEF_ENUMERATED.der_encoder;
107 td->free_struct = asn1_DEF_ENUMERATED.free_struct;
108 td->print_struct = asn1_DEF_ENUMERATED.print_struct;
109 td->last_tag_form = asn1_DEF_ENUMERATED.last_tag_form;
110 td->elements = asn1_DEF_ENUMERATED.elements;
111 td->elements_count = asn1_DEF_ENUMERATED.elements_count;
112 td->specifics = asn1_DEF_ENUMERATED.specifics;
113}
114
115ber_dec_rval_t
116SimpleType_decode_ber(asn1_TYPE_descriptor_t *td,
117 void **structure, void *bufptr, size_t size, int tag_mode) {
118 SimpleType_inherit_TYPE_descriptor(td);
119 return td->ber_decoder(td, structure, bufptr, size, tag_mode);
120}
121
122der_enc_rval_t
123SimpleType_encode_der(asn1_TYPE_descriptor_t *td,
124 void *structure, int tag_mode, ber_tlv_tag_t tag,
125 asn_app_consume_bytes_f *cb, void *app_key) {
126 SimpleType_inherit_TYPE_descriptor(td);
127 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
128}
129
130int
131SimpleType_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,
132 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
133 SimpleType_inherit_TYPE_descriptor(td);
134 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
135}
136
137void
138SimpleType_free(asn1_TYPE_descriptor_t *td,
139 void *struct_ptr, int contents_only) {
140 SimpleType_inherit_TYPE_descriptor(td);
141 td->free_struct(td, struct_ptr, contents_only);
142}
143
144
145/*** <<< STAT-DEFS [SimpleType] >>> ***/
146
147static ber_tlv_tag_t asn1_DEF_SimpleType_tags[] = {
148 (ASN_TAG_CLASS_UNIVERSAL | (10 << 2))
149};
150asn1_TYPE_descriptor_t asn1_DEF_SimpleType = {
151 "SimpleType",
152 SimpleType_constraint,
153 SimpleType_decode_ber,
154 SimpleType_encode_der,
155 SimpleType_print,
156 SimpleType_free,
157 0, /* Use generic outmost tag fetcher */
158 asn1_DEF_SimpleType_tags,
159 sizeof(asn1_DEF_SimpleType_tags)
160 /sizeof(asn1_DEF_SimpleType_tags[0]), /* 1 */
161 asn1_DEF_SimpleType_tags, /* Same as above */
162 sizeof(asn1_DEF_SimpleType_tags)
163 /sizeof(asn1_DEF_SimpleType_tags[0]), /* 1 */
164 -0, /* Unknown yet */
165 0, 0, /* No members */
166 0 /* No specifics */
167};
168