blob: 2ab1609d3b9efdc17313bcb459d571d1b9726cbd [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,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700228 SEQUENCE_compare,
Lev Walkin69353a32017-07-25 08:10:46 -0700229 SEQUENCE_constraint,
230 SEQUENCE_decode_ber,
231 SEQUENCE_encode_der,
232 SEQUENCE_decode_xer,
233 SEQUENCE_encode_xer,
234 SEQUENCE_decode_oer,
235 SEQUENCE_encode_oer,
236 0, 0, /* No PER support, use "-gen-PER" to enable */
237 0, /* Use generic outmost tag fetcher */
238 asn_DEF_unconstrained_tags_2,
239 sizeof(asn_DEF_unconstrained_tags_2)
240 /sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
241 asn_DEF_unconstrained_tags_2, /* Same as above */
242 sizeof(asn_DEF_unconstrained_tags_2)
243 /sizeof(asn_DEF_unconstrained_tags_2[0]), /* 1 */
244 0, /* No OER visible constraints */
245 0, /* No PER visible constraints */
246 asn_MBR_unconstrained_2,
247 3, /* Elements count */
248 &asn_SPC_unconstrained_specs_2 /* Additional specs */
249};
250
251static asn_TYPE_member_t asn_MBR_constrained_6[] = {
252 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_ia5),
253 .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
254 .tag_mode = 0,
255 .type = &asn_DEF_IA5String,
256 .memb_constraints = memb_con_ia5_constraint_6,
257 .oer_constraints = &asn_OER_memb_con_ia5_constr_7,
258 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
259 .default_value = 0,
260 .name = "con-ia5"
261 },
262 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_utf8),
263 .tag = (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)),
264 .tag_mode = 0,
265 .type = &asn_DEF_UTF8String,
266 .memb_constraints = memb_con_utf8_constraint_6,
267 .oer_constraints = &asn_OER_memb_con_utf8_constr_8,
268 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
269 .default_value = 0,
270 .name = "con-utf8"
271 },
272 { ATF_NOFLAGS, 0, offsetof(struct constrained, con_universal),
273 .tag = (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)),
274 .tag_mode = 0,
275 .type = &asn_DEF_UniversalString,
276 .memb_constraints = memb_con_universal_constraint_6,
277 .oer_constraints = &asn_OER_memb_con_universal_constr_9,
278 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
279 .default_value = 0,
280 .name = "con-universal"
281 },
282};
283static const ber_tlv_tag_t asn_DEF_constrained_tags_6[] = {
284 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
285};
286static const asn_TYPE_tag2member_t asn_MAP_constrained_tag2el_6[] = {
287 { (ASN_TAG_CLASS_UNIVERSAL | (12 << 2)), 1, 0, 0 }, /* con-utf8 */
288 { (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)), 0, 0, 0 }, /* con-ia5 */
289 { (ASN_TAG_CLASS_UNIVERSAL | (28 << 2)), 2, 0, 0 } /* con-universal */
290};
291static asn_SEQUENCE_specifics_t asn_SPC_constrained_specs_6 = {
292 sizeof(struct constrained),
293 offsetof(struct constrained, _asn_ctx),
294 asn_MAP_constrained_tag2el_6,
295 3, /* Count of tags in the map */
296 0, 0, 0, /* Optional elements (not needed) */
297 -1, /* Start extensions */
298 -1 /* Stop extensions */
299};
300static /* Use -fall-defs-global to expose */
301asn_TYPE_descriptor_t asn_DEF_constrained_6 = {
302 "constrained",
303 "constrained",
304 SEQUENCE_free,
305 SEQUENCE_print,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700306 SEQUENCE_compare,
Lev Walkin69353a32017-07-25 08:10:46 -0700307 SEQUENCE_constraint,
308 SEQUENCE_decode_ber,
309 SEQUENCE_encode_der,
310 SEQUENCE_decode_xer,
311 SEQUENCE_encode_xer,
312 SEQUENCE_decode_oer,
313 SEQUENCE_encode_oer,
314 0, 0, /* No PER support, use "-gen-PER" to enable */
315 0, /* Use generic outmost tag fetcher */
316 asn_DEF_constrained_tags_6,
317 sizeof(asn_DEF_constrained_tags_6)
318 /sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
319 asn_DEF_constrained_tags_6, /* Same as above */
320 sizeof(asn_DEF_constrained_tags_6)
321 /sizeof(asn_DEF_constrained_tags_6[0]), /* 1 */
322 0, /* No OER visible constraints */
323 0, /* No PER visible constraints */
324 asn_MBR_constrained_6,
325 3, /* Elements count */
326 &asn_SPC_constrained_specs_6 /* Additional specs */
327};
328
329static asn_TYPE_member_t asn_MBR_T_1[] = {
330 { ATF_NOFLAGS, 0, offsetof(struct T, unconstrained),
331 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
332 .tag_mode = 0,
333 .type = &asn_DEF_unconstrained_2,
334 .memb_constraints = 0, /* Defer constraints checking to the member type */
335 .oer_constraints = 0, /* No OER visible constraints */
336 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
337 .default_value = 0,
338 .name = "unconstrained"
339 },
340 { ATF_NOFLAGS, 0, offsetof(struct T, constrained),
341 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
342 .tag_mode = 0,
343 .type = &asn_DEF_constrained_6,
344 .memb_constraints = 0, /* Defer constraints checking to the member type */
345 .oer_constraints = 0, /* No OER visible constraints */
346 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
347 .default_value = 0,
348 .name = "constrained"
349 },
350};
351static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
352 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
353};
354static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
355 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 1 }, /* unconstrained */
356 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 1, -1, 0 } /* constrained */
357};
358static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
359 sizeof(struct T),
360 offsetof(struct T, _asn_ctx),
361 asn_MAP_T_tag2el_1,
362 2, /* Count of tags in the map */
363 0, 0, 0, /* Optional elements (not needed) */
364 -1, /* Start extensions */
365 -1 /* Stop extensions */
366};
367asn_TYPE_descriptor_t asn_DEF_T = {
368 "T",
369 "T",
370 SEQUENCE_free,
371 SEQUENCE_print,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700372 SEQUENCE_compare,
Lev Walkin69353a32017-07-25 08:10:46 -0700373 SEQUENCE_constraint,
374 SEQUENCE_decode_ber,
375 SEQUENCE_encode_der,
376 SEQUENCE_decode_xer,
377 SEQUENCE_encode_xer,
378 SEQUENCE_decode_oer,
379 SEQUENCE_encode_oer,
380 0, 0, /* No PER support, use "-gen-PER" to enable */
381 0, /* Use generic outmost tag fetcher */
382 asn_DEF_T_tags_1,
383 sizeof(asn_DEF_T_tags_1)
384 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
385 asn_DEF_T_tags_1, /* Same as above */
386 sizeof(asn_DEF_T_tags_1)
387 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
388 0, /* No OER visible constraints */
389 0, /* No PER visible constraints */
390 asn_MBR_T_1,
391 2, /* Elements count */
392 &asn_SPC_T_specs_1 /* Additional specs */
393};
394