Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. |
| 3 | * All rights reserved. |
Lev Walkin | 086ee9a | 2017-08-08 02:05:55 -0700 | [diff] [blame] | 4 | * Redistribution and modifications are permitted subject to BSD license. |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 5 | */ |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 6 | #ifndef OER_SUPPORT_H |
| 7 | #define OER_SUPPORT_H |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 8 | |
| 9 | #include <asn_system.h> /* Platform-specific types */ |
| 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | /* |
| 16 | * Pre-computed OER constraints. |
| 17 | */ |
Lev Walkin | 494fb70 | 2017-08-07 20:07:00 -0700 | [diff] [blame] | 18 | typedef struct asn_oer_constraint_number_s { |
Lev Walkin | 4118ccf | 2017-08-02 10:37:31 -0700 | [diff] [blame] | 19 | 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 Walkin | 494fb70 | 2017-08-07 20:07:00 -0700 | [diff] [blame] | 22 | typedef struct asn_oer_constraints_s { |
Lev Walkin | 4118ccf | 2017-08-02 10:37:31 -0700 | [diff] [blame] | 23 | asn_oer_constraint_number_t value; |
| 24 | ssize_t size; /* -1 (no constraint) or >= 0 */ |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 25 | } asn_oer_constraints_t; |
| 26 | |
Lev Walkin | e4d8c92 | 2017-07-10 20:29:33 -0700 | [diff] [blame] | 27 | |
| 28 | /* |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 29 | * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r. |
Lev Walkin | e4d8c92 | 2017-07-10 20:29:33 -0700 | [diff] [blame] | 30 | * 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 | */ |
| 35 | ssize_t oer_fetch_length(const void *bufptr, size_t size, size_t *len_r); |
| 36 | |
Lev Walkin | fcfe19b | 2017-07-10 21:57:14 -0700 | [diff] [blame] | 37 | /* |
| 38 | * Serialize OER length. Returns the number of bytes serialized |
| 39 | * or -1 if a given callback returned with negative result. |
| 40 | */ |
| 41 | ssize_t oer_serialize_length(size_t length, asn_app_consume_bytes_f *cb, void *app_key); |
| 42 | |
Lev Walkin | e4d8c92 | 2017-07-10 20:29:33 -0700 | [diff] [blame] | 43 | |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 44 | #ifdef __cplusplus |
| 45 | } |
| 46 | #endif |
| 47 | |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 48 | #endif /* OER_SUPPORT_H */ |