blob: 449707e2bc62119166616056964a3134e4274245 [file] [log] [blame]
Lev Walkin5bbff1e2004-06-28 21:13:22 +00001
Lev Walkinb47ddce2004-08-11 05:25:47 +00002/*** <<< INCLUDES [PrimitiveType] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +00003
4#include <OCTET_STRING.h>
5
6/*** <<< TYPE-DECLS [PrimitiveType] >>> ***/
7
Lev Walkin5bbff1e2004-06-28 21:13:22 +00008typedef OCTET_STRING_t PrimitiveType_t;
9
Lev Walkin5bbff1e2004-06-28 21:13:22 +000010/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
11
Lev Walkincaf0d5a2005-03-04 23:48:19 +000012extern asn_TYPE_descriptor_t asn_DEF_PrimitiveType;
13asn_struct_free_f PrimitiveType_free;
14asn_struct_print_f PrimitiveType_print;
15asn_constr_check_f PrimitiveType_constraint;
16ber_type_decoder_f PrimitiveType_decode_ber;
17der_type_encoder_f PrimitiveType_encode_der;
18xer_type_decoder_f PrimitiveType_decode_xer;
19xer_type_encoder_f PrimitiveType_encode_xer;
Lev Walkin5bbff1e2004-06-28 21:13:22 +000020
Lev Walkin2e3055d2004-08-20 13:36:32 +000021/*** <<< CODE [PrimitiveType] >>> ***/
22
Lev Walkincaf0d5a2005-03-04 23:48:19 +000023int
24PrimitiveType_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
25 asn_app_consume_bytes_f *app_errlog, void *app_key) {
26 /* Replace with underlying type checker */
27 td->check_constraints = asn_DEF_OCTET_STRING.check_constraints;
28 return td->check_constraints(td, sptr, app_errlog, app_key);
29}
30
31/*
32 * This type is implemented using OCTET_STRING,
33 * so here we adjust the DEF accordingly.
34 */
35static void
Lev Walkine8318b82005-03-06 09:29:03 +000036PrimitiveType_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
Lev Walkincaf0d5a2005-03-04 23:48:19 +000037 td->free_struct = asn_DEF_OCTET_STRING.free_struct;
38 td->print_struct = asn_DEF_OCTET_STRING.print_struct;
39 td->ber_decoder = asn_DEF_OCTET_STRING.ber_decoder;
40 td->der_encoder = asn_DEF_OCTET_STRING.der_encoder;
41 td->xer_decoder = asn_DEF_OCTET_STRING.xer_decoder;
42 td->xer_encoder = asn_DEF_OCTET_STRING.xer_encoder;
Lev Walkin59b176e2005-11-26 11:25:14 +000043 td->uper_decoder = asn_DEF_OCTET_STRING.uper_decoder;
44 if(!td->per_constraints)
45 td->per_constraints = asn_DEF_OCTET_STRING.per_constraints;
Lev Walkincaf0d5a2005-03-04 23:48:19 +000046 td->elements = asn_DEF_OCTET_STRING.elements;
47 td->elements_count = asn_DEF_OCTET_STRING.elements_count;
48 td->specifics = asn_DEF_OCTET_STRING.specifics;
49}
50
51void
52PrimitiveType_free(asn_TYPE_descriptor_t *td,
53 void *struct_ptr, int contents_only) {
Lev Walkine8318b82005-03-06 09:29:03 +000054 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000055 td->free_struct(td, struct_ptr, contents_only);
56}
57
58int
59PrimitiveType_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
60 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +000061 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000062 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
63}
64
65asn_dec_rval_t
66PrimitiveType_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkin3ebc65a2005-03-17 21:57:19 +000067 void **structure, const void *bufptr, size_t size, int tag_mode) {
Lev Walkine8318b82005-03-06 09:29:03 +000068 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000069 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
70}
71
72asn_enc_rval_t
73PrimitiveType_encode_der(asn_TYPE_descriptor_t *td,
74 void *structure, int tag_mode, ber_tlv_tag_t tag,
75 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +000076 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000077 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
78}
79
80asn_dec_rval_t
81PrimitiveType_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkin3ebc65a2005-03-17 21:57:19 +000082 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
Lev Walkine8318b82005-03-06 09:29:03 +000083 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000084 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
85}
86
87asn_enc_rval_t
88PrimitiveType_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
89 int ilevel, enum xer_encoder_flags_e flags,
90 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +000091 PrimitiveType_1_inherit_TYPE_descriptor(td);
Lev Walkincaf0d5a2005-03-04 23:48:19 +000092 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
93}
94
95
96/*** <<< STAT-DEFS [PrimitiveType] >>> ***/
97
Lev Walkin59b176e2005-11-26 11:25:14 +000098static ber_tlv_tag_t asn_DEF_PrimitiveType_tags_1[] = {
Lev Walkincaf0d5a2005-03-04 23:48:19 +000099 (ASN_TAG_CLASS_UNIVERSAL | (4 << 2))
100};
101asn_TYPE_descriptor_t asn_DEF_PrimitiveType = {
102 "PrimitiveType",
103 "PrimitiveType",
104 PrimitiveType_free,
105 PrimitiveType_print,
106 PrimitiveType_constraint,
107 PrimitiveType_decode_ber,
108 PrimitiveType_encode_der,
109 PrimitiveType_decode_xer,
110 PrimitiveType_encode_xer,
Lev Walkin59b176e2005-11-26 11:25:14 +0000111 0, /* No PER decoder, -gen-PER to enable */
Lev Walkincaf0d5a2005-03-04 23:48:19 +0000112 0, /* Use generic outmost tag fetcher */
Lev Walkin59b176e2005-11-26 11:25:14 +0000113 asn_DEF_PrimitiveType_tags_1,
114 sizeof(asn_DEF_PrimitiveType_tags_1)
115 /sizeof(asn_DEF_PrimitiveType_tags_1[0]), /* 1 */
116 asn_DEF_PrimitiveType_tags_1, /* Same as above */
117 sizeof(asn_DEF_PrimitiveType_tags_1)
118 /sizeof(asn_DEF_PrimitiveType_tags_1[0]), /* 1 */
119 0, /* No PER visible constraints */
Lev Walkincaf0d5a2005-03-04 23:48:19 +0000120 0, 0, /* No members */
121 0 /* No specifics */
122};
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000123
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000124
Lev Walkinb47ddce2004-08-11 05:25:47 +0000125/*** <<< INCLUDES [ConstructedType] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000126
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000127#include <PrimitiveType.h>
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000128#include <constr_SEQUENCE.h>
129
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000130/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
131
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000132typedef struct ConstructedType {
133 PrimitiveType_t field;
134
135 /* Context for parsing across buffer boundaries */
Lev Walkindfae9752004-09-29 13:19:37 +0000136 asn_struct_ctx_t _asn_ctx;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000137} ConstructedType_t;
138
Lev Walkinc8285712005-03-04 22:18:20 +0000139/*** <<< FUNC-DECLS [ConstructedType] >>> ***/
140
141extern asn_TYPE_descriptor_t asn_DEF_ConstructedType;
142
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000143/*** <<< STAT-DEFS [ConstructedType] >>> ***/
144
Lev Walkine0272aa2005-03-04 11:26:08 +0000145static asn_TYPE_member_t asn_MBR_ConstructedType_1[] = {
Lev Walkincc93b0f2004-09-10 09:18:20 +0000146 { ATF_NOFLAGS, 0, offsetof(struct ConstructedType, field),
Lev Walkin2e3055d2004-08-20 13:36:32 +0000147 .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
148 .tag_mode = -1, /* IMPLICIT tag at current level */
Lev Walkinae7bf3f2005-08-29 10:31:14 +0000149 .type = &asn_DEF_PrimitiveType,
Lev Walkinba58e1b2005-01-17 12:20:19 +0000150 .memb_constraints = 0, /* Defer constraints checking to the member type */
Lev Walkin59b176e2005-11-26 11:25:14 +0000151 .per_constraints = 0, /* PER is not compiled, use -gen-PER */
152 .default_value = 0,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000153 .name = "field"
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000154 },
155};
Lev Walkin59b176e2005-11-26 11:25:14 +0000156static ber_tlv_tag_t asn_DEF_ConstructedType_tags_1[] = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000157 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
158};
Lev Walkin59b176e2005-11-26 11:25:14 +0000159static asn_TYPE_tag2member_t asn_MAP_ConstructedType_tag2el_1[] = {
Lev Walkin55236182005-02-25 08:24:19 +0000160 { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 } /* field at 18 */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000161};
Lev Walkin59b176e2005-11-26 11:25:14 +0000162static asn_SEQUENCE_specifics_t asn_SPC_ConstructedType_specs_1 = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000163 sizeof(struct ConstructedType),
Lev Walkindfae9752004-09-29 13:19:37 +0000164 offsetof(struct ConstructedType, _asn_ctx),
Lev Walkin59b176e2005-11-26 11:25:14 +0000165 asn_MAP_ConstructedType_tag2el_1,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000166 1, /* Count of tags in the map */
Lev Walkin59b176e2005-11-26 11:25:14 +0000167 0, 0, 0, /* Optional elements (not needed) */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000168 -1, /* Start extensions */
169 -1 /* Stop extensions */
170};
Lev Walkindfae9752004-09-29 13:19:37 +0000171asn_TYPE_descriptor_t asn_DEF_ConstructedType = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000172 "ConstructedType",
Lev Walkindc06f6b2004-10-20 15:50:55 +0000173 "ConstructedType",
Lev Walkina9cc46e2004-09-22 16:06:28 +0000174 SEQUENCE_free,
175 SEQUENCE_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000176 SEQUENCE_constraint,
177 SEQUENCE_decode_ber,
178 SEQUENCE_encode_der,
Lev Walkin61b40d82004-10-23 15:07:45 +0000179 SEQUENCE_decode_xer,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000180 SEQUENCE_encode_xer,
Lev Walkin59b176e2005-11-26 11:25:14 +0000181 0, /* No PER decoder, -gen-PER to enable */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000182 0, /* Use generic outmost tag fetcher */
Lev Walkin59b176e2005-11-26 11:25:14 +0000183 asn_DEF_ConstructedType_tags_1,
184 sizeof(asn_DEF_ConstructedType_tags_1)
185 /sizeof(asn_DEF_ConstructedType_tags_1[0]), /* 1 */
186 asn_DEF_ConstructedType_tags_1, /* Same as above */
187 sizeof(asn_DEF_ConstructedType_tags_1)
188 /sizeof(asn_DEF_ConstructedType_tags_1[0]), /* 1 */
189 0, /* No PER visible constraints */
Lev Walkine0272aa2005-03-04 11:26:08 +0000190 asn_MBR_ConstructedType_1,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000191 1, /* Elements count */
Lev Walkin59b176e2005-11-26 11:25:14 +0000192 &asn_SPC_ConstructedType_specs_1 /* Additional specs */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000193};
194
195
Lev Walkinb47ddce2004-08-11 05:25:47 +0000196/*** <<< INCLUDES [T] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000197
198#include <ConstructedType.h>
199
200/*** <<< TYPE-DECLS [T] >>> ***/
201
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000202typedef ConstructedType_t T_t;
203
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000204/*** <<< FUNC-DECLS [T] >>> ***/
205
Lev Walkindfae9752004-09-29 13:19:37 +0000206extern asn_TYPE_descriptor_t asn_DEF_T;
Lev Walkina9cc46e2004-09-22 16:06:28 +0000207asn_struct_free_f T_free;
208asn_struct_print_f T_print;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000209asn_constr_check_f T_constraint;
210ber_type_decoder_f T_decode_ber;
211der_type_encoder_f T_encode_der;
Lev Walkin0ebe8b32004-10-23 13:26:56 +0000212xer_type_decoder_f T_decode_xer;
Lev Walkina9cc46e2004-09-22 16:06:28 +0000213xer_type_encoder_f T_encode_xer;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000214
Lev Walkin2e3055d2004-08-20 13:36:32 +0000215/*** <<< CODE [T] >>> ***/
216
217int
Lev Walkindfae9752004-09-29 13:19:37 +0000218T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000219 asn_app_consume_bytes_f *app_errlog, void *app_key) {
Lev Walkin154aa182004-09-26 13:12:56 +0000220 /* Replace with underlying type checker */
Lev Walkindfae9752004-09-29 13:19:37 +0000221 td->check_constraints = asn_DEF_ConstructedType.check_constraints;
Lev Walkin154aa182004-09-26 13:12:56 +0000222 return td->check_constraints(td, sptr, app_errlog, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000223}
224
225/*
226 * This type is implemented using ConstructedType,
Lev Walkinc3808c12004-09-23 22:14:58 +0000227 * so here we adjust the DEF accordingly.
Lev Walkin2e3055d2004-08-20 13:36:32 +0000228 */
229static void
Lev Walkine8318b82005-03-06 09:29:03 +0000230T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
Lev Walkindfae9752004-09-29 13:19:37 +0000231 td->free_struct = asn_DEF_ConstructedType.free_struct;
232 td->print_struct = asn_DEF_ConstructedType.print_struct;
233 td->ber_decoder = asn_DEF_ConstructedType.ber_decoder;
234 td->der_encoder = asn_DEF_ConstructedType.der_encoder;
235 td->xer_decoder = asn_DEF_ConstructedType.xer_decoder;
236 td->xer_encoder = asn_DEF_ConstructedType.xer_encoder;
Lev Walkin59b176e2005-11-26 11:25:14 +0000237 td->uper_decoder = asn_DEF_ConstructedType.uper_decoder;
238 if(!td->per_constraints)
239 td->per_constraints = asn_DEF_ConstructedType.per_constraints;
Lev Walkindfae9752004-09-29 13:19:37 +0000240 td->elements = asn_DEF_ConstructedType.elements;
241 td->elements_count = asn_DEF_ConstructedType.elements_count;
242 td->specifics = asn_DEF_ConstructedType.specifics;
Lev Walkin2e3055d2004-08-20 13:36:32 +0000243}
244
Lev Walkina9cc46e2004-09-22 16:06:28 +0000245void
Lev Walkindfae9752004-09-29 13:19:37 +0000246T_free(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000247 void *struct_ptr, int contents_only) {
Lev Walkine8318b82005-03-06 09:29:03 +0000248 T_1_inherit_TYPE_descriptor(td);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000249 td->free_struct(td, struct_ptr, contents_only);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000250}
251
252int
Lev Walkindfae9752004-09-29 13:19:37 +0000253T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000254 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +0000255 T_1_inherit_TYPE_descriptor(td);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000256 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
257}
258
Lev Walkindc06f6b2004-10-20 15:50:55 +0000259asn_dec_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000260T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkin3ebc65a2005-03-17 21:57:19 +0000261 void **structure, const void *bufptr, size_t size, int tag_mode) {
Lev Walkine8318b82005-03-06 09:29:03 +0000262 T_1_inherit_TYPE_descriptor(td);
Lev Walkindfae9752004-09-29 13:19:37 +0000263 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000264}
265
266asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000267T_encode_der(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000268 void *structure, int tag_mode, ber_tlv_tag_t tag,
269 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +0000270 T_1_inherit_TYPE_descriptor(td);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000271 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
272}
273
Lev Walkin0ebe8b32004-10-23 13:26:56 +0000274asn_dec_rval_t
275T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkin3ebc65a2005-03-17 21:57:19 +0000276 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
Lev Walkine8318b82005-03-06 09:29:03 +0000277 T_1_inherit_TYPE_descriptor(td);
Lev Walkin0ebe8b32004-10-23 13:26:56 +0000278 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
279}
280
Lev Walkina9cc46e2004-09-22 16:06:28 +0000281asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000282T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000283 int ilevel, enum xer_encoder_flags_e flags,
284 asn_app_consume_bytes_f *cb, void *app_key) {
Lev Walkine8318b82005-03-06 09:29:03 +0000285 T_1_inherit_TYPE_descriptor(td);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000286 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000287}
288
289
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000290/*** <<< STAT-DEFS [T] >>> ***/
291
Lev Walkin59b176e2005-11-26 11:25:14 +0000292static ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin188ed2c2004-09-13 08:31:01 +0000293 (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
294 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000295};
Lev Walkindfae9752004-09-29 13:19:37 +0000296asn_TYPE_descriptor_t asn_DEF_T = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000297 "T",
Lev Walkindc06f6b2004-10-20 15:50:55 +0000298 "T",
Lev Walkina9cc46e2004-09-22 16:06:28 +0000299 T_free,
300 T_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000301 T_constraint,
302 T_decode_ber,
303 T_encode_der,
Lev Walkin0ebe8b32004-10-23 13:26:56 +0000304 T_decode_xer,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000305 T_encode_xer,
Lev Walkin59b176e2005-11-26 11:25:14 +0000306 0, /* No PER decoder, -gen-PER to enable */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000307 0, /* Use generic outmost tag fetcher */
Lev Walkin59b176e2005-11-26 11:25:14 +0000308 asn_DEF_T_tags_1,
309 sizeof(asn_DEF_T_tags_1)
310 /sizeof(asn_DEF_T_tags_1[0]) - 1, /* 1 */
311 asn_DEF_T_tags_1, /* Same as above */
312 sizeof(asn_DEF_T_tags_1)
313 /sizeof(asn_DEF_T_tags_1[0]), /* 2 */
314 0, /* No PER visible constraints */
Lev Walkin2e3055d2004-08-20 13:36:32 +0000315 0, 0, /* Defined elsewhere */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000316 0 /* No specifics */
317};
318