blob: 89d20386880446255cf35aa0db9ff1e0c13019a0 [file] [log] [blame]
Lev Walkina00d6b32006-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
Lev Walkin0c0bca62006-03-21 04:48:15 +00009typedef struct Narrow_15P0 {
10 long *narrow1 /* DEFAULT 3 */;
11 long narrow2;
12 long *narrow3 /* OPTIONAL */;
Lev Walkina00d6b32006-03-21 03:40:38 +000013
14 /* Context for parsing across buffer boundaries */
15 asn_struct_ctx_t _asn_ctx;
Lev Walkin0c0bca62006-03-21 04:48:15 +000016} Narrow_15P0_t;
Lev Walkina00d6b32006-03-21 03:40:38 +000017
18/*** <<< FUNC-DECLS [Narrow] >>> ***/
19
Lev Walkin0c0bca62006-03-21 04:48:15 +000020extern asn_TYPE_descriptor_t asn_DEF_Narrow_15P0;
Lev Walkina00d6b32006-03-21 03:40:38 +000021
22/*** <<< CODE [Narrow] >>> ***/
23
24static int
Lev Walkin0c0bca62006-03-21 04:48:15 +000025memb_narrow1_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin1eded352006-07-13 11:19:01 +000026 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkin0c0bca62006-03-21 04:48:15 +000027 long value;
28
29 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070030 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin0c0bca62006-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 {
Lev Walkin7c1dc052016-03-14 03:08:15 -070042 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin0c0bca62006-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,
Lev Walkin1eded352006-07-13 11:19:01 +000051 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkina00d6b32006-03-21 03:40:38 +000052 long value;
53
54 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070055 ASN__CTFAIL(app_key, td, sptr,
Lev Walkina00d6b32006-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 {
Lev Walkin7c1dc052016-03-14 03:08:15 -070067 ASN__CTFAIL(app_key, td, sptr,
Lev Walkina00d6b32006-03-21 03:40:38 +000068 "%s: constraint failed (%s:%d)",
69 td->name, __FILE__, __LINE__);
70 return -1;
71 }
72}
73
Lev Walkin0c0bca62006-03-21 04:48:15 +000074static int
75memb_narrow3_constraint_1(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin1eded352006-07-13 11:19:01 +000076 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkin0c0bca62006-03-21 04:48:15 +000077 long value;
78
79 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070080 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin0c0bca62006-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 {
Lev Walkin7c1dc052016-03-14 03:08:15 -070092 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin0c0bca62006-03-21 04:48:15 +000093 "%s: constraint failed (%s:%d)",
94 td->name, __FILE__, __LINE__);
95 return -1;
96 }
97}
98
Lev Walkina00d6b32006-03-21 03:40:38 +000099
100/*** <<< STAT-DEFS [Narrow] >>> ***/
101
Lev Walkin9f5bb3a2006-08-18 01:46:46 +0000102static int asn_DFL_2_set_3(int set_value, void **sptr) {
Lev Walkin0c0bca62006-03-21 04:48:15 +0000103 long *st = *sptr;
104
105 if(!st) {
Lev Walkin9f5bb3a2006-08-18 01:46:46 +0000106 if(!set_value) return -1; /* Not a default value */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000107 st = (*sptr = CALLOC(1, sizeof(*st)));
108 if(!st) return -1;
109 }
110
Lev Walkin9f5bb3a2006-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 }
Lev Walkin0c0bca62006-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),
Lev Walkina00d6b32006-03-21 03:40:38 +0000122 .tag = (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)),
123 .tag_mode = 0,
124 .type = &asn_DEF_NativeInteger,
Lev Walkin0c0bca62006-03-21 04:48:15 +0000125 .memb_constraints = memb_narrow1_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400126 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000127 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
128 .default_value = asn_DFL_2_set_3, /* DEFAULT 3 */
129 .name = "narrow1"
130 },
131 { ATF_NOFLAGS, 0, offsetof(struct Narrow_15P0, narrow2),
132 .tag = (ASN_TAG_CLASS_CONTEXT | (0 << 2)),
133 .tag_mode = +1, /* EXPLICIT tag at current level */
134 .type = &asn_DEF_NativeInteger,
135 .memb_constraints = memb_narrow2_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400136 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkina00d6b32006-03-21 03:40:38 +0000137 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
138 .default_value = 0,
Lev Walkin0c0bca62006-03-21 04:48:15 +0000139 .name = "narrow2"
140 },
141 { ATF_POINTER, 1, offsetof(struct Narrow_15P0, narrow3),
142 .tag = (ASN_TAG_CLASS_CONTEXT | (1 << 2)),
143 .tag_mode = +1, /* EXPLICIT tag at current level */
144 .type = &asn_DEF_NativeInteger,
145 .memb_constraints = memb_narrow3_constraint_1,
Lev Walkinb33425f2017-07-14 14:59:52 +0400146 .oer_constraints = 0, /* OER is not compiled, use -gen-OER */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000147 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
148 .default_value = 0,
149 .name = "narrow3"
Lev Walkina00d6b32006-03-21 03:40:38 +0000150 },
151};
Lev Walkina7591b52014-10-12 18:37:35 -0700152static const ber_tlv_tag_t asn_DEF_Narrow_15P0_tags_1[] = {
Lev Walkina00d6b32006-03-21 03:40:38 +0000153 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
154};
Lev Walkina7591b52014-10-12 18:37:35 -0700155static const asn_TYPE_tag2member_t asn_MAP_Narrow_15P0_tag2el_1[] = {
Lev Walkin4062b012013-10-11 14:29:38 -0700156 { (ASN_TAG_CLASS_UNIVERSAL | (2 << 2)), 0, 0, 0 }, /* narrow1 */
157 { (ASN_TAG_CLASS_CONTEXT | (0 << 2)), 1, 0, 0 }, /* narrow2 */
158 { (ASN_TAG_CLASS_CONTEXT | (1 << 2)), 2, 0, 0 } /* narrow3 */
Lev Walkina00d6b32006-03-21 03:40:38 +0000159};
Lev Walkin0c0bca62006-03-21 04:48:15 +0000160static asn_SEQUENCE_specifics_t asn_SPC_Narrow_15P0_specs_1 = {
161 sizeof(struct Narrow_15P0),
162 offsetof(struct Narrow_15P0, _asn_ctx),
163 asn_MAP_Narrow_15P0_tag2el_1,
164 3, /* Count of tags in the map */
Lev Walkina00d6b32006-03-21 03:40:38 +0000165 0, 0, 0, /* Optional elements (not needed) */
166 -1, /* Start extensions */
167 -1 /* Stop extensions */
168};
Lev Walkin0c0bca62006-03-21 04:48:15 +0000169asn_TYPE_descriptor_t asn_DEF_Narrow_15P0 = {
Lev Walkina00d6b32006-03-21 03:40:38 +0000170 "Narrow",
171 "Narrow",
172 SEQUENCE_free,
173 SEQUENCE_print,
174 SEQUENCE_constraint,
175 SEQUENCE_decode_ber,
176 SEQUENCE_encode_der,
177 SEQUENCE_decode_xer,
178 SEQUENCE_encode_xer,
Lev Walkinba68c912017-07-06 07:52:39 -0700179 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkinb33425f2017-07-14 14:59:52 +0400180 0, 0, /* No PER support, use "-gen-PER" to enable */
Lev Walkina00d6b32006-03-21 03:40:38 +0000181 0, /* Use generic outmost tag fetcher */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000182 asn_DEF_Narrow_15P0_tags_1,
183 sizeof(asn_DEF_Narrow_15P0_tags_1)
184 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
185 asn_DEF_Narrow_15P0_tags_1, /* Same as above */
186 sizeof(asn_DEF_Narrow_15P0_tags_1)
187 /sizeof(asn_DEF_Narrow_15P0_tags_1[0]), /* 1 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400188 0, /* No OER visible constraints */
Lev Walkina00d6b32006-03-21 03:40:38 +0000189 0, /* No PER visible constraints */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000190 asn_MBR_Narrow_15P0_1,
191 3, /* Elements count */
192 &asn_SPC_Narrow_15P0_specs_1 /* Additional specs */
Lev Walkina00d6b32006-03-21 03:40:38 +0000193};
194
195
196/*** <<< INCLUDES [NarrowInteger] >>> ***/
197
Lev Walkin22b5ed42006-09-13 02:51:20 +0000198#include "Narrow.h"
Lev Walkina00d6b32006-03-21 03:40:38 +0000199
200/*** <<< TYPE-DECLS [NarrowInteger] >>> ***/
201
Lev Walkin0c0bca62006-03-21 04:48:15 +0000202typedef Narrow_15P0_t NarrowInteger_t;
Lev Walkina00d6b32006-03-21 03:40:38 +0000203
204/*** <<< FUNC-DECLS [NarrowInteger] >>> ***/
205
206extern asn_TYPE_descriptor_t asn_DEF_NarrowInteger;
207asn_struct_free_f NarrowInteger_free;
208asn_struct_print_f NarrowInteger_print;
209asn_constr_check_f NarrowInteger_constraint;
210ber_type_decoder_f NarrowInteger_decode_ber;
211der_type_encoder_f NarrowInteger_encode_der;
212xer_type_decoder_f NarrowInteger_decode_xer;
213xer_type_encoder_f NarrowInteger_encode_xer;
214
215/*** <<< CODE [NarrowInteger] >>> ***/
216
217int
218NarrowInteger_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin1eded352006-07-13 11:19:01 +0000219 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkina00d6b32006-03-21 03:40:38 +0000220 /* Replace with underlying type checker */
Lev Walkin0c0bca62006-03-21 04:48:15 +0000221 td->check_constraints = asn_DEF_Narrow_15P0.check_constraints;
Lev Walkin1eded352006-07-13 11:19:01 +0000222 return td->check_constraints(td, sptr, ctfailcb, app_key);
Lev Walkina00d6b32006-03-21 03:40:38 +0000223}
224
225/*
Lev Walkin0c0bca62006-03-21 04:48:15 +0000226 * This type is implemented using Narrow_15P0,
Lev Walkina00d6b32006-03-21 03:40:38 +0000227 * so here we adjust the DEF accordingly.
228 */
229static void
230NarrowInteger_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
Lev Walkin0c0bca62006-03-21 04:48:15 +0000231 td->free_struct = asn_DEF_Narrow_15P0.free_struct;
232 td->print_struct = asn_DEF_Narrow_15P0.print_struct;
Lev Walkin6169b8d2013-12-07 11:02:44 -0800233 td->check_constraints = asn_DEF_Narrow_15P0.check_constraints;
Lev Walkin0c0bca62006-03-21 04:48:15 +0000234 td->ber_decoder = asn_DEF_Narrow_15P0.ber_decoder;
235 td->der_encoder = asn_DEF_Narrow_15P0.der_encoder;
236 td->xer_decoder = asn_DEF_Narrow_15P0.xer_decoder;
237 td->xer_encoder = asn_DEF_Narrow_15P0.xer_encoder;
238 td->uper_decoder = asn_DEF_Narrow_15P0.uper_decoder;
Lev Walkin9f5bb3a2006-08-18 01:46:46 +0000239 td->uper_encoder = asn_DEF_Narrow_15P0.uper_encoder;
Lev Walkinba68c912017-07-06 07:52:39 -0700240 td->oer_decoder = asn_DEF_Narrow_15P0.oer_decoder;
241 td->oer_encoder = asn_DEF_Narrow_15P0.oer_encoder;
Lev Walkinb33425f2017-07-14 14:59:52 +0400242 if(!td->oer_constraints)
243 td->oer_constraints = asn_DEF_Narrow_15P0.oer_constraints;
Lev Walkina00d6b32006-03-21 03:40:38 +0000244 if(!td->per_constraints)
Lev Walkin0c0bca62006-03-21 04:48:15 +0000245 td->per_constraints = asn_DEF_Narrow_15P0.per_constraints;
246 td->elements = asn_DEF_Narrow_15P0.elements;
247 td->elements_count = asn_DEF_Narrow_15P0.elements_count;
248 td->specifics = asn_DEF_Narrow_15P0.specifics;
Lev Walkina00d6b32006-03-21 03:40:38 +0000249}
250
251void
252NarrowInteger_free(asn_TYPE_descriptor_t *td,
253 void *struct_ptr, int contents_only) {
254 NarrowInteger_1_inherit_TYPE_descriptor(td);
255 td->free_struct(td, struct_ptr, contents_only);
256}
257
258int
259NarrowInteger_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
260 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
261 NarrowInteger_1_inherit_TYPE_descriptor(td);
262 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
263}
264
265asn_dec_rval_t
266NarrowInteger_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
267 void **structure, const void *bufptr, size_t size, int tag_mode) {
268 NarrowInteger_1_inherit_TYPE_descriptor(td);
269 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
270}
271
272asn_enc_rval_t
273NarrowInteger_encode_der(asn_TYPE_descriptor_t *td,
274 void *structure, int tag_mode, ber_tlv_tag_t tag,
275 asn_app_consume_bytes_f *cb, void *app_key) {
276 NarrowInteger_1_inherit_TYPE_descriptor(td);
277 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
278}
279
280asn_dec_rval_t
281NarrowInteger_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
282 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
283 NarrowInteger_1_inherit_TYPE_descriptor(td);
284 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
285}
286
287asn_enc_rval_t
288NarrowInteger_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
289 int ilevel, enum xer_encoder_flags_e flags,
290 asn_app_consume_bytes_f *cb, void *app_key) {
291 NarrowInteger_1_inherit_TYPE_descriptor(td);
292 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
293}
294
295
296/*** <<< STAT-DEFS [NarrowInteger] >>> ***/
297
Lev Walkina7591b52014-10-12 18:37:35 -0700298static const ber_tlv_tag_t asn_DEF_NarrowInteger_tags_1[] = {
Lev Walkina00d6b32006-03-21 03:40:38 +0000299 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
300};
301asn_TYPE_descriptor_t asn_DEF_NarrowInteger = {
302 "NarrowInteger",
303 "NarrowInteger",
304 NarrowInteger_free,
305 NarrowInteger_print,
306 NarrowInteger_constraint,
307 NarrowInteger_decode_ber,
308 NarrowInteger_encode_der,
309 NarrowInteger_decode_xer,
310 NarrowInteger_encode_xer,
Lev Walkinba68c912017-07-06 07:52:39 -0700311 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkinb33425f2017-07-14 14:59:52 +0400312 0, 0, /* No PER support, use "-gen-PER" to enable */
Lev Walkina00d6b32006-03-21 03:40:38 +0000313 0, /* Use generic outmost tag fetcher */
314 asn_DEF_NarrowInteger_tags_1,
315 sizeof(asn_DEF_NarrowInteger_tags_1)
316 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
317 asn_DEF_NarrowInteger_tags_1, /* Same as above */
318 sizeof(asn_DEF_NarrowInteger_tags_1)
319 /sizeof(asn_DEF_NarrowInteger_tags_1[0]), /* 1 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400320 0, /* No OER visible constraints */
Lev Walkina00d6b32006-03-21 03:40:38 +0000321 0, /* No PER visible constraints */
322 0, 0, /* Defined elsewhere */
323 0 /* No specifics */
324};
325