blob: 41d6a7fb9fc2cc46e4b4fb01bcfb1c05d64dca72 [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
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 Walkin11c3e172004-09-24 21:00:50 +00008#include <asn_application.h>
Lev Walkinf15320b2004-06-03 03:38:44 +00009
Lev Walkinf15320b2004-06-03 03:38:44 +000010
Lev Walkin5e033762004-09-29 13:26:15 +000011typedef struct asn_SET_specifics_s {
Lev Walkinf15320b2004-06-03 03:38:44 +000012 /*
13 * Target structure description.
14 */
15 int struct_size; /* Size of the target structure. */
Lev Walkin5e033762004-09-29 13:26:15 +000016 int ctx_offset; /* Offset of the asn_struct_ctx_t member */
Lev Walkinf15320b2004-06-03 03:38:44 +000017 int pres_offset; /* Offset of _presence_map member */
18
19 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000020 * Tags to members mapping table (sorted).
Lev Walkind5193802004-10-03 09:12:07 +000021 * Sometimes suitable for DER encoding (untagged CHOICE is present);
22 * if so, tag2el_count will be greater than td->elements_count.
Lev Walkinf15320b2004-06-03 03:38:44 +000023 */
Lev Walkin5e033762004-09-29 13:26:15 +000024 asn_TYPE_tag2member_t *tag2el;
Lev Walkinf15320b2004-06-03 03:38:44 +000025 int tag2el_count;
26
27 /*
Lev Walkind5193802004-10-03 09:12:07 +000028 * 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 Walkinf15320b2004-06-03 03:38:44 +000035 * Extensions-related stuff.
36 */
37 int extensible; /* Whether SET is extensible */
38 unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */
Lev Walkin5e033762004-09-29 13:26:15 +000039} asn_SET_specifics_t;
Lev Walkinf15320b2004-06-03 03:38:44 +000040
41/*
42 * A set specialized functions dealing with the SET type.
43 */
Lev Walkina9cc46e2004-09-22 16:06:28 +000044asn_struct_free_f SET_free;
45asn_struct_print_f SET_print;
Lev Walkinf15320b2004-06-03 03:38:44 +000046asn_constr_check_f SET_constraint;
47ber_type_decoder_f SET_decode_ber;
48der_type_encoder_f SET_encode_der;
Lev Walkina9cc46e2004-09-22 16:06:28 +000049xer_type_encoder_f SET_encode_xer;
Lev Walkinf15320b2004-06-03 03:38:44 +000050
51/***********************
52 * Some handy helpers. *
53 ***********************/
54
55/*
56 * Figure out whether the SET member indicated by PR_x has already been decoded.
57 * It is very simple bitfield test, despite its visual complexity.
58 */
59#define ASN_SET_ISPRESENT(set_ptr, PR_x) \
60 ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map))
61#define ASN_SET_ISPRESENT2(map_ptr, PR_x) \
62 (((unsigned int *)(map_ptr)) \
63 [(PR_x) / (8 * sizeof(unsigned int))] \
64 & (1 << ((8 * sizeof(unsigned int)) - 1 \
65 - ((PR_x) % (8 * sizeof(unsigned int))))))
66
67#define ASN_SET_MKPRESENT(map_ptr, PR_x) \
68 (((unsigned int *)(map_ptr)) \
69 [(PR_x) / (8 * sizeof(unsigned int))] \
70 |= (1 << ((8 * sizeof(unsigned int)) - 1 \
71 - ((PR_x) % (8 * sizeof(unsigned int))))))
72
73#endif /* _CONSTR_SET_H_ */