blob: 2b2a619a942bc5fcc34396914ad5f63b5adda9df [file] [log] [blame]
Lev Walkincc159472017-07-06 08:26:36 -07001/*
2 * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3 * Redistribution and modifications are permitted subject to BSD license.
4 */
Lev Walkind88bea92017-07-20 11:21:30 +03005#ifndef OER_DECODER_H
6#define OER_DECODER_H
Lev Walkincc159472017-07-06 08:26:36 -07007
8#include <asn_application.h>
Lev Walkine7b73c42017-07-07 10:06:17 -07009#include <oer_support.h>
Lev Walkincc159472017-07-06 08:26:36 -070010
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 */
22asn_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 Walkine7b73c42017-07-07 10:06:17 -070032typedef 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 Walkin494fb702017-08-07 20:07:00 -070035 const asn_oer_constraints_t *constraints,
Lev Walkine7b73c42017-07-07 10:06:17 -070036 void **struct_ptr,
37 const void *buf_ptr,
38 size_t size);
Lev Walkincc159472017-07-06 08:26:36 -070039
Lev Walkind88bea92017-07-20 11:21:30 +030040/*
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 Walkin20ea8522017-07-20 14:52:02 +030047ssize_t oer_open_type_skip(const void *bufptr, size_t size);
Lev Walkind88bea92017-07-20 11:21:30 +030048
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 */
56ssize_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 Walkincc159472017-07-06 08:26:36 -070062#ifdef __cplusplus
63}
64#endif
65
Lev Walkind88bea92017-07-20 11:21:30 +030066#endif /* OER_DECODER_H */