oer_decoder.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (c) 2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  3. * Redistribution and modifications are permitted subject to BSD license.
  4. */
  5. #ifndef OER_DECODER_H
  6. #define OER_DECODER_H
  7. #include <asn_application.h>
  8. #include <oer_support.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. struct asn_TYPE_descriptor_s; /* Forward declaration */
  13. struct asn_codec_ctx_s; /* Forward declaration */
  14. /*
  15. * The Octet Encoding Rules (OER, X.696 08/2015) decoder for any given type.
  16. * This function may be invoked directly by the application.
  17. * Parses CANONICAL-OER and BASIC-OER.
  18. */
  19. asn_dec_rval_t oer_decode(const struct asn_codec_ctx_s *opt_codec_ctx,
  20. const struct asn_TYPE_descriptor_s *type_descriptor,
  21. void **struct_ptr, /* Pointer to a target structure's pointer */
  22. const void *buffer, /* Data to be decoded */
  23. size_t size /* Size of that buffer */
  24. );
  25. /*
  26. * Type of generic function which decodes the byte stream into the structure.
  27. */
  28. typedef asn_dec_rval_t(oer_type_decoder_f)(
  29. const struct asn_codec_ctx_s *opt_codec_ctx,
  30. const struct asn_TYPE_descriptor_s *type_descriptor,
  31. const asn_oer_constraints_t *constraints,
  32. void **struct_ptr,
  33. const void *buf_ptr,
  34. size_t size);
  35. /*
  36. * Swallow the Open Type (X.696 (08/2015), #30) into /dev/null.
  37. * RETURN VALUES:
  38. * -1: Fatal error deciphering length.
  39. * 0: More data expected than bufptr contains.
  40. * >0: Number of bytes used from bufptr.
  41. */
  42. ssize_t oer_open_type_skip(const void *bufptr, size_t size);
  43. /*
  44. * Read the Open Type (X.696 (08/2015), #30).
  45. * RETURN VALUES:
  46. * 0: More data expected than bufptr contains.
  47. * -1: Fatal error deciphering length.
  48. * >0: Number of bytes used from bufptr.
  49. */
  50. ssize_t oer_open_type_get(const asn_codec_ctx_t *opt_codec_ctx,
  51. const struct asn_TYPE_descriptor_s *td,
  52. const asn_oer_constraints_t *constraints,
  53. void **struct_ptr, const void *bufptr, size_t size);
  54. /*
  55. * Length-prefixed buffer decoding for primitive types.
  56. */
  57. oer_type_decoder_f oer_decode_primitive;
  58. #ifdef __cplusplus
  59. }
  60. #endif
  61. #endif /* OER_DECODER_H */