blob: b5ae3a39f9b2a9e078e1d54ad56f3a7a6b1e6ce4 [file] [log] [blame]
vlmb5be8c32004-08-18 05:42:05 +00001#ifndef ASN1FIX_CRANGE_H
2#define ASN1FIX_CRANGE_H
3
4typedef struct asn1cnst_edge_s {
5 enum asn1cnst_range_edge {
6 ARE_MIN,
7 ARE_MAX,
8 ARE_VALUE,
9 } type;
10 int lineno; /* Line where the corresponding token was found */
vlmd5b3bf32004-09-29 13:17:17 +000011 asn1c_integer_t value; /* Value when type is ARE_VALUE */
vlmb5be8c32004-08-18 05:42:05 +000012} asn1cnst_edge_t;
13
14typedef struct asn1cnst_range_s {
15 asn1cnst_edge_t left; /* MIN from (MIN..10) */
16 asn1cnst_edge_t right; /* 10 from (MIN..10) */
17
18 /* If range is split in parts, these are the parts */
19 struct asn1cnst_range_s **elements;
20 int el_count;
21 int el_size;
22
23 int empty_constraint; /* If yes, too bad. */
vlmee8b06f2004-08-25 02:05:28 +000024 int extensible; /* Extension marker (...) is in effect. */
vlmb5be8c32004-08-18 05:42:05 +000025
vlmee8b06f2004-08-25 02:05:28 +000026 int incompatible; /* Constraint incompatible with argument */
27 int not_PER_visible; /* Contains not PER-visible components */
vlmb5be8c32004-08-18 05:42:05 +000028} asn1cnst_range_t;
29
30/*
vlmee8b06f2004-08-25 02:05:28 +000031 * Compute the constraint range with variable PER visibility restrictions.
vlmb5be8c32004-08-18 05:42:05 +000032 *
33 * (expr_type) must have the type of the top-level parent ASN.1 type.
34 * (required_type) must be one of ACT_EL_RANGE, ACT_CT_SIZE or ACT_CT_FROM.
35 * (minmax) and (expectation_met) should be 0.
36 * ERRORS:
37 * EINVAL: Mandatory arguments missing.
38 * ENOMEM: Memory allocation failure.
39 * EPERM: Invalid constraint reference.
40 */
vlm27028582005-08-14 14:45:44 +000041enum cpr_flags {
42 CPR_noflags = 0x00,
43 CPR_strict_PER_visibility = 0x01,
44 CPR_simulate_fbless_SIZE = 0x02,
45};
vlmb5be8c32004-08-18 05:42:05 +000046asn1cnst_range_t *asn1constraint_compute_PER_range(asn1p_expr_type_e expr_type,
47 const asn1p_constraint_t *ct,
48 enum asn1p_constraint_type_e required_type,
49 const asn1cnst_range_t *minmax,
vlmee8b06f2004-08-25 02:05:28 +000050 int *expectation_met,
vlm27028582005-08-14 14:45:44 +000051 enum cpr_flags);
vlmb5be8c32004-08-18 05:42:05 +000052void asn1constraint_range_free(asn1cnst_range_t *);
53
54/*
55 * Check that a specific constraint is compatible
56 * with the given expression type.
57 */
58int asn1constraint_compatible(asn1p_expr_type_e expr_type,
vlm27028582005-08-14 14:45:44 +000059 enum asn1p_constraint_type_e constr_type, int fbless_SIZE);
vlmb5be8c32004-08-18 05:42:05 +000060
61/*
62 * Fetch a default alphabet for this type.
63 */
64asn1cnst_range_t *asn1constraint_default_alphabet(asn1p_expr_type_e expr_type);
65
66#endif /* ASN1FIX_CRANGE_H */