Extract or_state_t to its own header.

Fewer modules needed this than I had expected.
This commit is contained in:
Nick Mathewson
2018-07-01 14:51:53 -04:00
parent f75357ec35
commit 986d761510
24 changed files with 115 additions and 75 deletions
+1
View File
@@ -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>
+1
View File
@@ -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"
+2
View File
@@ -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";
+1
View File
@@ -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"
+1
View File
@@ -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? */
+1
View File
@@ -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"
+2 -1
View File
@@ -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 \
+1
View File
@@ -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"
+1 -72
View File
@@ -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
+86
View File
@@ -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
+1
View File
@@ -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"
+1
View File
@@ -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"
+2
View File
@@ -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 },
+1
View File
@@ -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"
+2
View File
@@ -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>
+2 -1
View File
@@ -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
};
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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 */
+2
View File
@@ -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)
{
+1
View File
@@ -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"
+1 -1
View File
@@ -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
};
+1
View File
@@ -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"
+1
View File
@@ -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"