Tor 0.4.9.0-alpha-dev
orconn_event.h
Go to the documentation of this file.
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 to an OR: We're doing a second SSL handshake for
38 * renegotiation purposes. (V2 handshake only.) */
39#define OR_CONN_STATE_TLS_CLIENT_RENEGOTIATING 4
40/** State for a connection at an OR: We're waiting for the client to
41 * renegotiate (to indicate a v2 handshake) or send a versions cell (to
42 * indicate a v3 handshake) */
43#define OR_CONN_STATE_TLS_SERVER_RENEGOTIATING 5
44/** State for an OR connection: We're done with our SSL handshake, we've done
45 * renegotiation, but we haven't yet negotiated link protocol versions and
46 * sent a netinfo cell. */
47#define OR_CONN_STATE_OR_HANDSHAKING_V2 6
48/** State for an OR connection: We're done with our SSL handshake, but we
49 * haven't yet negotiated link protocol versions, done a V3 handshake, and
50 * sent a netinfo cell. */
51#define OR_CONN_STATE_OR_HANDSHAKING_V3 7
52/** State for an OR connection: Ready to send/receive cells. */
53#define OR_CONN_STATE_OPEN 8
54#define OR_CONN_STATE_MAX_ 8
55/** @} */
56
57/** Used to indicate the type of an OR connection event passed to the
58 * controller. The various types are defined in control-spec.txt */
60 OR_CONN_EVENT_LAUNCHED = 0,
61 OR_CONN_EVENT_CONNECTED = 1,
62 OR_CONN_EVENT_FAILED = 2,
63 OR_CONN_EVENT_CLOSED = 3,
64 OR_CONN_EVENT_NEW = 4,
66
67/**
68 * Message for orconn state update
69 *
70 * This contains information about internal state changes of
71 * or_connection_t objects. The chan and proxy_type fields are
72 * additional information that a subscriber may need to make
73 * decisions.
74 **/
75typedef struct orconn_state_msg_t {
76 uint64_t gid; /**< connection's global ID */
77 uint64_t chan; /**< associated channel ID */
78 int proxy_type; /**< connection's proxy type */
79 uint8_t state; /**< new connection state */
81
82DECLARE_MESSAGE(orconn_state, orconn_state, orconn_state_msg_t *);
83
84/**
85 * Message for orconn status event
86 *
87 * This contains information that ends up in ORCONN control protocol
88 * events.
89 **/
90typedef struct orconn_status_msg_t {
91 uint64_t gid; /**< connection's global ID */
92 int status; /**< or_conn_status_event_t */
93 int reason; /**< reason */
95
96DECLARE_MESSAGE(orconn_status, orconn_status, orconn_status_msg_t *);
97
98#ifdef ORCONN_EVENT_PRIVATE
99void orconn_state_publish(orconn_state_msg_t *);
100void orconn_status_publish(orconn_status_msg_t *);
101#endif
102
103#endif /* !defined(TOR_ORCONN_EVENT_H) */
or_conn_status_event_t
Definition: orconn_event.h:59
Header for OO publish-subscribe functionality.
#define DECLARE_MESSAGE(messagename, typename, c_ptr_type)