control_cmd.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-2019, The Tor Project, Inc. */
  5. /* See LICENSE for licensing information */
  6. /**
  7. * \file control_cmd.h
  8. * \brief Header file for control_cmd.c.
  9. **/
  10. #ifndef TOR_CONTROL_CMD_H
  11. #define TOR_CONTROL_CMD_H
  12. #include "lib/malloc/malloc.h"
  13. int handle_control_command(control_connection_t *conn,
  14. uint32_t cmd_data_len,
  15. char *args);
  16. void control_cmd_free_all(void);
  17. typedef struct control_cmd_args_t control_cmd_args_t;
  18. void control_cmd_args_free_(control_cmd_args_t *args);
  19. #define control_cmd_args_free(v) \
  20. FREE_AND_NULL(control_cmd_args_t, control_cmd_args_free_, (v))
  21. #ifdef CONTROL_CMD_PRIVATE
  22. #include "lib/crypt_ops/crypto_ed25519.h"
  23. /* ADD_ONION secret key to create an ephemeral service. The command supports
  24. * multiple versions so this union stores the key and passes it to the HS
  25. * subsystem depending on the requested version. */
  26. typedef union add_onion_secret_key_t {
  27. /* Hidden service v2 secret key. */
  28. crypto_pk_t *v2;
  29. /* Hidden service v3 secret key. */
  30. ed25519_secret_key_t *v3;
  31. } add_onion_secret_key_t;
  32. STATIC int add_onion_helper_keyarg(const char *arg, int discard_pk,
  33. const char **key_new_alg_out,
  34. char **key_new_blob_out,
  35. add_onion_secret_key_t *decoded_key,
  36. int *hs_version, char **err_msg_out);
  37. STATIC rend_authorized_client_t *add_onion_helper_clientauth(const char *arg,
  38. int *created, char **err_msg_out);
  39. /**
  40. * Definition for the syntax of a controller command, as parsed by
  41. * control_cmd_parse_args.
  42. *
  43. * WORK IN PROGRESS: This structure is going to get more complex as this
  44. * branch goes on.
  45. **/
  46. typedef struct control_cmd_syntax_t {
  47. /**
  48. * Lowest number of positional arguments that this command accepts.
  49. * 0 for "it's okay not to have positional arguments."
  50. **/
  51. unsigned int min_args;
  52. /**
  53. * Highest number of positional arguments that this command accepts.
  54. * UINT_MAX for no limit.
  55. **/
  56. unsigned int max_args;
  57. /**
  58. * True iff this command wants to be followed by a multiline object.
  59. **/
  60. bool want_object;
  61. } control_cmd_syntax_t;
  62. STATIC control_cmd_args_t *control_cmd_parse_args(
  63. const char *command,
  64. const control_cmd_syntax_t *syntax,
  65. size_t body_len,
  66. const char *body,
  67. char **error_out);
  68. #endif /* defined(CONTROL_CMD_PRIVATE) */
  69. #ifdef CONTROL_MODULE_PRIVATE
  70. smartlist_t * get_detached_onion_services(void);
  71. #endif /* defined(CONTROL_MODULE_PRIVATE) */
  72. #endif /* !defined(TOR_CONTROL_CMD_H) */