Tor  0.4.7.0-alpha-dev
control_cmd.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 control_cmd.h
9  * \brief Header file for control_cmd.c.
10  **/
11 
12 #ifndef TOR_CONTROL_CMD_H
13 #define TOR_CONTROL_CMD_H
14 
15 #include "lib/malloc/malloc.h"
16 
18  uint32_t cmd_data_len,
19  char *args);
20 void control_cmd_free_all(void);
21 
25 
26 #define control_cmd_args_free(v) \
27  FREE_AND_NULL(control_cmd_args_t, control_cmd_args_free_, (v))
28 
29 /**
30  * Definition for the syntax of a controller command, as parsed by
31  * control_cmd_parse_args.
32  *
33  * WORK IN PROGRESS: This structure is going to get more complex as this
34  * branch goes on.
35  **/
36 typedef struct control_cmd_syntax_t {
37  /**
38  * Lowest number of positional arguments that this command accepts.
39  * 0 for "it's okay not to have positional arguments."
40  **/
41  unsigned int min_args;
42  /**
43  * Highest number of positional arguments that this command accepts.
44  * UINT_MAX for no limit.
45  **/
46  unsigned int max_args;
47  /**
48  * If true, we should parse options after the positional arguments
49  * as a set of unordered flags and key=value arguments.
50  *
51  * Requires that max_args is not UINT_MAX.
52  **/
54  /**
55  * If accept_keywords is true, then only the keywords listed in this
56  * (NULL-terminated) array are valid keywords for this command.
57  **/
58  const char **allowed_keywords;
59  /**
60  * If accept_keywords is true, this option is passed to kvline_parse() as
61  * its flags.
62  **/
63  unsigned kvline_flags;
64  /**
65  * True iff this command wants to be followed by a multiline object.
66  **/
68  /**
69  * True iff this command needs access to the raw body of the input.
70  *
71  * This should not be needed for pure commands; it is purely a legacy
72  * option.
73  **/
76 
77 #ifdef CONTROL_CMD_PRIVATE
78 #include "feature/hs/hs_service.h"
80 
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. */
87 } add_onion_secret_key_t;
88 
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,
93  int *hs_version,
94  control_connection_t *conn);
95 
96 STATIC hs_service_add_ephemeral_status_t add_onion_helper_add_service(
97  int hs_version,
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);
102 
104  const char *command,
105  const control_cmd_syntax_t *syntax,
106  size_t body_len,
107  const char *body,
108  char **error_out);
109 
110 #endif /* defined(CONTROL_CMD_PRIVATE) */
111 
112 #ifdef CONTROL_MODULE_PRIVATE
114 #endif /* defined(CONTROL_MODULE_PRIVATE) */
115 
116 #endif /* !defined(TOR_CONTROL_CMD_H) */
tor_cmdline_mode_t command
Definition: config.c:2440
STATIC int add_onion_helper_keyarg(const char *arg, int discard_pk, const char **key_new_alg_out, char **key_new_blob_out, add_onion_secret_key_t *decoded_key, int *hs_version, control_connection_t *conn)
Definition: control_cmd.c:1860
STATIC control_cmd_args_t * control_cmd_parse_args(const char *command, const control_cmd_syntax_t *syntax, size_t body_len, const char *body, char **error_out)
Definition: control_cmd.c:158
smartlist_t * get_detached_onion_services(void)
Definition: control_cmd.c:1606
void control_cmd_args_free_(control_cmd_args_t *args)
Definition: control_cmd.c:69
void control_cmd_args_wipe(control_cmd_args_t *args)
Definition: control_cmd.c:86
int handle_control_command(control_connection_t *conn, uint32_t cmd_data_len, char *args)
Definition: control_cmd.c:2204
Header for crypto_ed25519.c.
hs_service_add_ephemeral_status_t
Definition: hs_common.h:139
Header file containing service data for the HS subsystem.
Headers for util_malloc.c.
struct smartlist_t * args
unsigned int min_args
Definition: control_cmd.h:41
const char ** allowed_keywords
Definition: control_cmd.h:58
unsigned int max_args
Definition: control_cmd.h:46
#define STATIC
Definition: testsupport.h:32