blob: 4650b51314fbd848829f3a589bb1be3493345ccd [file] [log] [blame]
Lev Walkin5bbff1e2004-06-28 21:13:22 +00001
Lev Walkinb47ddce2004-08-11 05:25:47 +00002/*** <<< INCLUDES [PrimitiveType] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +00003
4#include <OCTET_STRING.h>
5
6/*** <<< TYPE-DECLS [PrimitiveType] >>> ***/
7
8
9typedef OCTET_STRING_t PrimitiveType_t;
10
Lev Walkin5bbff1e2004-06-28 21:13:22 +000011/*** <<< FUNC-DECLS [PrimitiveType] >>> ***/
12
Lev Walkin154aa182004-09-26 13:12:56 +000013/* This type is equivalent to OCTET_STRING */
Lev Walkindfae9752004-09-29 13:19:37 +000014#define asn_DEF_PrimitiveType asn_DEF_OCTET_STRING
Lev Walkin5bbff1e2004-06-28 21:13:22 +000015
Lev Walkin2e3055d2004-08-20 13:36:32 +000016/*** <<< CODE [PrimitiveType] >>> ***/
17
Lev Walkin154aa182004-09-26 13:12:56 +000018/* This type is equivalent to OCTET_STRING */
Lev Walkin5bbff1e2004-06-28 21:13:22 +000019
Lev Walkin5bbff1e2004-06-28 21:13:22 +000020
Lev Walkinb47ddce2004-08-11 05:25:47 +000021/*** <<< INCLUDES [ConstructedType] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +000022
Lev Walkin5bbff1e2004-06-28 21:13:22 +000023#include <PrimitiveType.h>
Lev Walkin5bbff1e2004-06-28 21:13:22 +000024#include <constr_SEQUENCE.h>
25
Lev Walkinb47ddce2004-08-11 05:25:47 +000026/*** <<< DEPS [ConstructedType] >>> ***/
27
Lev Walkindfae9752004-09-29 13:19:37 +000028extern asn_TYPE_descriptor_t asn_DEF_ConstructedType;
Lev Walkin5bbff1e2004-06-28 21:13:22 +000029
30/*** <<< TYPE-DECLS [ConstructedType] >>> ***/
31
32
33typedef struct ConstructedType {
34 PrimitiveType_t field;
35
36 /* Context for parsing across buffer boundaries */
Lev Walkindfae9752004-09-29 13:19:37 +000037 asn_struct_ctx_t _asn_ctx;
Lev Walkin5bbff1e2004-06-28 21:13:22 +000038} ConstructedType_t;
39
40/*** <<< STAT-DEFS [ConstructedType] >>> ***/
41
Lev Walkindfae9752004-09-29 13:19:37 +000042static asn_TYPE_member_t asn_MBR_ConstructedType[] = {
Lev Walkincc93b0f2004-09-10 09:18:20 +000043 { ATF_NOFLAGS, 0, offsetof(struct ConstructedType, field),
Lev Walkin2e3055d2004-08-20 13:36:32 +000044 .tag = (ASN_TAG_CLASS_CONTEXT | (5 << 2)),
45 .tag_mode = -1, /* IMPLICIT tag at current level */
Lev Walkindfae9752004-09-29 13:19:37 +000046 .type = (void *)&asn_DEF_PrimitiveType,
Lev Walkin2e3055d2004-08-20 13:36:32 +000047 .memb_constraints = 0, /* Defer to actual type */
48 .name = "field"
Lev Walkin5bbff1e2004-06-28 21:13:22 +000049 },
50};
Lev Walkindfae9752004-09-29 13:19:37 +000051static ber_tlv_tag_t asn_DEF_ConstructedType_tags[] = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +000052 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
53};
Lev Walkindfae9752004-09-29 13:19:37 +000054static asn_TYPE_tag2member_t asn_DEF_ConstructedType_tag2el[] = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +000055 { (ASN_TAG_CLASS_CONTEXT | (5 << 2)), 0, 0, 0 }, /* field at 18 */
56};
Lev Walkindfae9752004-09-29 13:19:37 +000057static asn_SEQUENCE_specifics_t asn_DEF_ConstructedType_specs = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +000058 sizeof(struct ConstructedType),
Lev Walkindfae9752004-09-29 13:19:37 +000059 offsetof(struct ConstructedType, _asn_ctx),
60 asn_DEF_ConstructedType_tag2el,
Lev Walkin5bbff1e2004-06-28 21:13:22 +000061 1, /* Count of tags in the map */
62 -1, /* Start extensions */
63 -1 /* Stop extensions */
64};
Lev Walkindfae9752004-09-29 13:19:37 +000065asn_TYPE_descriptor_t asn_DEF_ConstructedType = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +000066 "ConstructedType",
Lev Walkindc06f6b2004-10-20 15:50:55 +000067 "ConstructedType",
Lev Walkina9cc46e2004-09-22 16:06:28 +000068 SEQUENCE_free,
69 SEQUENCE_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +000070 SEQUENCE_constraint,
71 SEQUENCE_decode_ber,
72 SEQUENCE_encode_der,
Lev Walkina9cc46e2004-09-22 16:06:28 +000073 0, /* Not implemented yet */
74 SEQUENCE_encode_xer,
Lev Walkin5bbff1e2004-06-28 21:13:22 +000075 0, /* Use generic outmost tag fetcher */
Lev Walkindfae9752004-09-29 13:19:37 +000076 asn_DEF_ConstructedType_tags,
77 sizeof(asn_DEF_ConstructedType_tags)
78 /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */
79 asn_DEF_ConstructedType_tags, /* Same as above */
80 sizeof(asn_DEF_ConstructedType_tags)
81 /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */
82 asn_MBR_ConstructedType,
Lev Walkin2e3055d2004-08-20 13:36:32 +000083 1, /* Elements count */
Lev Walkindfae9752004-09-29 13:19:37 +000084 &asn_DEF_ConstructedType_specs /* Additional specs */
Lev Walkin5bbff1e2004-06-28 21:13:22 +000085};
86
87
Lev Walkinb47ddce2004-08-11 05:25:47 +000088/*** <<< INCLUDES [T] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +000089
90#include <ConstructedType.h>
91
92/*** <<< TYPE-DECLS [T] >>> ***/
93
94
95typedef ConstructedType_t T_t;
96
Lev Walkin5bbff1e2004-06-28 21:13:22 +000097/*** <<< FUNC-DECLS [T] >>> ***/
98
Lev Walkindfae9752004-09-29 13:19:37 +000099extern asn_TYPE_descriptor_t asn_DEF_T;
Lev Walkina9cc46e2004-09-22 16:06:28 +0000100asn_struct_free_f T_free;
101asn_struct_print_f T_print;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000102asn_constr_check_f T_constraint;
103ber_type_decoder_f T_decode_ber;
104der_type_encoder_f T_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +0000105xer_type_encoder_f T_encode_xer;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000106
Lev Walkin2e3055d2004-08-20 13:36:32 +0000107/*** <<< CODE [T] >>> ***/
108
109int
Lev Walkindfae9752004-09-29 13:19:37 +0000110T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000111 asn_app_consume_bytes_f *app_errlog, void *app_key) {
Lev Walkin154aa182004-09-26 13:12:56 +0000112 /* Replace with underlying type checker */
Lev Walkindfae9752004-09-29 13:19:37 +0000113 td->check_constraints = asn_DEF_ConstructedType.check_constraints;
Lev Walkin154aa182004-09-26 13:12:56 +0000114 return td->check_constraints(td, sptr, app_errlog, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000115}
116
117/*
118 * This type is implemented using ConstructedType,
Lev Walkinc3808c12004-09-23 22:14:58 +0000119 * so here we adjust the DEF accordingly.
Lev Walkin2e3055d2004-08-20 13:36:32 +0000120 */
121static void
Lev Walkindfae9752004-09-29 13:19:37 +0000122T_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
123 td->free_struct = asn_DEF_ConstructedType.free_struct;
124 td->print_struct = asn_DEF_ConstructedType.print_struct;
125 td->ber_decoder = asn_DEF_ConstructedType.ber_decoder;
126 td->der_encoder = asn_DEF_ConstructedType.der_encoder;
127 td->xer_decoder = asn_DEF_ConstructedType.xer_decoder;
128 td->xer_encoder = asn_DEF_ConstructedType.xer_encoder;
129 td->elements = asn_DEF_ConstructedType.elements;
130 td->elements_count = asn_DEF_ConstructedType.elements_count;
131 td->specifics = asn_DEF_ConstructedType.specifics;
Lev Walkin2e3055d2004-08-20 13:36:32 +0000132}
133
Lev Walkina9cc46e2004-09-22 16:06:28 +0000134void
Lev Walkindfae9752004-09-29 13:19:37 +0000135T_free(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000136 void *struct_ptr, int contents_only) {
Lev Walkin2e3055d2004-08-20 13:36:32 +0000137 T_inherit_TYPE_descriptor(td);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000138 td->free_struct(td, struct_ptr, contents_only);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000139}
140
141int
Lev Walkindfae9752004-09-29 13:19:37 +0000142T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000143 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
144 T_inherit_TYPE_descriptor(td);
145 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
146}
147
Lev Walkindc06f6b2004-10-20 15:50:55 +0000148asn_dec_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000149T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000150 void **structure, void *bufptr, size_t size, int tag_mode) {
Lev Walkin2e3055d2004-08-20 13:36:32 +0000151 T_inherit_TYPE_descriptor(td);
Lev Walkindfae9752004-09-29 13:19:37 +0000152 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000153}
154
155asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000156T_encode_der(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000157 void *structure, int tag_mode, ber_tlv_tag_t tag,
158 asn_app_consume_bytes_f *cb, void *app_key) {
159 T_inherit_TYPE_descriptor(td);
160 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
161}
162
163asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000164T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000165 int ilevel, enum xer_encoder_flags_e flags,
166 asn_app_consume_bytes_f *cb, void *app_key) {
167 T_inherit_TYPE_descriptor(td);
168 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000169}
170
171
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000172/*** <<< STAT-DEFS [T] >>> ***/
173
Lev Walkindfae9752004-09-29 13:19:37 +0000174static ber_tlv_tag_t asn_DEF_T_tags[] = {
Lev Walkin188ed2c2004-09-13 08:31:01 +0000175 (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
176 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000177};
Lev Walkindfae9752004-09-29 13:19:37 +0000178asn_TYPE_descriptor_t asn_DEF_T = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000179 "T",
Lev Walkindc06f6b2004-10-20 15:50:55 +0000180 "T",
Lev Walkina9cc46e2004-09-22 16:06:28 +0000181 T_free,
182 T_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000183 T_constraint,
184 T_decode_ber,
185 T_encode_der,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000186 0, /* Not implemented yet */
187 T_encode_xer,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000188 0, /* Use generic outmost tag fetcher */
Lev Walkindfae9752004-09-29 13:19:37 +0000189 asn_DEF_T_tags,
190 sizeof(asn_DEF_T_tags)
191 /sizeof(asn_DEF_T_tags[0]) - 1, /* 1 */
192 asn_DEF_T_tags, /* Same as above */
193 sizeof(asn_DEF_T_tags)
194 /sizeof(asn_DEF_T_tags[0]), /* 2 */
Lev Walkin2e3055d2004-08-20 13:36:32 +0000195 0, 0, /* Defined elsewhere */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000196 0 /* No specifics */
197};
198