oer_support.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_SUPPORT_H
  6. #define OER_SUPPORT_H
  7. #include <asn_system.h> /* Platform-specific types */
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /*
  12. * Pre-computed OER constraints.
  13. */
  14. typedef struct asn_oer_constraint_number_s {
  15. unsigned width; /* ±8,4,2,1 fixed bytes */
  16. unsigned positive; /* 1 for unsigned number, 0 for signed */
  17. } asn_oer_constraint_number_t;
  18. typedef struct asn_oer_constraints_s {
  19. asn_oer_constraint_number_t value;
  20. ssize_t size; /* -1 (no constraint) or >= 0 */
  21. } asn_oer_constraints_t;
  22. /*
  23. * Fetch the length determinant (X.696 (08/2015), #8.6) into *len_r.
  24. * RETURN VALUES:
  25. * 0: More data expected than bufptr contains.
  26. * -1: Fatal error deciphering length.
  27. * >0: Number of bytes used from bufptr.
  28. */
  29. ssize_t oer_fetch_length(const void *bufptr, size_t size, size_t *len_r);
  30. /*
  31. * Serialize OER length. Returns the number of bytes serialized
  32. * or -1 if a given callback returned with negative result.
  33. */
  34. ssize_t oer_serialize_length(size_t length, asn_app_consume_bytes_f *cb, void *app_key);
  35. #ifdef __cplusplus
  36. }
  37. #endif
  38. #endif /* OER_SUPPORT_H */