rajalakshmisv | 21b61dd | 2021-12-07 04:53:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef OER_SUPPORT_H |
| 6 | #define OER_SUPPORT_H |
| 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 | */ |
| 17 | typedef struct asn_oer_constraint_number_s { |
| 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; |
| 21 | typedef struct asn_oer_constraints_s { |
| 22 | asn_oer_constraint_number_t value; |
| 23 | ssize_t size; /* -1 (no constraint) or >= 0 */ |
| 24 | } asn_oer_constraints_t; |
| 25 | |
| 26 | |
| 27 | /* |
| 28 | * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r. |
| 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 | |
| 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 | |
| 42 | |
| 43 | #ifdef __cplusplus |
| 44 | } |
| 45 | #endif |
| 46 | |
| 47 | #endif /* OER_SUPPORT_H */ |