blob: 40992e9480ec37b7ffc27cdd2ab74bf4148619f0 [file] [log] [blame]
Ron Shacham0eba05c2020-05-08 15:13:19 -04001/*
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_DECODER_H
6#define OER_DECODER_H
7
8#include <asn_application.h>
9#include <oer_support.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15struct asn_TYPE_descriptor_s; /* Forward declaration */
16struct 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 * Parses CANONICAL-OER and BASIC-OER.
22 */
23asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
24 const 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 */
33typedef asn_dec_rval_t(oer_type_decoder_f)(
34 const struct asn_codec_ctx_s *opt_codec_ctx,
35 const struct asn_TYPE_descriptor_s *type_descriptor,
36 const asn_oer_constraints_t *constraints,
37 void **struct_ptr,
38 const void *buf_ptr,
39 size_t size);
40
41/*
42 * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null.
43 * RETURN VALUES:
44 * -1: Fatal error deciphering length.
45 * 0: More data expected than bufptr contains.
46 * >0: Number of bytes used from bufptr.
47 */
48ssize_t oer_open_type_skip(const void *bufptr, size_t size);
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 */
57ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
58 const struct asn_TYPE_descriptor_s *td,
59 const asn_oer_constraints_t *constraints,
60 void **struct_ptr, const void *bufptr, size_t size);
61
62/*
63 * Length-prefixed buffer decoding for primitive types.
64 */
65oer_type_decoder_f oer_decode_primitive;
66
67
68#ifdef __cplusplus
69}
70#endif
71
72#endif /* OER_DECODER_H */