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