rtypes.rs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #![allow(non_snake_case)]
  2. #![allow(non_camel_case_types)]
  3. use crate::cffi::{self, Iface_t, String_t};
  4. #[repr(C)]
  5. #[derive(Debug, Copy, Clone)]
  6. pub struct RTypes_IfWrapper_t {
  7. pub internal: *mut Iface_t,
  8. pub external: *mut Iface_t,
  9. }
  10. #[repr(C)]
  11. pub struct RTypes_StrList_t {
  12. pub len: usize,
  13. pub items: *mut *mut String_t,
  14. }
  15. #[repr(C)]
  16. #[derive(Copy, Clone, PartialEq, Eq, Debug)]
  17. pub enum RTypes_CryptoAuth_State_t {
  18. /// New CryptoAuth session, has not sent or received anything
  19. Init = 0,
  20. /// Sent a hello message, waiting for reply
  21. SentHello = 1,
  22. /// Received a hello message, have not yet sent a reply
  23. ReceivedHello = 2,
  24. /// Received a hello message, sent a key message, waiting for the session to complete
  25. SentKey = 3,
  26. /// Sent a hello message, received a key message, may or may not have sent some data traffic
  27. /// but no data traffic has yet been received
  28. ReceivedKey = 4,
  29. /// Received data traffic, session is in run state
  30. Established = 100,
  31. }
  32. #[repr(C)]
  33. #[derive(Copy, Clone, PartialEq, Eq, Debug)]
  34. pub struct RTypes_CryptoStats_t {
  35. /// Number of packets which were lost
  36. pub lost_packets: u64,
  37. /// Number of packets which were received but could not be validated
  38. pub received_unexpected: u64,
  39. /// Number of packets which were received (since last session setup)
  40. pub received_packets: u64,
  41. /// Number of packets which were received that were duplicates
  42. pub duplicate_packets: u64,
  43. /// True if the session is using the Noise protocol
  44. pub noise_proto: bool,
  45. }
  46. #[repr(C)]
  47. pub struct RTypes_CryptoAuth2_Session_t {
  48. pub plaintext: *mut cffi::Iface_t,
  49. pub ciphertext: *mut cffi::Iface_t,
  50. }
  51. pub struct RTypes_Error_t {
  52. pub e: Option<anyhow::Error>,
  53. }
  54. #[allow(dead_code)]
  55. #[repr(C)]
  56. pub struct RTypes_ExportMe {
  57. a: RTypes_IfWrapper_t,
  58. b: RTypes_StrList_t,
  59. c: RTypes_CryptoAuth_State_t,
  60. d: RTypes_CryptoStats_t,
  61. e: RTypes_CryptoAuth2_Session_t,
  62. f: *mut RTypes_Error_t,
  63. }