Tor  0.4.7.0-alpha-dev
ext_orport.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 ext_orport.h
9  * @brief Header for ext_orport.c
10  **/
11 
12 #ifndef EXT_ORPORT_H
13 #define EXT_ORPORT_H
14 
15 /** States of the Extended ORPort protocol. Be careful before changing
16  * the numbers: they matter. */
17 #define EXT_OR_CONN_STATE_MIN_ 1
18 /** Extended ORPort authentication is waiting for the authentication
19  * type selected by the client. */
20 #define EXT_OR_CONN_STATE_AUTH_WAIT_AUTH_TYPE 1
21 /** Extended ORPort authentication is waiting for the client nonce. */
22 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_NONCE 2
23 /** Extended ORPort authentication is waiting for the client hash. */
24 #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH 3
25 #define EXT_OR_CONN_STATE_AUTH_MAX 3
26 /** Authentication finished and the Extended ORPort is now accepting
27  * traffic. */
28 #define EXT_OR_CONN_STATE_OPEN 4
29 /** Extended ORPort is flushing its last messages and preparing to
30  * start accepting OR connections. */
31 #define EXT_OR_CONN_STATE_FLUSHING 5
32 #define EXT_OR_CONN_STATE_MAX_ 5
33 
34 #ifdef HAVE_MODULE_RELAY
35 
37 
42 
43 /* (No stub needed for these: they are only called within feature/relay.) */
44 int init_ext_or_cookie_authentication(int is_enabled);
45 void ext_orport_free_all(void);
46 
47 #else /* !defined(HAVE_MODULE_RELAY) */
48 
49 static inline int
51 {
52  (void)conn;
54  return -1;
55 }
56 static inline int
58 {
59  (void)conn;
61  return -1;
62 }
63 static inline int
65 {
66  (void)conn;
68  return -1;
69 }
70 #define connection_or_set_ext_or_identifier(conn) \
71  ((void)(conn))
72 
73 #define get_ext_or_auth_cookie_file_name() \
74  (NULL)
75 
76 #endif /* defined(HAVE_MODULE_RELAY) */
77 
78 #ifdef EXT_ORPORT_PRIVATE
80  uint16_t command,
81  const char *body,
82  size_t bodylen);
83 STATIC int handle_client_auth_nonce(const char *client_nonce,
84  size_t client_nonce_len,
85  char **client_hash_out,
86  char **reply_out, size_t *reply_len_out);
87 
88 #ifdef TOR_UNIT_TESTS
89 extern uint8_t *ext_or_auth_cookie;
90 extern int ext_or_auth_cookie_is_set;
91 #endif
92 #endif /* defined(EXT_ORPORT_PRIVATE) */
93 
94 #endif /* !defined(EXT_ORPORT_H) */
tor_cmdline_mode_t command
Definition: config.c:2440
STATIC uint8_t * ext_or_auth_cookie
Definition: ext_orport.c:122
STATIC int ext_or_auth_cookie_is_set
Definition: ext_orport.c:118
char * get_ext_or_auth_cookie_file_name(void)
Definition: ext_orport.c:127
void connection_or_set_ext_or_identifier(or_connection_t *conn)
Definition: ext_orport.c:662
int connection_ext_or_process_inbuf(or_connection_t *or_conn)
Definition: ext_orport.c:544
int connection_ext_or_start_auth(or_connection_t *or_conn)
Definition: ext_orport.c:640
void ext_orport_free_all(void)
Definition: ext_orport.c:674
int connection_ext_or_finished_flushing(or_connection_t *conn)
Definition: ext_orport.c:628
STATIC int connection_write_ext_or_command(connection_t *conn, uint16_t command, const char *body, size_t bodylen)
Definition: ext_orport.c:66
#define STATIC
Definition: testsupport.h:32
#define tor_assert_nonfatal_unreached()
Definition: util_bug.h:176