2004-09-02 12:11:47 +00:00
|
|
|
/*-
|
2017-10-18 04:27:33 +00:00
|
|
|
* Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
|
2004-09-02 12:11:47 +00:00
|
|
|
* Redistribution and modifications are permitted subject to BSD license.
|
|
|
|
*/
|
|
|
|
#ifndef ASN_TYPE_ANY_H
|
|
|
|
#define ASN_TYPE_ANY_H
|
|
|
|
|
2004-10-12 05:57:23 +00:00
|
|
|
#include <OCTET_STRING.h> /* Implemented via OCTET STRING type */
|
2004-09-02 12:11:47 +00:00
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-09-02 12:11:47 +00:00
|
|
|
typedef struct ANY {
|
|
|
|
uint8_t *buf; /* BER-encoded ANY contents */
|
|
|
|
int size; /* Size of the above buffer */
|
|
|
|
|
2004-09-29 13:26:15 +00:00
|
|
|
asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */
|
2004-09-02 12:11:47 +00:00
|
|
|
} ANY_t;
|
|
|
|
|
2004-09-29 13:26:15 +00:00
|
|
|
extern asn_TYPE_descriptor_t asn_DEF_ANY;
|
Move type operations to another structure
Every type has free, print, check_constraints, ber_decoder, der_encoder,
xer_decoder, xer_encoder, uper_decoder, uper_encoder and outmost_tag
operations. We move them out to a separate structure asn_TYPE_operation_t.
Combined with previous logic simplification, these operations are based
on ASN.1 basic types, constructed types and string types. So we can
reduce the space occupied by asn_TYPE_descriptor_t variables.
2017-08-19 17:25:45 +00:00
|
|
|
extern asn_TYPE_operation_t asn_OP_ANY;
|
2016-05-16 05:50:09 +00:00
|
|
|
extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs;
|
2004-09-02 12:11:47 +00:00
|
|
|
|
2004-09-22 16:06:28 +00:00
|
|
|
asn_struct_free_f ANY_free;
|
|
|
|
asn_struct_print_f ANY_print;
|
2004-09-02 12:11:47 +00:00
|
|
|
ber_type_decoder_f ANY_decode_ber;
|
|
|
|
der_type_encoder_f ANY_encode_der;
|
2004-09-22 16:06:28 +00:00
|
|
|
xer_type_encoder_f ANY_encode_xer;
|
2017-08-06 07:59:05 +00:00
|
|
|
per_type_decoder_f ANY_decode_uper;
|
|
|
|
per_type_encoder_f ANY_encode_uper;
|
2004-09-02 12:11:47 +00:00
|
|
|
|
2016-05-16 05:50:09 +00:00
|
|
|
#define ANY_free OCTET_STRING_free
|
|
|
|
#define ANY_print OCTET_STRING_print
|
2017-08-18 16:55:25 +00:00
|
|
|
#define ANY_compare OCTET_STRING_compare
|
2016-05-16 05:50:09 +00:00
|
|
|
#define ANY_constraint asn_generic_no_constraint
|
|
|
|
#define ANY_decode_ber OCTET_STRING_decode_ber
|
|
|
|
#define ANY_encode_der OCTET_STRING_encode_der
|
|
|
|
#define ANY_decode_xer OCTET_STRING_decode_xer_hex
|
|
|
|
|
2004-09-02 12:11:47 +00:00
|
|
|
/******************************
|
|
|
|
* Handy conversion routines. *
|
|
|
|
******************************/
|
|
|
|
|
2004-09-13 08:26:57 +00:00
|
|
|
/* Convert another ASN.1 type into the ANY. This implies DER encoding. */
|
2004-09-29 13:26:15 +00:00
|
|
|
int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr);
|
|
|
|
ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr);
|
2004-09-13 08:26:57 +00:00
|
|
|
|
|
|
|
/* Convert the contents of the ANY type into the specified type. */
|
2004-09-29 13:26:15 +00:00
|
|
|
int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr);
|
2004-09-13 08:26:57 +00:00
|
|
|
|
2004-09-02 12:11:47 +00:00
|
|
|
#define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size))
|
2006-01-25 01:56:58 +00:00
|
|
|
#define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \
|
|
|
|
&asn_DEF_ANY, (buf), (size))
|
2004-09-02 12:11:47 +00:00
|
|
|
|
2005-07-24 09:03:44 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-09-02 12:11:47 +00:00
|
|
|
#endif /* ASN_TYPE_ANY_H */
|