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