blob: 710f4ee096fad95ae948b79ed05659a4851ddd99 [file] [log] [blame]
Lev Walkin59b176e2005-11-26 11:25:14 +00001/*-
Lev Walkin20696a42017-10-17 21:27:33 -07002 * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
Lev Walkin59b176e2005-11-26 11:25:14 +00003 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef _PER_DECODER_H_
6#define _PER_DECODER_H_
7
8#include <asn_application.h>
9#include <per_support.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000015struct asn_TYPE_descriptor_s; /* Forward declaration */
16
17/*
Lev Walkin6d46bc32017-09-12 21:34:00 -070018 * Unaligned PER decoder of a "complete encoding" as per X.691 (08/2015) #11.1.
19 * On success, this call always returns (.consumed >= 1), as per #11.1.3.
Lev Walkin08b30bb2007-06-26 08:24:50 +000020 */
Lev Walkinafbf2a92017-09-12 23:30:27 -070021asn_dec_rval_t uper_decode_complete(
22 const struct asn_codec_ctx_s *opt_codec_ctx,
Lev Walkin20696a42017-10-17 21:27:33 -070023 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
Lev Walkinafbf2a92017-09-12 23:30:27 -070024 void **struct_ptr, /* Pointer to a target structure's pointer */
25 const void *buffer, /* Data to be decoded */
26 size_t size /* Size of data buffer */
Lev Walkin20696a42017-10-17 21:27:33 -070027);
Lev Walkin08b30bb2007-06-26 08:24:50 +000028
29/*
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000030 * Unaligned PER decoder of any ASN.1 type. May be invoked by the application.
Lev Walkin08b30bb2007-06-26 08:24:50 +000031 * WARNING: This call returns the number of BITS read from the stream. Beware.
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000032 */
Lev Walkinafbf2a92017-09-12 23:30:27 -070033asn_dec_rval_t uper_decode(
34 const struct asn_codec_ctx_s *opt_codec_ctx,
Lev Walkin20696a42017-10-17 21:27:33 -070035 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
Lev Walkinafbf2a92017-09-12 23:30:27 -070036 void **struct_ptr, /* Pointer to a target structure's pointer */
37 const void *buffer, /* Data to be decoded */
Lev Walkinec4b7af2017-11-07 04:20:36 -080038 size_t size, /* Size of the input data buffer, in bytes */
Lev Walkinafbf2a92017-09-12 23:30:27 -070039 int skip_bits, /* Number of unused leading bits, 0..7 */
40 int unused_bits /* Number of unused tailing bits, 0..7 */
Lev Walkin20696a42017-10-17 21:27:33 -070041);
Lev Walkin1d9e8dd2005-12-07 05:46:03 +000042
Lev Walkin59b176e2005-11-26 11:25:14 +000043
44/*
Lev Walkin59b176e2005-11-26 11:25:14 +000045 * Type of the type-specific PER decoder function.
46 */
Lev Walkinafbf2a92017-09-12 23:30:27 -070047typedef asn_dec_rval_t(per_type_decoder_f)(
48 const asn_codec_ctx_t *opt_codec_ctx,
Lev Walkin20696a42017-10-17 21:27:33 -070049 const struct asn_TYPE_descriptor_s *type_descriptor,
Lev Walkinafbf2a92017-09-12 23:30:27 -070050 const asn_per_constraints_t *constraints, void **struct_ptr,
51 asn_per_data_t *per_data);
Lev Walkin59b176e2005-11-26 11:25:14 +000052
53#ifdef __cplusplus
54}
55#endif
56
57#endif /* _PER_DECODER_H_ */