Tor  0.4.5.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-2020, 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
79 
80 /* ADD_ONION secret key to create an ephemeral service. The command supports
81  * multiple versions so this union stores the key and passes it to the HS
82  * subsystem depending on the requested version. */
83 typedef union add_onion_secret_key_t {
84  /* Hidden service v2 secret key. */
85  crypto_pk_t *v2;
86  /* Hidden service v3 secret key. */
88 } add_onion_secret_key_t;
89 
90 STATIC int add_onion_helper_keyarg(const char *arg, int discard_pk,
91  const char **key_new_alg_out,
92  char **key_new_blob_out,
93  add_onion_secret_key_t *decoded_key,
94  int *hs_version,
95  control_connection_t *conn);
96 
98  int *created, control_connection_t *conn);
99 
101  const char *command,
102  const control_cmd_syntax_t *syntax,
103  size_t body_len,
104  const char *body,
105  char **error_out);
106 
107 #endif /* defined(CONTROL_CMD_PRIVATE) */
108 
109 #ifdef CONTROL_MODULE_PRIVATE
111 #endif /* defined(CONTROL_MODULE_PRIVATE) */
112 
113 #endif /* !defined(TOR_CONTROL_CMD_H) */
add_onion_helper_clientauth
STATIC rend_authorized_client_t * add_onion_helper_clientauth(const char *arg, int *created, control_connection_t *conn)
Definition: control_cmd.c:2116
control_cmd_args_t
Definition: control_cmd_args_st.h:24
add_onion_helper_keyarg
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:1980
control_cmd_syntax_t::want_cmddata
bool want_cmddata
Definition: control_cmd.h:67
control_cmd_syntax_t::max_args
unsigned int max_args
Definition: control_cmd.h:46
get_detached_onion_services
smartlist_t * get_detached_onion_services(void)
Definition: control_cmd.c:1690
handle_control_command
int handle_control_command(control_connection_t *conn, uint32_t cmd_data_len, char *args)
Definition: control_cmd.c:2426
control_cmd_args_free_
void control_cmd_args_free_(control_cmd_args_t *args)
Definition: control_cmd.c:74
control_cmd_args_t::args
struct smartlist_t * args
Definition: control_cmd_args_st.h:33
control_cmd_syntax_t
Definition: control_cmd.h:36
control_cmd_syntax_t::min_args
unsigned int min_args
Definition: control_cmd.h:41
malloc.h
Headers for util_malloc.c.
command
tor_cmdline_mode_t command
Definition: config.c:2447
control_cmd_syntax_t::accept_keywords
bool accept_keywords
Definition: control_cmd.h:53
control_cmd_args_wipe
void control_cmd_args_wipe(control_cmd_args_t *args)
Definition: control_cmd.c:91
control_cmd_parse_args
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:163
crypto_pk_t
Definition: crypto_rsa_nss.c:37
control_cmd_syntax_t::store_raw_body
bool store_raw_body
Definition: control_cmd.h:74
control_connection_t
Definition: control_connection_st.h:19
STATIC
#define STATIC
Definition: testsupport.h:32
ed25519_secret_key_t
Definition: crypto_ed25519.h:28
control_cmd_syntax_t::kvline_flags
unsigned kvline_flags
Definition: control_cmd.h:63
crypto_ed25519.h
Header for crypto_ed25519.c.
smartlist_t
Definition: smartlist_core.h:26
rend_authorized_client_t
Definition: rend_authorized_client_st.h:16
control_cmd_syntax_t::allowed_keywords
const char ** allowed_keywords
Definition: control_cmd.h:58