blob: 930b110e7e8fc18684316eb4b570fbd347fca5fa [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 Walkinb33425f2017-07-14 14:59:52 +040071 if(!td->oer_constraints)
72 td->oer_constraints = asn_DEF_BIT_STRING.oer_constraints;
Lev Walkin1b6d63d2006-10-27 05:38:20 +000073 if(!td->per_constraints)
74 td->per_constraints = asn_DEF_BIT_STRING.per_constraints;
75 td->elements = asn_DEF_BIT_STRING.elements;
76 td->elements_count = asn_DEF_BIT_STRING.elements_count;
77 td->specifics = asn_DEF_BIT_STRING.specifics;
78}
79
80void
81T_free(asn_TYPE_descriptor_t *td,
82 void *struct_ptr, int contents_only) {
83 T_1_inherit_TYPE_descriptor(td);
84 td->free_struct(td, struct_ptr, contents_only);
85}
86
87int
88T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
89 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
90 T_1_inherit_TYPE_descriptor(td);
91 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
92}
93
94asn_dec_rval_t
95T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
96 void **structure, const void *bufptr, size_t size, int tag_mode) {
97 T_1_inherit_TYPE_descriptor(td);
98 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
99}
100
101asn_enc_rval_t
102T_encode_der(asn_TYPE_descriptor_t *td,
103 void *structure, int tag_mode, ber_tlv_tag_t tag,
104 asn_app_consume_bytes_f *cb, void *app_key) {
105 T_1_inherit_TYPE_descriptor(td);
106 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
107}
108
109asn_dec_rval_t
110T_decode_xer(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
111 void **structure, const char *opt_mname, const void *bufptr, size_t size) {
112 T_1_inherit_TYPE_descriptor(td);
113 return td->xer_decoder(opt_codec_ctx, td, structure, opt_mname, bufptr, size);
114}
115
116asn_enc_rval_t
117T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
118 int ilevel, enum xer_encoder_flags_e flags,
119 asn_app_consume_bytes_f *cb, void *app_key) {
120 T_1_inherit_TYPE_descriptor(td);
121 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
122}
123
124
125/*** <<< STAT-DEFS [T] >>> ***/
126
Lev Walkina7591b52014-10-12 18:37:35 -0700127static const ber_tlv_tag_t asn_DEF_T_tags_1[] = {
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000128 (ASN_TAG_CLASS_UNIVERSAL | (3 << 2))
129};
130asn_TYPE_descriptor_t asn_DEF_T = {
131 "T",
132 "T",
133 T_free,
134 T_print,
135 T_constraint,
136 T_decode_ber,
137 T_encode_der,
138 T_decode_xer,
139 T_encode_xer,
Lev Walkinba68c912017-07-06 07:52:39 -0700140 0, 0, /* No OER support, use "-gen-OER" to enable */
Lev Walkinb33425f2017-07-14 14:59:52 +0400141 0, 0, /* No PER support, use "-gen-PER" to enable */
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000142 0, /* Use generic outmost tag fetcher */
143 asn_DEF_T_tags_1,
144 sizeof(asn_DEF_T_tags_1)
145 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
146 asn_DEF_T_tags_1, /* Same as above */
147 sizeof(asn_DEF_T_tags_1)
148 /sizeof(asn_DEF_T_tags_1[0]), /* 1 */
Lev Walkinb33425f2017-07-14 14:59:52 +0400149 0, /* No OER visible constraints */
Lev Walkin1b6d63d2006-10-27 05:38:20 +0000150 0, /* No PER visible constraints */
151 0, 0, /* Defined elsewhere */
152 0 /* No specifics */
153};
154