blob: 92a81cae5c4a1791ab7233f610ac6697a5b9923f [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 Walkina9cc46e2004-09-22 16:06:28 +000067 SEQUENCE_free,
68 SEQUENCE_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +000069 SEQUENCE_constraint,
70 SEQUENCE_decode_ber,
71 SEQUENCE_encode_der,
Lev Walkina9cc46e2004-09-22 16:06:28 +000072 0, /* Not implemented yet */
73 SEQUENCE_encode_xer,
Lev Walkin5bbff1e2004-06-28 21:13:22 +000074 0, /* Use generic outmost tag fetcher */
Lev Walkindfae9752004-09-29 13:19:37 +000075 asn_DEF_ConstructedType_tags,
76 sizeof(asn_DEF_ConstructedType_tags)
77 /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */
78 asn_DEF_ConstructedType_tags, /* Same as above */
79 sizeof(asn_DEF_ConstructedType_tags)
80 /sizeof(asn_DEF_ConstructedType_tags[0]), /* 1 */
81 asn_MBR_ConstructedType,
Lev Walkin2e3055d2004-08-20 13:36:32 +000082 1, /* Elements count */
Lev Walkindfae9752004-09-29 13:19:37 +000083 &asn_DEF_ConstructedType_specs /* Additional specs */
Lev Walkin5bbff1e2004-06-28 21:13:22 +000084};
85
86
Lev Walkinb47ddce2004-08-11 05:25:47 +000087/*** <<< INCLUDES [T] >>> ***/
Lev Walkin5bbff1e2004-06-28 21:13:22 +000088
89#include <ConstructedType.h>
90
91/*** <<< TYPE-DECLS [T] >>> ***/
92
93
94typedef ConstructedType_t T_t;
95
Lev Walkin5bbff1e2004-06-28 21:13:22 +000096/*** <<< FUNC-DECLS [T] >>> ***/
97
Lev Walkindfae9752004-09-29 13:19:37 +000098extern asn_TYPE_descriptor_t asn_DEF_T;
Lev Walkina9cc46e2004-09-22 16:06:28 +000099asn_struct_free_f T_free;
100asn_struct_print_f T_print;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000101asn_constr_check_f T_constraint;
102ber_type_decoder_f T_decode_ber;
103der_type_encoder_f T_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +0000104xer_type_encoder_f T_encode_xer;
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000105
Lev Walkin2e3055d2004-08-20 13:36:32 +0000106/*** <<< CODE [T] >>> ***/
107
108int
Lev Walkindfae9752004-09-29 13:19:37 +0000109T_constraint(asn_TYPE_descriptor_t *td, const void *sptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000110 asn_app_consume_bytes_f *app_errlog, void *app_key) {
Lev Walkin154aa182004-09-26 13:12:56 +0000111 /* Replace with underlying type checker */
Lev Walkindfae9752004-09-29 13:19:37 +0000112 td->check_constraints = asn_DEF_ConstructedType.check_constraints;
Lev Walkin154aa182004-09-26 13:12:56 +0000113 return td->check_constraints(td, sptr, app_errlog, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000114}
115
116/*
117 * This type is implemented using ConstructedType,
Lev Walkinc3808c12004-09-23 22:14:58 +0000118 * so here we adjust the DEF accordingly.
Lev Walkin2e3055d2004-08-20 13:36:32 +0000119 */
120static void
Lev Walkindfae9752004-09-29 13:19:37 +0000121T_inherit_TYPE_descriptor(asn_TYPE_descriptor_t *td) {
122 td->free_struct = asn_DEF_ConstructedType.free_struct;
123 td->print_struct = asn_DEF_ConstructedType.print_struct;
124 td->ber_decoder = asn_DEF_ConstructedType.ber_decoder;
125 td->der_encoder = asn_DEF_ConstructedType.der_encoder;
126 td->xer_decoder = asn_DEF_ConstructedType.xer_decoder;
127 td->xer_encoder = asn_DEF_ConstructedType.xer_encoder;
128 td->elements = asn_DEF_ConstructedType.elements;
129 td->elements_count = asn_DEF_ConstructedType.elements_count;
130 td->specifics = asn_DEF_ConstructedType.specifics;
Lev Walkin2e3055d2004-08-20 13:36:32 +0000131}
132
Lev Walkina9cc46e2004-09-22 16:06:28 +0000133void
Lev Walkindfae9752004-09-29 13:19:37 +0000134T_free(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000135 void *struct_ptr, int contents_only) {
Lev Walkin2e3055d2004-08-20 13:36:32 +0000136 T_inherit_TYPE_descriptor(td);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000137 td->free_struct(td, struct_ptr, contents_only);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000138}
139
140int
Lev Walkindfae9752004-09-29 13:19:37 +0000141T_print(asn_TYPE_descriptor_t *td, const void *struct_ptr,
Lev Walkin2e3055d2004-08-20 13:36:32 +0000142 int ilevel, asn_app_consume_bytes_f *cb, void *app_key) {
143 T_inherit_TYPE_descriptor(td);
144 return td->print_struct(td, struct_ptr, ilevel, cb, app_key);
145}
146
Lev Walkina9cc46e2004-09-22 16:06:28 +0000147ber_dec_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000148T_decode_ber(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000149 void **structure, void *bufptr, size_t size, int tag_mode) {
Lev Walkin2e3055d2004-08-20 13:36:32 +0000150 T_inherit_TYPE_descriptor(td);
Lev Walkindfae9752004-09-29 13:19:37 +0000151 return td->ber_decoder(opt_codec_ctx, td, structure, bufptr, size, tag_mode);
Lev Walkina9cc46e2004-09-22 16:06:28 +0000152}
153
154asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000155T_encode_der(asn_TYPE_descriptor_t *td,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000156 void *structure, int tag_mode, ber_tlv_tag_t tag,
157 asn_app_consume_bytes_f *cb, void *app_key) {
158 T_inherit_TYPE_descriptor(td);
159 return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);
160}
161
162asn_enc_rval_t
Lev Walkindfae9752004-09-29 13:19:37 +0000163T_encode_xer(asn_TYPE_descriptor_t *td, void *structure,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000164 int ilevel, enum xer_encoder_flags_e flags,
165 asn_app_consume_bytes_f *cb, void *app_key) {
166 T_inherit_TYPE_descriptor(td);
167 return td->xer_encoder(td, structure, ilevel, flags, cb, app_key);
Lev Walkin2e3055d2004-08-20 13:36:32 +0000168}
169
170
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000171/*** <<< STAT-DEFS [T] >>> ***/
172
Lev Walkindfae9752004-09-29 13:19:37 +0000173static ber_tlv_tag_t asn_DEF_T_tags[] = {
Lev Walkin188ed2c2004-09-13 08:31:01 +0000174 (ASN_TAG_CLASS_CONTEXT | (3 << 2)),
175 (ASN_TAG_CLASS_UNIVERSAL | (16 << 2))
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000176};
Lev Walkindfae9752004-09-29 13:19:37 +0000177asn_TYPE_descriptor_t asn_DEF_T = {
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000178 "T",
Lev Walkina9cc46e2004-09-22 16:06:28 +0000179 T_free,
180 T_print,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000181 T_constraint,
182 T_decode_ber,
183 T_encode_der,
Lev Walkina9cc46e2004-09-22 16:06:28 +0000184 0, /* Not implemented yet */
185 T_encode_xer,
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000186 0, /* Use generic outmost tag fetcher */
Lev Walkindfae9752004-09-29 13:19:37 +0000187 asn_DEF_T_tags,
188 sizeof(asn_DEF_T_tags)
189 /sizeof(asn_DEF_T_tags[0]) - 1, /* 1 */
190 asn_DEF_T_tags, /* Same as above */
191 sizeof(asn_DEF_T_tags)
192 /sizeof(asn_DEF_T_tags[0]), /* 2 */
Lev Walkin2e3055d2004-08-20 13:36:32 +0000193 0, 0, /* Defined elsewhere */
Lev Walkin5bbff1e2004-06-28 21:13:22 +0000194 0 /* No specifics */
195};
196