blob: 719b3a9939d2588dc238eeca4e90c716e76a15ea [file] [log] [blame]
vlm7e66aa82004-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
20ber_type_decoder_f ANY_decode_ber;
21der_type_encoder_f ANY_encode_der;
22asn_struct_print_f ANY_print;
23asn_struct_free_f ANY_free;
24
25/******************************
26 * Handy conversion routines. *
27 ******************************/
28
vlm83204112004-09-13 08:26:57 +000029/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
30int ANY_fromType(ANY_t *, asn1_TYPE_descriptor_t *td, void *struct_ptr);
31ANY_t *ANY_new_fromType(asn1_TYPE_descriptor_t *td, void *struct_ptr);
32
33/* Convert the contents of the ANY type into the specified type. */
34int ANY_to_type(ANY_t *, asn1_TYPE_descriptor_t *td, void **struct_ptr);
35
vlm7e66aa82004-09-02 12:11:47 +000036#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
37#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf((buf), (size))
38
39#endif /* ASN_TYPE_ANY_H */