mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-14 07:03:44 +01:00
0cb921f3e9
In C, we technically aren't supposed to define our own things that start with an underscore. This is a purely machine-generated commit. First, I ran this script on all the headers in src/{common,or,test,tools/*}/*.h : ============================== use strict; my %macros = (); my %skipped = (); FILE: for my $fn (@ARGV) { my $f = $fn; if ($fn !~ /^\.\//) { $f = "./$fn"; } $skipped{$fn} = 0; open(F, $fn); while (<F>) { if (/^#ifndef ([A-Za-z0-9_]+)/) { $macros{$fn} = $1; next FILE; } } } print "#!/usr/bin/perl -w -i -p\n\n"; for my $fn (@ARGV) { if (! exists $macros{$fn}) { print "# No macro known for $fn!\n" if (!$skipped{$fn}); next; } if ($macros{$fn} !~ /_H_?$/) { print "# Weird macro for $fn...\n"; } my $goodmacro = uc $fn; $goodmacro =~ s#.*/##; $goodmacro =~ s#[\/\-\.]#_#g; print "s/(?<![A-Za-z0-9_])$macros{$fn}(?![A-Za-z0-9_])/TOR_${goodmacro}/g;\n" } ============================== It produced the following output, which I then re-ran on those same files: ============================== s/(?<![A-Za-z0-9_])_TOR_ADDRESS_H(?![A-Za-z0-9_])/TOR_ADDRESS_H/g; s/(?<![A-Za-z0-9_])_TOR_AES_H(?![A-Za-z0-9_])/TOR_AES_H/g; s/(?<![A-Za-z0-9_])_TOR_COMPAT_H(?![A-Za-z0-9_])/TOR_COMPAT_H/g; s/(?<![A-Za-z0-9_])_TOR_COMPAT_LIBEVENT_H(?![A-Za-z0-9_])/TOR_COMPAT_LIBEVENT_H/g; s/(?<![A-Za-z0-9_])_TOR_CONTAINER_H(?![A-Za-z0-9_])/TOR_CONTAINER_H/g; s/(?<![A-Za-z0-9_])_TOR_CRYPTO_H(?![A-Za-z0-9_])/TOR_CRYPTO_H/g; s/(?<![A-Za-z0-9_])TOR_DI_OPS_H(?![A-Za-z0-9_])/TOR_DI_OPS_H/g; s/(?<![A-Za-z0-9_])_TOR_MEMAREA_H(?![A-Za-z0-9_])/TOR_MEMAREA_H/g; s/(?<![A-Za-z0-9_])_TOR_MEMPOOL_H(?![A-Za-z0-9_])/TOR_MEMPOOL_H/g; s/(?<![A-Za-z0-9_])TOR_PROCMON_H(?![A-Za-z0-9_])/TOR_PROCMON_H/g; s/(?<![A-Za-z0-9_])_TOR_TORGZIP_H(?![A-Za-z0-9_])/TOR_TORGZIP_H/g; s/(?<![A-Za-z0-9_])_TOR_TORINT_H(?![A-Za-z0-9_])/TOR_TORINT_H/g; s/(?<![A-Za-z0-9_])_TOR_LOG_H(?![A-Za-z0-9_])/TOR_TORLOG_H/g; s/(?<![A-Za-z0-9_])_TOR_TORTLS_H(?![A-Za-z0-9_])/TOR_TORTLS_H/g; s/(?<![A-Za-z0-9_])_TOR_UTIL_H(?![A-Za-z0-9_])/TOR_UTIL_H/g; s/(?<![A-Za-z0-9_])_TOR_BUFFERS_H(?![A-Za-z0-9_])/TOR_BUFFERS_H/g; s/(?<![A-Za-z0-9_])_TOR_CHANNEL_H(?![A-Za-z0-9_])/TOR_CHANNEL_H/g; s/(?<![A-Za-z0-9_])_TOR_CHANNEL_TLS_H(?![A-Za-z0-9_])/TOR_CHANNELTLS_H/g; s/(?<![A-Za-z0-9_])_TOR_CIRCUITBUILD_H(?![A-Za-z0-9_])/TOR_CIRCUITBUILD_H/g; s/(?<![A-Za-z0-9_])_TOR_CIRCUITLIST_H(?![A-Za-z0-9_])/TOR_CIRCUITLIST_H/g; s/(?<![A-Za-z0-9_])_TOR_CIRCUITMUX_EWMA_H(?![A-Za-z0-9_])/TOR_CIRCUITMUX_EWMA_H/g; s/(?<![A-Za-z0-9_])_TOR_CIRCUITMUX_H(?![A-Za-z0-9_])/TOR_CIRCUITMUX_H/g; s/(?<![A-Za-z0-9_])_TOR_CIRCUITUSE_H(?![A-Za-z0-9_])/TOR_CIRCUITUSE_H/g; s/(?<![A-Za-z0-9_])_TOR_COMMAND_H(?![A-Za-z0-9_])/TOR_COMMAND_H/g; s/(?<![A-Za-z0-9_])_TOR_CONFIG_H(?![A-Za-z0-9_])/TOR_CONFIG_H/g; s/(?<![A-Za-z0-9_])TOR_CONFPARSE_H(?![A-Za-z0-9_])/TOR_CONFPARSE_H/g; s/(?<![A-Za-z0-9_])_TOR_CONNECTION_EDGE_H(?![A-Za-z0-9_])/TOR_CONNECTION_EDGE_H/g; s/(?<![A-Za-z0-9_])_TOR_CONNECTION_H(?![A-Za-z0-9_])/TOR_CONNECTION_H/g; s/(?<![A-Za-z0-9_])_TOR_CONNECTION_OR_H(?![A-Za-z0-9_])/TOR_CONNECTION_OR_H/g; s/(?<![A-Za-z0-9_])_TOR_CONTROL_H(?![A-Za-z0-9_])/TOR_CONTROL_H/g; s/(?<![A-Za-z0-9_])_TOR_CPUWORKER_H(?![A-Za-z0-9_])/TOR_CPUWORKER_H/g; s/(?<![A-Za-z0-9_])_TOR_DIRECTORY_H(?![A-Za-z0-9_])/TOR_DIRECTORY_H/g; s/(?<![A-Za-z0-9_])_TOR_DIRSERV_H(?![A-Za-z0-9_])/TOR_DIRSERV_H/g; s/(?<![A-Za-z0-9_])_TOR_DIRVOTE_H(?![A-Za-z0-9_])/TOR_DIRVOTE_H/g; s/(?<![A-Za-z0-9_])_TOR_DNS_H(?![A-Za-z0-9_])/TOR_DNS_H/g; s/(?<![A-Za-z0-9_])_TOR_DNSSERV_H(?![A-Za-z0-9_])/TOR_DNSSERV_H/g; s/(?<![A-Za-z0-9_])TOR_EVENTDNS_TOR_H(?![A-Za-z0-9_])/TOR_EVENTDNS_TOR_H/g; s/(?<![A-Za-z0-9_])_TOR_GEOIP_H(?![A-Za-z0-9_])/TOR_GEOIP_H/g; s/(?<![A-Za-z0-9_])_TOR_HIBERNATE_H(?![A-Za-z0-9_])/TOR_HIBERNATE_H/g; s/(?<![A-Za-z0-9_])_TOR_MAIN_H(?![A-Za-z0-9_])/TOR_MAIN_H/g; s/(?<![A-Za-z0-9_])_TOR_MICRODESC_H(?![A-Za-z0-9_])/TOR_MICRODESC_H/g; s/(?<![A-Za-z0-9_])_TOR_NETWORKSTATUS_H(?![A-Za-z0-9_])/TOR_NETWORKSTATUS_H/g; s/(?<![A-Za-z0-9_])_TOR_NODELIST_H(?![A-Za-z0-9_])/TOR_NODELIST_H/g; s/(?<![A-Za-z0-9_])_TOR_NTMAIN_H(?![A-Za-z0-9_])/TOR_NTMAIN_H/g; s/(?<![A-Za-z0-9_])_TOR_ONION_H(?![A-Za-z0-9_])/TOR_ONION_H/g; s/(?<![A-Za-z0-9_])_TOR_OR_H(?![A-Za-z0-9_])/TOR_OR_H/g; s/(?<![A-Za-z0-9_])_TOR_POLICIES_H(?![A-Za-z0-9_])/TOR_POLICIES_H/g; s/(?<![A-Za-z0-9_])_TOR_REASONS_H(?![A-Za-z0-9_])/TOR_REASONS_H/g; s/(?<![A-Za-z0-9_])_TOR_RELAY_H(?![A-Za-z0-9_])/TOR_RELAY_H/g; s/(?<![A-Za-z0-9_])_TOR_RENDCLIENT_H(?![A-Za-z0-9_])/TOR_RENDCLIENT_H/g; s/(?<![A-Za-z0-9_])_TOR_RENDCOMMON_H(?![A-Za-z0-9_])/TOR_RENDCOMMON_H/g; s/(?<![A-Za-z0-9_])_TOR_RENDMID_H(?![A-Za-z0-9_])/TOR_RENDMID_H/g; s/(?<![A-Za-z0-9_])_TOR_RENDSERVICE_H(?![A-Za-z0-9_])/TOR_RENDSERVICE_H/g; s/(?<![A-Za-z0-9_])_TOR_REPHIST_H(?![A-Za-z0-9_])/TOR_REPHIST_H/g; s/(?<![A-Za-z0-9_])_TOR_REPLAYCACHE_H(?![A-Za-z0-9_])/TOR_REPLAYCACHE_H/g; s/(?<![A-Za-z0-9_])_TOR_ROUTER_H(?![A-Za-z0-9_])/TOR_ROUTER_H/g; s/(?<![A-Za-z0-9_])_TOR_ROUTERLIST_H(?![A-Za-z0-9_])/TOR_ROUTERLIST_H/g; s/(?<![A-Za-z0-9_])_TOR_ROUTERPARSE_H(?![A-Za-z0-9_])/TOR_ROUTERPARSE_H/g; s/(?<![A-Za-z0-9_])TOR_ROUTERSET_H(?![A-Za-z0-9_])/TOR_ROUTERSET_H/g; s/(?<![A-Za-z0-9_])TOR_STATEFILE_H(?![A-Za-z0-9_])/TOR_STATEFILE_H/g; s/(?<![A-Za-z0-9_])_TOR_STATUS_H(?![A-Za-z0-9_])/TOR_STATUS_H/g; s/(?<![A-Za-z0-9_])TOR_TRANSPORTS_H(?![A-Za-z0-9_])/TOR_TRANSPORTS_H/g; s/(?<![A-Za-z0-9_])_TOR_TEST_H(?![A-Za-z0-9_])/TOR_TEST_H/g; s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_H/g; s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_NATPMP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_NATPMP_H/g; s/(?<![A-Za-z0-9_])_TOR_FW_HELPER_UPNP_H(?![A-Za-z0-9_])/TOR_TOR_FW_HELPER_UPNP_H/g; ==============================
122 lines
5.0 KiB
C
122 lines
5.0 KiB
C
/* Copyright (c) 2001 Matej Pfajfar.
|
|
* Copyright (c) 2001-2004, Roger Dingledine.
|
|
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
|
|
* Copyright (c) 2007-2012, The Tor Project, Inc. */
|
|
/* See LICENSE for licensing information */
|
|
|
|
/**
|
|
* \file dirvote.h
|
|
* \brief Header file for dirvote.c.
|
|
**/
|
|
|
|
#ifndef TOR_DIRVOTE_H
|
|
#define TOR_DIRVOTE_H
|
|
|
|
/** Lowest allowable value for VoteSeconds. */
|
|
#define MIN_VOTE_SECONDS 20
|
|
/** Lowest allowable value for DistSeconds. */
|
|
#define MIN_DIST_SECONDS 20
|
|
/** Smallest allowable voting interval. */
|
|
#define MIN_VOTE_INTERVAL 300
|
|
|
|
/** The highest consensus method that we currently support. */
|
|
#define MAX_SUPPORTED_CONSENSUS_METHOD 14
|
|
|
|
/** Lowest consensus method that contains a 'directory-footer' marker */
|
|
#define MIN_METHOD_FOR_FOOTER 9
|
|
|
|
/** Lowest consensus method that contains bandwidth weights */
|
|
#define MIN_METHOD_FOR_BW_WEIGHTS 9
|
|
|
|
/** Lowest consensus method that contains consensus params */
|
|
#define MIN_METHOD_FOR_PARAMS 7
|
|
|
|
/** Lowest consensus method that generates microdescriptors */
|
|
#define MIN_METHOD_FOR_MICRODESC 8
|
|
|
|
/** Lowest consensus method that ensures a majority of authorities voted
|
|
* for a param. */
|
|
#define MIN_METHOD_FOR_MAJORITY_PARAMS 12
|
|
|
|
/** Lowest consensus method where microdesc consensuses omit any entry
|
|
* with no microdesc. */
|
|
#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
|
|
|
|
/** Lowest consensus method that contains "a" lines. */
|
|
#define MIN_METHOD_FOR_A_LINES 14
|
|
|
|
void dirvote_free_all(void);
|
|
|
|
/* vote manipulation */
|
|
char *networkstatus_compute_consensus(smartlist_t *votes,
|
|
int total_authorities,
|
|
crypto_pk_t *identity_key,
|
|
crypto_pk_t *signing_key,
|
|
const char *legacy_identity_key_digest,
|
|
crypto_pk_t *legacy_signing_key,
|
|
consensus_flavor_t flavor);
|
|
int networkstatus_add_detached_signatures(networkstatus_t *target,
|
|
ns_detached_signatures_t *sigs,
|
|
const char *source,
|
|
int severity,
|
|
const char **msg_out);
|
|
char *networkstatus_get_detached_signatures(smartlist_t *consensuses);
|
|
void ns_detached_signatures_free(ns_detached_signatures_t *s);
|
|
|
|
/* cert manipulation */
|
|
authority_cert_t *authority_cert_dup(authority_cert_t *cert);
|
|
|
|
/* vote scheduling */
|
|
void dirvote_get_preferred_voting_intervals(vote_timing_t *timing_out);
|
|
time_t dirvote_get_start_of_next_interval(time_t now, int interval);
|
|
void dirvote_recalculate_timing(const or_options_t *options, time_t now);
|
|
void dirvote_act(const or_options_t *options, time_t now);
|
|
|
|
/* invoked on timers and by outside triggers. */
|
|
struct pending_vote_t * dirvote_add_vote(const char *vote_body,
|
|
const char **msg_out,
|
|
int *status_out);
|
|
int dirvote_add_signatures(const char *detached_signatures_body,
|
|
const char *source,
|
|
const char **msg_out);
|
|
|
|
/* Item access */
|
|
const char *dirvote_get_pending_consensus(consensus_flavor_t flav);
|
|
const char *dirvote_get_pending_detached_signatures(void);
|
|
#define DGV_BY_ID 1
|
|
#define DGV_INCLUDE_PENDING 2
|
|
#define DGV_INCLUDE_PREVIOUS 4
|
|
const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
|
|
void set_routerstatus_from_routerinfo(routerstatus_t *rs,
|
|
node_t *node,
|
|
routerinfo_t *ri, time_t now,
|
|
int naming, int listbadexits,
|
|
int listbaddirs, int vote_on_hsdirs);
|
|
networkstatus_t *
|
|
dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
|
|
authority_cert_t *cert);
|
|
|
|
microdesc_t *dirvote_create_microdescriptor(const routerinfo_t *ri,
|
|
int consensus_method);
|
|
ssize_t dirvote_format_microdesc_vote_line(char *out, size_t out_len,
|
|
const microdesc_t *md,
|
|
int consensus_method_low,
|
|
int consensus_method_high);
|
|
int vote_routerstatus_find_microdesc_hash(char *digest256_out,
|
|
const vote_routerstatus_t *vrs,
|
|
int method,
|
|
digest_algorithm_t alg);
|
|
document_signature_t *voter_get_sig_by_algorithm(
|
|
const networkstatus_voter_info_t *voter,
|
|
digest_algorithm_t alg);
|
|
|
|
#ifdef DIRVOTE_PRIVATE
|
|
char *format_networkstatus_vote(crypto_pk_t *private_key,
|
|
networkstatus_t *v3_ns);
|
|
char *dirvote_compute_params(smartlist_t *votes, int method,
|
|
int total_authorities);
|
|
#endif
|
|
|
|
#endif
|
|
|