[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Extract or_state_t to its own header.
commit 986d761510c4e5070cbdf8879f49342b7b1350c1
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sun Jul 1 14:51:53 2018 -0400
Extract or_state_t to its own header.
Fewer modules needed this than I had expected.
---
src/or/circuitstats.c | 1 +
src/or/connection_or.c | 1 +
src/or/dirauth/shared_random_state.c | 2 +
src/or/entrynodes.c | 1 +
src/or/hibernate.c | 1 +
src/or/hs_service.c | 1 +
src/or/include.am | 3 +-
src/or/main.c | 1 +
src/or/or.h | 73 +-----------------------------
src/or/or_state_st.h | 86 ++++++++++++++++++++++++++++++++++++
src/or/rephist.c | 1 +
src/or/router.c | 1 +
src/or/statefile.c | 2 +
src/or/status.c | 1 +
src/test/test.c | 2 +
src/test/test_accounting.c | 3 +-
src/test/test_entrynodes.c | 1 +
src/test/test_hs_common.c | 1 +
src/test/test_hs_service.c | 1 +
src/test/test_pt.c | 2 +
src/test/test_routerlist.c | 1 +
src/test/test_shared_random.c | 2 +-
src/test/test_status.c | 1 +
src/test/test_tortls.c | 1 +
24 files changed, 115 insertions(+), 75 deletions(-)
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index c090a1e7a..32584c26d 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -46,6 +46,7 @@
#include "or/crypt_path_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#undef log
#include <math.h>
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 41ec7e8bc..b3021edf1 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -66,6 +66,7 @@
#include "or/or_connection_st.h"
#include "or/or_handshake_certs_st.h"
#include "or/or_handshake_state_st.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
#include "or/var_cell_st.h"
#include "lib/crypt_ops/crypto_format.h"
diff --git a/src/or/dirauth/shared_random_state.c b/src/or/dirauth/shared_random_state.c
index 85c02887d..87ddcc073 100644
--- a/src/or/dirauth/shared_random_state.c
+++ b/src/or/dirauth/shared_random_state.c
@@ -23,6 +23,8 @@
#include "or/voting_schedule.h"
#include "lib/encoding/confline.h"
+#include "or/or_state_st.h"
+
/* Default filename of the shared random state on disk. */
static const char default_fname[] = "sr-state";
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 2ed2bc904..ba9c30f8b 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -143,6 +143,7 @@
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "lib/crypt_ops/digestset.h"
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index 2c43e0f99..f98ada02d 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -44,6 +44,7 @@ hibernating, phase 2:
#include "common/compat_libevent.h"
#include "or/or_connection_st.h"
+#include "or/or_state_st.h"
/** Are we currently awake, asleep, running out of bandwidth, or shutting
* down? */
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 6c134136f..b651f1e27 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -45,6 +45,7 @@
#include "or/networkstatus_st.h"
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "or/routerstatus_st.h"
#include "lib/encoding/confline.h"
diff --git a/src/or/include.am b/src/or/include.am
index ce195c92e..5475ea17e 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -75,7 +75,7 @@ LIBTOR_APP_A_SOURCES = \
src/or/onion_fast.c \
src/or/onion_tap.c \
src/or/transports.c \
- src/or/parsecommon.c \
+ src/or/parsecommon.c \
src/or/periodic.c \
src/or/protover.c \
src/or/protover_rust.c \
@@ -275,6 +275,7 @@ ORHEADERS = \
src/or/or_connection_st.h \
src/or/or_handshake_certs_st.h \
src/or/or_handshake_state_st.h \
+ src/or/or_state_st.h \
src/or/origin_circuit_st.h \
src/or/transports.h \
src/or/parsecommon.h \
diff --git a/src/or/main.c b/src/or/main.c
index 19b30f725..9851cdb57 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -131,6 +131,7 @@
#include "or/entry_connection_st.h"
#include "or/networkstatus_st.h"
#include "or/or_connection_st.h"
+#include "or/or_state_st.h"
#include "or/port_cfg_st.h"
#include "or/routerinfo_st.h"
#include "or/socks_request_st.h"
diff --git a/src/or/or.h b/src/or/or.h
index 1221084af..0886517dd 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2045,78 +2045,7 @@ typedef struct {
#define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
-/** Persistent state for an onion router, as saved to disk. */
-typedef struct {
- uint32_t magic_;
- /** The time at which we next plan to write the state to the disk. Equal to
- * TIME_MAX if there are no savable changes, 0 if there are changes that
- * should be saved right away. */
- time_t next_write;
-
- /** When was the state last written to disk? */
- time_t LastWritten;
-
- /** Fields for accounting bandwidth use. */
- time_t AccountingIntervalStart;
- uint64_t AccountingBytesReadInInterval;
- uint64_t AccountingBytesWrittenInInterval;
- int AccountingSecondsActive;
- int AccountingSecondsToReachSoftLimit;
- time_t AccountingSoftLimitHitAt;
- uint64_t AccountingBytesAtSoftLimit;
- uint64_t AccountingExpectedUsage;
-
- /** A list of Entry Guard-related configuration lines. (pre-prop271) */
- struct config_line_t *EntryGuards;
-
- /** A list of guard-related configuration lines. (post-prop271) */
- struct config_line_t *Guard;
-
- struct config_line_t *TransportProxies;
-
- /** Cached revision counters for active hidden services on this host */
- struct config_line_t *HidServRevCounter;
-
- /** These fields hold information on the history of bandwidth usage for
- * servers. The "Ends" fields hold the time when we last updated the
- * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
- * of the entries of Values. The "Values" lists hold decimal string
- * representations of the number of bytes read or written in each
- * interval. The "Maxima" list holds decimal strings describing the highest
- * rate achieved during the interval.
- */
- time_t BWHistoryReadEnds;
- int BWHistoryReadInterval;
- smartlist_t *BWHistoryReadValues;
- smartlist_t *BWHistoryReadMaxima;
- time_t BWHistoryWriteEnds;
- int BWHistoryWriteInterval;
- smartlist_t *BWHistoryWriteValues;
- smartlist_t *BWHistoryWriteMaxima;
- time_t BWHistoryDirReadEnds;
- int BWHistoryDirReadInterval;
- smartlist_t *BWHistoryDirReadValues;
- smartlist_t *BWHistoryDirReadMaxima;
- time_t BWHistoryDirWriteEnds;
- int BWHistoryDirWriteInterval;
- smartlist_t *BWHistoryDirWriteValues;
- smartlist_t *BWHistoryDirWriteMaxima;
-
- /** Build time histogram */
- struct config_line_t * BuildtimeHistogram;
- int TotalBuildTimes;
- int CircuitBuildAbandonedCount;
-
- /** What version of Tor wrote this state file? */
- char *TorVersion;
-
- /** Holds any unrecognized values we found in the state file, in the order
- * in which we found them. */
- struct config_line_t *ExtraLines;
-
- /** When did we last rotate our onion key? "0" for 'no idea'. */
- time_t LastRotatedOnionKey;
-} or_state_t;
+typedef struct or_state_t or_state_t;
#define MAX_SOCKS_ADDR_LEN 256
diff --git a/src/or/or_state_st.h b/src/or/or_state_st.h
new file mode 100644
index 000000000..f1d5f981f
--- /dev/null
+++ b/src/or/or_state_st.h
@@ -0,0 +1,86 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_OR_STATE_ST_H
+#define TOR_OR_STATE_ST_H
+
+#include "lib/cc/torint.h"
+struct smartlist_t;
+
+/** Persistent state for an onion router, as saved to disk. */
+struct or_state_t {
+ uint32_t magic_;
+ /** The time at which we next plan to write the state to the disk. Equal to
+ * TIME_MAX if there are no savable changes, 0 if there are changes that
+ * should be saved right away. */
+ time_t next_write;
+
+ /** When was the state last written to disk? */
+ time_t LastWritten;
+
+ /** Fields for accounting bandwidth use. */
+ time_t AccountingIntervalStart;
+ uint64_t AccountingBytesReadInInterval;
+ uint64_t AccountingBytesWrittenInInterval;
+ int AccountingSecondsActive;
+ int AccountingSecondsToReachSoftLimit;
+ time_t AccountingSoftLimitHitAt;
+ uint64_t AccountingBytesAtSoftLimit;
+ uint64_t AccountingExpectedUsage;
+
+ /** A list of Entry Guard-related configuration lines. (pre-prop271) */
+ struct config_line_t *EntryGuards;
+
+ /** A list of guard-related configuration lines. (post-prop271) */
+ struct config_line_t *Guard;
+
+ struct config_line_t *TransportProxies;
+
+ /** Cached revision counters for active hidden services on this host */
+ struct config_line_t *HidServRevCounter;
+
+ /** These fields hold information on the history of bandwidth usage for
+ * servers. The "Ends" fields hold the time when we last updated the
+ * bandwidth usage. The "Interval" fields hold the granularity, in seconds,
+ * of the entries of Values. The "Values" lists hold decimal string
+ * representations of the number of bytes read or written in each
+ * interval. The "Maxima" list holds decimal strings describing the highest
+ * rate achieved during the interval.
+ */
+ time_t BWHistoryReadEnds;
+ int BWHistoryReadInterval;
+ struct smartlist_t *BWHistoryReadValues;
+ struct smartlist_t *BWHistoryReadMaxima;
+ time_t BWHistoryWriteEnds;
+ int BWHistoryWriteInterval;
+ struct smartlist_t *BWHistoryWriteValues;
+ struct smartlist_t *BWHistoryWriteMaxima;
+ time_t BWHistoryDirReadEnds;
+ int BWHistoryDirReadInterval;
+ struct smartlist_t *BWHistoryDirReadValues;
+ struct smartlist_t *BWHistoryDirReadMaxima;
+ time_t BWHistoryDirWriteEnds;
+ int BWHistoryDirWriteInterval;
+ struct smartlist_t *BWHistoryDirWriteValues;
+ struct smartlist_t *BWHistoryDirWriteMaxima;
+
+ /** Build time histogram */
+ struct config_line_t * BuildtimeHistogram;
+ int TotalBuildTimes;
+ int CircuitBuildAbandonedCount;
+
+ /** What version of Tor wrote this state file? */
+ char *TorVersion;
+
+ /** Holds any unrecognized values we found in the state file, in the order
+ * in which we found them. */
+ struct config_line_t *ExtraLines;
+
+ /** When did we last rotate our onion key? "0" for 'no idea'. */
+ time_t LastRotatedOnionKey;
+};
+
+#endif
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 907b01d68..02dc86403 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -91,6 +91,7 @@
#include "or/networkstatus_st.h"
#include "or/or_circuit_st.h"
+#include "or/or_state_st.h"
#include "lib/container/bloomfilt.h"
#include "lib/container/order.h"
diff --git a/src/or/router.c b/src/or/router.c
index cc7102228..6420f1e5d 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -47,6 +47,7 @@
#include "or/extrainfo_st.h"
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "or/port_cfg_st.h"
#include "or/routerinfo_st.h"
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 090e29a18..5631001c0 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -44,6 +44,8 @@
#include "or/statefile.h"
#include "lib/encoding/confline.h"
+#include "or/or_state_st.h"
+
/** A list of state-file "abbreviations," for compatibility. */
static config_abbrev_t state_abbrevs_[] = {
{ "AccountingBytesReadInterval", "AccountingBytesReadInInterval", 0, 0 },
diff --git a/src/or/status.c b/src/or/status.c
index 2cb1dc734..80b56ac1a 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -30,6 +30,7 @@
#include "or/hs_service.h"
#include "or/dos.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
#include "lib/tls/tortls.h"
diff --git a/src/test/test.c b/src/test/test.c
index 64332e264..d6be5ea2e 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -12,6 +12,8 @@
#include "lib/crypt_ops/crypto_dh.h"
#include "lib/crypt_ops/crypto_rand.h"
+#include "or/or_state_st.h"
+
#include <stdio.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
diff --git a/src/test/test_accounting.c b/src/test/test_accounting.c
index ce8e08f7c..7b9511dc2 100644
--- a/src/test/test_accounting.c
+++ b/src/test/test_accounting.c
@@ -9,6 +9,8 @@
#define STATEFILE_PRIVATE
#include "or/statefile.h"
+#include "or/or_state_st.h"
+
#define NS_MODULE accounting
#define NS_SUBMODULE limits
@@ -102,4 +104,3 @@ struct testcase_t accounting_tests[] = {
{ "bwlimits", test_accounting_limits, TT_FORK, NULL, NULL },
END_OF_TESTCASES
};
-
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index f0d649330..262e2fa68 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -37,6 +37,7 @@
#include "or/networkstatus_st.h"
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
#include "or/routerstatus_st.h"
diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c
index cf221ca60..28c6316bd 100644
--- a/src/test/test_hs_common.c
+++ b/src/test/test_hs_common.c
@@ -37,6 +37,7 @@
#include "or/microdesc_st.h"
#include "or/networkstatus_st.h"
#include "or/node_st.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
#include "or/routerstatus_st.h"
diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c
index 3ea1e7530..e81a5eff4 100644
--- a/src/test/test_hs_service.c
+++ b/src/test/test_hs_service.c
@@ -59,6 +59,7 @@
#include "or/networkstatus_st.h"
#include "or/node_st.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
/* Trunnel */
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index 087040506..e685ab50d 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -21,6 +21,8 @@
#include "lib/process/subprocess.h"
#include "lib/encoding/confline.h"
+#include "or/or_state_st.h"
+
static void
reset_mp(managed_proxy_t *mp)
{
diff --git a/src/test/test_routerlist.c b/src/test/test_routerlist.c
index 804df0f14..b25a0be9a 100644
--- a/src/test/test_routerlist.c
+++ b/src/test/test_routerlist.c
@@ -37,6 +37,7 @@
#include "or/dir_connection_st.h"
#include "or/networkstatus_st.h"
#include "or/node_st.h"
+#include "or/or_state_st.h"
#include "or/routerstatus_st.h"
#include "lib/encoding/confline.h"
diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c
index 91ae20bff..293ed6cf3 100644
--- a/src/test/test_shared_random.c
+++ b/src/test/test_shared_random.c
@@ -24,6 +24,7 @@
#include "or/dir_server_st.h"
#include "or/networkstatus_st.h"
+#include "or/or_state_st.h"
static authority_cert_t *mock_cert;
@@ -1393,4 +1394,3 @@ struct testcase_t sr_tests[] = {
NULL, NULL },
END_OF_TESTCASES
};
-
diff --git a/src/test/test_status.c b/src/test/test_status.c
index 071b3ba8a..6c694be57 100644
--- a/src/test/test_status.c
+++ b/src/test/test_status.c
@@ -27,6 +27,7 @@
#include "lib/tls/tortls.h"
#include "or/origin_circuit_st.h"
+#include "or/or_state_st.h"
#include "or/routerinfo_st.h"
#include "test/test.h"
diff --git a/src/test/test_tortls.c b/src/test/test_tortls.c
index b45673468..9ae9d4dfb 100644
--- a/src/test/test_tortls.c
+++ b/src/test/test_tortls.c
@@ -34,6 +34,7 @@ ENABLE_GCC_WARNING(redundant-decls)
#include "lib/log/torlog.h"
#include "or/config.h"
#include "lib/tls/tortls.h"
+#include "or/or_state_st.h"
#include "test/test.h"
#include "test/log_test_helpers.h"
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits