blob: 1bca959ae727d8e20ca14cb00dd0d8fc061eec5f [file] [log] [blame]
vlm0c6d3812006-03-21 03:40:38 +00001
2/*** <<< INCLUDES [Narrow] >>> ***/
3
4#include <NativeInteger.h>
5#include <constr_SEQUENCE.h>
6
7/*** <<< TYPE-DECLS [Narrow] >>> ***/
8
vlm17e65d02006-03-21 04:48:15 +00009typedef struct Narrow_15P0 {
10 long *narrow1 /* DEFAULT 3 */;
11 long narrow2;
12 long *narrow3 /* OPTIONAL */;
vlm0c6d3812006-03-21 03:40:38 +000013
14 /* Context for parsing across buffer boundaries */
15 asn_struct_ctx_t _asn_ctx;
vlm17e65d02006-03-21 04:48:15 +000016} Narrow_15P0_t;
vlm0c6d3812006-03-21 03:40:38 +000017
18/*** <<< FUNC-DECLS [Narrow] >>> ***/
19
vlm17e65d02006-03-21 04:48:15 +000020extern asn_TYPE_descriptor_t asn_DEF_Narrow_15P0;
vlm0c6d3812006-03-21 03:40:38 +000021
22/*** <<< CODE [Narrow] >>> ***/
23
24static int
vlm17e65d02006-03-21 04:48:15 +000025memb_narrow1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
vlmaf68ef52006-07-13 11:19:01 +000026 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
vlm17e65d02006-03-21 04:48:15 +000027 long value;
28
29 if(!sptr) {
vlmd4ae41c2006-07-13 13:28:32 +000030 _ASN_CTFAIL(app_key, td, sptr,
vlm17e65d02006-03-21 04:48:15 +000031 "%s: value not given (%s:%d)",
32 td->name, __FILE__, __LINE__);
33 return -1;
34 }
35
36 value = *(const long *)sptr;
37
38 if((value >= 1 && value <= 5)) {
39 /* Constraint check succeeded */
40 return 0;
41 } else {
vlmd4ae41c2006-07-13 13:28:32 +000042 _ASN_CTFAIL(app_key, td, sptr,
vlm17e65d02006-03-21 04:48:15 +000043 "%s: constraint failed (%s:%d)",
44 td->name, __FILE__, __LINE__);
45 return -1;
46 }
47}
48
49static int
50memb_narrow2_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
vlmaf68ef52006-07-13 11:19:01 +000051 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
vlm0c6d3812006-03-21 03:40:38 +000052 long value;
53
54 if(!sptr) {
vlmd4ae41c2006-07-13 13:28:32 +000055 _ASN_CTFAIL(app_key, td, sptr,
vlm0c6d3812006-03-21 03:40:38 +000056 "%s: value not given (%s:%d)",
57 td->name, __FILE__, __LINE__);
58 return -1;
59 }
60
61 value = *(const long *)sptr;
62
63 if((value >= 2 && value <= 5)) {
64 /* Constraint check succeeded */
65 return 0;
66 } else {
vlmd4ae41c2006-07-13 13:28:32 +000067 _ASN_CTFAIL(app_key, td, sptr,
vlm0c6d3812006-03-21 03:40:38 +000068 "%s: constraint failed (%s:%d)",
69 td->name, __FILE__, __LINE__);
70 return -1;
71 }
72}
73
vlm17e65d02006-03-21 04:48:15 +000074static int
75memb_narrow3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
vlmaf68ef52006-07-13 11:19:01 +000076 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
vlm17e65d02006-03-21 04:48:15 +000077 long value;
78
79 if(!sptr) {
vlmd4ae41c2006-07-13 13:28:32 +000080 _ASN_CTFAIL(app_key, td, sptr,
vlm17e65d02006-03-21 04:48:15 +000081 "%s: value not given (%s:%d)",
82 td->name, __FILE__, __LINE__);
83 return -1;
84 }
85
86 value = *(const long *)sptr;
87
88 if((value >= 3 && value <= 5)) {
89 /* Constraint check succeeded */
90 return 0;
91 } else {
vlmd4ae41c2006-07-13 13:28:32 +000092 _ASN_CTFAIL(app_key, td, sptr,
vlm17e65d02006-03-21 04:48:15 +000093 "%s: constraint failed (%s:%d)",
94 td->name, __FILE__, __LINE__);
95 return -1;
96 }
97}
98
vlm0c6d3812006-03-21 03:40:38 +000099
100/*** <<< STAT-DEFS [Narrow] >>> ***/
101
vlmb1b193e2006-08-18 01:46:46 +0000102static int asn_DFL_2_set_3(int set_value, void **sptr) {
vlm17e65d02006-03-21 04:48:15 +0000103 long *st = *sptr;
104
105 if(!st) {
vlmb1b193e2006-08-18 01:46:46 +0000106 if(!set_value) return -1; /* Not a default value */
vlm17e65d02006-03-21 04:48:15 +0000107 st = (*sptr = CALLOC(1, sizeof(*st)));
108 if(!st) return -1;
109 }
110
vlmb1b193e2006-08-18 01:46:46 +0000111 if(set_value) {
112 /* Install default value 3 */
113 *st = 3;
114 return 0;
115 } else {
116 /* Test default value 3 */
117 return (*st == 3);
118 }
vlm17e65d02006-03-21 04:48:15 +0000119}
120static asn_TYPE_member_t asn_MBR_Narrow_15P0_1[] = {
121 { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow1),
vlm0c6d3812006-03-21 03:40:38 +0000122 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
123 .tag_mode = 0,
124 .type = &asn_DEF_NativeInteger,
vlm17e65d02006-03-21 04:48:15 +0000125 .memb_constraints = memb_narrow1_constraint_1,
126 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
127 .default_value = asn_DFL_2_set_3, /* DEFAULT 3 */
128 .name = "narrow1"
129 },
130 { ATF_NOFLAGS, 0, offsetof(struct Narrow_15P0, narrow2),
131 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
132 .tag_mode = +1, /* EXPLICIT tag at current level */
133 .type = &asn_DEF_NativeInteger,
134 .memb_constraints = memb_narrow2_constraint_1,
vlm0c6d3812006-03-21 03:40:38 +0000135 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
136 .default_value = 0,
vlm17e65d02006-03-21 04:48:15 +0000137 .name = "narrow2"
138 },
139 { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow3),
140 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
141 .tag_mode = +1, /* EXPLICIT tag at current level */
142 .type = &asn_DEF_NativeInteger,
143 .memb_constraints = memb_narrow3_constraint_1,
144 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
145 .default_value = 0,
146 .name = "narrow3"
vlm0c6d3812006-03-21 03:40:38 +0000147 },
148};
vlm17e65d02006-03-21 04:48:15 +0000149static ber_tlv_tag_t asn_DEF_Narrow_15P0_tags_1[] = {
vlm0c6d3812006-03-21 03:40:38 +0000150 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
151};
vlm17e65d02006-03-21 04:48:15 +0000152static asn_TYPE_tag2member_t asn_MAP_Narrow_15P0_tag2el_1[] = {
153 { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* narrow1 at 20 */
154 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* narrow2 at 20 */
155 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 2, 0, 0 } /* narrow3 at 20 */
vlm0c6d3812006-03-21 03:40:38 +0000156};
vlm17e65d02006-03-21 04:48:15 +0000157static asn_SEQUENCE_specifics_t asn_SPC_Narrow_15P0_specs_1 = {
158 sizeof(struct Narrow_15P0),
159 offsetof(struct Narrow_15P0, _asn_ctx),
160 asn_MAP_Narrow_15P0_tag2el_1,
161 3, /* Count of tags in the map */
vlm0c6d3812006-03-21 03:40:38 +0000162 0, 0, 0, /* Optional elements (not needed) */
163 -1, /* Start extensions */
164 -1 /* Stop extensions */
165};
vlm17e65d02006-03-21 04:48:15 +0000166asn_TYPE_descriptor_t asn_DEF_Narrow_15P0 = {
vlm0c6d3812006-03-21 03:40:38 +0000167 "Narrow",
168 "Narrow",
169 SEQUENCE_free,
170 SEQUENCE_print,
171 SEQUENCE_constraint,
172 SEQUENCE_decode_ber,
173 SEQUENCE_encode_der,
174 SEQUENCE_decode_xer,
175 SEQUENCE_encode_xer,
vlmb1b193e2006-08-18 01:46:46 +0000176 0, 0, /* No PER support, use "-gen-PER" to enable */
vlm0c6d3812006-03-21 03:40:38 +0000177 0, /* Use generic outmost tag fetcher */
vlm17e65d02006-03-21 04:48:15 +0000178 asn_DEF_Narrow_15P0_tags_1,
179 sizeof(asn_DEF_Narrow_15P0_tags_1)
180 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
181 asn_DEF_Narrow_15P0_tags_1, /* Same as above */
182 sizeof(asn_DEF_Narrow_15P0_tags_1)
183 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
vlm0c6d3812006-03-21 03:40:38 +0000184 0, /* No PER visible constraints */
vlm17e65d02006-03-21 04:48:15 +0000185 asn_MBR_Narrow_15P0_1,
186 3, /* Elements count */
187 &asn_SPC_Narrow_15P0_specs_1 /* Additional specs */
vlm0c6d3812006-03-21 03:40:38 +0000188};
189
190
191/*** <<< INCLUDES [NarrowInteger] >>> ***/
192
vlmea226772006-09-13 02:51:20 +0000193#include "Narrow.h"
vlm0c6d3812006-03-21 03:40:38 +0000194
195/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/
196
vlm17e65d02006-03-21 04:48:15 +0000197typedef Narrow_15P0_t NarrowInteger_t;
vlm0c6d3812006-03-21 03:40:38 +0000198
199/*** <<< FUNC-DECLS [NarrowInteger] >>> ***/
200
201extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger;
202asn_struct_free_f NarrowInteger_free;
203asn_struct_print_f NarrowInteger_print;
204asn_constr_check_f NarrowInteger_constraint;
205ber_type_decoder_f NarrowInteger_decode_ber;
206der_type_encoder_f NarrowInteger_encode_der;
207xer_type_decoder_f NarrowInteger_decode_xer;
208xer_type_encoder_f NarrowInteger_encode_xer;
209
210/*** <<< CODE [NarrowInteger] >>> ***/
211
212int
213NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
vlmaf68ef52006-07-13 11:19:01 +0000214 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
vlm0c6d3812006-03-21 03:40:38 +0000215 /* Replace with underlying type checker */
vlm17e65d02006-03-21 04:48:15 +0000216 td->check_constraints = asn_DEF_Narrow_15P0.check_constraints;
vlmaf68ef52006-07-13 11:19:01 +0000217 return td->check_constraints(td, sptr, ctfailcb, app_key);
vlm0c6d3812006-03-21 03:40:38 +0000218}
219
220/*
vlm17e65d02006-03-21 04:48:15 +0000221 * This type is implemented using Narrow_15P0,
vlm0c6d3812006-03-21 03:40:38 +0000222 * so here we adjust the DEF accordingly.
223 */
224static void
225NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
vlm17e65d02006-03-21 04:48:15 +0000226 td->free_struct = asn_DEF_Narrow_15P0.free_struct;
227 td->print_struct = asn_DEF_Narrow_15P0.print_struct;
228 td->ber_decoder = asn_DEF_Narrow_15P0.ber_decoder;
229 td->der_encoder = asn_DEF_Narrow_15P0.der_encoder;
230 td->xer_decoder = asn_DEF_Narrow_15P0.xer_decoder;
231 td->xer_encoder = asn_DEF_Narrow_15P0.xer_encoder;
232 td->uper_decoder = asn_DEF_Narrow_15P0.uper_decoder;
vlmb1b193e2006-08-18 01:46:46 +0000233 td->uper_encoder = asn_DEF_Narrow_15P0.uper_encoder;
vlm0c6d3812006-03-21 03:40:38 +0000234 if(!td->per_constraints)
vlm17e65d02006-03-21 04:48:15 +0000235 td->per_constraints = asn_DEF_Narrow_15P0.per_constraints;
236 td->elements = asn_DEF_Narrow_15P0.elements;
237 td->elements_count = asn_DEF_Narrow_15P0.elements_count;
238 td->specifics = asn_DEF_Narrow_15P0.specifics;
vlm0c6d3812006-03-21 03:40:38 +0000239}
240
241void
242NarrowInteger_free(asn_TYPE_descriptor_t *td,
243 void *struct_ptr, int contents_only) {
244 NarrowInteger_1_inherit_TYPE_descriptor(td);
245 td->free_struct(td, struct_ptr, contents_only);
246}
247
248int
249NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
250 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
251 NarrowInteger_1_inherit_TYPE_descriptor(td);
252 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
253}
254
255asn_dec_rval_t
256NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
257 void **structure, const void *bufptr, size_t size, int tag_mode) {
258 NarrowInteger_1_inherit_TYPE_descriptor(td);
259 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
260}
261
262asn_enc_rval_t
263NarrowInteger_encode_der(asn_TYPE_descriptor_t *td,
264 void *structure, int tag_mode, ber_tlv_tag_t tag,
265 asn_app_consume_bytes_f *cb, void *app_key) {
266 NarrowInteger_1_inherit_TYPE_descriptor(td);
267 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
268}
269
270asn_dec_rval_t
271NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
272 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
273 NarrowInteger_1_inherit_TYPE_descriptor(td);
274 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
275}
276
277asn_enc_rval_t
278NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
279 int ilevel, enum xer_encoder_flags_e flags,
280 asn_app_consume_bytes_f *cb, void *app_key) {
281 NarrowInteger_1_inherit_TYPE_descriptor(td);
282 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
283}
284
285
286/*** <<< STAT-DEFS [NarrowInteger] >>> ***/
287
288static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = {
289 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
290};
291asn_TYPE_descriptor_t asn_DEF_NarrowInteger = {
292 "NarrowInteger",
293 "NarrowInteger",
294 NarrowInteger_free,
295 NarrowInteger_print,
296 NarrowInteger_constraint,
297 NarrowInteger_decode_ber,
298 NarrowInteger_encode_der,
299 NarrowInteger_decode_xer,
300 NarrowInteger_encode_xer,
vlmb1b193e2006-08-18 01:46:46 +0000301 0, 0, /* No PER support, use "-gen-PER" to enable */
vlm0c6d3812006-03-21 03:40:38 +0000302 0, /* Use generic outmost tag fetcher */
303 asn_DEF_NarrowInteger_tags_1,
304 sizeof(asn_DEF_NarrowInteger_tags_1)
305 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
306 asn_DEF_NarrowInteger_tags_1, /* Same as above */
307 sizeof(asn_DEF_NarrowInteger_tags_1)
308 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
309 0, /* No PER visible constraints */
310 0, 0, /* Defined elsewhere */
311 0 /* No specifics */
312};
313