blob: 508ce64ff4fe5d97bed3b568bf52916443789641 [file] [log] [blame]
Lev Walkine7b73c42017-07-07 10:06:17 -07001/*
2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>.
3 * All rights reserved.
Lev Walkin086ee9a2017-08-08 02:05:55 -07004 * Redistribution and modifications are permitted subject to BSD license.
Lev Walkine7b73c42017-07-07 10:06:17 -07005 */
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 */
Lev Walkin494fb702017-08-07 20:07:00 -070018typedef struct asn_oer_constraint_number_s {
Lev Walkin4118ccf2017-08-02 10:37:31 -070019 unsigned width; /* ±8,4,2,1 fixed bytes */
20 unsigned positive; /* 1 for unsigned number, 0 for signed */
21} asn_oer_constraint_number_t;
Lev Walkin494fb702017-08-07 20:07:00 -070022typedef struct asn_oer_constraints_s {
Lev Walkin4118ccf2017-08-02 10:37:31 -070023 asn_oer_constraint_number_t value;
24 ssize_t size; /* -1 (no constraint) or >= 0 */
Lev Walkine7b73c42017-07-07 10:06:17 -070025} asn_oer_constraints_t;
26
Lev Walkine4d8c922017-07-10 20:29:33 -070027
28/*
Lev Walkind88bea92017-07-20 11:21:30 +030029 * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r.
Lev Walkine4d8c922017-07-10 20:29:33 -070030 * RETURN VALUES:
31 * 0: More data expected than bufptr contains.
32 * -1: Fatal error deciphering length.
33 * >0: Number of bytes used from bufptr.
34 */
35ssize_t oer_fetch_length(const void *bufptr, size_t size, size_t *len_r);
36
Lev Walkinfcfe19b2017-07-10 21:57:14 -070037/*
38 * Serialize OER length. Returns the number of bytes serialized
39 * or -1 if a given callback returned with negative result.
40 */
41ssize_t oer_serialize_length(size_t length, asn_app_consume_bytes_f *cb, void *app_key);
42
Lev Walkine4d8c922017-07-10 20:29:33 -070043
Lev Walkine7b73c42017-07-07 10:06:17 -070044#ifdef __cplusplus
45}
46#endif
47
Lev Walkind88bea92017-07-20 11:21:30 +030048#endif /* OER_SUPPORT_H */