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 */
9 * \brief Header file for control_cmd.c.
12 #ifndef TOR_CONTROL_CMD_H
13 #define TOR_CONTROL_CMD_H
15 #include "lib/malloc/malloc.h"
17 int handle_control_command(control_connection_t
*conn
,
18 uint32_t cmd_data_len
,
20 void control_cmd_free_all(void);
22 typedef struct control_cmd_args_t control_cmd_args_t
;
23 void control_cmd_args_free_(control_cmd_args_t
*args
);
24 void control_cmd_args_wipe(control_cmd_args_t
*args
);
26 #define control_cmd_args_free(v) \
27 FREE_AND_NULL(control_cmd_args_t, control_cmd_args_free_, (v))
30 * Definition for the syntax of a controller command, as parsed by
31 * control_cmd_parse_args.
33 * WORK IN PROGRESS: This structure is going to get more complex as this
36 typedef struct control_cmd_syntax_t
{
38 * Lowest number of positional arguments that this command accepts.
39 * 0 for "it's okay not to have positional arguments."
41 unsigned int min_args
;
43 * Highest number of positional arguments that this command accepts.
44 * UINT_MAX for no limit.
46 unsigned int max_args
;
48 * If true, we should parse options after the positional arguments
49 * as a set of unordered flags and key=value arguments.
51 * Requires that max_args is not UINT_MAX.
55 * If accept_keywords is true, then only the keywords listed in this
56 * (NULL-terminated) array are valid keywords for this command.
58 const char **allowed_keywords
;
60 * If accept_keywords is true, this option is passed to kvline_parse() as
63 unsigned kvline_flags
;
65 * True iff this command wants to be followed by a multiline object.
69 * True iff this command needs access to the raw body of the input.
71 * This should not be needed for pure commands; it is purely a legacy
75 } control_cmd_syntax_t
;
77 #ifdef CONTROL_CMD_PRIVATE
78 #include "feature/hs/hs_service.h"
79 #include "lib/crypt_ops/crypto_ed25519.h"
81 /* ADD_ONION secret key to create an ephemeral service. The command supports
82 * multiple versions so this union stores the key and passes it to the HS
83 * subsystem depending on the requested version. */
84 typedef union add_onion_secret_key_t
{
85 /* Hidden service v3 secret key. */
86 ed25519_secret_key_t
*v3
;
87 } add_onion_secret_key_t
;
89 STATIC
int add_onion_helper_keyarg(const char *arg
, int discard_pk
,
90 const char **key_new_alg_out
,
91 char **key_new_blob_out
,
92 add_onion_secret_key_t
*decoded_key
,
94 control_connection_t
*conn
);
96 STATIC hs_service_add_ephemeral_status_t
add_onion_helper_add_service(
98 add_onion_secret_key_t
*pk
,
99 smartlist_t
*port_cfgs
, int max_streams
,
100 int max_streams_close_circuit
,
101 smartlist_t
*auth_clients_v3
, char **address_out
);
103 STATIC control_cmd_args_t
*control_cmd_parse_args(
105 const control_cmd_syntax_t
*syntax
,
110 #endif /* defined(CONTROL_CMD_PRIVATE) */
112 #ifdef CONTROL_MODULE_PRIVATE
113 smartlist_t
* get_detached_onion_services(void);
114 #endif /* defined(CONTROL_MODULE_PRIVATE) */
116 #endif /* !defined(TOR_CONTROL_CMD_H) */