Moving in e2sim originally from it/test/simulators
[sim/e2-interface.git] / e2sim / ASN1c / asn_codecs_prim.h
1 /*****************************************************************************
2 #                                                                            *
3 # Copyright 2019 AT&T Intellectual Property                                  *
4 #                                                                            *
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                                    *
8 #                                                                            *
9 #      http://www.apache.org/licenses/LICENSE-2.0                            *
10 #                                                                            *
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.                                             *
16 #                                                                            *
17 ******************************************************************************/
18
19 /*-
20  * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
21  * Redistribution and modifications are permitted subject to BSD license.
22  */
23 #ifndef ASN_CODECS_PRIM_H
24 #define ASN_CODECS_PRIM_H
25
26 #include <asn_application.h>
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 typedef struct ASN__PRIMITIVE_TYPE_s {
33     uint8_t *buf;   /* Buffer with consecutive primitive encoding bytes */
34     size_t size;    /* Size of the buffer */
35 } ASN__PRIMITIVE_TYPE_t;        /* Do not use this type directly! */
36
37 asn_struct_free_f ASN__PRIMITIVE_TYPE_free;
38 ber_type_decoder_f ber_decode_primitive;
39 der_type_encoder_f der_encode_primitive;
40
41 /*
42  * A callback specification for the xer_decode_primitive() function below.
43  */
44 enum xer_pbd_rval {
45     XPBD_SYSTEM_FAILURE,  /* System failure (memory shortage, etc) */
46     XPBD_DECODER_LIMIT,   /* Hit some decoder limitation or deficiency */
47     XPBD_BROKEN_ENCODING, /* Encoding of a primitive body is broken */
48     XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */
49     XPBD_BODY_CONSUMED    /* Body is recognized and consumed */
50 };
51 typedef enum xer_pbd_rval(xer_primitive_body_decoder_f)(
52     const asn_TYPE_descriptor_t *td, void *struct_ptr, const void *chunk_buf,
53     size_t chunk_size);
54
55 /*
56  * Specific function to decode simple primitive types.
57  * Also see xer_decode_general() in xer_decoder.h
58  */
59 asn_dec_rval_t xer_decode_primitive(
60     const asn_codec_ctx_t *opt_codec_ctx,
61     const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
62     size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size,
63     xer_primitive_body_decoder_f *prim_body_decoder);
64
65 #ifdef __cplusplus
66 }
67 #endif
68
69 #endif  /* ASN_CODECS_PRIM_H */