19 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(DARWIN)
20 #define KERNEL_MAY_SUPPORT_IPFW
25 #define MIN_HEARTBEAT_PERIOD (30*60)
28 #if SIZEOF_VOID_P >= 8
29 #define MAX_DEFAULT_MEMORY_QUEUE_SIZE (UINT64_C(8) << 30)
31 #define MAX_DEFAULT_MEMORY_QUEUE_SIZE (UINT64_C(2) << 30)
38 const char *safe_str_client(
const char *address);
39 const char *safe_str(
const char *address);
45 #define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
48 #define CONFIG_BACKUP_PATTERN "%s.orig.1"
54 SETOPT_ERR_PARSE = -2,
55 SETOPT_ERR_TRANSITION = -3,
56 SETOPT_ERR_SETTING = -4,
63 #define OPTIONS_DUMP_MINIMAL 1
64 #define OPTIONS_DUMP_ALL 2
68 int command,
const char *command_arg,
char **msg);
84 directory_root_t roottype,
85 const char *sub1,
const char *sub2,
105 #define options_get_datadir_fname2_suffix(options, sub1, sub2, suffix) \
106 options_get_dir_fname2_suffix((options), DIRROOT_DATADIR, \
107 (sub1), (sub2), (suffix))
108 #define options_get_cachedir_fname2_suffix(options, sub1, sub2, suffix) \
109 options_get_dir_fname2_suffix((options), DIRROOT_CACHEDIR, \
110 (sub1), (sub2), (suffix))
111 #define options_get_keydir_fname2_suffix(options, sub1, sub2, suffix) \
112 options_get_dir_fname2_suffix((options), DIRROOT_KEYDIR, \
113 (sub1), (sub2), (suffix))
115 #define options_get_datadir_fname(opts,sub1) \
116 options_get_datadir_fname2_suffix((opts),(sub1), NULL, NULL)
117 #define options_get_datadir_fname2(opts,sub1,sub2) \
118 options_get_datadir_fname2_suffix((opts),(sub1), (sub2), NULL)
120 #define get_datadir_fname2_suffix(sub1, sub2, suffix) \
121 options_get_datadir_fname2_suffix(get_options(), (sub1), (sub2), (suffix))
122 #define get_datadir_fname(sub1) \
123 get_datadir_fname2_suffix((sub1), NULL, NULL)
124 #define get_datadir_fname2(sub1,sub2) \
125 get_datadir_fname2_suffix((sub1), (sub2), NULL)
126 #define get_datadir_fname_suffix(sub1, suffix) \
127 get_datadir_fname2_suffix((sub1), NULL, (suffix))
130 #define options_get_keydir_fname(options, sub1) \
131 options_get_keydir_fname2_suffix((options), (sub1), NULL, NULL)
132 #define get_keydir_fname_suffix(sub1, suffix) \
133 options_get_keydir_fname2_suffix(get_options(), (sub1), NULL, suffix)
134 #define get_keydir_fname(sub1) \
135 options_get_keydir_fname2_suffix(get_options(), (sub1), NULL, NULL)
137 #define get_cachedir_fname(sub1) \
138 options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, NULL)
139 #define get_cachedir_fname_suffix(sub1, suffix) \
140 options_get_cachedir_fname2_suffix(get_options(), (sub1), NULL, (suffix))
142 #define safe_str_client(address) \
143 safe_str_client_opts(NULL, address)
144 #define safe_str(address) \
145 safe_str_opts(NULL, address)
148 const char *address);
150 const char *address);
152 int using_default_dir_authorities(
const or_options_t *options);
158 const char* str,
const char* descr);
167 #define portconf_get_primary_dir_port() \
168 (portconf_get_first_advertised_port(CONN_TYPE_DIR_LISTENER, AF_INET))
172 int port,
int check_wildcard);
173 int port_exists_by_type_addr32h_port(
int listener_type, uint32_t addr_ipv4h,
174 int port,
int check_wildcard);
179 const char **reason_out);
182 const char *question,
char **answer,
183 const char **errmsg);
186 int cookie_len,
int group_readable,
187 uint8_t **cookie_out,
int *cookie_is_set_out);
209 #define parsed_cmdline_free(c) \
210 FREE_AND_NULL(parsed_cmdline_t, parsed_cmdline_free_, (c))
222 const char **rest_out);
228 char *transport_name;
236 #define bridge_line_free(line) \
237 FREE_AND_NULL(bridge_line_t, bridge_line_free_, (line))
244 const char *portname,
246 const char *defaultaddr,
248 const unsigned flags);
250 #define CL_PORT_NO_STREAM_OPTIONS (1u<<0)
251 #define CL_PORT_WARN_NONLOCAL (1u<<1)
253 #define CL_PORT_SERVER_OPTIONS (1u<<3)
254 #define CL_PORT_FORBID_NONLOCAL (1u<<4)
255 #define CL_PORT_TAKES_HOSTNAMES (1u<<5)
256 #define CL_PORT_IS_UNIXSOCKET (1u<<6)
257 #define CL_PORT_DFLT_GROUP_WRITABLE (1u<<7)
260 #define port_cfg_free(port) \
261 FREE_AND_NULL(port_cfg_t, port_cfg_free_, (port))
268 const char *line,
int validate_only,
272 #ifdef CONFIG_PRIVATE
280 #define or_options_free(opt) \
281 FREE_AND_NULL(or_options_t, or_options_free_, (opt))
296 STATIC uint64_t compute_real_max_mem_in_queues(
const uint64_t val,
312 #ifdef TOR_UNIT_TESTS
319 char **msg,
int *n_ports_out,
320 int *world_writable_control_socket);
STATIC void add_default_trusted_dir_authorities(dirinfo_type_t type)
void add_default_fallback_dir_servers(void)
STATIC int options_act_reversible(const or_options_t *old_options, char **msg)
STATIC void or_options_free_(or_options_t *options)
STATIC int parse_ports(or_options_t *options, int validate_only, char **msg, int *n_ports_out, int *world_writable_control_socket)
int consider_adding_dir_servers(const or_options_t *options, const or_options_t *old_options)
STATIC void options_commit_log_transaction(log_transaction_t *xn)
STATIC int open_and_add_file_log(const log_severity_list_t *severity, const char *filename, int truncate_log)
STATIC int options_create_directories(char **msg_out)
STATIC log_transaction_t * options_start_log_transaction(const or_options_t *old_options, char **msg_out)
STATIC const config_mgr_t * get_options_mgr(void)
int parse_dir_fallback_line(const char *line, int validate_only)
STATIC int options_act(const or_options_t *old_options)
STATIC int parse_dir_authority_line(const char *line, dirinfo_type_t required_type, int validate_only)
STATIC int options_init_logs(const or_options_t *old_options, const or_options_t *options, int validate_only)
STATIC void options_rollback_log_transaction(log_transaction_t *xn)
tor_cmdline_mode_t command
STATIC int parse_tcp_proxy_line(const char *line, or_options_t *options, char **msg)
int port_parse_config(smartlist_t *out, const config_line_t *ports, const char *portname, int listener_type, const char *defaultaddr, int defaultport, const unsigned flags)
int config_ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
void options_init(or_options_t *options)
int options_save_current(void)
const smartlist_t * get_configured_ports(void)
int pt_parse_transport_line(const or_options_t *options, const char *line, int validate_only, int server)
struct config_line_t * option_get_assignment(const or_options_t *options, const char *key)
void bridge_line_free_(bridge_line_t *bridge_line)
int get_num_cpus(const or_options_t *options)
setopt_err_t options_trial_assign(struct config_line_t *list, unsigned flags, char **msg)
or_options_t * get_options_mutable(void)
parsed_cmdline_t * config_parse_commandline(int argc, char **argv, int ignore_errors)
or_options_t * options_new(void)
int getinfo_helper_config(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
char * get_first_listener_addrport_string(int listener_type)
port_cfg_t * port_cfg_new(size_t namelen)
char * options_get_dir_fname2_suffix(const or_options_t *options, directory_root_t roottype, const char *sub1, const char *sub2, const char *suffix)
int options_init_from_torrc(int argc, char **argv)
void port_cfg_free_(port_cfg_t *port)
int portconf_get_first_advertised_port(int listener_type, int address_family)
const or_options_t * get_options(void)
int port_cfg_line_extract_addrport(const char *line, char **addrport_out, int *is_unix_out, const char **rest_out)
int check_or_create_data_subdir(const char *subdir)
int options_any_client_port_set(const or_options_t *options)
int create_keys_directory(const or_options_t *options)
void init_protocol_warning_severity_level(void)
int get_protocol_warning_severity_level(void)
const tor_addr_t * portconf_get_first_advertised_addr(int listener_type, int address_family)
char * options_dump(const or_options_t *options, int how_to_dump)
int option_is_recognized(const char *key)
const char * safe_str_client_opts(const or_options_t *options, const char *address)
const char * safe_str_opts(const or_options_t *options, const char *address)
void parsed_cmdline_free_(parsed_cmdline_t *cmdline)
const char * option_get_canonical_name(const char *key)
const char * get_torrc_fname(int defaults_fname)
int set_options(or_options_t *new_val, char **msg)
bridge_line_t * parse_bridge_line(const char *line)
const char * escaped_safe_str_client(const char *address)
int addressmap_register_auto(const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
int options_need_geoip_info(const or_options_t *options, const char **reason_out)
void config_register_addressmaps(const or_options_t *options)
void config_free_all(void)
int port_count_real_listeners(const smartlist_t *ports, int listenertype, int count_sockets)
int port_exists_by_type_addr_port(int listener_type, const tor_addr_t *addr, int port, int check_wildcard)
int init_cookie_authentication(const char *fname, const char *header, int cookie_len, int group_readable, uint8_t **cookie_out, int *cookie_is_set_out)
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
const char * escaped_safe_str(const char *address)
int write_to_data_subdir(const char *subdir, const char *fname, const char *str, const char *descr)
addressmap_entry_source_t
The or_options_t structure, which represents Tor's configuration.
Declare the quiet_level enumeration and global.
quiet_level_t quiet_level
struct config_line_t * cmdline_opts
struct config_line_t * other_opts
tor_cmdline_mode_t command
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)