tor

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

orconn_event.h (3361B)


      1 /* Copyright (c) 2001 Matej Pfajfar.
      2 * Copyright (c) 2001-2004, Roger Dingledine.
      3 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
      4 * Copyright (c) 2007-2021, The Tor Project, Inc. */
      5 /* See LICENSE for licensing information */
      6 
      7 /**
      8 * \file orconn_event.h
      9 * \brief Header file for orconn_event.c
     10 *
     11 * The OR_CONN_STATE_* symbols are here to make it easier for
     12 * subscribers to make decisions based on the messages that they
     13 * receive.
     14 **/
     15 
     16 #ifndef TOR_ORCONN_EVENT_H
     17 #define TOR_ORCONN_EVENT_H
     18 
     19 #include "lib/pubsub/pubsub.h"
     20 
     21 /**
     22 * @name States of OR connections
     23 *
     24 * These must be in a partial ordering such that usually no OR
     25 * connection will transition from a higher-numbered state to a
     26 * lower-numbered one.  Code such as bto_update_best() depends on this
     27 * ordering to determine the best state it's seen so far.
     28 * @{ */
     29 #define OR_CONN_STATE_MIN_ 1
     30 /** State for a connection to an OR: waiting for connect() to finish. */
     31 #define OR_CONN_STATE_CONNECTING 1
     32 /** State for a connection to an OR: waiting for proxy handshake to complete */
     33 #define OR_CONN_STATE_PROXY_HANDSHAKING 2
     34 /** State for an OR connection client: SSL is handshaking, not done
     35 * yet. */
     36 #define OR_CONN_STATE_TLS_HANDSHAKING 3
     37 /** State for a connection at an OR: We're waiting for the client to
     38 * send a versions cell (to indicate a v3+ handshake) */
     39 #define OR_CONN_STATE_SERVER_VERSIONS_WAIT 4
     40 /** State for an OR connection: We're done with our SSL handshake, but we
     41 * haven't yet negotiated link protocol versions, done a V3 handshake, and
     42 * sent a netinfo cell. */
     43 #define OR_CONN_STATE_OR_HANDSHAKING_V3 5
     44 /** State for an OR connection: Ready to send/receive cells. */
     45 #define OR_CONN_STATE_OPEN 6
     46 #define OR_CONN_STATE_MAX_ 6
     47 /** @} */
     48 
     49 /** Used to indicate the type of an OR connection event passed to the
     50 * controller.  The various types are defined in control-spec.txt */
     51 typedef enum or_conn_status_event_t {
     52  OR_CONN_EVENT_LAUNCHED     = 0,
     53  OR_CONN_EVENT_CONNECTED    = 1,
     54  OR_CONN_EVENT_FAILED       = 2,
     55  OR_CONN_EVENT_CLOSED       = 3,
     56  OR_CONN_EVENT_NEW          = 4,
     57 } or_conn_status_event_t;
     58 
     59 /**
     60 * Message for orconn state update
     61 *
     62 * This contains information about internal state changes of
     63 * or_connection_t objects.  The chan and proxy_type fields are
     64 * additional information that a subscriber may need to make
     65 * decisions.
     66 **/
     67 typedef struct orconn_state_msg_t {
     68  uint64_t gid;                 /**< connection's global ID */
     69  uint64_t chan;                /**< associated channel ID */
     70  int proxy_type;               /**< connection's proxy type */
     71  uint8_t state;                /**< new connection state */
     72 } orconn_state_msg_t;
     73 
     74 DECLARE_MESSAGE(orconn_state, orconn_state, orconn_state_msg_t *);
     75 
     76 /**
     77 * Message for orconn status event
     78 *
     79 * This contains information that ends up in ORCONN control protocol
     80 * events.
     81 **/
     82 typedef struct orconn_status_msg_t {
     83  uint64_t gid;                 /**< connection's global ID */
     84  int status;                   /**< or_conn_status_event_t */
     85  int reason;                   /**< reason */
     86 } orconn_status_msg_t;
     87 
     88 DECLARE_MESSAGE(orconn_status, orconn_status, orconn_status_msg_t *);
     89 
     90 #ifdef ORCONN_EVENT_PRIVATE
     91 void orconn_state_publish(orconn_state_msg_t *);
     92 void orconn_status_publish(orconn_status_msg_t *);
     93 #endif
     94 
     95 #endif /* !defined(TOR_ORCONN_EVENT_H) */