Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 1 | /*- |
Lev Walkin | 20696a4 | 2017-10-17 21:27:33 -0700 | [diff] [blame] | 2 | * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved. |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 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 Walkin | bbd9325 | 2004-10-12 05:57:23 +0000 | [diff] [blame] | 8 | #include <OCTET_STRING.h> /* Implemented via OCTET STRING type */ |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 9 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 10 | #ifdef __cplusplus |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 14 | typedef struct ANY { |
| 15 | uint8_t *buf; /* BER-encoded ANY contents */ |
| 16 | int size; /* Size of the above buffer */ |
| 17 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 18 | asn_struct_ctx_t _asn_ctx; /* Parsing across buffer boundaries */ |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 19 | } ANY_t; |
| 20 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 21 | extern asn_TYPE_descriptor_t asn_DEF_ANY; |
Bi-Ruei, Chiu | 1f87ac0 | 2017-08-20 01:25:45 +0800 | [diff] [blame] | 22 | extern asn_TYPE_operation_t asn_OP_ANY; |
Bi-Ruei, Chiu | 1fa31c9 | 2016-05-16 13:50:09 +0800 | [diff] [blame] | 23 | extern asn_OCTET_STRING_specifics_t asn_SPC_ANY_specs; |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 24 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 25 | asn_struct_free_f ANY_free; |
| 26 | asn_struct_print_f ANY_print; |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 27 | ber_type_decoder_f ANY_decode_ber; |
| 28 | der_type_encoder_f ANY_encode_der; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 29 | xer_type_encoder_f ANY_encode_xer; |
Lev Walkin | 6bd4b29 | 2017-08-06 00:59:05 -0700 | [diff] [blame] | 30 | per_type_decoder_f ANY_decode_uper; |
| 31 | per_type_encoder_f ANY_encode_uper; |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 32 | |
Bi-Ruei, Chiu | 1fa31c9 | 2016-05-16 13:50:09 +0800 | [diff] [blame] | 33 | #define ANY_free OCTET_STRING_free |
| 34 | #define ANY_print OCTET_STRING_print |
Bi-Ruei, Chiu | e1bf219 | 2017-08-19 00:55:25 +0800 | [diff] [blame] | 35 | #define ANY_compare OCTET_STRING_compare |
Bi-Ruei, Chiu | 1fa31c9 | 2016-05-16 13:50:09 +0800 | [diff] [blame] | 36 | #define ANY_constraint asn_generic_no_constraint |
| 37 | #define ANY_decode_ber OCTET_STRING_decode_ber |
| 38 | #define ANY_encode_der OCTET_STRING_encode_der |
| 39 | #define ANY_decode_xer OCTET_STRING_decode_xer_hex |
| 40 | |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 41 | /****************************** |
| 42 | * Handy conversion routines. * |
| 43 | ******************************/ |
| 44 | |
Lev Walkin | d563d39 | 2004-09-13 08:26:57 +0000 | [diff] [blame] | 45 | /* Convert another ASN.1 type into the ANY. This implies DER encoding. */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 46 | int ANY_fromType(ANY_t *, asn_TYPE_descriptor_t *td, void *struct_ptr); |
| 47 | ANY_t *ANY_new_fromType(asn_TYPE_descriptor_t *td, void *struct_ptr); |
Lev Walkin | d563d39 | 2004-09-13 08:26:57 +0000 | [diff] [blame] | 48 | |
| 49 | /* Convert the contents of the ANY type into the specified type. */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 50 | int ANY_to_type(ANY_t *, asn_TYPE_descriptor_t *td, void **struct_ptr); |
Lev Walkin | d563d39 | 2004-09-13 08:26:57 +0000 | [diff] [blame] | 51 | |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 52 | #define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size)) |
Lev Walkin | fc6a349 | 2006-01-25 01:56:58 +0000 | [diff] [blame] | 53 | #define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf( \ |
| 54 | &asn_DEF_ANY, (buf), (size)) |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 55 | |
Lev Walkin | 21b41ac | 2005-07-24 09:03:44 +0000 | [diff] [blame] | 56 | #ifdef __cplusplus |
| 57 | } |
| 58 | #endif |
| 59 | |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 60 | #endif /* ASN_TYPE_ANY_H */ |