871ed5ed393585c1d2f816c0341044f789f36897
[sim/e2-interface.git] / e2sim / asn1c / ANY.h
1 /*-
2  * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
3  * Redistribution and modifications are permitted subject to BSD license.
4  */
5 #ifndef ASN_TYPE_ANY_H
6 #define ASN_TYPE_ANY_H
7
8 #include <OCTET_STRING.h>       /* Implemented via OCTET STRING type */
9
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13
14 typedef struct ANY {
15         uint8_t *buf;   /* BER-encoded ANY contents */
16         int size;       /* Size of the above buffer */
17
18         asn_struct_ctx_t _asn_ctx;      /* Parsing across buffer boundaries */
19 } ANY_t;
20
21 extern asn_TYPE_descriptor_t asn_DEF_ANY;
22 extern asn_TYPE_operation_t asn_OP_ANY;
23 extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
24
25 #define ANY_free OCTET_STRING_free
26
27 #if !defined(ASN_DISABLE_PRINT_SUPPORT)
28 #define ANY_print OCTET_STRING_print
29 #endif  /* !defined(ASN_DISABLE_PRINT_SUPPORT) */
30
31 #define ANY_compare OCTET_STRING_compare
32
33 #define ANY_constraint asn_generic_no_constraint
34
35 #if !defined(ASN_DISABLE_BER_SUPPORT)
36 #define ANY_decode_ber OCTET_STRING_decode_ber
37 #define ANY_encode_der OCTET_STRING_encode_der
38 #endif  /* !defined(ASN_DISABLE_BER_SUPPORT) */
39
40 #if !defined(ASN_DISABLE_XER_SUPPORT)
41 #define ANY_decode_xer OCTET_STRING_decode_xer_hex
42 xer_type_encoder_f ANY_encode_xer;
43 #endif  /* !defined(ASN_DISABLE_XER_SUPPORT) */
44
45 #if !defined(ASN_DISABLE_JER_SUPPORT)
46 jer_type_encoder_f ANY_encode_jer;
47 #endif  /* !defined(ASN_DISABLE_JER_SUPPORT) */
48
49 #if !defined(ASN_DISABLE_UPER_SUPPORT)
50 per_type_decoder_f ANY_decode_uper;
51 per_type_encoder_f ANY_encode_uper;
52 #endif  /* !defined(ASN_DISABLE_UPER_SUPPORT) */
53 #if !defined(ASN_DISABLE_APER_SUPPORT)
54 per_type_decoder_f ANY_decode_aper;
55 per_type_encoder_f ANY_encode_aper;
56 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
57
58 /******************************
59  * Handy conversion routines. *
60  ******************************/
61
62 /* Convert another ASN.1 type into the ANY. This implies DER encoding. */
63 int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
64 ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
65 #if !defined(ASN_DISABLE_APER_SUPPORT)
66 int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
67 ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
68 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
69
70 /* Convert the contents of the ANY type into the specified type. */
71 int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
72 #if !defined(ASN_DISABLE_APER_SUPPORT)
73 int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
74 #endif  /* !defined(ASN_DISABLE_APER_SUPPORT) */
75
76 #define ANY_fromBuf(s, buf, size)       OCTET_STRING_fromBuf((s), (buf), (size))
77 #define ANY_new_fromBuf(buf, size)      OCTET_STRING_new_fromBuf(       \
78                                                 &asn_DEF_ANY, (buf), (size))
79
80 #ifdef __cplusplus
81 }
82 #endif
83
84 #endif  /* ASN_TYPE_ANY_H */