Moving in e2sim originally from it/test/simulators
[sim/e2-interface.git] / e2sim / ASN1c / ANY.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_TYPE_ANY_H
24 #define ASN_TYPE_ANY_H
25
26 #include <OCTET_STRING.h>       /* Implemented via OCTET STRING type */
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 typedef struct ANY {
33         uint8_t *buf;   /* BER-encoded ANY contents */
34         int size;       /* Size of the above buffer */
35
36         asn_struct_ctx_t _asn_ctx;      /* Parsing across buffer boundaries */
37 } ANY_t;
38
39 extern asn_TYPE_descriptor_t asn_DEF_ANY;
40 extern asn_TYPE_operation_t asn_OP_ANY;
41 extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
42
43 asn_struct_free_f ANY_free;
44 asn_struct_print_f ANY_print;
45 ber_type_decoder_f ANY_decode_ber;
46 der_type_encoder_f ANY_encode_der;
47 xer_type_encoder_f ANY_encode_xer;
48 per_type_decoder_f ANY_decode_uper;
49 per_type_encoder_f ANY_encode_uper;
50 per_type_decoder_f ANY_decode_aper;
51 per_type_encoder_f ANY_encode_aper;
52
53 #define ANY_free         OCTET_STRING_free
54 #define ANY_print        OCTET_STRING_print
55 #define ANY_compare      OCTET_STRING_compare
56 #define ANY_constraint   asn_generic_no_constraint
57 #define ANY_decode_ber   OCTET_STRING_decode_ber
58 #define ANY_encode_der   OCTET_STRING_encode_der
59 #define ANY_decode_xer   OCTET_STRING_decode_xer_hex
60
61 /******************************
62  * Handy conversion routines. *
63  ******************************/
64
65 /* Convert another ASN.1 type into the ANY. This implies DER encoding. */
66 int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
67 int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
68 ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
69 ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
70
71 /* Convert the contents of the ANY type into the specified type. */
72 int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
73 int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
74
75 #define ANY_fromBuf(s, buf, size)       OCTET_STRING_fromBuf((s), (buf), (size))
76 #define ANY_new_fromBuf(buf, size)      OCTET_STRING_new_fromBuf(       \
77                                                 &asn_DEF_ANY, (buf), (size))
78
79 #ifdef __cplusplus
80 }
81 #endif
82
83 #endif  /* ASN_TYPE_ANY_H */