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. |
| 21 | */ |
| 22 | asn_dec_rval_t oer_decode(struct asn_codec_ctx_s *opt_codec_ctx, |
| 23 | struct asn_TYPE_descriptor_s *type_descriptor, |
| 24 | void **struct_ptr, /* Pointer to a target structure's pointer */ |
| 25 | const void *buffer, /* Data to be decoded */ |
| 26 | size_t size /* Size of that buffer */ |
| 27 | ); |
| 28 | |
| 29 | /* |
| 30 | * Type of generic function which decodes the byte stream into the structure. |
| 31 | */ |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 32 | typedef asn_dec_rval_t(oer_type_decoder_f)( |
| 33 | struct asn_codec_ctx_s *opt_codec_ctx, |
| 34 | struct asn_TYPE_descriptor_s *type_descriptor, |
Lev Walkin | ed3a4ae | 2017-07-07 10:09:51 -0700 | [diff] [blame] | 35 | asn_oer_constraints_t *constraints, |
Lev Walkin | e7b73c4 | 2017-07-07 10:06:17 -0700 | [diff] [blame] | 36 | void **struct_ptr, |
| 37 | const void *buf_ptr, |
| 38 | size_t size); |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 39 | |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 40 | /* |
| 41 | * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null. |
| 42 | * RETURN VALUES: |
| 43 | * 0: More data expected than bufptr contains. |
| 44 | * -1: Fatal error deciphering length. |
| 45 | * >0: Number of bytes used from bufptr. |
| 46 | */ |
Lev Walkin | 20ea852 | 2017-07-20 14:52:02 +0300 | [diff] [blame] | 47 | ssize_t oer_open_type_skip(const void *bufptr, size_t size); |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * Read the Open Type (X.696 (08/2015), #30). |
| 51 | * RETURN VALUES: |
| 52 | * 0: More data expected than bufptr contains. |
| 53 | * -1: Fatal error deciphering length. |
| 54 | * >0: Number of bytes used from bufptr. |
| 55 | */ |
| 56 | ssize_t oer_open_type_get(asn_codec_ctx_t *opt_codec_ctx, |
| 57 | struct asn_TYPE_descriptor_s *td, |
| 58 | asn_oer_constraints_t *constraints, void **struct_ptr, |
| 59 | const void *bufptr, size_t size); |
| 60 | |
| 61 | |
Lev Walkin | cc15947 | 2017-07-06 08:26:36 -0700 | [diff] [blame] | 62 | #ifdef __cplusplus |
| 63 | } |
| 64 | #endif |
| 65 | |
Lev Walkin | d88bea9 | 2017-07-20 11:21:30 +0300 | [diff] [blame] | 66 | #endif /* OER_DECODER_H */ |