blob: 6b5c7621e76fb5d85cb630744dc8aa94264fb376 [file] [log] [blame]
Lev Walkin1b6d63d2006-10-27 05:38:20 +00001
2/*** <<< INCLUDES [T] >>> ***/
3
4#include <BIT_STRING.h>
5
6/*** <<< DEPS [T] >>> ***/
7
8typedef enum T {
9 T_flag1 = 0,
10 T_flag2 = 1,
11 T_flag3 = 2
12} e_T;
13
14/*** <<< TYPE-DECLS [T] >>> ***/
15
16typedef BIT_STRING_t T_t;
17
18/*** <<< FUNC-DECLS [T] >>> ***/
19
20extern asn_TYPE_descriptor_t asn_DEF_T;
21asn_struct_free_f T_free;
22asn_struct_print_f T_print;
23asn_constr_check_f T_constraint;
24ber_type_decoder_f T_decode_ber;
25der_type_encoder_f T_encode_der;
26xer_type_decoder_f T_decode_xer;
27xer_type_encoder_f T_encode_xer;
28
29/*** <<< CODE [T] >>> ***/
30
31int
32T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
33 asn_app_constraint_failed_f *ctfailcb, void *app_key) {
34 const BIT_STRING_t *st = (const BIT_STRING_t *)sptr;
35
36 if(!sptr) {
Lev Walkin7c1dc052016-03-14 03:08:15 -070037 ASN__CTFAIL(app_key, td, sptr,
Lev Walkin1b6d63d2006-10-27 05:38:20 +000038 "%s: value not given (%s:%d)",
39 td->name, __FILE__, __LINE__);
40 return -1;
41 }
42
43
44 if(1 /* No applicable constraints whatsoever */) {
45 /* Nothing is here. See below */
46 }
47
48 /* Replace with underlying type checker */
49 td->check_constraints = asn_DEF_BIT_STRING.check_constraints;
50 return td->check_constraints(td, sptr, ctfailcb, app_key);
51}
52
53/*
54 * This type is implemented using BIT_STRING,
55 * so here we adjust the DEF accordingly.
56 */
57static void
58T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
59 td->free_struct = asn_DEF_BIT_STRING.free_struct;
60 td->print_struct = asn_DEF_BIT_STRING.print_struct;
Lev Walkin6169b8d2013-12-07 11:02:44 -080061 td->check_constraints = asn_DEF_BIT_STRING.check_constraints;
Lev Walkin1b6d63d2006-10-27 05:38:20 +000062 td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder;
63 td->der_encoder = asn_DEF_BIT_STRING.der_encoder;
64 td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder;
65 td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder;
66 td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
67 td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
68 if(!td->per_constraints)
69 td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
70 td->elements = asn_DEF_BIT_STRING.elements;
71 td->elements_count = asn_DEF_BIT_STRING.elements_count;
72 td->specifics = asn_DEF_BIT_STRING.specifics;
73}
74
75void
76T_free(asn_TYPE_descriptor_t *td,
77 void *struct_ptr, int contents_only) {
78 T_1_inherit_TYPE_descriptor(td);
79 td->free_struct(td, struct_ptr, contents_only);
80}
81
82int
83T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
84 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
85 T_1_inherit_TYPE_descriptor(td);
86 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
87}
88
89asn_dec_rval_t
90T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
91 void **structure, const void *bufptr, size_t size, int tag_mode) {
92 T_1_inherit_TYPE_descriptor(td);
93 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
94}
95
96asn_enc_rval_t
97T_encode_der(asn_TYPE_descriptor_t *td,
98 void *structure, int tag_mode, ber_tlv_tag_t tag,
99 asn_app_consume_bytes_f *cb, void *app_key) {
100 T_1_inherit_TYPE_descriptor(td);
101 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
102}
103
104asn_dec_rval_t
105T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
106 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
107 T_1_inherit_TYPE_descriptor(td);
108 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
109}
110
111asn_enc_rval_t
112T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
113 int ilevel, enum xer_encoder_flags_e flags,
114 asn_app_consume_bytes_f *cb, void *app_key) {
115 T_1_inherit_TYPE_descriptor(td);
116 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
117}
118
119
120/*** <<< STAT-DEFS [T] >>> ***/
121
Lev Walkina7591b52014-10-12 18:37:35 -0700122static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000123 (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
124};
125asn_TYPE_descriptor_t asn_DEF_T = {
126 "T",
127 "T",
128 T_free,
129 T_print,
130 T_constraint,
131 T_decode_ber,
132 T_encode_der,
133 T_decode_xer,
134 T_encode_xer,
135 0, 0, /* No PER support, use "-gen-PER" to enable */
136 0, /* Use generic outmost tag fetcher */
137 asn_DEF_T_tags_1,
138 sizeof(asn_DEF_T_tags_1)
139 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
140 asn_DEF_T_tags_1, /* Same as above */
141 sizeof(asn_DEF_T_tags_1)
142 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
143 0, /* No PER visible constraints */
144 0, 0, /* Defined elsewhere */
145 0 /* No specifics */
146};
147