or_state_st.h (3566B)
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-2021, The Tor Project, Inc. */ 5 /* See LICENSE for licensing information */ 6 7 /** 8 * \file or_state_st.h 9 * 10 * \brief The or_state_t structure, which represents Tor's state file. 11 */ 12 13 #ifndef TOR_OR_STATE_ST_H 14 #define TOR_OR_STATE_ST_H 15 16 #include "lib/cc/torint.h" 17 struct smartlist_t; 18 struct config_suite_t; 19 20 /** Persistent state for an onion router, as saved to disk. */ 21 struct or_state_t { 22 uint32_t magic_; 23 /** The time at which we next plan to write the state to the disk. Equal to 24 * TIME_MAX if there are no saveable changes, 0 if there are changes that 25 * should be saved right away. */ 26 time_t next_write; 27 28 /** When was the state last written to disk? */ 29 time_t LastWritten; 30 31 /** Fields for accounting bandwidth use. */ 32 time_t AccountingIntervalStart; 33 uint64_t AccountingBytesReadInInterval; 34 uint64_t AccountingBytesWrittenInInterval; 35 int AccountingSecondsActive; 36 int AccountingSecondsToReachSoftLimit; 37 time_t AccountingSoftLimitHitAt; 38 uint64_t AccountingBytesAtSoftLimit; 39 uint64_t AccountingExpectedUsage; 40 41 /** A list of guard-related configuration lines. */ 42 struct config_line_t *Guard; 43 44 struct config_line_t *TransportProxies; 45 46 /** These fields hold information on the history of bandwidth usage for 47 * servers. The "Ends" fields hold the time when we last updated the 48 * bandwidth usage. The "Interval" fields hold the granularity, in seconds, 49 * of the entries of Values. The "Values" lists hold decimal string 50 * representations of the number of bytes read or written in each 51 * interval. The "Maxima" list holds decimal strings describing the highest 52 * rate achieved during the interval. 53 */ 54 time_t BWHistoryReadEnds; 55 int BWHistoryReadInterval; 56 struct smartlist_t *BWHistoryReadValues; 57 struct smartlist_t *BWHistoryReadMaxima; 58 time_t BWHistoryWriteEnds; 59 int BWHistoryWriteInterval; 60 struct smartlist_t *BWHistoryWriteValues; 61 struct smartlist_t *BWHistoryWriteMaxima; 62 time_t BWHistoryIPv6ReadEnds; 63 int BWHistoryIPv6ReadInterval; 64 struct smartlist_t *BWHistoryIPv6ReadValues; 65 struct smartlist_t *BWHistoryIPv6ReadMaxima; 66 time_t BWHistoryIPv6WriteEnds; 67 int BWHistoryIPv6WriteInterval; 68 struct smartlist_t *BWHistoryIPv6WriteValues; 69 struct smartlist_t *BWHistoryIPv6WriteMaxima; 70 time_t BWHistoryDirReadEnds; 71 int BWHistoryDirReadInterval; 72 struct smartlist_t *BWHistoryDirReadValues; 73 struct smartlist_t *BWHistoryDirReadMaxima; 74 time_t BWHistoryDirWriteEnds; 75 int BWHistoryDirWriteInterval; 76 struct smartlist_t *BWHistoryDirWriteValues; 77 struct smartlist_t *BWHistoryDirWriteMaxima; 78 79 /** Build time histogram */ 80 struct config_line_t * BuildtimeHistogram; 81 int TotalBuildTimes; 82 int CircuitBuildAbandonedCount; 83 84 /** What version of Tor wrote this state file? */ 85 char *TorVersion; 86 87 /** Holds any unrecognized values we found in the state file, in the order 88 * in which we found them. */ 89 struct config_line_t *ExtraLines; 90 91 /** When did we last rotate our onion key? "0" for 'no idea'. */ 92 time_t LastRotatedOnionKey; 93 94 /** 95 * State objects for individual modules. 96 * 97 * Never access this field or its members directly: instead, use the module 98 * in question to get its relevant state object if you must. 99 */ 100 struct config_suite_t *substates_; 101 }; 102 103 #endif /* !defined(TOR_OR_STATE_ST_H) */