Merge branch 'maint-0.4.8'
[tor.git] / src / feature / control / control.h
blobfc6196133bf317d1d33689206e5c6cc785f7c08c
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 */
7 /**
8 * \file control.h
9 * \brief Header file for control.c.
10 **/
12 #ifndef TOR_CONTROL_H
13 #define TOR_CONTROL_H
15 control_connection_t *TO_CONTROL_CONN(connection_t *);
16 const control_connection_t *CONST_TO_CONTROL_CONN(const connection_t *);
18 #define CONTROL_CONN_STATE_MIN_ 1
19 /** State for a control connection: Authenticated and accepting v1 commands. */
20 #define CONTROL_CONN_STATE_OPEN 1
21 /** State for a control connection: Waiting for authentication; speaking
22 * protocol v1. */
23 #define CONTROL_CONN_STATE_NEEDAUTH 2
24 #define CONTROL_CONN_STATE_MAX_ 2
26 void control_ports_write_to_file(void);
28 /** Log information about the connection <b>conn</b>, protecting it as with
29 * CONN_LOG_PROTECT. Example:
31 * LOG_FN_CONN(conn, (LOG_DEBUG, "Socket %d wants to write", conn->s));
32 **/
33 #define LOG_FN_CONN(conn, args) \
34 CONN_LOG_PROTECT(conn, log_fn args)
36 #define CC_LOCAL_FD_IS_OWNER (1u<<0)
37 #define CC_LOCAL_FD_IS_AUTHENTICATED (1u<<1)
38 int control_connection_add_local_fd(tor_socket_t sock, unsigned flags);
40 int connection_control_finished_flushing(control_connection_t *conn);
41 int connection_control_reached_eof(control_connection_t *conn);
42 void connection_control_closed(control_connection_t *conn);
44 int connection_control_process_inbuf(control_connection_t *conn);
46 void disable_control_logging(void);
47 void enable_control_logging(void);
49 void monitor_owning_controller_process(const char *process_spec);
51 const char *rend_auth_type_to_string(rend_auth_type_t auth_type);
52 void control_free_all(void);
54 #ifdef CONTROL_MODULE_PRIVATE
55 struct signal_name_t {
56 int sig;
57 const char *signal_name;
59 extern const struct signal_name_t signal_table[];
60 int get_cached_network_liveness(void);
61 void set_cached_network_liveness(int liveness);
62 #endif /* defined(CONTROL_MODULE_PRIVATE) */
64 #ifdef CONTROL_PRIVATE
65 STATIC char *control_split_incoming_command(char *incoming_cmd,
66 size_t *data_len,
67 char **current_cmd_out);
68 #endif
70 #endif /* !defined(TOR_CONTROL_H) */