blob: 01579c262296af05f7c84b9877fa9d6b8c842fc9 [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;
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +080022extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
Lev Walkina737f3b2004-09-02 12:11:47 +000023
Lev Walkina9cc46e2004-09-22 16:06:28 +000024asn_struct_free_f ANY_free;
25asn_struct_print_f ANY_print;
Lev Walkina737f3b2004-09-02 12:11:47 +000026ber_type_decoder_f ANY_decode_ber;
27der_type_encoder_f ANY_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +000028xer_type_encoder_f ANY_encode_xer;
Lev Walkin6bd4b292017-08-06 00:59:05 -070029per_type_decoder_f ANY_decode_uper;
30per_type_encoder_f ANY_encode_uper;
Lev Walkina737f3b2004-09-02 12:11:47 +000031
Bi-Ruei, Chiu1fa31c92016-05-16 13:50:09 +080032#define ANY_free OCTET_STRING_free
33#define ANY_print OCTET_STRING_print
34#define ANY_constraint asn_generic_no_constraint
35#define ANY_decode_ber OCTET_STRING_decode_ber
36#define ANY_encode_der OCTET_STRING_encode_der
37#define ANY_decode_xer OCTET_STRING_decode_xer_hex
38
Lev Walkina737f3b2004-09-02 12:11:47 +000039/******************************
40 * Handy conversion routines. *
41 ******************************/
42
Lev Walkind563d392004-09-13 08:26:57 +000043/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
Lev Walkin5e033762004-09-29 13:26:15 +000044int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
45ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
Lev Walkind563d392004-09-13 08:26:57 +000046
47/* Convert the contents of the ANY type into the specified type. */
Lev Walkin5e033762004-09-29 13:26:15 +000048int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
Lev Walkind563d392004-09-13 08:26:57 +000049
Lev Walkina737f3b2004-09-02 12:11:47 +000050#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
Lev Walkinfc6a3492006-01-25 01:56:58 +000051#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
52 &asn_DEF_ANY, (buf), (size))
Lev Walkina737f3b2004-09-02 12:11:47 +000053
Lev Walkin21b41ac2005-07-24 09:03:44 +000054#ifdef __cplusplus
55}
56#endif
57
Lev Walkina737f3b2004-09-02 12:11:47 +000058#endif /* ASN_TYPE_ANY_H */