[or-cvs] [tor/master 05/40] Create routerlist.h
nickm at torproject.org
nickm at torproject.org
Fri Jul 30 01:56:56 UTC 2010
Author: Sebastian Hahn <sebastian at torproject.org>
Date: Wed, 21 Jul 2010 17:08:11 +0200
Subject: Create routerlist.h
Commit: cbee969f407b53d2b453d03460eb2864d0eaf1db
---
src/or/circuitbuild.c | 1 +
src/or/circuitlist.c | 1 +
src/or/circuituse.c | 1 +
src/or/command.c | 1 +
src/or/config.c | 1 +
src/or/connection_edge.c | 1 +
src/or/connection_or.c | 1 +
src/or/control.c | 1 +
src/or/directory.c | 1 +
src/or/dirserv.c | 1 +
src/or/dirvote.c | 1 +
src/or/geoip.c | 1 +
src/or/main.c | 1 +
src/or/networkstatus.c | 1 +
src/or/or.h | 175 -----------------------------------------
src/or/relay.c | 1 +
src/or/rendclient.c | 1 +
src/or/rendcommon.c | 1 +
src/or/rendservice.c | 1 +
src/or/rephist.c | 1 +
src/or/router.c | 1 +
src/or/routerlist.c | 1 +
src/or/routerlist.h | 193 ++++++++++++++++++++++++++++++++++++++++++++++
src/or/routerparse.c | 1 +
src/test/test_dir.c | 1 +
25 files changed, 216 insertions(+), 175 deletions(-)
create mode 100644 src/or/routerlist.h
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 0a25c03..08aa252 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -13,6 +13,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
#include "crypto.h"
#undef log
#include <math.h>
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index e18e892..cc33fcb 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -10,6 +10,7 @@
**/
#include "or.h"
+#include "routerlist.h"
#include "ht.h"
/********* START VARIABLES **********/
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 7a7cc4d..753ae7b 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -11,6 +11,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
/********* START VARIABLES **********/
diff --git a/src/or/command.c b/src/or/command.c
index e367dd7..8ba45a3 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -17,6 +17,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
/** How many CELL_PADDING cells have we received, ever? */
uint64_t stats_n_padding_cells_processed = 0;
diff --git a/src/or/config.c b/src/or/config.c
index 48fa11e..8cd719a 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -14,6 +14,7 @@
#include "or.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
#ifdef MS_WINDOWS
#include <shlobj.h>
#endif
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 35d01ea..8c63d51 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -12,6 +12,7 @@
#include "or.h"
#include "dnsserv.h"
#include "router.h"
+#include "routerlist.h"
#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index e4fe58a..b1ed174 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -13,6 +13,7 @@
#include "or.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
static int connection_tls_finish_handshake(or_connection_t *conn);
static int connection_or_process_cells_from_inbuf(or_connection_t *conn);
diff --git a/src/or/control.c b/src/or/control.c
index 59d0a68..b994513 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -14,6 +14,7 @@
#include "dnsserv.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
/** Yield true iff <b>s</b> is the state of a control_connection_t that has
* finished authentication and is accepting commands. */
diff --git a/src/or/directory.c b/src/or/directory.c
index 9930444..1e31169 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -6,6 +6,7 @@
#include "or.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
#if defined(EXPORTMALLINFO) && defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
#ifndef OPENBSD
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index dbff932..59a8fdc 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -6,6 +6,7 @@
#define DIRSERV_PRIVATE
#include "or.h"
#include "router.h"
+#include "routerlist.h"
/**
* \file dirserv.c
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 637ad54..782e04c 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -6,6 +6,7 @@
#define DIRVOTE_PRIVATE
#include "or.h"
#include "router.h"
+#include "routerlist.h"
/**
* \file dirvote.c
diff --git a/src/or/geoip.c b/src/or/geoip.c
index f027f32..5275c6e 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -12,6 +12,7 @@
#include "ht.h"
#include "dnsserv.h"
#include "geoip.h"
+#include "routerlist.h"
static void clear_geoip_db(void);
diff --git a/src/or/main.c b/src/or/main.c
index d21de19..271d6fe 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -15,6 +15,7 @@
#include "dnsserv.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
#ifdef USE_DMALLOC
#include <dmalloc.h>
#include <openssl/crypto.h>
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 724730c..92a41b9 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -12,6 +12,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
/* For tracking v2 networkstatus documents. Only caches do this now. */
diff --git a/src/or/or.h b/src/or/or.h
index 5eac329..e9fd5b1 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4808,21 +4808,6 @@ typedef struct trusted_dir_server_t {
#define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
-int get_n_authorities(authority_type_t type);
-int trusted_dirs_reload_certs(void);
-int trusted_dirs_load_certs_from_string(const char *contents, int from_store,
- int flush);
-void trusted_dirs_flush_certs_to_disk(void);
-authority_cert_t *authority_cert_get_newest_by_id(const char *id_digest);
-authority_cert_t *authority_cert_get_by_sk_digest(const char *sk_digest);
-authority_cert_t *authority_cert_get_by_digests(const char *id_digest,
- const char *sk_digest);
-void authority_cert_get_all(smartlist_t *certs_out);
-void authority_cert_dl_failed(const char *id_digest, int status);
-void authority_certs_fetch_missing(networkstatus_t *status, time_t now);
-int router_reload_router_list(void);
-smartlist_t *router_get_trusted_dir_servers(void);
-
/* Flags for pick_directory_server and pick_trusteddirserver. */
/** Flag to indicate that we should not automatically be willing to use
* ourself to answer a directory request.
@@ -4852,25 +4837,6 @@ smartlist_t *router_get_trusted_dir_servers(void);
*/
#define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3)
#define _PDS_PREFER_TUNNELED_DIR_CONNS (1<<16)
-routerstatus_t *router_pick_directory_server(authority_type_t type, int flags);
-trusted_dir_server_t *router_get_trusteddirserver_by_digest(const char *d);
-trusted_dir_server_t *trusteddirserver_get_by_v3_auth_digest(const char *d);
-routerstatus_t *router_pick_trusteddirserver(authority_type_t type, int flags);
-int router_get_my_share_of_directory_requests(double *v2_share_out,
- double *v3_share_out);
-void router_reset_status_download_failures(void);
-void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
-int routers_in_same_family(routerinfo_t *r1, routerinfo_t *r2);
-void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
- int must_be_running);
-int router_nickname_is_in_list(routerinfo_t *router, const char *list);
-routerinfo_t *routerlist_find_my_routerinfo(void);
-routerinfo_t *router_find_exact_exit_enclave(const char *address,
- uint16_t port);
-int router_is_unreliable(routerinfo_t *router, int need_uptime,
- int need_capacity, int need_guard);
-uint32_t router_get_advertised_bandwidth(routerinfo_t *router);
-uint32_t router_get_advertised_bandwidth_capped(routerinfo_t *router);
/** Possible ways to weight routers when choosing one randomly. See
* routerlist_sl_choose_by_bandwidth() for more information.*/
@@ -4878,10 +4844,6 @@ typedef enum bandwidth_weight_rule_t {
NO_WEIGHTING, WEIGHT_FOR_EXIT, WEIGHT_FOR_MID, WEIGHT_FOR_GUARD,
WEIGHT_FOR_DIR
} bandwidth_weight_rule_t;
-routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl,
- bandwidth_weight_rule_t rule);
-routerstatus_t *routerstatus_sl_choose_by_bandwidth(smartlist_t *sl,
- bandwidth_weight_rule_t rule);
/* XXXX actually declared in reasons.c */
const char *bandwidth_weight_rule_to_string(enum bandwidth_weight_rule_t rule);
@@ -4897,38 +4859,6 @@ typedef enum {
CRN_WEIGHT_AS_EXIT = 1<<5
} router_crn_flags_t;
-routerinfo_t *router_choose_random_node(smartlist_t *excludedsmartlist,
- struct routerset_t *excludedset,
- router_crn_flags_t flags);
-
-routerinfo_t *router_get_by_nickname(const char *nickname,
- int warn_if_unnamed);
-int router_digest_version_as_new_as(const char *digest, const char *cutoff);
-int router_digest_is_trusted_dir_type(const char *digest,
- authority_type_t type);
-#define router_digest_is_trusted_dir(d) \
- router_digest_is_trusted_dir_type((d), NO_AUTHORITY)
-
-int router_addr_is_trusted_dir(uint32_t addr);
-int hexdigest_to_digest(const char *hexdigest, char *digest);
-routerinfo_t *router_get_by_hexdigest(const char *hexdigest);
-routerinfo_t *router_get_by_digest(const char *digest);
-signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
-signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
-signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
-const char *signed_descriptor_get_body(signed_descriptor_t *desc);
-const char *signed_descriptor_get_annotations(signed_descriptor_t *desc);
-routerlist_t *router_get_routerlist(void);
-void routerinfo_free(routerinfo_t *router);
-void extrainfo_free(extrainfo_t *extrainfo);
-void routerlist_free(routerlist_t *rl);
-void dump_routerlist_mem_usage(int severity);
-void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
- time_t now);
-void routerlist_free_all(void);
-void routerlist_reset_warnings(void);
-void router_set_status(const char *digest, int up);
-
/** Return value for router_add_to_routerlist() and dirserv_add_descriptor() */
typedef enum was_router_added_t {
ROUTER_ADDED_SUCCESSFULLY = 1,
@@ -4940,111 +4870,6 @@ typedef enum was_router_added_t {
ROUTER_AUTHDIR_REJECTS = -5,
} was_router_added_t;
-static int WRA_WAS_ADDED(was_router_added_t s);
-static int WRA_WAS_OUTDATED(was_router_added_t s);
-static int WRA_WAS_REJECTED(was_router_added_t s);
-/** Return true iff the descriptor was added. It might still be necessary to
- * check whether the descriptor generator should be notified.
- */
-static INLINE int
-WRA_WAS_ADDED(was_router_added_t s) {
- return s == ROUTER_ADDED_SUCCESSFULLY || s == ROUTER_ADDED_NOTIFY_GENERATOR;
-}
-/** Return true iff the descriptor was not added because it was either:
- * - not in the consensus
- * - neither in the consensus nor in any networkstatus document
- * - it was outdated.
- */
-static INLINE int WRA_WAS_OUTDATED(was_router_added_t s)
-{
- return (s == ROUTER_WAS_NOT_NEW ||
- s == ROUTER_NOT_IN_CONSENSUS ||
- s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS);
-}
-/** Return true iff the descriptor rejected because it was malformed. */
-static INLINE int WRA_WAS_REJECTED(was_router_added_t s)
-{
- return (s == ROUTER_AUTHDIR_REJECTS);
-}
-was_router_added_t router_add_to_routerlist(routerinfo_t *router,
- const char **msg,
- int from_cache,
- int from_fetch);
-was_router_added_t router_add_extrainfo_to_routerlist(
- extrainfo_t *ei, const char **msg,
- int from_cache, int from_fetch);
-void routerlist_remove_old_routers(void);
-int router_load_single_router(const char *s, uint8_t purpose, int cache,
- const char **msg);
-int router_load_routers_from_string(const char *s, const char *eos,
- saved_location_t saved_location,
- smartlist_t *requested_fingerprints,
- int descriptor_digests,
- const char *prepend_annotations);
-void router_load_extrainfo_from_string(const char *s, const char *eos,
- saved_location_t saved_location,
- smartlist_t *requested_fingerprints,
- int descriptor_digests);
-void routerlist_retry_directory_downloads(time_t now);
-int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
- int need_uptime);
-int router_exit_policy_rejects_all(routerinfo_t *router);
-trusted_dir_server_t *add_trusted_dir_server(const char *nickname,
- const char *address,
- uint16_t dir_port, uint16_t or_port,
- const char *digest, const char *v3_auth_digest,
- authority_type_t type);
-void authority_cert_free(authority_cert_t *cert);
-void clear_trusted_dir_servers(void);
-int any_trusted_dir_is_v1_authority(void);
-void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
- networkstatus_t *consensus);
-void update_router_descriptor_downloads(time_t now);
-void update_extrainfo_downloads(time_t now);
-int router_have_minimum_dir_info(void);
-void router_dir_info_changed(void);
-const char *get_dir_info_status_string(void);
-int count_loading_descriptors_progress(void);
-void router_reset_descriptor_download_failures(void);
-int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
-int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
- signed_descriptor_t *sd,
- const char **msg);
-void routerlist_assert_ok(routerlist_t *rl);
-const char *esc_router_info(routerinfo_t *router);
-void routers_sort_by_identity(smartlist_t *routers);
-
-routerset_t *routerset_new(void);
-int routerset_parse(routerset_t *target, const char *s,
- const char *description);
-void routerset_union(routerset_t *target, const routerset_t *source);
-int routerset_is_list(const routerset_t *set);
-int routerset_needs_geoip(const routerset_t *set);
-int routerset_contains_router(const routerset_t *set, routerinfo_t *ri);
-int routerset_contains_routerstatus(const routerset_t *set,
- routerstatus_t *rs);
-int routerset_contains_extendinfo(const routerset_t *set,
- const extend_info_t *ei);
-void routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
- int running_only);
-void routersets_get_disjunction(smartlist_t *target, const smartlist_t *source,
- const routerset_t *include,
- const routerset_t *exclude, int running_only);
-void routerset_subtract_routers(smartlist_t *out,
- const routerset_t *routerset);
-char *routerset_to_string(const routerset_t *routerset);
-void routerset_refresh_countries(routerset_t *target);
-int routerset_equal(const routerset_t *old, const routerset_t *new);
-void routerset_free(routerset_t *routerset);
-void routerinfo_set_country(routerinfo_t *ri);
-void routerlist_refresh_countries(void);
-void refresh_all_country_info(void);
-
-int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
- const char *id);
-int hid_serv_acting_as_directory(void);
-int hid_serv_responsible_for_desc_id(const char *id);
-
/********************************* routerparse.c ************************/
#define MAX_STATUS_TAG_LEN 32
diff --git a/src/or/relay.c b/src/or/relay.c
index 1c15549..d227bdf 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -14,6 +14,7 @@
#include "or.h"
#include "geoip.h"
#include "mempool.h"
+#include "routerlist.h"
static int relay_crypt(circuit_t *circ, cell_t *cell,
cell_direction_t cell_direction,
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 9a31c2d..0a9f483 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -8,6 +8,7 @@
**/
#include "or.h"
+#include "routerlist.h"
/** Called when we've established a circuit to an introduction point:
* send the introduction request. */
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 814abd8..4af0415 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -9,6 +9,7 @@
**/
#include "or.h"
+#include "routerlist.h"
/** Return 0 if one and two are the same service ids, else -1 or 1 */
int
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 30df64e..c7dc3c9 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -9,6 +9,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro,
const char *pk_digest);
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 00a2cab..25fda23 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -11,6 +11,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
#include "ht.h"
static void bw_arrays_init(void);
diff --git a/src/or/router.c b/src/or/router.c
index 2031681..53a4a7d 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -9,6 +9,7 @@
#include "or.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
/**
* \file router.c
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 7d9e48c..b4803e9 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -14,6 +14,7 @@
#include "or.h"
#include "geoip.h"
#include "router.h"
+#include "routerlist.h"
// #define DEBUG_ROUTERLIST
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
new file mode 100644
index 0000000..bbb3c5f
--- /dev/null
+++ b/src/or/routerlist.h
@@ -0,0 +1,193 @@
+/* Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2010, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file routerlist.h
+ * \brief Header file for routerlist functions
+ **/
+
+#ifndef _TOR_ROUTERLIST_H
+#define _TOR_ROUTERLIST_H
+
+int get_n_authorities(authority_type_t type);
+int trusted_dirs_reload_certs(void);
+int trusted_dirs_load_certs_from_string(const char *contents, int from_store,
+ int flush);
+void trusted_dirs_flush_certs_to_disk(void);
+authority_cert_t *authority_cert_get_newest_by_id(const char *id_digest);
+authority_cert_t *authority_cert_get_by_sk_digest(const char *sk_digest);
+authority_cert_t *authority_cert_get_by_digests(const char *id_digest,
+ const char *sk_digest);
+void authority_cert_get_all(smartlist_t *certs_out);
+void authority_cert_dl_failed(const char *id_digest, int status);
+void authority_certs_fetch_missing(networkstatus_t *status, time_t now);
+int router_reload_router_list(void);
+smartlist_t *router_get_trusted_dir_servers(void);
+
+routerstatus_t *router_pick_directory_server(authority_type_t type, int flags);
+trusted_dir_server_t *router_get_trusteddirserver_by_digest(const char *d);
+trusted_dir_server_t *trusteddirserver_get_by_v3_auth_digest(const char *d);
+routerstatus_t *router_pick_trusteddirserver(authority_type_t type, int flags);
+int router_get_my_share_of_directory_requests(double *v2_share_out,
+ double *v3_share_out);
+void router_reset_status_download_failures(void);
+void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
+int routers_in_same_family(routerinfo_t *r1, routerinfo_t *r2);
+void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
+ int must_be_running);
+int router_nickname_is_in_list(routerinfo_t *router, const char *list);
+routerinfo_t *routerlist_find_my_routerinfo(void);
+routerinfo_t *router_find_exact_exit_enclave(const char *address,
+ uint16_t port);
+int router_is_unreliable(routerinfo_t *router, int need_uptime,
+ int need_capacity, int need_guard);
+uint32_t router_get_advertised_bandwidth(routerinfo_t *router);
+uint32_t router_get_advertised_bandwidth_capped(routerinfo_t *router);
+
+routerinfo_t *routerlist_sl_choose_by_bandwidth(smartlist_t *sl,
+ bandwidth_weight_rule_t rule);
+routerstatus_t *routerstatus_sl_choose_by_bandwidth(smartlist_t *sl,
+ bandwidth_weight_rule_t rule);
+
+routerinfo_t *router_choose_random_node(smartlist_t *excludedsmartlist,
+ struct routerset_t *excludedset,
+ router_crn_flags_t flags);
+
+routerinfo_t *router_get_by_nickname(const char *nickname,
+ int warn_if_unnamed);
+int router_digest_version_as_new_as(const char *digest, const char *cutoff);
+int router_digest_is_trusted_dir_type(const char *digest,
+ authority_type_t type);
+#define router_digest_is_trusted_dir(d) \
+ router_digest_is_trusted_dir_type((d), NO_AUTHORITY)
+
+int router_addr_is_trusted_dir(uint32_t addr);
+int hexdigest_to_digest(const char *hexdigest, char *digest);
+routerinfo_t *router_get_by_hexdigest(const char *hexdigest);
+routerinfo_t *router_get_by_digest(const char *digest);
+signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
+signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
+signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
+const char *signed_descriptor_get_body(signed_descriptor_t *desc);
+const char *signed_descriptor_get_annotations(signed_descriptor_t *desc);
+routerlist_t *router_get_routerlist(void);
+void routerinfo_free(routerinfo_t *router);
+void extrainfo_free(extrainfo_t *extrainfo);
+void routerlist_free(routerlist_t *rl);
+void dump_routerlist_mem_usage(int severity);
+void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int make_old,
+ time_t now);
+void routerlist_free_all(void);
+void routerlist_reset_warnings(void);
+void router_set_status(const char *digest, int up);
+
+static int WRA_WAS_ADDED(was_router_added_t s);
+static int WRA_WAS_OUTDATED(was_router_added_t s);
+static int WRA_WAS_REJECTED(was_router_added_t s);
+/** Return true iff the descriptor was added. It might still be necessary to
+ * check whether the descriptor generator should be notified.
+ */
+static INLINE int
+WRA_WAS_ADDED(was_router_added_t s) {
+ return s == ROUTER_ADDED_SUCCESSFULLY || s == ROUTER_ADDED_NOTIFY_GENERATOR;
+}
+/** Return true iff the descriptor was not added because it was either:
+ * - not in the consensus
+ * - neither in the consensus nor in any networkstatus document
+ * - it was outdated.
+ */
+static INLINE int WRA_WAS_OUTDATED(was_router_added_t s)
+{
+ return (s == ROUTER_WAS_NOT_NEW ||
+ s == ROUTER_NOT_IN_CONSENSUS ||
+ s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS);
+}
+static INLINE int WRA_WAS_REJECTED(was_router_added_t s)
+{
+ return (s == ROUTER_AUTHDIR_REJECTS);
+}
+was_router_added_t router_add_to_routerlist(routerinfo_t *router,
+ const char **msg,
+ int from_cache,
+ int from_fetch);
+was_router_added_t router_add_extrainfo_to_routerlist(
+ extrainfo_t *ei, const char **msg,
+ int from_cache, int from_fetch);
+void routerlist_remove_old_routers(void);
+int router_load_single_router(const char *s, uint8_t purpose, int cache,
+ const char **msg);
+int router_load_routers_from_string(const char *s, const char *eos,
+ saved_location_t saved_location,
+ smartlist_t *requested_fingerprints,
+ int descriptor_digests,
+ const char *prepend_annotations);
+void router_load_extrainfo_from_string(const char *s, const char *eos,
+ saved_location_t saved_location,
+ smartlist_t *requested_fingerprints,
+ int descriptor_digests);
+
+void routerlist_retry_directory_downloads(time_t now);
+int router_exit_policy_all_routers_reject(uint32_t addr, uint16_t port,
+ int need_uptime);
+int router_exit_policy_rejects_all(routerinfo_t *router);
+trusted_dir_server_t *add_trusted_dir_server(const char *nickname,
+ const char *address,
+ uint16_t dir_port, uint16_t or_port,
+ const char *digest, const char *v3_auth_digest,
+ authority_type_t type);
+void authority_cert_free(authority_cert_t *cert);
+void clear_trusted_dir_servers(void);
+int any_trusted_dir_is_v1_authority(void);
+void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
+ networkstatus_t *consensus);
+void update_router_descriptor_downloads(time_t now);
+void update_extrainfo_downloads(time_t now);
+int router_have_minimum_dir_info(void);
+void router_dir_info_changed(void);
+const char *get_dir_info_status_string(void);
+int count_loading_descriptors_progress(void);
+void router_reset_descriptor_download_failures(void);
+int router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2);
+int routerinfo_incompatible_with_extrainfo(routerinfo_t *ri, extrainfo_t *ei,
+ signed_descriptor_t *sd,
+ const char **msg);
+
+void routerlist_assert_ok(routerlist_t *rl);
+const char *esc_router_info(routerinfo_t *router);
+void routers_sort_by_identity(smartlist_t *routers);
+
+routerset_t *routerset_new(void);
+int routerset_parse(routerset_t *target, const char *s,
+ const char *description);
+void routerset_union(routerset_t *target, const routerset_t *source);
+int routerset_is_list(const routerset_t *set);
+int routerset_needs_geoip(const routerset_t *set);
+int routerset_contains_router(const routerset_t *set, routerinfo_t *ri);
+int routerset_contains_routerstatus(const routerset_t *set,
+ routerstatus_t *rs);
+int routerset_contains_extendinfo(const routerset_t *set,
+ const extend_info_t *ei);
+void routerset_get_all_routers(smartlist_t *out, const routerset_t *routerset,
+ int running_only);
+void routersets_get_disjunction(smartlist_t *target, const smartlist_t *source,
+ const routerset_t *include,
+ const routerset_t *exclude, int running_only);
+void routerset_subtract_routers(smartlist_t *out,
+ const routerset_t *routerset);
+char *routerset_to_string(const routerset_t *routerset);
+void routerset_refresh_countries(routerset_t *target);
+int routerset_equal(const routerset_t *old, const routerset_t *new);
+void routerset_free(routerset_t *routerset);
+void routerinfo_set_country(routerinfo_t *ri);
+void routerlist_refresh_countries(void);
+void refresh_all_country_info(void);
+
+int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
+ const char *id);
+int hid_serv_acting_as_directory(void);
+int hid_serv_responsible_for_desc_id(const char *id);
+
+#endif
+
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 3da1915..760f876 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -11,6 +11,7 @@
#include "or.h"
#include "router.h"
+#include "routerlist.h"
#include "memarea.h"
#undef log
#include <math.h>
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index f99352a..5ea09d0 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -9,6 +9,7 @@
#define ROUTER_PRIVATE
#include "or.h"
#include "router.h"
+#include "routerlist.h"
#include "test.h"
static void
--
1.7.1
More information about the tor-commits
mailing list