sendme.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* Copyright (c) 2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file sendme.h
  5. * \brief Header file for sendme.c.
  6. **/
  7. #ifndef TOR_SENDME_H
  8. #define TOR_SENDME_H
  9. #include "core/or/edge_connection_st.h"
  10. #include "core/or/crypt_path_st.h"
  11. #include "core/or/circuit_st.h"
  12. /* Sending SENDME cell. */
  13. void sendme_connection_edge_consider_sending(edge_connection_t *edge_conn);
  14. void sendme_circuit_consider_sending(circuit_t *circ,
  15. crypt_path_t *layer_hint);
  16. /* Processing SENDME cell. */
  17. int sendme_process_circuit_level(crypt_path_t *layer_hint,
  18. circuit_t *circ, const uint8_t *cell_payload,
  19. uint16_t cell_payload_len);
  20. int sendme_process_stream_level(edge_connection_t *conn, circuit_t *circ,
  21. uint16_t cell_body_len);
  22. /* Update deliver window functions. */
  23. int sendme_stream_data_received(edge_connection_t *conn);
  24. int sendme_circuit_data_received(circuit_t *circ, crypt_path_t *layer_hint);
  25. /* Update package window functions. */
  26. int sendme_note_circuit_data_packaged(circuit_t *circ,
  27. crypt_path_t *layer_hint);
  28. int sendme_note_stream_data_packaged(edge_connection_t *conn);
  29. /* Record cell digest on circuit. */
  30. void sendme_record_cell_digest_on_circ(circuit_t *circ, crypt_path_t *cpath);
  31. /* Record cell digest as the SENDME digest. */
  32. void sendme_record_received_cell_digest(circuit_t *circ, crypt_path_t *cpath);
  33. void sendme_record_sending_cell_digest(circuit_t *circ, crypt_path_t *cpath);
  34. /* Private section starts. */
  35. #ifdef SENDME_PRIVATE
  36. /* The maximum supported version. Above that value, the cell can't be
  37. * recognized as a valid SENDME. */
  38. #define SENDME_MAX_SUPPORTED_VERSION 1
  39. /* The cell version constants for when emitting a cell. */
  40. #define SENDME_EMIT_MIN_VERSION_DEFAULT 0
  41. #define SENDME_EMIT_MIN_VERSION_MIN 0
  42. #define SENDME_EMIT_MIN_VERSION_MAX UINT8_MAX
  43. /* The cell version constants for when accepting a cell. */
  44. #define SENDME_ACCEPT_MIN_VERSION_DEFAULT 0
  45. #define SENDME_ACCEPT_MIN_VERSION_MIN 0
  46. #define SENDME_ACCEPT_MIN_VERSION_MAX UINT8_MAX
  47. /*
  48. * Unit tests declaractions.
  49. */
  50. #ifdef TOR_UNIT_TESTS
  51. STATIC int get_emit_min_version(void);
  52. STATIC int get_accept_min_version(void);
  53. STATIC bool cell_version_can_be_handled(uint8_t cell_version);
  54. STATIC ssize_t build_cell_payload_v1(const uint8_t *cell_digest,
  55. uint8_t *payload);
  56. STATIC bool sendme_is_valid(const circuit_t *circ,
  57. const uint8_t *cell_payload,
  58. size_t cell_payload_len);
  59. #endif /* defined(TOR_UNIT_TESTS) */
  60. #endif /* defined(SENDME_PRIVATE) */
  61. #endif /* !defined(TOR_SENDME_H) */