2013-07-16 13:42:25 -04:00
|
|
|
/* Copyright (c) 2001 Matej Pfajfar.
|
|
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
2018-06-20 08:13:28 -04:00
|
|
|
* Copyright (c) 2007-2018, The Tor Project, Inc. */
|
2013-07-16 13:42:25 -04:00
|
|
|
/* See LICENSE for licensing information */
|
|
|
|
|
|
|
|
#ifndef EXT_ORPORT_H
|
|
|
|
#define EXT_ORPORT_H
|
|
|
|
|
2018-07-01 14:16:25 -04:00
|
|
|
/** States of the Extended ORPort protocol. Be careful before changing
|
|
|
|
* the numbers: they matter. */
|
|
|
|
#define EXT_OR_CONN_STATE_MIN_ 1
|
|
|
|
/** Extended ORPort authentication is waiting for the authentication
|
|
|
|
* type selected by the client. */
|
|
|
|
#define EXT_OR_CONN_STATE_AUTH_WAIT_AUTH_TYPE 1
|
|
|
|
/** Extended ORPort authentication is waiting for the client nonce. */
|
|
|
|
#define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_NONCE 2
|
|
|
|
/** Extended ORPort authentication is waiting for the client hash. */
|
|
|
|
#define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH 3
|
|
|
|
#define EXT_OR_CONN_STATE_AUTH_MAX 3
|
|
|
|
/** Authentication finished and the Extended ORPort is now accepting
|
|
|
|
* traffic. */
|
|
|
|
#define EXT_OR_CONN_STATE_OPEN 4
|
|
|
|
/** Extended ORPort is flushing its last messages and preparing to
|
|
|
|
* start accepting OR connections. */
|
|
|
|
#define EXT_OR_CONN_STATE_FLUSHING 5
|
|
|
|
#define EXT_OR_CONN_STATE_MAX_ 5
|
|
|
|
|
2012-12-05 19:18:18 +02:00
|
|
|
int connection_ext_or_start_auth(or_connection_t *or_conn);
|
|
|
|
|
|
|
|
ext_or_cmd_t *ext_or_cmd_new(uint16_t len);
|
2017-12-08 10:21:12 -05:00
|
|
|
|
|
|
|
#define ext_or_cmd_free(cmd) \
|
|
|
|
FREE_AND_NULL(ext_or_cmd_t, ext_or_cmd_free_, (cmd))
|
|
|
|
|
|
|
|
void ext_or_cmd_free_(ext_or_cmd_t *cmd);
|
2012-12-05 19:18:18 +02:00
|
|
|
void connection_or_set_ext_or_identifier(or_connection_t *conn);
|
|
|
|
void connection_or_remove_from_ext_or_id_map(or_connection_t *conn);
|
|
|
|
void connection_or_clear_ext_or_id_map(void);
|
2013-07-18 15:51:29 -04:00
|
|
|
or_connection_t *connection_or_get_by_ext_or_id(const char *id);
|
2012-12-05 19:18:18 +02:00
|
|
|
|
|
|
|
int connection_ext_or_finished_flushing(or_connection_t *conn);
|
|
|
|
int connection_ext_or_process_inbuf(or_connection_t *or_conn);
|
|
|
|
|
2012-12-05 19:19:24 +02:00
|
|
|
int init_ext_or_cookie_authentication(int is_enabled);
|
2013-07-16 13:42:25 -04:00
|
|
|
char *get_ext_or_auth_cookie_file_name(void);
|
2013-08-14 17:16:06 +03:00
|
|
|
void ext_orport_free_all(void);
|
2013-07-16 13:42:25 -04:00
|
|
|
|
2013-07-18 16:23:48 -04:00
|
|
|
#ifdef EXT_ORPORT_PRIVATE
|
|
|
|
STATIC int connection_write_ext_or_command(connection_t *conn,
|
|
|
|
uint16_t command,
|
|
|
|
const char *body,
|
|
|
|
size_t bodylen);
|
2013-08-01 11:44:52 -04:00
|
|
|
STATIC int handle_client_auth_nonce(const char *client_nonce,
|
|
|
|
size_t client_nonce_len,
|
|
|
|
char **client_hash_out,
|
|
|
|
char **reply_out, size_t *reply_len_out);
|
|
|
|
#ifdef TOR_UNIT_TESTS
|
2013-06-04 20:00:28 +03:00
|
|
|
extern uint8_t *ext_or_auth_cookie;
|
2013-08-01 11:44:52 -04:00
|
|
|
extern int ext_or_auth_cookie_is_set;
|
|
|
|
#endif
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* defined(EXT_ORPORT_PRIVATE) */
|
2013-07-18 16:23:48 -04:00
|
|
|
|
2017-09-15 16:24:44 -04:00
|
|
|
#endif /* !defined(EXT_ORPORT_H) */
|