Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 1 | #ifndef ASN1FIX_CRANGE_H |
| 2 | #define ASN1FIX_CRANGE_H |
| 3 | |
| 4 | typedef 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 */ |
Lev Walkin | b8108ec | 2004-09-29 13:17:17 +0000 | [diff] [blame] | 11 | asn1c_integer_t value; /* Value when type is ARE_VALUE */ |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 12 | } asn1cnst_edge_t; |
| 13 | |
| 14 | typedef 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. */ |
Lev Walkin | b74ac57 | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 24 | int extensible; /* Extension marker (...) is in effect. */ |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 25 | |
Lev Walkin | b74ac57 | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 26 | int incompatible; /* Constraint incompatible with argument */ |
| 27 | int not_PER_visible; /* Contains not PER-visible components */ |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 28 | } asn1cnst_range_t; |
| 29 | |
| 30 | /* |
Lev Walkin | b74ac57 | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 31 | * Compute the constraint range with variable PER visibility restrictions. |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 32 | * |
| 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 | */ |
Lev Walkin | 4b55341 | 2005-08-14 14:45:44 +0000 | [diff] [blame] | 41 | enum cpr_flags { |
| 42 | CPR_noflags = 0x00, |
| 43 | CPR_strict_PER_visibility = 0x01, |
| 44 | CPR_simulate_fbless_SIZE = 0x02, |
| 45 | }; |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 46 | asn1cnst_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, |
Lev Walkin | b74ac57 | 2004-08-25 02:05:28 +0000 | [diff] [blame] | 50 | int *expectation_met, |
Lev Walkin | 4b55341 | 2005-08-14 14:45:44 +0000 | [diff] [blame] | 51 | enum cpr_flags); |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 52 | void asn1constraint_range_free(asn1cnst_range_t *); |
| 53 | |
| 54 | /* |
| 55 | * Check that a specific constraint is compatible |
| 56 | * with the given expression type. |
| 57 | */ |
| 58 | int asn1constraint_compatible(asn1p_expr_type_e expr_type, |
Lev Walkin | 4b55341 | 2005-08-14 14:45:44 +0000 | [diff] [blame] | 59 | enum asn1p_constraint_type_e constr_type, int fbless_SIZE); |
Lev Walkin | b45e067 | 2004-08-18 05:42:05 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * Fetch a default alphabet for this type. |
| 63 | */ |
| 64 | asn1cnst_range_t *asn1constraint_default_alphabet(asn1p_expr_type_e expr_type); |
| 65 | |
| 66 | #endif /* ASN1FIX_CRANGE_H */ |