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