2 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
\r
3 * Redistribution and modifications are permitted subject to BSD license.
\r
5 #ifndef _BER_DECODER_H_
\r
6 #define _BER_DECODER_H_
\r
8 #include <asn_application.h>
\r
14 struct asn_TYPE_descriptor_s; /* Forward declaration */
\r
15 struct asn_codec_ctx_s; /* Forward declaration */
\r
18 * The BER decoder of any type.
\r
19 * This function may be invoked directly from the application.
\r
20 * Decodes BER, DER and CER data (DER and CER are different subsets of BER).
\r
22 * NOTE: Use the der_encode() function (der_encoder.h) to produce encoding
\r
23 * which is compliant with ber_decode().
\r
25 asn_dec_rval_t ber_decode(
\r
26 const struct asn_codec_ctx_s *opt_codec_ctx,
\r
27 const struct asn_TYPE_descriptor_s *type_descriptor,
\r
28 void **struct_ptr, /* Pointer to a target structure's pointer */
\r
29 const void *buffer, /* Data to be decoded */
\r
30 size_t size /* Size of that buffer */
\r
34 * Type of generic function which decodes the byte stream into the structure.
\r
36 typedef asn_dec_rval_t(ber_type_decoder_f)(
\r
37 const struct asn_codec_ctx_s *opt_codec_ctx,
\r
38 const struct asn_TYPE_descriptor_s *type_descriptor, void **struct_ptr,
\r
39 const void *buf_ptr, size_t size, int tag_mode);
\r
41 /*******************************
\r
42 * INTERNALLY USEFUL FUNCTIONS *
\r
43 *******************************/
\r
46 * Check that all tags correspond to the type definition (as given in head).
\r
47 * On return, last_length would contain either a non-negative length of the
\r
48 * value part of the last TLV, or the negative number of expected
\r
49 * "end of content" sequences. The number may only be negative if the
\r
50 * head->last_tag_form is non-zero.
\r
52 asn_dec_rval_t ber_check_tags(
\r
53 const struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */
\r
54 const struct asn_TYPE_descriptor_s *type_descriptor,
\r
55 asn_struct_ctx_t *opt_ctx, /* saved decoding context */
\r
56 const void *ptr, size_t size,
\r
57 int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
\r
58 int last_tag_form, /* {-1,0:1}: any, primitive, constr */
\r
59 ber_tlv_len_t *last_length, int *opt_tlv_form /* optional tag form */
\r
66 #endif /* _BER_DECODER_H_ */
\r