1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
5 # Licensed under the Apache License, Version 2.0 (the "License"); *
6 # you may not use this file except in compliance with the License. *
7 # You may obtain a copy of the License at *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
11 # Unless required by applicable law or agreed to in writing, software *
12 # distributed under the License is distributed on an "AS IS" BASIS, *
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 # See the License for the specific language governing permissions and *
15 # limitations under the License. *
17 ******************************************************************************/
20 * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
21 * Redistribution and modifications are permitted subject to BSD license.
23 #ifndef _PER_DECODER_H_
24 #define _PER_DECODER_H_
26 #include <asn_application.h>
27 #include <per_support.h>
33 struct asn_TYPE_descriptor_s; /* Forward declaration */
36 * Unaligned PER decoder of a "complete encoding" as per X.691 (08/2015) #11.1.
37 * On success, this call always returns (.consumed >= 1), as per #11.1.3.
39 asn_dec_rval_t uper_decode_complete(
40 const struct asn_codec_ctx_s *opt_codec_ctx,
41 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
42 void **struct_ptr, /* Pointer to a target structure's pointer */
43 const void *buffer, /* Data to be decoded */
44 size_t size /* Size of data buffer */
48 * Unaligned PER decoder of any ASN.1 type. May be invoked by the application.
49 * WARNING: This call returns the number of BITS read from the stream. Beware.
51 asn_dec_rval_t uper_decode(
52 const struct asn_codec_ctx_s *opt_codec_ctx,
53 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
54 void **struct_ptr, /* Pointer to a target structure's pointer */
55 const void *buffer, /* Data to be decoded */
56 size_t size, /* Size of the input data buffer, in bytes */
57 int skip_bits, /* Number of unused leading bits, 0..7 */
58 int unused_bits /* Number of unused tailing bits, 0..7 */
62 * Aligned PER decoder of a "complete encoding" as per X.691#10.1.
63 * On success, this call always returns (.consumed >= 1), in BITS, as per X.691#10.1.3.
65 asn_dec_rval_t aper_decode_complete(
66 const struct asn_codec_ctx_s *opt_codec_ctx,
67 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
68 void **struct_ptr, /* Pointer to a target structure's pointer */
69 const void *buffer, /* Data to be decoded */
70 size_t size /* Size of data buffer */
74 * Aligned PER decoder of any ASN.1 type. May be invoked by the application.
75 * WARNING: This call returns the number of BITS read from the stream. Beware.
77 asn_dec_rval_t aper_decode(
78 const struct asn_codec_ctx_s *opt_codec_ctx,
79 const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
80 void **struct_ptr, /* Pointer to a target structure's pointer */
81 const void *buffer, /* Data to be decoded */
82 size_t size, /* Size of data buffer */
83 int skip_bits, /* Number of unused leading bits, 0..7 */
84 int unused_bits /* Number of unused tailing bits, 0..7 */
88 * Type of the type-specific PER decoder function.
90 typedef asn_dec_rval_t(per_type_decoder_f)(
91 const asn_codec_ctx_t *opt_codec_ctx,
92 const struct asn_TYPE_descriptor_s *type_descriptor,
93 const asn_per_constraints_t *constraints, void **struct_ptr,
94 asn_per_data_t *per_data);
100 #endif /* _PER_DECODER_H_ */