Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 1 | /*- |
| 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 | |
| 11 | typedef 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 | |
| 18 | extern asn1_TYPE_descriptor_t asn1_DEF_ANY; |
| 19 | |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 20 | asn_struct_free_f ANY_free; |
| 21 | asn_struct_print_f ANY_print; |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 22 | ber_type_decoder_f ANY_decode_ber; |
| 23 | der_type_encoder_f ANY_encode_der; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 24 | xer_type_encoder_f ANY_encode_xer; |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 25 | |
| 26 | /****************************** |
| 27 | * Handy conversion routines. * |
| 28 | ******************************/ |
| 29 | |
Lev Walkin | d563d39 | 2004-09-13 08:26:57 +0000 | [diff] [blame] | 30 | /* Convert another ASN.1 type into the ANY. This implies DER encoding. */ |
| 31 | int ANY_fromType(ANY_t *, asn1_TYPE_descriptor_t *td, void *struct_ptr); |
| 32 | ANY_t *ANY_new_fromType(asn1_TYPE_descriptor_t *td, void *struct_ptr); |
| 33 | |
| 34 | /* Convert the contents of the ANY type into the specified type. */ |
| 35 | int ANY_to_type(ANY_t *, asn1_TYPE_descriptor_t *td, void **struct_ptr); |
| 36 | |
Lev Walkin | a737f3b | 2004-09-02 12:11:47 +0000 | [diff] [blame] | 37 | #define ANY_fromBuf(s, buf, size) OCTET_STRING_fromBuf((s), (buf), (size)) |
| 38 | #define ANY_new_fromBuf(buf, size) OCTET_STRING_new_fromBuf((buf), (size)) |
| 39 | |
| 40 | #endif /* ASN_TYPE_ANY_H */ |