blob: a68441dfe004a2fcc4c7589db1dc9a49d0beeb3c [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
Lev Walkinbbd93252004-10-12 05:57:23 +00008#include <OCTET_STRING.h> /* Implemented via OCTET STRING type */
Lev Walkina737f3b2004-09-02 12:11:47 +00009
Lev Walkin21b41ac2005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
Lev Walkina737f3b2004-09-02 12:11:47 +000014typedef struct ANY {
15 uint8_t *buf; /* BER-encoded ANY contents */
16 int size; /* Size of the above buffer */
17
Lev Walkin5e033762004-09-29 13:26:15 +000018 asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
Lev Walkina737f3b2004-09-02 12:11:47 +000019} ANY_t;
20
Lev Walkin5e033762004-09-29 13:26:15 +000021extern asn_TYPE_descriptor_t asn_DEF_ANY;
Lev Walkina737f3b2004-09-02 12:11:47 +000022
Lev Walkina9cc46e2004-09-22 16:06:28 +000023asn_struct_free_f ANY_free;
24asn_struct_print_f ANY_print;
Lev Walkina737f3b2004-09-02 12:11:47 +000025ber_type_decoder_f ANY_decode_ber;
26der_type_encoder_f ANY_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +000027xer_type_encoder_f ANY_encode_xer;
Lev Walkina737f3b2004-09-02 12:11:47 +000028
29/******************************
30 * Handy conversion routines. *
31 ******************************/
32
Lev Walkind563d392004-09-13 08:26:57 +000033/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
Lev Walkin5e033762004-09-29 13:26:15 +000034int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
Harald Welte498c9712015-08-30 16:33:07 +020035int ANY_fromType_aper(ANY_t *st, asn_TYPE_descriptor_t *td, void *sptr);
Lev Walkin5e033762004-09-29 13:26:15 +000036ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
Harald Welte498c9712015-08-30 16:33:07 +020037ANY_t *ANY_new_fromType_aper(asn_TYPE_descriptor_t *td, void *sptr);
Lev Walkind563d392004-09-13 08:26:57 +000038
39/* Convert the contents of the ANY type into the specified type. */
Lev Walkin5e033762004-09-29 13:26:15 +000040int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
Harald Welte498c9712015-08-30 16:33:07 +020041int ANY_to_type_aper(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
Lev Walkind563d392004-09-13 08:26:57 +000042
Lev Walkina737f3b2004-09-02 12:11:47 +000043#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
Lev Walkinfc6a3492006-01-25 01:56:58 +000044#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
45 &asn_DEF_ANY, (buf), (size))
Lev Walkina737f3b2004-09-02 12:11:47 +000046
Lev Walkin21b41ac2005-07-24 09:03:44 +000047#ifdef __cplusplus
48}
49#endif
50
Lev Walkina737f3b2004-09-02 12:11:47 +000051#endif /* ASN_TYPE_ANY_H */