Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [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 | */ |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 5 | #ifndef OER_DECODER_H |
| 6 | #define OER_DECODER_H |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 7 | |
| 8 | #include <asn_application.h> |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 9 | #include <oer_support.h> |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 10 | |
| 11 | #ifdef __cplusplus |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | struct asn_TYPE_descriptor_s; /* Forward declaration */ |
| 16 | struct asn_codec_ctx_s; /* Forward declaration */ |
| 17 | |
| 18 | /* |
| 19 | * The Octet Encoding Rules (OER, X.696 08/2015) decoder for any given type. |
| 20 | * This function may be invoked directly by the application. |
Lev Walkin | 2864774 | 2017-09-12 11:07:06 -0700 | [diff] [blame] | 21 | * Parses CANONICAL-OER and BASIC-OER. |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 22 | */ |
Lev Walkin | afbf2a9 | 2017-09-12 23:30:27 -0700 | [diff] [blame] | 23 | asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx, |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 24 | struct asn_TYPE_descriptor_s *type_descriptor, |
| 25 | void **struct_ptr, /* Pointer to a target structure's pointer */ |
| 26 | const void *buffer, /* Data to be decoded */ |
| 27 | size_t size /* Size of that buffer */ |
| 28 | ); |
| 29 | |
| 30 | /* |
| 31 | * Type of generic function which decodes the byte stream into the structure. |
| 32 | */ |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 33 | typedef asn_dec_rval_t(oer_type_decoder_f)( |
Lev Walkin | afbf2a9 | 2017-09-12 23:30:27 -0700 | [diff] [blame] | 34 | const struct asn_codec_ctx_s *opt_codec_ctx, |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 35 | struct asn_TYPE_descriptor_s *type_descriptor, |
Lev Walkin | 494fb70 | 2017-08-07 20:07:00 -0700 | [diff] [blame] | 36 | const asn_oer_constraints_t *constraints, |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 37 | void **struct_ptr, |
| 38 | const void *buf_ptr, |
| 39 | size_t size); |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 40 | |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 41 | /* |
| 42 | * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null. |
| 43 | * RETURN VALUES: |
| 44 | * 0: More data expected than bufptr contains. |
| 45 | * -1: Fatal error deciphering length. |
| 46 | * >0: Number of bytes used from bufptr. |
| 47 | */ |
Lev Walkin | 20ea852 | 2017-07-20 14:52:02 +0300 | [diff] [blame] | 48 | ssize_t oer_open_type_skip(const void *bufptr, size_t size); |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Read the Open Type (X.696 (08/2015), #30). |
| 52 | * RETURN VALUES: |
| 53 | * 0: More data expected than bufptr contains. |
| 54 | * -1: Fatal error deciphering length. |
| 55 | * >0: Number of bytes used from bufptr. |
| 56 | */ |
Lev Walkin | afbf2a9 | 2017-09-12 23:30:27 -0700 | [diff] [blame] | 57 | ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx, |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 58 | struct asn_TYPE_descriptor_s *td, |
| 59 | asn_oer_constraints_t *constraints, void **struct_ptr, |
| 60 | const void *bufptr, size_t size); |
| 61 | |
| 62 | |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 63 | #ifdef __cplusplus |
| 64 | } |
| 65 | #endif |
| 66 | |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 67 | #endif /* OER_DECODER_H */ |