aboutsummaryrefslogtreecommitdiffstats
path: root/include/asn1c/per_support.h
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2015-08-31 08:56:53 +0200
committerHarald Welte <laforge@gnumonks.org>2015-08-31 09:35:13 +0200
commit41b85d5597119fa8105dc0641ffe5cd1bbae39b2 (patch)
tree1a425d76fafe089cca547eb9c79c6a9a631c34e2 /include/asn1c/per_support.h
parentf6b9173b02bfac093177cf6fd0f48ad56c5786c7 (diff)
update to asn1c aper branch commit 6e00cbce7304a6972e82a12bb5fa82e41fa541be
which is closes to Lev Walkins master 62913d8b8e1eb96d74315ff748475ca818b69752
Diffstat (limited to 'include/asn1c/per_support.h')
-rw-r--r--include/asn1c/per_support.h44
1 files changed, 34 insertions, 10 deletions
diff --git a/include/asn1c/per_support.h b/include/asn1c/per_support.h
index 7cb1a0c..181fe24 100644
--- a/include/asn1c/per_support.h
+++ b/include/asn1c/per_support.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2006, 2007 Lev Walkin <vlm@lionet.info>.
+ * Copyright (c) 2005-2014 Lev Walkin <vlm@lionet.info>.
* All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
@@ -15,7 +15,7 @@ extern "C" {
/*
* Pre-computed PER constraints.
*/
-typedef struct asn_per_constraint_s {
+typedef const struct asn_per_constraint_s {
enum asn_per_constraint_flags {
APC_UNCONSTRAINED = 0x0, /* No PER visible constraints */
APC_SEMI_CONSTRAINED = 0x1, /* Constrained at "lb" */
@@ -24,12 +24,12 @@ typedef struct asn_per_constraint_s {
} flags;
int range_bits; /* Full number of bits in the range */
int effective_bits; /* Effective bits */
- long lower_bound; /* "lb" value */
- long upper_bound; /* "ub" value */
+ int64_t lower_bound; /* "lb" value */
+ int64_t upper_bound; /* "ub" value */
} asn_per_constraint_t;
-typedef struct asn_per_constraints_s {
- asn_per_constraint_t value;
- asn_per_constraint_t size;
+typedef const struct asn_per_constraints_s {
+ struct asn_per_constraint_s value;
+ struct asn_per_constraint_s size;
int (*value2code)(unsigned int value);
int (*code2value)(unsigned int code);
} asn_per_constraints_t;
@@ -39,9 +39,9 @@ typedef struct asn_per_constraints_s {
*/
typedef struct asn_per_data_s {
const uint8_t *buffer; /* Pointer to the octet stream */
- size_t nboff; /* Bit offset to the meaningful bit */
- size_t nbits; /* Number of bits in the stream */
- size_t moved; /* Number of bits moved through this bit stream */
+ size_t nboff; /* Bit offset to the meaningful bit */
+ size_t nbits; /* Number of bits in the stream */
+ size_t moved; /* Number of bits moved through this bit stream */
int (*refill)(struct asn_per_data_s *);
void *refill_key;
} asn_per_data_t;
@@ -71,15 +71,25 @@ ssize_t uper_get_length(asn_per_data_t *pd,
int effective_bound_bits,
int *repeat);
+ssize_t aper_get_length(asn_per_data_t *pd,
+ int range,
+ int effective_bound_bits,
+ int *repeat);
+
/*
* Get the normally small length "n".
*/
ssize_t uper_get_nslength(asn_per_data_t *pd);
+ssize_t aper_get_nslength(asn_per_data_t *pd);
/*
* Get the normally small non-negative whole number.
*/
ssize_t uper_get_nsnnwn(asn_per_data_t *pd);
+ssize_t aper_get_nsnnwn(asn_per_data_t *pd, int range);
+
+/* X.691-2008/11, #11.5.6 */
+int uper_get_constrained_whole_number(asn_per_data_t *pd, unsigned long *v, int nbits);
/* Non-thread-safe debugging function, don't use it */
char *per_data_string(asn_per_data_t *pd);
@@ -103,6 +113,14 @@ int per_put_few_bits(asn_per_outp_t *per_data, uint32_t bits, int obits);
/* Output a large number of bits */
int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits);
+/* X.691-2008/11, #11.5 */
+int uper_put_constrained_whole_number_s(asn_per_outp_t *po, long v, int nbits);
+int uper_put_constrained_whole_number_u(asn_per_outp_t *po, unsigned long v, int nbits);
+
+/* Align the current bit position to octet bundary */
+int aper_put_align(asn_per_outp_t *po);
+int32_t aper_get_align(asn_per_data_t *pd);
+
/*
* Put the length "n" to the Unaligned PER stream.
* This function returns the number of units which may be flushed
@@ -110,17 +128,23 @@ int per_put_many_bits(asn_per_outp_t *po, const uint8_t *src, int put_nbits);
*/
ssize_t uper_put_length(asn_per_outp_t *po, size_t whole_length);
+ssize_t aper_put_length(asn_per_outp_t *po, int range, size_t length);
+
/*
* Put the normally small length "n" to the Unaligned PER stream.
* Returns 0 or -1.
*/
int uper_put_nslength(asn_per_outp_t *po, size_t length);
+int aper_put_nslength(asn_per_outp_t *po, size_t length);
+
/*
* Put the normally small non-negative whole number.
*/
int uper_put_nsnnwn(asn_per_outp_t *po, int n);
+int aper_put_nsnnwn(asn_per_outp_t *po, int range, int number);
+
#ifdef __cplusplus
}
#endif