tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

ocirc_event.h (2222B)


      1 /* Copyright (c) 2007-2021, The Tor Project, Inc. */
      2 /* See LICENSE for licensing information */
      3 
      4 /**
      5 * \file ocirc_event.h
      6 * \brief Header file for ocirc_event.c
      7 **/
      8 
      9 #ifndef TOR_OCIRC_EVENT_H
     10 #define TOR_OCIRC_EVENT_H
     11 
     12 #include <stdbool.h>
     13 
     14 #include "lib/cc/torint.h"
     15 #include "lib/pubsub/pubsub.h"
     16 
     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;
     26 
     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;
     33 
     34 DECLARE_MESSAGE(ocirc_state, ocirc_state, ocirc_state_msg_t *);
     35 
     36 /**
     37 * Message when a channel gets associated to a circuit.
     38 *
     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.
     43 */
     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;
     49 
     50 DECLARE_MESSAGE(ocirc_chan, ocirc_chan, ocirc_chan_msg_t *);
     51 
     52 /**
     53 * Message for origin circuit status event
     54 *
     55 * This contains information that ends up in CIRC control protocol events.
     56 */
     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;
     63 
     64 DECLARE_MESSAGE(ocirc_cevent, ocirc_cevent, ocirc_cevent_msg_t *);
     65 
     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
     71 
     72 #endif /* !defined(TOR_OCIRC_EVENT_H) */