blob: 8f9b265cb46beb7f9c76c9d32cda6421757dadeb [file] [log] [blame]
vlmfa67ddc2004-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
vlmd1579582004-09-24 21:00:50 +00008#include <asn_application.h>
vlmfa67ddc2004-06-03 03:38:44 +00009
vlmfa67ddc2004-06-03 03:38:44 +000010
vlmef6355b2004-09-29 13:26:15 +000011typedef struct asn_SET_specifics_s {
vlmfa67ddc2004-06-03 03:38:44 +000012 /*
13 * Target structure description.
14 */
15 int struct_size; /* Size of the target structure. */
vlmef6355b2004-09-29 13:26:15 +000016 int ctx_offset; /* Offset of the asn_struct_ctx_t member */
vlmfa67ddc2004-06-03 03:38:44 +000017 int pres_offset; /* Offset of _presence_map member */
18
19 /*
vlmfa67ddc2004-06-03 03:38:44 +000020 * Tags to members mapping table (sorted).
21 */
vlmef6355b2004-09-29 13:26:15 +000022 asn_TYPE_tag2member_t *tag2el;
vlmfa67ddc2004-06-03 03:38:44 +000023 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 */
vlmef6355b2004-09-29 13:26:15 +000030} asn_SET_specifics_t;
vlmfa67ddc2004-06-03 03:38:44 +000031
32/*
33 * A set specialized functions dealing with the SET type.
34 */
vlm39ba4c42004-09-22 16:06:28 +000035asn_struct_free_f SET_free;
36asn_struct_print_f SET_print;
vlmfa67ddc2004-06-03 03:38:44 +000037asn_constr_check_f SET_constraint;
38ber_type_decoder_f SET_decode_ber;
39der_type_encoder_f SET_encode_der;
vlm39ba4c42004-09-22 16:06:28 +000040xer_type_encoder_f SET_encode_xer;
vlmfa67ddc2004-06-03 03:38:44 +000041
42/***********************
43 * Some handy helpers. *
44 ***********************/
45
46/*
47 * Figure out whether the SET member indicated by PR_x has already been decoded.
48 * It is very simple bitfield test, despite its visual complexity.
49 */
50#define ASN_SET_ISPRESENT(set_ptr, PR_x) \
51 ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map))
52#define ASN_SET_ISPRESENT2(map_ptr, PR_x) \
53 (((unsigned int *)(map_ptr)) \
54 [(PR_x) / (8 * sizeof(unsigned int))] \
55 & (1 << ((8 * sizeof(unsigned int)) - 1 \
56 - ((PR_x) % (8 * sizeof(unsigned int))))))
57
58#define ASN_SET_MKPRESENT(map_ptr, PR_x) \
59 (((unsigned int *)(map_ptr)) \
60 [(PR_x) / (8 * sizeof(unsigned int))] \
61 |= (1 << ((8 * sizeof(unsigned int)) - 1 \
62 - ((PR_x) % (8 * sizeof(unsigned int))))))
63
64#endif /* _CONSTR_SET_H_ */