blob: b30381fa157c2b08b256b2e62959eafe51bca61b [file] [log] [blame]
Peter Szilagyifbc56f92019-07-23 19:29:46 +00001/*-
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
11extern "C" {
12#endif
13
14typedef 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
21extern asn_TYPE_descriptor_t asn_DEF_ANY;
22extern asn_TYPE_operation_t asn_OP_ANY;
23extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
24
25asn_struct_free_f ANY_free;
26asn_struct_print_f ANY_print;
27ber_type_decoder_f ANY_decode_ber;
28der_type_encoder_f ANY_encode_der;
29xer_type_encoder_f ANY_encode_xer;
30per_type_decoder_f ANY_decode_uper;
31per_type_encoder_f ANY_encode_uper;
32per_type_decoder_f ANY_decode_aper;
33per_type_encoder_f ANY_encode_aper;
34
35#define ANY_free OCTET_STRING_free
36#define ANY_print OCTET_STRING_print
37#define ANY_compare OCTET_STRING_compare
38#define ANY_constraint asn_generic_no_constraint
39#define ANY_decode_ber OCTET_STRING_decode_ber
40#define ANY_encode_der OCTET_STRING_encode_der
41#define ANY_decode_xer OCTET_STRING_decode_xer_hex
42
43/******************************
44 * Handy conversion routines. *
45 ******************************/
46
47/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
48int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
49int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
50ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
51ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
52
53/* Convert the contents of the ANY type into the specified type. */
54int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
55int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
56
57#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
58#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
59 &asn_DEF_ANY, (buf), (size))
60
61#ifdef __cplusplus
62}
63#endif
64
65#endif /* ASN_TYPE_ANY_H */