Change version after creation of r2 branch
[ric-plt/resource-status-manager.git] / RSM / 3rdparty / asn1codec / e2ap_engine / der_encoder.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 _DER_ENCODER_H_
7 #define _DER_ENCODER_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
17 /*
18  * The DER encoder of any type. May be invoked by the application.
19  * Produces DER- and BER-compliant encoding. (DER is a subset of BER).
20  *
21  * NOTE: Use the ber_decode() function (ber_decoder.h) to decode data
22  * produced by der_encode().
23  */
24 asn_enc_rval_t der_encode(const struct asn_TYPE_descriptor_s *type_descriptor,
25                           const void *struct_ptr, /* Structure to be encoded */
26                           asn_app_consume_bytes_f *consume_bytes_cb,
27                           void *app_key /* Arbitrary callback argument */
28 );
29
30 /* A variant of der_encode() which encodes data into the pre-allocated buffer */
31 asn_enc_rval_t der_encode_to_buffer(
32     const struct asn_TYPE_descriptor_s *type_descriptor,
33     const void *struct_ptr, /* Structure to be encoded */
34     void *buffer,           /* Pre-allocated buffer */
35     size_t buffer_size      /* Initial buffer size (maximum) */
36 );
37
38 /*
39  * Type of the generic DER encoder.
40  */
41 typedef asn_enc_rval_t(der_type_encoder_f)(
42     const struct asn_TYPE_descriptor_s *type_descriptor,
43     const void *struct_ptr, /* Structure to be encoded */
44     int tag_mode,           /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
45     ber_tlv_tag_t tag, asn_app_consume_bytes_f *consume_bytes_cb, /* Callback */
46     void *app_key /* Arbitrary callback argument */
47 );
48
49
50 /*******************************
51  * INTERNALLY USEFUL FUNCTIONS *
52  *******************************/
53
54 /*
55  * Write out leading TL[v] sequence according to the type definition.
56  */
57 ssize_t der_write_tags(const struct asn_TYPE_descriptor_s *type_descriptor,
58                        size_t struct_length,
59                        int tag_mode,      /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
60                        int last_tag_form, /* {0,!0}: prim, constructed */
61                        ber_tlv_tag_t tag,
62                        asn_app_consume_bytes_f *consume_bytes_cb,
63                        void *app_key);
64
65 #ifdef __cplusplus
66 }
67 #endif
68
69 #endif  /* _DER_ENCODER_H_ */