Tor  0.4.8.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 
41 
42 /* (No stub needed for these: they are only called within feature/relay.) */
43 int init_ext_or_cookie_authentication(int is_enabled);
44 void ext_orport_free_all(void);
45 
46 #else /* !defined(HAVE_MODULE_RELAY) */
47 
48 static inline int
50 {
51  (void)conn;
53  return -1;
54 }
55 static inline int
57 {
58  (void)conn;
60  return -1;
61 }
62 static inline int
64 {
65  (void)conn;
67  return -1;
68 }
69 #define get_ext_or_auth_cookie_file_name() \
70  (NULL)
71 
72 #endif /* defined(HAVE_MODULE_RELAY) */
73 
74 #ifdef EXT_ORPORT_PRIVATE
76  uint16_t command,
77  const char *body,
78  size_t bodylen);
79 STATIC int handle_client_auth_nonce(const char *client_nonce,
80  size_t client_nonce_len,
81  char **client_hash_out,
82  char **reply_out, size_t *reply_len_out);
83 
84 #ifdef TOR_UNIT_TESTS
85 extern uint8_t *ext_or_auth_cookie;
86 extern int ext_or_auth_cookie_is_set;
87 #endif
88 #endif /* defined(EXT_ORPORT_PRIVATE) */
89 
90 #endif /* !defined(EXT_ORPORT_H) */
tor_cmdline_mode_t command
Definition: config.c:2449
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
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:661
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