blob: 80e595b77ff7b0dc780b556fc6977a1c2e8d9fd0 [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) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070032 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +000033 "%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 */
Lev Walkin8bb57a22007-12-03 13:41:36 +000047static int
48unsplit32_5_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
49 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
50 unsigned long value;
51
52 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070053 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +000054 "%s: value not given (%s:%d)",
55 td->name, __FILE__, __LINE__);
56 return -1;
57 }
58
59 value = *(const unsigned long *)sptr;
60
61 if(((value >= 5 && value <= 500) || (value >= 600 && value <= 4294967290))) {
62 /* Constraint check succeeded */
63 return 0;
64 } else {
Lev Walkin7c1dc052016-03-14 03:08:15 -070065 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +000066 "%s: constraint failed (%s:%d)",
67 td->name, __FILE__, __LINE__);
68 return -1;
69 }
70}
71
72/*
73 * This type is implemented using NativeInteger,
74 * so here we adjust the DEF accordingly.
75 */
Lev Walkin8bb57a22007-12-03 13:41:36 +000076static int
77memb_small32range_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
78 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
79 long value;
80
81 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070082 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +000083 "%s: value not given (%s:%d)",
84 td->name, __FILE__, __LINE__);
85 return -1;
86 }
87
88 value = *(const long *)sptr;
89
90 if((value >= -2000000000 && value <= 2000000000)) {
91 /* Constraint check succeeded */
92 return 0;
93 } else {
Lev Walkin7c1dc052016-03-14 03:08:15 -070094 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +000095 "%s: constraint failed (%s:%d)",
96 td->name, __FILE__, __LINE__);
97 return -1;
98 }
99}
100
101static int
102memb_full32range_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
103 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
104 long value;
105
106 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -0700107 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000108 "%s: value not given (%s:%d)",
109 td->name, __FILE__, __LINE__);
110 return -1;
111 }
112
113 value = *(const long *)sptr;
114
115 if((value >= (-2147483647L - 1) && value <= 2147483647)) {
116 /* Constraint check succeeded */
117 return 0;
118 } else {
Lev Walkin7c1dc052016-03-14 03:08:15 -0700119 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000120 "%s: constraint failed (%s:%d)",
121 td->name, __FILE__, __LINE__);
122 return -1;
123 }
124}
125
126static int
127memb_unsigned32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
128 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000129
130 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -0700131 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000132 "%s: value not given (%s:%d)",
133 td->name, __FILE__, __LINE__);
134 return -1;
135 }
136
Lev Walkin8bb57a22007-12-03 13:41:36 +0000137
138 /* Constraint check succeeded */
139 return 0;
140}
141
142static int
143memb_unsplit32_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
144 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
145 unsigned long value;
146
147 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -0700148 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000149 "%s: value not given (%s:%d)",
150 td->name, __FILE__, __LINE__);
151 return -1;
152 }
153
154 value = *(const unsigned long *)sptr;
155
156 if(((value >= 5 && value <= 500) || (value >= 600 && value <= 4294967290))) {
157 /* Constraint check succeeded */
158 return 0;
159 } else {
Lev Walkin7c1dc052016-03-14 03:08:15 -0700160 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000161 "%s: constraint failed (%s:%d)",
162 td->name, __FILE__, __LINE__);
163 return -1;
164 }
165}
166
167
168/*** <<< CTDEFS [T] >>> ***/
169
Lev Walkin2fce55d2013-03-28 05:00:39 -0700170static asn_per_constraints_t asn_PER_type_unsigned32_constr_4 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000171 { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */,
172 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
173 0, 0 /* No PER value map */
174};
Lev Walkin2fce55d2013-03-28 05:00:39 -0700175static asn_per_constraints_t asn_PER_type_unsplit32_constr_5 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000176 { APC_CONSTRAINED, 32, -1, 5, 4294967290 } /* (5..4294967290) */,
177 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
178 0, 0 /* No PER value map */
179};
Lev Walkin2fce55d2013-03-28 05:00:39 -0700180static asn_per_constraints_t asn_PER_memb_small32range_constr_2 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000181 { APC_CONSTRAINED, 32, -1, -2000000000, 2000000000 } /* (-2000000000..2000000000) */,
182 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
183 0, 0 /* No PER value map */
184};
Lev Walkin2fce55d2013-03-28 05:00:39 -0700185static asn_per_constraints_t asn_PER_memb_full32range_constr_3 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000186 { APC_CONSTRAINED, 32, -1, (-2147483647L - 1), 2147483647 } /* (-2147483648..2147483647) */,
187 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
188 0, 0 /* No PER value map */
189};
Lev Walkin2fce55d2013-03-28 05:00:39 -0700190static asn_per_constraints_t asn_PER_memb_unsigned32_constr_4 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000191 { APC_CONSTRAINED, 32, -1, 0, 4294967295 } /* (0..4294967295) */,
192 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
193 0, 0 /* No PER value map */
194};
Lev Walkin2fce55d2013-03-28 05:00:39 -0700195static asn_per_constraints_t asn_PER_memb_unsplit32_constr_5 GCC_NOTUSED = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000196 { APC_CONSTRAINED, 32, -1, 5, 4294967290 } /* (5..4294967290) */,
197 { APC_UNCONSTRAINED, -1, -1, 0, 0 },
198 0, 0 /* No PER value map */
199};
200
201/*** <<< STAT-DEFS [T] >>> ***/
202
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800203static const asn_INTEGER_specifics_t asn_SPC_unsigned32_specs_4 = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000204 0, 0, 0, 0, 0,
205 0, /* Native long size */
206 1 /* Unsigned representation */
207};
Lev Walkina7591b52014-10-12 18:37:35 -0700208static const ber_tlv_tag_t asn_DEF_unsigned32_tags_4[] = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000209 (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
210 (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
211};
212static /* Use -fall-defs-global to expose */
213asn_TYPE_descriptor_t asn_DEF_unsigned32_4 = {
214 "unsigned32",
215 "unsigned32",
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800216 NativeInteger_free,
217 NativeInteger_print,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700218 NativeInteger_compare,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000219 unsigned32_4_constraint,
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800220 NativeInteger_decode_ber,
221 NativeInteger_encode_der,
222 NativeInteger_decode_xer,
223 NativeInteger_encode_xer,
Lev Walkinb33425f2017-07-14 14:59:52 +0400224 0, 0, /* No OER support, use "-gen-OER" to enable */
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800225 NativeInteger_decode_uper,
226 NativeInteger_encode_uper,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000227 0, /* Use generic outmost tag fetcher */
228 asn_DEF_unsigned32_tags_4,
229 sizeof(asn_DEF_unsigned32_tags_4)
230 /sizeof(asn_DEF_unsigned32_tags_4[0]) - 1, /* 1 */
231 asn_DEF_unsigned32_tags_4, /* Same as above */
232 sizeof(asn_DEF_unsigned32_tags_4)
233 /sizeof(asn_DEF_unsigned32_tags_4[0]), /* 2 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400234 0, /* No OER visible constraints */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000235 &asn_PER_type_unsigned32_constr_4,
236 0, 0, /* No members */
237 &asn_SPC_unsigned32_specs_4 /* Additional specs */
238};
239
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800240static const asn_INTEGER_specifics_t asn_SPC_unsplit32_specs_5 = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000241 0, 0, 0, 0, 0,
242 0, /* Native long size */
243 1 /* Unsigned representation */
244};
Lev Walkina7591b52014-10-12 18:37:35 -0700245static const ber_tlv_tag_t asn_DEF_unsplit32_tags_5[] = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000246 (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
247 (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
248};
249static /* Use -fall-defs-global to expose */
250asn_TYPE_descriptor_t asn_DEF_unsplit32_5 = {
251 "unsplit32",
252 "unsplit32",
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800253 NativeInteger_free,
254 NativeInteger_print,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700255 NativeInteger_compare,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000256 unsplit32_5_constraint,
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800257 NativeInteger_decode_ber,
258 NativeInteger_encode_der,
259 NativeInteger_decode_xer,
260 NativeInteger_encode_xer,
Lev Walkinb33425f2017-07-14 14:59:52 +0400261 0, 0, /* No OER support, use "-gen-OER" to enable */
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +0800262 NativeInteger_decode_uper,
263 NativeInteger_encode_uper,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000264 0, /* Use generic outmost tag fetcher */
265 asn_DEF_unsplit32_tags_5,
266 sizeof(asn_DEF_unsplit32_tags_5)
267 /sizeof(asn_DEF_unsplit32_tags_5[0]) - 1, /* 1 */
268 asn_DEF_unsplit32_tags_5, /* Same as above */
269 sizeof(asn_DEF_unsplit32_tags_5)
270 /sizeof(asn_DEF_unsplit32_tags_5[0]), /* 2 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400271 0, /* No OER visible constraints */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000272 &asn_PER_type_unsplit32_constr_5,
273 0, 0, /* No members */
274 &asn_SPC_unsplit32_specs_5 /* Additional specs */
275};
276
277static asn_TYPE_member_t asn_MBR_T_1[] = {
278 { ATF_NOFLAGS, 0, offsetof(struct T, small32range),
279 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
280 .tag_mode = -1, /* IMPLICIT tag at current level */
281 .type = &asn_DEF_NativeInteger,
Lev Walkin67a30122017-08-10 05:48:54 -0700282 .type_selector = 0,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000283 .memb_constraints = memb_small32range_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400284 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000285 .per_constraints = &asn_PER_memb_small32range_constr_2,
286 .default_value = 0,
287 .name = "small32range"
288 },
289 { ATF_NOFLAGS, 0, offsetof(struct T, full32range),
290 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
291 .tag_mode = -1, /* IMPLICIT tag at current level */
292 .type = &asn_DEF_NativeInteger,
Lev Walkin67a30122017-08-10 05:48:54 -0700293 .type_selector = 0,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000294 .memb_constraints = memb_full32range_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400295 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000296 .per_constraints = &asn_PER_memb_full32range_constr_3,
297 .default_value = 0,
298 .name = "full32range"
299 },
300 { ATF_NOFLAGS, 0, offsetof(struct T, unsigned32),
301 .tag = (ASN_TAG_CLASS_CONTEXT | (2 << 2)),
302 .tag_mode = -1, /* IMPLICIT tag at current level */
303 .type = &asn_DEF_unsigned32_4,
Lev Walkin67a30122017-08-10 05:48:54 -0700304 .type_selector = 0,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000305 .memb_constraints = memb_unsigned32_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400306 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000307 .per_constraints = &asn_PER_memb_unsigned32_constr_4,
308 .default_value = 0,
309 .name = "unsigned32"
310 },
311 { ATF_NOFLAGS, 0, offsetof(struct T, unsplit32),
312 .tag = (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
313 .tag_mode = -1, /* IMPLICIT tag at current level */
314 .type = &asn_DEF_unsplit32_5,
Lev Walkin67a30122017-08-10 05:48:54 -0700315 .type_selector = 0,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000316 .memb_constraints = memb_unsplit32_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400317 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000318 .per_constraints = &asn_PER_memb_unsplit32_constr_5,
319 .default_value = 0,
320 .name = "unsplit32"
321 },
322};
Lev Walkina7591b52014-10-12 18:37:35 -0700323static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin8bb57a22007-12-03 13:41:36 +0000324 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
325};
Lev Walkina7591b52014-10-12 18:37:35 -0700326static const asn_TYPE_tag2member_t asn_MAP_T_tag2el_1[] = {
Lev Walkin4062b012013-10-11 14:29:38 -0700327 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 0, 0, 0 }, /* small32range */
328 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 1, 0, 0 }, /* full32range */
329 { (ASN_TAG_CLASS_CONTEXT | (2 << 2)), 2, 0, 0 }, /* unsigned32 */
330 { (ASN_TAG_CLASS_CONTEXT | (3 << 2)), 3, 0, 0 } /* unsplit32 */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000331};
332static asn_SEQUENCE_specifics_t asn_SPC_T_specs_1 = {
333 sizeof(struct T),
334 offsetof(struct T, _asn_ctx),
335 asn_MAP_T_tag2el_1,
336 4, /* Count of tags in the map */
337 0, 0, 0, /* Optional elements (not needed) */
338 -1, /* Start extensions */
339 -1 /* Stop extensions */
340};
341asn_TYPE_descriptor_t asn_DEF_T = {
342 "T",
343 "T",
344 SEQUENCE_free,
345 SEQUENCE_print,
Lev Walkincd2f48e2017-08-10 02:14:59 -0700346 SEQUENCE_compare,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000347 SEQUENCE_constraint,
348 SEQUENCE_decode_ber,
349 SEQUENCE_encode_der,
350 SEQUENCE_decode_xer,
351 SEQUENCE_encode_xer,
Lev Walkinb33425f2017-07-14 14:59:52 +0400352 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000353 SEQUENCE_decode_uper,
354 SEQUENCE_encode_uper,
Lev Walkin8bb57a22007-12-03 13:41:36 +0000355 0, /* Use generic outmost tag fetcher */
356 asn_DEF_T_tags_1,
357 sizeof(asn_DEF_T_tags_1)
358 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
359 asn_DEF_T_tags_1, /* Same as above */
360 sizeof(asn_DEF_T_tags_1)
361 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400362 0, /* No OER visible constraints */
Lev Walkin8bb57a22007-12-03 13:41:36 +0000363 0, /* No PER visible constraints */
364 asn_MBR_T_1,
365 4, /* Elements count */
366 &asn_SPC_T_specs_1 /* Additional specs */
367};
368