blob: d010de4a1590d67a741c8c1f8adc44ac1b0e6f89 [file] [log] [blame]
Lev Walkina737f3b2004-09-02 12:11:47 +00001/*-
2 * Copyright (c) 2004 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 <constr_TYPE.h>
9#include <OCTET_STRING.h> /* Implemented via OCTET SRING type */
10
11typedef struct ANY {
12 uint8_t *buf; /* BER-encoded ANY contents */
13 int size; /* Size of the above buffer */
14
15 ber_dec_ctx_t _ber_dec_ctx; /* Parsing across buffer boundaries */
16} ANY_t;
17
18extern asn1_TYPE_descriptor_t asn1_DEF_ANY;
19
Lev Walkina9cc46e2004-09-22 16:06:28 +000020asn_struct_free_f ANY_free;
21asn_struct_print_f ANY_print;
Lev Walkina737f3b2004-09-02 12:11:47 +000022ber_type_decoder_f ANY_decode_ber;
23der_type_encoder_f ANY_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +000024xer_type_encoder_f ANY_encode_xer;
Lev Walkina737f3b2004-09-02 12:11:47 +000025
26/******************************
27 * Handy conversion routines. *
28 ******************************/
29
Lev Walkind563d392004-09-13 08:26:57 +000030/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
31int ANY_fromType(ANY_t *, asn1_TYPE_descriptor_t *td, void *struct_ptr);
32ANY_t *ANY_new_fromType(asn1_TYPE_descriptor_t *td, void *struct_ptr);
33
34/* Convert the contents of the ANY type into the specified type. */
35int ANY_to_type(ANY_t *, asn1_TYPE_descriptor_t *td, void **struct_ptr);
36
Lev Walkina737f3b2004-09-02 12:11:47 +000037#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
38#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf((buf), (size))
39
40#endif /* ASN_TYPE_ANY_H */