per_decoder.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*-
  2. * Copyright (c) 2005-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  3. * Redistribution and modifications are permitted subject to BSD license.
  4. */
  5. #ifndef _PER_DECODER_H_
  6. #define _PER_DECODER_H_
  7. #include <asn_application.h>
  8. #include <per_support.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. struct asn_TYPE_descriptor_s; /* Forward declaration */
  13. /*
  14. * Unaligned PER decoder of a "complete encoding" as per X.691 (08/2015) #11.1.
  15. * On success, this call always returns (.consumed >= 1), as per #11.1.3.
  16. */
  17. asn_dec_rval_t uper_decode_complete(
  18. const struct asn_codec_ctx_s *opt_codec_ctx,
  19. const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
  20. void **struct_ptr, /* Pointer to a target structure's pointer */
  21. const void *buffer, /* Data to be decoded */
  22. size_t size /* Size of data buffer */
  23. );
  24. /*
  25. * Unaligned PER decoder of any ASN.1 type. May be invoked by the application.
  26. * WARNING: This call returns the number of BITS read from the stream. Beware.
  27. */
  28. asn_dec_rval_t uper_decode(
  29. const struct asn_codec_ctx_s *opt_codec_ctx,
  30. const struct asn_TYPE_descriptor_s *type_descriptor, /* Type to decode */
  31. void **struct_ptr, /* Pointer to a target structure's pointer */
  32. const void *buffer, /* Data to be decoded */
  33. size_t size, /* Size of the input data buffer, in bytes */
  34. int skip_bits, /* Number of unused leading bits, 0..7 */
  35. int unused_bits /* Number of unused tailing bits, 0..7 */
  36. );
  37. /*
  38. * Type of the type-specific PER decoder function.
  39. */
  40. typedef asn_dec_rval_t(per_type_decoder_f)(
  41. const asn_codec_ctx_t *opt_codec_ctx,
  42. const struct asn_TYPE_descriptor_s *type_descriptor,
  43. const asn_per_constraints_t *constraints, void **struct_ptr,
  44. asn_per_data_t *per_data);
  45. #ifdef __cplusplus
  46. }
  47. #endif
  48. #endif /* _PER_DECODER_H_ */