tor  0.4.2.0-alpha-dev
dirclient.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-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_DIRCLIENT_H
13 #define TOR_DIRCLIENT_H
14 
15 #include "feature/hs/hs_ident.h"
16 
18 void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,
19  dirinfo_type_t type, const char *payload,
20  size_t payload_len, size_t extrainfo_len);
21 MOCK_DECL(void, directory_get_from_dirserver, (
22  uint8_t dir_purpose,
23  uint8_t router_purpose,
24  const char *resource,
25  int pds_flags,
26  download_want_authority_t want_authority));
27 void directory_get_from_all_authorities(uint8_t dir_purpose,
28  uint8_t router_purpose,
29  const char *resource);
30 
32 typedef enum {
43 
44 int directory_must_use_begindir(const or_options_t *options);
45 
53 directory_request_t *directory_request_new(uint8_t dir_purpose);
55 #define directory_request_free(req) \
56  FREE_AND_NULL(directory_request_t, directory_request_free_, (req))
58  const tor_addr_port_t *p);
60  const tor_addr_port_t *p);
62  const char *digest);
63 struct circuit_guard_state_t;
65  struct circuit_guard_state_t *state);
67  uint8_t router_purpose);
69  dir_indirection_t indirection);
71  const char *resource);
73  const char *payload,
74  size_t payload_len);
76  time_t if_modified_since);
78  const rend_data_t *query);
80  const hs_ident_dir_conn_t *ident);
82  const hs_ident_dir_conn_t *ident);
83 
85  const routerstatus_t *rs);
87  const char *key,
88  const char *val);
89 MOCK_DECL(void, directory_initiate_request, (directory_request_t *request));
90 
91 int router_supports_extrainfo(const char *identity_digest, int is_authority);
92 
95  dir_connection_t *dir_conn);
96 
97 #ifdef DIRCLIENT_PRIVATE
98 struct directory_request_t {
104  tor_addr_port_t or_addr_port;
105  tor_addr_port_t dir_addr_port;
106  char digest[DIGEST_LEN];
107 
108  const routerstatus_t *routerstatus;
113  uint8_t dir_purpose;
116  uint8_t router_purpose;
119  dir_indirection_t indirection;
121  const char *resource;
123  const char *payload;
125  size_t payload_len;
127  time_t if_modified_since;
129  const rend_data_t *rend_query;
131  struct config_line_t *additional_headers;
133  const hs_ident_dir_conn_t *hs_ident;
137  struct circuit_guard_state_t *guard_state;
138 };
139 
142 typedef struct response_handler_args_t {
143  int status_code;
144  const char *reason;
145  const char *body;
146  size_t body_len;
147  const char *headers;
148 } response_handler_args_t;
149 
150 enum compress_method_t;
151 STATIC int allowed_anonymous_connection_compression_method(
152  enum compress_method_t);
153 STATIC void warn_disallowed_anonymous_compression_method(
154  enum compress_method_t);
155 
156 STATIC int should_use_directory_guards(const or_options_t *options);
157 STATIC char *accept_encoding_header(void);
158 STATIC const char *dir_conn_purpose_to_string(int purpose);
159 
160 STATIC int handle_response_fetch_hsdesc_v3(dir_connection_t *conn,
161  const response_handler_args_t *args);
162 STATIC int handle_response_fetch_microdesc(dir_connection_t *conn,
163  const response_handler_args_t *args);
164 
165 STATIC int handle_response_fetch_consensus(dir_connection_t *conn,
166  const response_handler_args_t *args);
167 
168 STATIC dirinfo_type_t dir_fetch_type(int dir_purpose, int router_purpose,
169  const char *resource);
170 #endif /* defined(DIRCLIENT_PRIVATE) */
171 
172 #endif /* !defined(TOR_DIRCLIENT_H) */
void directory_request_set_dir_addr_port(directory_request_t *req, const tor_addr_port_t *p)
Definition: dirclient.c:992
void directory_request_set_routerstatus(directory_request_t *req, const routerstatus_t *rs)
Definition: dirclient.c:1160
dir_indirection_t
Definition: dirclient.h:32
int router_supports_extrainfo(const char *identity_digest, int is_authority)
Definition: dirclient.c:174
void directory_get_from_all_authorities(uint8_t dir_purpose, uint8_t router_purpose, const char *resource)
Definition: dirclient.c:579
download_want_authority_t
Definition: or.h:778
struct directory_request_t directory_request_t
Definition: dirclient.h:52
void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose, dirinfo_type_t type, const char *payload, size_t payload_len, size_t extrainfo_len)
Definition: dirclient.c:228
dirinfo_type_t
Definition: or.h:891
void connection_dir_client_request_failed(dir_connection_t *conn)
Definition: dirclient.c:719
void directory_request_set_indirection(directory_request_t *req, dir_indirection_t indirection)
Definition: dirclient.c:1030
directory_request_t * directory_request_new(uint8_t dir_purpose)
Definition: dirclient.c:946
void directory_request_set_guard_state(directory_request_t *req, struct circuit_guard_state_t *state)
Definition: dirclient.c:1135
#define DIGEST_LEN
Definition: digest_sizes.h:20
void directory_request_fetch_set_hs_ident(directory_request_t *req, const hs_ident_dir_conn_t *ident)
Definition: dirclient.c:1123
int directories_have_accepted_server_descriptor(void)
Definition: dirclient.c:197
Header file containing circuit and connection identifier data for the whole HS subsytem.
void directory_request_set_router_purpose(directory_request_t *req, uint8_t router_purpose)
Definition: dirclient.c:1014
void directory_request_add_header(directory_request_t *req, const char *key, const char *val)
Definition: dirclient.c:1082
void directory_request_set_if_modified_since(directory_request_t *req, time_t if_modified_since)
Definition: dirclient.c:1068
void directory_request_set_or_addr_port(directory_request_t *req, const tor_addr_port_t *p)
Definition: dirclient.c:981
void directory_request_set_rend_query(directory_request_t *req, const rend_data_t *query)
Definition: dirclient.c:1094
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:94
void directory_request_free_(directory_request_t *req)
Definition: dirclient.c:968
void directory_request_set_directory_id_digest(directory_request_t *req, const char *digest)
Definition: dirclient.c:1002
void directory_request_upload_set_hs_ident(directory_request_t *req, const hs_ident_dir_conn_t *ident)
Definition: dirclient.c:1109
compress_method_t
Definition: compress.h:21
void connection_dir_client_refetch_hsdesc_if_needed(dir_connection_t *dir_conn)
Definition: dirclient.c:3009
void directory_request_set_resource(directory_request_t *req, const char *resource)
Definition: dirclient.c:1043
void directory_request_set_payload(directory_request_t *req, const char *payload, size_t payload_len)
Definition: dirclient.c:1054