blob: e00e740ca2e82b9aebe848cf44af37cd7640673d [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*
2 * A collection of data members of unspecified types.
3 */
4#ifndef ASN1_PARSER_EXPR_H
5#define ASN1_PARSER_EXPR_H
6
7/*
8 * Meta type of the ASN expression.
9 */
10typedef enum asn1p_expr_meta {
11 AMT_INVALID,
12 AMT_TYPE, /* Type1 ::= INTEGER */
13 AMT_TYPEREF, /* Type2 ::= Type1 */
14 AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */
15 AMT_VALUE, /* value1 Type1 ::= 1 */
16 AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */
17 AMT_OBJECT, /* FUNCTION ::= CLASS {...} */
18 AMT_OBJECTSET, /* Functions FUNCTION ::= {...} */
19 AMT_OBJECTFIELD, /* ... */
20 AMT_EXPR_META_MAX
21} asn1p_expr_meta_e;
22
23/*
24 * ASN type of the expression.
25 */
26typedef enum asn1p_expr_type {
27 /*
28 * Internal types.
29 */
30 A1TC_INVALID, /* Invalid type */
31 A1TC_REFERENCE, /* Reference to the type defined elsewhere */
32 A1TC_EXPORTVAR, /* We're exporting this definition */
33 A1TC_UNIVERVAL, /* A value of an ENUMERATED, INTEGER or BS */
34 A1TC_BOOLBITPOS, /* A bit position in a BIT STRING */
35 A1TC_BITVECTOR, /* A plain collection of bits */
36 A1TC_OPAQUE, /* Opaque data encoded as a bitvector */
37 A1TC_EXTENSIBLE, /* An extension marker "..." */
Lev Walkin070a52d2004-08-22 03:19:54 +000038 A1TC_COMPONENTS_OF, /* COMPONENTS OF clause */
Lev Walkinf15320b2004-06-03 03:38:44 +000039 A1TC_PARAMETRIZED, /* A parametrized type declaration */
40 A1TC_VALUESET, /* Value set definition */
41 A1TC_CLASSDEF, /* Information Object Class */
42 A1TC_CLASSFIELD, /* Information Object Class field */
43 A1TC_INSTANCE, /* Instance of Object Class */
44 A1TC_TYPEID, /* Type identifier */
Lev Walkin070a52d2004-08-22 03:19:54 +000045
Lev Walkinf15320b2004-06-03 03:38:44 +000046 /*
47 * ASN.1 Constructed types
48 */
49#define ASN_CONSTR_MASK 0x10 /* Every constructed type */
50 ASN_CONSTR_SEQUENCE = ASN_CONSTR_MASK, /* SEQUENCE */
51 ASN_CONSTR_CHOICE, /* CHOICE */
52 ASN_CONSTR_SET, /* SET */
53 ASN_CONSTR_SEQUENCE_OF, /* SEQUENCE OF */
54 ASN_CONSTR_SET_OF, /* SET OF */
55 ASN_CONSTR_ANY, /* ANY (deprecated) */
56 /*
57 * ASN.1 Basic types
58 */
59#define ASN_BASIC_MASK 0x20 /* Every basic type */
60 ASN_BASIC_BOOLEAN = ASN_BASIC_MASK,
61 ASN_BASIC_NULL,
62 ASN_BASIC_INTEGER,
63 ASN_BASIC_REAL,
64 ASN_BASIC_ENUMERATED,
65 ASN_BASIC_BIT_STRING,
66 ASN_BASIC_OCTET_STRING,
67 ASN_BASIC_OBJECT_IDENTIFIER,
68 ASN_BASIC_RELATIVE_OID,
69 ASN_BASIC_EXTERNAL,
70 ASN_BASIC_EMBEDDED_PDV,
71 ASN_BASIC_CHARACTER_STRING,
72 ASN_BASIC_UTCTime,
73 ASN_BASIC_GeneralizedTime,
Lev Walkin070a52d2004-08-22 03:19:54 +000074
Lev Walkinf15320b2004-06-03 03:38:44 +000075 /*
76 * ASN.1 String types
77 */
78#define ASN_STRING_MASK 0x40 /* Every string type */
79 ASN_STRING_BMPString = ASN_STRING_MASK,
80 ASN_STRING_GeneralString,
81 ASN_STRING_GraphicString,
82 ASN_STRING_IA5String,
83 ASN_STRING_ISO646String,
84 ASN_STRING_NumericString,
85 ASN_STRING_PrintableString,
86 ASN_STRING_TeletexString,
87 ASN_STRING_T61String,
88 ASN_STRING_UniversalString,
89 ASN_STRING_UTF8String,
90 ASN_STRING_VideotexString,
91 ASN_STRING_VisibleString,
92 ASN_STRING_ObjectDescriptor,
93 ASN_EXPR_TYPE_MAX
94} asn1p_expr_type_e;
95
96#include "asn1p_expr_str.h"
97#include "asn1p_expr2uclass.h"
98
Lev Walkin070a52d2004-08-22 03:19:54 +000099struct asn1p_module_s; /* Forward declaration */
100
Lev Walkinf15320b2004-06-03 03:38:44 +0000101/*
102 * A named collection of types.
103 */
104typedef struct asn1p_expr_s {
105
106 /*
107 * Human readable name.
108 */
109 char *Identifier;
110
111 /*
112 * Meta type of the expression (type, value, value set, etc).
113 */
114 asn1p_expr_meta_e meta_type;
115
116 /*
117 * ASN type of the expression.
118 */
119 asn1p_expr_type_e expr_type;
120
121 /*
122 * Referenced type, if defined elsewhere.
123 * (If expr_type == A1TC_REFERENCE)
124 */
125 asn1p_ref_t *reference;
126
127 /*
128 * Constraints for the type.
129 */
130 asn1p_constraint_t *constraints;
131
132 /*
Lev Walkinf59d0752004-08-18 04:59:12 +0000133 * This field is holding the transformed constraints, with all the
134 * parent constraints taken into account.
135 */
136 asn1p_constraint_t *combined_constraints;
137
138 /*
Lev Walkinf15320b2004-06-03 03:38:44 +0000139 * A list of parameters for parametrized type declaration
140 * (AMT_PARAMTYPE).
141 */
142 asn1p_paramlist_t *params;
143
144 /*
145 * The actual value (DefinedValue or inlined value).
146 */
147 asn1p_value_t *value;
148
149 /*
150 * The WITH SYHTAX clause.
151 */
152 asn1p_wsyntx_t *with_syntax;
153
154 /*
155 * A tag.
156 */
157 struct asn1p_type_tag_s {
158 enum {
159 TC_NOCLASS,
160 TC_UNIVERSAL,
161 TC_APPLICATION,
162 TC_CONTEXT_SPECIFIC,
163 TC_PRIVATE,
164 } tag_class;
165 enum {
166 TM_DEFAULT,
167 TM_IMPLICIT,
168 TM_EXPLICIT,
169 } tag_mode;
170 asn1_integer_t tag_value;
171 } tag;
172
173 /*
174 * Whether automatic tagging is applicable for subtypes.
175 */
176 int auto_tags_OK;
177
178 enum asn1p_expr_marker_e {
179 EM_NOMARK,
180 EM_OPTIONAL,
181 EM_DEFAULT, /* FIXME: store the value somewhere. */
182 } marker;
183 int unique; /* UNIQUE */
184
185 /*
186 * Members of the constructed type.
187 */
188 TQ_HEAD(struct asn1p_expr_s) members;
189
190 /*
191 * Next expression in the list.
192 */
193 TQ_ENTRY(struct asn1p_expr_s) next;
194
195 /*
196 * Line number where this structure is defined in the original
197 * grammar source.
198 */
199 int _lineno;
Lev Walkin070a52d2004-08-22 03:19:54 +0000200
201 struct asn1p_module_s *module; /* Defined in module */
202
Lev Walkinf15320b2004-06-03 03:38:44 +0000203 /*
204 * Marks are used for various purposes.
205 * Here are some predefined ones.
206 */
207 enum {
208 TM_NOMARK,
209 TM_RECURSION, /* Used to break recursion */
210 } _mark;
211
Lev Walkin070a52d2004-08-22 03:19:54 +0000212 int _anonymous_type; /* Used by the compiler */
213
Lev Walkinf15320b2004-06-03 03:38:44 +0000214 /*
215 * Opaque data may be attached to this structure,
216 * probably by compiler.
217 */
218 void *data;
219 void (*data_free)(void *data);
220} asn1p_expr_t;
221
222
223/*
224 * Constructor and destructor.
225 */
226asn1p_expr_t *asn1p_expr_new(int _lineno);
Lev Walkin070a52d2004-08-22 03:19:54 +0000227asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *, int skip_extensions);
Lev Walkinf15320b2004-06-03 03:38:44 +0000228void asn1p_expr_free(asn1p_expr_t *expr);
229
230#endif /* ASN1_PARSER_EXPR_H */