Lev Walkin | f15320b | 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 | |
Lev Walkin | 11c3e17 | 2004-09-24 21:00:50 +0000 | [diff] [blame] | 8 | #include <asn_application.h> |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 9 | |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 10 | |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 11 | typedef struct asn_SET_specifics_s { |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 12 | /* |
| 13 | * Target structure description. |
| 14 | */ |
| 15 | int struct_size; /* Size of the target structure. */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 16 | int ctx_offset; /* Offset of the asn_struct_ctx_t member */ |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 17 | int pres_offset; /* Offset of _presence_map member */ |
| 18 | |
| 19 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 20 | * Tags to members mapping table (sorted). |
Lev Walkin | d519380 | 2004-10-03 09:12:07 +0000 | [diff] [blame] | 21 | * Sometimes suitable for DER encoding (untagged CHOICE is present); |
| 22 | * if so, tag2el_count will be greater than td->elements_count. |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 23 | */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 24 | asn_TYPE_tag2member_t *tag2el; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 25 | int tag2el_count; |
| 26 | |
| 27 | /* |
Lev Walkin | d519380 | 2004-10-03 09:12:07 +0000 | [diff] [blame] | 28 | * Tags to members mapping table, second edition. |
| 29 | * Suitable for CANONICAL-XER encoding. |
| 30 | */ |
| 31 | asn_TYPE_tag2member_t *tag2el_cxer; |
| 32 | int tag2el_cxer_count; |
| 33 | |
| 34 | /* |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 35 | * Extensions-related stuff. |
| 36 | */ |
| 37 | int extensible; /* Whether SET is extensible */ |
| 38 | unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */ |
Lev Walkin | 5e03376 | 2004-09-29 13:26:15 +0000 | [diff] [blame] | 39 | } asn_SET_specifics_t; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * A set specialized functions dealing with the SET type. |
| 43 | */ |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 44 | asn_struct_free_f SET_free; |
| 45 | asn_struct_print_f SET_print; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 46 | asn_constr_check_f SET_constraint; |
| 47 | ber_type_decoder_f SET_decode_ber; |
| 48 | der_type_encoder_f SET_encode_der; |
Lev Walkin | 6c0df20 | 2005-02-14 19:03:17 +0000 | [diff] [blame] | 49 | xer_type_decoder_f SET_decode_xer; |
Lev Walkin | a9cc46e | 2004-09-22 16:06:28 +0000 | [diff] [blame] | 50 | xer_type_encoder_f SET_encode_xer; |
Lev Walkin | f15320b | 2004-06-03 03:38:44 +0000 | [diff] [blame] | 51 | |
| 52 | /*********************** |
| 53 | * Some handy helpers. * |
| 54 | ***********************/ |
| 55 | |
| 56 | /* |
| 57 | * Figure out whether the SET member indicated by PR_x has already been decoded. |
| 58 | * It is very simple bitfield test, despite its visual complexity. |
| 59 | */ |
| 60 | #define ASN_SET_ISPRESENT(set_ptr, PR_x) \ |
| 61 | ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map)) |
| 62 | #define ASN_SET_ISPRESENT2(map_ptr, PR_x) \ |
| 63 | (((unsigned int *)(map_ptr)) \ |
| 64 | [(PR_x) / (8 * sizeof(unsigned int))] \ |
| 65 | & (1 << ((8 * sizeof(unsigned int)) - 1 \ |
| 66 | - ((PR_x) % (8 * sizeof(unsigned int)))))) |
| 67 | |
| 68 | #define ASN_SET_MKPRESENT(map_ptr, PR_x) \ |
| 69 | (((unsigned int *)(map_ptr)) \ |
| 70 | [(PR_x) / (8 * sizeof(unsigned int))] \ |
| 71 | |= (1 << ((8 * sizeof(unsigned int)) - 1 \ |
| 72 | - ((PR_x) % (8 * sizeof(unsigned int)))))) |
| 73 | |
| 74 | #endif /* _CONSTR_SET_H_ */ |