blob: db115163f3e39765d3a9f1445335cda90b9df182 [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,
26 asn_app_consume_bytes_f *app_errlog, void *app_key) {
27 long value;
28
29 if(!sptr) {
30 _ASN_ERRLOG(app_errlog, app_key,
31 "%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 {
42 _ASN_ERRLOG(app_errlog, app_key,
43 "%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,
vlm0c6d3812006-03-21 03:40:38 +000051 asn_app_consume_bytes_f *app_errlog, void *app_key) {
52 long value;
53
54 if(!sptr) {
55 _ASN_ERRLOG(app_errlog, app_key,
56 "%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 {
67 _ASN_ERRLOG(app_errlog, app_key,
68 "%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,
76 asn_app_consume_bytes_f *app_errlog, void *app_key) {
77 long value;
78
79 if(!sptr) {
80 _ASN_ERRLOG(app_errlog, app_key,
81 "%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 {
92 _ASN_ERRLOG(app_errlog, app_key,
93 "%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
vlm17e65d02006-03-21 04:48:15 +0000102static int asn_DFL_2_set_3(void **sptr) {
103 long *st = *sptr;
104
105 if(!st) {
106 st = (*sptr = CALLOC(1, sizeof(*st)));
107 if(!st) return -1;
108 }
109
110 /* Install default value 3 */
111 *st = 3;
112 return 0;
113}
114static asn_TYPE_member_t asn_MBR_Narrow_15P0_1[] = {
115 { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow1),
vlm0c6d3812006-03-21 03:40:38 +0000116 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
117 .tag_mode = 0,
118 .type = &asn_DEF_NativeInteger,
vlm17e65d02006-03-21 04:48:15 +0000119 .memb_constraints = memb_narrow1_constraint_1,
120 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
121 .default_value = asn_DFL_2_set_3, /* DEFAULT 3 */
122 .name = "narrow1"
123 },
124 { ATF_NOFLAGS, 0, offsetof(struct Narrow_15P0, narrow2),
125 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
126 .tag_mode = +1, /* EXPLICIT tag at current level */
127 .type = &asn_DEF_NativeInteger,
128 .memb_constraints = memb_narrow2_constraint_1,
vlm0c6d3812006-03-21 03:40:38 +0000129 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
130 .default_value = 0,
vlm17e65d02006-03-21 04:48:15 +0000131 .name = "narrow2"
132 },
133 { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow3),
134 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
135 .tag_mode = +1, /* EXPLICIT tag at current level */
136 .type = &asn_DEF_NativeInteger,
137 .memb_constraints = memb_narrow3_constraint_1,
138 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
139 .default_value = 0,
140 .name = "narrow3"
vlm0c6d3812006-03-21 03:40:38 +0000141 },
142};
vlm17e65d02006-03-21 04:48:15 +0000143static ber_tlv_tag_t asn_DEF_Narrow_15P0_tags_1[] = {
vlm0c6d3812006-03-21 03:40:38 +0000144 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
145};
vlm17e65d02006-03-21 04:48:15 +0000146static asn_TYPE_tag2member_t asn_MAP_Narrow_15P0_tag2el_1[] = {
147 { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* narrow1 at 20 */
148 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* narrow2 at 20 */
149 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 2, 0, 0 } /* narrow3 at 20 */
vlm0c6d3812006-03-21 03:40:38 +0000150};
vlm17e65d02006-03-21 04:48:15 +0000151static asn_SEQUENCE_specifics_t asn_SPC_Narrow_15P0_specs_1 = {
152 sizeof(struct Narrow_15P0),
153 offsetof(struct Narrow_15P0, _asn_ctx),
154 asn_MAP_Narrow_15P0_tag2el_1,
155 3, /* Count of tags in the map */
vlm0c6d3812006-03-21 03:40:38 +0000156 0, 0, 0, /* Optional elements (not needed) */
157 -1, /* Start extensions */
158 -1 /* Stop extensions */
159};
vlm17e65d02006-03-21 04:48:15 +0000160asn_TYPE_descriptor_t asn_DEF_Narrow_15P0 = {
vlm0c6d3812006-03-21 03:40:38 +0000161 "Narrow",
162 "Narrow",
163 SEQUENCE_free,
164 SEQUENCE_print,
165 SEQUENCE_constraint,
166 SEQUENCE_decode_ber,
167 SEQUENCE_encode_der,
168 SEQUENCE_decode_xer,
169 SEQUENCE_encode_xer,
170 0, /* No PER decoder, -gen-PER to enable */
171 0, /* Use generic outmost tag fetcher */
vlm17e65d02006-03-21 04:48:15 +0000172 asn_DEF_Narrow_15P0_tags_1,
173 sizeof(asn_DEF_Narrow_15P0_tags_1)
174 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
175 asn_DEF_Narrow_15P0_tags_1, /* Same as above */
176 sizeof(asn_DEF_Narrow_15P0_tags_1)
177 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
vlm0c6d3812006-03-21 03:40:38 +0000178 0, /* No PER visible constraints */
vlm17e65d02006-03-21 04:48:15 +0000179 asn_MBR_Narrow_15P0_1,
180 3, /* Elements count */
181 &asn_SPC_Narrow_15P0_specs_1 /* Additional specs */
vlm0c6d3812006-03-21 03:40:38 +0000182};
183
184
185/*** <<< INCLUDES [NarrowInteger] >>> ***/
186
187#include <Narrow.h>
188
189/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/
190
vlm17e65d02006-03-21 04:48:15 +0000191typedef Narrow_15P0_t NarrowInteger_t;
vlm0c6d3812006-03-21 03:40:38 +0000192
193/*** <<< FUNC-DECLS [NarrowInteger] >>> ***/
194
195extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger;
196asn_struct_free_f NarrowInteger_free;
197asn_struct_print_f NarrowInteger_print;
198asn_constr_check_f NarrowInteger_constraint;
199ber_type_decoder_f NarrowInteger_decode_ber;
200der_type_encoder_f NarrowInteger_encode_der;
201xer_type_decoder_f NarrowInteger_decode_xer;
202xer_type_encoder_f NarrowInteger_encode_xer;
203
204/*** <<< CODE [NarrowInteger] >>> ***/
205
206int
207NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
208 asn_app_consume_bytes_f *app_errlog, void *app_key) {
209 /* Replace with underlying type checker */
vlm17e65d02006-03-21 04:48:15 +0000210 td->check_constraints = asn_DEF_Narrow_15P0.check_constraints;
vlm0c6d3812006-03-21 03:40:38 +0000211 return td->check_constraints(td, sptr, app_errlog, app_key);
212}
213
214/*
vlm17e65d02006-03-21 04:48:15 +0000215 * This type is implemented using Narrow_15P0,
vlm0c6d3812006-03-21 03:40:38 +0000216 * so here we adjust the DEF accordingly.
217 */
218static void
219NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
vlm17e65d02006-03-21 04:48:15 +0000220 td->free_struct = asn_DEF_Narrow_15P0.free_struct;
221 td->print_struct = asn_DEF_Narrow_15P0.print_struct;
222 td->ber_decoder = asn_DEF_Narrow_15P0.ber_decoder;
223 td->der_encoder = asn_DEF_Narrow_15P0.der_encoder;
224 td->xer_decoder = asn_DEF_Narrow_15P0.xer_decoder;
225 td->xer_encoder = asn_DEF_Narrow_15P0.xer_encoder;
226 td->uper_decoder = asn_DEF_Narrow_15P0.uper_decoder;
vlm0c6d3812006-03-21 03:40:38 +0000227 if(!td->per_constraints)
vlm17e65d02006-03-21 04:48:15 +0000228 td->per_constraints = asn_DEF_Narrow_15P0.per_constraints;
229 td->elements = asn_DEF_Narrow_15P0.elements;
230 td->elements_count = asn_DEF_Narrow_15P0.elements_count;
231 td->specifics = asn_DEF_Narrow_15P0.specifics;
vlm0c6d3812006-03-21 03:40:38 +0000232}
233
234void
235NarrowInteger_free(asn_TYPE_descriptor_t *td,
236 void *struct_ptr, int contents_only) {
237 NarrowInteger_1_inherit_TYPE_descriptor(td);
238 td->free_struct(td, struct_ptr, contents_only);
239}
240
241int
242NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
243 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
244 NarrowInteger_1_inherit_TYPE_descriptor(td);
245 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
246}
247
248asn_dec_rval_t
249NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
250 void **structure, const void *bufptr, size_t size, int tag_mode) {
251 NarrowInteger_1_inherit_TYPE_descriptor(td);
252 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
253}
254
255asn_enc_rval_t
256NarrowInteger_encode_der(asn_TYPE_descriptor_t *td,
257 void *structure, int tag_mode, ber_tlv_tag_t tag,
258 asn_app_consume_bytes_f *cb, void *app_key) {
259 NarrowInteger_1_inherit_TYPE_descriptor(td);
260 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
261}
262
263asn_dec_rval_t
264NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
265 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
266 NarrowInteger_1_inherit_TYPE_descriptor(td);
267 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
268}
269
270asn_enc_rval_t
271NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
272 int ilevel, enum xer_encoder_flags_e flags,
273 asn_app_consume_bytes_f *cb, void *app_key) {
274 NarrowInteger_1_inherit_TYPE_descriptor(td);
275 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
276}
277
278
279/*** <<< STAT-DEFS [NarrowInteger] >>> ***/
280
281static ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = {
282 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
283};
284asn_TYPE_descriptor_t asn_DEF_NarrowInteger = {
285 "NarrowInteger",
286 "NarrowInteger",
287 NarrowInteger_free,
288 NarrowInteger_print,
289 NarrowInteger_constraint,
290 NarrowInteger_decode_ber,
291 NarrowInteger_encode_der,
292 NarrowInteger_decode_xer,
293 NarrowInteger_encode_xer,
294 0, /* No PER decoder, -gen-PER to enable */
295 0, /* Use generic outmost tag fetcher */
296 asn_DEF_NarrowInteger_tags_1,
297 sizeof(asn_DEF_NarrowInteger_tags_1)
298 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
299 asn_DEF_NarrowInteger_tags_1, /* Same as above */
300 sizeof(asn_DEF_NarrowInteger_tags_1)
301 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
302 0, /* No PER visible constraints */
303 0, 0, /* Defined elsewhere */
304 0 /* No specifics */
305};
306