asn_codecs_prim.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*-
  2. * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
  3. * Redistribution and modifications are permitted subject to BSD license.
  4. */
  5. #ifndef ASN_CODECS_PRIM_H
  6. #define ASN_CODECS_PRIM_H
  7. #include <asn_application.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. typedef struct ASN__PRIMITIVE_TYPE_s {
  12. uint8_t *buf; /* Buffer with consecutive primitive encoding bytes */
  13. size_t size; /* Size of the buffer */
  14. } ASN__PRIMITIVE_TYPE_t; /* Do not use this type directly! */
  15. asn_struct_free_f ASN__PRIMITIVE_TYPE_free;
  16. ber_type_decoder_f ber_decode_primitive;
  17. der_type_encoder_f der_encode_primitive;
  18. /*
  19. * A callback specification for the xer_decode_primitive() function below.
  20. */
  21. enum xer_pbd_rval {
  22. XPBD_SYSTEM_FAILURE, /* System failure (memory shortage, etc) */
  23. XPBD_DECODER_LIMIT, /* Hit some decoder limitation or deficiency */
  24. XPBD_BROKEN_ENCODING, /* Encoding of a primitive body is broken */
  25. XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */
  26. XPBD_BODY_CONSUMED /* Body is recognized and consumed */
  27. };
  28. typedef enum xer_pbd_rval(xer_primitive_body_decoder_f)(
  29. const asn_TYPE_descriptor_t *td, void *struct_ptr, const void *chunk_buf,
  30. size_t chunk_size);
  31. /*
  32. * Specific function to decode simple primitive types.
  33. * Also see xer_decode_general() in xer_decoder.h
  34. */
  35. asn_dec_rval_t xer_decode_primitive(
  36. const asn_codec_ctx_t *opt_codec_ctx,
  37. const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
  38. size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size,
  39. xer_primitive_body_decoder_f *prim_body_decoder);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* ASN_CODECS_PRIM_H */