constr_SET.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*-
  2. * Copyright (c) 2003-2017 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. #include <asn_application.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct asn_SET_specifics_s {
  12. /*
  13. * Target structure description.
  14. */
  15. unsigned struct_size; /* Size of the target structure. */
  16. unsigned ctx_offset; /* Offset of the asn_struct_ctx_t member */
  17. unsigned pres_offset; /* Offset of _presence_map member */
  18. /*
  19. * Tags to members mapping table (sorted).
  20. * Sometimes suitable for DER encoding (untagged CHOICE is present);
  21. * if so, tag2el_count will be greater than td->elements_count.
  22. */
  23. const asn_TYPE_tag2member_t *tag2el;
  24. unsigned tag2el_count;
  25. /*
  26. * Tags to members mapping table, second edition.
  27. * Suitable for CANONICAL-XER encoding.
  28. */
  29. const asn_TYPE_tag2member_t *tag2el_cxer;
  30. unsigned tag2el_cxer_count;
  31. /*
  32. * Extensions-related stuff.
  33. */
  34. int extensible; /* Whether SET is extensible */
  35. const unsigned int *_mandatory_elements; /* Bitmask of mandatory ones */
  36. } asn_SET_specifics_t;
  37. /*
  38. * A set specialized functions dealing with the SET type.
  39. */
  40. asn_struct_free_f SET_free;
  41. asn_struct_print_f SET_print;
  42. asn_struct_compare_f SET_compare;
  43. asn_constr_check_f SET_constraint;
  44. ber_type_decoder_f SET_decode_ber;
  45. der_type_encoder_f SET_encode_der;
  46. xer_type_decoder_f SET_decode_xer;
  47. xer_type_encoder_f SET_encode_xer;
  48. per_type_decoder_f SET_decode_uper;
  49. per_type_encoder_f SET_encode_uper;
  50. asn_random_fill_f SET_random_fill;
  51. extern asn_TYPE_operation_t asn_OP_SET;
  52. /***********************
  53. * Some handy helpers. *
  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), PR_x)
  61. #define ASN_SET_ISPRESENT2(map_ptr, PR_x) \
  62. (((unsigned int *)(map_ptr)) \
  63. [(PR_x) / (8 * sizeof(unsigned int))] \
  64. & (1u << ((8 * sizeof(unsigned int)) - 1 \
  65. - ((PR_x) % (8 * sizeof(unsigned int))))))
  66. #define ASN_SET_MKPRESENT(map_ptr, PR_x) \
  67. (((unsigned int *)(map_ptr)) \
  68. [(PR_x) / (8 * sizeof(unsigned int))] \
  69. |= (1u << ((8 * sizeof(unsigned int)) - 1 \
  70. - ((PR_x) % (8 * sizeof(unsigned int))))))
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* _CONSTR_SET_H_ */