blob: 11b7153e2d3f1911412c3e3a7d7b28e79523ad3a [file] [log] [blame]
Harald Welte92c45f32010-06-12 18:59:38 +02001/*-
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
8#include <asn_application.h>
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14
Harald Welte41b85d52015-08-31 08:56:53 +020015typedef const struct asn_SET_specifics_s {
Harald Welte92c45f32010-06-12 18:59:38 +020016 /*
17 * Target structure description.
18 */
19 int struct_size; /* Size of the target structure. */
20 int ctx_offset; /* Offset of the asn_struct_ctx_t member */
21 int pres_offset; /* Offset of _presence_map member */
22
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 */
Harald Welte41b85d52015-08-31 08:56:53 +020028 const asn_TYPE_tag2member_t *tag2el;
Harald Welte92c45f32010-06-12 18:59:38 +020029 int tag2el_count;
30
31 /*
32 * Tags to members mapping table, second edition.
33 * Suitable for CANONICAL-XER encoding.
34 */
Harald Welte41b85d52015-08-31 08:56:53 +020035 const asn_TYPE_tag2member_t *tag2el_cxer;
Harald Welte92c45f32010-06-12 18:59:38 +020036 int tag2el_cxer_count;
37
38 /*
39 * Extensions-related stuff.
40 */
41 int extensible; /* Whether SET is extensible */
Harald Welte41b85d52015-08-31 08:56:53 +020042 const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */
Harald Welte92c45f32010-06-12 18:59:38 +020043} asn_SET_specifics_t;
44
45/*
46 * A set specialized functions dealing with the SET type.
47 */
48asn_struct_free_f SET_free;
49asn_struct_print_f SET_print;
50asn_constr_check_f SET_constraint;
51ber_type_decoder_f SET_decode_ber;
52der_type_encoder_f SET_encode_der;
53xer_type_decoder_f SET_decode_xer;
54xer_type_encoder_f SET_encode_xer;
55per_type_decoder_f SET_decode_uper;
Harald Welte41b85d52015-08-31 08:56:53 +020056per_type_decoder_f SET_decode_aper;
Harald Welte92c45f32010-06-12 18:59:38 +020057per_type_encoder_f SET_encode_uper;
Harald Welte41b85d52015-08-31 08:56:53 +020058per_type_encoder_f SET_encode_aper;
Harald Welte92c45f32010-06-12 18:59:38 +020059
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) \
69 ASN_SET_ISPRESENT2(&((set_ptr)->_presence_map), PR_x)
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
82#ifdef __cplusplus
83}
84#endif
85
86#endif /* _CONSTR_SET_H_ */