Debian Codegraph @

tests/127-per-long-OK.asn1.-Pgen-PER

raw
1
2 /*** <<< INCLUDES [T] >>> ***/
3
4 #include <NativeInteger.h>
5 #include <constr_SEQUENCE.h>
6
7 /*** <<< TYPE-DECLS [T] >>> ***/
8
9 typedef struct T {
10 long small32range;
11 long full32range;
12 unsigned long unsigned32;
13 unsigned long unsplit32;
14
15 /* Context for parsing across buffer boundaries */
16 asn_struct_ctx_t _asn_ctx;
17 } T_t;
18
19 /*** <<< FUNC-DECLS [T] >>> ***/
20
21 /* extern asn_TYPE_descriptor_t asn_DEF_unsigned32_4; // (Use -fall-defs-global to expose) */
22 /* extern asn_TYPE_descriptor_t asn_DEF_unsplit32_5; // (Use -fall-defs-global to expose) */
23 extern asn_TYPE_descriptor_t asn_DEF_T;
24
25 /*** <<< CODE [T] >>> ***/
26
27 static int
28 unsigned32_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
29 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
30
31 if(!sptr) {
32 ASN__CTFAIL(app_key, td, sptr,
33 "%s: value not given (%s:%d)",
34 td->name, __FILE__, __LINE__);
35 return -1;
36 }
37
38
39 /* Constraint check succeeded */
40 return 0;
41 }
42
43 /*
44 * This type is implemented using NativeInteger,
45 * so here we adjust the DEF accordingly.
46 */
47 static void
48 unsigned32_4_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
49 td->free_struct = asn_DEF_NativeInteger.free_struct;
50 td->print_struct = asn_DEF_NativeInteger.print_struct;
51 td->check_constraints = asn_DEF_NativeInteger.check_constraints;
52 td->ber_decoder = asn_DEF_NativeInteger.ber_decoder;
53 td->der_encoder = asn_DEF_NativeInteger.der_encoder;
54 td->xer_decoder = asn_DEF_NativeInteger.xer_decoder;
55 td->xer_encoder = asn_DEF_NativeInteger.xer_encoder;
56 td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
57 td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
58 if(!td->per_constraints)
59 td->per_constraints = asn_DEF_NativeInteger.per_constraints;
60 td->elements = asn_DEF_NativeInteger.elements;
61 td->elements_count = asn_DEF_NativeInteger.elements_count;
62 /* td->specifics = asn_DEF_NativeInteger.specifics; // Defined explicitly */
63 }
64
65 static void
66 unsigned32_4_free(asn_TYPE_descriptor_t *td,
67 void *struct_ptr, int contents_only) {
68 unsigned32_4_inherit_TYPE_descriptor(td);
69 td->free_struct(td, struct_ptr, contents_only);
70 }
71
72 static int
73 unsigned32_4_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
74 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
75 unsigned32_4_inherit_TYPE_descriptor(td);
76 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
77 }
78
79 static asn_dec_rval_t
80 unsigned32_4_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
81 void **structure, const void *bufptr, size_t size, int tag_mode) {
82 unsigned32_4_inherit_TYPE_descriptor(td);
83 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
84 }
85
86 static asn_enc_rval_t
87 unsigned32_4_encode_der(asn_TYPE_descriptor_t *td,
88 void *structure, int tag_mode, ber_tlv_tag_t tag,
89 asn_app_consume_bytes_f *cb, void *app_key) {
90 unsigned32_4_inherit_TYPE_descriptor(td);
91 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
92 }
93
94 static asn_dec_rval_t
95 unsigned32_4_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
96 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
97 unsigned32_4_inherit_TYPE_descriptor(td);
98 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
99 }
100
101 static asn_enc_rval_t
102 unsigned32_4_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
103 int ilevel, enum xer_encoder_flags_e flags,
104 asn_app_consume_bytes_f *cb, void *app_key) {
105 unsigned32_4_inherit_TYPE_descriptor(td);
106 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
107 }
108
109 static asn_dec_rval_t
110 unsigned32_4_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
111 asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) {
112 unsigned32_4_inherit_TYPE_descriptor(td);
113 return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data);
114 }
115
116 static asn_enc_rval_t
117 unsigned32_4_encode_uper(asn_TYPE_descriptor_t *td,
118 asn_per_constraints_t *constraints,
119 void *structure, asn_per_outp_t *per_out) {
120 unsigned32_4_inherit_TYPE_descriptor(td);
121 return td->uper_encoder(td, constraints, structure, per_out);
122 }
123
124 static int
125 unsplit32_5_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
126 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
127 unsigned long value;
128
129 if(!sptr) {
130 ASN__CTFAIL(app_key, td, sptr,
131 "%s: value not given (%s:%d)",
132 td->name, __FILE__, __LINE__);
133 return -1;
134 }
135
136 value = *(const unsigned long *)sptr;
137
138 if(((value >= 5 && value <= 500) || (value >= 600 && value <= 4294967290))) {
139 /* Constraint check succeeded */
140 return 0;
141 } else {
142 ASN__CTFAIL(app_key, td, sptr,
143 "%s: constraint failed (%s:%d)",
144 td->name, __FILE__, __LINE__);
145 return -1;
146 }
147 }
148
149 /*
150 * This type is implemented using NativeInteger,
151 * so here we adjust the DEF accordingly.
152 */
153 static void
154 unsplit32_5_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
155 td->free_struct = asn_DEF_NativeInteger.free_struct;
156 td->print_struct = asn_DEF_NativeInteger.print_struct;
157 td->check_constraints = asn_DEF_NativeInteger.check_constraints;
158 td->ber_decoder = asn_DEF_NativeInteger.ber_decoder;
159 td->der_encoder = asn_DEF_NativeInteger.der_encoder;
160 td->xer_decoder = asn_DEF_NativeInteger.xer_decoder;
161 td->xer_encoder = asn_DEF_NativeInteger.xer_encoder;
162 td->uper_decoder = asn_DEF_NativeInteger.uper_decoder;
163 td->uper_encoder = asn_DEF_NativeInteger.uper_encoder;
164 if(!td->per_constraints)
165 td->per_constraints = asn_DEF_NativeInteger.per_constraints;
166 td->elements = asn_DEF_NativeInteger.elements;
167 td->elements_count = asn_DEF_NativeInteger.elements_count;
168 /* td->specifics = asn_DEF_NativeInteger.specifics; // Defined explicitly */
169 }
170
171 static void
172 unsplit32_5_free(asn_TYPE_descriptor_t *td,
173 void *struct_ptr, int contents_only) {
174 unsplit32_5_inherit_TYPE_descriptor(td);
175 td->free_struct(td, struct_ptr, contents_only);
176 }
177
178 static int
179 unsplit32_5_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
180 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
181 unsplit32_5_inherit_TYPE_descriptor(td);
182 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
183 }
184
185 static asn_dec_rval_t
186 unsplit32_5_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
187 void **structure, const void *bufptr, size_t size, int tag_mode) {
188 unsplit32_5_inherit_TYPE_descriptor(td);
189 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
190 }
191
192 static asn_enc_rval_t
193 unsplit32_5_encode_der(asn_TYPE_descriptor_t *td,
194 void *structure, int tag_mode, ber_tlv_tag_t tag,
195 asn_app_consume_bytes_f *cb, void *app_key) {
196 unsplit32_5_inherit_TYPE_descriptor(td);
197 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
198 }
199
200 static asn_dec_rval_t
201 unsplit32_5_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
202 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
203 unsplit32_5_inherit_TYPE_descriptor(td);
204 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
205 }
206
207 static asn_enc_rval_t
208 unsplit32_5_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
209 int ilevel, enum xer_encoder_flags_e flags,
210 asn_app_consume_bytes_f *cb, void *app_key) {
211 unsplit32_5_inherit_TYPE_descriptor(td);
212 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
213 }
214
215 static asn_dec_rval_t
216 unsplit32_5_decode_uper(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
217 asn_per_constraints_t *constraints, void **structure, asn_per_data_t *per_data) {
218 unsplit32_5_inherit_TYPE_descriptor(td);
219 return td->uper_decoder(opt_codec_ctx, td, constraints, structure, per_data);
220 }
221
222 static asn_enc_rval_t
223 unsplit32_5_encode_uper(asn_TYPE_descriptor_t *td,
224 asn_per_constraints_t *constraints,
225 void *structure, asn_per_outp_t *per_out) {
226 unsplit32_5_inherit_TYPE_descriptor(td);
227 return td->uper_encoder(td, constraints, structure, per_out);
228 }
229
230 static int
231 memb_small32range_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
232 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
233 long value;
234
235 if(!sptr) {
236 ASN__CTFAIL(app_key, td, sptr,
237 "%s: value not given (%s:%d)",
238 td->name, __FILE__, __LINE__);
239 return -1;
240 }
241
242 value = *(const long *)sptr;
243
244 if((value >= -2000000000 && value <= 2000000000)) {
245 /* Constraint check succeeded */
246 return 0;
247 } else {
248 ASN__CTFAIL(app_key, td, sptr,
249 "%s: constraint failed (%s:%d)",
250 td->name, __FILE__, __LINE__);
251 return -1;
252 }
253 }
254
255 static int
256 memb_full32range_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
257 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
258 long value;
259
260 if(!sptr) {
261 ASN__CTFAIL(app_key, td, sptr,
262 "%s: value not given (%s:%d)",
263 td->name, __FILE__, __LINE__);
264 return -1;
265 }
266
267 value = *(const long *)sptr;
268
269 if((value >= (-2147483647L - 1) && value <= 2147483647)) {
270 /* Constraint check succeeded */
271 return 0;
272 } else {
273 ASN__CTFAIL(app_key, td, sptr,
274 "%s: constraint failed (%s:%d)",
275 td->name, __FILE__, __LINE__);
276 return -1;
277 }
278 }
279
280 static int
281 memb_unsigned32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
282 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
283
284 if(!sptr) {
285 ASN__CTFAIL(app_key, td, sptr,
286 "%s: value not given (%s:%d)",
287 td->name, __FILE__, __LINE__);
288 return -1;
289 }
290
291
292 /* Constraint check succeeded */
293 return 0;
294 }
295
296 static int
297 memb_unsplit32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
298 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
299 unsigned long value;
300
301 if(!sptr) {
302 ASN__CTFAIL(app_key, td, sptr,
303 "%s: value not given (%s:%d)",
304 td->name, __FILE__, __LINE__);
305 return -1;
306 }
307
308 value = *(const unsigned long *)sptr;
309
310 if(((value >= 5 && value <= 500) || (value >= 600 && value <= 4294967290))) {
311 /* Constraint check succeeded */
312 return 0;
313 } else {
314 ASN__CTFAIL(app_key, td, sptr,
315 "%s: constraint failed (%s:%d)",
316 td->name, __FILE__, __LINE__);
317 return -1;
318 }
319 }
320
321
322 /*** <<< CTDEFS [T] >>> ***/
323
324 static asn_per_constraints_t asn_PER_type_unsigned32_constr_4 GCC_NOTUSED = {
325 { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */,
326 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
327 0, 0 /* No PER value map */
328 };
329 static asn_per_constraints_t asn_PER_type_unsplit32_constr_5 GCC_NOTUSED = {
330 { APC_CONSTRAINED, 32, -1, 5, 4294967290 } /* (5..4294967290) */,
331 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
332 0, 0 /* No PER value map */
333 };
334 static asn_per_constraints_t asn_PER_memb_small32range_constr_2 GCC_NOTUSED = {
335 { APC_CONSTRAINED, 32, -1, -2000000000, 2000000000 } /* (-2000000000..2000000000) */,
336 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
337 0, 0 /* No PER value map */
338 };
339 static asn_per_constraints_t asn_PER_memb_full32range_constr_3 GCC_NOTUSED = {
340 { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */,
341 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
342 0, 0 /* No PER value map */
343 };
344 static asn_per_constraints_t asn_PER_memb_unsigned32_constr_4 GCC_NOTUSED = {
345 { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */,
346 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
347 0, 0 /* No PER value map */
348 };
349 static asn_per_constraints_t asn_PER_memb_unsplit32_constr_5 GCC_NOTUSED = {
350 { APC_CONSTRAINED, 32, -1, 5, 4294967290 } /* (5..4294967290) */,
351 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
352 0, 0 /* No PER value map */
353 };
354
355 /*** <<< STAT-DEFS [T] >>> ***/
356
357 static const asn_INTEGER_specifics_t asn_SPC_unsigned32_specs_4 = {
358 0, 0, 0, 0, 0,
359 0, /* Native long size */
360 1 /* Unsigned representation */
361 };
362 static const ber_tlv_tag_t asn_DEF_unsigned32_tags_4[] = {
363 (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
364 (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
365 };
366 static /* Use -fall-defs-global to expose */
367 asn_TYPE_descriptor_t asn_DEF_unsigned32_4 = {
368 "unsigned32",
369 "unsigned32",
370 unsigned32_4_free,
371 unsigned32_4_print,
372 unsigned32_4_constraint,
373 unsigned32_4_decode_ber,
374 unsigned32_4_encode_der,
375 unsigned32_4_decode_xer,
376 unsigned32_4_encode_xer,
377 unsigned32_4_decode_uper,
378 unsigned32_4_encode_uper,
379 0, /* Use generic outmost tag fetcher */
380 asn_DEF_unsigned32_tags_4,
381 sizeof(asn_DEF_unsigned32_tags_4)
382 /sizeof(asn_DEF_unsigned32_tags_4[0]) - 1, /* 1 */
383 asn_DEF_unsigned32_tags_4, /* Same as above */
384 sizeof(asn_DEF_unsigned32_tags_4)
385 /sizeof(asn_DEF_unsigned32_tags_4[0]), /* 2 */
386 &asn_PER_type_unsigned32_constr_4,
387 0, 0, /* No members */
388 &asn_SPC_unsigned32_specs_4 /* Additional specs */
389 };
390
391 static const asn_INTEGER_specifics_t asn_SPC_unsplit32_specs_5 = {
392 0, 0, 0, 0, 0,
393 0, /* Native long size */
394 1 /* Unsigned representation */
395 };
396 static const ber_tlv_tag_t asn_DEF_unsplit32_tags_5[] = {
397 (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
398 (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
399 };
400 static /* Use -fall-defs-global to expose */
401 asn_TYPE_descriptor_t asn_DEF_unsplit32_5 = {
402 "unsplit32",
403 "unsplit32",
404 unsplit32_5_free,
405 unsplit32_5_print,
406 unsplit32_5_constraint,
407 unsplit32_5_decode_ber,
408 unsplit32_5_encode_der,
409 unsplit32_5_decode_xer,
410 unsplit32_5_encode_xer,
411 unsplit32_5_decode_uper,
412 unsplit32_5_encode_uper,
413 0, /* Use generic outmost tag fetcher */
414 asn_DEF_unsplit32_tags_5,
415 sizeof(asn_DEF_unsplit32_tags_5)
416 /sizeof(asn_DEF_unsplit32_tags_5[0]) - 1, /* 1 */
417 asn_DEF_unsplit32_tags_5, /* Same as above */
418 sizeof(asn_DEF_unsplit32_tags_5)
419 /sizeof(asn_DEF_unsplit32_tags_5[0]), /* 2 */
420 &asn_PER_type_unsplit32_constr_5,
421 0, 0, /* No members */
422 &asn_SPC_unsplit32_specs_5 /* Additional specs */
423 };
424
425 static asn_TYPE_member_t asn_MBR_T_1[] = {
426 { ATF_NOFLAGS, 0, offsetof(struct T, small32range),
427 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
428 .tag_mode = -1, /* IMPLICIT tag at current level */
429 .type = &asn_DEF_NativeInteger,
430 .memb_constraints = memb_small32range_constraint_1,
431 .per_constraints = &asn_PER_memb_small32range_constr_2,
432 .default_value = 0,
433 .name = "small32range"
434 },
435 { ATF_NOFLAGS, 0, offsetof(struct T, full32range),
436 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
437 .tag_mode = -1, /* IMPLICIT tag at current level */
438 .type = &asn_DEF_NativeInteger,
439 .memb_constraints = memb_full32range_constraint_1,
440 .per_constraints = &asn_PER_memb_full32range_constr_3,
441 .default_value = 0,
442 .name = "full32range"
443 },
444 { ATF_NOFLAGS, 0, offsetof(struct T, unsigned32),
445 .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
446 .tag_mode = -1, /* IMPLICIT tag at current level */
447 .type = &asn_DEF_unsigned32_4,
448 .memb_constraints = memb_unsigned32_constraint_1,
449 .per_constraints = &asn_PER_memb_unsigned32_constr_4,
450 .default_value = 0,
451 .name = "unsigned32"
452 },
453 { ATF_NOFLAGS, 0, offsetof(struct T, unsplit32),
454 .tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
455 .tag_mode = -1, /* IMPLICIT tag at current level */
456 .type = &asn_DEF_unsplit32_5,
457 .memb_constraints = memb_unsplit32_constraint_1,
458 .per_constraints = &asn_PER_memb_unsplit32_constr_5,
459 .default_value = 0,
460 .name = "unsplit32"
461 },
462 };
463 static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
464 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
465 };
466 static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
467 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* small32range */
468 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* full32range */
469 { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* unsigned32 */
470 { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* unsplit32 */
471 };
472 static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
473 sizeof(struct T),
474 offsetof(struct T, _asn_ctx),
475 asn_MAP_T_tag2el_1,
476 4, /* Count of tags in the map */
477 0, 0, 0, /* Optional elements (not needed) */
478 -1, /* Start extensions */
479 -1 /* Stop extensions */
480 };
481 asn_TYPE_descriptor_t asn_DEF_T = {
482 "T",
483 "T",
484 SEQUENCE_free,
485 SEQUENCE_print,
486 SEQUENCE_constraint,
487 SEQUENCE_decode_ber,
488 SEQUENCE_encode_der,
489 SEQUENCE_decode_xer,
490 SEQUENCE_encode_xer,
491 SEQUENCE_decode_uper,
492 SEQUENCE_encode_uper,
493 0, /* Use generic outmost tag fetcher */
494 asn_DEF_T_tags_1,
495 sizeof(asn_DEF_T_tags_1)
496 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
497 asn_DEF_T_tags_1, /* Same as above */
498 sizeof(asn_DEF_T_tags_1)
499 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
500 0, /* No PER visible constraints */
501 asn_MBR_T_1,
502 4, /* Elements count */
503 &asn_SPC_T_specs_1 /* Additional specs */
504 };
505