1 /*****************************************************************************
3 # Copyright 2019 AT&T Intellectual Property *
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 *
9 # http://www.apache.org/licenses/LICENSE-2.0 *
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. *
17 ******************************************************************************/
20 * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
21 * Redistribution and modifications are permitted subject to BSD license.
23 #ifndef ASN_TYPE_ANY_H
24 #define ASN_TYPE_ANY_H
26 #include <OCTET_STRING.h> /* Implemented via OCTET STRING type */
33 uint8_t *buf; /* BER-encoded ANY contents */
34 int size; /* Size of the above buffer */
36 asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
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;
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;
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
61 /******************************
62 * Handy conversion routines. *
63 ******************************/
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);
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);
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))
83 #endif /* ASN_TYPE_ANY_H */