tor  0.4.2.0-alpha-dev
directory.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_DIRECTORY_H
13 #define TOR_DIRECTORY_H
14 
16 
17 #define DIR_CONN_STATE_MIN_ 1
18 
19 #define DIR_CONN_STATE_CONNECTING 1
20 
21 #define DIR_CONN_STATE_CLIENT_SENDING 2
22 
23 #define DIR_CONN_STATE_CLIENT_READING 3
24 
25 #define DIR_CONN_STATE_CLIENT_FINISHED 4
26 
27 #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5
28 
29 #define DIR_CONN_STATE_SERVER_WRITING 6
30 #define DIR_CONN_STATE_MAX_ 6
31 
32 #define DIR_PURPOSE_MIN_ 4
33 
35 #define DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 4
36 
38 #define DIR_PURPOSE_FETCH_SERVERDESC 6
39 
41 #define DIR_PURPOSE_FETCH_EXTRAINFO 7
42 
43 #define DIR_PURPOSE_UPLOAD_DIR 8
44 
45 #define DIR_PURPOSE_UPLOAD_VOTE 10
46 
47 #define DIR_PURPOSE_UPLOAD_SIGNATURES 11
48 
50 #define DIR_PURPOSE_FETCH_STATUS_VOTE 12
51 
53 #define DIR_PURPOSE_FETCH_DETACHED_SIGNATURES 13
54 
56 #define DIR_PURPOSE_FETCH_CONSENSUS 14
57 
59 #define DIR_PURPOSE_FETCH_CERTIFICATE 15
60 
62 #define DIR_PURPOSE_SERVER 16
63 
65 #define DIR_PURPOSE_UPLOAD_RENDDESC_V2 17
66 
68 #define DIR_PURPOSE_FETCH_RENDDESC_V2 18
69 
70 #define DIR_PURPOSE_FETCH_MICRODESC 19
71 
72 #define DIR_PURPOSE_UPLOAD_HSDESC 20
73 
74 #define DIR_PURPOSE_FETCH_HSDESC 21
75 
77 #define DIR_PURPOSE_HAS_FETCHED_HSDESC 22
78 #define DIR_PURPOSE_MAX_ 22
79 
82 #define DIR_PURPOSE_IS_UPLOAD(p) \
83  ((p)==DIR_PURPOSE_UPLOAD_DIR || \
84  (p)==DIR_PURPOSE_UPLOAD_VOTE || \
85  (p)==DIR_PURPOSE_UPLOAD_SIGNATURES || \
86  (p)==DIR_PURPOSE_UPLOAD_RENDDESC_V2 || \
87  (p)==DIR_PURPOSE_UPLOAD_HSDESC)
88 
90 int parse_http_response(const char *headers, int *code, time_t *date,
91  enum compress_method_t *compression, char **response);
92 int parse_http_command(const char *headers,
93  char **command_out, char **url_out);
94 char *http_get_header(const char *headers, const char *which);
95 
102 
103 #define DSR_HEX (1<<0)
104 #define DSR_BASE64 (1<<1)
105 #define DSR_DIGEST256 (1<<2)
106 #define DSR_SORT_UNIQ (1<<3)
107 int dir_split_resource_into_fingerprints(const char *resource,
108  smartlist_t *fp_out, int *compressed_out,
109  int flags);
110 enum dir_spool_source_t;
111 int dir_split_resource_into_spoolable(const char *resource,
112  enum dir_spool_source_t source,
113  smartlist_t *spool_out,
114  int *compressed_out,
115  int flags);
117  smartlist_t *pairs_out);
118 char *directory_dump_request_log(void);
119 void note_request(const char *key, size_t bytes);
120 
121 int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose,
122  const char *resource);
123 
125 
126 #define X_ADDRESS_HEADER "X-Your-Address-Is: "
127 #define X_OR_DIFF_FROM_CONSENSUS_HEADER "X-Or-Diff-From-Consensus: "
128 
129 #endif /* !defined(TOR_DIRECTORY_H) */
int connection_dir_reached_eof(dir_connection_t *conn)
Definition: dirclient.c:2988
void connection_dir_about_to_close(dir_connection_t *dir_conn)
Definition: directory.c:389
int dir_split_resource_into_fingerprint_pairs(const char *res, smartlist_t *pairs_out)
Definition: directory.c:485
int connection_dir_finished_flushing(dir_connection_t *conn)
Definition: directory.c:407
char * authdir_type_to_string(dirinfo_type_t auth)
Definition: directory.c:140
dirinfo_type_t
Definition: or.h:887
int parse_http_command(const char *headers, char **command_out, char **url_out)
Definition: directory.c:175
int purpose_needs_anonymity(uint8_t dir_purpose, uint8_t router_purpose, const char *resource)
Definition: directory.c:90
int connection_dir_process_inbuf(dir_connection_t *conn)
Definition: directory.c:347
dir_spool_source_t
Definition: dirserv.h:20
int parse_http_response(const char *headers, int *code, time_t *date, enum compress_method_t *compression, char **response)
Definition: directory.c:264
int dir_split_resource_into_fingerprints(const char *resource, smartlist_t *fp_out, int *compressed_out, int flags)
Definition: directory.c:544
dir_connection_t * TO_DIR_CONN(connection_t *c)
Definition: directory.c:77
char * http_get_header(const char *headers, const char *which)
Definition: directory.c:229
int dir_split_resource_into_spoolable(const char *resource, enum dir_spool_source_t source, smartlist_t *spool_out, int *compressed_out, int flags)
Definition: directory.c:626
int connection_dir_finished_connecting(dir_connection_t *conn)
Definition: directory.c:453
compress_method_t
Definition: compress.h:21
int connection_dir_is_encrypted(const dir_connection_t *conn)
Definition: directory.c:160