blob: 2a7fcb96be0c6a5f7b825c80b0c80b5db1f5c175 [file] [log] [blame]
Lev Walkine7b73c42017-07-07 10:06:17 -07001/*
2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
3 * All rights reserved.
4 * Redistribution and modifications are oermitted subject to BSD license.
5 */
Lev Walkind88bea92017-07-20 11:21:30 +03006#ifndef OER_SUPPORT_H
7#define OER_SUPPORT_H
Lev Walkine7b73c42017-07-07 10:06:17 -07008
9#include <asn_system.h> /* Platform-specific types */
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/*
16 * Pre-computed OER constraints.
17 */
18typedef const struct asn_oer_constraint_s {
19 enum asn_oer_constraint_flags {
20 AOC_HAS_LOWER_BOUND = 0x01,
21 AOC_HAS_UPPER_BOUND = 0x02
22 } flags;
23 intmax_t lower_bound;
Lev Walkine4d8c922017-07-10 20:29:33 -070024 intmax_t upper_bound;
Lev Walkine7b73c42017-07-07 10:06:17 -070025} asn_oer_constraint_t;
26typedef const struct asn_oer_constraints_s {
27 struct asn_oer_constraint_s value;
28 struct asn_oer_constraint_s size;
29} asn_oer_constraints_t;
30
Lev Walkine4d8c922017-07-10 20:29:33 -070031
32/*
Lev Walkind88bea92017-07-20 11:21:30 +030033 * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r.
Lev Walkine4d8c922017-07-10 20:29:33 -070034 * RETURN VALUES:
35 * 0: More data expected than bufptr contains.
36 * -1: Fatal error deciphering length.
37 * >0: Number of bytes used from bufptr.
38 */
39ssize_t oer_fetch_length(const void *bufptr, size_t size, size_t *len_r);
40
Lev Walkinfcfe19b2017-07-10 21:57:14 -070041/*
42 * Serialize OER length. Returns the number of bytes serialized
43 * or -1 if a given callback returned with negative result.
44 */
45ssize_t oer_serialize_length(size_t length, asn_app_consume_bytes_f *cb, void *app_key);
46
Lev Walkine4d8c922017-07-10 20:29:33 -070047
Lev Walkine7b73c42017-07-07 10:06:17 -070048#ifdef __cplusplus
49}
50#endif
51
Lev Walkind88bea92017-07-20 11:21:30 +030052#endif /* OER_SUPPORT_H */