2 * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
5 #ifndef _PER_SUPPORT_H_
6 #define _PER_SUPPORT_H_
8 #include <asn_system.h> /* Platform-specific types */
9 #include <asn_bit_data.h>
16 * Pre-computed PER constraints.
18 typedef struct asn_per_constraint_s {
19 enum asn_per_constraint_flags {
20 APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
21 APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
22 APC_CONSTRAINED = 0x2, /* Fully constrained */
23 APC_EXTENSIBLE = 0x4 /* May have extension */
25 int range_bits; /* Full number of bits in the range */
26 int effective_bits; /* Effective bits */
27 intmax_t lower_bound; /* "lb" value */
28 intmax_t upper_bound; /* "ub" value */
29 } asn_per_constraint_t;
30 typedef struct asn_per_constraints_s {
31 asn_per_constraint_t value;
32 asn_per_constraint_t size;
33 int (*value2code)(unsigned int value);
34 int (*code2value)(unsigned int code);
35 } asn_per_constraints_t;
37 /* Temporary compatibility layer. Will get removed. */
38 typedef struct asn_bit_data_s asn_per_data_t;
39 #define per_get_few_bits(data, bits) asn_get_few_bits(data, bits)
40 #define per_get_undo(data, bits) asn_get_undo(data, bits)
41 #define per_get_many_bits(data, dst, align, bits) \
42 asn_get_many_bits(data, dst, align, bits)
44 /* Temporary compatibility layer. Will get removed. */
45 typedef struct asn_bit_outp_s asn_per_outp_t;
46 #define per_put_few_bits(out, bits, obits) asn_put_few_bits(out, bits, obits)
47 #define per_put_many_bits(out, src, nbits) asn_put_many_bits(out, src, nbits)
48 #define per_put_aligned_flush(out) asn_put_aligned_flush(out)
54 #endif /* _PER_SUPPORT_H_ */