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