blob: 8e105aeb039aaffb3d84f9aac51013a691797510 [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 */) {
johvikbd3dea92017-05-09 10:20:51 +020045 (void)st; /* Unused variable */
Lev Walkin1b6d63d2006-10-27 05:38:20 +000046 /* Nothing is here. See below */
47 }
48
49 /* Replace with underlying type checker */
50 td->check_constraints = asn_DEF_BIT_STRING.check_constraints;
51 return td->check_constraints(td, sptr, ctfailcb, app_key);
52}
53
54/*
55 * This type is implemented using BIT_STRING,
56 * so here we adjust the DEF accordingly.
57 */
58static void
59T_1_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
60 td->free_struct = asn_DEF_BIT_STRING.free_struct;
61 td->print_struct = asn_DEF_BIT_STRING.print_struct;
Lev Walkin6169b8d2013-12-07 11:02:44 -080062 td->check_constraints = asn_DEF_BIT_STRING.check_constraints;
Lev Walkin1b6d63d2006-10-27 05:38:20 +000063 td->ber_decoder = asn_DEF_BIT_STRING.ber_decoder;
64 td->der_encoder = asn_DEF_BIT_STRING.der_encoder;
65 td->xer_decoder = asn_DEF_BIT_STRING.xer_decoder;
66 td->xer_encoder = asn_DEF_BIT_STRING.xer_encoder;
67 td->uper_decoder = asn_DEF_BIT_STRING.uper_decoder;
68 td->uper_encoder = asn_DEF_BIT_STRING.uper_encoder;
Lev Walkinba68c912017-07-06 07:52:39 -070069 td->oer_decoder = asn_DEF_BIT_STRING.oer_decoder;
70 td->oer_encoder = asn_DEF_BIT_STRING.oer_encoder;
Lev Walkin1b6d63d2006-10-27 05:38:20 +000071 if(!td->per_constraints)
72 td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
73 td->elements = asn_DEF_BIT_STRING.elements;
74 td->elements_count = asn_DEF_BIT_STRING.elements_count;
75 td->specifics = asn_DEF_BIT_STRING.specifics;
76}
77
78void
79T_free(asn_TYPE_descriptor_t *td,
80 void *struct_ptr, int contents_only) {
81 T_1_inherit_TYPE_descriptor(td);
82 td->free_struct(td, struct_ptr, contents_only);
83}
84
85int
86T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
87 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
88 T_1_inherit_TYPE_descriptor(td);
89 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
90}
91
92asn_dec_rval_t
93T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
94 void **structure, const void *bufptr, size_t size, int tag_mode) {
95 T_1_inherit_TYPE_descriptor(td);
96 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
97}
98
99asn_enc_rval_t
100T_encode_der(asn_TYPE_descriptor_t *td,
101 void *structure, int tag_mode, ber_tlv_tag_t tag,
102 asn_app_consume_bytes_f *cb, void *app_key) {
103 T_1_inherit_TYPE_descriptor(td);
104 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
105}
106
107asn_dec_rval_t
108T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
109 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
110 T_1_inherit_TYPE_descriptor(td);
111 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
112}
113
114asn_enc_rval_t
115T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
116 int ilevel, enum xer_encoder_flags_e flags,
117 asn_app_consume_bytes_f *cb, void *app_key) {
118 T_1_inherit_TYPE_descriptor(td);
119 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
120}
121
122
123/*** <<< STAT-DEFS [T] >>> ***/
124
Lev Walkina7591b52014-10-12 18:37:35 -0700125static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000126 (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
127};
128asn_TYPE_descriptor_t asn_DEF_T = {
129 "T",
130 "T",
131 T_free,
132 T_print,
133 T_constraint,
134 T_decode_ber,
135 T_encode_der,
136 T_decode_xer,
137 T_encode_xer,
138 0, 0, /* No PER support, use "-gen-PER" to enable */
Lev Walkinba68c912017-07-06 07:52:39 -0700139 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000140 0, /* Use generic outmost tag fetcher */
141 asn_DEF_T_tags_1,
142 sizeof(asn_DEF_T_tags_1)
143 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
144 asn_DEF_T_tags_1, /* Same as above */
145 sizeof(asn_DEF_T_tags_1)
146 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
147 0, /* No PER visible constraints */
148 0, 0, /* Defined elsewhere */
149 0 /* No specifics */
150};
151