Merge branch 'maint-0.4.8'
[tor.git] / src / core / or / ocirc_event.h
blobe9a98929e1cce36933cf33ebbffd09c44602c9a4
1 /* Copyright (c) 2007-2021, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
4 /**
5 * \file ocirc_event.h
6 * \brief Header file for ocirc_event.c
7 **/
9 #ifndef TOR_OCIRC_EVENT_H
10 #define TOR_OCIRC_EVENT_H
12 #include <stdbool.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,
21 CIRC_EVENT_BUILT = 1,
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? */
32 } ocirc_state_msg_t;
34 DECLARE_MESSAGE(ocirc_state, ocirc_state, ocirc_state_msg_t *);
36 /**
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
42 * the n_chan field.
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? */
48 } ocirc_chan_msg_t;
50 DECLARE_MESSAGE(ocirc_chan, ocirc_chan, ocirc_chan_msg_t *);
52 /**
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? */
62 } ocirc_cevent_msg_t;
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);
70 #endif
72 #endif /* !defined(TOR_OCIRC_EVENT_H) */