blob: dbc9b5fcff51a184b7fb7937cd4353592d0f6156 [file] [log] [blame]
Lev Walkine7b73c42017-07-07 10:06:17 -07001/*
Lev Walkin20696a42017-10-17 21:27:33 -07002 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
Lev Walkin086ee9a2017-08-08 02:05:55 -07003 * Redistribution and modifications are permitted subject to BSD license.
Lev Walkine7b73c42017-07-07 10:06:17 -07004 */
Lev Walkind88bea92017-07-20 11:21:30 +03005#ifndef OER_SUPPORT_H
6#define OER_SUPPORT_H
Lev Walkine7b73c42017-07-07 10:06:17 -07007
8#include <asn_system.h> /* Platform-specific types */
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14/*
15 * Pre-computed OER constraints.
16 */
Lev Walkin494fb702017-08-07 20:07:00 -070017typedef struct asn_oer_constraint_number_s {
Lev Walkin4118ccf2017-08-02 10:37:31 -070018 unsigned width; /* ±8,4,2,1 fixed bytes */
19 unsigned positive; /* 1 for unsigned number, 0 for signed */
20} asn_oer_constraint_number_t;
Lev Walkin494fb702017-08-07 20:07:00 -070021typedef struct asn_oer_constraints_s {
Lev Walkin4118ccf2017-08-02 10:37:31 -070022 asn_oer_constraint_number_t value;
23 ssize_t size; /* -1 (no constraint) or >= 0 */
Lev Walkine7b73c42017-07-07 10:06:17 -070024} asn_oer_constraints_t;
25
Lev Walkine4d8c922017-07-10 20:29:33 -070026
27/*
Lev Walkind88bea92017-07-20 11:21:30 +030028 * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r.
Lev Walkine4d8c922017-07-10 20:29:33 -070029 * RETURN VALUES:
30 * 0: More data expected than bufptr contains.
31 * -1: Fatal error deciphering length.
32 * >0: Number of bytes used from bufptr.
33 */
34ssize_t oer_fetch_length(const void *bufptr, size_t size, size_t *len_r);
35
Lev Walkinfcfe19b2017-07-10 21:57:14 -070036/*
37 * Serialize OER length. Returns the number of bytes serialized
38 * or -1 if a given callback returned with negative result.
39 */
40ssize_t oer_serialize_length(size_t length, asn_app_consume_bytes_f *cb, void *app_key);
41
Lev Walkine4d8c922017-07-10 20:29:33 -070042
Lev Walkine7b73c42017-07-07 10:06:17 -070043#ifdef __cplusplus
44}
45#endif
46
Lev Walkind88bea92017-07-20 11:21:30 +030047#endif /* OER_SUPPORT_H */