ocirc_event.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (c) 2007-2019, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file ocirc_event.h
  5. * \brief Header file for ocirc_event.c
  6. **/
  7. #ifndef TOR_OCIRC_EVENT_H
  8. #define TOR_OCIRC_EVENT_H
  9. #include <stdbool.h>
  10. #include "lib/cc/torint.h"
  11. #include "lib/pubsub/pubsub.h"
  12. /** Used to indicate the type of a circuit event passed to the controller.
  13. * The various types are defined in control-spec.txt */
  14. typedef enum circuit_status_event_t {
  15. CIRC_EVENT_LAUNCHED = 0,
  16. CIRC_EVENT_BUILT = 1,
  17. CIRC_EVENT_EXTENDED = 2,
  18. CIRC_EVENT_FAILED = 3,
  19. CIRC_EVENT_CLOSED = 4,
  20. } circuit_status_event_t;
  21. /** Message for origin circuit state update */
  22. typedef struct ocirc_state_msg_t {
  23. uint32_t gid; /**< global ID (only origin circuits have them) */
  24. int state; /**< new circuit state */
  25. bool onehop; /**< one-hop circuit? */
  26. } ocirc_state_msg_t;
  27. DECLARE_MESSAGE(ocirc_state, ocirc_state, ocirc_state_msg_t *);
  28. /**
  29. * Message when a channel gets associated to a circuit.
  30. *
  31. * This doesn't always correspond to something in circuitbuild.c
  32. * setting the n_chan field in the circuit. For some reason, if
  33. * circuit_handle_first_hop() launches a new circuit, it doesn't set
  34. * the n_chan field.
  35. */
  36. typedef struct ocirc_chan_msg_t {
  37. uint32_t gid; /**< global ID */
  38. uint64_t chan; /**< channel ID */
  39. bool onehop; /**< one-hop circuit? */
  40. } ocirc_chan_msg_t;
  41. DECLARE_MESSAGE(ocirc_chan, ocirc_chan, ocirc_chan_msg_t *);
  42. /**
  43. * Message for origin circuit status event
  44. *
  45. * This contains information that ends up in CIRC control protocol events.
  46. */
  47. typedef struct ocirc_cevent_msg_t {
  48. uint32_t gid; /**< global ID */
  49. int evtype; /**< event type */
  50. int reason; /**< reason */
  51. bool onehop; /**< one-hop circuit? */
  52. } ocirc_cevent_msg_t;
  53. DECLARE_MESSAGE(ocirc_cevent, ocirc_cevent, ocirc_cevent_msg_t *);
  54. #ifdef OCIRC_EVENT_PRIVATE
  55. void ocirc_state_publish(ocirc_state_msg_t *msg);
  56. void ocirc_chan_publish(ocirc_chan_msg_t *msg);
  57. void ocirc_cevent_publish(ocirc_cevent_msg_t *msg);
  58. #endif
  59. #endif /* !defined(TOR_OCIRC_EVENT_H) */