blob: 11b7153e2d3f1911412c3e3a7d7b28e79523ad3a [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 Walkin21b41ac2005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
Lev Walkinf15320b2004-06-03 03:38:44 +000014
Wim Lewisfb6344e2014-07-28 12:16:01 -070015typedef const struct asn_SET_specifics_s {
Lev Walkinf15320b2004-06-03 03:38:44 +000016 /*
17 * Target structure description.
18 */
19 int struct_size; /* Size of the target structure. */
Lev Walkin5e033762004-09-29 13:26:15 +000020 int ctx_offset; /* Offset of the asn_struct_ctx_t member */
Lev Walkinf15320b2004-06-03 03:38:44 +000021 int pres_offset; /* Offset of _presence_map member */
22
23 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000024 * Tags to members mapping table (sorted).
Lev Walkind5193802004-10-03 09:12:07 +000025 * Sometimes suitable for DER encoding (untagged CHOICE is present);
26 * if so, tag2el_count will be greater than td->elements_count.
Lev Walkinf15320b2004-06-03 03:38:44 +000027 */
Wim Lewisfb6344e2014-07-28 12:16:01 -070028 const asn_TYPE_tag2member_t *tag2el;
Lev Walkinf15320b2004-06-03 03:38:44 +000029 int tag2el_count;
30
31 /*
Lev Walkind5193802004-10-03 09:12:07 +000032 * Tags to members mapping table, second edition.
33 * Suitable for CANONICAL-XER encoding.
34 */
Wim Lewisfb6344e2014-07-28 12:16:01 -070035 const asn_TYPE_tag2member_t *tag2el_cxer;
Lev Walkind5193802004-10-03 09:12:07 +000036 int tag2el_cxer_count;
37
38 /*
Lev Walkinf15320b2004-06-03 03:38:44 +000039 * Extensions-related stuff.
40 */
41 int extensible; /* Whether SET is extensible */
Wim Lewisfb6344e2014-07-28 12:16:01 -070042 const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */
Lev Walkin5e033762004-09-29 13:26:15 +000043} asn_SET_specifics_t;
Lev Walkinf15320b2004-06-03 03:38:44 +000044
45/*
46 * A set specialized functions dealing with the SET type.
47 */
Lev Walkina9cc46e2004-09-22 16:06:28 +000048asn_struct_free_f SET_free;
49asn_struct_print_f SET_print;
Lev Walkinf15320b2004-06-03 03:38:44 +000050asn_constr_check_f SET_constraint;
51ber_type_decoder_f SET_decode_ber;
52der_type_encoder_f SET_encode_der;
Lev Walkin6c0df202005-02-14 19:03:17 +000053xer_type_decoder_f SET_decode_xer;
Lev Walkina9cc46e2004-09-22 16:06:28 +000054xer_type_encoder_f SET_encode_xer;
Lev Walkinadf863f2006-09-05 16:18:34 +000055per_type_decoder_f SET_decode_uper;
Harald Welte0b57b082015-08-30 16:33:07 +020056per_type_decoder_f SET_decode_aper;
Lev Walkinadf863f2006-09-05 16:18:34 +000057per_type_encoder_f SET_encode_uper;
Harald Welte0b57b082015-08-30 16:33:07 +020058per_type_encoder_f SET_encode_aper;
Lev Walkinf15320b2004-06-03 03:38:44 +000059
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 Walkin57dabf12005-07-08 18:36:51 +000069 ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map), PR_x)
Lev Walkinf15320b2004-06-03 03:38:44 +000070#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 Walkin21b41ac2005-07-24 09:03:44 +000082#ifdef __cplusplus
83}
84#endif
85
Lev Walkinf15320b2004-06-03 03:38:44 +000086#endif /* _CONSTR_SET_H_ */