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