ext_orport.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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-2018, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. #ifndef EXT_ORPORT_H
  7. #define EXT_ORPORT_H
  8. /** States of the Extended ORPort protocol. Be careful before changing
  9. * the numbers: they matter. */
  10. #define EXT_OR_CONN_STATE_MIN_ 1
  11. /** Extended ORPort authentication is waiting for the authentication
  12. * type selected by the client. */
  13. #define EXT_OR_CONN_STATE_AUTH_WAIT_AUTH_TYPE 1
  14. /** Extended ORPort authentication is waiting for the client nonce. */
  15. #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_NONCE 2
  16. /** Extended ORPort authentication is waiting for the client hash. */
  17. #define EXT_OR_CONN_STATE_AUTH_WAIT_CLIENT_HASH 3
  18. #define EXT_OR_CONN_STATE_AUTH_MAX 3
  19. /** Authentication finished and the Extended ORPort is now accepting
  20. * traffic. */
  21. #define EXT_OR_CONN_STATE_OPEN 4
  22. /** Extended ORPort is flushing its last messages and preparing to
  23. * start accepting OR connections. */
  24. #define EXT_OR_CONN_STATE_FLUSHING 5
  25. #define EXT_OR_CONN_STATE_MAX_ 5
  26. int connection_ext_or_start_auth(or_connection_t *or_conn);
  27. ext_or_cmd_t *ext_or_cmd_new(uint16_t len);
  28. #define ext_or_cmd_free(cmd) \
  29. FREE_AND_NULL(ext_or_cmd_t, ext_or_cmd_free_, (cmd))
  30. void ext_or_cmd_free_(ext_or_cmd_t *cmd);
  31. void connection_or_set_ext_or_identifier(or_connection_t *conn);
  32. void connection_or_remove_from_ext_or_id_map(or_connection_t *conn);
  33. void connection_or_clear_ext_or_id_map(void);
  34. or_connection_t *connection_or_get_by_ext_or_id(const char *id);
  35. int connection_ext_or_finished_flushing(or_connection_t *conn);
  36. int connection_ext_or_process_inbuf(or_connection_t *or_conn);
  37. int init_ext_or_cookie_authentication(int is_enabled);
  38. char *get_ext_or_auth_cookie_file_name(void);
  39. void ext_orport_free_all(void);
  40. #ifdef EXT_ORPORT_PRIVATE
  41. STATIC int connection_write_ext_or_command(connection_t *conn,
  42. uint16_t command,
  43. const char *body,
  44. size_t bodylen);
  45. STATIC int handle_client_auth_nonce(const char *client_nonce,
  46. size_t client_nonce_len,
  47. char **client_hash_out,
  48. char **reply_out, size_t *reply_len_out);
  49. #ifdef TOR_UNIT_TESTS
  50. extern uint8_t *ext_or_auth_cookie;
  51. extern int ext_or_auth_cookie_is_set;
  52. #endif
  53. #endif /* defined(EXT_ORPORT_PRIVATE) */
  54. #endif /* !defined(EXT_ORPORT_H) */