Debian Codegraph @

tests/19-param-OK.asn1.-Pfwide-types

raw
1
2 /*** <<< INCLUDES [SIGNED] >>> ***/
3
4 #include <OBJECT_IDENTIFIER.h>
5 #include <BIT_STRING.h>
6 #include <INTEGER.h>
7 #include "Name.h"
8 #include <constr_SEQUENCE.h>
9
10 /*** <<< TYPE-DECLS [SIGNED] >>> ***/
11
12 typedef struct SIGNED_15P0 {
13 struct toBeSigned {
14 INTEGER_t version;
15 OBJECT_IDENTIFIER_t signature;
16 Name_t issuer;
17
18 /* Context for parsing across buffer boundaries */
19 asn_struct_ctx_t _asn_ctx;
20 } toBeSigned;
21 OBJECT_IDENTIFIER_t algorithm;
22 BIT_STRING_t signature;
23
24 /* Context for parsing across buffer boundaries */
25 asn_struct_ctx_t _asn_ctx;
26 } SIGNED_15P0_t;
27
28 /*** <<< FUNC-DECLS [SIGNED] >>> ***/
29
30 extern asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0;
31
32 /*** <<< CODE [SIGNED] >>> ***/
33
34 static int
35 memb_signature_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
36 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
37 const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
38 size_t size;
39
40 if(!sptr) {
41 ASN__CTFAIL(app_key, td, sptr,
42 "%s: value not given (%s:%d)",
43 td->name, __FILE__, __LINE__);
44 return -1;
45 }
46
47 if(st->size > 0) {
48 /* Size in bits */
49 size = 8 * st->size - (st->bits_unused & 0x07);
50 } else {
51 size = 0;
52 }
53
54 if((size <= 256)) {
55 /* Constraint check succeeded */
56 return 0;
57 } else {
58 ASN__CTFAIL(app_key, td, sptr,
59 "%s: constraint failed (%s:%d)",
60 td->name, __FILE__, __LINE__);
61 return -1;
62 }
63 }
64
65
66 /*** <<< STAT-DEFS [SIGNED] >>> ***/
67
68 static asn_TYPE_member_t asn_MBR_toBeSigned_2[] = {
69 { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, version),
70 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
71 .tag_mode = 0,
72 .type = &asn_DEF_INTEGER,
73 .memb_constraints = 0, /* Defer constraints checking to the member type */
74 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
75 .default_value = 0,
76 .name = "version"
77 },
78 { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, signature),
79 .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
80 .tag_mode = 0,
81 .type = &asn_DEF_OBJECT_IDENTIFIER,
82 .memb_constraints = 0, /* Defer constraints checking to the member type */
83 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
84 .default_value = 0,
85 .name = "signature"
86 },
87 { ATF_NOFLAGS, 0, offsetof(struct toBeSigned, issuer),
88 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
89 .tag_mode = 0,
90 .type = &asn_DEF_Name,
91 .memb_constraints = 0, /* Defer constraints checking to the member type */
92 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
93 .default_value = 0,
94 .name = "issuer"
95 },
96 };
97 static const ber_tlv_tag_t asn_DEF_toBeSigned_tags_2[] = {
98 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
99 };
100 static const asn_TYPE_tag2member_t asn_MAP_toBeSigned_tag2el_2[] = {
101 { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* version */
102 { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* signature */
103 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 2, 0, 0 } /* issuer */
104 };
105 static asn_SEQUENCE_specifics_t asn_SPC_toBeSigned_specs_2 = {
106 sizeof(struct toBeSigned),
107 offsetof(struct toBeSigned, _asn_ctx),
108 asn_MAP_toBeSigned_tag2el_2,
109 3, /* Count of tags in the map */
110 0, 0, 0, /* Optional elements (not needed) */
111 -1, /* Start extensions */
112 -1 /* Stop extensions */
113 };
114 static /* Use -fall-defs-global to expose */
115 asn_TYPE_descriptor_t asn_DEF_toBeSigned_2 = {
116 "toBeSigned",
117 "toBeSigned",
118 SEQUENCE_free,
119 SEQUENCE_print,
120 SEQUENCE_constraint,
121 SEQUENCE_decode_ber,
122 SEQUENCE_encode_der,
123 SEQUENCE_decode_xer,
124 SEQUENCE_encode_xer,
125 0, 0, /* No PER support, use "-gen-PER" to enable */
126 0, /* Use generic outmost tag fetcher */
127 asn_DEF_toBeSigned_tags_2,
128 sizeof(asn_DEF_toBeSigned_tags_2)
129 /sizeof(asn_DEF_toBeSigned_tags_2[0]), /* 1 */
130 asn_DEF_toBeSigned_tags_2, /* Same as above */
131 sizeof(asn_DEF_toBeSigned_tags_2)
132 /sizeof(asn_DEF_toBeSigned_tags_2[0]), /* 1 */
133 0, /* No PER visible constraints */
134 asn_MBR_toBeSigned_2,
135 3, /* Elements count */
136 &asn_SPC_toBeSigned_specs_2 /* Additional specs */
137 };
138
139 static asn_TYPE_member_t asn_MBR_SIGNED_15P0_1[] = {
140 { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, toBeSigned),
141 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
142 .tag_mode = 0,
143 .type = &asn_DEF_toBeSigned_2,
144 .memb_constraints = 0, /* Defer constraints checking to the member type */
145 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
146 .default_value = 0,
147 .name = "toBeSigned"
148 },
149 { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, algorithm),
150 .tag = (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)),
151 .tag_mode = 0,
152 .type = &asn_DEF_OBJECT_IDENTIFIER,
153 .memb_constraints = 0, /* Defer constraints checking to the member type */
154 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
155 .default_value = 0,
156 .name = "algorithm"
157 },
158 { ATF_NOFLAGS, 0, offsetof(struct SIGNED_15P0, signature),
159 .tag = (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)),
160 .tag_mode = 0,
161 .type = &asn_DEF_BIT_STRING,
162 .memb_constraints = memb_signature_constraint_1,
163 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
164 .default_value = 0,
165 .name = "signature"
166 },
167 };
168 static const ber_tlv_tag_t asn_DEF_SIGNED_15P0_tags_1[] = {
169 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
170 };
171 static const asn_TYPE_tag2member_t asn_MAP_SIGNED_15P0_tag2el_1[] = {
172 { (ASN_TAG_CLASS_UNIVERSAL | (3 << 2)), 2, 0, 0 }, /* signature */
173 { (ASN_TAG_CLASS_UNIVERSAL | (6 << 2)), 1, 0, 0 }, /* algorithm */
174 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 } /* toBeSigned */
175 };
176 static asn_SEQUENCE_specifics_t asn_SPC_SIGNED_15P0_specs_1 = {
177 sizeof(struct SIGNED_15P0),
178 offsetof(struct SIGNED_15P0, _asn_ctx),
179 asn_MAP_SIGNED_15P0_tag2el_1,
180 3, /* Count of tags in the map */
181 0, 0, 0, /* Optional elements (not needed) */
182 -1, /* Start extensions */
183 -1 /* Stop extensions */
184 };
185 asn_TYPE_descriptor_t asn_DEF_SIGNED_15P0 = {
186 "SIGNED",
187 "SIGNED",
188 SEQUENCE_free,
189 SEQUENCE_print,
190 SEQUENCE_constraint,
191 SEQUENCE_decode_ber,
192 SEQUENCE_encode_der,
193 SEQUENCE_decode_xer,
194 SEQUENCE_encode_xer,
195 0, 0, /* No PER support, use "-gen-PER" to enable */
196 0, /* Use generic outmost tag fetcher */
197 asn_DEF_SIGNED_15P0_tags_1,
198 sizeof(asn_DEF_SIGNED_15P0_tags_1)
199 /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
200 asn_DEF_SIGNED_15P0_tags_1, /* Same as above */
201 sizeof(asn_DEF_SIGNED_15P0_tags_1)
202 /sizeof(asn_DEF_SIGNED_15P0_tags_1[0]), /* 1 */
203 0, /* No PER visible constraints */
204 asn_MBR_SIGNED_15P0_1,
205 3, /* Elements count */
206 &asn_SPC_SIGNED_15P0_specs_1 /* Additional specs */
207 };
208
209
210 /*** <<< INCLUDES [Certificate] >>> ***/
211
212 #include "SIGNED.h"
213
214 /*** <<< TYPE-DECLS [Certificate] >>> ***/
215
216 typedef SIGNED_15P0_t Certificate_t;
217
218 /*** <<< FUNC-DECLS [Certificate] >>> ***/
219
220 extern asn_TYPE_descriptor_t asn_DEF_Certificate;
221 asn_struct_free_f Certificate_free;
222 asn_struct_print_f Certificate_print;
223 asn_constr_check_f Certificate_constraint;
224 ber_type_decoder_f Certificate_decode_ber;
225 der_type_encoder_f Certificate_encode_der;
226 xer_type_decoder_f Certificate_decode_xer;
227 xer_type_encoder_f Certificate_encode_xer;
228
229 /*** <<< CODE [Certificate] >>> ***/
230
231 int
232 Certificate_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
233 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
234 /* Replace with underlying type checker */
235 td->check_constraints = asn_DEF_SIGNED_15P0.check_constraints;
236 return td->check_constraints(td, sptr, ctfailcb, app_key);
237 }
238
239 /*
240 * This type is implemented using SIGNED_15P0,
241 * so here we adjust the DEF accordingly.
242 */
243 static void
244 Certificate_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
245 td->free_struct = asn_DEF_SIGNED_15P0.free_struct;
246 td->print_struct = asn_DEF_SIGNED_15P0.print_struct;
247 td->check_constraints = asn_DEF_SIGNED_15P0.check_constraints;
248 td->ber_decoder = asn_DEF_SIGNED_15P0.ber_decoder;
249 td->der_encoder = asn_DEF_SIGNED_15P0.der_encoder;
250 td->xer_decoder = asn_DEF_SIGNED_15P0.xer_decoder;
251 td->xer_encoder = asn_DEF_SIGNED_15P0.xer_encoder;
252 td->uper_decoder = asn_DEF_SIGNED_15P0.uper_decoder;
253 td->uper_encoder = asn_DEF_SIGNED_15P0.uper_encoder;
254 if(!td->per_constraints)
255 td->per_constraints = asn_DEF_SIGNED_15P0.per_constraints;
256 td->elements = asn_DEF_SIGNED_15P0.elements;
257 td->elements_count = asn_DEF_SIGNED_15P0.elements_count;
258 td->specifics = asn_DEF_SIGNED_15P0.specifics;
259 }
260
261 void
262 Certificate_free(asn_TYPE_descriptor_t *td,
263 void *struct_ptr, int contents_only) {
264 Certificate_1_inherit_TYPE_descriptor(td);
265 td->free_struct(td, struct_ptr, contents_only);
266 }
267
268 int
269 Certificate_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
270 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
271 Certificate_1_inherit_TYPE_descriptor(td);
272 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
273 }
274
275 asn_dec_rval_t
276 Certificate_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
277 void **structure, const void *bufptr, size_t size, int tag_mode) {
278 Certificate_1_inherit_TYPE_descriptor(td);
279 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
280 }
281
282 asn_enc_rval_t
283 Certificate_encode_der(asn_TYPE_descriptor_t *td,
284 void *structure, int tag_mode, ber_tlv_tag_t tag,
285 asn_app_consume_bytes_f *cb, void *app_key) {
286 Certificate_1_inherit_TYPE_descriptor(td);
287 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
288 }
289
290 asn_dec_rval_t
291 Certificate_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
292 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
293 Certificate_1_inherit_TYPE_descriptor(td);
294 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
295 }
296
297 asn_enc_rval_t
298 Certificate_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
299 int ilevel, enum xer_encoder_flags_e flags,
300 asn_app_consume_bytes_f *cb, void *app_key) {
301 Certificate_1_inherit_TYPE_descriptor(td);
302 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
303 }
304
305
306 /*** <<< STAT-DEFS [Certificate] >>> ***/
307
308 static const ber_tlv_tag_t asn_DEF_Certificate_tags_1[] = {
309 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
310 };
311 asn_TYPE_descriptor_t asn_DEF_Certificate = {
312 "Certificate",
313 "Certificate",
314 Certificate_free,
315 Certificate_print,
316 Certificate_constraint,
317 Certificate_decode_ber,
318 Certificate_encode_der,
319 Certificate_decode_xer,
320 Certificate_encode_xer,
321 0, 0, /* No PER support, use "-gen-PER" to enable */
322 0, /* Use generic outmost tag fetcher */
323 asn_DEF_Certificate_tags_1,
324 sizeof(asn_DEF_Certificate_tags_1)
325 /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
326 asn_DEF_Certificate_tags_1, /* Same as above */
327 sizeof(asn_DEF_Certificate_tags_1)
328 /sizeof(asn_DEF_Certificate_tags_1[0]), /* 1 */
329 0, /* No PER visible constraints */
330 0, 0, /* Defined elsewhere */
331 0 /* No specifics */
332 };
333
334
335 /*** <<< INCLUDES [Name] >>> ***/
336
337 #include <asn_SEQUENCE_OF.h>
338 #include <constr_SEQUENCE_OF.h>
339
340 /*** <<< FWD-DECLS [Name] >>> ***/
341
342 struct RelativeDistinguishedName;
343
344 /*** <<< TYPE-DECLS [Name] >>> ***/
345
346 typedef struct Name {
347 A_SEQUENCE_OF(struct RelativeDistinguishedName) list;
348
349 /* Context for parsing across buffer boundaries */
350 asn_struct_ctx_t _asn_ctx;
351 } Name_t;
352
353 /*** <<< FUNC-DECLS [Name] >>> ***/
354
355 extern asn_TYPE_descriptor_t asn_DEF_Name;
356
357 /*** <<< POST-INCLUDE [Name] >>> ***/
358
359 #include "RelativeDistinguishedName.h"
360
361 /*** <<< STAT-DEFS [Name] >>> ***/
362
363 static asn_TYPE_member_t asn_MBR_Name_1[] = {
364 { ATF_POINTER, 0, 0,
365 .tag = (ASN_TAG_CLASS_UNIVERSAL | (17 << 2)),
366 .tag_mode = 0,
367 .type = &asn_DEF_RelativeDistinguishedName,
368 .memb_constraints = 0, /* Defer constraints checking to the member type */
369 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
370 .default_value = 0,
371 .name = ""
372 },
373 };
374 static const ber_tlv_tag_t asn_DEF_Name_tags_1[] = {
375 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
376 };
377 static asn_SET_OF_specifics_t asn_SPC_Name_specs_1 = {
378 sizeof(struct Name),
379 offsetof(struct Name, _asn_ctx),
380 0, /* XER encoding is XMLDelimitedItemList */
381 };
382 asn_TYPE_descriptor_t asn_DEF_Name = {
383 "Name",
384 "Name",
385 SEQUENCE_OF_free,
386 SEQUENCE_OF_print,
387 SEQUENCE_OF_constraint,
388 SEQUENCE_OF_decode_ber,
389 SEQUENCE_OF_encode_der,
390 SEQUENCE_OF_decode_xer,
391 SEQUENCE_OF_encode_xer,
392 0, 0, /* No PER support, use "-gen-PER" to enable */
393 0, /* Use generic outmost tag fetcher */
394 asn_DEF_Name_tags_1,
395 sizeof(asn_DEF_Name_tags_1)
396 /sizeof(asn_DEF_Name_tags_1[0]), /* 1 */
397 asn_DEF_Name_tags_1, /* Same as above */
398 sizeof(asn_DEF_Name_tags_1)
399 /sizeof(asn_DEF_Name_tags_1[0]), /* 1 */
400 0, /* No PER visible constraints */
401 asn_MBR_Name_1,
402 1, /* Single element */
403 &asn_SPC_Name_specs_1 /* Additional specs */
404 };
405
406
407 /*** <<< INCLUDES [RelativeDistinguishedName] >>> ***/
408
409 #include <IA5String.h>
410 #include <asn_SET_OF.h>
411 #include <constr_SET_OF.h>
412
413 /*** <<< TYPE-DECLS [RelativeDistinguishedName] >>> ***/
414
415 typedef struct RelativeDistinguishedName {
416 A_SET_OF(IA5String_t) list;
417
418 /* Context for parsing across buffer boundaries */
419 asn_struct_ctx_t _asn_ctx;
420 } RelativeDistinguishedName_t;
421
422 /*** <<< FUNC-DECLS [RelativeDistinguishedName] >>> ***/
423
424 extern asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName;
425
426 /*** <<< CTABLES [RelativeDistinguishedName] >>> ***/
427
428 static const int permitted_alphabet_table_2[256] = {
429 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
430 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* */
431 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 0, /* ,-. */
432 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, /* 0 9 */
433 0, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20, /* ABCDEFGHIJKLMNO */
434 21,22,23,24,25,26,27,28,29,30,31, 0, 0, 0, 0, 0, /* PQRSTUVWXYZ */
435 0,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, /* abcdefghijklmno */
436 47,48,49,50,51,52,53,54,55,56,57, 0, 0, 0, 0, 0, /* pqrstuvwxyz */
437 };
438
439 static int check_permitted_alphabet_2(const void *sptr) {
440 const int *table = permitted_alphabet_table_2;
441 /* The underlying type is IA5String */
442 const IA5String_t *st = (const IA5String_t *)sptr;
443 const uint8_t *ch = st->buf;
444 const uint8_t *end = ch + st->size;
445
446 for(; ch < end; ch++) {
447 uint8_t cv = *ch;
448 if(!table[cv]) return -1;
449 }
450 return 0;
451 }
452
453
454 /*** <<< CODE [RelativeDistinguishedName] >>> ***/
455
456 static int
457 memb_IA5String_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
458 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
459 const IA5String_t *st = (const IA5String_t *)sptr;
460
461 if(!sptr) {
462 ASN__CTFAIL(app_key, td, sptr,
463 "%s: value not given (%s:%d)",
464 td->name, __FILE__, __LINE__);
465 return -1;
466 }
467
468
469 if(!check_permitted_alphabet_2(st)) {
470 /* Constraint check succeeded */
471 return 0;
472 } else {
473 ASN__CTFAIL(app_key, td, sptr,
474 "%s: constraint failed (%s:%d)",
475 td->name, __FILE__, __LINE__);
476 return -1;
477 }
478 }
479
480
481 /*** <<< STAT-DEFS [RelativeDistinguishedName] >>> ***/
482
483 static asn_TYPE_member_t asn_MBR_RelativeDistinguishedName_1[] = {
484 { ATF_POINTER, 0, 0,
485 .tag = (ASN_TAG_CLASS_UNIVERSAL | (22 << 2)),
486 .tag_mode = 0,
487 .type = &asn_DEF_IA5String,
488 .memb_constraints = memb_IA5String_constraint_1,
489 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
490 .default_value = 0,
491 .name = ""
492 },
493 };
494 static const ber_tlv_tag_t asn_DEF_RelativeDistinguishedName_tags_1[] = {
495 (ASN_TAG_CLASS_UNIVERSAL | (17 << 2))
496 };
497 static asn_SET_OF_specifics_t asn_SPC_RelativeDistinguishedName_specs_1 = {
498 sizeof(struct RelativeDistinguishedName),
499 offsetof(struct RelativeDistinguishedName, _asn_ctx),
500 0, /* XER encoding is XMLDelimitedItemList */
501 };
502 asn_TYPE_descriptor_t asn_DEF_RelativeDistinguishedName = {
503 "RelativeDistinguishedName",
504 "RelativeDistinguishedName",
505 SET_OF_free,
506 SET_OF_print,
507 SET_OF_constraint,
508 SET_OF_decode_ber,
509 SET_OF_encode_der,
510 SET_OF_decode_xer,
511 SET_OF_encode_xer,
512 0, 0, /* No PER support, use "-gen-PER" to enable */
513 0, /* Use generic outmost tag fetcher */
514 asn_DEF_RelativeDistinguishedName_tags_1,
515 sizeof(asn_DEF_RelativeDistinguishedName_tags_1)
516 /sizeof(asn_DEF_RelativeDistinguishedName_tags_1[0]), /* 1 */
517 asn_DEF_RelativeDistinguishedName_tags_1, /* Same as above */
518 sizeof(asn_DEF_RelativeDistinguishedName_tags_1)
519 /sizeof(asn_DEF_RelativeDistinguishedName_tags_1[0]), /* 1 */
520 0, /* No PER visible constraints */
521 asn_MBR_RelativeDistinguishedName_1,
522 1, /* Single element */
523 &asn_SPC_RelativeDistinguishedName_specs_1 /* Additional specs */
524 };
525