blob: d387aa724d78410f346dc1257c127b85b022698f [file] [log] [blame]
Lev Walkin414b0782005-08-13 23:30:24 +00001
2/*** <<< INCLUDES [T] >>> ***/
3
4#include <INTEGER.h>
5
6/*** <<< DEPS [T] >>> ***/
7
8typedef enum T {
9 T_a = 1,
10 T_b = 2
Lev Walkin171487e2006-03-21 07:25:18 +000011} e_T;
Lev Walkin414b0782005-08-13 23:30:24 +000012
13/*** <<< TYPE-DECLS [T] >>> ***/
14
15typedef INTEGER_t T_t;
16
17/*** <<< FUNC-DECLS [T] >>> ***/
18
19extern asn_TYPE_descriptor_t asn_DEF_T;
20asn_struct_free_f T_free;
21asn_struct_print_f T_print;
22asn_constr_check_f T_constraint;
23ber_type_decoder_f T_decode_ber;
24der_type_encoder_f T_encode_der;
25xer_type_decoder_f T_decode_xer;
26xer_type_encoder_f T_encode_xer;
27
28/*** <<< CODE [T] >>> ***/
29
30int
31T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin1eded352006-07-13 11:19:01 +000032 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
Lev Walkin414b0782005-08-13 23:30:24 +000033 /* Replace with underlying type checker */
34 td->check_constraints = asn_DEF_INTEGER.check_constraints;
Lev Walkin1eded352006-07-13 11:19:01 +000035 return td->check_constraints(td, sptr, ctfailcb, app_key);
Lev Walkin414b0782005-08-13 23:30:24 +000036}
37
38/*
39 * This type is implemented using INTEGER,
40 * so here we adjust the DEF accordingly.
41 */
42static void
43T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
44 td->free_struct = asn_DEF_INTEGER.free_struct;
45 td->print_struct = asn_DEF_INTEGER.print_struct;
Lev Walkin6169b8d2013-12-07 11:02:44 -080046 td->check_constraints = asn_DEF_INTEGER.check_constraints;
Lev Walkin414b0782005-08-13 23:30:24 +000047 td->ber_decoder = asn_DEF_INTEGER.ber_decoder;
48 td->der_encoder = asn_DEF_INTEGER.der_encoder;
49 td->xer_decoder = asn_DEF_INTEGER.xer_decoder;
50 td->xer_encoder = asn_DEF_INTEGER.xer_encoder;
Lev Walkin59b176e2005-11-26 11:25:14 +000051 td->uper_decoder = asn_DEF_INTEGER.uper_decoder;
Lev Walkin9f5bb3a2006-08-18 01:46:46 +000052 td->uper_encoder = asn_DEF_INTEGER.uper_encoder;
Lev Walkinba68c912017-07-06 07:52:39 -070053 td->oer_decoder = asn_DEF_INTEGER.oer_decoder;
54 td->oer_encoder = asn_DEF_INTEGER.oer_encoder;
Lev Walkin59b176e2005-11-26 11:25:14 +000055 if(!td->per_constraints)
56 td->per_constraints = asn_DEF_INTEGER.per_constraints;
Lev Walkin414b0782005-08-13 23:30:24 +000057 td->elements = asn_DEF_INTEGER.elements;
58 td->elements_count = asn_DEF_INTEGER.elements_count;
59 td->specifics = asn_DEF_INTEGER.specifics;
60}
61
62void
63T_free(asn_TYPE_descriptor_t *td,
64 void *struct_ptr, int contents_only) {
65 T_1_inherit_TYPE_descriptor(td);
66 td->free_struct(td, struct_ptr, contents_only);
67}
68
69int
70T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
71 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
72 T_1_inherit_TYPE_descriptor(td);
73 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
74}
75
76asn_dec_rval_t
77T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
78 void **structure, const void *bufptr, size_t size, int tag_mode) {
79 T_1_inherit_TYPE_descriptor(td);
80 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
81}
82
83asn_enc_rval_t
84T_encode_der(asn_TYPE_descriptor_t *td,
85 void *structure, int tag_mode, ber_tlv_tag_t tag,
86 asn_app_consume_bytes_f *cb, void *app_key) {
87 T_1_inherit_TYPE_descriptor(td);
88 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
89}
90
91asn_dec_rval_t
92T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
93 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
94 T_1_inherit_TYPE_descriptor(td);
95 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
96}
97
98asn_enc_rval_t
99T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
100 int ilevel, enum xer_encoder_flags_e flags,
101 asn_app_consume_bytes_f *cb, void *app_key) {
102 T_1_inherit_TYPE_descriptor(td);
103 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
104}
105
106
107/*** <<< STAT-DEFS [T] >>> ***/
108
Lev Walkina7591b52014-10-12 18:37:35 -0700109static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin414b0782005-08-13 23:30:24 +0000110 (ASN_TAG_CLASS_UNIVERSAL | (2 << 2))
111};
112asn_TYPE_descriptor_t asn_DEF_T = {
113 "T",
114 "T",
115 T_free,
116 T_print,
117 T_constraint,
118 T_decode_ber,
119 T_encode_der,
120 T_decode_xer,
121 T_encode_xer,
Lev Walkin9f5bb3a2006-08-18 01:46:46 +0000122 0, 0, /* No PER support, use "-gen-PER" to enable */
Lev Walkinba68c912017-07-06 07:52:39 -0700123 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkin414b0782005-08-13 23:30:24 +0000124 0, /* Use generic outmost tag fetcher */
Lev Walkin59b176e2005-11-26 11:25:14 +0000125 asn_DEF_T_tags_1,
126 sizeof(asn_DEF_T_tags_1)
127 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
128 asn_DEF_T_tags_1, /* Same as above */
129 sizeof(asn_DEF_T_tags_1)
130 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
131 0, /* No PER visible constraints */
Lev Walkin414b0782005-08-13 23:30:24 +0000132 0, 0, /* Defined elsewhere */
133 0 /* No specifics */
134};
135