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