blob: 9bfe87960311537940829554dc81464fce4508db [file] [log] [blame]
Lev Walkin69353a32017-07-25 08:10:46 -07001
2/*** <<< INCLUDES [T] >>> ***/
3
4#include <IA5String.h>
5#include <UTF8String.h>
6#include <UniversalString.h>
7#include <constr_SEQUENCE.h>
8
9/*** <<< TYPE-DECLS [T] >>> ***/
10
11typedef struct T {
12 struct unconstrained {
13 IA5String_t unc_ia5;
14 UTF8String_t unc_utf8;
15 UniversalString_t unc_universal;
16
17 /* Context for parsing across buffer boundaries */
18 asn_struct_ctx_t _asn_ctx;
19 } unconstrained;
20 struct constrained {
21 IA5String_t con_ia5;
22 UTF8String_t con_utf8;
23 UniversalString_t con_universal;
24
25 /* Context for parsing across buffer boundaries */
26 asn_struct_ctx_t _asn_ctx;
27 } constrained;
28
29 /* Context for parsing across buffer boundaries */
30 asn_struct_ctx_t _asn_ctx;
31} T_t;
32
33/*** <<< FUNC-DECLS [T] >>> ***/
34
35extern asn_TYPE_descriptor_t asn_DEF_T;
36
37/*** <<< CTABLES [T] >>> ***/
38
39static int check_permitted_alphabet_7(const void *sptr) {
40 /* The underlying type is IA5String */
41 const IA5String_t *st = (const IA5String_t *)sptr;
42 const uint8_t *ch = st->buf;
43 const uint8_t *end = ch + st->size;
44
45 for(; ch < end; ch++) {
46 uint8_t cv = *ch;
47 if(!(cv <= 127)) return -1;
48 }
49 return 0;
50}
51
52static int check_permitted_alphabet_9(const void *sptr) {
53 /* The underlying type is UniversalString */
54 const UniversalString_t *st = (const UniversalString_t *)sptr;
55 const uint8_t *ch = st->buf;
56 const uint8_t *end = ch + st->size;
57
58 if(st->size % 4) return -1; /* (size%4)! */
59 for(; ch < end; ch += 4) {
60 uint32_t cv = (ch[0] << 24)
61 | (ch[1] << 16)
62 | (ch[2] << 8)
63 | ch[3];
64 if(!(1 /* Constraint matches natural range of cv */)) return -1;
65 }
66 return 0;
67}
68
69
70/*** <<< CODE [T] >>> ***/
71
72static int
73memb_con_ia5_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
74 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
75 const IA5String_t *st = (const IA5String_t *)sptr;
76 size_t size;
77
78 if(!sptr) {
79 ASN__CTFAIL(app_key, td, sptr,
80 "%s: value not given (%s:%d)",
81 td->name, __FILE__, __LINE__);
82 return -1;
83 }
84
85 size = st->size;
86
87 if((size == 2)
88 && !check_permitted_alphabet_7(st)) {
89 /* Constraint check succeeded */
90 return 0;
91 } else {
92 ASN__CTFAIL(app_key, td, sptr,
93 "%s: constraint failed (%s:%d)",
94 td->name, __FILE__, __LINE__);
95 return -1;
96 }
97}
98
99static int
100memb_con_utf8_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
101 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
102 const UTF8String_t *st = (const UTF8String_t *)sptr;
103 size_t size;
104
105 if(!sptr) {
106 ASN__CTFAIL(app_key, td, sptr,
107 "%s: value not given (%s:%d)",
108 td->name, __FILE__, __LINE__);
109 return -1;
110 }
111
112 size = UTF8String_length(st);
113 if((ssize_t)size < 0) {
114 ASN__CTFAIL(app_key, td, sptr,
115 "%s: UTF-8: broken encoding (%s:%d)",
116 td->name, __FILE__, __LINE__);
117 return -1;
118 }
119
120 if((size == 2)) {
121 /* Constraint check succeeded */
122 return 0;
123 } else {
124 ASN__CTFAIL(app_key, td, sptr,
125 "%s: constraint failed (%s:%d)",
126 td->name, __FILE__, __LINE__);
127 return -1;
128 }
129}
130
131static int
132memb_con_universal_constraint_6(asn_TYPE_descriptor_t *td, const void *sptr,
133 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
134 const UniversalString_t *st = (const UniversalString_t *)sptr;
135 size_t size;
136
137 if(!sptr) {
138 ASN__CTFAIL(app_key, td, sptr,
139 "%s: value not given (%s:%d)",
140 td->name, __FILE__, __LINE__);
141 return -1;
142 }
143
144 size = st->size >> 2; /* 4 byte per character */
145
146 if((size == 2)
147 && !check_permitted_alphabet_9(st)) {
148 /* Constraint check succeeded */
149 return 0;
150 } else {
151 ASN__CTFAIL(app_key, td, sptr,
152 "%s: constraint failed (%s:%d)",
153 td->name, __FILE__, __LINE__);
154 return -1;
155 }
156}
157
158
159/*** <<< CTDEFS [T] >>> ***/
160
161static asn_oer_constraints_t asn_OER_memb_con_ia5_constr_7 GCC_NOTUSED = {
Lev Walkin8041fe82017-08-02 10:39:01 -0700162 { 0, 0 },
163 2 /* (SIZE(2..2)) */};
Lev Walkin69353a32017-07-25 08:10:46 -0700164static asn_oer_constraints_t asn_OER_memb_con_utf8_constr_8 GCC_NOTUSED = {
Lev Walkin8041fe82017-08-02 10:39:01 -0700165 { 0, 0 },
166 -1 /* (SIZE(0..MAX)) */};
Lev Walkin69353a32017-07-25 08:10:46 -0700167static asn_oer_constraints_t asn_OER_memb_con_universal_constr_9 GCC_NOTUSED = {
Lev Walkin8041fe82017-08-02 10:39:01 -0700168 { 0, 0 },
169 2 /* (SIZE(2..2)) */};
Lev Walkin69353a32017-07-25 08:10:46 -0700170
171/*** <<< STAT-DEFS [T] >>> ***/
172
173static asn_TYPE_member_t asn_MBR_unconstrained_2[] = {
174 { ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_ia5),
175 .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
176 .tag_mode = 0,
177 .type = &asn_DEF_IA5String,
178 .memb_constraints = 0, /* Defer constraints checking to the member type */
179 .oer_constraints = 0, /* No OER visible constraints */
180 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
181 .default_value = 0,
182 .name = "unc-ia5"
183 },
184 { ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_utf8),
185 .tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
186 .tag_mode = 0,
187 .type = &asn_DEF_UTF8String,
188 .memb_constraints = 0, /* Defer constraints checking to the member type */
189 .oer_constraints = 0, /* No OER visible constraints */
190 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
191 .default_value = 0,
192 .name = "unc-utf8"
193 },
194 { ATF_NOFLAGS, 0, offsetof(struct unconstrained, unc_universal),
195 .tag = (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)),
196 .tag_mode = 0,
197 .type = &asn_DEF_UniversalString,
198 .memb_constraints = 0, /* Defer constraints checking to the member type */
199 .oer_constraints = 0, /* No OER visible constraints */
200 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
201 .default_value = 0,
202 .name = "unc-universal"
203 },
204};
205static const ber_tlv_tag_t asn_DEF_unconstrained_tags_2[] = {
206 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
207};
208static const asn_TYPE_tag2member_t asn_MAP_unconstrained_tag2el_2[] = {
209 { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), 1, 0, 0 }, /* unc-utf8 */
210 { (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), 0, 0, 0 }, /* unc-ia5 */
211 { (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), 2, 0, 0 } /* unc-universal */
212};
213static asn_SEQUENCE_specifics_t asn_SPC_unconstrained_specs_2 = {
214 sizeof(struct unconstrained),
215 offsetof(struct unconstrained, _asn_ctx),
216 asn_MAP_unconstrained_tag2el_2,
217 3, /* Count of tags in the map */
218 0, 0, 0, /* Optional elements (not needed) */
219 -1, /* Start extensions */
220 -1 /* Stop extensions */
221};
222static /* Use -fall-defs-global to expose */
223asn_TYPE_descriptor_t asn_DEF_unconstrained_2 = {
224 "unconstrained",
225 "unconstrained",
226 SEQUENCE_free,
227 SEQUENCE_print,
228 SEQUENCE_constraint,
229 SEQUENCE_decode_ber,
230 SEQUENCE_encode_der,
231 SEQUENCE_decode_xer,
232 SEQUENCE_encode_xer,
233 SEQUENCE_decode_oer,
234 SEQUENCE_encode_oer,
235 0, 0, /* No PER support, use "-gen-PER" to enable */
236 0, /* Use generic outmost tag fetcher */
237 asn_DEF_unconstrained_tags_2,
238 sizeof(asn_DEF_unconstrained_tags_2)
239 /sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
240 asn_DEF_unconstrained_tags_2, /* Same as above */
241 sizeof(asn_DEF_unconstrained_tags_2)
242 /sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
243 0, /* No OER visible constraints */
244 0, /* No PER visible constraints */
245 asn_MBR_unconstrained_2,
246 3, /* Elements count */
247 &asn_SPC_unconstrained_specs_2 /* Additional specs */
248};
249
250static asn_TYPE_member_t asn_MBR_constrained_6[] = {
251 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_ia5),
252 .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
253 .tag_mode = 0,
254 .type = &asn_DEF_IA5String,
255 .memb_constraints = memb_con_ia5_constraint_6,
256 .oer_constraints = &asn_OER_memb_con_ia5_constr_7,
257 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
258 .default_value = 0,
259 .name = "con-ia5"
260 },
261 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_utf8),
262 .tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
263 .tag_mode = 0,
264 .type = &asn_DEF_UTF8String,
265 .memb_constraints = memb_con_utf8_constraint_6,
266 .oer_constraints = &asn_OER_memb_con_utf8_constr_8,
267 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
268 .default_value = 0,
269 .name = "con-utf8"
270 },
271 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_universal),
272 .tag = (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)),
273 .tag_mode = 0,
274 .type = &asn_DEF_UniversalString,
275 .memb_constraints = memb_con_universal_constraint_6,
276 .oer_constraints = &asn_OER_memb_con_universal_constr_9,
277 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
278 .default_value = 0,
279 .name = "con-universal"
280 },
281};
282static const ber_tlv_tag_t asn_DEF_constrained_tags_6[] = {
283 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
284};
285static const asn_TYPE_tag2member_t asn_MAP_constrained_tag2el_6[] = {
286 { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), 1, 0, 0 }, /* con-utf8 */
287 { (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), 0, 0, 0 }, /* con-ia5 */
288 { (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), 2, 0, 0 } /* con-universal */
289};
290static asn_SEQUENCE_specifics_t asn_SPC_constrained_specs_6 = {
291 sizeof(struct constrained),
292 offsetof(struct constrained, _asn_ctx),
293 asn_MAP_constrained_tag2el_6,
294 3, /* Count of tags in the map */
295 0, 0, 0, /* Optional elements (not needed) */
296 -1, /* Start extensions */
297 -1 /* Stop extensions */
298};
299static /* Use -fall-defs-global to expose */
300asn_TYPE_descriptor_t asn_DEF_constrained_6 = {
301 "constrained",
302 "constrained",
303 SEQUENCE_free,
304 SEQUENCE_print,
305 SEQUENCE_constraint,
306 SEQUENCE_decode_ber,
307 SEQUENCE_encode_der,
308 SEQUENCE_decode_xer,
309 SEQUENCE_encode_xer,
310 SEQUENCE_decode_oer,
311 SEQUENCE_encode_oer,
312 0, 0, /* No PER support, use "-gen-PER" to enable */
313 0, /* Use generic outmost tag fetcher */
314 asn_DEF_constrained_tags_6,
315 sizeof(asn_DEF_constrained_tags_6)
316 /sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
317 asn_DEF_constrained_tags_6, /* Same as above */
318 sizeof(asn_DEF_constrained_tags_6)
319 /sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
320 0, /* No OER visible constraints */
321 0, /* No PER visible constraints */
322 asn_MBR_constrained_6,
323 3, /* Elements count */
324 &asn_SPC_constrained_specs_6 /* Additional specs */
325};
326
327static asn_TYPE_member_t asn_MBR_T_1[] = {
328 { ATF_NOFLAGS, 0, offsetof(struct T, unconstrained),
329 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
330 .tag_mode = 0,
331 .type = &asn_DEF_unconstrained_2,
332 .memb_constraints = 0, /* Defer constraints checking to the member type */
333 .oer_constraints = 0, /* No OER visible constraints */
334 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
335 .default_value = 0,
336 .name = "unconstrained"
337 },
338 { ATF_NOFLAGS, 0, offsetof(struct T, constrained),
339 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
340 .tag_mode = 0,
341 .type = &asn_DEF_constrained_6,
342 .memb_constraints = 0, /* Defer constraints checking to the member type */
343 .oer_constraints = 0, /* No OER visible constraints */
344 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
345 .default_value = 0,
346 .name = "constrained"
347 },
348};
349static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
350 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
351};
352static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
353 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* unconstrained */
354 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* constrained */
355};
356static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
357 sizeof(struct T),
358 offsetof(struct T, _asn_ctx),
359 asn_MAP_T_tag2el_1,
360 2, /* Count of tags in the map */
361 0, 0, 0, /* Optional elements (not needed) */
362 -1, /* Start extensions */
363 -1 /* Stop extensions */
364};
365asn_TYPE_descriptor_t asn_DEF_T = {
366 "T",
367 "T",
368 SEQUENCE_free,
369 SEQUENCE_print,
370 SEQUENCE_constraint,
371 SEQUENCE_decode_ber,
372 SEQUENCE_encode_der,
373 SEQUENCE_decode_xer,
374 SEQUENCE_encode_xer,
375 SEQUENCE_decode_oer,
376 SEQUENCE_encode_oer,
377 0, 0, /* No PER support, use "-gen-PER" to enable */
378 0, /* Use generic outmost tag fetcher */
379 asn_DEF_T_tags_1,
380 sizeof(asn_DEF_T_tags_1)
381 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
382 asn_DEF_T_tags_1, /* Same as above */
383 sizeof(asn_DEF_T_tags_1)
384 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
385 0, /* No OER visible constraints */
386 0, /* No PER visible constraints */
387 asn_MBR_T_1,
388 2, /* Elements count */
389 &asn_SPC_T_specs_1 /* Additional specs */
390};
391