vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 1 | /*- |
| 2 | * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. |
| 3 | * Redistribution and modifications are permitted subject to BSD license. |
| 4 | */ |
| 5 | #ifndef _CONSTR_SET_H_ |
| 6 | #define _CONSTR_SET_H_ |
| 7 | |
| 8 | #include <constr_TYPE.h> |
| 9 | |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 10 | |
| 11 | typedef struct asn1_SET_specifics_s { |
| 12 | /* |
| 13 | * Target structure description. |
| 14 | */ |
| 15 | int struct_size; /* Size of the target structure. */ |
| 16 | int ctx_offset; /* Offset of the ber_dec_ctx_t member */ |
| 17 | int pres_offset; /* Offset of _presence_map member */ |
| 18 | |
| 19 | /* |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 20 | * Tags to members mapping table (sorted). |
| 21 | */ |
vlm | 3147308 | 2004-06-06 07:20:02 +0000 | [diff] [blame] | 22 | asn1_TYPE_tag2member_t *tag2el; |
vlm | fa67ddc | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 23 | int tag2el_count; |
| 24 | |
| 25 | /* |
| 26 | * Extensions-related stuff. |
| 27 | */ |
| 28 | int extensible; /* Whether SET is extensible */ |
| 29 | unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ |
| 30 | } asn1_SET_specifics_t; |
| 31 | |
| 32 | /* |
| 33 | * A set specialized functions dealing with the SET type. |
| 34 | */ |
| 35 | asn_constr_check_f SET_constraint; |
| 36 | ber_type_decoder_f SET_decode_ber; |
| 37 | der_type_encoder_f SET_encode_der; |
| 38 | asn_struct_print_f SET_print; |
| 39 | asn_struct_free_f SET_free; |
| 40 | |
| 41 | /*********************** |
| 42 | * Some handy helpers. * |
| 43 | ***********************/ |
| 44 | |
| 45 | /* |
| 46 | * Figure out whether the SET member indicated by PR_x has already been decoded. |
| 47 | * It is very simple bitfield test, despite its visual complexity. |
| 48 | */ |
| 49 | #define ASN_SET_ISPRESENT(set_ptr, PR_x) \ |
| 50 | ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map)) |
| 51 | #define ASN_SET_ISPRESENT2(map_ptr, PR_x) \ |
| 52 | (((unsigned int *)(map_ptr)) \ |
| 53 | [(PR_x) / (8 * sizeof(unsigned int))] \ |
| 54 | & (1 << ((8 * sizeof(unsigned int)) - 1 \ |
| 55 | - ((PR_x) % (8 * sizeof(unsigned int)))))) |
| 56 | |
| 57 | #define ASN_SET_MKPRESENT(map_ptr, PR_x) \ |
| 58 | (((unsigned int *)(map_ptr)) \ |
| 59 | [(PR_x) / (8 * sizeof(unsigned int))] \ |
| 60 | |= (1 << ((8 * sizeof(unsigned int)) - 1 \ |
| 61 | - ((PR_x) % (8 * sizeof(unsigned int)))))) |
| 62 | |
| 63 | #endif /* _CONSTR_SET_H_ */ |