[or-cvs] [tor/master 27/40] Create networkstatus.h

nickm at torproject.org nickm at torproject.org
Fri Jul 30 01:56:58 UTC 2010


Author: Sebastian Hahn <sebastian at torproject.org>
Date: Fri, 23 Jul 2010 20:18:55 +0200
Subject: Create networkstatus.h
Commit: 69fcbbaa8932f83ca715d0cf40c69340c90001a1

---
 src/or/circuitbuild.c  |    1 +
 src/or/circuitlist.c   |    1 +
 src/or/config.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/main.c          |    1 +
 src/or/networkstatus.c |    1 +
 src/or/networkstatus.h |  101 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/or/or.h            |   85 ----------------------------------------
 src/or/relay.c         |    1 +
 src/or/rendservice.c   |    1 +
 src/or/routerlist.c    |    1 +
 src/or/routerparse.c   |    1 +
 src/test/test_dir.c    |    1 +
 17 files changed, 116 insertions(+), 85 deletions(-)
 create mode 100644 src/or/networkstatus.h

diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 71eb643..5b36080 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -22,6 +22,7 @@
 #include "control.h"
 #include "directory.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 #include "crypto.h"
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index d2212dc..b8c2737 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -18,6 +18,7 @@
 #include "connection_edge.h"
 #include "connection_or.h"
 #include "control.h"
+#include "networkstatus.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "routerlist.h"
diff --git a/src/or/config.c b/src/or/config.c
index 34acc4f..bfec2f4 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -25,6 +25,7 @@
 #include "geoip.h"
 #include "hibernate.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "rendclient.h"
 #include "rendservice.h"
 #include "router.h"
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 0ddd5f1..8ec5290 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -21,6 +21,7 @@
 #include "dirserv.h"
 #include "geoip.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/control.c b/src/or/control.c
index e1073ab..5f5e45f 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -25,6 +25,7 @@
 #include "geoip.h"
 #include "hibernate.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/directory.c b/src/or/directory.c
index 8c7bf4f..057961d 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -15,6 +15,7 @@
 #include "dirvote.h"
 #include "geoip.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "router.h"
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 5f2c789..d23542c 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -15,6 +15,7 @@
 #include "dirvote.h"
 #include "hibernate.h"
 #include "microdesc.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index 3940298..5b53267 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -10,6 +10,7 @@
 #include "dirserv.h"
 #include "dirvote.h"
 #include "microdesc.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/main.c b/src/or/main.c
index 8e4f35c..18525f0 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -32,6 +32,7 @@
 #include "hibernate.h"
 #include "main.h"
 #include "microdesc.h"
+#include "networkstatus.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "rendservice.h"
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 98af3a2..bd98660 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -18,6 +18,7 @@
 #include "directory.h"
 #include "dirserv.h"
 #include "dirvote.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
new file mode 100644
index 0000000..4059dea
--- /dev/null
+++ b/src/or/networkstatus.h
@@ -0,0 +1,101 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * 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 networkstatus.h
+ * \brief Header file for networkstatus.c.
+ **/
+
+#ifndef _TOR_NETWORKSTATUS_H
+#define _TOR_NETWORKSTATUS_H
+
+/** How old do we allow a v2 network-status to get before removing it
+ * completely? */
+#define MAX_NETWORKSTATUS_AGE (10*24*60*60)
+
+void networkstatus_reset_warnings(void);
+void networkstatus_reset_download_failures(void);
+int router_reload_v2_networkstatus(void);
+int router_reload_consensus_networkstatus(void);
+void routerstatus_free(routerstatus_t *rs);
+void networkstatus_v2_free(networkstatus_v2_t *ns);
+void networkstatus_vote_free(networkstatus_t *ns);
+networkstatus_voter_info_t *networkstatus_get_voter_by_id(
+                                       networkstatus_t *vote,
+                                       const char *identity);
+int networkstatus_check_consensus_signature(networkstatus_t *consensus,
+                                            int warn);
+int networkstatus_check_document_signature(const networkstatus_t *consensus,
+                                           document_signature_t *sig,
+                                           const authority_cert_t *cert);
+char *networkstatus_get_cache_filename(const char *identity_digest);
+int router_set_networkstatus_v2(const char *s, time_t arrived_at,
+                             v2_networkstatus_source_t source,
+                             smartlist_t *requested_fingerprints);
+void networkstatus_v2_list_clean(time_t now);
+int compare_digest_to_routerstatus_entry(const void *_key,
+                                         const void **_member);
+routerstatus_t *networkstatus_v2_find_entry(networkstatus_v2_t *ns,
+                                         const char *digest);
+routerstatus_t *networkstatus_vote_find_entry(networkstatus_t *ns,
+                                              const char *digest);
+int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
+                                      const char *digest, int *found_out);
+const smartlist_t *networkstatus_get_v2_list(void);
+download_status_t *router_get_dl_status_by_descriptor_digest(const char *d);
+routerstatus_t *router_get_consensus_status_by_id(const char *digest);
+routerstatus_t *router_get_consensus_status_by_descriptor_digest(
+                                                        const char *digest);
+routerstatus_t *router_get_consensus_status_by_nickname(const char *nickname,
+                                                       int warn_if_unnamed);
+const char *networkstatus_get_router_digest_by_nickname(const char *nickname);
+int networkstatus_nickname_is_unnamed(const char *nickname);
+void networkstatus_consensus_download_failed(int status_code);
+void update_consensus_networkstatus_fetch_time(time_t now);
+int should_delay_dir_fetches(or_options_t *options);
+void update_networkstatus_downloads(time_t now);
+void update_certificate_downloads(time_t now);
+int consensus_is_waiting_for_certs(void);
+networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
+networkstatus_t *networkstatus_get_latest_consensus(void);
+networkstatus_t *networkstatus_get_live_consensus(time_t now);
+networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now);
+#define NSSET_FROM_CACHE 1
+#define NSSET_WAS_WAITING_FOR_CERTS 2
+#define NSSET_DONT_DOWNLOAD_CERTS 4
+#define NSSET_ACCEPT_OBSOLETE 8
+#define NSSET_REQUIRE_FLAVOR 16
+int networkstatus_set_current_consensus(const char *consensus,
+                                        const char *flavor,
+                                        unsigned flags);
+void networkstatus_note_certs_arrived(void);
+void routers_update_all_from_networkstatus(time_t now, int dir_version);
+void routerstatus_list_update_from_consensus_networkstatus(time_t now);
+void routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
+                                                        int reset_failures);
+void signed_descs_update_status_from_consensus_networkstatus(
+                                                         smartlist_t *descs);
+
+char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
+char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
+void networkstatus_dump_bridge_status_to_file(time_t now);
+int32_t get_net_param_from_list(smartlist_t *net_params, const char *name,
+                                int default_val);
+int32_t networkstatus_get_param(networkstatus_t *ns, const char *param_name,
+                                int32_t default_val);
+int getinfo_helper_networkstatus(control_connection_t *conn,
+                                 const char *question, char **answer,
+                                 const char **errmsg);
+int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
+                                    int32_t default_val);
+const char *networkstatus_get_flavor_name(consensus_flavor_t flav);
+int networkstatus_parse_flavor_name(const char *flavname);
+void document_signature_free(document_signature_t *sig);
+document_signature_t *document_signature_dup(const document_signature_t *sig);
+void networkstatus_free_all(void);
+
+#endif
+
diff --git a/src/or/or.h b/src/or/or.h
index 2b3b384..4f1eab5 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -3274,10 +3274,6 @@ typedef struct microdesc_cache_t microdesc_cache_t;
 
 /********************************* networkstatus.c *********************/
 
-/** How old do we allow a v2 network-status to get before removing it
- * completely? */
-#define MAX_NETWORKSTATUS_AGE (10*24*60*60)
-
 /** Location where we found a v2 networkstatus. */
 typedef enum {
   NS_FROM_CACHE, NS_FROM_DIR_BY_FP, NS_FROM_DIR_ALL, NS_GENERATED
@@ -3297,87 +3293,6 @@ typedef enum version_status_t {
   VS_UNKNOWN, /**< We have no idea. */
 } version_status_t;
 
-void networkstatus_reset_warnings(void);
-void networkstatus_reset_download_failures(void);
-int router_reload_v2_networkstatus(void);
-int router_reload_consensus_networkstatus(void);
-void routerstatus_free(routerstatus_t *rs);
-void networkstatus_v2_free(networkstatus_v2_t *ns);
-void networkstatus_vote_free(networkstatus_t *ns);
-networkstatus_voter_info_t *networkstatus_get_voter_by_id(
-                                       networkstatus_t *vote,
-                                       const char *identity);
-int networkstatus_check_consensus_signature(networkstatus_t *consensus,
-                                            int warn);
-int networkstatus_check_document_signature(const networkstatus_t *consensus,
-                                           document_signature_t *sig,
-                                           const authority_cert_t *cert);
-char *networkstatus_get_cache_filename(const char *identity_digest);
-int router_set_networkstatus_v2(const char *s, time_t arrived_at,
-                             v2_networkstatus_source_t source,
-                             smartlist_t *requested_fingerprints);
-void networkstatus_v2_list_clean(time_t now);
-int compare_digest_to_routerstatus_entry(const void *_key,
-                                         const void **_member);
-routerstatus_t *networkstatus_v2_find_entry(networkstatus_v2_t *ns,
-                                         const char *digest);
-routerstatus_t *networkstatus_vote_find_entry(networkstatus_t *ns,
-                                              const char *digest);
-int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
-                                      const char *digest, int *found_out);
-const smartlist_t *networkstatus_get_v2_list(void);
-download_status_t *router_get_dl_status_by_descriptor_digest(const char *d);
-routerstatus_t *router_get_consensus_status_by_id(const char *digest);
-routerstatus_t *router_get_consensus_status_by_descriptor_digest(
-                                                        const char *digest);
-routerstatus_t *router_get_consensus_status_by_nickname(const char *nickname,
-                                                       int warn_if_unnamed);
-const char *networkstatus_get_router_digest_by_nickname(const char *nickname);
-int networkstatus_nickname_is_unnamed(const char *nickname);
-void networkstatus_consensus_download_failed(int status_code);
-void update_consensus_networkstatus_fetch_time(time_t now);
-int should_delay_dir_fetches(or_options_t *options);
-void update_networkstatus_downloads(time_t now);
-void update_certificate_downloads(time_t now);
-int consensus_is_waiting_for_certs(void);
-networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
-networkstatus_t *networkstatus_get_latest_consensus(void);
-networkstatus_t *networkstatus_get_live_consensus(time_t now);
-networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now);
-#define NSSET_FROM_CACHE 1
-#define NSSET_WAS_WAITING_FOR_CERTS 2
-#define NSSET_DONT_DOWNLOAD_CERTS 4
-#define NSSET_ACCEPT_OBSOLETE 8
-#define NSSET_REQUIRE_FLAVOR 16
-int networkstatus_set_current_consensus(const char *consensus,
-                                        const char *flavor,
-                                        unsigned flags);
-void networkstatus_note_certs_arrived(void);
-void routers_update_all_from_networkstatus(time_t now, int dir_version);
-void routerstatus_list_update_from_consensus_networkstatus(time_t now);
-void routers_update_status_from_consensus_networkstatus(smartlist_t *routers,
-                                                        int reset_failures);
-void signed_descs_update_status_from_consensus_networkstatus(
-                                                         smartlist_t *descs);
-
-char *networkstatus_getinfo_helper_single(routerstatus_t *rs);
-char *networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now);
-void networkstatus_dump_bridge_status_to_file(time_t now);
-int32_t get_net_param_from_list(smartlist_t *net_params, const char *name,
-                                int default_val);
-int32_t networkstatus_get_param(networkstatus_t *ns, const char *param_name,
-                                int32_t default_val);
-int getinfo_helper_networkstatus(control_connection_t *conn,
-                                 const char *question, char **answer,
-                                 const char **errmsg);
-int32_t networkstatus_get_bw_weight(networkstatus_t *ns, const char *weight,
-                                    int32_t default_val);
-const char *networkstatus_get_flavor_name(consensus_flavor_t flav);
-int networkstatus_parse_flavor_name(const char *flavname);
-void document_signature_free(document_signature_t *sig);
-document_signature_t *document_signature_dup(const document_signature_t *sig);
-void networkstatus_free_all(void);
-
 /********************************* ntmain.c ***************************/
 #ifdef MS_WINDOWS
 #if !defined (WINCE)
diff --git a/src/or/relay.c b/src/or/relay.c
index c362bcb..83f8754 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -23,6 +23,7 @@
 #include "geoip.h"
 #include "main.h"
 #include "mempool.h"
+#include "networkstatus.h"
 #include "rendcommon.h"
 #include "routerlist.h"
 
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 5d72ef8..0324102 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -13,6 +13,7 @@
 #include "circuituse.h"
 #include "config.h"
 #include "directory.h"
+#include "networkstatus.h"
 #include "rendclient.h"
 #include "rendcommon.h"
 #include "rendservice.h"
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index a84ccb8..f189943 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -22,6 +22,7 @@
 #include "geoip.h"
 #include "hibernate.h"
 #include "main.h"
+#include "networkstatus.h"
 #include "rendcommon.h"
 #include "rendservice.h"
 #include "router.h"
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index c3b6ffb..a7df1f5 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -18,6 +18,7 @@
 #include "routerlist.h"
 #include "memarea.h"
 #include "microdesc.h"
+#include "networkstatus.h"
 #undef log
 #include <math.h>
 
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 206ee48..628dac7 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -11,6 +11,7 @@
 #include "directory.h"
 #include "dirserv.h"
 #include "dirvote.h"
+#include "networkstatus.h"
 #include "router.h"
 #include "routerlist.h"
 #include "test.h"
-- 
1.7.1




More information about the tor-commits mailing list