blob: d64a00f1af0fc60481b21791536b03d993e84abc [file] [log] [blame]
Lev Walkinf15320b2004-06-03 03:38:44 +00001/*-
Lev Walkin20696a42017-10-17 21:27:33 -07002 * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
Lev Walkinf15320b2004-06-03 03:38:44 +00003 * 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
Lev Walkind84f6032017-10-03 16:33:59 -070015typedef struct asn_SET_specifics_s {
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080016 /*
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 Walkinf15320b2004-06-03 03:38:44 +000022
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080023 /*
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 Walkinf15320b2004-06-03 03:38:44 +000030
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080031 /*
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 Walkind5193802004-10-03 09:12:07 +000037
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080038 /*
39 * Extensions-related stuff.
40 */
41 int extensible; /* Whether SET is extensible */
42 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 Walkincd2f48e2017-08-10 02:14:59 -070050asn_struct_compare_f SET_compare;
Lev Walkinf15320b2004-06-03 03:38:44 +000051asn_constr_check_f SET_constraint;
52ber_type_decoder_f SET_decode_ber;
53der_type_encoder_f SET_encode_der;
Lev Walkin6c0df202005-02-14 19:03:17 +000054xer_type_decoder_f SET_decode_xer;
Lev Walkina9cc46e2004-09-22 16:06:28 +000055xer_type_encoder_f SET_encode_xer;
Lev Walkinadf863f2006-09-05 16:18:34 +000056per_type_decoder_f SET_decode_uper;
57per_type_encoder_f SET_encode_uper;
Lev Walkina5972be2017-09-29 23:15:58 -070058asn_random_fill_f SET_random_fill;
Bi-Ruei, Chiu1f87ac02017-08-20 01:25:45 +080059extern asn_TYPE_operation_t asn_OP_SET;
Lev Walkinf15320b2004-06-03 03:38:44 +000060
61/***********************
62 * Some handy helpers. *
63 ***********************/
64
65/*
66 * Figure out whether the SET member indicated by PR_x has already been decoded.
67 * It is very simple bitfield test, despite its visual complexity.
68 */
69#define ASN_SET_ISPRESENT(set_ptr, PR_x) \
Lev Walkin57dabf12005-07-08 18:36:51 +000070 ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map), PR_x)
Lev Walkinf15320b2004-06-03 03:38:44 +000071#define ASN_SET_ISPRESENT2(map_ptr, PR_x) \
72 (((unsigned int *)(map_ptr)) \
73 [(PR_x) / (8 * sizeof(unsigned int))] \
Lev Walkin547973d2017-09-18 00:11:01 -070074 & (1u << ((8 * sizeof(unsigned int)) - 1 \
Lev Walkinf15320b2004-06-03 03:38:44 +000075 - ((PR_x) % (8 * sizeof(unsigned int))))))
76
77#define ASN_SET_MKPRESENT(map_ptr, PR_x) \
78 (((unsigned int *)(map_ptr)) \
79 [(PR_x) / (8 * sizeof(unsigned int))] \
Lev Walkin547973d2017-09-18 00:11:01 -070080 |= (1u << ((8 * sizeof(unsigned int)) - 1 \
Lev Walkinf15320b2004-06-03 03:38:44 +000081 - ((PR_x) % (8 * sizeof(unsigned int))))))
82
Lev Walkin21b41ac2005-07-24 09:03:44 +000083#ifdef __cplusplus
84}
85#endif
86
Lev Walkinf15320b2004-06-03 03:38:44 +000087#endif /* _CONSTR_SET_H_ */