blob: b191b564e29b1a2347ba7ce3c843d392b6e817b6 [file] [log] [blame]
vlm1a9741e2005-07-03 05:27:19 +00001
2/*** <<< INCLUDES [TestChoice] >>> ***/
3
4#include <INTEGER.h>
5#include <constr_SEQUENCE.h>
6#include <BOOLEAN.h>
7#include <constr_CHOICE.h>
8
9/*** <<< DEPS [TestChoice] >>> ***/
10
11typedef enum TestChoice_PR {
12 TestChoice_PR_NOTHING, /* No components present */
13 TestChoice_PR_type1,
14 TestChoice_PR_type2,
15} TestChoice_PR;
16
17/*** <<< TYPE-DECLS [TestChoice] >>> ***/
18
19typedef struct TestChoice {
20 TestChoice_PR present;
21 union {
22 struct type1 {
23 INTEGER_t *common /* DEFAULT 0 */;
24
25 /* Context for parsing across buffer boundaries */
26 asn_struct_ctx_t _asn_ctx;
27 } type1;
28 struct type2 {
29 BOOLEAN_t *common /* DEFAULT 0 */;
30
31 /* Context for parsing across buffer boundaries */
32 asn_struct_ctx_t _asn_ctx;
33 } type2;
34 } choice;
35
36 /* Context for parsing across buffer boundaries */
37 asn_struct_ctx_t _asn_ctx;
38} TestChoice_t;
39
40/*** <<< FUNC-DECLS [TestChoice] >>> ***/
41
42extern asn_TYPE_descriptor_t asn_DEF_TestChoice;
43
44/*** <<< CODE [TestChoice] >>> ***/
45
46static int
47memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
48 asn_app_consume_bytes_f *app_errlog, void *app_key) {
49 const INTEGER_t *st = (const INTEGER_t *)sptr;
50 long value;
51
52 if(!sptr) {
53 _ASN_ERRLOG(app_errlog, app_key,
54 "%s: value not given (%s:%d)",
55 td->name, __FILE__, __LINE__);
56 return -1;
57 }
58
59 if(asn_INTEGER2long(st, &value)) {
60 _ASN_ERRLOG(app_errlog, app_key,
61 "%s: value too large (%s:%d)",
62 td->name, __FILE__, __LINE__);
63 return -1;
64 }
65
66 if((value >= 1 && value <= 10)) {
67 /* Constraint check succeeded */
68 return 0;
69 } else {
70 _ASN_ERRLOG(app_errlog, app_key,
71 "%s: constraint failed (%s:%d)",
72 td->name, __FILE__, __LINE__);
73 return -1;
74 }
75}
76
77
78/*** <<< STAT-DEFS [TestChoice] >>> ***/
79
80static asn_TYPE_member_t asn_MBR_type1_2[] = {
81 { ATF_POINTER, 1, offsetof(struct type1, common),
82 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
83 .tag_mode = 0,
84 .type = (void *)&asn_DEF_INTEGER,
85 .memb_constraints = memb_common_2_constraint,
86 .name = "common"
87 },
88};
89static ber_tlv_tag_t asn_DEF_type1_2_tags[] = {
90 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
91};
92static asn_TYPE_tag2member_t asn_MAP_type1_2_tag2el[] = {
93 { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 } /* common at 20 */
94};
95static asn_SEQUENCE_specifics_t asn_SPC_type1_2_specs = {
96 sizeof(struct type1),
97 offsetof(struct type1, _asn_ctx),
98 asn_MAP_type1_2_tag2el,
99 1, /* Count of tags in the map */
100 -1, /* Start extensions */
101 -1 /* Stop extensions */
102};
103static /* Use -fall-defs-global to expose */
104asn_TYPE_descriptor_t asn_DEF_type1_2 = {
105 "type1",
106 "type1",
107 SEQUENCE_free,
108 SEQUENCE_print,
109 SEQUENCE_constraint,
110 SEQUENCE_decode_ber,
111 SEQUENCE_encode_der,
112 SEQUENCE_decode_xer,
113 SEQUENCE_encode_xer,
114 0, /* Use generic outmost tag fetcher */
115 asn_DEF_type1_2_tags,
116 sizeof(asn_DEF_type1_2_tags)
117 /sizeof(asn_DEF_type1_2_tags[0]), /* 1 */
118 asn_DEF_type1_2_tags, /* Same as above */
119 sizeof(asn_DEF_type1_2_tags)
120 /sizeof(asn_DEF_type1_2_tags[0]), /* 1 */
121 asn_MBR_type1_2,
122 1, /* Elements count */
123 &asn_SPC_type1_2_specs /* Additional specs */
124};
125
126static asn_TYPE_member_t asn_MBR_type2_4[] = {
127 { ATF_POINTER, 1, offsetof(struct type2, common),
128 .tag = (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)),
129 .tag_mode = 0,
130 .type = (void *)&asn_DEF_BOOLEAN,
131 .memb_constraints = 0, /* Defer constraints checking to the member type */
132 .name = "common"
133 },
134};
135static ber_tlv_tag_t asn_DEF_type2_4_tags[] = {
136 (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
137 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
138};
139static asn_TYPE_tag2member_t asn_MAP_type2_4_tag2el[] = {
140 { (ASN_TAG_CLASS_UNIVERSAL | (1 << 2)), 0, 0, 0 } /* common at 21 */
141};
142static asn_SEQUENCE_specifics_t asn_SPC_type2_4_specs = {
143 sizeof(struct type2),
144 offsetof(struct type2, _asn_ctx),
145 asn_MAP_type2_4_tag2el,
146 1, /* Count of tags in the map */
147 -1, /* Start extensions */
148 -1 /* Stop extensions */
149};
150static /* Use -fall-defs-global to expose */
151asn_TYPE_descriptor_t asn_DEF_type2_4 = {
152 "type2",
153 "type2",
154 SEQUENCE_free,
155 SEQUENCE_print,
156 SEQUENCE_constraint,
157 SEQUENCE_decode_ber,
158 SEQUENCE_encode_der,
159 SEQUENCE_decode_xer,
160 SEQUENCE_encode_xer,
161 0, /* Use generic outmost tag fetcher */
162 asn_DEF_type2_4_tags,
163 sizeof(asn_DEF_type2_4_tags)
164 /sizeof(asn_DEF_type2_4_tags[0]) - 1, /* 1 */
165 asn_DEF_type2_4_tags, /* Same as above */
166 sizeof(asn_DEF_type2_4_tags)
167 /sizeof(asn_DEF_type2_4_tags[0]), /* 2 */
168 asn_MBR_type2_4,
169 1, /* Elements count */
170 &asn_SPC_type2_4_specs /* Additional specs */
171};
172
173static asn_TYPE_member_t asn_MBR_TestChoice_1[] = {
174 { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type1),
175 .tag = (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)),
176 .tag_mode = 0,
177 .type = (void *)&asn_DEF_type1_2,
178 .memb_constraints = 0, /* Defer constraints checking to the member type */
179 .name = "type1"
180 },
181 { ATF_NOFLAGS, 0, offsetof(struct TestChoice, choice.type2),
182 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
183 .tag_mode = -1, /* IMPLICIT tag at current level */
184 .type = (void *)&asn_DEF_type2_4,
185 .memb_constraints = 0, /* Defer constraints checking to the member type */
186 .name = "type2"
187 },
188};
189static asn_TYPE_tag2member_t asn_MAP_TestChoice_1_tag2el[] = {
190 { (ASN_TAG_CLASS_UNIVERSAL | (16 << 2)), 0, 0, 0 }, /* type1 at 16 */
191 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 } /* type2 at 16 */
192};
193static asn_CHOICE_specifics_t asn_SPC_TestChoice_1_specs = {
194 sizeof(struct TestChoice),
195 offsetof(struct TestChoice, _asn_ctx),
196 offsetof(struct TestChoice, present),
197 sizeof(((struct TestChoice *)0)->present),
198 asn_MAP_TestChoice_1_tag2el,
199 2, /* Count of tags in the map */
200 0 /* Whether extensible */
201};
202asn_TYPE_descriptor_t asn_DEF_TestChoice = {
203 "TestChoice",
204 "TestChoice",
205 CHOICE_free,
206 CHOICE_print,
207 CHOICE_constraint,
208 CHOICE_decode_ber,
209 CHOICE_encode_der,
210 CHOICE_decode_xer,
211 CHOICE_encode_xer,
212 CHOICE_outmost_tag,
213 0, /* No effective tags (pointer) */
214 0, /* No effective tags (count) */
215 0, /* No tags (pointer) */
216 0, /* No tags (count) */
217 asn_MBR_TestChoice_1,
218 2, /* Elements count */
219 &asn_SPC_TestChoice_1_specs /* Additional specs */
220};
221
222
223/*** <<< INCLUDES [AutoChoice] >>> ***/
224
225#include <INTEGER.h>
226#include <constr_SEQUENCE.h>
227#include <BOOLEAN.h>
228#include <constr_CHOICE.h>
229
230/*** <<< DEPS [AutoChoice] >>> ***/
231
232typedef enum AutoChoice_PR {
233 AutoChoice_PR_NOTHING, /* No components present */
234 AutoChoice_PR_type1,
235 AutoChoice_PR_type2,
236} AutoChoice_PR;
237
238/*** <<< TYPE-DECLS [AutoChoice] >>> ***/
239
240typedef struct AutoChoice {
241 AutoChoice_PR present;
242 union {
243 struct type1 {
244 INTEGER_t common;
245
246 /* Context for parsing across buffer boundaries */
247 asn_struct_ctx_t _asn_ctx;
248 } type1;
249 struct type2 {
250 BOOLEAN_t common;
251
252 /* Context for parsing across buffer boundaries */
253 asn_struct_ctx_t _asn_ctx;
254 } type2;
255 } choice;
256
257 /* Context for parsing across buffer boundaries */
258 asn_struct_ctx_t _asn_ctx;
259} AutoChoice_t;
260
261/*** <<< FUNC-DECLS [AutoChoice] >>> ***/
262
263extern asn_TYPE_descriptor_t asn_DEF_AutoChoice;
264
265/*** <<< CODE [AutoChoice] >>> ***/
266
267static int
268memb_common_2_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
269 asn_app_consume_bytes_f *app_errlog, void *app_key) {
270 const INTEGER_t *st = (const INTEGER_t *)sptr;
271 long value;
272
273 if(!sptr) {
274 _ASN_ERRLOG(app_errlog, app_key,
275 "%s: value not given (%s:%d)",
276 td->name, __FILE__, __LINE__);
277 return -1;
278 }
279
280 if(asn_INTEGER2long(st, &value)) {
281 _ASN_ERRLOG(app_errlog, app_key,
282 "%s: value too large (%s:%d)",
283 td->name, __FILE__, __LINE__);
284 return -1;
285 }
286
287 if((value == 0)) {
288 /* Constraint check succeeded */
289 return 0;
290 } else {
291 _ASN_ERRLOG(app_errlog, app_key,
292 "%s: constraint failed (%s:%d)",
293 td->name, __FILE__, __LINE__);
294 return -1;
295 }
296}
297
298static int
299memb_common_4_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
300 asn_app_consume_bytes_f *app_errlog, void *app_key) {
301 BOOLEAN_t value;
302
303 if(!sptr) {
304 _ASN_ERRLOG(app_errlog, app_key,
305 "%s: value not given (%s:%d)",
306 td->name, __FILE__, __LINE__);
307 return -1;
308 }
309
310 value = (*(const long *)sptr) ? 1 : 0;
311
312 if((value <= 0)) {
313 /* Constraint check succeeded */
314 return 0;
315 } else {
316 _ASN_ERRLOG(app_errlog, app_key,
317 "%s: constraint failed (%s:%d)",
318 td->name, __FILE__, __LINE__);
319 return -1;
320 }
321}
322
323
324/*** <<< STAT-DEFS [AutoChoice] >>> ***/
325
326static asn_TYPE_member_t asn_MBR_type1_2[] = {
327 { ATF_NOFLAGS, 0, offsetof(struct type1, common),
328 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
329 .tag_mode = -1, /* IMPLICIT tag at current level */
330 .type = (void *)&asn_DEF_INTEGER,
331 .memb_constraints = memb_common_2_constraint,
332 .name = "common"
333 },
334};
335static ber_tlv_tag_t asn_DEF_type1_2_tags[] = {
336 (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
337 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
338};
339static asn_TYPE_tag2member_t asn_MAP_type1_2_tag2el[] = {
340 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 37 */
341};
342static asn_SEQUENCE_specifics_t asn_SPC_type1_2_specs = {
343 sizeof(struct type1),
344 offsetof(struct type1, _asn_ctx),
345 asn_MAP_type1_2_tag2el,
346 1, /* Count of tags in the map */
347 -1, /* Start extensions */
348 -1 /* Stop extensions */
349};
350static /* Use -fall-defs-global to expose */
351asn_TYPE_descriptor_t asn_DEF_type1_2 = {
352 "type1",
353 "type1",
354 SEQUENCE_free,
355 SEQUENCE_print,
356 SEQUENCE_constraint,
357 SEQUENCE_decode_ber,
358 SEQUENCE_encode_der,
359 SEQUENCE_decode_xer,
360 SEQUENCE_encode_xer,
361 0, /* Use generic outmost tag fetcher */
362 asn_DEF_type1_2_tags,
363 sizeof(asn_DEF_type1_2_tags)
364 /sizeof(asn_DEF_type1_2_tags[0]) - 1, /* 1 */
365 asn_DEF_type1_2_tags, /* Same as above */
366 sizeof(asn_DEF_type1_2_tags)
367 /sizeof(asn_DEF_type1_2_tags[0]), /* 2 */
368 asn_MBR_type1_2,
369 1, /* Elements count */
370 &asn_SPC_type1_2_specs /* Additional specs */
371};
372
373static asn_TYPE_member_t asn_MBR_type2_4[] = {
374 { ATF_NOFLAGS, 0, offsetof(struct type2, common),
375 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
376 .tag_mode = -1, /* IMPLICIT tag at current level */
377 .type = (void *)&asn_DEF_BOOLEAN,
378 .memb_constraints = memb_common_4_constraint,
379 .name = "common"
380 },
381};
382static ber_tlv_tag_t asn_DEF_type2_4_tags[] = {
383 (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
384 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
385};
386static asn_TYPE_tag2member_t asn_MAP_type2_4_tag2el[] = {
387 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 } /* common at 38 */
388};
389static asn_SEQUENCE_specifics_t asn_SPC_type2_4_specs = {
390 sizeof(struct type2),
391 offsetof(struct type2, _asn_ctx),
392 asn_MAP_type2_4_tag2el,
393 1, /* Count of tags in the map */
394 -1, /* Start extensions */
395 -1 /* Stop extensions */
396};
397static /* Use -fall-defs-global to expose */
398asn_TYPE_descriptor_t asn_DEF_type2_4 = {
399 "type2",
400 "type2",
401 SEQUENCE_free,
402 SEQUENCE_print,
403 SEQUENCE_constraint,
404 SEQUENCE_decode_ber,
405 SEQUENCE_encode_der,
406 SEQUENCE_decode_xer,
407 SEQUENCE_encode_xer,
408 0, /* Use generic outmost tag fetcher */
409 asn_DEF_type2_4_tags,
410 sizeof(asn_DEF_type2_4_tags)
411 /sizeof(asn_DEF_type2_4_tags[0]) - 1, /* 1 */
412 asn_DEF_type2_4_tags, /* Same as above */
413 sizeof(asn_DEF_type2_4_tags)
414 /sizeof(asn_DEF_type2_4_tags[0]), /* 2 */
415 asn_MBR_type2_4,
416 1, /* Elements count */
417 &asn_SPC_type2_4_specs /* Additional specs */
418};
419
420static asn_TYPE_member_t asn_MBR_AutoChoice_1[] = {
421 { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type1),
422 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
423 .tag_mode = -1, /* IMPLICIT tag at current level */
424 .type = (void *)&asn_DEF_type1_2,
425 .memb_constraints = 0, /* Defer constraints checking to the member type */
426 .name = "type1"
427 },
428 { ATF_NOFLAGS, 0, offsetof(struct AutoChoice, choice.type2),
429 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
430 .tag_mode = -1, /* IMPLICIT tag at current level */
431 .type = (void *)&asn_DEF_type2_4,
432 .memb_constraints = 0, /* Defer constraints checking to the member type */
433 .name = "type2"
434 },
435};
436static asn_TYPE_tag2member_t asn_MAP_AutoChoice_1_tag2el[] = {
437 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* type1 at 34 */
438 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 } /* type2 at 34 */
439};
440static asn_CHOICE_specifics_t asn_SPC_AutoChoice_1_specs = {
441 sizeof(struct AutoChoice),
442 offsetof(struct AutoChoice, _asn_ctx),
443 offsetof(struct AutoChoice, present),
444 sizeof(((struct AutoChoice *)0)->present),
445 asn_MAP_AutoChoice_1_tag2el,
446 2, /* Count of tags in the map */
447 0 /* Whether extensible */
448};
449asn_TYPE_descriptor_t asn_DEF_AutoChoice = {
450 "AutoChoice",
451 "AutoChoice",
452 CHOICE_free,
453 CHOICE_print,
454 CHOICE_constraint,
455 CHOICE_decode_ber,
456 CHOICE_encode_der,
457 CHOICE_decode_xer,
458 CHOICE_encode_xer,
459 CHOICE_outmost_tag,
460 0, /* No effective tags (pointer) */
461 0, /* No effective tags (count) */
462 0, /* No tags (pointer) */
463 0, /* No tags (count) */
464 asn_MBR_AutoChoice_1,
465 2, /* Elements count */
466 &asn_SPC_AutoChoice_1_specs /* Additional specs */
467};
468