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