Don't use log_err for non-criticial warnings.
[tor/rransom.git] / src / or / dirserv.h
blob94e4e811d65089537878e6a55e05f76562a7d462
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-2010, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
7 /**
8 * \file dirserv.h
9 * \brief Header file for dirserv.c.
10 **/
12 #ifndef _TOR_DIRSERV_H
13 #define _TOR_DIRSERV_H
15 /** Maximum length of an exit policy summary. */
16 #define MAX_EXITPOLICY_SUMMARY_LEN 1000
18 /** Maximum allowable length of a version line in a networkstatus. */
19 #define MAX_V_LINE_LEN 128
20 /** Length of "r Authority BadDirectory BadExit Exit Fast Guard HSDir Named
21 * Running Stable Unnamed V2Dir Valid\n". */
22 #define MAX_FLAG_LINE_LEN 96
23 /** Length of "w" line for weighting. Currently at most
24 * "w Bandwidth=<uint32t> Measured=<uint32t>\n" */
25 #define MAX_WEIGHT_LINE_LEN (12+10+10+10+1)
26 /** Maximum length of an exit policy summary line. */
27 #define MAX_POLICY_LINE_LEN (3+MAX_EXITPOLICY_SUMMARY_LEN)
28 /** Amount of space to allocate for each entry: r, s, and v lines. */
29 #define RS_ENTRY_LEN \
30 ( /* first line */ \
31 MAX_NICKNAME_LEN+BASE64_DIGEST_LEN*2+ISO_TIME_LEN+INET_NTOA_BUF_LEN+ \
32 5*2 /* ports */ + 10 /* punctuation */ + \
33 /* second line */ \
34 MAX_FLAG_LINE_LEN + \
35 /* weight line */ \
36 MAX_WEIGHT_LINE_LEN + \
37 /* p line. */ \
38 MAX_POLICY_LINE_LEN + \
39 /* v line. */ \
40 MAX_V_LINE_LEN \
43 #define UNNAMED_ROUTER_NICKNAME "Unnamed"
45 int connection_dirserv_flushed_some(dir_connection_t *conn);
47 int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk);
48 int dirserv_load_fingerprint_file(void);
49 void dirserv_free_fingerprint_list(void);
50 const char *dirserv_get_nickname_by_digest(const char *digest);
51 enum was_router_added_t dirserv_add_multiple_descriptors(
52 const char *desc, uint8_t purpose,
53 const char *source,
54 const char **msg);
55 enum was_router_added_t dirserv_add_descriptor(routerinfo_t *ri,
56 const char **msg,
57 const char *source);
58 void dirserv_set_router_is_running(routerinfo_t *router, time_t now);
59 int list_server_status_v1(smartlist_t *routers, char **router_status_out,
60 int for_controller);
61 int dirserv_dump_directory_to_string(char **dir_out,
62 crypto_pk_env_t *private_key);
64 int directory_fetches_from_authorities(or_options_t *options);
65 int directory_fetches_dir_info_early(or_options_t *options);
66 int directory_fetches_dir_info_later(or_options_t *options);
67 int directory_caches_v2_dir_info(or_options_t *options);
68 #define directory_caches_v1_dir_info(o) directory_caches_v2_dir_info(o)
69 int directory_caches_dir_info(or_options_t *options);
70 int directory_permits_begindir_requests(or_options_t *options);
71 int directory_permits_controller_requests(or_options_t *options);
72 int directory_too_idle_to_fetch_descriptors(or_options_t *options, time_t now);
74 void directory_set_dirty(void);
75 cached_dir_t *dirserv_get_directory(void);
76 cached_dir_t *dirserv_get_runningrouters(void);
77 cached_dir_t *dirserv_get_consensus(const char *flavor_name);
78 void dirserv_set_cached_directory(const char *directory, time_t when,
79 int is_running_routers);
80 void dirserv_set_cached_networkstatus_v2(const char *directory,
81 const char *identity,
82 time_t published);
83 void dirserv_set_cached_consensus_networkstatus(const char *consensus,
84 const char *flavor_name,
85 const digests_t *digests,
86 time_t published);
87 void dirserv_clear_old_networkstatuses(time_t cutoff);
88 void dirserv_clear_old_v1_info(time_t now);
89 void dirserv_get_networkstatus_v2(smartlist_t *result, const char *key);
90 void dirserv_get_networkstatus_v2_fingerprints(smartlist_t *result,
91 const char *key);
92 int dirserv_get_routerdesc_fingerprints(smartlist_t *fps_out, const char *key,
93 const char **msg,
94 int for_unencrypted_conn,
95 int is_extrainfo);
96 int dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
97 const char **msg);
98 void dirserv_orconn_tls_done(const char *address,
99 uint16_t or_port,
100 const char *digest_rcvd,
101 int as_advertised);
102 int dirserv_should_launch_reachability_test(routerinfo_t *ri,
103 routerinfo_t *ri_old);
104 void dirserv_single_reachability_test(time_t now, routerinfo_t *router);
105 void dirserv_test_reachability(time_t now);
106 int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
107 int complain);
108 int dirserv_would_reject_router(routerstatus_t *rs);
109 int dirserv_remove_old_statuses(smartlist_t *fps, time_t cutoff);
110 int dirserv_have_any_serverdesc(smartlist_t *fps, int spool_src);
111 int dirserv_have_any_microdesc(const smartlist_t *fps);
112 size_t dirserv_estimate_data_size(smartlist_t *fps, int is_serverdescs,
113 int compressed);
114 size_t dirserv_estimate_microdesc_size(const smartlist_t *fps, int compressed);
116 int routerstatus_format_entry(char *buf, size_t buf_len,
117 routerstatus_t *rs, const char *platform,
118 routerstatus_format_type_t format);
119 void dirserv_free_all(void);
120 void cached_dir_decref(cached_dir_t *d);
121 cached_dir_t *new_cached_dir(char *s, time_t published);
123 #ifdef DIRSERV_PRIVATE
124 int measured_bw_line_parse(measured_bw_line_t *out, const char *line);
126 int measured_bw_line_apply(measured_bw_line_t *parsed_line,
127 smartlist_t *routerstatuses);
128 #endif
130 int dirserv_read_measured_bandwidths(const char *from_file,
131 smartlist_t *routerstatuses);
133 #endif