Browse Source

Merge remote-tracking branch 'public/bug1031'

Nick Mathewson 12 years ago
parent
commit
9f83142591
100 changed files with 1269 additions and 1260 deletions
  1. 5 0
      changes/bug1031
  2. 12 12
      src/common/address.c
  3. 3 3
      src/common/address.h
  4. 5 5
      src/common/aes.c
  5. 2 2
      src/common/aes.h
  6. 1 1
      src/common/compat.c
  7. 4 4
      src/common/compat.h
  8. 2 2
      src/common/compat_libevent.h
  9. 11 11
      src/common/container.c
  10. 2 2
      src/common/container.h
  11. 31 31
      src/common/crypto.c
  12. 6 6
      src/common/crypto.h
  13. 41 41
      src/common/log.c
  14. 1 1
      src/common/memarea.c
  15. 2 2
      src/common/memarea.h
  16. 1 1
      src/common/mempool.c
  17. 2 2
      src/common/mempool.h
  18. 2 2
      src/common/torgzip.h
  19. 2 2
      src/common/torint.h
  20. 30 30
      src/common/torlog.h
  21. 18 18
      src/common/tortls.c
  22. 5 5
      src/common/tortls.h
  23. 23 23
      src/common/util.c
  24. 22 22
      src/common/util.h
  25. 2 2
      src/ext/eventdns.h
  26. 2 2
      src/ext/ht.h
  27. 2 2
      src/or/buffers.h
  28. 1 1
      src/or/channel.c
  29. 3 3
      src/or/channel.h
  30. 50 50
      src/or/channeltls.c
  31. 5 5
      src/or/channeltls.h
  32. 55 55
      src/or/circuitbuild.c
  33. 2 2
      src/or/circuitbuild.h
  34. 23 23
      src/or/circuitlist.c
  35. 5 5
      src/or/circuitlist.h
  36. 5 5
      src/or/circuitmux.h
  37. 5 5
      src/or/circuitmux_ewma.c
  38. 5 5
      src/or/circuitmux_ewma.h
  39. 32 32
      src/or/circuituse.c
  40. 2 2
      src/or/circuituse.h
  41. 1 1
      src/or/command.c
  42. 2 2
      src/or/command.h
  43. 59 59
      src/or/config.c
  44. 2 2
      src/or/config.h
  45. 38 38
      src/or/connection.c
  46. 10 10
      src/or/connection.h
  47. 60 60
      src/or/connection_edge.c
  48. 4 4
      src/or/connection_edge.h
  49. 77 77
      src/or/connection_or.c
  50. 2 2
      src/or/connection_or.h
  51. 23 23
      src/or/control.c
  52. 2 2
      src/or/control.h
  53. 2 2
      src/or/cpuworker.h
  54. 156 156
      src/or/directory.c
  55. 2 2
      src/or/directory.h
  56. 8 8
      src/or/dirserv.c
  57. 2 2
      src/or/dirserv.h
  58. 15 15
      src/or/dirvote.c
  59. 2 2
      src/or/dirvote.h
  60. 69 69
      src/or/dns.c
  61. 2 2
      src/or/dns.h
  62. 2 2
      src/or/dnsserv.c
  63. 2 2
      src/or/dnsserv.h
  64. 4 0
      src/or/eventdns_tor.h
  65. 21 21
      src/or/geoip.c
  66. 2 2
      src/or/geoip.h
  67. 2 2
      src/or/hibernate.h
  68. 1 1
      src/or/main.c
  69. 2 2
      src/or/main.h
  70. 4 4
      src/or/microdesc.c
  71. 2 2
      src/or/microdesc.h
  72. 6 6
      src/or/networkstatus.c
  73. 2 2
      src/or/networkstatus.h
  74. 1 1
      src/or/nodelist.c
  75. 2 2
      src/or/nodelist.h
  76. 2 2
      src/or/ntmain.h
  77. 2 2
      src/or/onion.h
  78. 59 59
      src/or/or.h
  79. 2 2
      src/or/policies.h
  80. 2 2
      src/or/reasons.h
  81. 38 38
      src/or/relay.c
  82. 2 2
      src/or/relay.h
  83. 17 17
      src/or/rendclient.c
  84. 2 2
      src/or/rendclient.h
  85. 4 4
      src/or/rendcommon.c
  86. 2 2
      src/or/rendcommon.h
  87. 4 4
      src/or/rendmid.c
  88. 2 2
      src/or/rendmid.h
  89. 31 31
      src/or/rendservice.c
  90. 2 2
      src/or/rendservice.h
  91. 7 7
      src/or/rephist.c
  92. 2 2
      src/or/rephist.h
  93. 1 1
      src/or/replaycache.c
  94. 2 2
      src/or/replaycache.h
  95. 11 11
      src/or/router.c
  96. 2 2
      src/or/router.h
  97. 19 19
      src/or/routerlist.c
  98. 2 2
      src/or/routerlist.h
  99. 27 27
      src/or/routerparse.c
  100. 2 2
      src/or/routerparse.h

+ 5 - 0
changes/bug1031

@@ -0,0 +1,5 @@
+  o Code cleanup:
+    - Avoid use of reserved identifiers in our C code. The C standard
+      doesn't like us declaring anything that starts with an
+      underscore, so let's knock it off before we get in trouble. Fix
+      for bug 1031; bugfix on the first Tor commit.

+ 12 - 12
src/common/address.c

@@ -1422,17 +1422,17 @@ addr_port_lookup(int severity, const char *addrport, char **address,
                 uint32_t *addr, uint16_t *port_out)
 {
   const char *colon;
-  char *_address = NULL;
-  int _port;
+  char *address_ = NULL;
+  int port_;
   int ok = 1;
 
   tor_assert(addrport);
 
   colon = strrchr(addrport, ':');
   if (colon) {
-    _address = tor_strndup(addrport, colon-addrport);
-    _port = (int) tor_parse_long(colon+1,10,1,65535,NULL,NULL);
-    if (!_port) {
+    address_ = tor_strndup(addrport, colon-addrport);
+    port_ = (int) tor_parse_long(colon+1,10,1,65535,NULL,NULL);
+    if (!port_) {
       log_fn(severity, LD_GENERAL, "Port %s out of range", escaped(colon+1));
       ok = 0;
     }
@@ -1445,28 +1445,28 @@ addr_port_lookup(int severity, const char *addrport, char **address,
       ok = 0;
     }
   } else {
-    _address = tor_strdup(addrport);
-    _port = 0;
+    address_ = tor_strdup(addrport);
+    port_ = 0;
   }
 
   if (addr) {
     /* There's an addr pointer, so we need to resolve the hostname. */
-    if (tor_lookup_hostname(_address,addr)) {
-      log_fn(severity, LD_NET, "Couldn't look up %s", escaped(_address));
+    if (tor_lookup_hostname(address_,addr)) {
+      log_fn(severity, LD_NET, "Couldn't look up %s", escaped(address_));
       ok = 0;
       *addr = 0;
     }
   }
 
   if (address && ok) {
-    *address = _address;
+    *address = address_;
   } else {
     if (address)
       *address = NULL;
-    tor_free(_address);
+    tor_free(address_);
   }
   if (port_out)
-    *port_out = ok ? ((uint16_t) _port) : 0;
+    *port_out = ok ? ((uint16_t) port_) : 0;
 
   return ok ? 0 : -1;
 }

+ 3 - 3
src/common/address.h

@@ -8,8 +8,8 @@
  * \brief Headers for address.h
  **/
 
-#ifndef _TOR_ADDRESS_H
-#define _TOR_ADDRESS_H
+#ifndef TOR_ADDRESS_H
+#define TOR_ADDRESS_H
 
 #include "orconfig.h"
 #include "torint.h"
@@ -171,7 +171,7 @@ int tor_addr_is_v4(const tor_addr_t *addr);
 int tor_addr_is_internal_(const tor_addr_t *ip, int for_listening,
                           const char *filename, int lineno);
 #define tor_addr_is_internal(addr, for_listening) \
-  tor_addr_is_internal_((addr), (for_listening), _SHORT_FILE_, __LINE__)
+  tor_addr_is_internal_((addr), (for_listening), SHORT_FILE__, __LINE__)
 
 /** Longest length that can be required for a reverse lookup name. */
 /* 32 nybbles, 32 dots, 8 characters of "ip6.arpa", 1 NUL: 73 characters. */

+ 5 - 5
src/common/aes.c

@@ -285,7 +285,7 @@ evaluate_ctr_for_aes(void)
  * value of the current counter.
  */
 static INLINE void
-_aes_fill_buf(aes_cnt_cipher_t *cipher)
+aes_fill_buf_(aes_cnt_cipher_t *cipher)
 {
   /* We don't currently use OpenSSL's counter mode implementation because:
    *  1) some versions have known bugs
@@ -360,7 +360,7 @@ aes_set_key(aes_cnt_cipher_t *cipher, const char *key, int key_bits)
     memset(cipher->buf, 0, sizeof(cipher->buf));
   else
 #endif
-    _aes_fill_buf(cipher);
+    aes_fill_buf_(cipher);
 }
 
 /** Release storage held by <b>cipher</b>
@@ -453,7 +453,7 @@ aes_crypt(aes_cnt_cipher_t *cipher, const char *input, size_t len,
         UPDATE_CTR_BUF(cipher, 1);
       }
       UPDATE_CTR_BUF(cipher, 0);
-      _aes_fill_buf(cipher);
+      aes_fill_buf_(cipher);
     }
   }
 }
@@ -492,7 +492,7 @@ aes_crypt_inplace(aes_cnt_cipher_t *cipher, char *data, size_t len)
         UPDATE_CTR_BUF(cipher, 1);
       }
       UPDATE_CTR_BUF(cipher, 0);
-      _aes_fill_buf(cipher);
+      aes_fill_buf_(cipher);
     }
   }
 }
@@ -514,7 +514,7 @@ aes_set_iv(aes_cnt_cipher_t *cipher, const char *iv)
 #ifdef CAN_USE_OPENSSL_CTR
   if (!should_use_openssl_CTR)
 #endif
-    _aes_fill_buf(cipher);
+    aes_fill_buf_(cipher);
 }
 
 #endif

+ 2 - 2
src/common/aes.h

@@ -5,8 +5,8 @@
 
 /* Implements a minimal interface to counter-mode AES. */
 
-#ifndef _TOR_AES_H
-#define _TOR_AES_H
+#ifndef TOR_AES_H
+#define TOR_AES_H
 
 /**
  * \file aes.h

+ 1 - 1
src/common/compat.c

@@ -1256,7 +1256,7 @@ tor_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
 
 /** Number of extra file descriptors to keep in reserve beyond those that we
  * tell Tor it's allowed to use. */
-#define ULIMIT_BUFFER 32 /* keep 32 extra fd's beyond _ConnLimit */
+#define ULIMIT_BUFFER 32 /* keep 32 extra fd's beyond ConnLimit_ */
 
 /** Learn the maximum allowed number of file descriptors, and tell the system
  * we want to use up to that number. (Some systems have a low soft limit, and

+ 4 - 4
src/common/compat.h

@@ -3,8 +3,8 @@
  * Copyright (c) 2007-2012, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#ifndef _TOR_COMPAT_H
-#define _TOR_COMPAT_H
+#ifndef TOR_COMPAT_H
+#define TOR_COMPAT_H
 
 #include "orconfig.h"
 #include "torint.h"
@@ -308,10 +308,10 @@ char *tor_strtok_r_impl(char *str, const char *sep, char **lasts);
 #endif
 
 #ifdef _WIN32
-#define _SHORT_FILE_ (tor_fix_source_file(__FILE__))
+#define SHORT_FILE__ (tor_fix_source_file(__FILE__))
 const char *tor_fix_source_file(const char *fname);
 #else
-#define _SHORT_FILE_ (__FILE__)
+#define SHORT_FILE__ (__FILE__)
 #define tor_fix_source_file(s) (s)
 #endif
 

+ 2 - 2
src/common/compat_libevent.h

@@ -1,8 +1,8 @@
 /* Copyright (c) 2009-2012, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#ifndef _TOR_COMPAT_LIBEVENT_H
-#define _TOR_COMPAT_LIBEVENT_H
+#ifndef TOR_COMPAT_LIBEVENT_H
+#define TOR_COMPAT_LIBEVENT_H
 
 #include "orconfig.h"
 

+ 11 - 11
src/common/container.c

@@ -602,7 +602,7 @@ smartlist_bsearch_idx(const smartlist_t *sl, const void *key,
 
 /** Helper: compare two const char **s. */
 static int
-_compare_string_ptrs(const void **_a, const void **_b)
+compare_string_ptrs_(const void **_a, const void **_b)
 {
   return strcmp((const char*)*_a, (const char*)*_b);
 }
@@ -612,14 +612,14 @@ _compare_string_ptrs(const void **_a, const void **_b)
 void
 smartlist_sort_strings(smartlist_t *sl)
 {
-  smartlist_sort(sl, _compare_string_ptrs);
+  smartlist_sort(sl, compare_string_ptrs_);
 }
 
 /** Return the most frequent string in the sorted list <b>sl</b> */
 char *
 smartlist_get_most_frequent_string(smartlist_t *sl)
 {
-  return smartlist_get_most_frequent(sl, _compare_string_ptrs);
+  return smartlist_get_most_frequent(sl, compare_string_ptrs_);
 }
 
 /** Remove duplicate strings from a sorted list, and free them with tor_free().
@@ -627,7 +627,7 @@ smartlist_get_most_frequent_string(smartlist_t *sl)
 void
 smartlist_uniq_strings(smartlist_t *sl)
 {
-  smartlist_uniq(sl, _compare_string_ptrs, _tor_free);
+  smartlist_uniq(sl, compare_string_ptrs_, tor_free_);
 }
 
 /* Heap-based priority queue implementation for O(lg N) insert and remove.
@@ -828,7 +828,7 @@ smartlist_pqueue_assert_ok(smartlist_t *sl,
 
 /** Helper: compare two DIGEST_LEN digests. */
 static int
-_compare_digests(const void **_a, const void **_b)
+compare_digests_(const void **_a, const void **_b)
 {
   return tor_memcmp((const char*)*_a, (const char*)*_b, DIGEST_LEN);
 }
@@ -837,7 +837,7 @@ _compare_digests(const void **_a, const void **_b)
 void
 smartlist_sort_digests(smartlist_t *sl)
 {
-  smartlist_sort(sl, _compare_digests);
+  smartlist_sort(sl, compare_digests_);
 }
 
 /** Remove duplicate digests from a sorted list, and free them with tor_free().
@@ -845,12 +845,12 @@ smartlist_sort_digests(smartlist_t *sl)
 void
 smartlist_uniq_digests(smartlist_t *sl)
 {
-  smartlist_uniq(sl, _compare_digests, _tor_free);
+  smartlist_uniq(sl, compare_digests_, tor_free_);
 }
 
 /** Helper: compare two DIGEST256_LEN digests. */
 static int
-_compare_digests256(const void **_a, const void **_b)
+compare_digests256_(const void **_a, const void **_b)
 {
   return tor_memcmp((const char*)*_a, (const char*)*_b, DIGEST256_LEN);
 }
@@ -859,7 +859,7 @@ _compare_digests256(const void **_a, const void **_b)
 void
 smartlist_sort_digests256(smartlist_t *sl)
 {
-  smartlist_sort(sl, _compare_digests256);
+  smartlist_sort(sl, compare_digests256_);
 }
 
 /** Return the most frequent member of the sorted list of DIGEST256_LEN
@@ -867,7 +867,7 @@ smartlist_sort_digests256(smartlist_t *sl)
 char *
 smartlist_get_most_frequent_digest256(smartlist_t *sl)
 {
-  return smartlist_get_most_frequent(sl, _compare_digests256);
+  return smartlist_get_most_frequent(sl, compare_digests256_);
 }
 
 /** Remove duplicate 256-bit digests from a sorted list, and free them with
@@ -876,7 +876,7 @@ smartlist_get_most_frequent_digest256(smartlist_t *sl)
 void
 smartlist_uniq_digests256(smartlist_t *sl)
 {
-  smartlist_uniq(sl, _compare_digests256, _tor_free);
+  smartlist_uniq(sl, compare_digests256_, tor_free_);
 }
 
 /** Helper: Declare an entry type and a map type to implement a mapping using

+ 2 - 2
src/common/container.h

@@ -3,8 +3,8 @@
  * Copyright (c) 2007-2012, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#ifndef _TOR_CONTAINER_H
-#define _TOR_CONTAINER_H
+#ifndef TOR_CONTAINER_H
+#define TOR_CONTAINER_H
 
 #include "util.h"
 

+ 31 - 31
src/common/crypto.c

@@ -76,9 +76,9 @@
 
 #ifdef TOR_IS_MULTITHREADED
 /** A number of preallocated mutexes for use by OpenSSL. */
-static tor_mutex_t **_openssl_mutexes = NULL;
+static tor_mutex_t **openssl_mutexes_ = NULL;
 /** How many mutexes have we allocated for use by OpenSSL? */
-static int _n_openssl_mutexes = 0;
+static int n_openssl_mutexes_ = 0;
 #endif
 
 /** A public key, or a public/private key-pair. */
@@ -133,7 +133,7 @@ crypto_get_rsa_padding(int padding)
 }
 
 /** Boolean: has OpenSSL's crypto been initialized? */
-static int _crypto_global_initialized = 0;
+static int crypto_global_initialized_ = 0;
 
 /** Log all pending crypto errors at level <b>severity</b>.  Use
  * <b>doing</b> to describe our current activities.
@@ -225,10 +225,10 @@ crypto_openssl_get_version_str(void)
 int
 crypto_global_init(int useAccel, const char *accelName, const char *accelDir)
 {
-  if (!_crypto_global_initialized) {
+  if (!crypto_global_initialized_) {
     ERR_load_crypto_strings();
     OpenSSL_add_all_algorithms();
-    _crypto_global_initialized = 1;
+    crypto_global_initialized_ = 1;
     setup_openssl_threading();
 
     if (SSLeay() == OPENSSL_VERSION_NUMBER &&
@@ -313,7 +313,7 @@ crypto_thread_cleanup(void)
 
 /** used by tortls.c: wrap an RSA* in a crypto_pk_t. */
 crypto_pk_t *
-_crypto_new_pk_from_rsa(RSA *rsa)
+crypto_new_pk_from_rsa_(RSA *rsa)
 {
   crypto_pk_t *env;
   tor_assert(rsa);
@@ -326,7 +326,7 @@ _crypto_new_pk_from_rsa(RSA *rsa)
 /** Helper, used by tor-checkkey.c and tor-gencert.c.  Return the RSA from a
  * crypto_pk_t. */
 RSA *
-_crypto_pk_get_rsa(crypto_pk_t *env)
+crypto_pk_get_rsa_(crypto_pk_t *env)
 {
   return env->key;
 }
@@ -334,7 +334,7 @@ _crypto_pk_get_rsa(crypto_pk_t *env)
 /** used by tortls.c: get an equivalent EVP_PKEY* for a crypto_pk_t.  Iff
  * private is set, include the private-key portion of the key. */
 EVP_PKEY *
-_crypto_pk_get_evp_pkey(crypto_pk_t *env, int private)
+crypto_pk_get_evp_pkey_(crypto_pk_t *env, int private)
 {
   RSA *key = NULL;
   EVP_PKEY *pkey = NULL;
@@ -362,7 +362,7 @@ _crypto_pk_get_evp_pkey(crypto_pk_t *env, int private)
 /** Used by tortls.c: Get the DH* from a crypto_dh_t.
  */
 DH *
-_crypto_dh_get_dh(crypto_dh_t *dh)
+crypto_dh_get_dh_(crypto_dh_t *dh)
 {
   return dh->dh;
 }
@@ -377,7 +377,7 @@ crypto_pk_new(void)
 
   rsa = RSA_new();
   tor_assert(rsa);
-  return _crypto_new_pk_from_rsa(rsa);
+  return crypto_new_pk_from_rsa_(rsa);
 }
 
 /** Release a reference to an asymmetric key; when all the references
@@ -822,7 +822,7 @@ crypto_pk_copy_full(crypto_pk_t *env)
     return NULL;
   }
 
-  return _crypto_new_pk_from_rsa(new_key);
+  return crypto_new_pk_from_rsa_(new_key);
 }
 
 /** Encrypt <b>fromlen</b> bytes from <b>from</b> with the public key
@@ -1189,7 +1189,7 @@ crypto_pk_asn1_decode(const char *str, size_t len)
     crypto_log_errors(LOG_WARN,"decoding public key");
     return NULL;
   }
-  return _crypto_new_pk_from_rsa(rsa);
+  return crypto_new_pk_from_rsa_(rsa);
 }
 
 /** Given a private or public key <b>pk</b>, put a SHA1 hash of the
@@ -2873,19 +2873,19 @@ secret_to_key(char *key_out, size_t key_out_len, const char *secret,
 #ifdef TOR_IS_MULTITHREADED
 /** Helper: OpenSSL uses this callback to manipulate mutexes. */
 static void
-_openssl_locking_cb(int mode, int n, const char *file, int line)
+openssl_locking_cb_(int mode, int n, const char *file, int line)
 {
   (void)file;
   (void)line;
-  if (!_openssl_mutexes)
+  if (!openssl_mutexes_)
     /* This is not a really good  fix for the
      * "release-freed-lock-from-separate-thread-on-shutdown" problem, but
      * it can't hurt. */
     return;
   if (mode & CRYPTO_LOCK)
-    tor_mutex_acquire(_openssl_mutexes[n]);
+    tor_mutex_acquire(openssl_mutexes_[n]);
   else
-    tor_mutex_release(_openssl_mutexes[n]);
+    tor_mutex_release(openssl_mutexes_[n]);
 }
 
 /** OpenSSL helper type: wraps a Tor mutex so that OpenSSL can use it
@@ -2897,7 +2897,7 @@ struct CRYPTO_dynlock_value {
 /** OpenSSL callback function to allocate a lock: see CRYPTO_set_dynlock_*
  * documentation in OpenSSL's docs for more info. */
 static struct CRYPTO_dynlock_value *
-_openssl_dynlock_create_cb(const char *file, int line)
+openssl_dynlock_create_cb_(const char *file, int line)
 {
   struct CRYPTO_dynlock_value *v;
   (void)file;
@@ -2910,7 +2910,7 @@ _openssl_dynlock_create_cb(const char *file, int line)
 /** OpenSSL callback function to acquire or release a lock: see
  * CRYPTO_set_dynlock_* documentation in OpenSSL's docs for more info. */
 static void
-_openssl_dynlock_lock_cb(int mode, struct CRYPTO_dynlock_value *v,
+openssl_dynlock_lock_cb_(int mode, struct CRYPTO_dynlock_value *v,
                          const char *file, int line)
 {
   (void)file;
@@ -2924,7 +2924,7 @@ _openssl_dynlock_lock_cb(int mode, struct CRYPTO_dynlock_value *v,
 /** OpenSSL callback function to free a lock: see CRYPTO_set_dynlock_*
  * documentation in OpenSSL's docs for more info. */
 static void
-_openssl_dynlock_destroy_cb(struct CRYPTO_dynlock_value *v,
+openssl_dynlock_destroy_cb_(struct CRYPTO_dynlock_value *v,
                             const char *file, int line)
 {
   (void)file;
@@ -2941,15 +2941,15 @@ setup_openssl_threading(void)
 {
   int i;
   int n = CRYPTO_num_locks();
-  _n_openssl_mutexes = n;
-  _openssl_mutexes = tor_malloc(n*sizeof(tor_mutex_t *));
+  n_openssl_mutexes_ = n;
+  openssl_mutexes_ = tor_malloc(n*sizeof(tor_mutex_t *));
   for (i=0; i < n; ++i)
-    _openssl_mutexes[i] = tor_mutex_new();
-  CRYPTO_set_locking_callback(_openssl_locking_cb);
+    openssl_mutexes_[i] = tor_mutex_new();
+  CRYPTO_set_locking_callback(openssl_locking_cb_);
   CRYPTO_set_id_callback(tor_get_thread_id);
-  CRYPTO_set_dynlock_create_callback(_openssl_dynlock_create_cb);
-  CRYPTO_set_dynlock_lock_callback(_openssl_dynlock_lock_cb);
-  CRYPTO_set_dynlock_destroy_callback(_openssl_dynlock_destroy_cb);
+  CRYPTO_set_dynlock_create_callback(openssl_dynlock_create_cb_);
+  CRYPTO_set_dynlock_lock_callback(openssl_dynlock_lock_cb_);
+  CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy_cb_);
   return 0;
 }
 #else
@@ -2983,12 +2983,12 @@ crypto_global_cleanup(void)
   CONF_modules_unload(1);
   CRYPTO_cleanup_all_ex_data();
 #ifdef TOR_IS_MULTITHREADED
-  if (_n_openssl_mutexes) {
-    int n = _n_openssl_mutexes;
-    tor_mutex_t **ms = _openssl_mutexes;
+  if (n_openssl_mutexes_) {
+    int n = n_openssl_mutexes_;
+    tor_mutex_t **ms = openssl_mutexes_;
     int i;
-    _openssl_mutexes = NULL;
-    _n_openssl_mutexes = 0;
+    openssl_mutexes_ = NULL;
+    n_openssl_mutexes_ = 0;
     for (i=0;i<n;++i) {
       tor_mutex_free(ms[i]);
     }

+ 6 - 6
src/common/crypto.h

@@ -10,8 +10,8 @@
  * \brief Headers for crypto.c
  **/
 
-#ifndef _TOR_CRYPTO_H
-#define _TOR_CRYPTO_H
+#ifndef TOR_CRYPTO_H
+#define TOR_CRYPTO_H
 
 #include <stdio.h>
 #include "torint.h"
@@ -279,11 +279,11 @@ void secret_to_key(char *key_out, size_t key_out_len, const char *secret,
 struct rsa_st;
 struct evp_pkey_st;
 struct dh_st;
-struct rsa_st *_crypto_pk_get_rsa(crypto_pk_t *env);
-crypto_pk_t *_crypto_new_pk_from_rsa(struct rsa_st *rsa);
-struct evp_pkey_st *_crypto_pk_get_evp_pkey(crypto_pk_t *env,
+struct rsa_st *crypto_pk_get_rsa_(crypto_pk_t *env);
+crypto_pk_t *crypto_new_pk_from_rsa_(struct rsa_st *rsa);
+struct evp_pkey_st *crypto_pk_get_evp_pkey_(crypto_pk_t *env,
                                                 int private);
-struct dh_st *_crypto_dh_get_dh(crypto_dh_t *dh);
+struct dh_st *crypto_dh_get_dh_(crypto_dh_t *dh);
 /* Prototypes for private functions only used by crypto.c and test.c*/
 void add_spaces_to_fp(char *out, size_t outlen, const char *in);
 #endif

+ 41 - 41
src/common/log.c

@@ -131,7 +131,7 @@ static smartlist_t *pending_cb_messages = NULL;
 
 /** What's the lowest log level anybody cares about?  Checking this lets us
  * bail out early from log_debug if we aren't debugging.  */
-int _log_global_min_severity = LOG_NOTICE;
+int log_global_min_severity_ = LOG_NOTICE;
 
 static void delete_log(logfile_t *victim);
 static void close_log(logfile_t *victim);
@@ -177,7 +177,7 @@ set_log_time_granularity(int granularity_msec)
  * <b>buf_len</b> character buffer in <b>buf</b>.
  */
 static INLINE size_t
-_log_prefix(char *buf, size_t buf_len, int severity)
+log_prefix_(char *buf, size_t buf_len, int severity)
 {
   time_t t;
   struct timeval now;
@@ -230,7 +230,7 @@ log_tor_version(logfile_t *lf, int reset)
     /* We are resetting, but we aren't at the start of the file; no
      * need to log again. */
     return 0;
-  n = _log_prefix(buf, sizeof(buf), LOG_NOTICE);
+  n = log_prefix_(buf, sizeof(buf), LOG_NOTICE);
   if (appname) {
     tor_snprintf(buf+n, sizeof(buf)-n,
                  "%s opening %slog file.\n", appname, is_new?"new ":"");
@@ -262,7 +262,7 @@ format_msg(char *buf, size_t buf_len,
   buf_len -= 2; /* subtract 2 characters so we have room for \n\0 */
   buf_end = buf+buf_len; /* point *after* the last char we can write to */
 
-  n = _log_prefix(buf, buf_len, severity);
+  n = log_prefix_(buf, buf_len, severity);
   end_of_prefix = buf+n;
 
   if (log_domains_are_logged) {
@@ -423,7 +423,7 @@ void
 tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (severity > _log_global_min_severity)
+  if (severity > log_global_min_severity_)
     return;
   va_start(ap,format);
   logv(severity, domain, NULL, format, ap);
@@ -436,11 +436,11 @@ tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
  * variadic macros. All arguments are as for log_fn, except for
  * <b>fn</b>, which is the name of the calling functions. */
 void
-_log_fn(int severity, log_domain_mask_t domain, const char *fn,
+log_fn_(int severity, log_domain_mask_t domain, const char *fn,
         const char *format, ...)
 {
   va_list ap;
-  if (severity > _log_global_min_severity)
+  if (severity > log_global_min_severity_)
     return;
   va_start(ap,format);
   logv(severity, domain, fn, format, ap);
@@ -450,75 +450,75 @@ _log_fn(int severity, log_domain_mask_t domain, const char *fn,
 /** @{ */
 /** Variant implementation of log_fn, log_debug, log_info,... for C compilers
  * without variadic macros.  In this case, the calling function sets
- * _log_fn_function_name to the name of the function, then invokes the
- * appropriate _log_fn, _log_debug, etc. */
-const char *_log_fn_function_name=NULL;
+ * log_fn_function_name_ to the name of the function, then invokes the
+ * appropriate log_fn_, log_debug_, etc. */
+const char *log_fn_function_name_=NULL;
 void
-_log_fn(int severity, log_domain_mask_t domain, const char *format, ...)
+log_fn_(int severity, log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (severity > _log_global_min_severity)
+  if (severity > log_global_min_severity_)
     return;
   va_start(ap,format);
-  logv(severity, domain, _log_fn_function_name, format, ap);
+  logv(severity, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 void
-_log_debug(log_domain_mask_t domain, const char *format, ...)
+log_debug_(log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
   /* For GCC we do this check in the macro. */
-  if (PREDICT_LIKELY(LOG_DEBUG > _log_global_min_severity))
+  if (PREDICT_LIKELY(LOG_DEBUG > log_global_min_severity_))
     return;
   va_start(ap,format);
-  logv(LOG_DEBUG, domain, _log_fn_function_name, format, ap);
+  logv(LOG_DEBUG, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 void
-_log_info(log_domain_mask_t domain, const char *format, ...)
+log_info_(log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (LOG_INFO > _log_global_min_severity)
+  if (LOG_INFO > log_global_min_severity_)
     return;
   va_start(ap,format);
-  logv(LOG_INFO, domain, _log_fn_function_name, format, ap);
+  logv(LOG_INFO, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 void
-_log_notice(log_domain_mask_t domain, const char *format, ...)
+log_notice_(log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (LOG_NOTICE > _log_global_min_severity)
+  if (LOG_NOTICE > log_global_min_severity_)
     return;
   va_start(ap,format);
-  logv(LOG_NOTICE, domain, _log_fn_function_name, format, ap);
+  logv(LOG_NOTICE, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 void
-_log_warn(log_domain_mask_t domain, const char *format, ...)
+log_warn_(log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (LOG_WARN > _log_global_min_severity)
+  if (LOG_WARN > log_global_min_severity_)
     return;
   va_start(ap,format);
-  logv(LOG_WARN, domain, _log_fn_function_name, format, ap);
+  logv(LOG_WARN, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 void
-_log_err(log_domain_mask_t domain, const char *format, ...)
+log_err_(log_domain_mask_t domain, const char *format, ...)
 {
   va_list ap;
-  if (LOG_ERR > _log_global_min_severity)
+  if (LOG_ERR > log_global_min_severity_)
     return;
   va_start(ap,format);
-  logv(LOG_ERR, domain, _log_fn_function_name, format, ap);
+  logv(LOG_ERR, domain, log_fn_function_name_, format, ap);
   va_end(ap);
-  _log_fn_function_name = NULL;
+  log_fn_function_name_ = NULL;
 }
 /** @} */
 #endif
@@ -638,7 +638,7 @@ add_stream_log_impl(const log_severity_list_t *severity,
   lf->next = logfiles;
 
   logfiles = lf;
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
 }
 
 /** Add a log handler named <b>name</b> to send all messages in <b>severity</b>
@@ -706,7 +706,7 @@ add_callback_log(const log_severity_list_t *severity, log_callback cb)
 
   LOCK_LOGS();
   logfiles = lf;
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
   UNLOCK_LOGS();
   return 0;
 }
@@ -726,7 +726,7 @@ change_callback_log_severity(int loglevelMin, int loglevelMax,
       memcpy(lf->severities, &severities, sizeof(severities));
     }
   }
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
   UNLOCK_LOGS();
 }
 
@@ -792,7 +792,7 @@ close_temp_logs(void)
     }
   }
 
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
   UNLOCK_LOGS();
 }
 
@@ -840,7 +840,7 @@ add_file_log(const log_severity_list_t *severity, const char *filename)
   add_stream_log_impl(severity, filename, fd);
   logfiles->needs_close = 1;
   lf = logfiles;
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
 
   if (log_tor_version(lf, 0) < 0) {
     delete_log(lf);
@@ -871,7 +871,7 @@ add_syslog_log(const log_severity_list_t *severity)
   LOCK_LOGS();
   lf->next = logfiles;
   logfiles = lf;
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
   UNLOCK_LOGS();
   return 0;
 }
@@ -1106,7 +1106,7 @@ switch_logs_debug(void)
     for (i = LOG_DEBUG; i >= LOG_ERR; --i)
       lf->severities->masks[SEVERITY_MASK_IDX(i)] = ~0u;
   }
-  _log_global_min_severity = get_min_log_level();
+  log_global_min_severity_ = get_min_log_level();
   UNLOCK_LOGS();
 }
 

+ 1 - 1
src/common/memarea.c

@@ -77,7 +77,7 @@ typedef struct memarea_chunk_t {
                    * full. */
   union {
     char mem[1]; /**< Memory space in this chunk.  */
-    void *_void_for_alignment; /**< Dummy; used to make sure mem is aligned. */
+    void *void_for_alignment_; /**< Dummy; used to make sure mem is aligned. */
   } u;
 } memarea_chunk_t;
 

+ 2 - 2
src/common/memarea.h

@@ -2,8 +2,8 @@
 /* See LICENSE for licensing information */
 /* Tor dependencies */
 
-#ifndef _TOR_MEMAREA_H
-#define _TOR_MEMAREA_H
+#ifndef TOR_MEMAREA_H
+#define TOR_MEMAREA_H
 
 typedef struct memarea_t memarea_t;
 

+ 1 - 1
src/common/mempool.c

@@ -113,7 +113,7 @@ struct mp_allocated_t {
      * (Not actual size.) */
     char mem[1];
     /** An extra element to the union to insure correct alignment. */
-    ALIGNMENT_TYPE _dummy;
+    ALIGNMENT_TYPE dummy_;
   } u;
 };
 

+ 2 - 2
src/common/mempool.h

@@ -6,8 +6,8 @@
  * \brief Headers for mempool.c
  **/
 
-#ifndef _TOR_MEMPOOL_H
-#define _TOR_MEMPOOL_H
+#ifndef TOR_MEMPOOL_H
+#define TOR_MEMPOOL_H
 
 /** A memory pool is a context in which a large number of fixed-sized
 * objects can be allocated efficiently.  See mempool.c for implementation

+ 2 - 2
src/common/torgzip.h

@@ -8,8 +8,8 @@
  * \brief Headers for torgzip.h
  **/
 
-#ifndef _TOR_TORGZIP_H
-#define _TOR_TORGZIP_H
+#ifndef TOR_TORGZIP_H
+#define TOR_TORGZIP_H
 
 /** Enumeration of what kind of compression to use.  Only ZLIB_METHOD is
  * guaranteed to be supported by the compress/uncompress functions here;

+ 2 - 2
src/common/torint.h

@@ -8,8 +8,8 @@
  * \brief Header file to define uint32_t and friends
  **/
 
-#ifndef _TOR_TORINT_H
-#define _TOR_TORINT_H
+#ifndef TOR_TORINT_H
+#define TOR_TORINT_H
 
 #include "orconfig.h"
 

+ 30 - 30
src/common/torlog.h

@@ -10,7 +10,7 @@
  * \brief Headers for log.c
  **/
 
-#ifndef _TOR_LOG_H
+#ifndef TOR_TORLOG_H
 
 #include "compat.h"
 
@@ -156,63 +156,63 @@ void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
 #define log tor_log /* hack it so we don't conflict with log() as much */
 
 #if defined(__GNUC__) || defined(RUNNING_DOXYGEN)
-extern int _log_global_min_severity;
+extern int log_global_min_severity_;
 
-void _log_fn(int severity, log_domain_mask_t domain,
+void log_fn_(int severity, log_domain_mask_t domain,
              const char *funcname, const char *format, ...)
   CHECK_PRINTF(4,5);
 /** Log a message at level <b>severity</b>, using a pretty-printed version
  * of the current function name. */
 #define log_fn(severity, domain, args...)               \
-  _log_fn(severity, domain, __PRETTY_FUNCTION__, args)
+  log_fn_(severity, domain, __PRETTY_FUNCTION__, args)
 #define log_debug(domain, args...)                                      \
   STMT_BEGIN                                                            \
-    if (PREDICT_UNLIKELY(_log_global_min_severity == LOG_DEBUG))        \
-      _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args);            \
+    if (PREDICT_UNLIKELY(log_global_min_severity_ == LOG_DEBUG))        \
+      log_fn_(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args);            \
   STMT_END
 #define log_info(domain, args...)                           \
-  _log_fn(LOG_INFO, domain, __PRETTY_FUNCTION__, args)
+  log_fn_(LOG_INFO, domain, __PRETTY_FUNCTION__, args)
 #define log_notice(domain, args...)                         \
-  _log_fn(LOG_NOTICE, domain, __PRETTY_FUNCTION__, args)
+  log_fn_(LOG_NOTICE, domain, __PRETTY_FUNCTION__, args)
 #define log_warn(domain, args...)                           \
-  _log_fn(LOG_WARN, domain, __PRETTY_FUNCTION__, args)
+  log_fn_(LOG_WARN, domain, __PRETTY_FUNCTION__, args)
 #define log_err(domain, args...)                            \
-  _log_fn(LOG_ERR, domain, __PRETTY_FUNCTION__, args)
+  log_fn_(LOG_ERR, domain, __PRETTY_FUNCTION__, args)
 
 #else /* ! defined(__GNUC__) */
 
-void _log_fn(int severity, log_domain_mask_t domain, const char *format, ...);
-void _log_debug(log_domain_mask_t domain, const char *format, ...);
-void _log_info(log_domain_mask_t domain, const char *format, ...);
-void _log_notice(log_domain_mask_t domain, const char *format, ...);
-void _log_warn(log_domain_mask_t domain, const char *format, ...);
-void _log_err(log_domain_mask_t domain, const char *format, ...);
+void log_fn_(int severity, log_domain_mask_t domain, const char *format, ...);
+void log_debug_(log_domain_mask_t domain, const char *format, ...);
+void log_info_(log_domain_mask_t domain, const char *format, ...);
+void log_notice_(log_domain_mask_t domain, const char *format, ...);
+void log_warn_(log_domain_mask_t domain, const char *format, ...);
+void log_err_(log_domain_mask_t domain, const char *format, ...);
 
 #if defined(_MSC_VER) && _MSC_VER < 1300
 /* MSVC 6 and earlier don't have __func__, or even __LINE__. */
-#define log_fn _log_fn
-#define log_debug _log_debug
-#define log_info _log_info
-#define log_notice _log_notice
-#define log_warn _log_warn
-#define log_err _log_err
+#define log_fn log_fn_
+#define log_debug log_debug_
+#define log_info log_info_
+#define log_notice log_notice_
+#define log_warn log_warn_
+#define log_err log_err_
 #else
 /* We don't have GCC's varargs macros, so use a global variable to pass the
  * function name to log_fn */
-extern const char *_log_fn_function_name;
+extern const char *log_fn_function_name_;
 /* We abuse the comma operator here, since we can't use the standard
  * do {...} while (0) trick to wrap this macro, since the macro can't take
  * arguments. */
-#define log_fn (_log_fn_function_name=__func__),_log_fn
-#define log_debug (_log_fn_function_name=__func__),_log_debug
-#define log_info (_log_fn_function_name=__func__),_log_info
-#define log_notice (_log_fn_function_name=__func__),_log_notice
-#define log_warn (_log_fn_function_name=__func__),_log_warn
-#define log_err (_log_fn_function_name=__func__),_log_err
+#define log_fn (log_fn_function_name_=__func__),log_fn_
+#define log_debug (log_fn_function_name_=__func__),log_debug_
+#define log_info (log_fn_function_name_=__func__),log_info_
+#define log_notice (log_fn_function_name_=__func__),log_notice_
+#define log_warn (log_fn_function_name_=__func__),log_warn_
+#define log_err (log_fn_function_name_=__func__),log_err_
 #endif
 
 #endif /* !GNUC */
 
-# define _TOR_LOG_H
+# define TOR_TORLOG_H
 #endif
 

+ 18 - 18
src/common/tortls.c

@@ -234,8 +234,8 @@ static tor_tls_context_t *client_tls_context = NULL;
 static int tls_library_is_initialized = 0;
 
 /* Module-internal error codes. */
-#define _TOR_TLS_SYSCALL    (_MIN_TOR_TLS_ERROR_VAL - 2)
-#define _TOR_TLS_ZERORETURN (_MIN_TOR_TLS_ERROR_VAL - 1)
+#define TOR_TLS_SYSCALL_    (MIN_TOR_TLS_ERROR_VAL_ - 2)
+#define TOR_TLS_ZERORETURN_ (MIN_TOR_TLS_ERROR_VAL_ - 1)
 
 /** Write a description of the current state of <b>tls</b> into the
  * <b>sz</b>-byte buffer at <b>buf</b>. */
@@ -393,9 +393,9 @@ tor_tls_err_to_string(int err)
 /** Given a TLS object and the result of an SSL_* call, use
  * SSL_get_error to determine whether an error has occurred, and if so
  * which one.  Return one of TOR_TLS_{DONE|WANTREAD|WANTWRITE|ERROR}.
- * If extra&CATCH_SYSCALL is true, return _TOR_TLS_SYSCALL instead of
+ * If extra&CATCH_SYSCALL is true, return TOR_TLS_SYSCALL_ instead of
  * reporting syscall errors.  If extra&CATCH_ZERO is true, return
- * _TOR_TLS_ZERORETURN instead of reporting zero-return errors.
+ * TOR_TLS_ZERORETURN_ instead of reporting zero-return errors.
  *
  * If an error has occurred, log it at level <b>severity</b> and describe the
  * current action as <b>doing</b>.
@@ -415,7 +415,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
       return TOR_TLS_WANTWRITE;
     case SSL_ERROR_SYSCALL:
       if (extra&CATCH_SYSCALL)
-        return _TOR_TLS_SYSCALL;
+        return TOR_TLS_SYSCALL_;
       if (r == 0) {
         log(severity, LD_NET, "TLS error: unexpected close while %s (%s)",
             doing, SSL_state_string_long(tls->ssl));
@@ -432,7 +432,7 @@ tor_tls_get_error(tor_tls_t *tls, int r, int extra,
       return tor_error;
     case SSL_ERROR_ZERO_RETURN:
       if (extra&CATCH_ZERO)
-        return _TOR_TLS_ZERORETURN;
+        return TOR_TLS_ZERORETURN_;
       log(severity, LD_NET, "TLS connection closed while %s in state %s",
           doing, SSL_state_string_long(tls->ssl));
       tls_log_errors(tls, severity, domain, doing);
@@ -597,9 +597,9 @@ tor_tls_create_certificate(crypto_pk_t *rsa,
   tor_assert(cname);
   tor_assert(rsa_sign);
   tor_assert(cname_sign);
-  if (!(sign_pkey = _crypto_pk_get_evp_pkey(rsa_sign,1)))
+  if (!(sign_pkey = crypto_pk_get_evp_pkey_(rsa_sign,1)))
     goto error;
-  if (!(pkey = _crypto_pk_get_evp_pkey(rsa,0)))
+  if (!(pkey = crypto_pk_get_evp_pkey_(rsa,0)))
     goto error;
   if (!(x509 = X509_new()))
     goto error;
@@ -754,7 +754,7 @@ tor_cert_new(X509 *x509_cert)
 
   if ((pkey = X509_get_pubkey(x509_cert)) &&
       (rsa = EVP_PKEY_get1_RSA(pkey))) {
-    crypto_pk_t *pk = _crypto_new_pk_from_rsa(rsa);
+    crypto_pk_t *pk = crypto_new_pk_from_rsa_(rsa);
     crypto_pk_get_all_digests(pk, &cert->pkey_digests);
     cert->pkey_digests_set = 1;
     crypto_pk_free(pk);
@@ -896,7 +896,7 @@ tor_tls_cert_get_key(tor_cert_t *cert)
     EVP_PKEY_free(pkey);
     return NULL;
   }
-  result = _crypto_new_pk_from_rsa(rsa);
+  result = crypto_new_pk_from_rsa_(rsa);
   EVP_PKEY_free(pkey);
   return result;
 }
@@ -1244,7 +1244,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
   SSL_CTX_set_session_cache_mode(result->ctx, SSL_SESS_CACHE_OFF);
   if (!is_client) {
     tor_assert(rsa);
-    if (!(pkey = _crypto_pk_get_evp_pkey(rsa,1)))
+    if (!(pkey = crypto_pk_get_evp_pkey_(rsa,1)))
       goto error;
     if (!SSL_CTX_use_PrivateKey(result->ctx, pkey))
       goto error;
@@ -1256,7 +1256,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
   {
     crypto_dh_t *dh = crypto_dh_new(DH_TYPE_TLS);
     tor_assert(dh);
-    SSL_CTX_set_tmp_dh(result->ctx, _crypto_dh_get_dh(dh));
+    SSL_CTX_set_tmp_dh(result->ctx, crypto_dh_get_dh_(dh));
     crypto_dh_free(dh);
   }
   SSL_CTX_set_verify(result->ctx, SSL_VERIFY_PEER,
@@ -1748,7 +1748,7 @@ tor_tls_read(tor_tls_t *tls, char *cp, size_t len)
     return r;
   }
   err = tor_tls_get_error(tls, r, CATCH_ZERO, "reading", LOG_DEBUG, LD_NET);
-  if (err == _TOR_TLS_ZERORETURN || err == TOR_TLS_CLOSE) {
+  if (err == TOR_TLS_ZERORETURN_ || err == TOR_TLS_CLOSE) {
     log_debug(LD_NET,"read returned r=%d; TLS is closed",r);
     tls->state = TOR_TLS_ST_CLOSED;
     return TOR_TLS_CLOSE;
@@ -1961,7 +1961,7 @@ tor_tls_shutdown(tor_tls_t *tls)
       } while (r>0);
       err = tor_tls_get_error(tls, r, CATCH_ZERO, "reading to shut down",
                               LOG_INFO, LD_NET);
-      if (err == _TOR_TLS_ZERORETURN) {
+      if (err == TOR_TLS_ZERORETURN_) {
         tls->state = TOR_TLS_ST_GOTCLOSE;
         /* fall through... */
       } else {
@@ -1977,11 +1977,11 @@ tor_tls_shutdown(tor_tls_t *tls)
     }
     err = tor_tls_get_error(tls, r, CATCH_SYSCALL|CATCH_ZERO, "shutting down",
                             LOG_INFO, LD_NET);
-    if (err == _TOR_TLS_SYSCALL) {
+    if (err == TOR_TLS_SYSCALL_) {
       /* The underlying TCP connection closed while we were shutting down. */
       tls->state = TOR_TLS_ST_CLOSED;
       return TOR_TLS_DONE;
-    } else if (err == _TOR_TLS_ZERORETURN) {
+    } else if (err == TOR_TLS_ZERORETURN_) {
       /* The TLS connection says that it sent a shutdown record, but
        * isn't done shutting down yet.  Make sure that this hasn't
        * happened before, then go back to the start of the function
@@ -2151,7 +2151,7 @@ tor_tls_verify(int severity, tor_tls_t *tls, crypto_pk_t **identity_key)
   rsa = EVP_PKEY_get1_RSA(id_pkey);
   if (!rsa)
     goto done;
-  *identity_key = _crypto_new_pk_from_rsa(rsa);
+  *identity_key = crypto_new_pk_from_rsa_(rsa);
 
   r = 0;
 
@@ -2281,7 +2281,7 @@ tor_tls_get_n_raw_bytes(tor_tls_t *tls, size_t *n_read, size_t *n_written)
 /** Implement check_no_tls_errors: If there are any pending OpenSSL
  * errors, log an error message. */
 void
-_check_no_tls_errors(const char *fname, int line)
+check_no_tls_errors_(const char *fname, int line)
 {
   if (ERR_peek_error() == 0)
     return;

+ 5 - 5
src/common/tortls.h

@@ -3,8 +3,8 @@
  * Copyright (c) 2007-2012, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
-#ifndef _TOR_TORTLS_H
-#define _TOR_TORTLS_H
+#ifndef TOR_TORTLS_H
+#define TOR_TORTLS_H
 
 /**
  * \file tortls.h
@@ -21,7 +21,7 @@ typedef struct tor_tls_t tor_tls_t;
 typedef struct tor_cert_t tor_cert_t;
 
 /* Possible return values for most tor_tls_* functions. */
-#define _MIN_TOR_TLS_ERROR_VAL     -9
+#define MIN_TOR_TLS_ERROR_VAL_     -9
 #define TOR_TLS_ERROR_MISC         -9
 /* Rename to unexpected close or something. XXXX */
 #define TOR_TLS_ERROR_IO           -8
@@ -98,9 +98,9 @@ int tor_tls_get_tlssecrets(tor_tls_t *tls, uint8_t *secrets_out);
 
 /* Log and abort if there are unhandled TLS errors in OpenSSL's error stack.
  */
-#define check_no_tls_errors() _check_no_tls_errors(__FILE__,__LINE__)
+#define check_no_tls_errors() check_no_tls_errors_(__FILE__,__LINE__)
 
-void _check_no_tls_errors(const char *fname, int line);
+void check_no_tls_errors_(const char *fname, int line);
 void tor_tls_log_one_error(tor_tls_t *tls, unsigned long err,
                            int severity, int domain, const char *doing);
 

+ 23 - 23
src/common/util.c

@@ -39,8 +39,8 @@
 #endif
 
 /* math.h needs this on Linux */
-#ifndef __USE_ISOC99
-#define __USE_ISOC99 1
+#ifndef _USE_ISOC99_
+#define _USE_ISOC99_ 1
 #endif
 #include <math.h>
 #include <stdlib.h>
@@ -125,7 +125,7 @@
  * ignored otherwise.
  */
 void *
-_tor_malloc(size_t size DMALLOC_PARAMS)
+tor_malloc_(size_t size DMALLOC_PARAMS)
 {
   void *result;
 
@@ -159,7 +159,7 @@ _tor_malloc(size_t size DMALLOC_PARAMS)
  * the process on error.  (Same as calloc(size,1), but never returns NULL.)
  */
 void *
-_tor_malloc_zero(size_t size DMALLOC_PARAMS)
+tor_malloc_zero_(size_t size DMALLOC_PARAMS)
 {
   /* You may ask yourself, "wouldn't it be smart to use calloc instead of
    * malloc+memset?  Perhaps libc's calloc knows some nifty optimization trick
@@ -167,7 +167,7 @@ _tor_malloc_zero(size_t size DMALLOC_PARAMS)
    * we're allocating something very big (it knows if it just got the memory
    * from the OS in a pre-zeroed state).  We don't want to use tor_malloc_zero
    * for big stuff, so we don't bother with calloc. */
-  void *result = _tor_malloc(size DMALLOC_FN_ARGS);
+  void *result = tor_malloc_(size DMALLOC_FN_ARGS);
   memset(result, 0, size);
   return result;
 }
@@ -184,7 +184,7 @@ _tor_malloc_zero(size_t size DMALLOC_PARAMS)
  * smaller than size).  Don't do that then.
  */
 void *
-_tor_calloc(size_t nmemb, size_t size DMALLOC_PARAMS)
+tor_calloc_(size_t nmemb, size_t size DMALLOC_PARAMS)
 {
   /* You may ask yourself, "wouldn't it be smart to use calloc instead of
    * malloc+memset?  Perhaps libc's calloc knows some nifty optimization trick
@@ -197,7 +197,7 @@ _tor_calloc(size_t nmemb, size_t size DMALLOC_PARAMS)
 
   tor_assert(nmemb < max_nmemb);
 
-  result = _tor_malloc_zero((nmemb * size) DMALLOC_FN_ARGS);
+  result = tor_malloc_zero_((nmemb * size) DMALLOC_FN_ARGS);
   return result;
 }
 
@@ -206,7 +206,7 @@ _tor_calloc(size_t nmemb, size_t size DMALLOC_PARAMS)
  * terminate. (Like realloc(ptr,size), but never returns NULL.)
  */
 void *
-_tor_realloc(void *ptr, size_t size DMALLOC_PARAMS)
+tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS)
 {
   void *result;
 
@@ -230,7 +230,7 @@ _tor_realloc(void *ptr, size_t size DMALLOC_PARAMS)
  * NULL.)
  */
 char *
-_tor_strdup(const char *s DMALLOC_PARAMS)
+tor_strdup_(const char *s DMALLOC_PARAMS)
 {
   char *dup;
   tor_assert(s);
@@ -254,12 +254,12 @@ _tor_strdup(const char *s DMALLOC_PARAMS)
  * NULL.)
  */
 char *
-_tor_strndup(const char *s, size_t n DMALLOC_PARAMS)
+tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
 {
   char *dup;
   tor_assert(s);
   tor_assert(n < SIZE_T_CEILING);
-  dup = _tor_malloc((n+1) DMALLOC_FN_ARGS);
+  dup = tor_malloc_((n+1) DMALLOC_FN_ARGS);
   /* Performance note: Ordinarily we prefer strlcpy to strncpy.  But
    * this function gets called a whole lot, and platform strncpy is
    * much faster than strlcpy when strlen(s) is much longer than n.
@@ -272,12 +272,12 @@ _tor_strndup(const char *s, size_t n DMALLOC_PARAMS)
 /** Allocate a chunk of <b>len</b> bytes, with the same contents as the
  * <b>len</b> bytes starting at <b>mem</b>. */
 void *
-_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS)
+tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
 {
   char *dup;
   tor_assert(len < SIZE_T_CEILING);
   tor_assert(mem);
-  dup = _tor_malloc(len DMALLOC_FN_ARGS);
+  dup = tor_malloc_(len DMALLOC_FN_ARGS);
   memcpy(dup, mem, len);
   return dup;
 }
@@ -285,7 +285,7 @@ _tor_memdup(const void *mem, size_t len DMALLOC_PARAMS)
 /** Helper for places that need to take a function pointer to the right
  * spelling of "free()". */
 void
-_tor_free(void *mem)
+tor_free_(void *mem)
 {
   tor_free(mem);
 }
@@ -1019,7 +1019,7 @@ base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
 
 /** Helper: given a hex digit, return its value, or -1 if it isn't hex. */
 static INLINE int
-_hex_decode_digit(char c)
+hex_decode_digit_(char c)
 {
   switch (c) {
     case '0': return 0;
@@ -1047,7 +1047,7 @@ _hex_decode_digit(char c)
 int
 hex_decode_digit(char c)
 {
-  return _hex_decode_digit(c);
+  return hex_decode_digit_(c);
 }
 
 /** Given a hexadecimal string of <b>srclen</b> bytes in <b>src</b>, decode it
@@ -1065,8 +1065,8 @@ base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
     return -1;
   end = src+srclen;
   while (src<end) {
-    v1 = _hex_decode_digit(*src);
-    v2 = _hex_decode_digit(*(src+1));
+    v1 = hex_decode_digit_(*src);
+    v2 = hex_decode_digit_(*(src+1));
     if (v1<0||v2<0)
       return -1;
     *(uint8_t*)dest = (v1<<4)|v2;
@@ -1166,15 +1166,15 @@ esc_for_log(const char *s)
 const char *
 escaped(const char *s)
 {
-  static char *_escaped_val = NULL;
-  tor_free(_escaped_val);
+  static char *escaped_val_ = NULL;
+  tor_free(escaped_val_);
 
   if (s)
-    _escaped_val = esc_for_log(s);
+    escaped_val_ = esc_for_log(s);
   else
-    _escaped_val = NULL;
+    escaped_val_ = NULL;
 
-  return _escaped_val;
+  return escaped_val_;
 }
 
 /** Rudimentary string wrapping code: given a un-wrapped <b>string</b> (no

+ 22 - 22
src/common/util.h

@@ -8,8 +8,8 @@
  * \brief Headers for util.c
  **/
 
-#ifndef _TOR_UTIL_H
-#define _TOR_UTIL_H
+#ifndef TOR_UTIL_H
+#define TOR_UTIL_H
 
 #include "orconfig.h"
 #include "torint.h"
@@ -49,9 +49,9 @@
 #define tor_assert(expr) STMT_BEGIN                                     \
     if (PREDICT_UNLIKELY(!(expr))) {                                    \
       log_err(LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.",      \
-          _SHORT_FILE_, __LINE__, __func__, #expr);                     \
+          SHORT_FILE__, __LINE__, __func__, #expr);                     \
       fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n",      \
-              _SHORT_FILE_, __LINE__, __func__, #expr);                 \
+              SHORT_FILE__, __LINE__, __func__, #expr);                 \
       abort();                                                          \
     } STMT_END
 
@@ -62,7 +62,7 @@
  * to calls. */
 #ifdef USE_DMALLOC
 #define DMALLOC_PARAMS , const char *file, const int line
-#define DMALLOC_ARGS , _SHORT_FILE_, __LINE__
+#define DMALLOC_ARGS , SHORT_FILE__, __LINE__
 #else
 #define DMALLOC_PARAMS
 #define DMALLOC_ARGS
@@ -74,22 +74,22 @@
 #define tor_fragile_assert()
 
 /* Memory management */
-void *_tor_malloc(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
-void *_tor_malloc_zero(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
-void *_tor_calloc(size_t nmemb, size_t size DMALLOC_PARAMS) ATTR_MALLOC;
-void *_tor_realloc(void *ptr, size_t size DMALLOC_PARAMS);
-char *_tor_strdup(const char *s DMALLOC_PARAMS) ATTR_MALLOC ATTR_NONNULL((1));
-char *_tor_strndup(const char *s, size_t n DMALLOC_PARAMS)
+void *tor_malloc_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
+void *tor_malloc_zero_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
+void *tor_calloc_(size_t nmemb, size_t size DMALLOC_PARAMS) ATTR_MALLOC;
+void *tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS);
+char *tor_strdup_(const char *s DMALLOC_PARAMS) ATTR_MALLOC ATTR_NONNULL((1));
+char *tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
   ATTR_MALLOC ATTR_NONNULL((1));
-void *_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS)
+void *tor_memdup_(const void *mem, size_t len DMALLOC_PARAMS)
   ATTR_MALLOC ATTR_NONNULL((1));
-void _tor_free(void *mem);
+void tor_free_(void *mem);
 #ifdef USE_DMALLOC
 extern int dmalloc_free(const char *file, const int line, void *pnt,
                         const int func_id);
 #define tor_free(p) STMT_BEGIN \
     if (PREDICT_LIKELY((p)!=NULL)) {                \
-      dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
+      dmalloc_free(SHORT_FILE__, __LINE__, (p), 0); \
       (p)=NULL;                                     \
     }                                               \
   STMT_END
@@ -99,7 +99,7 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
  * and it sets the pointer value to NULL after freeing it.
  *
  * This is a macro.  If you need a function pointer to release memory from
- * tor_malloc(), use _tor_free().
+ * tor_malloc(), use tor_free_().
  */
 #define tor_free(p) STMT_BEGIN                                 \
     if (PREDICT_LIKELY((p)!=NULL)) {                           \
@@ -109,14 +109,14 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
   STMT_END
 #endif
 
-#define tor_malloc(size)       _tor_malloc(size DMALLOC_ARGS)
-#define tor_malloc_zero(size)  _tor_malloc_zero(size DMALLOC_ARGS)
-#define tor_calloc(nmemb,size) _tor_calloc(nmemb, size DMALLOC_ARGS)
+#define tor_malloc(size)       tor_malloc_(size DMALLOC_ARGS)
+#define tor_malloc_zero(size)  tor_malloc_zero_(size DMALLOC_ARGS)
+#define tor_calloc(nmemb,size) tor_calloc_(nmemb, size DMALLOC_ARGS)
 #define tor_malloc_roundup(szp) _tor_malloc_roundup(szp DMALLOC_ARGS)
-#define tor_realloc(ptr, size) _tor_realloc(ptr, size DMALLOC_ARGS)
-#define tor_strdup(s)          _tor_strdup(s DMALLOC_ARGS)
-#define tor_strndup(s, n)      _tor_strndup(s, n DMALLOC_ARGS)
-#define tor_memdup(s, n)       _tor_memdup(s, n DMALLOC_ARGS)
+#define tor_realloc(ptr, size) tor_realloc_(ptr, size DMALLOC_ARGS)
+#define tor_strdup(s)          tor_strdup_(s DMALLOC_ARGS)
+#define tor_strndup(s, n)      tor_strndup_(s, n DMALLOC_ARGS)
+#define tor_memdup(s, n)       tor_memdup_(s, n DMALLOC_ARGS)
 
 void tor_log_mallinfo(int severity);
 

+ 2 - 2
src/ext/eventdns.h

@@ -209,8 +209,8 @@
  * with the next probe.
  */
 
-#ifndef _TOR_EVENTDNS_H
-#define _TOR_EVENTDNS_H
+#ifndef TOR_EVENTDNS_H
+#define TOR_EVENTDNS_H
 
 /* Error codes 0-5 are as described in RFC 1035. */
 #define DNS_ERR_NONE 0

+ 2 - 2
src/ext/ht.h

@@ -5,8 +5,8 @@
 
 /* Based on ideas by Christopher Clark and interfaces from Niels Provos. */
 
-#ifndef _TOR_HT_H
-#define _TOR_HT_H
+#ifndef HT_H_INCLUDED_
+#define HT_H_INCLUDED_
 
 #define HT_HEAD(name, type)                                             \
   struct name {                                                         \

+ 2 - 2
src/or/buffers.h

@@ -9,8 +9,8 @@
  * \brief Header file for buffers.c.
  **/
 
-#ifndef _TOR_BUFFERS_H
-#define _TOR_BUFFERS_H
+#ifndef TOR_BUFFERS_H
+#define TOR_BUFFERS_H
 
 buf_t *buf_new(void);
 buf_t *buf_new_with_capacity(size_t size);

+ 1 - 1
src/or/channel.c

@@ -11,7 +11,7 @@
  * should touch.
  */
 
-#define _TOR_CHANNEL_INTERNAL
+#define TOR_CHANNEL_INTERNAL_
 
 #include "or.h"
 #include "channel.h"

+ 3 - 3
src/or/channel.h

@@ -6,8 +6,8 @@
  * \brief Header file for channel.c
  **/
 
-#ifndef _TOR_CHANNEL_H
-#define _TOR_CHANNEL_H
+#ifndef TOR_CHANNEL_H
+#define TOR_CHANNEL_H
 
 #include "or.h"
 #include "circuitmux.h"
@@ -294,7 +294,7 @@ void channel_listener_dumpstats(int severity);
 /* Set the cmux policy on all active channels */
 void channel_set_cmux_policy_everywhere(circuitmux_policy_t *pol);
 
-#ifdef _TOR_CHANNEL_INTERNAL
+#ifdef TOR_CHANNEL_INTERNAL_
 
 /* Channel operations for subclasses and internal use only */
 

+ 50 - 50
src/or/channeltls.c

@@ -11,7 +11,7 @@
  * should touch.
  */
 
-#define _TOR_CHANNEL_INTERNAL
+#define TOR_CHANNEL_INTERNAL_
 
 #include "or.h"
 #include "channel.h"
@@ -104,7 +104,7 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
                     const char *id_digest)
 {
   channel_tls_t *tlschan = tor_malloc_zero(sizeof(*tlschan));
-  channel_t *chan = &(tlschan->_base);
+  channel_t *chan = &(tlschan->base_);
   channel_init(chan);
   chan->magic = TLS_CHAN_MAGIC;
   chan->state = CHANNEL_STATE_OPENING;
@@ -238,7 +238,7 @@ channel_t *
 channel_tls_handle_incoming(or_connection_t *orconn)
 {
   channel_tls_t *tlschan = tor_malloc_zero(sizeof(*tlschan));
-  channel_t *chan = &(tlschan->_base);
+  channel_t *chan = &(tlschan->base_);
 
   tor_assert(orconn);
   tor_assert(!(orconn->chan));
@@ -288,7 +288,7 @@ channel_tls_to_base(channel_tls_t *tlschan)
 {
   if (!tlschan) return NULL;
 
-  return &(tlschan->_base);
+  return &(tlschan->base_);
 }
 
 /**
@@ -441,7 +441,7 @@ channel_tls_get_remote_descr_method(channel_t *chan, int req)
 /**
  * Tell the upper layer if we have queued writes
  *
- * This implements the has_queued_writes method for channel_tls _t; it returns
+ * This implements the has_queued_writes method for channel_tls t_; it returns
  * 1 iff we have queued writes on the outbuf of the underlying or_connection_t.
  */
 
@@ -520,7 +520,7 @@ channel_tls_matches_extend_info_method(channel_t *chan,
 /**
  * Check if we match a target address
  *
- * This implements the matches_target method for channel_tls _t; the upper
+ * This implements the matches_target method for channel_tls t_; the upper
  * layer wants to know if this channel matches a target address when extending
  * a circuit.
  */
@@ -847,7 +847,7 @@ channel_tls_handle_cell(cell_t *cell, or_connection_t *conn)
 
   handshaking = (TO_CONN(conn)->state != OR_CONN_STATE_OPEN);
 
-  if (conn->_base.marked_for_close)
+  if (conn->base_.marked_for_close)
     return;
 
   /* Reject all but VERSIONS and NETINFO when handshaking. */
@@ -864,7 +864,7 @@ channel_tls_handle_cell(cell_t *cell, or_connection_t *conn)
     return;
   }
 
-  if (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
     or_handshake_state_record_cell(conn->handshake_state, cell, 1);
 
   switch (cell->command) {
@@ -1118,7 +1118,7 @@ enter_v3_handshake_with_cell(var_cell_t *cell, channel_tls_t *chan)
            "Received a cell while TLS-handshaking, not in "
            "OR_HANDSHAKING_V3, on a connection we originated.");
   }
-  chan->conn->_base.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
+  chan->conn->base_.state = OR_CONN_STATE_OR_HANDSHAKING_V3;
   if (connection_init_or_handshake_state(chan->conn, started_here) < 0) {
     connection_or_close_for_error(chan->conn, 0);
     return -1;
@@ -1159,7 +1159,7 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
            (int)(chan->conn->link_proto));
     return;
   }
-  switch (chan->conn->_base.state)
+  switch (chan->conn->base_.state)
     {
     case OR_CONN_STATE_OR_HANDSHAKING_V2:
     case OR_CONN_STATE_OR_HANDSHAKING_V3:
@@ -1194,7 +1194,7 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
     connection_or_close_for_error(chan->conn, 0);
     return;
   } else if (highest_supported_version < 3 &&
-             chan->conn->_base.state ==  OR_CONN_STATE_OR_HANDSHAKING_V3) {
+             chan->conn->base_.state ==  OR_CONN_STATE_OR_HANDSHAKING_V3) {
     log_fn(LOG_PROTOCOL_WARN, LD_OR,
            "Negotiated link protocol 2 or lower after doing a v3 TLS "
            "handshake. Closing connection.");
@@ -1209,8 +1209,8 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
     log_info(LD_OR,
              "Negotiated version %d with %s:%d; sending NETINFO.",
              highest_supported_version,
-             safe_str_client(chan->conn->_base.address),
-             chan->conn->_base.port);
+             safe_str_client(chan->conn->base_.address),
+             chan->conn->base_.port);
 
     if (connection_or_send_netinfo(chan->conn) < 0) {
       connection_or_close_for_error(chan->conn, 0);
@@ -1232,8 +1232,8 @@ channel_tls_process_versions_cell(var_cell_t *cell, channel_tls_t *chan)
     log_info(LD_OR,
              "Negotiated version %d with %s:%d; %s%s%s%s%s",
              highest_supported_version,
-             safe_str_client(chan->conn->_base.address),
-             chan->conn->_base.port,
+             safe_str_client(chan->conn->base_.address),
+             chan->conn->base_.port,
              send_any ? "Sending cells:" : "Waiting for CERTS cell",
              send_versions ? " VERSIONS" : "",
              send_certs ? " CERTS" : "",
@@ -1309,8 +1309,8 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
            chan->conn->link_proto == 0 ? "non-versioned" : "a v1");
     return;
   }
-  if (chan->conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V2 &&
-      chan->conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V3) {
+  if (chan->conn->base_.state != OR_CONN_STATE_OR_HANDSHAKING_V2 &&
+      chan->conn->base_.state != OR_CONN_STATE_OR_HANDSHAKING_V3) {
     log_fn(LOG_PROTOCOL_WARN, LD_OR,
            "Received a NETINFO cell on non-handshaking connection; dropping.");
     return;
@@ -1318,7 +1318,7 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
   tor_assert(chan->conn->handshake_state &&
              chan->conn->handshake_state->received_versions);
 
-  if (chan->conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3) {
+  if (chan->conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3) {
     tor_assert(chan->conn->link_proto >= 3);
     if (chan->conn->handshake_state->started_here) {
       if (!(chan->conn->handshake_state->authenticated)) {
@@ -1338,8 +1338,8 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
         channel_set_circid_type(TLS_CHAN_TO_BASE(chan), NULL);
 
         connection_or_init_conn_from_address(chan->conn,
-                  &(chan->conn->_base.addr),
-                  chan->conn->_base.port,
+                  &(chan->conn->base_.addr),
+                  chan->conn->base_.port,
                   (const char*)(chan->conn->handshake_state->
                    authenticated_peer_id),
                   0);
@@ -1408,8 +1408,8 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
            "server at %s:%d.  It seems that our clock is %s by %s, or "
            "that theirs is %s. Tor requires an accurate clock to work: "
            "please check your time and date settings.",
-           chan->conn->_base.address,
-           (int)(chan->conn->_base.port),
+           chan->conn->base_.address,
+           (int)(chan->conn->base_.port),
            apparent_skew > 0 ? "ahead" : "behind",
            dbuf,
            apparent_skew > 0 ? "behind" : "ahead");
@@ -1417,8 +1417,8 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
       control_event_general_status(LOG_WARN,
                           "CLOCK_SKEW SKEW=%ld SOURCE=OR:%s:%d",
                           apparent_skew,
-                          chan->conn->_base.address,
-                          chan->conn->_base.port);
+                          chan->conn->base_.address,
+                          chan->conn->base_.port);
   }
 
   /* XXX maybe act on my_apparent_addr, if the source is sufficiently
@@ -1428,16 +1428,16 @@ channel_tls_process_netinfo_cell(cell_t *cell, channel_tls_t *chan)
     log_fn(LOG_PROTOCOL_WARN, LD_OR,
            "Got good NETINFO cell from %s:%d; but "
            "was unable to make the OR connection become open.",
-           safe_str_client(chan->conn->_base.address),
-           chan->conn->_base.port);
+           safe_str_client(chan->conn->base_.address),
+           chan->conn->base_.port);
     connection_or_close_for_error(chan->conn, 0);
   } else {
     log_info(LD_OR,
              "Got good NETINFO cell from %s:%d; OR connection is now "
              "open, using protocol version %d. Its ID digest is %s. "
              "Our address is apparently %s.",
-             safe_str_client(chan->conn->_base.address),
-             chan->conn->_base.port,
+             safe_str_client(chan->conn->base_.address),
+             chan->conn->base_.port,
              (int)(chan->conn->link_proto),
              hex_str(TLS_CHAN_TO_BASE(chan)->identity_digest,
                      DIGEST_LEN),
@@ -1481,13 +1481,13 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
   do {                                                          \
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,                      \
            "Received a bad CERTS cell from %s:%d: %s",          \
-           safe_str(chan->conn->_base.address),                 \
-           chan->conn->_base.port, (s));                        \
+           safe_str(chan->conn->base_.address),                 \
+           chan->conn->base_.port, (s));                        \
     connection_or_close_for_error(chan->conn, 0);               \
     return;                                                     \
   } while (0)
 
-  if (chan->conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (chan->conn->base_.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
     ERR("We're not doing a v3 handshake!");
   if (chan->conn->link_proto < 3)
     ERR("We're not using link protocol >= 3");
@@ -1522,8 +1522,8 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
       if (!cert) {
         log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
                "Received undecodable certificate in CERTS cell from %s:%d",
-               safe_str(chan->conn->_base.address),
-               chan->conn->_base.port);
+               safe_str(chan->conn->base_.address),
+               chan->conn->base_.port);
       } else {
         if (cert_type == OR_CERT_TYPE_TLS_LINK) {
           if (link_cert) {
@@ -1599,7 +1599,7 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
 
     log_info(LD_OR,
              "Got some good certificates from %s:%d: Authenticated it.",
-             safe_str(chan->conn->_base.address), chan->conn->_base.port);
+             safe_str(chan->conn->base_.address), chan->conn->base_.port);
 
     chan->conn->handshake_state->id_cert = id_cert;
     id_cert = NULL;
@@ -1623,8 +1623,8 @@ channel_tls_process_certs_cell(var_cell_t *cell, channel_tls_t *chan)
     log_info(LD_OR,
              "Got some good certificates from %s:%d: "
              "Waiting for AUTHENTICATE.",
-             safe_str(chan->conn->_base.address),
-             chan->conn->_base.port);
+             safe_str(chan->conn->base_.address),
+             chan->conn->base_.port);
     /* XXXX check more stuff? */
 
     chan->conn->handshake_state->id_cert = id_cert;
@@ -1674,13 +1674,13 @@ channel_tls_process_auth_challenge_cell(var_cell_t *cell, channel_tls_t *chan)
   do {                                                          \
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,                      \
            "Received a bad AUTH_CHALLENGE cell from %s:%d: %s", \
-           safe_str(chan->conn->_base.address),                 \
-           chan->conn->_base.port, (s));                        \
+           safe_str(chan->conn->base_.address),                 \
+           chan->conn->base_.port, (s));                        \
     connection_or_close_for_error(chan->conn, 0);               \
     return;                                                     \
   } while (0)
 
-  if (chan->conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (chan->conn->base_.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
     ERR("We're not currently doing a v3 handshake");
   if (chan->conn->link_proto < 3)
     ERR("We're not using link protocol >= 3");
@@ -1720,8 +1720,8 @@ channel_tls_process_auth_challenge_cell(var_cell_t *cell, channel_tls_t *chan)
     log_info(LD_OR,
              "Got an AUTH_CHALLENGE cell from %s:%d: Sending "
              "authentication",
-             safe_str(chan->conn->_base.address),
-             chan->conn->_base.port);
+             safe_str(chan->conn->base_.address),
+             chan->conn->base_.port);
 
     if (connection_or_send_authenticate_cell(chan->conn, use_type) < 0) {
       log_warn(LD_OR,
@@ -1733,8 +1733,8 @@ channel_tls_process_auth_challenge_cell(var_cell_t *cell, channel_tls_t *chan)
     log_info(LD_OR,
              "Got an AUTH_CHALLENGE cell from %s:%d, but we don't "
              "know any of its authentication types. Not authenticating.",
-             safe_str(chan->conn->_base.address),
-             chan->conn->_base.port);
+             safe_str(chan->conn->base_.address),
+             chan->conn->base_.port);
   }
 
   if (connection_or_send_netinfo(chan->conn) < 0) {
@@ -1771,13 +1771,13 @@ channel_tls_process_authenticate_cell(var_cell_t *cell, channel_tls_t *chan)
   do {                                                          \
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,                      \
            "Received a bad AUTHENTICATE cell from %s:%d: %s",   \
-           safe_str(chan->conn->_base.address),                 \
-           chan->conn->_base.port, (s));                        \
+           safe_str(chan->conn->base_.address),                 \
+           chan->conn->base_.port, (s));                        \
     connection_or_close_for_error(chan->conn, 0);               \
     return;                                                     \
   } while (0)
 
-  if (chan->conn->_base.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (chan->conn->base_.state != OR_CONN_STATE_OR_HANDSHAKING_V3)
     ERR("We're not doing a v3 handshake");
   if (chan->conn->link_proto < 3)
     ERR("We're not using link protocol >= 3");
@@ -1877,16 +1877,16 @@ channel_tls_process_authenticate_cell(var_cell_t *cell, channel_tls_t *chan)
     crypto_pk_free(identity_rcvd);
 
     connection_or_init_conn_from_address(chan->conn,
-                  &(chan->conn->_base.addr),
-                  chan->conn->_base.port,
+                  &(chan->conn->base_.addr),
+                  chan->conn->base_.port,
                   (const char*)(chan->conn->handshake_state->
                     authenticated_peer_id),
                   0);
 
     log_info(LD_OR,
              "Got an AUTHENTICATE cell from %s:%d: Looks good.",
-             safe_str(chan->conn->_base.address),
-             chan->conn->_base.port);
+             safe_str(chan->conn->base_.address),
+             chan->conn->base_.port);
   }
 
 #undef ERR

+ 5 - 5
src/or/channeltls.h

@@ -6,8 +6,8 @@
  * \brief Header file for channeltls.c
  **/
 
-#ifndef _TOR_CHANNEL_TLS_H
-#define _TOR_CHANNEL_TLS_H
+#ifndef TOR_CHANNELTLS_H
+#define TOR_CHANNELTLS_H
 
 #include "or.h"
 #include "channel.h"
@@ -17,16 +17,16 @@
 
 #define TLS_CHAN_MAGIC 0x8a192427U
 
-#ifdef _TOR_CHANNEL_INTERNAL
+#ifdef TOR_CHANNEL_INTERNAL_
 
 struct channel_tls_s {
   /* Base channel_t struct */
-  channel_t _base;
+  channel_t base_;
   /* or_connection_t pointer */
   or_connection_t *conn;
 };
 
-#endif /* _TOR_CHANNEL_INTERNAL */
+#endif /* TOR_CHANNEL_INTERNAL_ */
 
 channel_t * channel_tls_connect(const tor_addr_t *addr, uint16_t port,
                                 const char *id_digest);

+ 55 - 55
src/or/circuitbuild.c

@@ -1763,8 +1763,8 @@ circuit_list_path_impl(origin_circuit_t *circ, int verbose, int verbose_names)
                  circ->build_state->is_internal ? "internal" : "exit",
                  circ->build_state->need_uptime ? " (high-uptime)" : "",
                  circ->build_state->desired_path_len,
-                 circ->_base.state == CIRCUIT_STATE_OPEN ? "" : ", last hop ",
-                 circ->_base.state == CIRCUIT_STATE_OPEN ? "" :
+                 circ->base_.state == CIRCUIT_STATE_OPEN ? "" : ", last hop ",
+                 circ->base_.state == CIRCUIT_STATE_OPEN ? "" :
                  (nickname?nickname:"*unnamed*"));
   }
 
@@ -1927,7 +1927,7 @@ origin_circuit_init(uint8_t purpose, int flags)
     ((flags & CIRCLAUNCH_NEED_CAPACITY) ? 1 : 0);
   circ->build_state->is_internal =
     ((flags & CIRCLAUNCH_IS_INTERNAL) ? 1 : 0);
-  circ->_base.purpose = purpose;
+  circ->base_.purpose = purpose;
   return circ;
 }
 
@@ -1993,7 +1993,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
     log_info(LD_CIRC, "Next router is %s: %s",
              safe_str_client(extend_info_describe(firsthop->extend_info)),
              msg?msg:"???");
-    circ->_base.n_hop = extend_info_dup(firsthop->extend_info);
+    circ->base_.n_hop = extend_info_dup(firsthop->extend_info);
 
     if (should_launch) {
       if (circ->build_state->onehop_tunnel)
@@ -2015,8 +2015,8 @@ circuit_handle_first_hop(origin_circuit_t *circ)
      */
     return 0;
   } else { /* it's already open. use it. */
-    tor_assert(!circ->_base.n_hop);
-    circ->_base.n_chan = n_chan;
+    tor_assert(!circ->base_.n_hop);
+    circ->base_.n_chan = n_chan;
     log_debug(LD_CIRC,"Conn open. Delivering first onion skin.");
     if ((err_reason = circuit_send_next_onion_skin(circ)) < 0) {
       log_info(LD_CIRC,"circuit_send_next_onion_skin failed.");
@@ -2244,7 +2244,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
     else
       control_event_bootstrap(BOOTSTRAP_STATUS_CIRCUIT_CREATE, 0);
 
-    node = node_get_by_id(circ->_base.n_chan->identity_digest);
+    node = node_get_by_id(circ->base_.n_chan->identity_digest);
     fast = should_use_create_fast_for_circuit(circ);
     if (!fast) {
       /* We are an OR and we know the right onion key: we should
@@ -2281,7 +2281,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
              node ? node_describe(node) : "<unnamed>");
   } else {
     tor_assert(circ->cpath->state == CPATH_STATE_OPEN);
-    tor_assert(circ->_base.state == CIRCUIT_STATE_BUILDING);
+    tor_assert(circ->base_.state == CIRCUIT_STATE_BUILDING);
     log_debug(LD_CIRC,"starting to send subsequent skin.");
     hop = onion_next_hop_in_cpath(circ->cpath);
     if (!hop) {
@@ -2291,7 +2291,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
         struct timeval end;
         long timediff;
         tor_gettimeofday(&end);
-        timediff = tv_mdiff(&circ->_base.timestamp_created, &end);
+        timediff = tv_mdiff(&circ->base_.timestamp_created, &end);
 
         /*
          * If the circuit build time is much greater than we would have cut
@@ -2301,8 +2301,8 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
         if (timediff < 0 || timediff > 2*circ_times.close_ms+1000) {
           log_notice(LD_CIRC, "Strange value for circuit build time: %ldmsec. "
                               "Assuming clock jump. Purpose %d (%s)", timediff,
-                     circ->_base.purpose,
-                     circuit_purpose_to_string(circ->_base.purpose));
+                     circ->base_.purpose,
+                     circuit_purpose_to_string(circ->base_.purpose));
         } else if (!circuit_build_times_disabled()) {
           /* Only count circuit times if the network is live */
           if (circuit_build_times_network_check_live(&circ_times)) {
@@ -2310,7 +2310,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
             circuit_build_times_set_timeout(&circ_times);
           }
 
-          if (circ->_base.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
+          if (circ->base_.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
             circuit_build_times_network_circ_success(&circ_times);
           }
         }
@@ -2343,7 +2343,7 @@ circuit_send_next_onion_skin(origin_circuit_t *circ)
       circuit_has_opened(circ); /* do other actions as necessary */
 
       /* We're done with measurement circuits here. Just close them */
-      if (circ->_base.purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)
+      if (circ->base_.purpose == CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT)
         circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
       return 0;
     }
@@ -2679,8 +2679,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
   /* We can't do path bias accounting without entry guards.
    * Testing and controller circuits also have no guards. */
   if (get_options()->UseEntryGuards == 0 ||
-          circ->_base.purpose == CIRCUIT_PURPOSE_TESTING ||
-          circ->_base.purpose == CIRCUIT_PURPOSE_CONTROLLER) {
+          circ->base_.purpose == CIRCUIT_PURPOSE_TESTING ||
+          circ->base_.purpose == CIRCUIT_PURPOSE_CONTROLLER) {
     return 0;
   }
 
@@ -2697,8 +2697,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
                "Circuit is a %s currently %s.%s",
                circ->build_state->desired_path_len,
                pathbias_state_to_string(circ->path_state),
-               circuit_purpose_to_string(circ->_base.purpose),
-               circuit_state_to_string(circ->_base.state),
+               circuit_purpose_to_string(circ->base_.purpose),
+               circuit_state_to_string(circ->base_.state),
                rate_msg);
         tor_free(rate_msg);
       }
@@ -2716,8 +2716,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
                 "Opened circuit is in strange path state %s. "
                 "Circuit is a %s currently %s.%s",
                 pathbias_state_to_string(circ->path_state),
-                circuit_purpose_to_string(circ->_base.purpose),
-                circuit_state_to_string(circ->_base.state),
+                circuit_purpose_to_string(circ->base_.purpose),
+                circuit_state_to_string(circ->base_.state),
                 rate_msg);
         tor_free(rate_msg);
       }
@@ -2728,7 +2728,7 @@ pathbias_count_first_hop(origin_circuit_t *circ)
       entry_guard_t *guard;
 
       guard =
-        entry_guard_get_by_id_digest(circ->_base.n_chan->identity_digest);
+        entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
       if (guard) {
         if (circ->path_state == PATH_STATE_NEW_CIRC) {
           circ->path_state = PATH_STATE_DID_FIRST_HOP;
@@ -2744,8 +2744,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
                    "Unopened circuit has strange path state %s. "
                    "Circuit is a %s currently %s.%s",
                    pathbias_state_to_string(circ->path_state),
-                   circuit_purpose_to_string(circ->_base.purpose),
-                   circuit_state_to_string(circ->_base.state),
+                   circuit_purpose_to_string(circ->base_.purpose),
+                   circuit_state_to_string(circ->base_.state),
                    rate_msg);
             tor_free(rate_msg);
           }
@@ -2756,8 +2756,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
           log_info(LD_BUG,
               "Unopened circuit has no known guard. "
               "Circuit is a %s currently %s.%s",
-              circuit_purpose_to_string(circ->_base.purpose),
-              circuit_state_to_string(circ->_base.state),
+              circuit_purpose_to_string(circ->base_.purpose),
+              circuit_state_to_string(circ->base_.state),
               rate_msg);
           tor_free(rate_msg);
         }
@@ -2773,8 +2773,8 @@ pathbias_count_first_hop(origin_circuit_t *circ)
             "Circuit is a %s currently %s.%s",
             pathbias_state_to_string(circ->path_state),
             circ->cpath->state, circ->has_opened,
-            circuit_purpose_to_string(circ->_base.purpose),
-            circuit_state_to_string(circ->_base.state),
+            circuit_purpose_to_string(circ->base_.purpose),
+            circuit_state_to_string(circ->base_.state),
             rate_msg);
         tor_free(rate_msg);
       }
@@ -2803,8 +2803,8 @@ pathbias_count_success(origin_circuit_t *circ)
   /* We can't do path bias accounting without entry guards.
    * Testing and controller circuits also have no guards. */
   if (get_options()->UseEntryGuards == 0 ||
-          circ->_base.purpose == CIRCUIT_PURPOSE_TESTING ||
-          circ->_base.purpose == CIRCUIT_PURPOSE_CONTROLLER) {
+          circ->base_.purpose == CIRCUIT_PURPOSE_TESTING ||
+          circ->base_.purpose == CIRCUIT_PURPOSE_CONTROLLER) {
     return;
   }
 
@@ -2821,8 +2821,8 @@ pathbias_count_success(origin_circuit_t *circ)
                "Circuit is a %s currently %s.%s",
                circ->build_state->desired_path_len,
                pathbias_state_to_string(circ->path_state),
-               circuit_purpose_to_string(circ->_base.purpose),
-               circuit_state_to_string(circ->_base.state),
+               circuit_purpose_to_string(circ->base_.purpose),
+               circuit_state_to_string(circ->base_.state),
                rate_msg);
         tor_free(rate_msg);
       }
@@ -2834,7 +2834,7 @@ pathbias_count_success(origin_circuit_t *circ)
   /* Don't count cannibalized/reused circs for path bias */
   if (!circ->has_opened) {
     guard =
-      entry_guard_get_by_id_digest(circ->_base.n_chan->identity_digest);
+      entry_guard_get_by_id_digest(circ->base_.n_chan->identity_digest);
 
     if (guard) {
       if (circ->path_state == PATH_STATE_DID_FIRST_HOP) {
@@ -2851,8 +2851,8 @@ pathbias_count_success(origin_circuit_t *circ)
               "Succeeded circuit is in strange path state %s. "
               "Circuit is a %s currently %s.%s",
               pathbias_state_to_string(circ->path_state),
-              circuit_purpose_to_string(circ->_base.purpose),
-              circuit_state_to_string(circ->_base.state),
+              circuit_purpose_to_string(circ->base_.purpose),
+              circuit_state_to_string(circ->base_.state),
               rate_msg);
           tor_free(rate_msg);
         }
@@ -2867,14 +2867,14 @@ pathbias_count_success(origin_circuit_t *circ)
     /* In rare cases, CIRCUIT_PURPOSE_TESTING can get converted to
      * CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT and have no guards here.
      * No need to log that case. */
-    } else if (circ->_base.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
+    } else if (circ->base_.purpose != CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT) {
       if ((rate_msg = rate_limit_log(&success_notice_limit,
               approx_time()))) {
         log_info(LD_BUG,
             "Completed circuit has no known guard. "
             "Circuit is a %s currently %s.%s",
-            circuit_purpose_to_string(circ->_base.purpose),
-            circuit_state_to_string(circ->_base.state),
+            circuit_purpose_to_string(circ->base_.purpose),
+            circuit_state_to_string(circ->base_.state),
             rate_msg);
         tor_free(rate_msg);
       }
@@ -2887,8 +2887,8 @@ pathbias_count_success(origin_circuit_t *circ)
             "Opened circuit is in strange path state %s. "
             "Circuit is a %s currently %s.%s",
             pathbias_state_to_string(circ->path_state),
-            circuit_purpose_to_string(circ->_base.purpose),
-            circuit_state_to_string(circ->_base.state),
+            circuit_purpose_to_string(circ->base_.purpose),
+            circuit_state_to_string(circ->base_.state),
             rate_msg);
         tor_free(rate_msg);
       }
@@ -3331,7 +3331,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
       n_supported[i] = -1;
       continue;
     }
-    if (routerset_contains_node(options->_ExcludeExitNodesUnion, node)) {
+    if (routerset_contains_node(options->ExcludeExitNodesUnion_, node)) {
       n_supported[i] = -1;
       continue; /* user asked us not to use it, no matter what */
     }
@@ -3348,7 +3348,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
                  * we'll retry later in this function with need_update and
                  * need_capacity set to 0. */
     }
-    if (!(node->is_valid || options->_AllowInvalid & ALLOW_INVALID_EXIT)) {
+    if (!(node->is_valid || options->AllowInvalid_ & ALLOW_INVALID_EXIT)) {
       /* if it's invalid and we don't want it */
       n_supported[i] = -1;
 //      log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- invalid router.",
@@ -3434,7 +3434,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
       }
       log_notice(LD_CIRC, "All routers are down or won't exit%s -- "
                  "choosing a doomed exit at random.",
-                 options->_ExcludeExitNodesUnion ? " or are Excluded" : "");
+                 options->ExcludeExitNodesUnion_ ? " or are Excluded" : "");
     }
     supporting = smartlist_new();
     needed_ports = circuit_get_unhandled_ports(time(NULL));
@@ -3473,7 +3473,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
     log_warn(LD_CIRC,
              "No specified %sexit routers seem to be running: "
              "can't choose an exit.",
-             options->_ExcludeExitNodesUnion ? "non-excluded " : "");
+             options->ExcludeExitNodesUnion_ ? "non-excluded " : "");
   }
   return NULL;
 }
@@ -3501,14 +3501,14 @@ choose_good_exit_server(uint8_t purpose,
 
   switch (purpose) {
     case CIRCUIT_PURPOSE_C_GENERAL:
-      if (options->_AllowInvalid & ALLOW_INVALID_MIDDLE)
+      if (options->AllowInvalid_ & ALLOW_INVALID_MIDDLE)
         flags |= CRN_ALLOW_INVALID;
       if (is_internal) /* pick it like a middle hop */
         return router_choose_random_node(NULL, options->ExcludeNodes, flags);
       else
         return choose_good_exit_server_general(need_uptime,need_capacity);
     case CIRCUIT_PURPOSE_C_ESTABLISH_REND:
-      if (options->_AllowInvalid & ALLOW_INVALID_RENDEZVOUS)
+      if (options->AllowInvalid_ & ALLOW_INVALID_RENDEZVOUS)
         flags |= CRN_ALLOW_INVALID;
       return router_choose_random_node(NULL, options->ExcludeNodes, flags);
   }
@@ -3525,7 +3525,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
   const or_options_t *options = get_options();
   routerset_t *rs = options->ExcludeNodes;
   const char *description;
-  uint8_t purpose = circ->_base.purpose;
+  uint8_t purpose = circ->base_.purpose;
 
   if (circ->build_state->onehop_tunnel)
     return;
@@ -3545,7 +3545,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
       if (circ->build_state->is_internal)
         return;
       description = "requested exit node";
-      rs = options->_ExcludeExitNodesUnion;
+      rs = options->ExcludeExitNodesUnion_;
       break;
     case CIRCUIT_PURPOSE_C_INTRODUCING:
     case CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT:
@@ -3562,7 +3562,7 @@ warn_if_last_router_excluded(origin_circuit_t *circ, const extend_info_t *exit)
       description = "chosen rendezvous point";
       break;
     case CIRCUIT_PURPOSE_CONTROLLER:
-      rs = options->_ExcludeExitNodesUnion;
+      rs = options->ExcludeExitNodesUnion_;
       description = "controller-selected circuit target";
       break;
     }
@@ -3604,7 +3604,7 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
     log_debug(LD_CIRC, "Launching a one-hop circuit for dir tunnel.");
     state->desired_path_len = 1;
   } else {
-    int r = new_route_len(circ->_base.purpose, exit, nodelist_get_list());
+    int r = new_route_len(circ->base_.purpose, exit, nodelist_get_list());
     if (r < 1) /* must be at least 1 */
       return -1;
     state->desired_path_len = r;
@@ -3617,7 +3617,7 @@ onion_pick_cpath_exit(origin_circuit_t *circ, extend_info_t *exit)
     exit = extend_info_dup(exit);
   } else { /* we have to decide one */
     const node_t *node =
-      choose_good_exit_server(circ->_base.purpose, state->need_uptime,
+      choose_good_exit_server(circ->base_.purpose, state->need_uptime,
                               state->need_capacity, state->is_internal);
     if (!node) {
       log_warn(LD_CIRC,"failed to choose an exit server");
@@ -3738,8 +3738,8 @@ choose_good_middle_server(uint8_t purpose,
   smartlist_t *excluded;
   const or_options_t *options = get_options();
   router_crn_flags_t flags = CRN_NEED_DESC;
-  tor_assert(_CIRCUIT_PURPOSE_MIN <= purpose &&
-             purpose <= _CIRCUIT_PURPOSE_MAX);
+  tor_assert(CIRCUIT_PURPOSE_MIN_ <= purpose &&
+             purpose <= CIRCUIT_PURPOSE_MAX_);
 
   log_debug(LD_CIRC, "Contemplating intermediate hop: random choice.");
   excluded = smartlist_new();
@@ -3756,7 +3756,7 @@ choose_good_middle_server(uint8_t purpose,
     flags |= CRN_NEED_UPTIME;
   if (state->need_capacity)
     flags |= CRN_NEED_CAPACITY;
-  if (options->_AllowInvalid & ALLOW_INVALID_MIDDLE)
+  if (options->AllowInvalid_ & ALLOW_INVALID_MIDDLE)
     flags |= CRN_ALLOW_INVALID;
   choice = router_choose_random_node(excluded, options->ExcludeNodes, flags);
   smartlist_free(excluded);
@@ -3818,7 +3818,7 @@ choose_good_entry_server(uint8_t purpose, cpath_build_state_t *state)
     if (state->need_capacity)
       flags |= CRN_NEED_CAPACITY;
   }
-  if (options->_AllowInvalid & ALLOW_INVALID_ENTRY)
+  if (options->AllowInvalid_ & ALLOW_INVALID_ENTRY)
     flags |= CRN_ALLOW_INVALID;
 
   choice = router_choose_random_node(excluded, options->ExcludeNodes, flags);
@@ -3846,7 +3846,7 @@ onion_next_hop_in_cpath(crypt_path_t *cpath)
 static int
 onion_extend_cpath(origin_circuit_t *circ)
 {
-  uint8_t purpose = circ->_base.purpose;
+  uint8_t purpose = circ->base_.purpose;
   cpath_build_state_t *state = circ->build_state;
   int cur_len = circuit_get_cpath_len(circ);
   extend_info_t *info = NULL;
@@ -5049,7 +5049,7 @@ entry_guards_parse_state(or_state_t *state, int set, char **msg)
     if (remove_obsolete_entry_guards(now))
       entry_guards_dirty = 1;
   }
-  digestmap_free(added_by, _tor_free);
+  digestmap_free(added_by, tor_free_);
   return *msg ? -1 : 0;
 }
 

+ 2 - 2
src/or/circuitbuild.h

@@ -9,8 +9,8 @@
  * \brief Header file for circuitbuild.c.
  **/
 
-#ifndef _TOR_CIRCUITBUILD_H
-#define _TOR_CIRCUITBUILD_H
+#ifndef TOR_CIRCUITBUILD_H
+#define TOR_CIRCUITBUILD_H
 
 char *circuit_list_path(origin_circuit_t *circ, int verbose);
 char *circuit_list_path_for_controller(origin_circuit_t *circ);

+ 23 - 23
src/or/circuitlist.c

@@ -58,7 +58,7 @@ typedef struct chan_circid_circuit_map_t {
  * b, and return less than, equal to, or greater than zero appropriately.
  */
 static INLINE int
-_chan_circid_entries_eq(chan_circid_circuit_map_t *a,
+chan_circid_entries_eq_(chan_circid_circuit_map_t *a,
                         chan_circid_circuit_map_t *b)
 {
   return a->chan == b->chan && a->circ_id == b->circ_id;
@@ -67,7 +67,7 @@ _chan_circid_entries_eq(chan_circid_circuit_map_t *a,
 /** Helper: return a hash based on circuit ID and the pointer value of
  * chan in <b>a</b>. */
 static INLINE unsigned int
-_chan_circid_entry_hash(chan_circid_circuit_map_t *a)
+chan_circid_entry_hash_(chan_circid_circuit_map_t *a)
 {
   return (((unsigned)a->circ_id)<<8) ^ (unsigned)(uintptr_t)(a->chan);
 }
@@ -76,9 +76,9 @@ _chan_circid_entry_hash(chan_circid_circuit_map_t *a)
 static HT_HEAD(chan_circid_map, chan_circid_circuit_map_t)
      chan_circid_map = HT_INITIALIZER();
 HT_PROTOTYPE(chan_circid_map, chan_circid_circuit_map_t, node,
-             _chan_circid_entry_hash, _chan_circid_entries_eq)
+             chan_circid_entry_hash_, chan_circid_entries_eq_)
 HT_GENERATE(chan_circid_map, chan_circid_circuit_map_t, node,
-            _chan_circid_entry_hash, _chan_circid_entries_eq, 0.6,
+            chan_circid_entry_hash_, chan_circid_entries_eq_, 0.6,
             malloc, realloc, free)
 
 /** The most recently returned entry from circuit_get_by_circid_chan;
@@ -350,7 +350,7 @@ circuit_close_all_marked(void)
 
 /** Return the head of the global linked list of circuits. */
 circuit_t *
-_circuit_get_global_list(void)
+circuit_get_global_list_(void)
 {
   return global_circuitlist;
 }
@@ -572,7 +572,7 @@ origin_circuit_new(void)
   static uint32_t n_circuits_allocated = 1;
 
   circ = tor_malloc_zero(sizeof(origin_circuit_t));
-  circ->_base.magic = ORIGIN_CIRCUIT_MAGIC;
+  circ->base_.magic = ORIGIN_CIRCUIT_MAGIC;
 
   circ->next_stream_id = crypto_rand_int(1<<16);
   circ->global_identifier = n_circuits_allocated++;
@@ -595,7 +595,7 @@ or_circuit_new(circid_t p_circ_id, channel_t *p_chan)
   or_circuit_t *circ;
 
   circ = tor_malloc_zero(sizeof(or_circuit_t));
-  circ->_base.magic = OR_CIRCUIT_MAGIC;
+  circ->base_.magic = OR_CIRCUIT_MAGIC;
 
   if (p_chan)
     circuit_set_p_circid_chan(circ, p_circ_id, p_chan);
@@ -659,7 +659,7 @@ circuit_free(circuit_t *circ)
 
     if (ocirc->rend_splice) {
       or_circuit_t *other = ocirc->rend_splice;
-      tor_assert(other->_base.magic == OR_CIRCUIT_MAGIC);
+      tor_assert(other->base_.magic == OR_CIRCUIT_MAGIC);
       other->rend_splice = NULL;
     }
 
@@ -1162,7 +1162,7 @@ origin_circuit_t *
 circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
                             int flags)
 {
-  circuit_t *_circ;
+  circuit_t *circ_;
   origin_circuit_t *best=NULL;
   int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
   int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
@@ -1178,13 +1178,13 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
             "capacity %d, internal %d",
             purpose, need_uptime, need_capacity, internal);
 
-  for (_circ=global_circuitlist; _circ; _circ = _circ->next) {
-    if (CIRCUIT_IS_ORIGIN(_circ) &&
-        _circ->state == CIRCUIT_STATE_OPEN &&
-        !_circ->marked_for_close &&
-        _circ->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
-        !_circ->timestamp_dirty) {
-      origin_circuit_t *circ = TO_ORIGIN_CIRCUIT(_circ);
+  for (circ_=global_circuitlist; circ_; circ_ = circ_->next) {
+    if (CIRCUIT_IS_ORIGIN(circ_) &&
+        circ_->state == CIRCUIT_STATE_OPEN &&
+        !circ_->marked_for_close &&
+        circ_->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
+        !circ_->timestamp_dirty) {
+      origin_circuit_t *circ = TO_ORIGIN_CIRCUIT(circ_);
       if ((!need_uptime || circ->build_state->need_uptime) &&
           (!need_capacity || circ->build_state->need_capacity) &&
           (internal == circ->build_state->is_internal) &&
@@ -1318,7 +1318,7 @@ circuit_expire_all_dirty_circs(void)
  *     rendezvous stream), then mark the other circuit to close as well.
  */
 void
-_circuit_mark_for_close(circuit_t *circ, int reason, int line,
+circuit_mark_for_close_(circuit_t *circ, int reason, int line,
                         const char *file)
 {
   int orig_reason = reason; /* Passed to the controller */
@@ -1349,7 +1349,7 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line,
   if (reason & END_CIRC_REASON_FLAG_REMOTE)
     reason &= ~END_CIRC_REASON_FLAG_REMOTE;
 
-  if (reason < _END_CIRC_REASON_MIN || reason > _END_CIRC_REASON_MAX) {
+  if (reason < END_CIRC_REASON_MIN_ || reason > END_CIRC_REASON_MAX_) {
     if (!(orig_reason & END_CIRC_REASON_FLAG_REMOTE))
       log_warn(LD_BUG, "Reason %d out of range at %s:%d", reason, file, line);
     reason = END_CIRC_REASON_NONE;
@@ -1424,7 +1424,7 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line,
     while (or_circ->resolving_streams) {
       conn = or_circ->resolving_streams;
       or_circ->resolving_streams = conn->next_stream;
-      if (!conn->_base.marked_for_close) {
+      if (!conn->base_.marked_for_close) {
         /* The client will see a DESTROY, and infer that the connections
          * are closing because the circuit is getting torn down.  No need
          * to send an end cell. */
@@ -1455,7 +1455,7 @@ _circuit_mark_for_close(circuit_t *circ, int reason, int line,
   if (!CIRCUIT_IS_ORIGIN(circ)) {
     or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
     if (or_circ->rend_splice) {
-      if (!or_circ->rend_splice->_base.marked_for_close) {
+      if (!or_circ->rend_splice->base_.marked_for_close) {
         /* do this after marking this circuit, to avoid infinite recursion. */
         circuit_mark_for_close(TO_CIRCUIT(or_circ->rend_splice), reason);
       }
@@ -1529,8 +1529,8 @@ assert_circuit_ok(const circuit_t *c)
 
   tor_assert(c);
   tor_assert(c->magic == ORIGIN_CIRCUIT_MAGIC || c->magic == OR_CIRCUIT_MAGIC);
-  tor_assert(c->purpose >= _CIRCUIT_PURPOSE_MIN &&
-             c->purpose <= _CIRCUIT_PURPOSE_MAX);
+  tor_assert(c->purpose >= CIRCUIT_PURPOSE_MIN_ &&
+             c->purpose <= CIRCUIT_PURPOSE_MAX_);
 
   {
     /* Having a separate variable for this pleases GCC 4.2 in ways I hope I
@@ -1563,7 +1563,7 @@ assert_circuit_ok(const circuit_t *c)
   }
   if (or_circ)
     for (conn = or_circ->n_streams; conn; conn = conn->next_stream)
-      tor_assert(conn->_base.type == CONN_TYPE_EXIT);
+      tor_assert(conn->base_.type == CONN_TYPE_EXIT);
 
   tor_assert(c->deliver_window >= 0);
   tor_assert(c->package_window >= 0);

+ 5 - 5
src/or/circuitlist.h

@@ -9,10 +9,10 @@
  * \brief Header file for circuitlist.c.
  **/
 
-#ifndef _TOR_CIRCUITLIST_H
-#define _TOR_CIRCUITLIST_H
+#ifndef TOR_CIRCUITLIST_H
+#define TOR_CIRCUITLIST_H
 
-circuit_t * _circuit_get_global_list(void);
+circuit_t * circuit_get_global_list_(void);
 const char *circuit_state_to_string(int state);
 const char *circuit_purpose_to_controller_string(uint8_t purpose);
 const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);
@@ -47,7 +47,7 @@ origin_circuit_t *circuit_find_to_cannibalize(uint8_t purpose,
                                               extend_info_t *info, int flags);
 void circuit_mark_all_unused_circs(void);
 void circuit_expire_all_dirty_circs(void);
-void _circuit_mark_for_close(circuit_t *circ, int reason,
+void circuit_mark_for_close_(circuit_t *circ, int reason,
                              int line, const char *file);
 int circuit_get_cpath_len(origin_circuit_t *circ);
 crypt_path_t *circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum);
@@ -56,7 +56,7 @@ void circuit_get_all_pending_on_channel(smartlist_t *out,
 int circuit_count_pending_on_channel(channel_t *chan);
 
 #define circuit_mark_for_close(c, reason)                               \
-  _circuit_mark_for_close((c), (reason), __LINE__, _SHORT_FILE_)
+  circuit_mark_for_close_((c), (reason), __LINE__, SHORT_FILE__)
 
 void assert_cpath_layer_ok(const crypt_path_t *cp);
 void assert_circuit_ok(const circuit_t *c);

+ 5 - 5
src/or/circuitmux.h

@@ -6,8 +6,8 @@
  * \brief Header file for circuitmux.c
  **/
 
-#ifndef _TOR_CIRCUITMUX_H
-#define _TOR_CIRCUITMUX_H
+#ifndef TOR_CIRCUITMUX_H
+#define TOR_CIRCUITMUX_H
 
 #include "or.h"
 
@@ -84,14 +84,14 @@ struct circuitmux_policy_circ_data_s {
  * Convert a circuitmux_policy_data_t subtype to a circuitmux_policy_data_t.
  */
 
-#define TO_CMUX_POL_DATA(x)  (&((x)->_base))
+#define TO_CMUX_POL_DATA(x)  (&((x)->base_))
 
 /**
  * Convert a circuitmux_policy_circ_data_t subtype to a
  * circuitmux_policy_circ_data_t.
  */
 
-#define TO_CMUX_POL_CIRC_DATA(x)  (&((x)->_base))
+#define TO_CMUX_POL_CIRC_DATA(x)  (&((x)->base_))
 
 /* Consistency check */
 void circuitmux_assert_okay(circuitmux_t *cmux);
@@ -132,5 +132,5 @@ void circuitmux_clear_num_cells(circuitmux_t *cmux, circuit_t *circ);
 void circuitmux_set_num_cells(circuitmux_t *cmux, circuit_t *circ,
                               unsigned int n_cells);
 
-#endif /* _TOR_CIRCUITMUX_H */
+#endif /* TOR_CIRCUITMUX_H */
 

+ 5 - 5
src/or/circuitmux_ewma.c

@@ -6,7 +6,7 @@
  * \brief EWMA circuit selection as a circuitmux_t policy
  **/
 
-#define _TOR_CIRCUITMUX_EWMA_C
+#define TOR_CIRCUITMUX_EWMA_C_
 
 #include <math.h>
 
@@ -62,7 +62,7 @@ struct cell_ewma_s {
 };
 
 struct ewma_policy_data_s {
-  circuitmux_policy_data_t _base;
+  circuitmux_policy_data_t base_;
 
   /**
    * Priority queue of cell_ewma_t for circuits with queued cells waiting
@@ -81,7 +81,7 @@ struct ewma_policy_data_s {
 };
 
 struct ewma_policy_circ_data_s {
-  circuitmux_policy_circ_data_t _base;
+  circuitmux_policy_circ_data_t base_;
 
   /**
    * The EWMA count for the number of cells flushed from this circuit
@@ -226,7 +226,7 @@ ewma_alloc_cmux_data(circuitmux_t *cmux)
   tor_assert(cmux);
 
   pol = tor_malloc_zero(sizeof(*pol));
-  pol->_base.magic = EWMA_POL_DATA_MAGIC;
+  pol->base_.magic = EWMA_POL_DATA_MAGIC;
   pol->active_circuit_pqueue = smartlist_new();
   pol->active_circuit_pqueue_last_recalibrated = cell_ewma_get_tick();
 
@@ -276,7 +276,7 @@ ewma_alloc_circ_data(circuitmux_t *cmux,
   tor_assert(cell_count == cell_count);
 
   cdata = tor_malloc_zero(sizeof(*cdata));
-  cdata->_base.magic = EWMA_POL_CIRC_DATA_MAGIC;
+  cdata->base_.magic = EWMA_POL_CIRC_DATA_MAGIC;
   cdata->circ = circ;
 
   /*

+ 5 - 5
src/or/circuitmux_ewma.h

@@ -6,18 +6,18 @@
  * \brief Header file for circuitmux_ewma.c
  **/
 
-#ifndef _TOR_CIRCUITMUX_EWMA_H
-#define _TOR_CIRCUITMUX_EWMA_H
+#ifndef TOR_CIRCUITMUX_EWMA_H
+#define TOR_CIRCUITMUX_EWMA_H
 
 #include "or.h"
 #include "circuitmux.h"
 
 /* Everything but circuitmux_ewma.c should see this extern */
-#ifndef _TOR_CIRCUITMUX_EWMA_C
+#ifndef TOR_CIRCUITMUX_EWMA_C_
 
 extern circuitmux_policy_t ewma_policy;
 
-#endif /* !(_TOR_CIRCUITMUX_EWMA_C) */
+#endif /* !(TOR_CIRCUITMUX_EWMA_C_) */
 
 /* Externally visible EWMA functions */
 int cell_ewma_enabled(void);
@@ -25,5 +25,5 @@ unsigned int cell_ewma_get_tick(void);
 void cell_ewma_set_scale_factor(const or_options_t *options,
                                 const networkstatus_t *consensus);
 
-#endif /* _TOR_CIRCUITMUX_EWMA_H */
+#endif /* TOR_CIRCUITMUX_EWMA_H */
 

+ 32 - 32
src/or/circuituse.c

@@ -809,7 +809,7 @@ circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
   tor_assert(circ);
   tor_assert(conn);
 
-  if (conn->_base.type == CONN_TYPE_AP) {
+  if (conn->base_.type == CONN_TYPE_AP) {
     entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
     entry_conn->may_use_optimistic_data = 0;
   }
@@ -1126,7 +1126,7 @@ static int
 circuit_try_clearing_isolation_state(origin_circuit_t *circ)
 {
   if (/* The circuit may have become non-open if it was cannibalized.*/
-      circ->_base.state == CIRCUIT_STATE_OPEN &&
+      circ->base_.state == CIRCUIT_STATE_OPEN &&
       /* If !isolation_values_set, there is nothing to clear. */
       circ->isolation_values_set &&
       /* It's not legal to clear a circuit's isolation info if it's ever had
@@ -1183,8 +1183,8 @@ circuit_build_failed(origin_circuit_t *circ)
      * fail any one-hop directory fetches destined for it. */
     const char *n_chan_id = circ->cpath->extend_info->identity_digest;
     int already_marked = 0;
-    if (circ->_base.n_chan) {
-      n_chan = circ->_base.n_chan;
+    if (circ->base_.n_chan) {
+      n_chan = circ->base_.n_chan;
 
       if (n_chan->is_bad_for_new_circs) {
         /* We only want to blame this router when a fresh healthy
@@ -1213,7 +1213,7 @@ circuit_build_failed(origin_circuit_t *circ)
     }
   }
 
-  switch (circ->_base.purpose) {
+  switch (circ->base_.purpose) {
     case CIRCUIT_PURPOSE_C_GENERAL:
       /* If we never built the circuit, note it as a failure. */
       circuit_increment_failure_count();
@@ -1228,7 +1228,7 @@ circuit_build_failed(origin_circuit_t *circ)
       break;
     case CIRCUIT_PURPOSE_S_ESTABLISH_INTRO:
       /* at Bob, waiting for introductions */
-      if (circ->_base.state != CIRCUIT_STATE_OPEN) {
+      if (circ->base_.state != CIRCUIT_STATE_OPEN) {
         circuit_increment_failure_count();
       }
       /* no need to care here, because bob will rebuild intro
@@ -1312,7 +1312,7 @@ circuit_launch_by_extend_info(uint8_t purpose,
      * internal circs rather than exit circs? -RD */
     circ = circuit_find_to_cannibalize(purpose, extend_info, flags);
     if (circ) {
-      uint8_t old_purpose = circ->_base.purpose;
+      uint8_t old_purpose = circ->base_.purpose;
       struct timeval old_timestamp_created;
 
       log_info(LD_CIRC,"Cannibalizing circ '%s' for purpose %d (%s)",
@@ -1323,7 +1323,7 @@ circuit_launch_by_extend_info(uint8_t purpose,
       /* reset the birth date of this circ, else expire_building
        * will see it and think it's been trying to build since it
        * began. */
-      tor_gettimeofday(&circ->_base.timestamp_created);
+      tor_gettimeofday(&circ->base_.timestamp_created);
 
       control_event_circuit_cannibalized(circ, old_purpose,
                                          &old_timestamp_created);
@@ -1637,8 +1637,8 @@ circuit_get_open_circ_or_launch(entry_connection_t *conn,
       if (circ) {
         /* write the service_id into circ */
         circ->rend_data = rend_data_dup(ENTRY_TO_EDGE_CONN(conn)->rend_data);
-        if (circ->_base.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND &&
-            circ->_base.state == CIRCUIT_STATE_OPEN)
+        if (circ->base_.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND &&
+            circ->base_.state == CIRCUIT_STATE_OPEN)
           rend_client_rendcirc_has_opened(circ);
       }
     }
@@ -1701,7 +1701,7 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
 
   /* add it into the linked list of streams on this circuit */
   log_debug(LD_APP|LD_CIRC, "attaching new conn to circ. n_circ_id %d.",
-            circ->_base.n_circ_id);
+            circ->base_.n_circ_id);
   /* reset it, so we can measure circ timeouts */
   ENTRY_TO_CONN(apconn)->timestamp_lastread = time(NULL);
   ENTRY_TO_EDGE_CONN(apconn)->next_stream = circ->p_streams;
@@ -1737,7 +1737,7 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
       exitnode->rs) {
     /* Okay; we know what exit node this is. */
     if (optimistic_data_enabled() &&
-        circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL &&
+        circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL &&
         exitnode->rs->version_supports_optimistic_data)
       apconn->may_use_optimistic_data = 1;
     else
@@ -1823,12 +1823,12 @@ connection_ap_handshake_attach_chosen_circuit(entry_connection_t *conn,
              base_conn->state == AP_CONN_STATE_CONTROLLER_WAIT);
   tor_assert(conn->socks_request);
   tor_assert(circ);
-  tor_assert(circ->_base.state == CIRCUIT_STATE_OPEN);
+  tor_assert(circ->base_.state == CIRCUIT_STATE_OPEN);
 
   base_conn->state = AP_CONN_STATE_CIRCUIT_WAIT;
 
-  if (!circ->_base.timestamp_dirty)
-    circ->_base.timestamp_dirty = time(NULL);
+  if (!circ->base_.timestamp_dirty)
+    circ->base_.timestamp_dirty = time(NULL);
 
   link_apconn_to_circ(conn, circ, cpath);
   tor_assert(conn->socks_request);
@@ -1924,7 +1924,7 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
 
     log_debug(LD_APP|LD_CIRC,
               "Attaching apconn to circ %d (stream %d sec old).",
-              circ->_base.n_circ_id, conn_age);
+              circ->base_.n_circ_id, conn_age);
     /* print the circ's path, so people can figure out which circs are
      * sucking. */
     circuit_log_path(LOG_INFO,LD_APP|LD_CIRC,circ);
@@ -1949,25 +1949,25 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
       log_info(LD_REND,
                "rend joined circ %d already here. attaching. "
                "(stream %d sec old)",
-               rendcirc->_base.n_circ_id, conn_age);
+               rendcirc->base_.n_circ_id, conn_age);
       /* Mark rendezvous circuits as 'newly dirty' every time you use
        * them, since the process of rebuilding a rendezvous circ is so
        * expensive. There is a tradeoff between linkability and
        * feasibility, at this point.
        */
-      rendcirc->_base.timestamp_dirty = time(NULL);
+      rendcirc->base_.timestamp_dirty = time(NULL);
       link_apconn_to_circ(conn, rendcirc, NULL);
       if (connection_ap_handshake_send_begin(conn) < 0)
         return 0; /* already marked, let them fade away */
       return 1;
     }
 
-    if (rendcirc && (rendcirc->_base.purpose ==
+    if (rendcirc && (rendcirc->base_.purpose ==
                      CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)) {
       log_info(LD_REND,
                "pending-join circ %d already here, with intro ack. "
                "Stalling. (stream %d sec old)",
-                rendcirc->_base.n_circ_id, conn_age);
+                rendcirc->base_.n_circ_id, conn_age);
       return 0;
     }
 
@@ -1982,8 +1982,8 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
       tor_assert(introcirc);
       log_info(LD_REND, "Intro circ %d present and awaiting ack (rend %d). "
                "Stalling. (stream %d sec old)",
-               introcirc->_base.n_circ_id,
-               rendcirc ? rendcirc->_base.n_circ_id : 0,
+               introcirc->base_.n_circ_id,
+               rendcirc ? rendcirc->base_.n_circ_id : 0,
                conn_age);
       /* abort parallel intro circs, if any */
       for (c = global_circuitlist; c; c = c->next) {
@@ -2006,23 +2006,23 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
     /* now rendcirc and introcirc are each either undefined or not finished */
 
     if (rendcirc && introcirc &&
-        rendcirc->_base.purpose == CIRCUIT_PURPOSE_C_REND_READY) {
+        rendcirc->base_.purpose == CIRCUIT_PURPOSE_C_REND_READY) {
       log_info(LD_REND,
                "ready rend circ %d already here (no intro-ack yet on "
                "intro %d). (stream %d sec old)",
-               rendcirc->_base.n_circ_id,
-               introcirc->_base.n_circ_id, conn_age);
+               rendcirc->base_.n_circ_id,
+               introcirc->base_.n_circ_id, conn_age);
 
-      tor_assert(introcirc->_base.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
-      if (introcirc->_base.state == CIRCUIT_STATE_OPEN) {
+      tor_assert(introcirc->base_.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
+      if (introcirc->base_.state == CIRCUIT_STATE_OPEN) {
         log_info(LD_REND,"found open intro circ %d (rend %d); sending "
                  "introduction. (stream %d sec old)",
-                 introcirc->_base.n_circ_id, rendcirc->_base.n_circ_id,
+                 introcirc->base_.n_circ_id, rendcirc->base_.n_circ_id,
                  conn_age);
         switch (rend_client_send_introduction(introcirc, rendcirc)) {
         case 0: /* success */
-          rendcirc->_base.timestamp_dirty = time(NULL);
-          introcirc->_base.timestamp_dirty = time(NULL);
+          rendcirc->base_.timestamp_dirty = time(NULL);
+          introcirc->base_.timestamp_dirty = time(NULL);
           assert_circuit_ok(TO_CIRCUIT(rendcirc));
           assert_circuit_ok(TO_CIRCUIT(introcirc));
           return 0;
@@ -2039,8 +2039,8 @@ connection_ap_handshake_attach_circuit(entry_connection_t *conn)
 
     log_info(LD_REND, "Intro (%d) and rend (%d) circs are not both ready. "
              "Stalling conn. (%d sec old)",
-             introcirc ? introcirc->_base.n_circ_id : 0,
-             rendcirc ? rendcirc->_base.n_circ_id : 0, conn_age);
+             introcirc ? introcirc->base_.n_circ_id : 0,
+             rendcirc ? rendcirc->base_.n_circ_id : 0, conn_age);
     return 0;
   }
 }

+ 2 - 2
src/or/circuituse.h

@@ -9,8 +9,8 @@
  * \brief Header file for circuituse.c.
  **/
 
-#ifndef _TOR_CIRCUITUSE_H
-#define _TOR_CIRCUITUSE_H
+#ifndef TOR_CIRCUITUSE_H
+#define TOR_CIRCUITUSE_H
 
 void circuit_expire_building(void);
 void circuit_remove_handled_ports(smartlist_t *needed_ports);

+ 1 - 1
src/or/command.c

@@ -250,7 +250,7 @@ command_process_create_cell(cell_t *cell, channel_t *chan)
   }
 
   circ = or_circuit_new(cell->circ_id, chan);
-  circ->_base.purpose = CIRCUIT_PURPOSE_OR;
+  circ->base_.purpose = CIRCUIT_PURPOSE_OR;
   circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_ONIONSKIN_PENDING);
   if (cell->command == CELL_CREATE) {
     char *onionskin = tor_malloc(ONIONSKIN_CHALLENGE_LEN);

+ 2 - 2
src/or/command.h

@@ -9,8 +9,8 @@
  * \brief Header file for command.c.
  **/
 
-#ifndef _TOR_COMMAND_H
-#define _TOR_COMMAND_H
+#ifndef TOR_COMMAND_H
+#define TOR_COMMAND_H
 
 #include "channel.h"
 

+ 59 - 59
src/or/config.c

@@ -54,7 +54,7 @@ extern int quiet_level;
 
 /** A list of abbreviations and aliases to map command-line options, obsolete
  * option names, or alternative option names, to their current values. */
-static config_abbrev_t _option_abbrevs[] = {
+static config_abbrev_t option_abbrevs_[] = {
   PLURAL(AuthDirBadDirCC),
   PLURAL(AuthDirBadExitCC),
   PLURAL(AuthDirInvalidCC),
@@ -119,7 +119,7 @@ static config_abbrev_t _option_abbrevs[] = {
  * abbreviations, order is significant, since the first matching option will
  * be chosen first.
  */
-static config_var_t _option_vars[] = {
+static config_var_t option_vars_[] = {
   OBSOLETE("AccountingMaxKB"),
   V(AccountingMax,               MEMUNIT,  "0 bytes"),
   V(AccountingStart,             STRING,   NULL),
@@ -403,7 +403,7 @@ static config_var_t _option_vars[] = {
   VAR("__OwningControllerProcess",STRING,OwningControllerProcess, NULL),
   V(MinUptimeHidServDirectoryV2, INTERVAL, "25 hours"),
   V(VoteOnHidServDirectoriesV2,  BOOL,     "1"),
-  VAR("___UsingTestNetworkDefaults", BOOL, _UsingTestNetworkDefaults, "0"),
+  VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "0"),
 
   { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
 };
@@ -431,7 +431,7 @@ static const config_var_t testing_tor_network_defaults[] = {
   V(TestingAuthDirTimeToLearnReachability, INTERVAL, "0 minutes"),
   V(TestingEstimatedDescriptorPropagationTime, INTERVAL, "0 minutes"),
   V(MinUptimeHidServDirectoryV2, INTERVAL, "0 minutes"),
-  VAR("___UsingTestNetworkDefaults", BOOL, _UsingTestNetworkDefaults, "1"),
+  VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "1"),
 
   { NULL, CONFIG_TYPE_OBSOLETE, 0, NULL }
 };
@@ -487,9 +487,9 @@ static int parse_outbound_addresses(or_options_t *options, int validate_only,
 static config_format_t options_format = {
   sizeof(or_options_t),
   OR_OPTIONS_MAGIC,
-  STRUCT_OFFSET(or_options_t, _magic),
-  _option_abbrevs,
-  _option_vars,
+  STRUCT_OFFSET(or_options_t, magic_),
+  option_abbrevs_,
+  option_vars_,
   (validate_fn_t)options_validate,
   NULL
 };
@@ -642,13 +642,13 @@ or_options_free(or_options_t *options)
   if (!options)
     return;
 
-  routerset_free(options->_ExcludeExitNodesUnion);
+  routerset_free(options->ExcludeExitNodesUnion_);
   if (options->NodeFamilySets) {
     SMARTLIST_FOREACH(options->NodeFamilySets, routerset_t *,
                       rs, routerset_free(rs));
     smartlist_free(options->NodeFamilySets);
   }
-  tor_free(options->_BridgePassword_AuthDigest);
+  tor_free(options->BridgePassword_AuthDigest_);
   config_free(&options_format, options);
 }
 
@@ -691,7 +691,7 @@ const char *
 safe_str_client(const char *address)
 {
   tor_assert(address);
-  if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
+  if (get_options()->SafeLogging_ == SAFELOG_SCRUB_ALL)
     return "[scrubbed]";
   else
     return address;
@@ -708,7 +708,7 @@ const char *
 safe_str(const char *address)
 {
   tor_assert(address);
-  if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
+  if (get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE)
     return "[scrubbed]";
   else
     return address;
@@ -720,7 +720,7 @@ safe_str(const char *address)
 const char *
 escaped_safe_str_client(const char *address)
 {
-  if (get_options()->_SafeLogging == SAFELOG_SCRUB_ALL)
+  if (get_options()->SafeLogging_ == SAFELOG_SCRUB_ALL)
     return "[scrubbed]";
   else
     return escaped(address);
@@ -732,7 +732,7 @@ escaped_safe_str_client(const char *address)
 const char *
 escaped_safe_str(const char *address)
 {
-  if (get_options()->_SafeLogging != SAFELOG_SCRUB_NONE)
+  if (get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE)
     return "[scrubbed]";
   else
     return escaped(address);
@@ -929,7 +929,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
     int n_ports=0;
     /* We need to set the connection limit before we can open the listeners. */
     if (set_max_file_descriptors((unsigned)options->ConnLimit,
-                                 &options->_ConnLimit) < 0) {
+                                 &options->ConnLimit_) < 0) {
       *msg = tor_strdup("Problem with ConnLimit value. See logs for details.");
       goto rollback;
     }
@@ -1070,7 +1070,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
 
   if (set_conn_limit && old_options)
     set_max_file_descriptors((unsigned)old_options->ConnLimit,
-                             &options->_ConnLimit);
+                             &options->ConnLimit_);
 
   SMARTLIST_FOREACH(new_listeners, connection_t *, conn,
   {
@@ -1403,8 +1403,8 @@ options_act(const or_options_t *old_options)
                "BridgePassword.");
       return -1;
     }
-    options->_BridgePassword_AuthDigest = tor_malloc(DIGEST256_LEN);
-    crypto_digest256(options->_BridgePassword_AuthDigest,
+    options->BridgePassword_AuthDigest_ = tor_malloc(DIGEST256_LEN);
+    crypto_digest256(options->BridgePassword_AuthDigest_,
                      http_authenticator, strlen(http_authenticator),
                      DIGEST_SHA256);
     tor_free(http_authenticator);
@@ -1819,8 +1819,8 @@ list_torrc_options(void)
 {
   int i;
   smartlist_t *lines = smartlist_new();
-  for (i = 0; _option_vars[i].name; ++i) {
-    const config_var_t *var = &_option_vars[i];
+  for (i = 0; option_vars_[i].name; ++i) {
+    const config_var_t *var = &option_vars_[i];
     if (var->type == CONFIG_TYPE_OBSOLETE ||
         var->type == CONFIG_TYPE_LINELIST_V)
       continue;
@@ -2085,16 +2085,16 @@ ensure_bandwidth_cap(uint64_t *value, const char *desc, char **msg)
 }
 
 /** Parse an authority type from <b>options</b>-\>PublishServerDescriptor
- * and write it to <b>options</b>-\>_PublishServerDescriptor. Treat "1"
+ * and write it to <b>options</b>-\>PublishServerDescriptor_. Treat "1"
  * as "v2,v3" unless BridgeRelay is 1, in which case treat it as "bridge".
  * Treat "0" as "".
  * Return 0 on success or -1 if not a recognized authority type (in which
- * case the value of _PublishServerDescriptor is undefined). */
+ * case the value of PublishServerDescriptor_ is undefined). */
 static int
 compute_publishserverdescriptor(or_options_t *options)
 {
   smartlist_t *list = options->PublishServerDescriptor;
-  dirinfo_type_t *auth = &options->_PublishServerDescriptor;
+  dirinfo_type_t *auth = &options->PublishServerDescriptor_;
   *auth = NO_DIRINFO;
   if (!list) /* empty list, answer is none */
     return 0;
@@ -2257,9 +2257,9 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->ExcludeExitNodes || options->ExcludeNodes) {
-    options->_ExcludeExitNodesUnion = routerset_new();
-    routerset_union(options->_ExcludeExitNodesUnion,options->ExcludeExitNodes);
-    routerset_union(options->_ExcludeExitNodesUnion,options->ExcludeNodes);
+    options->ExcludeExitNodesUnion_ = routerset_new();
+    routerset_union(options->ExcludeExitNodesUnion_,options->ExcludeExitNodes);
+    routerset_union(options->ExcludeExitNodesUnion_,options->ExcludeNodes);
   }
 
   if (options->NodeFamilies) {
@@ -2458,19 +2458,19 @@ options_validate(or_options_t *old_options, or_options_t *options,
     log_warn(LD_CONFIG, "EntryNodes is set, but UseEntryGuards is disabled. "
              "EntryNodes will be ignored.");
 
-  options->_AllowInvalid = 0;
+  options->AllowInvalid_ = 0;
   if (options->AllowInvalidNodes) {
     SMARTLIST_FOREACH_BEGIN(options->AllowInvalidNodes, const char *, cp) {
         if (!strcasecmp(cp, "entry"))
-          options->_AllowInvalid |= ALLOW_INVALID_ENTRY;
+          options->AllowInvalid_ |= ALLOW_INVALID_ENTRY;
         else if (!strcasecmp(cp, "exit"))
-          options->_AllowInvalid |= ALLOW_INVALID_EXIT;
+          options->AllowInvalid_ |= ALLOW_INVALID_EXIT;
         else if (!strcasecmp(cp, "middle"))
-          options->_AllowInvalid |= ALLOW_INVALID_MIDDLE;
+          options->AllowInvalid_ |= ALLOW_INVALID_MIDDLE;
         else if (!strcasecmp(cp, "introduction"))
-          options->_AllowInvalid |= ALLOW_INVALID_INTRODUCTION;
+          options->AllowInvalid_ |= ALLOW_INVALID_INTRODUCTION;
         else if (!strcasecmp(cp, "rendezvous"))
-          options->_AllowInvalid |= ALLOW_INVALID_RENDEZVOUS;
+          options->AllowInvalid_ |= ALLOW_INVALID_RENDEZVOUS;
         else {
           tor_asprintf(msg,
               "Unrecognized value '%s' in AllowInvalidNodes", cp);
@@ -2481,11 +2481,11 @@ options_validate(or_options_t *old_options, or_options_t *options,
 
   if (!options->SafeLogging ||
       !strcasecmp(options->SafeLogging, "0")) {
-    options->_SafeLogging = SAFELOG_SCRUB_NONE;
+    options->SafeLogging_ = SAFELOG_SCRUB_NONE;
   } else if (!strcasecmp(options->SafeLogging, "relay")) {
-    options->_SafeLogging = SAFELOG_SCRUB_RELAY;
+    options->SafeLogging_ = SAFELOG_SCRUB_RELAY;
   } else if (!strcasecmp(options->SafeLogging, "1")) {
-    options->_SafeLogging = SAFELOG_SCRUB_ALL;
+    options->SafeLogging_ = SAFELOG_SCRUB_ALL;
   } else {
     tor_asprintf(msg,
                      "Unrecognized value '%s' in SafeLogging",
@@ -2499,8 +2499,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if ((options->BridgeRelay
-        || options->_PublishServerDescriptor & BRIDGE_DIRINFO)
-      && (options->_PublishServerDescriptor
+        || options->PublishServerDescriptor_ & BRIDGE_DIRINFO)
+      && (options->PublishServerDescriptor_
           & (V1_DIRINFO|V2_DIRINFO|V3_DIRINFO))) {
     REJECT("Bridges are not supposed to publish router descriptors to the "
            "directory authorities. Please correct your "
@@ -2971,7 +2971,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
   /* Keep changes to hard-coded values synchronous to man page and default
    * values table. */
   if (options->TestingV3AuthInitialVotingInterval != 30*60 &&
-      !options->TestingTorNetwork && !options->_UsingTestNetworkDefaults) {
+      !options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
     REJECT("TestingV3AuthInitialVotingInterval may only be changed in testing "
            "Tor networks!");
   } else if (options->TestingV3AuthInitialVotingInterval < MIN_VOTE_INTERVAL) {
@@ -2982,7 +2982,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->TestingV3AuthInitialVoteDelay != 5*60 &&
-      !options->TestingTorNetwork && !options->_UsingTestNetworkDefaults) {
+      !options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
 
     REJECT("TestingV3AuthInitialVoteDelay may only be changed in testing "
            "Tor networks!");
@@ -2991,7 +2991,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->TestingV3AuthInitialDistDelay != 5*60 &&
-      !options->TestingTorNetwork && !options->_UsingTestNetworkDefaults) {
+      !options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
     REJECT("TestingV3AuthInitialDistDelay may only be changed in testing "
            "Tor networks!");
   } else if (options->TestingV3AuthInitialDistDelay < MIN_DIST_SECONDS) {
@@ -3006,7 +3006,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->TestingAuthDirTimeToLearnReachability != 30*60 &&
-      !options->TestingTorNetwork && !options->_UsingTestNetworkDefaults) {
+      !options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
     REJECT("TestingAuthDirTimeToLearnReachability may only be changed in "
            "testing Tor networks!");
   } else if (options->TestingAuthDirTimeToLearnReachability < 0) {
@@ -3016,7 +3016,7 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->TestingEstimatedDescriptorPropagationTime != 10*60 &&
-      !options->TestingTorNetwork && !options->_UsingTestNetworkDefaults) {
+      !options->TestingTorNetwork && !options->UsingTestNetworkDefaults_) {
     REJECT("TestingEstimatedDescriptorPropagationTime may only be changed in "
            "testing Tor networks!");
   } else if (options->TestingEstimatedDescriptorPropagationTime < 0) {
@@ -3152,7 +3152,7 @@ options_transition_affects_workers(const or_options_t *old_options,
       !config_lines_eq(old_options->ORPort_lines, new_options->ORPort_lines) ||
       old_options->ServerDNSSearchDomains !=
                                        new_options->ServerDNSSearchDomains ||
-      old_options->_SafeLogging != new_options->_SafeLogging ||
+      old_options->SafeLogging_ != new_options->SafeLogging_ ||
       old_options->ClientOnly != new_options->ClientOnly ||
       public_server_mode(old_options) != public_server_mode(new_options) ||
       !config_lines_eq(old_options->Logs, new_options->Logs) ||
@@ -3185,8 +3185,8 @@ options_transition_affects_descriptor(const or_options_t *old_options,
                        new_options->DirPort_lines) ||
       old_options->ClientOnly != new_options->ClientOnly ||
       old_options->DisableNetwork != new_options->DisableNetwork ||
-      old_options->_PublishServerDescriptor !=
-        new_options->_PublishServerDescriptor ||
+      old_options->PublishServerDescriptor_ !=
+        new_options->PublishServerDescriptor_ ||
       get_effective_bwrate(old_options) != get_effective_bwrate(new_options) ||
       get_effective_bwburst(old_options) !=
         get_effective_bwburst(new_options) ||
@@ -3543,7 +3543,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
                                   this is the first time we run*/
 
   newoptions = tor_malloc_zero(sizeof(or_options_t));
-  newoptions->_magic = OR_OPTIONS_MAGIC;
+  newoptions->magic_ = OR_OPTIONS_MAGIC;
   options_init(newoptions);
   newoptions->command = command;
   newoptions->command_arg = command_arg;
@@ -3603,7 +3603,7 @@ options_init_from_string(const char *cf_defaults, const char *cf,
     config_free(&options_format, newdefaultoptions);
     newdefaultoptions = NULL;
     newoptions = tor_malloc_zero(sizeof(or_options_t));
-    newoptions->_magic = OR_OPTIONS_MAGIC;
+    newoptions->magic_ = OR_OPTIONS_MAGIC;
     options_init(newoptions);
     newoptions->command = command;
     newoptions->command_arg = command_arg;
@@ -5469,11 +5469,11 @@ getinfo_helper_config(control_connection_t *conn,
   if (!strcmp(question, "config/names")) {
     smartlist_t *sl = smartlist_new();
     int i;
-    for (i = 0; _option_vars[i].name; ++i) {
-      const config_var_t *var = &_option_vars[i];
+    for (i = 0; option_vars_[i].name; ++i) {
+      const config_var_t *var = &option_vars_[i];
       const char *type;
       /* don't tell controller about triple-underscore options */
-      if (!strncmp(_option_vars[i].name, "___", 3))
+      if (!strncmp(option_vars_[i].name, "___", 3))
         continue;
       switch (var->type) {
         case CONFIG_TYPE_STRING: type = "String"; break;
@@ -5507,8 +5507,8 @@ getinfo_helper_config(control_connection_t *conn,
   } else if (!strcmp(question, "config/defaults")) {
     smartlist_t *sl = smartlist_new();
     int i;
-    for (i = 0; _option_vars[i].name; ++i) {
-      const config_var_t *var = &_option_vars[i];
+    for (i = 0; option_vars_[i].name; ++i) {
+      const config_var_t *var = &option_vars_[i];
       if (var->initvalue != NULL) {
           char *val = esc_for_log(var->initvalue);
           smartlist_add_asprintf(sl, "%s %s\n",var->name,val);
@@ -5523,8 +5523,8 @@ getinfo_helper_config(control_connection_t *conn,
 }
 
 /** Parse outbound bind address option lines. If <b>validate_only</b>
- * is not 0 update _OutboundBindAddressIPv4 and
- * _OutboundBindAddressIPv6 in <b>options</b>. On failure, set
+ * is not 0 update OutboundBindAddressIPv4_ and
+ * OutboundBindAddressIPv6_ in <b>options</b>. On failure, set
  * <b>msg</b> (if provided) to a newly allocated string containing a
  * description of the problem and return -1. */
 static int
@@ -5534,10 +5534,10 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg)
   int found_v4 = 0, found_v6 = 0;
 
   if (!validate_only) {
-    memset(&options->_OutboundBindAddressIPv4, 0,
-           sizeof(options->_OutboundBindAddressIPv4));
-    memset(&options->_OutboundBindAddressIPv6, 0,
-           sizeof(options->_OutboundBindAddressIPv6));
+    memset(&options->OutboundBindAddressIPv4_, 0,
+           sizeof(options->OutboundBindAddressIPv4_));
+    memset(&options->OutboundBindAddressIPv6_, 0,
+           sizeof(options->OutboundBindAddressIPv6_));
   }
   while (lines) {
     tor_addr_t addr, *dst_addr = NULL;
@@ -5551,7 +5551,7 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg)
         return -1;
       }
       found_v4 = 1;
-      dst_addr = &options->_OutboundBindAddressIPv4;
+      dst_addr = &options->OutboundBindAddressIPv4_;
       break;
     case AF_INET6:
       if (found_v6) {
@@ -5561,7 +5561,7 @@ parse_outbound_addresses(or_options_t *options, int validate_only, char **msg)
         return -1;
       }
       found_v6 = 1;
-      dst_addr = &options->_OutboundBindAddressIPv6;
+      dst_addr = &options->OutboundBindAddressIPv6_;
       break;
     default:
       if (msg)

+ 2 - 2
src/or/config.h

@@ -9,8 +9,8 @@
  * \brief Header file for config.c.
  **/
 
-#ifndef _TOR_CONFIG_H
-#define _TOR_CONFIG_H
+#ifndef TOR_CONFIG_H
+#define TOR_CONFIG_H
 
 const char *get_dirportfrontpage(void);
 const or_options_t *get_options(void);

+ 38 - 38
src/or/connection.c

@@ -16,7 +16,7 @@
  * Define this so we get channel internal functions, since we're implementing
  * part of a subclass (channel_tls_t).
  */
-#define _TOR_CHANNEL_INTERNAL
+#define TOR_CHANNEL_INTERNAL_
 #include "channel.h"
 #include "channeltls.h"
 #include "circuitbuild.h"
@@ -427,7 +427,7 @@ connection_link_connections(connection_t *conn_a, connection_t *conn_b)
  * if <b>conn</b> is an OR or OP connection.
  */
 static void
-_connection_free(connection_t *conn)
+connection_free_(connection_t *conn)
 {
   void *mem;
   size_t memlen;
@@ -604,7 +604,7 @@ connection_free(connection_t *conn)
     connection_control_closed(TO_CONTROL_CONN(conn));
   }
   connection_unregister_events(conn);
-  _connection_free(conn);
+  connection_free_(conn);
 }
 
 /**
@@ -680,7 +680,7 @@ connection_close_immediate(connection_t *conn)
 /** Mark <b>conn</b> to be closed next time we loop through
  * conn_close_if_marked() in main.c. */
 void
-_connection_mark_for_close(connection_t *conn, int line, const char *file)
+connection_mark_for_close_(connection_t *conn, int line, const char *file)
 {
   assert_connection_ok(conn,0);
   tor_assert(line);
@@ -903,7 +903,7 @@ connection_listener_new(const struct sockaddr *listensockaddr,
   static int global_next_session_group = SESSION_GROUP_FIRST_AUTO;
   tor_addr_t addr;
 
-  if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
+  if (get_n_open_sockets() >= get_options()->ConnLimit_-1) {
     warn_too_many_conns();
     return NULL;
   }
@@ -1310,7 +1310,7 @@ connection_init_accepted_conn(connection_t *conn,
       TO_ENTRY_CONN(conn)->isolation_flags = listener->isolation_flags;
       TO_ENTRY_CONN(conn)->session_group = listener->session_group;
       TO_ENTRY_CONN(conn)->nym_epoch = get_signewnym_epoch();
-      TO_ENTRY_CONN(conn)->socks_request->listener_type = listener->_base.type;
+      TO_ENTRY_CONN(conn)->socks_request->listener_type = listener->base_.type;
       switch (TO_CONN(listener)->type) {
         case CONN_TYPE_AP_LISTENER:
           conn->state = AP_CONN_STATE_SOCKS_WAIT;
@@ -1357,7 +1357,7 @@ connection_connect(connection_t *conn, const char *address,
   const or_options_t *options = get_options();
   int protocol_family;
 
-  if (get_n_open_sockets() >= get_options()->_ConnLimit-1) {
+  if (get_n_open_sockets() >= get_options()->ConnLimit_-1) {
     warn_too_many_conns();
     *socket_error = SOCK_ERRNO(ENOBUFS);
     return -1;
@@ -1399,11 +1399,11 @@ connection_connect(connection_t *conn, const char *address,
   if (!tor_addr_is_loopback(addr)) {
     const tor_addr_t *ext_addr = NULL;
     if (protocol_family == AF_INET &&
-        !tor_addr_is_null(&options->_OutboundBindAddressIPv4))
-      ext_addr = &options->_OutboundBindAddressIPv4;
+        !tor_addr_is_null(&options->OutboundBindAddressIPv4_))
+      ext_addr = &options->OutboundBindAddressIPv4_;
     else if (protocol_family == AF_INET6 &&
-             !tor_addr_is_null(&options->_OutboundBindAddressIPv6))
-      ext_addr = &options->_OutboundBindAddressIPv6;
+             !tor_addr_is_null(&options->OutboundBindAddressIPv6_))
+      ext_addr = &options->OutboundBindAddressIPv6_;
     if (ext_addr) {
       struct sockaddr_storage ext_addr_sa;
       socklen_t ext_addr_len = 0;
@@ -2570,7 +2570,7 @@ connection_bucket_should_increase(int bucket, or_connection_t *conn)
 {
   tor_assert(conn);
 
-  if (conn->_base.state != OR_CONN_STATE_OPEN)
+  if (conn->base_.state != OR_CONN_STATE_OPEN)
     return 0; /* only open connections play the rate limiting game */
   if (bucket >= conn->bandwidthburst)
     return 0;
@@ -3428,7 +3428,7 @@ connection_flush(connection_t *conn)
  * once.
  */
 void
-_connection_write_to_buf_impl(const char *string, size_t len,
+connection_write_to_buf_impl_(const char *string, size_t len,
                               connection_t *conn, int zlib)
 {
   /* XXXX This function really needs to return -1 on failure. */
@@ -3995,9 +3995,9 @@ connection_reached_eof(connection_t *conn)
 void
 connection_dump_buffer_mem_stats(int severity)
 {
-  uint64_t used_by_type[_CONN_TYPE_MAX+1];
-  uint64_t alloc_by_type[_CONN_TYPE_MAX+1];
-  int n_conns_by_type[_CONN_TYPE_MAX+1];
+  uint64_t used_by_type[CONN_TYPE_MAX_+1];
+  uint64_t alloc_by_type[CONN_TYPE_MAX_+1];
+  int n_conns_by_type[CONN_TYPE_MAX_+1];
   uint64_t total_alloc = 0;
   uint64_t total_used = 0;
   int i;
@@ -4019,7 +4019,7 @@ connection_dump_buffer_mem_stats(int severity)
       alloc_by_type[tp] += buf_allocation(c->outbuf);
     }
   } SMARTLIST_FOREACH_END(c);
-  for (i=0; i <= _CONN_TYPE_MAX; ++i) {
+  for (i=0; i <= CONN_TYPE_MAX_; ++i) {
     total_used += used_by_type[i];
     total_alloc += alloc_by_type[i];
   }
@@ -4028,7 +4028,7 @@ connection_dump_buffer_mem_stats(int severity)
      "In buffers for %d connections: "U64_FORMAT" used/"U64_FORMAT" allocated",
       smartlist_len(conns),
       U64_PRINTF_ARG(total_used), U64_PRINTF_ARG(total_alloc));
-  for (i=_CONN_TYPE_MIN; i <= _CONN_TYPE_MAX; ++i) {
+  for (i=CONN_TYPE_MIN_; i <= CONN_TYPE_MAX_; ++i) {
     if (!n_conns_by_type[i])
       continue;
     log(severity, LD_GENERAL,
@@ -4046,8 +4046,8 @@ assert_connection_ok(connection_t *conn, time_t now)
 {
   (void) now; /* XXXX unused. */
   tor_assert(conn);
-  tor_assert(conn->type >= _CONN_TYPE_MIN);
-  tor_assert(conn->type <= _CONN_TYPE_MAX);
+  tor_assert(conn->type >= CONN_TYPE_MIN_);
+  tor_assert(conn->type <= CONN_TYPE_MAX_);
 
 #ifdef USE_BUFFEREVENTS
   if (conn->bufev) {
@@ -4162,33 +4162,33 @@ assert_connection_ok(connection_t *conn, time_t now)
       tor_assert(conn->state == LISTENER_STATE_READY);
       break;
     case CONN_TYPE_OR:
-      tor_assert(conn->state >= _OR_CONN_STATE_MIN);
-      tor_assert(conn->state <= _OR_CONN_STATE_MAX);
+      tor_assert(conn->state >= OR_CONN_STATE_MIN_);
+      tor_assert(conn->state <= OR_CONN_STATE_MAX_);
       break;
     case CONN_TYPE_EXIT:
-      tor_assert(conn->state >= _EXIT_CONN_STATE_MIN);
-      tor_assert(conn->state <= _EXIT_CONN_STATE_MAX);
-      tor_assert(conn->purpose >= _EXIT_PURPOSE_MIN);
-      tor_assert(conn->purpose <= _EXIT_PURPOSE_MAX);
+      tor_assert(conn->state >= EXIT_CONN_STATE_MIN_);
+      tor_assert(conn->state <= EXIT_CONN_STATE_MAX_);
+      tor_assert(conn->purpose >= EXIT_PURPOSE_MIN_);
+      tor_assert(conn->purpose <= EXIT_PURPOSE_MAX_);
       break;
     case CONN_TYPE_AP:
-      tor_assert(conn->state >= _AP_CONN_STATE_MIN);
-      tor_assert(conn->state <= _AP_CONN_STATE_MAX);
+      tor_assert(conn->state >= AP_CONN_STATE_MIN_);
+      tor_assert(conn->state <= AP_CONN_STATE_MAX_);
       tor_assert(TO_ENTRY_CONN(conn)->socks_request);
       break;
     case CONN_TYPE_DIR:
-      tor_assert(conn->state >= _DIR_CONN_STATE_MIN);
-      tor_assert(conn->state <= _DIR_CONN_STATE_MAX);
-      tor_assert(conn->purpose >= _DIR_PURPOSE_MIN);
-      tor_assert(conn->purpose <= _DIR_PURPOSE_MAX);
+      tor_assert(conn->state >= DIR_CONN_STATE_MIN_);
+      tor_assert(conn->state <= DIR_CONN_STATE_MAX_);
+      tor_assert(conn->purpose >= DIR_PURPOSE_MIN_);
+      tor_assert(conn->purpose <= DIR_PURPOSE_MAX_);
       break;
     case CONN_TYPE_CPUWORKER:
-      tor_assert(conn->state >= _CPUWORKER_STATE_MIN);
-      tor_assert(conn->state <= _CPUWORKER_STATE_MAX);
+      tor_assert(conn->state >= CPUWORKER_STATE_MIN_);
+      tor_assert(conn->state <= CPUWORKER_STATE_MAX_);
       break;
     case CONN_TYPE_CONTROL:
-      tor_assert(conn->state >= _CONTROL_CONN_STATE_MIN);
-      tor_assert(conn->state <= _CONTROL_CONN_STATE_MAX);
+      tor_assert(conn->state >= CONTROL_CONN_STATE_MIN_);
+      tor_assert(conn->state <= CONTROL_CONN_STATE_MAX_);
       break;
     default:
       tor_assert(0);
@@ -4293,7 +4293,7 @@ proxy_type_to_string(int proxy_type)
   return NULL; /*Unreached*/
 }
 
-/** Call _connection_free() on every connection in our array, and release all
+/** Call connection_free_() on every connection in our array, and release all
  * storage held by connection.c. This is used by cpuworkers and dnsworkers
  * when they fork, so they don't keep resources held open (especially
  * sockets).
@@ -4319,7 +4319,7 @@ connection_free_all(void)
   /* Clear out our list of broken connections */
   clear_broken_connection_map(0);
 
-  SMARTLIST_FOREACH(conns, connection_t *, conn, _connection_free(conn));
+  SMARTLIST_FOREACH(conns, connection_t *, conn, connection_free_(conn));
 
   if (outgoing_addrs) {
     SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t *, addr, tor_free(addr));

+ 10 - 10
src/or/connection.h

@@ -9,8 +9,8 @@
  * \brief Header file for connection.c.
  **/
 
-#ifndef _TOR_CONNECTION_H
-#define _TOR_CONNECTION_H
+#ifndef TOR_CONNECTION_H
+#define TOR_CONNECTION_H
 
 /* XXXX For buf_datalen in inline function */
 #include "buffers.h"
@@ -31,25 +31,25 @@ void connection_free(connection_t *conn);
 void connection_free_all(void);
 void connection_about_to_close_connection(connection_t *conn);
 void connection_close_immediate(connection_t *conn);
-void _connection_mark_for_close(connection_t *conn,int line, const char *file);
+void connection_mark_for_close_(connection_t *conn,int line, const char *file);
 
 #define connection_mark_for_close(c) \
-  _connection_mark_for_close((c), __LINE__, _SHORT_FILE_)
+  connection_mark_for_close_((c), __LINE__, SHORT_FILE__)
 
 /**
  * Mark 'c' for close, but try to hold it open until all the data is written.
  */
-#define _connection_mark_and_flush(c,line,file)                         \
+#define connection_mark_and_flush_(c,line,file)                         \
   do {                                                                  \
     connection_t *tmp_conn_ = (c);                                      \
-    _connection_mark_for_close(tmp_conn_, (line), (file));              \
+    connection_mark_for_close_(tmp_conn_, (line), (file));              \
     tmp_conn_->hold_open_until_flushed = 1;                             \
     IF_HAS_BUFFEREVENT(tmp_conn_,                                       \
                        connection_start_writing(tmp_conn_));            \
   } while (0)
 
 #define connection_mark_and_flush(c)            \
-  _connection_mark_and_flush((c), __LINE__, _SHORT_FILE_)
+  connection_mark_and_flush_((c), __LINE__, SHORT_FILE__)
 
 void connection_expire_held_open(void);
 
@@ -90,7 +90,7 @@ int connection_outbuf_too_full(connection_t *conn);
 int connection_handle_write(connection_t *conn, int force);
 int connection_flush(connection_t *conn);
 
-void _connection_write_to_buf_impl(const char *string, size_t len,
+void connection_write_to_buf_impl_(const char *string, size_t len,
                                    connection_t *conn, int zlib);
 /* DOCDOC connection_write_to_buf */
 static void connection_write_to_buf(const char *string, size_t len,
@@ -101,13 +101,13 @@ static void connection_write_to_buf_zlib(const char *string, size_t len,
 static INLINE void
 connection_write_to_buf(const char *string, size_t len, connection_t *conn)
 {
-  _connection_write_to_buf_impl(string, len, conn, 0);
+  connection_write_to_buf_impl_(string, len, conn, 0);
 }
 static INLINE void
 connection_write_to_buf_zlib(const char *string, size_t len,
                              dir_connection_t *conn, int done)
 {
-  _connection_write_to_buf_impl(string, len, TO_CONN(conn), done ? -1 : 1);
+  connection_write_to_buf_impl_(string, len, TO_CONN(conn), done ? -1 : 1);
 }
 
 /* DOCDOC connection_get_inbuf_len */

+ 60 - 60
src/or/connection_edge.c

@@ -66,7 +66,7 @@ static int connection_ap_supports_optimistic_data(const entry_connection_t *);
  * has_sent_end to 1, and mark the conn.
  */
 void
-_connection_mark_unattached_ap(entry_connection_t *conn, int endreason,
+connection_mark_unattached_ap_(entry_connection_t *conn, int endreason,
                                int line, const char *file)
 {
   connection_t *base_conn = ENTRY_TO_CONN(conn);
@@ -89,7 +89,7 @@ _connection_mark_unattached_ap(entry_connection_t *conn, int endreason,
 
   if (base_conn->marked_for_close) {
     /* This call will warn as appropriate. */
-    _connection_mark_for_close(base_conn, line, file);
+    connection_mark_for_close_(base_conn, line, file);
     return;
   }
 
@@ -109,7 +109,7 @@ _connection_mark_unattached_ap(entry_connection_t *conn, int endreason,
       conn->socks_request->has_finished = 1;
   }
 
-  _connection_mark_and_flush(base_conn, line, file);
+  connection_mark_and_flush_(base_conn, line, file);
 
   ENTRY_TO_EDGE_CONN(conn)->end_reason = endreason;
 }
@@ -124,12 +124,12 @@ connection_edge_reached_eof(edge_connection_t *conn)
     /* it still has stuff to process. don't let it die yet. */
     return 0;
   }
-  log_info(LD_EDGE,"conn (fd %d) reached eof. Closing.", conn->_base.s);
-  if (!conn->_base.marked_for_close) {
+  log_info(LD_EDGE,"conn (fd %d) reached eof. Closing.", conn->base_.s);
+  if (!conn->base_.marked_for_close) {
     /* only mark it if not already marked. it's possible to
      * get the 'end' right around when the client hangs up on us. */
     connection_edge_end(conn, END_STREAM_REASON_DONE);
-    if (conn->_base.type == CONN_TYPE_AP) {
+    if (conn->base_.type == CONN_TYPE_AP) {
       /* eof, so don't send a socks reply back */
       if (EDGE_TO_ENTRY_CONN(conn)->socks_request)
         EDGE_TO_ENTRY_CONN(conn)->socks_request->has_finished = 1;
@@ -154,7 +154,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
 {
   tor_assert(conn);
 
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case AP_CONN_STATE_SOCKS_WAIT:
       if (connection_ap_handshake_process_socks(EDGE_TO_ENTRY_CONN(conn)) <0) {
         /* already marked */
@@ -180,7 +180,7 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
         log_info(LD_EDGE,
                  "data from edge while in '%s' state. Sending it anyway. "
                  "package_partial=%d, buflen=%ld",
-                 conn_state_to_string(conn->_base.type, conn->_base.state),
+                 conn_state_to_string(conn->base_.type, conn->base_.state),
                  package_partial,
                  (long)connection_get_inbuf_len(TO_CONN(conn)));
         if (connection_edge_package_raw_inbuf(conn, package_partial, NULL)<0) {
@@ -199,10 +199,10 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
     case AP_CONN_STATE_CONTROLLER_WAIT:
       log_info(LD_EDGE,
                "data from edge while in '%s' state. Leaving it on buffer.",
-               conn_state_to_string(conn->_base.type, conn->_base.state));
+               conn_state_to_string(conn->base_.type, conn->base_.state));
       return 0;
   }
-  log_warn(LD_BUG,"Got unexpected state %d. Closing.",conn->_base.state);
+  log_warn(LD_BUG,"Got unexpected state %d. Closing.",conn->base_.state);
   tor_fragile_assert();
   connection_edge_end(conn, END_STREAM_REASON_INTERNAL);
   connection_mark_for_close(TO_CONN(conn));
@@ -215,10 +215,10 @@ connection_edge_process_inbuf(edge_connection_t *conn, int package_partial)
 int
 connection_edge_destroy(circid_t circ_id, edge_connection_t *conn)
 {
-  if (!conn->_base.marked_for_close) {
+  if (!conn->base_.marked_for_close) {
     log_info(LD_EDGE,
              "CircID %d: At an edge. Marking connection for close.", circ_id);
-    if (conn->_base.type == CONN_TYPE_AP) {
+    if (conn->base_.type == CONN_TYPE_AP) {
       entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
       connection_mark_unattached_ap(entry_conn, END_STREAM_REASON_DESTROY);
       control_event_stream_bandwidth(conn);
@@ -282,10 +282,10 @@ connection_edge_end(edge_connection_t *conn, uint8_t reason)
     return -1;
   }
 
-  if (conn->_base.marked_for_close) {
+  if (conn->base_.marked_for_close) {
     log_warn(LD_BUG,
              "called on conn that's already marked for close at %s:%d.",
-             conn->_base.marked_for_close_file, conn->_base.marked_for_close);
+             conn->base_.marked_for_close_file, conn->base_.marked_for_close);
     return 0;
   }
 
@@ -301,11 +301,11 @@ connection_edge_end(edge_connection_t *conn, uint8_t reason)
   if (reason == END_STREAM_REASON_EXITPOLICY &&
       !connection_edge_is_rendezvous_stream(conn)) {
     int addrlen;
-    if (tor_addr_family(&conn->_base.addr) == AF_INET) {
-      set_uint32(payload+1, tor_addr_to_ipv4n(&conn->_base.addr));
+    if (tor_addr_family(&conn->base_.addr) == AF_INET) {
+      set_uint32(payload+1, tor_addr_to_ipv4n(&conn->base_.addr));
       addrlen = 4;
     } else {
-      memcpy(payload+1, tor_addr_to_in6_addr8(&conn->_base.addr), 16);
+      memcpy(payload+1, tor_addr_to_in6_addr8(&conn->base_.addr), 16);
       addrlen = 16;
     }
     set_uint32(payload+1+addrlen, htonl(dns_clip_ttl(conn->address_ttl)));
@@ -313,12 +313,12 @@ connection_edge_end(edge_connection_t *conn, uint8_t reason)
   }
 
   if (circ && !circ->marked_for_close) {
-    log_debug(LD_EDGE,"Sending end on conn (fd %d).",conn->_base.s);
+    log_debug(LD_EDGE,"Sending end on conn (fd %d).",conn->base_.s);
     connection_edge_send_command(conn, RELAY_COMMAND_END,
                                  payload, payload_len);
   } else {
     log_debug(LD_EDGE,"No circ to send end on conn (fd %d).",
-              conn->_base.s);
+              conn->base_.s);
   }
 
   conn->edge_has_sent_end = 1;
@@ -335,7 +335,7 @@ connection_edge_end_errno(edge_connection_t *conn)
 {
   uint8_t reason;
   tor_assert(conn);
-  reason = errno_to_stream_end_reason(tor_socket_errno(conn->_base.s));
+  reason = errno_to_stream_end_reason(tor_socket_errno(conn->base_.s));
   return connection_edge_end(conn, reason);
 }
 
@@ -347,7 +347,7 @@ connection_edge_end_errno(edge_connection_t *conn)
 int
 connection_edge_flushed_some(edge_connection_t *conn)
 {
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case AP_CONN_STATE_OPEN:
     case EXIT_CONN_STATE_OPEN:
       connection_edge_consider_sending_sendme(conn);
@@ -371,7 +371,7 @@ connection_edge_finished_flushing(edge_connection_t *conn)
 {
   tor_assert(conn);
 
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case AP_CONN_STATE_OPEN:
     case EXIT_CONN_STATE_OPEN:
       connection_edge_consider_sending_sendme(conn);
@@ -385,7 +385,7 @@ connection_edge_finished_flushing(edge_connection_t *conn)
     case AP_CONN_STATE_RESOLVE_WAIT:
       return 0;
     default:
-      log_warn(LD_BUG, "Called in unexpected state %d.",conn->_base.state);
+      log_warn(LD_BUG, "Called in unexpected state %d.",conn->base_.state);
       tor_fragile_assert();
       return -1;
   }
@@ -401,7 +401,7 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
   connection_t *conn;
 
   tor_assert(edge_conn);
-  tor_assert(edge_conn->_base.type == CONN_TYPE_EXIT);
+  tor_assert(edge_conn->base_.type == CONN_TYPE_EXIT);
   conn = TO_CONN(edge_conn);
   tor_assert(conn->state == EXIT_CONN_STATE_CONNECTING);
 
@@ -628,7 +628,7 @@ connection_ap_expire_beginning(void)
     tor_assert(circ->timestamp_dirty);
     circ->timestamp_dirty -= options->MaxCircuitDirtiness;
     /* give our stream another 'cutoff' seconds to try */
-    conn->_base.timestamp_lastread += cutoff;
+    conn->base_.timestamp_lastread += cutoff;
     if (entry_conn->num_socks_retries < 250) /* avoid overflow */
       entry_conn->num_socks_retries++;
     /* move it back into 'pending' state, and try to attach. */
@@ -934,7 +934,7 @@ void
 addressmap_clear_excluded_trackexithosts(const or_options_t *options)
 {
   const routerset_t *allow_nodes = options->ExitNodes;
-  const routerset_t *exclude_nodes = options->_ExcludeExitNodesUnion;
+  const routerset_t *exclude_nodes = options->ExcludeExitNodesUnion_;
 
   if (!addressmap)
     return;
@@ -1688,15 +1688,15 @@ addressmap_get_mappings(smartlist_t *sl, time_t min_expires,
 {
    strmap_iter_t *iter;
    const char *key;
-   void *_val;
+   void *val_;
    addressmap_entry_t *val;
 
    if (!addressmap)
      addressmap_init();
 
    for (iter = strmap_iter_init(addressmap); !strmap_iter_done(iter); ) {
-     strmap_iter_get(iter, &key, &_val);
-     val = _val;
+     strmap_iter_get(iter, &key, &val_);
+     val = val_;
      if (val->expires >= min_expires && val->expires <= max_expires) {
        if (!sl) {
          iter = strmap_iter_next_rmv(addressmap,iter);
@@ -1925,7 +1925,7 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
 
     /* If StrictNodes is not set, then .exit overrides ExcludeNodes. */
     routerset_t *excludeset = options->StrictNodes ?
-      options->_ExcludeExitNodesUnion : options->ExcludeExitNodes;
+      options->ExcludeExitNodesUnion_ : options->ExcludeExitNodes;
     const node_t *node;
 
     if (exit_source == ADDRMAPSRC_AUTOMAP && !options->AllowDotExit) {
@@ -2587,13 +2587,13 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
 
     /* Mark this circuit "unusable for new streams". */
     /* XXXX024 this is a kludgy way to do this. */
-    tor_assert(circ->_base.timestamp_dirty);
-    circ->_base.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
+    tor_assert(circ->base_.timestamp_dirty);
+    circ->base_.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
     return -1;
   }
 
   tor_snprintf(payload,RELAY_PAYLOAD_SIZE, "%s:%d",
-               (circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL) ?
+               (circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL) ?
                  ap_conn->socks_request->address : "",
                ap_conn->socks_request->port);
   payload_len = (int)strlen(payload)+1;
@@ -2620,7 +2620,7 @@ connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
   edge_conn->deliver_window = STREAMWINDOW_START;
   base_conn->state = AP_CONN_STATE_CONNECT_WAIT;
   log_info(LD_APP,"Address/port sent, ap socket %d, n_circ_id %d",
-           base_conn->s, circ->_base.n_circ_id);
+           base_conn->s, circ->base_.n_circ_id);
   control_event_stream_status(ap_conn, STREAM_EVENT_SENT_CONNECT, 0);
 
   /* If there's queued-up data, send it now */
@@ -2659,7 +2659,7 @@ connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
   tor_assert(base_conn->type == CONN_TYPE_AP);
   tor_assert(base_conn->state == AP_CONN_STATE_CIRCUIT_WAIT);
   tor_assert(ap_conn->socks_request);
-  tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_C_GENERAL);
+  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL);
 
   command = ap_conn->socks_request->command;
   tor_assert(SOCKS_COMMAND_IS_RESOLVE(command));
@@ -2672,8 +2672,8 @@ connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
 
     /* Mark this circuit "unusable for new streams". */
     /* XXXX024 this is a kludgy way to do this. */
-    tor_assert(circ->_base.timestamp_dirty);
-    circ->_base.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
+    tor_assert(circ->base_.timestamp_dirty);
+    circ->base_.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
     return -1;
   }
 
@@ -2721,7 +2721,7 @@ connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
   base_conn->address = tor_strdup("(Tor_internal)");
   base_conn->state = AP_CONN_STATE_RESOLVE_WAIT;
   log_info(LD_APP,"Address sent for resolve, ap socket %d, n_circ_id %d",
-           base_conn->s, circ->_base.n_circ_id);
+           base_conn->s, circ->base_.n_circ_id);
   control_event_stream_status(ap_conn, STREAM_EVENT_NEW, 0);
   control_event_stream_status(ap_conn, STREAM_EVENT_SENT_RESOLVE, 0);
   return 0;
@@ -3102,7 +3102,7 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
     }
     /* Make sure to get the 'real' address of the previous hop: the
      * caller might want to know whether his IP address has changed, and
-     * we might already have corrected _base.addr[ess] for the relay's
+     * we might already have corrected base_.addr[ess] for the relay's
      * canonical IP address. */
     if (or_circ && or_circ->p_chan)
       address = tor_strdup(channel_get_actual_remote_descr(or_circ->p_chan));
@@ -3125,10 +3125,10 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
    * we can measure download times. */
   n_stream->dirreq_id = circ->dirreq_id;
 
-  n_stream->_base.purpose = EXIT_PURPOSE_CONNECT;
+  n_stream->base_.purpose = EXIT_PURPOSE_CONNECT;
 
   n_stream->stream_id = rh.stream_id;
-  n_stream->_base.port = port;
+  n_stream->base_.port = port;
   /* leave n_stream->s at -1, because it's not yet valid */
   n_stream->package_window = STREAMWINDOW_START;
   n_stream->deliver_window = STREAMWINDOW_START;
@@ -3136,14 +3136,14 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
   if (circ->purpose == CIRCUIT_PURPOSE_S_REND_JOINED) {
     origin_circuit_t *origin_circ = TO_ORIGIN_CIRCUIT(circ);
     log_info(LD_REND,"begin is for rendezvous. configuring stream.");
-    n_stream->_base.address = tor_strdup("(rendezvous)");
-    n_stream->_base.state = EXIT_CONN_STATE_CONNECTING;
+    n_stream->base_.address = tor_strdup("(rendezvous)");
+    n_stream->base_.state = EXIT_CONN_STATE_CONNECTING;
     n_stream->rend_data = rend_data_dup(origin_circ->rend_data);
     tor_assert(connection_edge_is_rendezvous_stream(n_stream));
     assert_circuit_ok(circ);
     if (rend_service_set_connection_addr_port(n_stream, origin_circ) < 0) {
       log_info(LD_REND,"Didn't find rendezvous service (port %d)",
-               n_stream->_base.port);
+               n_stream->base_.port);
       relay_send_end_cell_from_edge(rh.stream_id, circ,
                                     END_STREAM_REASON_EXITPOLICY,
                                     origin_circ->cpath->prev);
@@ -3166,8 +3166,8 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
     return 0;
   }
   tor_strlower(address);
-  n_stream->_base.address = address;
-  n_stream->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
+  n_stream->base_.address = address;
+  n_stream->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
   /* default to failed, change in dns_resolve if it turns out not to fail */
 
   if (we_are_hibernating()) {
@@ -3230,12 +3230,12 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ)
    */
   dummy_conn = edge_connection_new(CONN_TYPE_EXIT, AF_INET);
   dummy_conn->stream_id = rh.stream_id;
-  dummy_conn->_base.address = tor_strndup(
+  dummy_conn->base_.address = tor_strndup(
                                        (char*)cell->payload+RELAY_HEADER_SIZE,
                                        rh.length);
-  dummy_conn->_base.port = 0;
-  dummy_conn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
-  dummy_conn->_base.purpose = EXIT_PURPOSE_RESOLVE;
+  dummy_conn->base_.port = 0;
+  dummy_conn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
+  dummy_conn->base_.purpose = EXIT_PURPOSE_RESOLVE;
 
   dummy_conn->on_circuit = TO_CIRCUIT(circ);
 
@@ -3245,7 +3245,7 @@ connection_exit_begin_resolve(cell_t *cell, or_circuit_t *circ)
       /* Connection freed; don't touch it. */
       return 0;
     case 1: /* The result was cached; a resolved cell was sent. */
-      if (!dummy_conn->_base.marked_for_close)
+      if (!dummy_conn->base_.marked_for_close)
         connection_free(TO_CONN(dummy_conn));
       return 0;
     case 0: /* resolve added to pending list */
@@ -3352,16 +3352,16 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
 
   log_info(LD_EXIT, "Opening local connection for anonymized directory exit");
 
-  exitconn->_base.state = EXIT_CONN_STATE_OPEN;
+  exitconn->base_.state = EXIT_CONN_STATE_OPEN;
 
-  dirconn = dir_connection_new(tor_addr_family(&exitconn->_base.addr));
+  dirconn = dir_connection_new(tor_addr_family(&exitconn->base_.addr));
 
-  tor_addr_copy(&dirconn->_base.addr, &exitconn->_base.addr);
-  dirconn->_base.port = 0;
-  dirconn->_base.address = tor_strdup(exitconn->_base.address);
-  dirconn->_base.type = CONN_TYPE_DIR;
-  dirconn->_base.purpose = DIR_PURPOSE_SERVER;
-  dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
+  tor_addr_copy(&dirconn->base_.addr, &exitconn->base_.addr);
+  dirconn->base_.port = 0;
+  dirconn->base_.address = tor_strdup(exitconn->base_.address);
+  dirconn->base_.type = CONN_TYPE_DIR;
+  dirconn->base_.purpose = DIR_PURPOSE_SERVER;
+  dirconn->base_.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
 
   /* Note that the new dir conn belongs to the same tunneled request as
    * the edge conn, so that we can measure download times. */
@@ -3467,7 +3467,7 @@ connection_ap_can_use_exit(const entry_connection_t *conn, const node_t *exit)
     if (!conn->chosen_exit_name && node_exit_policy_rejects_all(exit))
       return 0;
   }
-  if (routerset_contains_node(options->_ExcludeExitNodesUnion, exit)) {
+  if (routerset_contains_node(options->ExcludeExitNodesUnion_, exit)) {
     /* Not a suitable exit. Refuse it. */
     return 0;
   }

+ 4 - 4
src/or/connection_edge.h

@@ -9,13 +9,13 @@
  * \brief Header file for connection_edge.c.
  **/
 
-#ifndef _TOR_CONNECTION_EDGE_H
-#define _TOR_CONNECTION_EDGE_H
+#ifndef TOR_CONNECTION_EDGE_H
+#define TOR_CONNECTION_EDGE_H
 
 #define connection_mark_unattached_ap(conn, endreason) \
-  _connection_mark_unattached_ap((conn), (endreason), __LINE__, _SHORT_FILE_)
+  connection_mark_unattached_ap_((conn), (endreason), __LINE__, SHORT_FILE__)
 
-void _connection_mark_unattached_ap(entry_connection_t *conn, int endreason,
+void connection_mark_unattached_ap_(entry_connection_t *conn, int endreason,
                                     int line, const char *file);
 int connection_edge_reached_eof(edge_connection_t *conn);
 int connection_edge_process_inbuf(edge_connection_t *conn,

+ 77 - 77
src/or/connection_or.c

@@ -16,7 +16,7 @@
  * Define this so we get channel internal functions, since we're implementing
  * part of a subclass (channel_tls_t).
  */
-#define _TOR_CHANNEL_INTERNAL
+#define TOR_CHANNEL_INTERNAL_
 #include "channel.h"
 #include "channeltls.h"
 #include "circuitbuild.h"
@@ -318,8 +318,8 @@ connection_or_change_state(or_connection_t *conn, uint8_t state)
 
   tor_assert(conn);
 
-  old_state = conn->_base.state;
-  conn->_base.state = state;
+  old_state = conn->base_.state;
+  conn->base_.state = state;
 
   if (conn->chan)
     channel_tls_handle_state_change_on_orconn(conn->chan, conn,
@@ -427,7 +427,7 @@ connection_or_process_inbuf(or_connection_t *conn)
   int ret = 0;
   tor_assert(conn);
 
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case OR_CONN_STATE_PROXY_HANDSHAKING:
       ret = connection_read_proxy_handshake(TO_CONN(conn));
 
@@ -449,7 +449,7 @@ connection_or_process_inbuf(or_connection_t *conn)
 #ifdef USE_BUFFEREVENTS
       if (tor_tls_server_got_renegotiate(conn->tls))
         connection_or_tls_renegotiated_cb(conn->tls, conn);
-      if (conn->_base.marked_for_close)
+      if (conn->base_.marked_for_close)
         return 0;
       /* fall through. */
 #endif
@@ -467,13 +467,13 @@ connection_or_process_inbuf(or_connection_t *conn)
    *
    * XXX024 Remove this check once we verify that the above paragraph is
    * 100% true. */
-  if (buf_datalen(conn->_base.inbuf) > MAX_OR_INBUF_WHEN_NONOPEN) {
+  if (buf_datalen(conn->base_.inbuf) > MAX_OR_INBUF_WHEN_NONOPEN) {
     log_fn(LOG_PROTOCOL_WARN, LD_NET, "Accumulated too much data (%d bytes) "
            "on nonopen OR connection %s %s:%u in state %s; closing.",
-           (int)buf_datalen(conn->_base.inbuf),
+           (int)buf_datalen(conn->base_.inbuf),
            connection_or_nonopen_was_started_here(conn) ? "to" : "from",
-           conn->_base.address, conn->_base.port,
-           conn_state_to_string(conn->_base.type, conn->_base.state));
+           conn->base_.address, conn->base_.port,
+           conn_state_to_string(conn->base_.type, conn->base_.state));
     connection_or_close_for_error(conn, 0);
     ret = -1;
   }
@@ -536,14 +536,14 @@ connection_or_finished_flushing(or_connection_t *conn)
   tor_assert(conn);
   assert_connection_ok(TO_CONN(conn),0);
 
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case OR_CONN_STATE_PROXY_HANDSHAKING:
     case OR_CONN_STATE_OPEN:
     case OR_CONN_STATE_OR_HANDSHAKING_V2:
     case OR_CONN_STATE_OR_HANDSHAKING_V3:
       break;
     default:
-      log_err(LD_BUG,"Called in unexpected state %d.", conn->_base.state);
+      log_err(LD_BUG,"Called in unexpected state %d.", conn->base_.state);
       tor_fragile_assert();
       return -1;
   }
@@ -691,8 +691,8 @@ connection_or_update_token_buckets_helper(or_connection_t *conn, int reset,
     cfg = ev_token_bucket_cfg_new(rate_per_tick, burst, rate_per_tick,
                                   burst, tick);
     old_cfg = conn->bucket_cfg;
-    if (conn->_base.bufev)
-      tor_set_bufferevent_rate_limit(conn->_base.bufev, cfg);
+    if (conn->base_.bufev)
+      tor_set_bufferevent_rate_limit(conn->base_.bufev, cfg);
     if (old_cfg)
       ev_token_bucket_cfg_free(old_cfg);
     conn->bucket_cfg = cfg;
@@ -741,15 +741,15 @@ connection_or_init_conn_from_address(or_connection_t *conn,
   connection_or_set_identity_digest(conn, id_digest);
   connection_or_update_token_buckets_helper(conn, 1, get_options());
 
-  conn->_base.port = port;
-  tor_addr_copy(&conn->_base.addr, addr);
+  conn->base_.port = port;
+  tor_addr_copy(&conn->base_.addr, addr);
   tor_addr_copy(&conn->real_addr, addr);
   if (r) {
     tor_addr_port_t node_ap;
     node_get_pref_orport(r, &node_ap);
     /* XXXX proposal 186 is making this more complex.  For now, a conn
        is canonical when it uses the _preferred_ address. */
-    if (tor_addr_eq(&conn->_base.addr, &node_ap.addr))
+    if (tor_addr_eq(&conn->base_.addr, &node_ap.addr))
       conn->is_canonical = 1;
     if (!started_here) {
       /* Override the addr/port, so our log messages will make sense.
@@ -762,12 +762,12 @@ connection_or_init_conn_from_address(or_connection_t *conn,
        * right IP address and port 56244, that wouldn't be as helpful. now we
        * log the "right" port too, so we know if it's moria1 or moria2.
        */
-      tor_addr_copy(&conn->_base.addr, &node_ap.addr);
-      conn->_base.port = node_ap.port;
+      tor_addr_copy(&conn->base_.addr, &node_ap.addr);
+      conn->base_.port = node_ap.port;
     }
     conn->nickname = tor_strdup(node_get_nickname(r));
-    tor_free(conn->_base.address);
-    conn->_base.address = tor_dup_addr(&node_ap.addr);
+    tor_free(conn->base_.address);
+    conn->base_.address = tor_dup_addr(&node_ap.addr);
   } else {
     const char *n;
     /* If we're an authoritative directory server, we may know a
@@ -781,8 +781,8 @@ connection_or_init_conn_from_address(or_connection_t *conn,
       base16_encode(conn->nickname+1, HEX_DIGEST_LEN+1,
                     conn->identity_digest, DIGEST_LEN);
     }
-    tor_free(conn->_base.address);
-    conn->_base.address = tor_dup_addr(addr);
+    tor_free(conn->base_.address);
+    conn->base_.address = tor_dup_addr(addr);
   }
 }
 
@@ -839,23 +839,23 @@ connection_or_group_set_badness(or_connection_t *head, int force)
   /* Pass 1: expire everything that's old, and see what the status of
    * everything else is. */
   for (or_conn = head; or_conn; or_conn = or_conn->next_with_same_id) {
-    if (or_conn->_base.marked_for_close ||
+    if (or_conn->base_.marked_for_close ||
         connection_or_is_bad_for_new_circs(or_conn))
       continue;
     if (force ||
-        or_conn->_base.timestamp_created + TIME_BEFORE_OR_CONN_IS_TOO_OLD
+        or_conn->base_.timestamp_created + TIME_BEFORE_OR_CONN_IS_TOO_OLD
           < now) {
       log_info(LD_OR,
                "Marking OR conn to %s:%d as too old for new circuits "
                "(fd %d, %d secs old).",
-               or_conn->_base.address, or_conn->_base.port, or_conn->_base.s,
-               (int)(now - or_conn->_base.timestamp_created));
+               or_conn->base_.address, or_conn->base_.port, or_conn->base_.s,
+               (int)(now - or_conn->base_.timestamp_created));
       connection_or_mark_bad_for_new_circs(or_conn);
     }
 
     if (connection_or_is_bad_for_new_circs(or_conn)) {
       ++n_old;
-    } else if (or_conn->_base.state != OR_CONN_STATE_OPEN) {
+    } else if (or_conn->base_.state != OR_CONN_STATE_OPEN) {
       ++n_inprogress;
     } else if (or_conn->is_canonical) {
       ++n_canonical;
@@ -867,10 +867,10 @@ connection_or_group_set_badness(or_connection_t *head, int force)
   /* Pass 2: We know how about how good the best connection is.
    * expire everything that's worse, and find the very best if we can. */
   for (or_conn = head; or_conn; or_conn = or_conn->next_with_same_id) {
-    if (or_conn->_base.marked_for_close ||
+    if (or_conn->base_.marked_for_close ||
         connection_or_is_bad_for_new_circs(or_conn))
       continue; /* This one doesn't need to be marked bad. */
-    if (or_conn->_base.state != OR_CONN_STATE_OPEN)
+    if (or_conn->base_.state != OR_CONN_STATE_OPEN)
       continue; /* Don't mark anything bad until we have seen what happens
                  * when the connection finishes. */
     if (n_canonical && !or_conn->is_canonical) {
@@ -880,8 +880,8 @@ connection_or_group_set_badness(or_connection_t *head, int force)
                "Marking OR conn to %s:%d as unsuitable for new circuits: "
                "(fd %d, %d secs old).  It is not canonical, and we have "
                "another connection to that OR that is.",
-               or_conn->_base.address, or_conn->_base.port, or_conn->_base.s,
-               (int)(now - or_conn->_base.timestamp_created));
+               or_conn->base_.address, or_conn->base_.port, or_conn->base_.s,
+               (int)(now - or_conn->base_.timestamp_created));
       connection_or_mark_bad_for_new_circs(or_conn);
       continue;
     }
@@ -913,9 +913,9 @@ connection_or_group_set_badness(or_connection_t *head, int force)
    *   "mostly harmless", so a fix can wait until somebody is bored.
    */
   for (or_conn = head; or_conn; or_conn = or_conn->next_with_same_id) {
-    if (or_conn->_base.marked_for_close ||
+    if (or_conn->base_.marked_for_close ||
         connection_or_is_bad_for_new_circs(or_conn) ||
-        or_conn->_base.state != OR_CONN_STATE_OPEN)
+        or_conn->base_.state != OR_CONN_STATE_OPEN)
       continue;
     if (or_conn != best &&
         channel_is_better(now,
@@ -928,9 +928,9 @@ connection_or_group_set_badness(or_connection_t *head, int force)
                  "Marking OR conn to %s:%d as unsuitable for new circuits: "
                  "(fd %d, %d secs old).  We have a better canonical one "
                  "(fd %d; %d secs old).",
-                 or_conn->_base.address, or_conn->_base.port, or_conn->_base.s,
-                 (int)(now - or_conn->_base.timestamp_created),
-                 best->_base.s, (int)(now - best->_base.timestamp_created));
+                 or_conn->base_.address, or_conn->base_.port, or_conn->base_.s,
+                 (int)(now - or_conn->base_.timestamp_created),
+                 best->base_.s, (int)(now - best->base_.timestamp_created));
         connection_or_mark_bad_for_new_circs(or_conn);
       } else if (!tor_addr_compare(&or_conn->real_addr,
                                    &best->real_addr, CMP_EXACT)) {
@@ -938,9 +938,9 @@ connection_or_group_set_badness(or_connection_t *head, int force)
                  "Marking OR conn to %s:%d as unsuitable for new circuits: "
                  "(fd %d, %d secs old).  We have a better one with the "
                  "same address (fd %d; %d secs old).",
-                 or_conn->_base.address, or_conn->_base.port, or_conn->_base.s,
-                 (int)(now - or_conn->_base.timestamp_created),
-                 best->_base.s, (int)(now - best->_base.timestamp_created));
+                 or_conn->base_.address, or_conn->base_.port, or_conn->base_.s,
+                 (int)(now - or_conn->base_.timestamp_created),
+                 best->base_.s, (int)(now - best->base_.timestamp_created));
         connection_or_mark_bad_for_new_circs(or_conn);
       }
     }
@@ -1074,7 +1074,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
     if (proxy_type != PROXY_NONE) {
       tor_addr_copy(&addr, &proxy_addr);
       port = proxy_port;
-      conn->_base.proxy_state = PROXY_INFANT;
+      conn->base_.proxy_state = PROXY_INFANT;
     }
   } else {
     /* get_proxy_addrport() might fail if we have a Bridge line that
@@ -1103,12 +1103,12 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
     return NULL;
   }
 
-  switch (connection_connect(TO_CONN(conn), conn->_base.address,
+  switch (connection_connect(TO_CONN(conn), conn->base_.address,
                              &addr, port, &socket_error)) {
     case -1:
       /* If the connection failed immediately, and we're using
        * a proxy, our proxy is down. Don't blame the Tor server. */
-      if (conn->_base.proxy_state == PROXY_INFANT)
+      if (conn->base_.proxy_state == PROXY_INFANT)
         entry_guard_register_connect_status(conn->identity_digest,
                                             0, 1, time(NULL));
       connection_or_connect_failed(conn,
@@ -1207,27 +1207,27 @@ connection_tls_start_handshake(or_connection_t *conn, int receiving)
 
   connection_or_change_state(conn, OR_CONN_STATE_TLS_HANDSHAKING);
   tor_assert(!conn->tls);
-  conn->tls = tor_tls_new(conn->_base.s, receiving);
+  conn->tls = tor_tls_new(conn->base_.s, receiving);
   if (!conn->tls) {
     log_warn(LD_BUG,"tor_tls_new failed. Closing.");
     return -1;
   }
   tor_tls_set_logged_address(conn->tls, // XXX client and relay?
-      escaped_safe_str(conn->_base.address));
+      escaped_safe_str(conn->base_.address));
 
 #ifdef USE_BUFFEREVENTS
   if (connection_type_uses_bufferevent(TO_CONN(conn))) {
     const int filtering = get_options()->UseFilteringSSLBufferevents;
     struct bufferevent *b =
-      tor_tls_init_bufferevent(conn->tls, conn->_base.bufev, conn->_base.s,
+      tor_tls_init_bufferevent(conn->tls, conn->base_.bufev, conn->base_.s,
                                receiving, filtering);
     if (!b) {
       log_warn(LD_BUG,"tor_tls_init_bufferevent failed. Closing.");
       return -1;
     }
-    conn->_base.bufev = b;
+    conn->base_.bufev = b;
     if (conn->bucket_cfg)
-      tor_set_bufferevent_rate_limit(conn->_base.bufev, conn->bucket_cfg);
+      tor_set_bufferevent_rate_limit(conn->base_.bufev, conn->bucket_cfg);
     connection_enable_rate_limiting(TO_CONN(conn));
 
     connection_configure_bufferevent_callbacks(TO_CONN(conn));
@@ -1239,7 +1239,7 @@ connection_tls_start_handshake(or_connection_t *conn, int receiving)
   }
 #endif
   connection_start_reading(TO_CONN(conn));
-  log_debug(LD_HANDSHAKE,"starting TLS handshake on fd %d", conn->_base.s);
+  log_debug(LD_HANDSHAKE,"starting TLS handshake on fd %d", conn->base_.s);
   note_crypto_pk_op(receiving ? TLS_HANDSHAKE_S : TLS_HANDSHAKE_C);
 
   IF_HAS_BUFFEREVENT(TO_CONN(conn), {
@@ -1281,12 +1281,12 @@ connection_tls_continue_handshake(or_connection_t *conn)
   int result;
   check_no_tls_errors();
  again:
-  if (conn->_base.state == OR_CONN_STATE_TLS_CLIENT_RENEGOTIATING) {
+  if (conn->base_.state == OR_CONN_STATE_TLS_CLIENT_RENEGOTIATING) {
     // log_notice(LD_OR, "Renegotiate with %p", conn->tls);
     result = tor_tls_renegotiate(conn->tls);
     // log_notice(LD_OR, "Result: %d", result);
   } else {
-    tor_assert(conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING);
+    tor_assert(conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING);
     // log_notice(LD_OR, "Continue handshake with %p", conn->tls);
     result = tor_tls_handshake(conn->tls);
     // log_notice(LD_OR, "Result: %d", result);
@@ -1299,7 +1299,7 @@ connection_tls_continue_handshake(or_connection_t *conn)
     case TOR_TLS_DONE:
       if (! tor_tls_used_v1_handshake(conn->tls)) {
         if (!tor_tls_is_server(conn->tls)) {
-          if (conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING) {
+          if (conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING) {
             if (tor_tls_received_v3_certificate(conn->tls)) {
               log_info(LD_OR, "Client got a v3 cert!  Moving on to v3 "
                          "handshake.");
@@ -1312,7 +1312,7 @@ connection_tls_continue_handshake(or_connection_t *conn)
               goto again;
             }
           }
-          // log_notice(LD_OR,"Done. state was %d.", conn->_base.state);
+          // log_notice(LD_OR,"Done. state was %d.", conn->base_.state);
         } else {
           /* v2/v3 handshake, but not a client. */
           log_debug(LD_OR, "Done with initial SSL handshake (server-side). "
@@ -1351,7 +1351,7 @@ connection_or_handle_event_cb(struct bufferevent *bufev, short event,
 
   /* XXXX cut-and-paste code; should become a function. */
   if (event & BEV_EVENT_CONNECTED) {
-    if (conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING) {
+    if (conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING) {
       if (tor_tls_finish_handshake(conn->tls) < 0) {
         log_warn(LD_OR, "Problem finishing handshake");
         connection_or_close_for_error(conn, 0);
@@ -1361,7 +1361,7 @@ connection_or_handle_event_cb(struct bufferevent *bufev, short event,
 
     if (! tor_tls_used_v1_handshake(conn->tls)) {
       if (!tor_tls_is_server(conn->tls)) {
-        if (conn->_base.state == OR_CONN_STATE_TLS_HANDSHAKING) {
+        if (conn->base_.state == OR_CONN_STATE_TLS_HANDSHAKING) {
           if (tor_tls_received_v3_certificate(conn->tls)) {
             log_info(LD_OR, "Client got a v3 cert!");
             if (connection_or_launch_v3_or_handshake(conn) < 0)
@@ -1371,7 +1371,7 @@ connection_or_handle_event_cb(struct bufferevent *bufev, short event,
             connection_or_change_state(conn,
                 OR_CONN_STATE_TLS_CLIENT_RENEGOTIATING);
             tor_tls_unblock_renegotiation(conn->tls);
-            if (bufferevent_ssl_renegotiate(conn->_base.bufev)<0) {
+            if (bufferevent_ssl_renegotiate(conn->base_.bufev)<0) {
               log_warn(LD_OR, "Start_renegotiating went badly.");
               connection_or_close_for_error(conn, 0);
             }
@@ -1431,7 +1431,7 @@ connection_or_handle_event_cb(struct bufferevent *bufev, short event,
 int
 connection_or_nonopen_was_started_here(or_connection_t *conn)
 {
-  tor_assert(conn->_base.type == CONN_TYPE_OR);
+  tor_assert(conn->base_.type == CONN_TYPE_OR);
   if (!conn->tls)
     return 1; /* it's still in proxy states or something */
   if (conn->handshake_state)
@@ -1473,8 +1473,8 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
   const or_options_t *options = get_options();
   int severity = server_mode(options) ? LOG_PROTOCOL_WARN : LOG_WARN;
   const char *safe_address =
-    started_here ? conn->_base.address :
-                   safe_str_client(conn->_base.address);
+    started_here ? conn->base_.address :
+                   safe_str_client(conn->base_.address);
   const char *conn_type = started_here ? "outgoing" : "incoming";
   int has_cert = 0;
 
@@ -1483,7 +1483,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
   if (started_here && !has_cert) {
     log_info(LD_HANDSHAKE,"Tried connecting to router at %s:%d, but it didn't "
              "send a cert! Closing.",
-             safe_address, conn->_base.port);
+             safe_address, conn->base_.port);
     return -1;
   } else if (!has_cert) {
     log_debug(LD_HANDSHAKE,"Got incoming connection with no certificate. "
@@ -1497,7 +1497,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
     if (started_here && v<0) {
       log_fn(severity,LD_HANDSHAKE,"Tried connecting to router at %s:%d: It"
              " has a cert but it's invalid. Closing.",
-             safe_address, conn->_base.port);
+             safe_address, conn->base_.port);
         return -1;
     } else if (v<0) {
       log_info(LD_HANDSHAKE,"Incoming connection gave us an invalid cert "
@@ -1505,7 +1505,7 @@ connection_or_check_valid_tls_handshake(or_connection_t *conn,
     } else {
       log_debug(LD_HANDSHAKE,
                 "The certificate seems to be valid on %s connection "
-                "with %s:%d", conn_type, safe_address, conn->_base.port);
+                "with %s:%d", conn_type, safe_address, conn->base_.port);
     }
     check_no_tls_errors();
   }
@@ -1558,10 +1558,10 @@ connection_or_client_learned_peer_id(or_connection_t *conn,
                   conn->identity_digest, DIGEST_LEN);
     log_info(LD_HANDSHAKE, "Connected to router %s at %s:%d without knowing "
                     "its key. Hoping for the best.",
-                    conn->nickname, conn->_base.address, conn->_base.port);
+                    conn->nickname, conn->base_.address, conn->base_.port);
     /* if it's a bridge and we didn't know its identity fingerprint, now
      * we do -- remember it for future attempts. */
-    learned_router_identity(&conn->_base.addr, conn->_base.port,
+    learned_router_identity(&conn->base_.addr, conn->base_.port,
                             (const char*)peer_id);
   }
 
@@ -1575,7 +1575,7 @@ connection_or_client_learned_peer_id(or_connection_t *conn,
     log_fn(severity, LD_HANDSHAKE,
            "Tried connecting to router at %s:%d, but identity key was not "
            "as expected: wanted %s but got %s.",
-           conn->_base.address, conn->_base.port, expected, seen);
+           conn->base_.address, conn->base_.port, expected, seen);
     entry_guard_register_connect_status(conn->identity_digest, 0, 1,
                                         time(NULL));
     control_event_or_conn_status(conn, OR_CONN_EVENT_FAILED,
@@ -1587,7 +1587,7 @@ connection_or_client_learned_peer_id(or_connection_t *conn,
     return -1;
   }
   if (authdir_mode_tests_reachability(options)) {
-    dirserv_orconn_tls_done(&conn->_base.addr, conn->_base.port,
+    dirserv_orconn_tls_done(&conn->base_.addr, conn->base_.port,
                             (const char*)peer_id);
   }
 
@@ -1629,7 +1629,7 @@ connection_tls_finish_handshake(or_connection_t *conn)
   log_debug(LD_HANDSHAKE,"%s tls handshake on %p with %s done. verifying.",
             started_here?"outgoing":"incoming",
             conn,
-            safe_str_client(conn->_base.address));
+            safe_str_client(conn->base_.address));
 
   directory_set_dirty();
 
@@ -1642,8 +1642,8 @@ connection_tls_finish_handshake(or_connection_t *conn)
   if (tor_tls_used_v1_handshake(conn->tls)) {
     conn->link_proto = 1;
     if (!started_here) {
-      connection_or_init_conn_from_address(conn, &conn->_base.addr,
-                                           conn->_base.port, digest_rcvd, 0);
+      connection_or_init_conn_from_address(conn, &conn->base_.addr,
+                                           conn->base_.port, digest_rcvd, 0);
     }
     tor_tls_block_renegotiation(conn->tls);
     return connection_or_set_state_open(conn);
@@ -1652,8 +1652,8 @@ connection_tls_finish_handshake(or_connection_t *conn)
     if (connection_init_or_handshake_state(conn, started_here) < 0)
       return -1;
     if (!started_here) {
-      connection_or_init_conn_from_address(conn, &conn->_base.addr,
-                                           conn->_base.port, digest_rcvd, 0);
+      connection_or_init_conn_from_address(conn, &conn->base_.addr,
+                                           conn->base_.port, digest_rcvd, 0);
     }
     return connection_or_send_versions(conn, 0);
   }
@@ -1826,7 +1826,7 @@ connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)
   if (conn->chan)
     channel_timestamp_active(TLS_CHAN_TO_BASE(conn->chan));
 
-  if (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
     or_handshake_state_record_cell(conn->handshake_state, cell, 0);
 
   if (cell->command != CELL_PADDING)
@@ -1848,7 +1848,7 @@ connection_or_write_var_cell_to_buf(const var_cell_t *cell,
   connection_write_to_buf(hdr, sizeof(hdr), TO_CONN(conn));
   connection_write_to_buf((char*)cell->payload,
                           cell->payload_len, TO_CONN(conn));
-  if (conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
+  if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
     or_handshake_state_record_var_cell(conn->handshake_state, cell, 0);
   if (cell->command != CELL_PADDING)
     conn->timestamp_last_added_nonpadding = approx_time();
@@ -1887,7 +1887,7 @@ connection_or_process_cells_from_inbuf(or_connection_t *conn)
   while (1) {
     log_debug(LD_OR,
               "%d: starting, inbuf_datalen %d (%d pending in tls object).",
-              conn->_base.s,(int)connection_get_inbuf_len(TO_CONN(conn)),
+              conn->base_.s,(int)connection_get_inbuf_len(TO_CONN(conn)),
               tor_tls_get_pending_bytes(conn->tls));
     if (connection_fetch_var_cell_from_buf(conn, &var_cell)) {
       if (!var_cell)
@@ -2000,10 +2000,10 @@ connection_or_send_netinfo(or_connection_t *conn)
   /* Their address. */
   out = cell.payload + 4;
   /* We use &conn->real_addr below, unless it hasn't yet been set. If it
-   * hasn't yet been set, we know that _base.addr hasn't been tampered with
+   * hasn't yet been set, we know that base_.addr hasn't been tampered with
    * yet either. */
   len = append_address_to_payload(out, !tor_addr_is_null(&conn->real_addr)
-                                       ? &conn->real_addr : &conn->_base.addr);
+                                       ? &conn->real_addr : &conn->base_.addr);
   if (len<0)
     return -1;
   out += len;
@@ -2050,7 +2050,7 @@ connection_or_send_certs_cell(or_connection_t *conn)
   ssize_t pos;
   int server_mode;
 
-  tor_assert(conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3);
+  tor_assert(conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3);
 
   if (! conn->handshake_state)
     return -1;
@@ -2097,7 +2097,7 @@ connection_or_send_auth_challenge_cell(or_connection_t *conn)
   var_cell_t *cell;
   uint8_t *cp;
   uint8_t challenge[OR_AUTH_CHALLENGE_LEN];
-  tor_assert(conn->_base.state == OR_CONN_STATE_OR_HANDSHAKING_V3);
+  tor_assert(conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3);
 
   if (! conn->handshake_state)
     return -1;

+ 2 - 2
src/or/connection_or.h

@@ -9,8 +9,8 @@
  * \brief Header file for connection_or.c.
  **/
 
-#ifndef _TOR_CONNECTION_OR_H
-#define _TOR_CONNECTION_OR_H
+#ifndef TOR_CONNECTION_OR_H
+#define TOR_CONNECTION_OR_H
 
 void connection_or_remove_from_identity_map(or_connection_t *conn);
 void connection_or_clear_identity_map(void);

+ 23 - 23
src/or/control.c

@@ -53,7 +53,7 @@
  * because it is used both as a list of v0 event types, and as indices
  * into the bitfield to determine which controllers want which events.
  */
-#define _EVENT_MIN             0x0001
+#define EVENT_MIN_             0x0001
 #define EVENT_CIRCUIT_STATUS   0x0001
 #define EVENT_STREAM_STATUS    0x0002
 #define EVENT_OR_CONN_STATUS   0x0003
@@ -79,8 +79,8 @@
 #define EVENT_BUILDTIMEOUT_SET     0x0017
 #define EVENT_SIGNAL           0x0018
 #define EVENT_CONF_CHANGED     0x0019
-#define _EVENT_MAX             0x0019
-/* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */
+#define EVENT_MAX_             0x0019
+/* If EVENT_MAX_ ever hits 0x0020, we need to make the mask wider. */
 
 /** Bitfield: The bit 1&lt;&lt;e is set if <b>any</b> open control
  * connection is interested in events of type <b>e</b>.  We use this
@@ -595,7 +595,7 @@ send_control_event_string(uint16_t event, event_format_t which,
 {
   smartlist_t *conns = get_connection_array();
   (void)which;
-  tor_assert(event >= _EVENT_MIN && event <= _EVENT_MAX);
+  tor_assert(event >= EVENT_MIN_ && event <= EVENT_MAX_);
 
   SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) {
     if (conn->type == CONN_TYPE_CONTROL &&
@@ -1218,9 +1218,9 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
   connection_mark_for_close(TO_CONN(conn));
   return 0;
  ok:
-  log_info(LD_CONTROL, "Authenticated control connection (%d)", conn->_base.s);
+  log_info(LD_CONTROL, "Authenticated control connection (%d)", conn->base_.s);
   send_control_done(conn);
-  conn->_base.state = CONTROL_CONN_STATE_OPEN;
+  conn->base_.state = CONTROL_CONN_STATE_OPEN;
   tor_free(password);
   if (sl) { /* clean up */
     SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
@@ -1323,7 +1323,7 @@ handle_control_takeownership(control_connection_t *conn, uint32_t len,
 
   log_info(LD_CONTROL, "Control connection %d has taken ownership of this "
            "Tor instance.",
-           (int)(conn->_base.s));
+           (int)(conn->base_.s));
 
   send_control_done(conn);
   return 0;
@@ -1880,11 +1880,11 @@ circuit_describe_status_for_controller(origin_circuit_t *circ)
   }
 
   smartlist_add_asprintf(descparts, "PURPOSE=%s",
-                    circuit_purpose_to_controller_string(circ->_base.purpose));
+                    circuit_purpose_to_controller_string(circ->base_.purpose));
 
   {
     const char *hs_state =
-      circuit_purpose_to_controller_hs_state_string(circ->_base.purpose);
+      circuit_purpose_to_controller_hs_state_string(circ->base_.purpose);
 
     if (hs_state != NULL) {
       smartlist_add_asprintf(descparts, "HS_STATE=%s", hs_state);
@@ -1898,7 +1898,7 @@ circuit_describe_status_for_controller(origin_circuit_t *circ)
 
   {
     char tbuf[ISO_TIME_USEC_LEN+1];
-    format_iso_time_nospace_usec(tbuf, &circ->_base.timestamp_created);
+    format_iso_time_nospace_usec(tbuf, &circ->base_.timestamp_created);
 
     smartlist_add_asprintf(descparts, "TIME_CREATED=%s", tbuf);
   }
@@ -1922,7 +1922,7 @@ getinfo_helper_events(control_connection_t *control_conn,
   if (!strcmp(question, "circuit-status")) {
     circuit_t *circ_;
     smartlist_t *status = smartlist_new();
-    for (circ_ = _circuit_get_global_list(); circ_; circ_ = circ_->next) {
+    for (circ_ = circuit_get_global_list_(); circ_; circ_ = circ_->next) {
       origin_circuit_t *circ;
       char *circdesc;
       const char *state;
@@ -1930,7 +1930,7 @@ getinfo_helper_events(control_connection_t *control_conn,
         continue;
       circ = TO_ORIGIN_CIRCUIT(circ_);
 
-      if (circ->_base.state == CIRCUIT_STATE_OPEN)
+      if (circ->base_.state == CIRCUIT_STATE_OPEN)
         state = "BUILT";
       else if (circ->cpath)
         state = "EXTENDED";
@@ -2007,7 +2007,7 @@ getinfo_helper_events(control_connection_t *control_conn,
       if (base_conn->type != CONN_TYPE_OR || base_conn->marked_for_close)
         continue;
       conn = TO_OR_CONN(base_conn);
-      if (conn->_base.state == OR_CONN_STATE_OPEN)
+      if (conn->base_.state == OR_CONN_STATE_OPEN)
         state = "CONNECTED";
       else if (conn->nickname)
         state = "LAUNCHED";
@@ -2534,7 +2534,7 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len,
       goto done;
     }
   } else {
-    if (circ->_base.state == CIRCUIT_STATE_OPEN) {
+    if (circ->base_.state == CIRCUIT_STATE_OPEN) {
       int err_reason = 0;
       circuit_set_state(TO_CIRCUIT(circ), CIRCUIT_STATE_BUILDING);
       if ((err_reason = circuit_send_next_onion_skin(circ)) < 0) {
@@ -2667,7 +2667,7 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len,
     TO_CONN(edge_conn)->state = AP_CONN_STATE_CONTROLLER_WAIT;
   }
 
-  if (circ && (circ->_base.state != CIRCUIT_STATE_OPEN)) {
+  if (circ && (circ->base_.state != CIRCUIT_STATE_OPEN)) {
     connection_write_str_to_buf(
                     "551 Can't attach stream to non-open origin circuit\r\n",
                     conn);
@@ -3235,7 +3235,7 @@ connection_control_closed(control_connection_t *conn)
 static int
 is_valid_initial_command(control_connection_t *conn, const char *cmd)
 {
-  if (conn->_base.state == CONTROL_CONN_STATE_OPEN)
+  if (conn->base_.state == CONTROL_CONN_STATE_OPEN)
     return 1;
   if (!strcasecmp(cmd, "PROTOCOLINFO"))
     return (!conn->have_sent_protocolinfo &&
@@ -3280,8 +3280,8 @@ connection_control_process_inbuf(control_connection_t *conn)
   char *args;
 
   tor_assert(conn);
-  tor_assert(conn->_base.state == CONTROL_CONN_STATE_OPEN ||
-             conn->_base.state == CONTROL_CONN_STATE_NEEDAUTH);
+  tor_assert(conn->base_.state == CONTROL_CONN_STATE_OPEN ||
+             conn->base_.state == CONTROL_CONN_STATE_NEEDAUTH);
 
   if (!conn->incoming_cmd) {
     conn->incoming_cmd = tor_malloc(1024);
@@ -3289,7 +3289,7 @@ connection_control_process_inbuf(control_connection_t *conn)
     conn->incoming_cmd_cur_len = 0;
   }
 
-  if (conn->_base.state == CONTROL_CONN_STATE_NEEDAUTH &&
+  if (conn->base_.state == CONTROL_CONN_STATE_NEEDAUTH &&
       peek_connection_has_control0_command(TO_CONN(conn))) {
     /* Detect v0 commands and send a "no more v0" message. */
     size_t body_len;
@@ -3388,7 +3388,7 @@ connection_control_process_inbuf(control_connection_t *conn)
     return 0;
   }
 
-  if (conn->_base.state == CONTROL_CONN_STATE_NEEDAUTH &&
+  if (conn->base_.state == CONTROL_CONN_STATE_NEEDAUTH &&
       !is_valid_initial_command(conn, conn->incoming_cmd)) {
     connection_write_str_to_buf("514 Authentication required.\r\n", conn);
     connection_mark_for_close(TO_CONN(conn));
@@ -3792,7 +3792,7 @@ orconn_target_get_name(char *name, size_t len, or_connection_t *conn)
                   DIGEST_LEN);
   } else {
     tor_snprintf(name, len, "%s:%d",
-                 conn->_base.address, conn->_base.port);
+                 conn->base_.address, conn->base_.port);
   }
 }
 
@@ -3858,7 +3858,7 @@ control_event_stream_bandwidth(edge_connection_t *edge_conn)
 
     send_control_event(EVENT_STREAM_BANDWIDTH_USED, ALL_FORMATS,
                        "650 STREAM_BW "U64_FORMAT" %lu %lu\r\n",
-                       U64_PRINTF_ARG(edge_conn->_base.global_identifier),
+                       U64_PRINTF_ARG(edge_conn->base_.global_identifier),
                        (unsigned long)edge_conn->n_read,
                        (unsigned long)edge_conn->n_written);
 
@@ -3887,7 +3887,7 @@ control_event_stream_bandwidth_used(void)
 
         send_control_event(EVENT_STREAM_BANDWIDTH_USED, ALL_FORMATS,
                            "650 STREAM_BW "U64_FORMAT" %lu %lu\r\n",
-                           U64_PRINTF_ARG(edge_conn->_base.global_identifier),
+                           U64_PRINTF_ARG(edge_conn->base_.global_identifier),
                            (unsigned long)edge_conn->n_read,
                            (unsigned long)edge_conn->n_written);
 

+ 2 - 2
src/or/control.h

@@ -9,8 +9,8 @@
  * \brief Header file for control.c.
  **/
 
-#ifndef _TOR_CONTROL_H
-#define _TOR_CONTROL_H
+#ifndef TOR_CONTROL_H
+#define TOR_CONTROL_H
 
 void control_update_global_event_mask(void);
 void control_adjust_event_log_severity(void);

+ 2 - 2
src/or/cpuworker.h

@@ -9,8 +9,8 @@
  * \brief Header file for cpuworker.c.
  **/
 
-#ifndef _TOR_CPUWORKER_H
-#define _TOR_CPUWORKER_H
+#ifndef TOR_CPUWORKER_H
+#define TOR_CPUWORKER_H
 
 void cpu_init(void);
 void cpuworkers_rotate(void);

+ 156 - 156
src/or/directory.c

@@ -246,7 +246,7 @@ directories_have_accepted_server_descriptor(void)
   smartlist_t *servers = router_get_trusted_dir_servers();
   const or_options_t *options = get_options();
   SMARTLIST_FOREACH(servers, trusted_dir_server_t *, d, {
-    if ((d->type & options->_PublishServerDescriptor) &&
+    if ((d->type & options->PublishServerDescriptor_) &&
         d->has_accepted_serverdesc) {
       return 1;
     }
@@ -645,8 +645,8 @@ directory_conn_is_self_reachability_test(dir_connection_t *conn)
     const routerinfo_t *me = router_get_my_routerinfo();
     if (me &&
         router_digest_is_me(conn->identity_digest) &&
-        tor_addr_eq_ipv4h(&conn->_base.addr, me->addr) && /*XXXX prop 118*/
-        me->dir_port == conn->_base.port)
+        tor_addr_eq_ipv4h(&conn->base_.addr, me->addr) && /*XXXX prop 118*/
+        me->dir_port == conn->base_.port)
       return 1;
   }
   return 0;
@@ -664,35 +664,35 @@ connection_dir_request_failed(dir_connection_t *conn)
   }
   if (!entry_list_is_constrained(get_options()))
     router_set_status(conn->identity_digest, 0); /* don't try him again */
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
     log_info(LD_DIR, "Giving up on directory server at '%s'; retrying",
-             conn->_base.address);
+             conn->base_.address);
     connection_dir_download_v2_networkstatus_failed(conn, -1);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
-             conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
+             conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
     log_info(LD_DIR, "Giving up on serverdesc/extrainfo fetch from "
              "directory server at '%s'; retrying",
-             conn->_base.address);
+             conn->base_.address);
     if (conn->router_purpose == ROUTER_PURPOSE_BRIDGE)
       connection_dir_bridge_routerdesc_failed(conn);
     connection_dir_download_routerdesc_failed(conn);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
     if (conn->requested_resource)
       networkstatus_consensus_download_failed(0, conn->requested_resource);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
     log_info(LD_DIR, "Giving up on certificate fetch from directory server "
              "at '%s'; retrying",
-             conn->_base.address);
+             conn->base_.address);
     connection_dir_download_cert_failed(conn, 0);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
     log_info(LD_DIR, "Giving up downloading detached signatures from '%s'",
-             conn->_base.address);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
+             conn->base_.address);
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
     log_info(LD_DIR, "Giving up downloading votes from '%s'",
-             conn->_base.address);
-  } else if (conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
+             conn->base_.address);
+  } else if (conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
     log_info(LD_DIR, "Giving up on downloading microdescriptors from "
-             " directory server at '%s'; will retry", conn->_base.address);
+             " directory server at '%s'; will retry", conn->base_.address);
     connection_dir_download_routerdesc_failed(conn);
   }
 }
@@ -718,7 +718,7 @@ connection_dir_download_v2_networkstatus_failed(dir_connection_t *conn,
     smartlist_t *trusted_dirs = router_get_trusted_dir_servers();
     SMARTLIST_FOREACH(trusted_dirs, trusted_dir_server_t *, ds,
                       download_status_failed(&ds->v2_ns_dl_status, 0));
-    directory_get_from_dirserver(conn->_base.purpose, conn->router_purpose,
+    directory_get_from_dirserver(conn->base_.purpose, conn->router_purpose,
                                  "all.z", 0 /* don't retry_if_no_servers */);
   } else if (!strcmpstart(conn->requested_resource, "fp/")) {
     /* We were trying to download by fingerprint; mark them all as having
@@ -763,9 +763,9 @@ connection_dir_download_routerdesc_failed(dir_connection_t *conn)
 
   /* No need to relaunch descriptor downloads here: we already do it
    * every 10 or 60 seconds (FOO_DESCRIPTOR_RETRY_INTERVAL) in main.c. */
-  tor_assert(conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
-             conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
-             conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC);
+  tor_assert(conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
+             conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
+             conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC);
 
   (void) conn;
 }
@@ -789,7 +789,7 @@ connection_dir_bridge_routerdesc_failed(dir_connection_t *conn)
                                         + strlen("fp/"),
                                        which, NULL, 0);
 
-  tor_assert(conn->_base.purpose != DIR_PURPOSE_FETCH_EXTRAINFO);
+  tor_assert(conn->base_.purpose != DIR_PURPOSE_FETCH_EXTRAINFO);
   if (smartlist_len(which)) {
     connection_dir_retry_bridges(which);
     SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
@@ -802,7 +802,7 @@ static void
 connection_dir_download_cert_failed(dir_connection_t *conn, int status)
 {
   smartlist_t *failed;
-  tor_assert(conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE);
+  tor_assert(conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE);
 
   if (!conn->requested_resource)
     return;
@@ -934,16 +934,16 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
   conn = dir_connection_new(tor_addr_family(&addr));
 
   /* set up conn so it's got all the data we need to remember */
-  tor_addr_copy(&conn->_base.addr, &addr);
-  conn->_base.port = use_begindir ? or_port : dir_port;
-  conn->_base.address = tor_strdup(address);
+  tor_addr_copy(&conn->base_.addr, &addr);
+  conn->base_.port = use_begindir ? or_port : dir_port;
+  conn->base_.address = tor_strdup(address);
   memcpy(conn->identity_digest, digest, DIGEST_LEN);
 
-  conn->_base.purpose = dir_purpose;
+  conn->base_.purpose = dir_purpose;
   conn->router_purpose = router_purpose;
 
   /* give it an initial state */
-  conn->_base.state = DIR_CONN_STATE_CONNECTING;
+  conn->base_.state = DIR_CONN_STATE_CONNECTING;
 
   /* decide whether we can learn our IP address from this conn */
   /* XXXX This is a bad name for this field now. */
@@ -961,7 +961,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
       dir_port = options->HTTPProxyPort;
     }
 
-    switch (connection_connect(TO_CONN(conn), conn->_base.address, &addr,
+    switch (connection_connect(TO_CONN(conn), conn->base_.address, &addr,
                                dir_port, &socket_error)) {
       case -1:
         connection_dir_request_failed(conn); /* retry if we want */
@@ -971,7 +971,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
         return;
       case 1:
         /* start flushing conn */
-        conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING;
+        conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING;
         /* fall through */
       case 0:
         /* queue the command on the outbuf */
@@ -994,7 +994,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
     if (anonymized_connection && use_begindir)
       rep_hist_note_used_internal(time(NULL), 0, 1);
     else if (anonymized_connection && !use_begindir)
-      rep_hist_note_used_port(time(NULL), conn->_base.port);
+      rep_hist_note_used_port(time(NULL), conn->base_.port);
 
     /* make an AP connection
      * populate it and add it at the right state
@@ -1002,7 +1002,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
      */
     linked_conn =
       connection_ap_make_link(TO_CONN(conn),
-                              conn->_base.address, conn->_base.port,
+                              conn->base_.address, conn->base_.port,
                               digest,
                               SESSION_GROUP_DIRCONN, iso_flags,
                               use_begindir, conn->dirconn_direct);
@@ -1017,7 +1017,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
       connection_mark_for_close(TO_CONN(conn));
       return;
     }
-    conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING;
+    conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING;
     /* queue the command on the outbuf */
     directory_send_command(conn, dir_purpose, 0, resource,
                            payload, payload_len,
@@ -1050,7 +1050,7 @@ connection_dir_is_encrypted(dir_connection_t *conn)
  * sort strings alphabetically
  */
 static int
-_compare_strs(const void **a, const void **b)
+compare_strs_(const void **a, const void **b)
 {
   const char *s1 = *a, *s2 = *b;
   return strcmp(s1, s2);
@@ -1097,7 +1097,7 @@ directory_get_consensus_url(const char *resource)
                       ds->v3_identity_digest, CONDITIONAL_CONSENSUS_FPR_LEN);
         smartlist_add(authority_digests, hex);
     } SMARTLIST_FOREACH_END(ds);
-    smartlist_sort(authority_digests, _compare_strs);
+    smartlist_sort(authority_digests, compare_strs_);
     authority_id_list = smartlist_join_strings(authority_digests,
                                                "+", 0, NULL);
 
@@ -1128,18 +1128,18 @@ directory_send_command(dir_connection_t *conn,
   const char *httpcommand = NULL;
 
   tor_assert(conn);
-  tor_assert(conn->_base.type == CONN_TYPE_DIR);
+  tor_assert(conn->base_.type == CONN_TYPE_DIR);
 
   tor_free(conn->requested_resource);
   if (resource)
     conn->requested_resource = tor_strdup(resource);
 
   /* come up with a string for which Host: we want */
-  if (conn->_base.port == 80) {
-    strlcpy(hoststring, conn->_base.address, sizeof(hoststring));
+  if (conn->base_.port == 80) {
+    strlcpy(hoststring, conn->base_.address, sizeof(hoststring));
   } else {
     tor_snprintf(hoststring, sizeof(hoststring),"%s:%d",
-                 conn->_base.address, conn->_base.port);
+                 conn->base_.address, conn->base_.port);
   }
 
   /* Format if-modified-since */
@@ -1574,9 +1574,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
   compress_method_t compression;
   int plausible;
   int skewed=0;
-  int allow_partial = (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
-                       conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
-                       conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC);
+  int allow_partial = (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
+                       conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO ||
+                       conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC);
   int was_compressed=0;
   time_t now = time(NULL);
 
@@ -1587,7 +1587,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     case -1: /* overflow */
       log_warn(LD_PROTOCOL,
                "'fetch' response too large (server '%s:%d'). Closing.",
-               conn->_base.address, conn->_base.port);
+               conn->base_.address, conn->base_.port);
       return -1;
     case 0:
       log_info(LD_HTTP,
@@ -1600,7 +1600,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
   if (parse_http_response(headers, &status_code, &date_header,
                           &compression, &reason) < 0) {
     log_warn(LD_HTTP,"Unparseable headers (server '%s:%d'). Closing.",
-             conn->_base.address, conn->_base.port);
+             conn->base_.address, conn->base_.port);
     tor_free(body); tor_free(headers);
     return -1;
   }
@@ -1609,9 +1609,9 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
   log_debug(LD_DIR,
             "Received response from directory server '%s:%d': %d %s "
             "(purpose: %d)",
-            conn->_base.address, conn->_base.port, status_code,
+            conn->base_.address, conn->base_.port, status_code,
             escaped(reason),
-            conn->_base.purpose);
+            conn->base_.purpose);
 
   /* now check if it's got any hints for us about our IP address. */
   if (conn->dirconn_direct) {
@@ -1628,7 +1628,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
      * and the date header.  (We used to check now-date_header, but that's
      * inaccurate if we spend a lot of time downloading.)
      */
-    delta = conn->_base.timestamp_lastwritten - date_header;
+    delta = conn->base_.timestamp_lastwritten - date_header;
     if (labs(delta)>ALLOW_DIRECTORY_TIME_SKEW) {
       char dbuf[64];
       int trusted = router_digest_is_trusted_dir(conn->identity_digest);
@@ -1639,14 +1639,14 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
              "It seems that our clock is %s by %s, or that theirs is %s. "
              "Tor requires an accurate clock to work: please check your time, "
              "timezone, and date settings.",
-             conn->_base.address, conn->_base.port,
+             conn->base_.address, conn->base_.port,
              delta>0 ? "ahead" : "behind", dbuf,
              delta>0 ? "behind" : "ahead");
       skewed = 1; /* don't check the recommended-versions line */
       if (trusted)
         control_event_general_status(LOG_WARN,
                                  "CLOCK_SKEW SKEW=%ld SOURCE=DIRSERV:%s:%d",
-                                 delta, conn->_base.address, conn->_base.port);
+                                 delta, conn->base_.address, conn->base_.port);
     } else {
       log_debug(LD_HTTP, "Time on received directory is within tolerance; "
                 "we are %ld seconds skewed.  (That's okay.)", delta);
@@ -1660,8 +1660,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     const char *id_digest = conn->identity_digest;
     log_info(LD_DIR,"Received http status code %d (%s) from server "
              "'%s:%d'. I'll try again soon.",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port);
     if ((rs = router_get_mutable_consensus_status_by_id(id_digest)))
       rs->last_dir_503_at = now;
     if ((ds = router_get_trusteddirserver_by_digest(id_digest)))
@@ -1671,7 +1671,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     return -1;
   }
 
-  plausible = body_is_plausible(body, body_len, conn->_base.purpose);
+  plausible = body_is_plausible(body, body_len, conn->base_.purpose);
   if (compression != NO_METHOD || !plausible) {
     char *new_body = NULL;
     size_t new_len = 0;
@@ -1698,7 +1698,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
 
       log_info(LD_HTTP, "HTTP body from server '%s:%d' was labeled %s, "
                "but it seems to be %s.%s",
-               conn->_base.address, conn->_base.port, description1,
+               conn->base_.address, conn->base_.port, description1,
                description2,
                (compression>0 && guessed>0)?"  Trying both.":"");
     }
@@ -1718,7 +1718,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     if (!plausible && !new_body) {
       log_fn(LOG_PROTOCOL_WARN, LD_HTTP,
              "Unable to decompress HTTP body (server '%s:%d').",
-             conn->_base.address, conn->_base.port);
+             conn->base_.address, conn->base_.port);
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }
@@ -1730,12 +1730,12 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_V2_NETWORKSTATUS) {
     smartlist_t *which = NULL;
     v2_networkstatus_source_t source;
     char *cp;
     log_info(LD_DIR,"Received networkstatus objects (size %d) from server "
-             "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
+             "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
     if (status_code != 200) {
       static ratelim_t warning_limit = RATELIM_INIT(3600);
       char *m;
@@ -1744,8 +1744,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
                  "Received http status code %d (%s) from server "
                  "'%s:%d' while fetching \"/tor/status/%s\". "
                  "I'll try again soon.%s",
-                 status_code, escaped(reason), conn->_base.address,
-                 conn->_base.port, conn->requested_resource, m);
+                 status_code, escaped(reason), conn->base_.address,
+                 conn->base_.port, conn->requested_resource, m);
         tor_free(m);
       }
       tor_free(body); tor_free(headers); tor_free(reason);
@@ -1801,7 +1801,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_CONSENSUS) {
     int r;
     const char *flavname = conn->requested_resource;
     if (status_code != 200) {
@@ -1809,19 +1809,19 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log(severity, LD_DIR,
           "Received http status code %d (%s) from server "
           "'%s:%d' while fetching consensus directory.",
-           status_code, escaped(reason), conn->_base.address,
-           conn->_base.port);
+           status_code, escaped(reason), conn->base_.address,
+           conn->base_.port);
       tor_free(body); tor_free(headers); tor_free(reason);
       networkstatus_consensus_download_failed(status_code, flavname);
       return -1;
     }
     log_info(LD_DIR,"Received consensus directory (size %d) from server "
-             "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
+             "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
     if ((r=networkstatus_set_current_consensus(body, flavname, 0))<0) {
       log_fn(r<-1?LOG_WARN:LOG_INFO, LD_DIR,
              "Unable to load %s consensus directory downloaded from "
              "server '%s:%d'. I'll try again soon.",
-             flavname, conn->_base.address, conn->_base.port);
+             flavname, conn->base_.address, conn->base_.port);
       tor_free(body); tor_free(headers); tor_free(reason);
       networkstatus_consensus_download_failed(0, flavname);
       return -1;
@@ -1834,19 +1834,19 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     log_info(LD_DIR, "Successfully loaded consensus.");
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_CERTIFICATE) {
     if (status_code != 200) {
       log_warn(LD_DIR,
           "Received http status code %d (%s) from server "
           "'%s:%d' while fetching \"/tor/keys/%s\".",
-           status_code, escaped(reason), conn->_base.address,
-           conn->_base.port, conn->requested_resource);
+           status_code, escaped(reason), conn->base_.address,
+           conn->base_.port, conn->requested_resource);
       connection_dir_download_cert_failed(conn, status_code);
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }
     log_info(LD_DIR,"Received authority certificates (size %d) from server "
-             "'%s:%d'", (int)body_len, conn->_base.address, conn->_base.port);
+             "'%s:%d'", (int)body_len, conn->base_.address, conn->base_.port);
     if (trusted_dirs_load_certs_from_string(body, 0, 1)<0) {
       log_warn(LD_DIR, "Unable to parse fetched certificates");
       /* if we fetched more than one and only some failed, the successful
@@ -1857,17 +1857,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log_info(LD_DIR, "Successfully loaded certificates from fetch.");
     }
   }
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_STATUS_VOTE) {
     const char *msg;
     int st;
     log_info(LD_DIR,"Got votes (size %d) from server %s:%d",
-             (int)body_len, conn->_base.address, conn->_base.port);
+             (int)body_len, conn->base_.address, conn->base_.port);
     if (status_code != 200) {
       log_warn(LD_DIR,
              "Received http status code %d (%s) from server "
              "'%s:%d' while fetching \"/tor/status-vote/next/%s.z\".",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port, conn->requested_resource);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port, conn->requested_resource);
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }
@@ -1878,35 +1878,35 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log_info(LD_DIR, "Added vote(s) successfully [msg: %s]", msg);
     }
   }
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_DETACHED_SIGNATURES) {
     const char *msg = NULL;
     log_info(LD_DIR,"Got detached signatures (size %d) from server %s:%d",
-             (int)body_len, conn->_base.address, conn->_base.port);
+             (int)body_len, conn->base_.address, conn->base_.port);
     if (status_code != 200) {
       log_warn(LD_DIR,
         "Received http status code %d (%s) from server '%s:%d' while fetching "
         "\"/tor/status-vote/next/consensus-signatures.z\".",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port);
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }
-    if (dirvote_add_signatures(body, conn->_base.address, &msg)<0) {
+    if (dirvote_add_signatures(body, conn->base_.address, &msg)<0) {
       log_warn(LD_DIR, "Problem adding detached signatures from %s:%d: %s",
-               conn->_base.address, conn->_base.port, msg?msg:"???");
+               conn->base_.address, conn->base_.port, msg?msg:"???");
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
-      conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
-    int was_ei = conn->_base.purpose == DIR_PURPOSE_FETCH_EXTRAINFO;
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_SERVERDESC ||
+      conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO) {
+    int was_ei = conn->base_.purpose == DIR_PURPOSE_FETCH_EXTRAINFO;
     smartlist_t *which = NULL;
     int n_asked_for = 0;
     int descriptor_digests = conn->requested_resource &&
                              !strcmpstart(conn->requested_resource,"d/");
     log_info(LD_DIR,"Received %s (size %d) from server '%s:%d'",
              was_ei ? "extra server info" : "server info",
-             (int)body_len, conn->_base.address, conn->_base.port);
+             (int)body_len, conn->base_.address, conn->base_.port);
     if (conn->requested_resource &&
         (!strcmpstart(conn->requested_resource,"d/") ||
          !strcmpstart(conn->requested_resource,"fp/"))) {
@@ -1924,8 +1924,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log_fn(dir_okay ? LOG_INFO : LOG_WARN, LD_DIR,
              "Received http status code %d (%s) from server '%s:%d' "
              "while fetching \"/tor/server/%s\". I'll try again soon.",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port, conn->requested_resource);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port, conn->requested_resource);
       if (!which) {
         connection_dir_download_routerdesc_failed(conn);
       } else {
@@ -1959,7 +1959,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
         //                       descriptor_digests, conn->router_purpose);
         if (load_downloaded_routers(body, which, descriptor_digests,
                                 conn->router_purpose,
-                                conn->_base.address))
+                                conn->base_.address))
           directory_info_has_arrived(now, 0);
       }
     }
@@ -1967,7 +1967,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log_info(LD_DIR, "Received %d/%d %s requested from %s:%d",
                n_asked_for-smartlist_len(which), n_asked_for,
                was_ei ? "extra-info documents" : "router descriptors",
-               conn->_base.address, (int)conn->_base.port);
+               conn->base_.address, (int)conn->base_.port);
       if (smartlist_len(which)) {
         dir_routerdesc_download_failed(which, status_code,
                                        conn->router_purpose,
@@ -1979,12 +1979,12 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     if (directory_conn_is_self_reachability_test(conn))
       router_dirport_found_reachable();
   }
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_MICRODESC) {
     smartlist_t *which = NULL;
     log_info(LD_DIR,"Received answer to microdescriptor request (status %d, "
              "size %d) from server '%s:%d'",
-             status_code, (int)body_len, conn->_base.address,
-             conn->_base.port);
+             status_code, (int)body_len, conn->base_.address,
+             conn->base_.port);
     tor_assert(conn->requested_resource &&
                !strcmpstart(conn->requested_resource, "d/"));
     which = smartlist_new();
@@ -1995,8 +1995,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       log_info(LD_DIR, "Received status code %d (%s) from server "
                "'%s:%d' while fetching \"/tor/micro/%s\".  I'll try again "
                "soon.",
-               status_code, escaped(reason), conn->_base.address,
-               (int)conn->_base.port, conn->requested_resource);
+               status_code, escaped(reason), conn->base_.address,
+               (int)conn->base_.port, conn->requested_resource);
       dir_microdesc_download_failed(which, status_code);
       SMARTLIST_FOREACH(which, char *, cp, tor_free(cp));
       smartlist_free(which);
@@ -2017,7 +2017,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_DIR) {
+  if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_DIR) {
     switch (status_code) {
       case 200: {
           trusted_dir_server_t *ds =
@@ -2043,7 +2043,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
                    "descriptor: finished.");
           control_event_server_status(
                       LOG_NOTICE, "ACCEPTED_SERVER_DESCRIPTOR DIRAUTH=%s:%d",
-                      conn->_base.address, conn->_base.port);
+                      conn->base_.address, conn->base_.port);
 
           ds->has_accepted_serverdesc = 1;
           if (directories_have_accepted_server_descriptor())
@@ -2053,72 +2053,72 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       case 400:
         log_warn(LD_GENERAL,"http status 400 (%s) response from "
                  "dirserver '%s:%d'. Please correct.",
-                 escaped(reason), conn->_base.address, conn->_base.port);
+                 escaped(reason), conn->base_.address, conn->base_.port);
         control_event_server_status(LOG_WARN,
                       "BAD_SERVER_DESCRIPTOR DIRAUTH=%s:%d REASON=\"%s\"",
-                      conn->_base.address, conn->_base.port, escaped(reason));
+                      conn->base_.address, conn->base_.port, escaped(reason));
         break;
       default:
         log_warn(LD_GENERAL,
              "http status %d (%s) reason unexpected while uploading "
              "descriptor to server '%s:%d').",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port);
         break;
     }
     /* return 0 in all cases, since we don't want to mark any
      * dirservers down just because they don't like us. */
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_VOTE) {
+  if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_VOTE) {
     switch (status_code) {
       case 200: {
         log_notice(LD_DIR,"Uploaded a vote to dirserver %s:%d",
-                   conn->_base.address, conn->_base.port);
+                   conn->base_.address, conn->base_.port);
         }
         break;
       case 400:
         log_warn(LD_DIR,"http status 400 (%s) response after uploading "
                  "vote to dirserver '%s:%d'. Please correct.",
-                 escaped(reason), conn->_base.address, conn->_base.port);
+                 escaped(reason), conn->base_.address, conn->base_.port);
         break;
       default:
         log_warn(LD_GENERAL,
              "http status %d (%s) reason unexpected while uploading "
              "vote to server '%s:%d').",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port);
         break;
     }
     /* return 0 in all cases, since we don't want to mark any
      * dirservers down just because they don't like us. */
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_SIGNATURES) {
+  if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_SIGNATURES) {
     switch (status_code) {
       case 200: {
         log_notice(LD_DIR,"Uploaded signature(s) to dirserver %s:%d",
-                   conn->_base.address, conn->_base.port);
+                   conn->base_.address, conn->base_.port);
         }
         break;
       case 400:
         log_warn(LD_DIR,"http status 400 (%s) response after uploading "
                  "signatures to dirserver '%s:%d'. Please correct.",
-                 escaped(reason), conn->_base.address, conn->_base.port);
+                 escaped(reason), conn->base_.address, conn->base_.port);
         break;
       default:
         log_warn(LD_GENERAL,
              "http status %d (%s) reason unexpected while uploading "
              "signatures to server '%s:%d').",
-             status_code, escaped(reason), conn->_base.address,
-             conn->_base.port);
+             status_code, escaped(reason), conn->base_.address,
+             conn->base_.port);
         break;
     }
     /* return 0 in all cases, since we don't want to mark any
      * dirservers down just because they don't like us. */
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_RENDDESC) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_RENDDESC) {
     tor_assert(conn->rend_data);
     log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d "
              "(%s))",
@@ -2136,7 +2136,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
         } else {
           /* Success, or at least there's a v2 descriptor already
            * present. Notify pending connections about this. */
-          conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
+          conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
           rend_client_desc_trynow(conn->rend_data->onion_address);
         }
         break;
@@ -2152,13 +2152,13 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       default:
         log_warn(LD_REND,"http status %d (%s) response unexpected while "
                  "fetching hidden service descriptor (server '%s:%d').",
-                 status_code, escaped(reason), conn->_base.address,
-                 conn->_base.port);
+                 status_code, escaped(reason), conn->base_.address,
+                 conn->base_.port);
         break;
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_FETCH_RENDDESC_V2) {
+  if (conn->base_.purpose == DIR_PURPOSE_FETCH_RENDDESC_V2) {
     tor_assert(conn->rend_data);
     log_info(LD_REND,"Received rendezvous descriptor (size %d, status %d "
              "(%s))",
@@ -2177,13 +2177,13 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
              * and _not_ performing another request. */
             log_info(LD_REND, "Successfully fetched v2 rendezvous "
                      "descriptor, but we already have a v0 descriptor.");
-            conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
+            conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
             break;
           default:
             /* success. notify pending connections about this. */
             log_info(LD_REND, "Successfully fetched v2 rendezvous "
                      "descriptor.");
-            conn->_base.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
+            conn->base_.purpose = DIR_PURPOSE_HAS_FETCHED_RENDDESC;
             rend_client_desc_trynow(conn->rend_data->onion_address);
             break;
         }
@@ -2205,14 +2205,14 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
                  "http status %d (%s) response unexpected while "
                  "fetching v2 hidden service descriptor (server '%s:%d'). "
                  "Retrying at another directory.",
-                 status_code, escaped(reason), conn->_base.address,
-                 conn->_base.port);
+                 status_code, escaped(reason), conn->base_.address,
+                 conn->base_.port);
         break;
     }
   }
 
-  if (conn->_base.purpose == DIR_PURPOSE_UPLOAD_RENDDESC ||
-      conn->_base.purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) {
+  if (conn->base_.purpose == DIR_PURPOSE_UPLOAD_RENDDESC ||
+      conn->base_.purpose == DIR_PURPOSE_UPLOAD_RENDDESC_V2) {
     log_info(LD_REND,"Uploaded rendezvous descriptor (status %d "
              "(%s))",
              status_code, escaped(reason));
@@ -2225,17 +2225,17 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
       case 400:
         log_warn(LD_REND,"http status 400 (%s) response from dirserver "
                  "'%s:%d'. Malformed rendezvous descriptor?",
-                 escaped(reason), conn->_base.address, conn->_base.port);
+                 escaped(reason), conn->base_.address, conn->base_.port);
         break;
       default:
         log_warn(LD_REND,"http status %d (%s) response unexpected (server "
                  "'%s:%d').",
-                 status_code, escaped(reason), conn->_base.address,
-                 conn->_base.port);
+                 status_code, escaped(reason), conn->base_.address,
+                 conn->base_.port);
         break;
     }
   }
-  note_client_request(conn->_base.purpose, was_compressed, orig_len);
+  note_client_request(conn->base_.purpose, was_compressed, orig_len);
   tor_free(body); tor_free(headers); tor_free(reason);
   return 0;
 }
@@ -2245,9 +2245,9 @@ int
 connection_dir_reached_eof(dir_connection_t *conn)
 {
   int retval;
-  if (conn->_base.state != DIR_CONN_STATE_CLIENT_READING) {
+  if (conn->base_.state != DIR_CONN_STATE_CLIENT_READING) {
     log_info(LD_HTTP,"conn reached eof, not reading. [state=%d] Closing.",
-             conn->_base.state);
+             conn->base_.state);
     connection_close_immediate(TO_CONN(conn)); /* error: give up on flushing */
     connection_mark_for_close(TO_CONN(conn));
     return -1;
@@ -2255,7 +2255,7 @@ connection_dir_reached_eof(dir_connection_t *conn)
 
   retval = connection_dir_client_reached_eof(conn);
   if (retval == 0) /* success */
-    conn->_base.state = DIR_CONN_STATE_CLIENT_FINISHED;
+    conn->base_.state = DIR_CONN_STATE_CLIENT_FINISHED;
   connection_mark_for_close(TO_CONN(conn));
   return retval;
 }
@@ -2273,7 +2273,7 @@ int
 connection_dir_process_inbuf(dir_connection_t *conn)
 {
   tor_assert(conn);
-  tor_assert(conn->_base.type == CONN_TYPE_DIR);
+  tor_assert(conn->base_.type == CONN_TYPE_DIR);
 
   /* Directory clients write, then read data until they receive EOF;
    * directory servers read data until they get an HTTP command, then
@@ -2282,7 +2282,7 @@ connection_dir_process_inbuf(dir_connection_t *conn)
    */
 
   /* If we're on the dirserver side, look for a command. */
-  if (conn->_base.state == DIR_CONN_STATE_SERVER_COMMAND_WAIT) {
+  if (conn->base_.state == DIR_CONN_STATE_SERVER_COMMAND_WAIT) {
     if (directory_handle_command(conn) < 0) {
       connection_mark_for_close(TO_CONN(conn));
       return -1;
@@ -2297,7 +2297,7 @@ connection_dir_process_inbuf(dir_connection_t *conn)
     return -1;
   }
 
-  if (!conn->_base.inbuf_reached_eof)
+  if (!conn->base_.inbuf_reached_eof)
     log_debug(LD_HTTP,"Got data, not eof. Leaving on inbuf.");
   return 0;
 }
@@ -2370,12 +2370,12 @@ write_http_response_header_impl(dir_connection_t *conn, ssize_t length,
     tor_snprintf(cp, sizeof(tmp)-(cp-tmp), "Content-Type: %s\r\n", type);
     cp += strlen(cp);
   }
-  if (!is_local_addr(&conn->_base.addr)) {
+  if (!is_local_addr(&conn->base_.addr)) {
     /* Don't report the source address for a nearby/private connection.
      * Otherwise we tend to mis-report in cases where incoming ports are
      * being forwarded to a Tor server running behind the firewall. */
     tor_snprintf(cp, sizeof(tmp)-(cp-tmp),
-                 X_ADDRESS_HEADER "%s\r\n", conn->_base.address);
+                 X_ADDRESS_HEADER "%s\r\n", conn->base_.address);
     cp += strlen(cp);
   }
   if (encoding) {
@@ -2627,7 +2627,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
 
   log_debug(LD_DIRSERV,"Received GET command.");
 
-  conn->_base.state = DIR_CONN_STATE_SERVER_WRITING;
+  conn->base_.state = DIR_CONN_STATE_SERVER_WRITING;
 
   if (parse_http_url(headers, &url) < 0) {
     write_http_status_line(conn, 400, "Bad request");
@@ -3220,7 +3220,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
   }
 
   if (options->BridgeAuthoritativeDir &&
-      options->_BridgePassword_AuthDigest &&
+      options->BridgePassword_AuthDigest_ &&
       connection_dir_is_encrypted(conn) &&
       !strcmp(url,"/tor/networkstatus-bridges")) {
     char *status;
@@ -3233,7 +3233,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
     /* now make sure the password is there and right */
     if (!header ||
         tor_memneq(digest,
-                   options->_BridgePassword_AuthDigest, DIGEST256_LEN)) {
+                   options->BridgePassword_AuthDigest_, DIGEST256_LEN)) {
       write_http_status_line(conn, 404, "Not found");
       tor_free(header);
       goto done;
@@ -3289,7 +3289,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
   }while(0);
 
   if (!strcmp(url,"/tor/mallinfo.txt") &&
-      (tor_addr_eq_ipv4h(&conn->_base.addr, 0x7f000001ul))) {
+      (tor_addr_eq_ipv4h(&conn->base_.addr, 0x7f000001ul))) {
     char *result;
     size_t len;
     struct mallinfo mi;
@@ -3344,7 +3344,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
 
   log_debug(LD_DIRSERV,"Received POST command.");
 
-  conn->_base.state = DIR_CONN_STATE_SERVER_WRITING;
+  conn->base_.state = DIR_CONN_STATE_SERVER_WRITING;
 
   if (parse_http_url(headers, &url) < 0) {
     write_http_status_line(conn, 400, "Bad request");
@@ -3359,13 +3359,13 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
       case -2:
         log_info(LD_REND, "Rejected v2 rend descriptor (length %d) from %s "
                  "since we're not currently a hidden service directory.",
-                 (int)body_len, conn->_base.address);
+                 (int)body_len, conn->base_.address);
         write_http_status_line(conn, 503, "Currently not acting as v2 "
                                "hidden service directory");
         break;
       case -1:
         log_warn(LD_REND, "Rejected v2 rend descriptor (length %d) from %s.",
-                 (int)body_len, conn->_base.address);
+                 (int)body_len, conn->base_.address);
         write_http_status_line(conn, 400,
                                "Invalid v2 service descriptor rejected");
         break;
@@ -3390,7 +3390,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
     uint8_t purpose = authdir_mode_bridge(options) ?
                       ROUTER_PURPOSE_BRIDGE : ROUTER_PURPOSE_GENERAL;
     was_router_added_t r = dirserv_add_multiple_descriptors(body, purpose,
-                                             conn->_base.address, &msg);
+                                             conn->base_.address, &msg);
     tor_assert(msg);
     if (WRA_WAS_ADDED(r))
       dirserv_get_directory(); /* rebuild and write to disk */
@@ -3400,7 +3400,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
       log_info(LD_DIRSERV,
                "Problematic router descriptor or extra-info from %s "
                "(\"%s\").",
-               conn->_base.address, msg);
+               conn->base_.address, msg);
       write_http_status_line(conn, 400, msg);
     } else if (r == ROUTER_ADDED_SUCCESSFULLY) {
       write_http_status_line(conn, 200, msg);
@@ -3411,7 +3411,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
       log_info(LD_DIRSERV,
                "Rejected router descriptor or extra-info from %s "
                "(\"%s\").",
-               conn->_base.address, msg);
+               conn->base_.address, msg);
       write_http_status_line(conn, 400, msg);
     }
     goto done;
@@ -3424,7 +3424,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
     if (rend_cache_store(body, body_len, 1, NULL) < 0) {
       log_fn(LOG_PROTOCOL_WARN, LD_DIRSERV,
              "Rejected rend descriptor (length %d) from %s.",
-             (int)body_len, conn->_base.address);
+             (int)body_len, conn->base_.address);
       write_http_status_line(conn, 400,
                              "Invalid v0 service descriptor rejected");
     } else {
@@ -3442,7 +3442,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
     } else {
       tor_assert(msg);
       log_warn(LD_DIRSERV, "Rejected vote from %s (\"%s\").",
-               conn->_base.address, msg);
+               conn->base_.address, msg);
       write_http_status_line(conn, status, msg);
     }
     goto done;
@@ -3451,11 +3451,11 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
   if (authdir_mode_v3(options) &&
       !strcmp(url,"/tor/post/consensus-signature")) { /* sigs on consensus. */
     const char *msg = NULL;
-    if (dirvote_add_signatures(body, conn->_base.address, &msg)>=0) {
+    if (dirvote_add_signatures(body, conn->base_.address, &msg)>=0) {
       write_http_status_line(conn, 200, msg?msg:"Signatures stored");
     } else {
       log_warn(LD_DIR, "Unable to store signatures posted by %s: %s",
-               conn->_base.address, msg?msg:"???");
+               conn->base_.address, msg?msg:"???");
       write_http_status_line(conn, 400, msg?msg:"Unable to store signatures");
     }
     goto done;
@@ -3482,7 +3482,7 @@ directory_handle_command(dir_connection_t *conn)
   int r;
 
   tor_assert(conn);
-  tor_assert(conn->_base.type == CONN_TYPE_DIR);
+  tor_assert(conn->base_.type == CONN_TYPE_DIR);
 
   switch (connection_fetch_from_buf_http(TO_CONN(conn),
                               &headers, MAX_HEADERS_SIZE,
@@ -3490,7 +3490,7 @@ directory_handle_command(dir_connection_t *conn)
     case -1: /* overflow */
       log_warn(LD_DIRSERV,
                "Request too large from address '%s' to DirPort. Closing.",
-               safe_str(conn->_base.address));
+               safe_str(conn->base_.address));
       return -1;
     case 0:
       log_debug(LD_DIRSERV,"command not all here yet.");
@@ -3524,7 +3524,7 @@ int
 connection_dir_finished_flushing(dir_connection_t *conn)
 {
   tor_assert(conn);
-  tor_assert(conn->_base.type == CONN_TYPE_DIR);
+  tor_assert(conn->base_.type == CONN_TYPE_DIR);
 
   /* Note that we have finished writing the directory response. For direct
    * connections this means we're done, for tunneled connections its only
@@ -3536,11 +3536,11 @@ connection_dir_finished_flushing(dir_connection_t *conn)
     geoip_change_dirreq_state(TO_CONN(conn)->global_identifier,
                               DIRREQ_DIRECT,
                               DIRREQ_FLUSHING_DIR_CONN_FINISHED);
-  switch (conn->_base.state) {
+  switch (conn->base_.state) {
     case DIR_CONN_STATE_CONNECTING:
     case DIR_CONN_STATE_CLIENT_SENDING:
       log_debug(LD_DIR,"client finished sending command.");
-      conn->_base.state = DIR_CONN_STATE_CLIENT_READING;
+      conn->base_.state = DIR_CONN_STATE_CLIENT_READING;
       return 0;
     case DIR_CONN_STATE_SERVER_WRITING:
       if (conn->dir_spool_src != DIR_SPOOL_NONE) {
@@ -3561,7 +3561,7 @@ connection_dir_finished_flushing(dir_connection_t *conn)
       return 0;
     default:
       log_warn(LD_BUG,"called in unexpected state %d.",
-               conn->_base.state);
+               conn->base_.state);
       tor_fragile_assert();
       return -1;
   }
@@ -3574,13 +3574,13 @@ int
 connection_dir_finished_connecting(dir_connection_t *conn)
 {
   tor_assert(conn);
-  tor_assert(conn->_base.type == CONN_TYPE_DIR);
-  tor_assert(conn->_base.state == DIR_CONN_STATE_CONNECTING);
+  tor_assert(conn->base_.type == CONN_TYPE_DIR);
+  tor_assert(conn->base_.state == DIR_CONN_STATE_CONNECTING);
 
   log_debug(LD_HTTP,"Dir connection to router %s:%u established.",
-            conn->_base.address,conn->_base.port);
+            conn->base_.address,conn->base_.port);
 
-  conn->_base.state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */
+  conn->base_.state = DIR_CONN_STATE_CLIENT_SENDING; /* start flushing conn */
   return 0;
 }
 
@@ -3817,7 +3817,7 @@ dir_microdesc_download_failed(smartlist_t *failed,
 /** Helper.  Compare two fp_pair_t objects, and return negative, 0, or
  * positive as appropriate. */
 static int
-_compare_pairs(const void **a, const void **b)
+compare_pairs_(const void **a, const void **b)
 {
   const fp_pair_t *fp1 = *a, *fp2 = *b;
   int r;
@@ -3868,8 +3868,8 @@ dir_split_resource_into_fingerprint_pairs(const char *res,
   smartlist_free(pairs_tmp);
 
   /* Uniq-and-sort */
-  smartlist_sort(pairs_result, _compare_pairs);
-  smartlist_uniq(pairs_result, _compare_pairs, _tor_free);
+  smartlist_sort(pairs_result, compare_pairs_);
+  smartlist_uniq(pairs_result, compare_pairs_, tor_free_);
 
   smartlist_add_all(pairs_out, pairs_result);
   smartlist_free(pairs_result);

+ 2 - 2
src/or/directory.h

@@ -9,8 +9,8 @@
  * \brief Header file for directory.c.
  **/
 
-#ifndef _TOR_DIRECTORY_H
-#define _TOR_DIRECTORY_H
+#ifndef TOR_DIRECTORY_H
+#define TOR_DIRECTORY_H
 
 int directories_have_accepted_server_descriptor(void);
 void directory_post_to_dirservers(uint8_t dir_purpose, uint8_t router_purpose,

+ 8 - 8
src/or/dirserv.c

@@ -516,8 +516,8 @@ dirserv_free_fingerprint_list(void)
   if (!fingerprint_list)
     return;
 
-  strmap_free(fingerprint_list->fp_by_name, _tor_free);
-  digestmap_free(fingerprint_list->status_by_digest, _tor_free);
+  strmap_free(fingerprint_list->fp_by_name, tor_free_);
+  digestmap_free(fingerprint_list->status_by_digest, tor_free_);
   tor_free(fingerprint_list);
 }
 
@@ -1427,7 +1427,7 @@ clear_cached_dir(cached_dir_t *d)
 
 /** Free all storage held by the cached_dir_t in <b>d</b>. */
 static void
-_free_cached_dir(void *_d)
+free_cached_dir_(void *_d)
 {
   cached_dir_t *d;
   if (!_d)
@@ -2258,7 +2258,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
  * and a router with more bandwidth is more useful than one with less.)
  **/
 static int
-_compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
+compare_routerinfo_by_ip_and_bw_(const void **a, const void **b)
 {
   routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b;
   int first_is_auth, second_is_auth;
@@ -2333,7 +2333,7 @@ get_possible_sybil_list(const smartlist_t *routers)
     max_with_same_addr_on_authority = INT_MAX;
 
   smartlist_add_all(routers_by_ip, routers);
-  smartlist_sort(routers_by_ip, _compare_routerinfo_by_ip_and_bw);
+  smartlist_sort(routers_by_ip, compare_routerinfo_by_ip_and_bw_);
   omit_as_sybil = digestmap_new();
 
   last_addr = 0;
@@ -3849,7 +3849,7 @@ connection_dirserv_add_networkstatus_bytes_to_outbuf(dir_connection_t *conn)
 int
 connection_dirserv_flushed_some(dir_connection_t *conn)
 {
-  tor_assert(conn->_base.state == DIR_CONN_STATE_SERVER_WRITING);
+  tor_assert(conn->base_.state == DIR_CONN_STATE_SERVER_WRITING);
 
   if (connection_get_outbuf_len(TO_CONN(conn)) >= DIRSERV_BUFFER_MIN)
     return 0;
@@ -3884,9 +3884,9 @@ dirserv_free_all(void)
   cached_dir_decref(cached_directory);
   clear_cached_dir(&cached_runningrouters);
 
-  digestmap_free(cached_v2_networkstatus, _free_cached_dir);
+  digestmap_free(cached_v2_networkstatus, free_cached_dir_);
   cached_v2_networkstatus = NULL;
-  strmap_free(cached_consensuses, _free_cached_dir);
+  strmap_free(cached_consensuses, free_cached_dir_);
   cached_consensuses = NULL;
 }
 

+ 2 - 2
src/or/dirserv.h

@@ -9,8 +9,8 @@
  * \brief Header file for dirserv.c.
  **/
 
-#ifndef _TOR_DIRSERV_H
-#define _TOR_DIRSERV_H
+#ifndef TOR_DIRSERV_H
+#define TOR_DIRSERV_H
 
 /** What fraction (1 over this number) of the relay ID space do we
  * (as a directory authority) launch connections to at each reachability

+ 15 - 15
src/or/dirvote.c

@@ -323,7 +323,7 @@ typedef struct dir_src_ent_t {
 /** Helper for sorting networkstatus_t votes (not consensuses) by the
  * hash of their voters' identity digests. */
 static int
-_compare_votes_by_authority_id(const void **_a, const void **_b)
+compare_votes_by_authority_id_(const void **_a, const void **_b)
 {
   const networkstatus_t *a = *_a, *b = *_b;
   return fast_memcmp(get_voter(a)->identity_digest,
@@ -334,7 +334,7 @@ _compare_votes_by_authority_id(const void **_a, const void **_b)
  * their identity digests, and return -1, 0, or 1 depending on their
  * ordering */
 static int
-_compare_dir_src_ents_by_authority_id(const void **_a, const void **_b)
+compare_dir_src_ents_by_authority_id_(const void **_a, const void **_b)
 {
   const dir_src_ent_t *a = *_a, *b = *_b;
   const networkstatus_voter_info_t *a_v = get_voter(a->v),
@@ -401,7 +401,7 @@ compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b)
 
 /** Helper for sorting routerlists based on compare_vote_rs. */
 static int
-_compare_vote_rs(const void **_a, const void **_b)
+compare_vote_rs_(const void **_a, const void **_b)
 {
   const vote_routerstatus_t *a = *_a, *b = *_b;
   return compare_vote_rs(a,b);
@@ -409,7 +409,7 @@ _compare_vote_rs(const void **_a, const void **_b)
 
 /** Helper for sorting OR ports. */
 static int
-_compare_orports(const void **_a, const void **_b)
+compare_orports_(const void **_a, const void **_b)
 {
   const tor_addr_port_t *a = *_a, *b = *_b;
   int r;
@@ -436,11 +436,11 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
   int most_n = 0, cur_n = 0;
   time_t most_published = 0;
 
-  /* _compare_vote_rs() sorts the items by identity digest (all the same),
+  /* compare_vote_rs_() sorts the items by identity digest (all the same),
    * then by SD digest.  That way, if we have a tie that the published_on
    * date cannot tie, we use the descriptor with the smaller digest.
    */
-  smartlist_sort(votes, _compare_vote_rs);
+  smartlist_sort(votes, compare_vote_rs_);
   SMARTLIST_FOREACH_BEGIN(votes, vote_routerstatus_t *, rs) {
     if (cur && !compare_vote_rs(cur, rs)) {
       ++cur_n;
@@ -484,9 +484,9 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
       }
     } SMARTLIST_FOREACH_END(rs);
 
-    smartlist_sort(alt_orports, _compare_orports);
+    smartlist_sort(alt_orports, compare_orports_);
     most_alt_orport = smartlist_get_most_frequent(alt_orports,
-                                                  _compare_orports);
+                                                  compare_orports_);
     if (most_alt_orport) {
       memcpy(best_alt_orport_out, most_alt_orport, sizeof(tor_addr_port_t));
       log_debug(LD_DIR, "\"a\" line winner for %s is %s",
@@ -543,7 +543,7 @@ hash_list_members(char *digest_out, size_t len_out,
  * positive integers. (Non-integers are treated as prior to all integers, and
  * compared lexically.) */
 static int
-_cmp_int_strings(const void **_a, const void **_b)
+cmp_int_strings_(const void **_a, const void **_b)
 {
   const char *a = *_a, *b = *_b;
   int ai = (int)tor_parse_long(a, 10, 1, INT_MAX, NULL, NULL);
@@ -574,13 +574,13 @@ compute_consensus_method(smartlist_t *votes)
   {
     tor_assert(vote->supported_methods);
     smartlist_add_all(tmp, vote->supported_methods);
-    smartlist_sort(tmp, _cmp_int_strings);
-    smartlist_uniq(tmp, _cmp_int_strings, NULL);
+    smartlist_sort(tmp, cmp_int_strings_);
+    smartlist_uniq(tmp, cmp_int_strings_, NULL);
     smartlist_add_all(all_methods, tmp);
     smartlist_clear(tmp);
   });
 
-  smartlist_sort(all_methods, _cmp_int_strings);
+  smartlist_sort(all_methods, cmp_int_strings_);
   get_frequent_members(acceptable_methods, all_methods, min);
   n_ok = smartlist_len(acceptable_methods);
   if (n_ok) {
@@ -1529,7 +1529,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
   }
 
   /* Sort the votes. */
-  smartlist_sort(votes, _compare_votes_by_authority_id);
+  smartlist_sort(votes, compare_votes_by_authority_id_);
   /* Add the authority sections. */
   {
     smartlist_t *dir_sources = smartlist_new();
@@ -1548,7 +1548,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
         smartlist_add(dir_sources, e_legacy);
       }
     } SMARTLIST_FOREACH_END(v);
-    smartlist_sort(dir_sources, _compare_dir_src_ents_by_authority_id);
+    smartlist_sort(dir_sources, compare_dir_src_ents_by_authority_id_);
 
     SMARTLIST_FOREACH_BEGIN(dir_sources, const dir_src_ent_t *, e) {
       char fingerprint[HEX_DIGEST_LEN+1];
@@ -2487,7 +2487,7 @@ ns_detached_signatures_free(ns_detached_signatures_t *s)
       smartlist_free(sigs);
     } STRMAP_FOREACH_END;
     strmap_free(s->signatures, NULL);
-    strmap_free(s->digests, _tor_free);
+    strmap_free(s->digests, tor_free_);
   }
 
   tor_free(s);

+ 2 - 2
src/or/dirvote.h

@@ -9,8 +9,8 @@
  * \brief Header file for dirvote.c.
  **/
 
-#ifndef _TOR_DIRVOTE_H
-#define _TOR_DIRVOTE_H
+#ifndef TOR_DIRVOTE_H
+#define TOR_DIRVOTE_H
 
 /** Lowest allowable value for VoteSeconds. */
 #define MIN_VOTE_SECONDS 20

+ 69 - 69
src/or/dns.c

@@ -171,8 +171,8 @@ static int dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
                             or_circuit_t *oncirc, char **resolved_to_hostname,
                             int *made_connection_pending_out);
 #ifdef DEBUG_DNS_CACHE
-static void _assert_cache_ok(void);
-#define assert_cache_ok() _assert_cache_ok()
+static void assert_cache_ok_(void);
+#define assert_cache_ok() assert_cache_ok_()
 #else
 #define assert_cache_ok() STMT_NIL
 #endif
@@ -254,7 +254,7 @@ evdns_log_cb(int warn, const char *msg)
 /** Helper: passed to eventdns.c as a callback so it can generate random
  * numbers for transaction IDs and 0x20-hack coding. */
 static void
-_dns_randfn(char *b, size_t n)
+dns_randfn_(char *b, size_t n)
 {
   crypto_rand(b,n);
 }
@@ -264,7 +264,7 @@ int
 dns_init(void)
 {
   init_cache_map();
-  evdns_set_random_bytes_fn(_dns_randfn);
+  evdns_set_random_bytes_fn(dns_randfn_);
   if (server_mode(get_options())) {
     int r = configure_nameservers(1);
     return r;
@@ -336,7 +336,7 @@ dns_get_expiry_ttl(uint32_t ttl)
 
 /** Helper: free storage held by an entry in the DNS cache. */
 static void
-_free_cached_resolve(cached_resolve_t *r)
+free_cached_resolve_(cached_resolve_t *r)
 {
   if (!r)
     return;
@@ -355,7 +355,7 @@ _free_cached_resolve(cached_resolve_t *r)
  * less-than-zero, zero, or greater-than-zero as appropriate. Used for
  * the priority queue implementation. */
 static int
-_compare_cached_resolves_by_expiry(const void *_a, const void *_b)
+compare_cached_resolves_by_expiry_(const void *_a, const void *_b)
 {
   const cached_resolve_t *a = _a, *b = _b;
   if (a->expire < b->expire)
@@ -380,7 +380,7 @@ set_expiry(cached_resolve_t *resolve, time_t expires)
     cached_resolve_pqueue = smartlist_new();
   resolve->expire = expires;
   smartlist_pqueue_add(cached_resolve_pqueue,
-                       _compare_cached_resolves_by_expiry,
+                       compare_cached_resolves_by_expiry_,
                        STRUCT_OFFSET(cached_resolve_t, minheap_idx),
                        resolve);
 }
@@ -395,13 +395,13 @@ dns_free_all(void)
     SMARTLIST_FOREACH(cached_resolve_pqueue, cached_resolve_t *, res,
       {
         if (res->state == CACHE_STATE_DONE)
-          _free_cached_resolve(res);
+          free_cached_resolve_(res);
       });
   }
   for (ptr = HT_START(cache_map, &cache_root); ptr != NULL; ptr = next) {
     item = *ptr;
     next = HT_NEXT_RMV(cache_map, &cache_root, ptr);
-    _free_cached_resolve(item);
+    free_cached_resolve_(item);
   }
   HT_CLEAR(cache_map, &cache_root);
   smartlist_free(cached_resolve_pqueue);
@@ -427,7 +427,7 @@ purge_expired_resolves(time_t now)
     if (resolve->expire > now)
       break;
     smartlist_pqueue_pop(cached_resolve_pqueue,
-                         _compare_cached_resolves_by_expiry,
+                         compare_cached_resolves_by_expiry_,
                          STRUCT_OFFSET(cached_resolve_t, minheap_idx));
 
     if (resolve->state == CACHE_STATE_PENDING) {
@@ -454,9 +454,9 @@ purge_expired_resolves(time_t now)
         pend = resolve->pending_connections;
         resolve->pending_connections = pend->next;
         /* Connections should only be pending if they have no socket. */
-        tor_assert(!SOCKET_OK(pend->conn->_base.s));
+        tor_assert(!SOCKET_OK(pend->conn->base_.s));
         pendconn = pend->conn;
-        if (!pendconn->_base.marked_for_close) {
+        if (!pendconn->base_.marked_for_close) {
           connection_edge_end(pendconn, END_STREAM_REASON_TIMEOUT);
           circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
           connection_free(TO_CONN(pendconn));
@@ -512,7 +512,7 @@ send_resolved_cell(edge_connection_t *conn, uint8_t answer_type)
     {
     case RESOLVED_TYPE_IPV4:
       buf[1] = 4;
-      set_uint32(buf+2, tor_addr_to_ipv4n(&conn->_base.addr));
+      set_uint32(buf+2, tor_addr_to_ipv4n(&conn->base_.addr));
       set_uint32(buf+6, htonl(ttl));
       buflen = 10;
       break;
@@ -600,7 +600,7 @@ dns_resolve(edge_connection_t *exitconn)
   int is_resolve, r;
   int made_connection_pending = 0;
   char *hostname = NULL;
-  is_resolve = exitconn->_base.purpose == EXIT_PURPOSE_RESOLVE;
+  is_resolve = exitconn->base_.purpose == EXIT_PURPOSE_RESOLVE;
 
   r = dns_resolve_impl(exitconn, is_resolve, oncirc, &hostname,
                        &made_connection_pending);
@@ -626,7 +626,7 @@ dns_resolve(edge_connection_t *exitconn)
     case 0:
       /* The request is pending: add the connection into the linked list of
        * resolving_streams on this circuit. */
-      exitconn->_base.state = EXIT_CONN_STATE_RESOLVING;
+      exitconn->base_.state = EXIT_CONN_STATE_RESOLVING;
       exitconn->next_stream = oncirc->resolving_streams;
       oncirc->resolving_streams = exitconn;
       break;
@@ -641,9 +641,9 @@ dns_resolve(edge_connection_t *exitconn)
 
       exitconn->on_circuit = NULL;
 
-      dns_cancel_pending_resolve(exitconn->_base.address);
+      dns_cancel_pending_resolve(exitconn->base_.address);
 
-      if (!made_connection_pending && !exitconn->_base.marked_for_close) {
+      if (!made_connection_pending && !exitconn->base_.marked_for_close) {
         /* If we made the connection pending, then we freed it already in
          * dns_cancel_pending_resolve().  If we marked it for close, it'll
          * get freed from the main loop.  Otherwise, can free it now. */
@@ -685,16 +685,16 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
   uint8_t is_reverse = 0;
   int r;
   assert_connection_ok(TO_CONN(exitconn), 0);
-  tor_assert(!SOCKET_OK(exitconn->_base.s));
+  tor_assert(!SOCKET_OK(exitconn->base_.s));
   assert_cache_ok();
   tor_assert(oncirc);
   *made_connection_pending_out = 0;
 
-  /* first check if exitconn->_base.address is an IP. If so, we already
+  /* first check if exitconn->base_.address is an IP. If so, we already
    * know the answer. */
-  if (tor_addr_parse(&addr, exitconn->_base.address) >= 0) {
+  if (tor_addr_parse(&addr, exitconn->base_.address) >= 0) {
     if (tor_addr_family(&addr) == AF_INET) {
-      tor_addr_copy(&exitconn->_base.addr, &addr);
+      tor_addr_copy(&exitconn->base_.addr, &addr);
       exitconn->address_ttl = DEFAULT_DNS_TTL;
       return 1;
     } else {
@@ -708,10 +708,10 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
       policy_is_reject_star(me->exit_policy)) {
     return -1;
   }
-  if (address_is_invalid_destination(exitconn->_base.address, 0)) {
+  if (address_is_invalid_destination(exitconn->base_.address, 0)) {
     log(LOG_PROTOCOL_WARN, LD_EXIT,
         "Rejecting invalid destination address %s",
-        escaped_safe_str(exitconn->_base.address));
+        escaped_safe_str(exitconn->base_.address));
     return -1;
   }
 
@@ -719,14 +719,14 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
    * resolves in the hash table. */
   purge_expired_resolves(now);
 
-  /* lower-case exitconn->_base.address, so it's in canonical form */
-  tor_strlower(exitconn->_base.address);
+  /* lower-case exitconn->base_.address, so it's in canonical form */
+  tor_strlower(exitconn->base_.address);
 
   /* Check whether this is a reverse lookup.  If it's malformed, or it's a
    * .in-addr.arpa address but this isn't a resolve request, kill the
    * connection.
    */
-  if ((r = tor_addr_parse_PTR_name(&addr, exitconn->_base.address,
+  if ((r = tor_addr_parse_PTR_name(&addr, exitconn->base_.address,
                                               AF_UNSPEC, 0)) != 0) {
     if (r == 1) {
       is_reverse = 1;
@@ -737,21 +737,21 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
     if (!is_reverse || !is_resolve) {
       if (!is_reverse)
         log_info(LD_EXIT, "Bad .in-addr.arpa address \"%s\"; sending error.",
-                 escaped_safe_str(exitconn->_base.address));
+                 escaped_safe_str(exitconn->base_.address));
       else if (!is_resolve)
         log_info(LD_EXIT,
                  "Attempt to connect to a .in-addr.arpa address \"%s\"; "
                  "sending error.",
-                 escaped_safe_str(exitconn->_base.address));
+                 escaped_safe_str(exitconn->base_.address));
 
       return -1;
     }
     //log_notice(LD_EXIT, "Looks like an address %s",
-    //exitconn->_base.address);
+    //exitconn->base_.address);
   }
 
   /* now check the hash table to see if 'address' is already there. */
-  strlcpy(search.address, exitconn->_base.address, sizeof(search.address));
+  strlcpy(search.address, exitconn->base_.address, sizeof(search.address));
   resolve = HT_FIND(cache_map, &cache_root, &search);
   if (resolve && resolve->expire > now) { /* already there */
     switch (resolve->state) {
@@ -764,25 +764,25 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
         resolve->pending_connections = pending_connection;
         *made_connection_pending_out = 1;
         log_debug(LD_EXIT,"Connection (fd %d) waiting for pending DNS "
-                  "resolve of %s", exitconn->_base.s,
-                  escaped_safe_str(exitconn->_base.address));
+                  "resolve of %s", exitconn->base_.s,
+                  escaped_safe_str(exitconn->base_.address));
         return 0;
       case CACHE_STATE_CACHED_VALID:
         log_debug(LD_EXIT,"Connection (fd %d) found cached answer for %s",
-                  exitconn->_base.s,
+                  exitconn->base_.s,
                   escaped_safe_str(resolve->address));
         exitconn->address_ttl = resolve->ttl;
         if (resolve->is_reverse) {
           tor_assert(is_resolve);
           *hostname_out = tor_strdup(resolve->result.hostname);
         } else {
-          tor_addr_from_ipv4h(&exitconn->_base.addr, resolve->result.a.addr);
+          tor_addr_from_ipv4h(&exitconn->base_.addr, resolve->result.a.addr);
         }
         return 1;
       case CACHE_STATE_CACHED_FAILED:
         log_debug(LD_EXIT,"Connection (fd %d) found cached error for %s",
-                  exitconn->_base.s,
-                  escaped_safe_str(exitconn->_base.address));
+                  exitconn->base_.s,
+                  escaped_safe_str(exitconn->base_.address));
         return -1;
       case CACHE_STATE_DONE:
         log_err(LD_BUG, "Found a 'DONE' dns resolve still in the cache.");
@@ -797,7 +797,7 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
   resolve->state = CACHE_STATE_PENDING;
   resolve->minheap_idx = -1;
   resolve->is_reverse = is_reverse;
-  strlcpy(resolve->address, exitconn->_base.address, sizeof(resolve->address));
+  strlcpy(resolve->address, exitconn->base_.address, sizeof(resolve->address));
 
   /* add this connection to the pending list */
   pending_connection = tor_malloc_zero(sizeof(pending_connection_t));
@@ -810,7 +810,7 @@ dns_resolve_impl(edge_connection_t *exitconn, int is_resolve,
   set_expiry(resolve, now + RESOLVE_MAX_TIMEOUT);
 
   log_debug(LD_EXIT,"Launching %s.",
-            escaped_safe_str(exitconn->_base.address));
+            escaped_safe_str(exitconn->base_.address));
   assert_cache_ok();
 
   return launch_resolve(exitconn);
@@ -826,7 +826,7 @@ assert_connection_edge_not_dns_pending(edge_connection_t *conn)
 
 #if 1
   cached_resolve_t *resolve;
-  strlcpy(search.address, conn->_base.address, sizeof(search.address));
+  strlcpy(search.address, conn->base_.address, sizeof(search.address));
   resolve = HT_FIND(cache_map, &cache_root, &search);
   if (!resolve)
     return;
@@ -856,7 +856,7 @@ assert_all_pending_dns_resolves_ok(void)
          pend;
          pend = pend->next) {
       assert_connection_ok(TO_CONN(pend->conn), 0);
-      tor_assert(!SOCKET_OK(pend->conn->_base.s));
+      tor_assert(!SOCKET_OK(pend->conn->base_.s));
       tor_assert(!connection_in_array(TO_CONN(pend->conn)));
     }
   }
@@ -871,15 +871,15 @@ connection_dns_remove(edge_connection_t *conn)
   cached_resolve_t search;
   cached_resolve_t *resolve;
 
-  tor_assert(conn->_base.type == CONN_TYPE_EXIT);
-  tor_assert(conn->_base.state == EXIT_CONN_STATE_RESOLVING);
+  tor_assert(conn->base_.type == CONN_TYPE_EXIT);
+  tor_assert(conn->base_.state == EXIT_CONN_STATE_RESOLVING);
 
-  strlcpy(search.address, conn->_base.address, sizeof(search.address));
+  strlcpy(search.address, conn->base_.address, sizeof(search.address));
 
   resolve = HT_FIND(cache_map, &cache_root, &search);
   if (!resolve) {
     log_notice(LD_BUG, "Address %s is not pending. Dropping.",
-               escaped_safe_str(conn->_base.address));
+               escaped_safe_str(conn->base_.address));
     return;
   }
 
@@ -893,8 +893,8 @@ connection_dns_remove(edge_connection_t *conn)
     tor_free(pend);
     log_debug(LD_EXIT, "First connection (fd %d) no longer waiting "
               "for resolve of %s",
-              conn->_base.s,
-              escaped_safe_str(conn->_base.address));
+              conn->base_.s,
+              escaped_safe_str(conn->base_.address));
     return;
   } else {
     for ( ; pend->next; pend = pend->next) {
@@ -904,7 +904,7 @@ connection_dns_remove(edge_connection_t *conn)
         tor_free(victim);
         log_debug(LD_EXIT,
                   "Connection (fd %d) no longer waiting for resolve of %s",
-                  conn->_base.s, escaped_safe_str(conn->_base.address));
+                  conn->base_.s, escaped_safe_str(conn->base_.address));
         return; /* more are pending */
       }
     }
@@ -959,17 +959,17 @@ dns_cancel_pending_resolve(const char *address)
              escaped_safe_str(address));
   while (resolve->pending_connections) {
     pend = resolve->pending_connections;
-    pend->conn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
+    pend->conn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
     pendconn = pend->conn;
     assert_connection_ok(TO_CONN(pendconn), 0);
-    tor_assert(!SOCKET_OK(pendconn->_base.s));
-    if (!pendconn->_base.marked_for_close) {
+    tor_assert(!SOCKET_OK(pendconn->base_.s));
+    if (!pendconn->base_.marked_for_close) {
       connection_edge_end(pendconn, END_STREAM_REASON_RESOLVEFAILED);
     }
     circ = circuit_get_by_edge_conn(pendconn);
     if (circ)
       circuit_detach_stream(circ, pendconn);
-    if (!pendconn->_base.marked_for_close)
+    if (!pendconn->base_.marked_for_close)
       connection_free(TO_CONN(pendconn));
     resolve->pending_connections = pend->next;
     tor_free(pend);
@@ -1092,20 +1092,20 @@ dns_found_answer(const char *address, uint8_t is_reverse, uint32_t addr,
     pendconn = pend->conn; /* don't pass complex things to the
                               connection_mark_for_close macro */
     assert_connection_ok(TO_CONN(pendconn),time(NULL));
-    if (pendconn->_base.marked_for_close) {
+    if (pendconn->base_.marked_for_close) {
       /* prevent double-remove. */
-      pendconn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
+      pendconn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
       resolve->pending_connections = pend->next;
       tor_free(pend);
       continue;
     }
-    tor_addr_from_ipv4h(&pendconn->_base.addr, addr);
+    tor_addr_from_ipv4h(&pendconn->base_.addr, addr);
     pendconn->address_ttl = ttl;
 
     if (outcome != DNS_RESOLVE_SUCCEEDED) {
       /* prevent double-remove. */
-      pendconn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
-      if (pendconn->_base.purpose == EXIT_PURPOSE_CONNECT) {
+      pendconn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
+      if (pendconn->base_.purpose == EXIT_PURPOSE_CONNECT) {
         connection_edge_end(pendconn, END_STREAM_REASON_RESOLVEFAILED);
         /* This detach must happen after we send the end cell. */
         circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
@@ -1117,10 +1117,10 @@ dns_found_answer(const char *address, uint8_t is_reverse, uint32_t addr,
       }
       connection_free(TO_CONN(pendconn));
     } else {
-      if (pendconn->_base.purpose == EXIT_PURPOSE_CONNECT) {
+      if (pendconn->base_.purpose == EXIT_PURPOSE_CONNECT) {
         tor_assert(!is_reverse);
         /* prevent double-remove. */
-        pend->conn->_base.state = EXIT_CONN_STATE_CONNECTING;
+        pend->conn->base_.state = EXIT_CONN_STATE_CONNECTING;
 
         circ = circuit_get_by_edge_conn(pend->conn);
         tor_assert(circ);
@@ -1136,7 +1136,7 @@ dns_found_answer(const char *address, uint8_t is_reverse, uint32_t addr,
       } else {
         /* prevent double-remove.  This isn't really an accurate state,
          * but it does the right thing. */
-        pendconn->_base.state = EXIT_CONN_STATE_RESOLVEFAILED;
+        pendconn->base_.state = EXIT_CONN_STATE_RESOLVEFAILED;
         if (is_reverse)
           send_resolved_hostname_cell(pendconn, hostname);
         else
@@ -1210,10 +1210,10 @@ configure_nameservers(int force)
   }
 
 #ifdef HAVE_EVDNS_SET_DEFAULT_OUTGOING_BIND_ADDRESS
-  if (! tor_addr_is_null(&options->_OutboundBindAddressIPv4)) {
+  if (! tor_addr_is_null(&options->OutboundBindAddressIPv4_)) {
     int socklen;
     struct sockaddr_storage ss;
-    socklen = tor_addr_to_sockaddr(&options->_OutboundBindAddressIPv4, 0,
+    socklen = tor_addr_to_sockaddr(&options->OutboundBindAddressIPv4_, 0,
                                    (struct sockaddr *)&ss, sizeof(ss));
     if (socklen <= 0) {
       log_warn(LD_BUG, "Couldn't convert outbound bind address to sockaddr."
@@ -1416,21 +1416,21 @@ launch_resolve(edge_connection_t *exitconn)
     }
   }
 
-  addr = tor_strdup(exitconn->_base.address);
+  addr = tor_strdup(exitconn->base_.address);
 
   r = tor_addr_parse_PTR_name(
-                            &a, exitconn->_base.address, AF_UNSPEC, 0);
+                            &a, exitconn->base_.address, AF_UNSPEC, 0);
 
   tor_assert(the_evdns_base);
   if (r == 0) {
     log_info(LD_EXIT, "Launching eventdns request for %s",
-             escaped_safe_str(exitconn->_base.address));
+             escaped_safe_str(exitconn->base_.address));
     req = evdns_base_resolve_ipv4(the_evdns_base,
-                                exitconn->_base.address, options,
+                                exitconn->base_.address, options,
                                 evdns_callback, addr);
   } else if (r == 1) {
     log_info(LD_EXIT, "Launching eventdns reverse request for %s",
-             escaped_safe_str(exitconn->_base.address));
+             escaped_safe_str(exitconn->base_.address));
     if (tor_addr_family(&a) == AF_INET)
       req = evdns_base_resolve_reverse(the_evdns_base,
                                 tor_addr_to_in(&a), DNS_QUERY_NO_SEARCH,
@@ -1707,7 +1707,7 @@ dns_seems_to_be_broken(void)
 void
 dns_reset_correctness_checks(void)
 {
-  strmap_free(dns_wildcard_response_count, _tor_free);
+  strmap_free(dns_wildcard_response_count, tor_free_);
   dns_wildcard_response_count = NULL;
 
   n_wildcard_requests = 0;
@@ -1781,7 +1781,7 @@ dump_dns_mem_usage(int severity)
 #ifdef DEBUG_DNS_CACHE
 /** Exit with an assertion if the DNS cache is corrupt. */
 static void
-_assert_cache_ok(void)
+assert_cache_ok_(void)
 {
   cached_resolve_t **resolve;
   int bad_rep = _cache_map_HT_REP_IS_BAD(&cache_root);
@@ -1798,7 +1798,7 @@ _assert_cache_ok(void)
     return;
 
   smartlist_pqueue_assert_ok(cached_resolve_pqueue,
-                             _compare_cached_resolves_by_expiry,
+                             compare_cached_resolves_by_expiry_,
                              STRUCT_OFFSET(cached_resolve_t, minheap_idx));
 
   SMARTLIST_FOREACH(cached_resolve_pqueue, cached_resolve_t *, res,

+ 2 - 2
src/or/dns.h

@@ -9,8 +9,8 @@
  * \brief Header file for dns.c.
  **/
 
-#ifndef _TOR_DNS_H
-#define _TOR_DNS_H
+#ifndef TOR_DNS_H
+#define TOR_DNS_H
 
 int dns_init(void);
 int has_dns_init_failed(void);

+ 2 - 2
src/or/dnsserv.c

@@ -133,7 +133,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
   strlcpy(entry_conn->socks_request->address, q->name,
           sizeof(entry_conn->socks_request->address));
 
-  entry_conn->socks_request->listener_type = listener->_base.type;
+  entry_conn->socks_request->listener_type = listener->base_.type;
   entry_conn->dns_server_request = req;
   entry_conn->isolation_flags = listener->isolation_flags;
   entry_conn->session_group = listener->session_group;
@@ -178,7 +178,7 @@ dnsserv_launch_request(const char *name, int reverse)
   /* Make a new dummy AP connection, and attach the request to it. */
   entry_conn = entry_connection_new(CONN_TYPE_AP, AF_INET);
   conn = ENTRY_TO_EDGE_CONN(entry_conn);
-  conn->_base.state = AP_CONN_STATE_RESOLVE_WAIT;
+  conn->base_.state = AP_CONN_STATE_RESOLVE_WAIT;
 
   if (reverse)
     entry_conn->socks_request->command = SOCKS_COMMAND_RESOLVE_PTR;

+ 2 - 2
src/or/dnsserv.h

@@ -9,8 +9,8 @@
  * \brief Header file for dnsserv.c.
  **/
 
-#ifndef _TOR_DNSSERV_H
-#define _TOR_DNSSERV_H
+#ifndef TOR_DNSSERV_H
+#define TOR_DNSSERV_H
 
 void dnsserv_configure_listener(connection_t *conn);
 void dnsserv_close_listener(connection_t *conn);

+ 4 - 0
src/or/eventdns_tor.h

@@ -1,6 +1,9 @@
 /* Copyright (c) 2007-2012, The Tor Project, Inc. */
 /* See LICENSE for licensing information */
 
+#ifndef TOR_EVENTDNS_TOR_H
+#define TOR_EVENTDNS_TOR_H
+
 #include "orconfig.h"
 #define DNS_USE_OPENSSL_FOR_ID
 #ifndef HAVE_UINT
@@ -18,3 +21,4 @@ typedef unsigned char u_char;
 #include "util.h"
 #include "compat.h"
 
+#endif

+ 21 - 21
src/or/geoip.c

@@ -53,14 +53,14 @@ static char geoip_digest[DIGEST_LEN];
 country_t
 geoip_get_country(const char *country)
 {
-  void *_idxplus1;
+  void *idxplus1_;
   intptr_t idx;
 
-  _idxplus1 = strmap_get_lc(country_idxplus1_by_lc_code, country);
-  if (!_idxplus1)
+  idxplus1_ = strmap_get_lc(country_idxplus1_by_lc_code, country);
+  if (!idxplus1_)
     return -1;
 
-  idx = ((uintptr_t)_idxplus1)-1;
+  idx = ((uintptr_t)idxplus1_)-1;
   return (country_t)idx;
 }
 
@@ -72,14 +72,14 @@ geoip_add_entry(uint32_t low, uint32_t high, const char *country)
 {
   intptr_t idx;
   geoip_entry_t *ent;
-  void *_idxplus1;
+  void *idxplus1_;
 
   if (high < low)
     return;
 
-  _idxplus1 = strmap_get_lc(country_idxplus1_by_lc_code, country);
+  idxplus1_ = strmap_get_lc(country_idxplus1_by_lc_code, country);
 
-  if (!_idxplus1) {
+  if (!idxplus1_) {
     geoip_country_t *c = tor_malloc_zero(sizeof(geoip_country_t));
     strlcpy(c->countrycode, country, sizeof(c->countrycode));
     tor_strlower(c->countrycode);
@@ -87,7 +87,7 @@ geoip_add_entry(uint32_t low, uint32_t high, const char *country)
     idx = smartlist_len(geoip_countries) - 1;
     strmap_set_lc(country_idxplus1_by_lc_code, country, (void*)(idx+1));
   } else {
-    idx = ((uintptr_t)_idxplus1)-1;
+    idx = ((uintptr_t)idxplus1_)-1;
   }
   {
     geoip_country_t *c = smartlist_get(geoip_countries, idx);
@@ -132,7 +132,7 @@ geoip_parse_entry(const char *line)
 /** Sorting helper: return -1, 1, or 0 based on comparison of two
  * geoip_entry_t */
 static int
-_geoip_compare_entries(const void **_a, const void **_b)
+geoip_compare_entries_(const void **_a, const void **_b)
 {
   const geoip_entry_t *a = *_a, *b = *_b;
   if (a->ip_low < b->ip_low)
@@ -146,7 +146,7 @@ _geoip_compare_entries(const void **_a, const void **_b)
 /** bsearch helper: return -1, 1, or 0 based on comparison of an IP (a pointer
  * to a uint32_t in host order) to a geoip_entry_t */
 static int
-_geoip_compare_key_to_entry(const void *_key, const void **_member)
+geoip_compare_key_to_entry_(const void *_key, const void **_member)
 {
   /* No alignment issue here, since _key really is a pointer to uint32_t */
   const uint32_t addr = *(uint32_t *)_key;
@@ -231,7 +231,7 @@ geoip_load_file(const char *filename, const or_options_t *options)
   /*XXXX abort and return -1 if no entries/illformed?*/
   fclose(f);
 
-  smartlist_sort(geoip_entries, _geoip_compare_entries);
+  smartlist_sort(geoip_entries, geoip_compare_entries_);
 
   /* Okay, now we need to maybe change our mind about what is in which
    * country. */
@@ -257,7 +257,7 @@ geoip_get_country_by_ip(uint32_t ipaddr)
   geoip_entry_t *ent;
   if (!geoip_entries)
     return -1;
-  ent = smartlist_bsearch(geoip_entries, &ipaddr, _geoip_compare_key_to_entry);
+  ent = smartlist_bsearch(geoip_entries, &ipaddr, geoip_compare_key_to_entry_);
   return ent ? (int)ent->country : 0;
 }
 
@@ -489,7 +489,7 @@ geoip_note_client_seen(geoip_client_action_t action,
 /** HT_FOREACH helper: remove a clientmap_entry_t from the hashtable if it's
  * older than a certain time. */
 static int
-_remove_old_client_helper(struct clientmap_entry_t *ent, void *_cutoff)
+remove_old_client_helper_(struct clientmap_entry_t *ent, void *_cutoff)
 {
   time_t cutoff = *(time_t*)_cutoff / 60;
   if (ent->last_seen_in_minutes < cutoff) {
@@ -505,7 +505,7 @@ void
 geoip_remove_old_clients(time_t cutoff)
 {
   clientmap_HT_FOREACH_FN(&client_history,
-                          _remove_old_client_helper,
+                          remove_old_client_helper_,
                           &cutoff);
 }
 
@@ -562,7 +562,7 @@ typedef struct c_hist_t {
  * geoip_entry_t.  Sort in descending order of total, and then by country
  * code. */
 static int
-_c_hist_compare(const void **_a, const void **_b)
+c_hist_compare_(const void **_a, const void **_b)
 {
   const c_hist_t *a = *_a, *b = *_b;
   if (a->total > b->total)
@@ -631,7 +631,7 @@ HT_GENERATE(dirreqmap, dirreq_map_entry_t, node, dirreq_map_ent_hash,
  * <b>type</b> and <b>dirreq_id</b> as key parts. If there is
  * already an entry for that key, print out a BUG warning and return. */
 static void
-_dirreq_map_put(dirreq_map_entry_t *entry, dirreq_type_t type,
+dirreq_map_put_(dirreq_map_entry_t *entry, dirreq_type_t type,
                uint64_t dirreq_id)
 {
   dirreq_map_entry_t *old_ent;
@@ -653,7 +653,7 @@ _dirreq_map_put(dirreq_map_entry_t *entry, dirreq_type_t type,
  * using <b>type</b> and <b>dirreq_id</b> as key parts. If there
  * is no such entry, return NULL. */
 static dirreq_map_entry_t *
-_dirreq_map_get(dirreq_type_t type, uint64_t dirreq_id)
+dirreq_map_get_(dirreq_type_t type, uint64_t dirreq_id)
 {
   dirreq_map_entry_t lookup;
   lookup.type = type;
@@ -678,7 +678,7 @@ geoip_start_dirreq(uint64_t dirreq_id, size_t response_size,
   ent->response_size = response_size;
   ent->action = action;
   ent->type = type;
-  _dirreq_map_put(ent, type, dirreq_id);
+  dirreq_map_put_(ent, type, dirreq_id);
 }
 
 /** Change the state of the either direct or tunneled (see <b>type</b>)
@@ -694,7 +694,7 @@ geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type,
   dirreq_map_entry_t *ent;
   if (!get_options()->DirReqStatistics)
     return;
-  ent = _dirreq_map_get(type, dirreq_id);
+  ent = dirreq_map_get_(type, dirreq_id);
   if (!ent)
     return;
   if (new_state == DIRREQ_IS_FOR_NETWORK_STATUS)
@@ -868,7 +868,7 @@ geoip_get_client_history(geoip_client_action_t action)
   }
   /* Sort entries. Note that we must do this _AFTER_ rounding, or else
    * the sort order could leak info. */
-  smartlist_sort(entries, _c_hist_compare);
+  smartlist_sort(entries, c_hist_compare_);
 
   /* Build the result. */
   chunks = smartlist_new();
@@ -918,7 +918,7 @@ geoip_get_request_history(geoip_client_action_t action)
       ent->total = round_to_next_multiple_of(tot, granularity);
       smartlist_add(entries, ent);
   } SMARTLIST_FOREACH_END(c);
-  smartlist_sort(entries, _c_hist_compare);
+  smartlist_sort(entries, c_hist_compare_);
 
   strings = smartlist_new();
   SMARTLIST_FOREACH(entries, c_hist_t *, ent, {

+ 2 - 2
src/or/geoip.h

@@ -9,8 +9,8 @@
  * \brief Header file for geoip.c.
  **/
 
-#ifndef _TOR_GEOIP_H
-#define _TOR_GEOIP_H
+#ifndef TOR_GEOIP_H
+#define TOR_GEOIP_H
 
 #ifdef GEOIP_PRIVATE
 int geoip_parse_entry(const char *line);

+ 2 - 2
src/or/hibernate.h

@@ -9,8 +9,8 @@
  * \brief Header file for hibernate.c.
  **/
 
-#ifndef _TOR_HIBERNATE_H
-#define _TOR_HIBERNATE_H
+#ifndef TOR_HIBERNATE_H
+#define TOR_HIBERNATE_H
 
 int accounting_parse_options(const or_options_t *options, int validate_only);
 int accounting_is_enabled(const or_options_t *options);

+ 1 - 1
src/or/main.c

@@ -2677,7 +2677,7 @@ tor_main(int argc, char *argv[])
   {
     /* Instruct OpenSSL to use our internal wrappers for malloc,
        realloc and free. */
-    int r = CRYPTO_set_mem_ex_functions(_tor_malloc, _tor_realloc, _tor_free);
+    int r = CRYPTO_set_mem_ex_functions(tor_malloc_, tor_realloc_, tor_free_);
     tor_assert(r);
   }
 #endif

+ 2 - 2
src/or/main.h

@@ -9,8 +9,8 @@
  * \brief Header file for main.c.
  **/
 
-#ifndef _TOR_MAIN_H
-#define _TOR_MAIN_H
+#ifndef TOR_MAIN_H
+#define TOR_MAIN_H
 
 extern int can_complete_circuit;
 

+ 4 - 4
src/or/microdesc.c

@@ -42,7 +42,7 @@ struct microdesc_cache_t {
 
 /** Helper: computes a hash of <b>md</b> to place it in a hash table. */
 static INLINE unsigned int
-_microdesc_hash(microdesc_t *md)
+microdesc_hash_(microdesc_t *md)
 {
   unsigned *d = (unsigned*)md->digest;
 #if SIZEOF_INT == 4
@@ -54,15 +54,15 @@ _microdesc_hash(microdesc_t *md)
 
 /** Helper: compares <b>a</b> and </b> for equality for hash-table purposes. */
 static INLINE int
-_microdesc_eq(microdesc_t *a, microdesc_t *b)
+microdesc_eq_(microdesc_t *a, microdesc_t *b)
 {
   return tor_memeq(a->digest, b->digest, DIGEST256_LEN);
 }
 
 HT_PROTOTYPE(microdesc_map, microdesc_t, node,
-             _microdesc_hash, _microdesc_eq);
+             microdesc_hash_, microdesc_eq_);
 HT_GENERATE(microdesc_map, microdesc_t, node,
-             _microdesc_hash, _microdesc_eq, 0.6,
+             microdesc_hash_, microdesc_eq_, 0.6,
              malloc, realloc, free);
 
 /** Write the body of <b>md</b> into <b>f</b>, with appropriate annotations.

+ 2 - 2
src/or/microdesc.h

@@ -9,8 +9,8 @@
  * \brief Header file for microdesc.c.
  **/
 
-#ifndef _TOR_MICRODESC_H
-#define _TOR_MICRODESC_H
+#ifndef TOR_MICRODESC_H
+#define TOR_MICRODESC_H
 
 microdesc_cache_t *get_microdesc_cache(void);
 

+ 6 - 6
src/or/networkstatus.c

@@ -670,7 +670,7 @@ networkstatus_get_cache_filename(const char *identity_digest)
 /** Helper for smartlist_sort: Compare two networkstatus objects by
  * publication date. */
 static int
-_compare_networkstatus_v2_published_on(const void **_a, const void **_b)
+compare_networkstatus_v2_published_on_(const void **_a, const void **_b)
 {
   const networkstatus_v2_t *a = *_a, *b = *_b;
   if (a->published_on < b->published_on)
@@ -904,7 +904,7 @@ router_set_networkstatus_v2(const char *s, time_t arrived_at,
   networkstatus_v2_list_has_changed = 1;
 
   smartlist_sort(networkstatus_v2_list,
-                 _compare_networkstatus_v2_published_on);
+                 compare_networkstatus_v2_published_on_);
 
   if (!skewed)
     add_networkstatus_to_cache(s, source, ns);
@@ -2005,7 +2005,7 @@ download_status_map_update_from_v2_networkstatus(void)
       digestmap_set(dl_status, d, s);
     } SMARTLIST_FOREACH_END(rs);
   } SMARTLIST_FOREACH_END(ns);
-  digestmap_free(v2_download_status_map, _tor_free);
+  digestmap_free(v2_download_status_map, tor_free_);
   v2_download_status_map = dl_status;
   networkstatus_v2_list_has_changed = 0;
 }
@@ -2018,7 +2018,7 @@ routerstatus_list_update_named_server_map(void)
   if (!current_consensus)
     return;
 
-  strmap_free(named_server_map, _tor_free);
+  strmap_free(named_server_map, tor_free_);
   named_server_map = strmap_new();
   strmap_free(unnamed_server_map, NULL);
   unnamed_server_map = strmap_new();
@@ -2405,7 +2405,7 @@ networkstatus_free_all(void)
     networkstatus_v2_list = NULL;
   }
 
-  digestmap_free(v2_download_status_map, _tor_free);
+  digestmap_free(v2_download_status_map, tor_free_);
   v2_download_status_map = NULL;
   networkstatus_vote_free(current_ns_consensus);
   networkstatus_vote_free(current_md_consensus);
@@ -2420,7 +2420,7 @@ networkstatus_free_all(void)
     tor_free(waiting->body);
   }
 
-  strmap_free(named_server_map, _tor_free);
+  strmap_free(named_server_map, tor_free_);
   strmap_free(unnamed_server_map, NULL);
 }
 

+ 2 - 2
src/or/networkstatus.h

@@ -9,8 +9,8 @@
  * \brief Header file for networkstatus.c.
  **/
 
-#ifndef _TOR_NETWORKSTATUS_H
-#define _TOR_NETWORKSTATUS_H
+#ifndef TOR_NETWORKSTATUS_H
+#define TOR_NETWORKSTATUS_H
 
 /** How old do we allow a v2 network-status to get before removing it
  * completely? */

+ 1 - 1
src/or/nodelist.c

@@ -1110,7 +1110,7 @@ router_find_exact_exit_enclave(const char *address, uint16_t port)
         node->is_running &&
         compare_tor_addr_to_node_policy(&a, port, node) ==
           ADDR_POLICY_ACCEPTED &&
-        !routerset_contains_node(options->_ExcludeExitNodesUnion, node))
+        !routerset_contains_node(options->ExcludeExitNodesUnion_, node))
       return node;
   });
   return NULL;

+ 2 - 2
src/or/nodelist.h

@@ -9,8 +9,8 @@
  * \brief Header file for nodelist.c.
  **/
 
-#ifndef _TOR_NODELIST_H
-#define _TOR_NODELIST_H
+#ifndef TOR_NODELIST_H
+#define TOR_NODELIST_H
 
 #define node_assert_ok(n) STMT_BEGIN {                          \
     tor_assert((n)->ri || (n)->rs);                             \

+ 2 - 2
src/or/ntmain.h

@@ -9,8 +9,8 @@
  * \brief Header file for ntmain.c.
  **/
 
-#ifndef _TOR_NTMAIN_H
-#define _TOR_NTMAIN_H
+#ifndef TOR_NTMAIN_H
+#define TOR_NTMAIN_H
 
 #ifdef _WIN32
 #if !defined (WINCE)

+ 2 - 2
src/or/onion.h

@@ -9,8 +9,8 @@
  * \brief Header file for onion.c.
  **/
 
-#ifndef _TOR_ONION_H
-#define _TOR_ONION_H
+#ifndef TOR_ONION_H
+#define TOR_ONION_H
 
 int onion_pending_add(or_circuit_t *circ, char *onionskin);
 or_circuit_t *onion_next_task(char **onionskin_out);

+ 59 - 59
src/or/or.h

@@ -9,8 +9,8 @@
  * \brief Master header file for Tor-specific functionality.
  **/
 
-#ifndef _TOR_OR_H
-#define _TOR_OR_H
+#ifndef TOR_OR_H
+#define TOR_OR_H
 
 #include "orconfig.h"
 
@@ -198,7 +198,7 @@ typedef enum {
   CIRC_ID_TYPE_NEITHER=2
 } circ_id_type_t;
 
-#define _CONN_TYPE_MIN 3
+#define CONN_TYPE_MIN_ 3
 /** Type for sockets listening for OR connections. */
 #define CONN_TYPE_OR_LISTENER 3
 /** A bidirectional TLS connection transmitting a sequence of cells.
@@ -229,8 +229,8 @@ typedef enum {
 #define CONN_TYPE_AP_NATD_LISTENER 14
 /** Type for sockets listening for DNS requests. */
 #define CONN_TYPE_AP_DNS_LISTENER 15
-#define _CONN_TYPE_MAX 15
-/* !!!! If _CONN_TYPE_MAX is ever over 15, we must grow the type field in
+#define CONN_TYPE_MAX_ 15
+/* !!!! If CONN_TYPE_MAX_ is ever over 15, we must grow the type field in
  * connection_t. */
 
 /* Proxy client types */
@@ -270,17 +270,17 @@ typedef enum {
 /** State for any listener connection. */
 #define LISTENER_STATE_READY 0
 
-#define _CPUWORKER_STATE_MIN 1
+#define CPUWORKER_STATE_MIN_ 1
 /** State for a connection to a cpuworker process that's idle. */
 #define CPUWORKER_STATE_IDLE 1
 /** State for a connection to a cpuworker process that's processing a
  * handshake. */
 #define CPUWORKER_STATE_BUSY_ONION 2
-#define _CPUWORKER_STATE_MAX 2
+#define CPUWORKER_STATE_MAX_ 2
 
 #define CPUWORKER_TASK_ONION CPUWORKER_STATE_BUSY_ONION
 
-#define _OR_CONN_STATE_MIN 1
+#define OR_CONN_STATE_MIN_ 1
 /** State for a connection to an OR: waiting for connect() to finish. */
 #define OR_CONN_STATE_CONNECTING 1
 /** State for a connection to an OR: waiting for proxy handshake to complete */
@@ -305,9 +305,9 @@ typedef enum {
 #define OR_CONN_STATE_OR_HANDSHAKING_V3 7
 /** State for an OR connection: Ready to send/receive cells. */
 #define OR_CONN_STATE_OPEN 8
-#define _OR_CONN_STATE_MAX 8
+#define OR_CONN_STATE_MAX_ 8
 
-#define _EXIT_CONN_STATE_MIN 1
+#define EXIT_CONN_STATE_MIN_ 1
 /** State for an exit connection: waiting for response from DNS farm. */
 #define EXIT_CONN_STATE_RESOLVING 1
 /** State for an exit connection: waiting for connect() to finish. */
@@ -316,10 +316,10 @@ typedef enum {
 #define EXIT_CONN_STATE_OPEN 3
 /** State for an exit connection: waiting to be removed. */
 #define EXIT_CONN_STATE_RESOLVEFAILED 4
-#define _EXIT_CONN_STATE_MAX 4
+#define EXIT_CONN_STATE_MAX_ 4
 
 /* The AP state values must be disjoint from the EXIT state values. */
-#define _AP_CONN_STATE_MIN 5
+#define AP_CONN_STATE_MIN_ 5
 /** State for a SOCKS connection: waiting for SOCKS request. */
 #define AP_CONN_STATE_SOCKS_WAIT 5
 /** State for a SOCKS connection: got a y.onion URL; waiting to receive
@@ -339,14 +339,14 @@ typedef enum {
 /** State for a transparent natd connection: waiting for original
  * destination. */
 #define AP_CONN_STATE_NATD_WAIT 12
-#define _AP_CONN_STATE_MAX 12
+#define AP_CONN_STATE_MAX_ 12
 
 /** True iff the AP_CONN_STATE_* value <b>s</b> means that the corresponding
  * edge connection is not attached to any circuit. */
 #define AP_CONN_STATE_IS_UNATTACHED(s) \
   ((s) <= AP_CONN_STATE_CIRCUIT_WAIT || (s) == AP_CONN_STATE_NATD_WAIT)
 
-#define _DIR_CONN_STATE_MIN 1
+#define DIR_CONN_STATE_MIN_ 1
 /** State for connection to directory server: waiting for connect(). */
 #define DIR_CONN_STATE_CONNECTING 1
 /** State for connection to directory server: sending HTTP request. */
@@ -359,21 +359,21 @@ typedef enum {
 #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5
 /** State for connection at directory server: sending HTTP response. */
 #define DIR_CONN_STATE_SERVER_WRITING 6
-#define _DIR_CONN_STATE_MAX 6
+#define DIR_CONN_STATE_MAX_ 6
 
 /** True iff the purpose of <b>conn</b> means that it's a server-side
  * directory connection. */
 #define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
 
-#define _CONTROL_CONN_STATE_MIN 1
+#define CONTROL_CONN_STATE_MIN_ 1
 /** State for a control connection: Authenticated and accepting v1 commands. */
 #define CONTROL_CONN_STATE_OPEN 1
 /** State for a control connection: Waiting for authentication; speaking
  * protocol v1. */
 #define CONTROL_CONN_STATE_NEEDAUTH 2
-#define _CONTROL_CONN_STATE_MAX 2
+#define CONTROL_CONN_STATE_MAX_ 2
 
-#define _DIR_PURPOSE_MIN 3
+#define DIR_PURPOSE_MIN_ 3
 /** A connection to a directory server: download a rendezvous
  * descriptor. */
 #define DIR_PURPOSE_FETCH_RENDDESC 3
@@ -421,7 +421,7 @@ typedef enum {
 #define DIR_PURPOSE_FETCH_RENDDESC_V2 18
 /** A connection to a directory server: download a microdescriptor. */
 #define DIR_PURPOSE_FETCH_MICRODESC 19
-#define _DIR_PURPOSE_MAX 19
+#define DIR_PURPOSE_MAX_ 19
 
 /** True iff <b>p</b> is a purpose corresponding to uploading data to a
  * directory server. */
@@ -431,12 +431,12 @@ typedef enum {
    (p)==DIR_PURPOSE_UPLOAD_VOTE ||              \
    (p)==DIR_PURPOSE_UPLOAD_SIGNATURES)
 
-#define _EXIT_PURPOSE_MIN 1
+#define EXIT_PURPOSE_MIN_ 1
 /** This exit stream wants to do an ordinary connect. */
 #define EXIT_PURPOSE_CONNECT 1
 /** This exit stream wants to do a resolve (either normal or reverse). */
 #define EXIT_PURPOSE_RESOLVE 2
-#define _EXIT_PURPOSE_MAX 2
+#define EXIT_PURPOSE_MAX_ 2
 
 /* !!!! If any connection purpose is ever over 31, we must grow the type
  * field in connection_t. */
@@ -451,10 +451,10 @@ typedef enum {
 /** Circuit state: onionskin(s) processed, ready to send/receive cells. */
 #define CIRCUIT_STATE_OPEN 3
 
-#define _CIRCUIT_PURPOSE_MIN 1
+#define CIRCUIT_PURPOSE_MIN_ 1
 
 /* these circuits were initiated elsewhere */
-#define _CIRCUIT_PURPOSE_OR_MIN 1
+#define CIRCUIT_PURPOSE_OR_MIN_ 1
 /** OR-side circuit purpose: normal circuit, at OR. */
 #define CIRCUIT_PURPOSE_OR 1
 /** OR-side circuit purpose: At OR, from Bob, waiting for intro from Alices. */
@@ -463,7 +463,7 @@ typedef enum {
 #define CIRCUIT_PURPOSE_REND_POINT_WAITING 3
 /** OR-side circuit purpose: At OR, both circuits have this purpose. */
 #define CIRCUIT_PURPOSE_REND_ESTABLISHED 4
-#define _CIRCUIT_PURPOSE_OR_MAX 4
+#define CIRCUIT_PURPOSE_OR_MAX_ 4
 
 /* these circuits originate at this node */
 
@@ -506,7 +506,7 @@ typedef enum {
 #define CIRCUIT_PURPOSE_C_REND_JOINED 12
 /** This circuit is used for build time measurement only */
 #define CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT 13
-#define _CIRCUIT_PURPOSE_C_MAX 13
+#define CIRCUIT_PURPOSE_C_MAX_ 13
 /** Hidden-service-side circuit purpose: at Bob, waiting for introductions. */
 #define CIRCUIT_PURPOSE_S_ESTABLISH_INTRO 14
 /** Hidden-service-side circuit purpose: at Bob, successfully established
@@ -520,19 +520,19 @@ typedef enum {
 #define CIRCUIT_PURPOSE_TESTING 18
 /** A controller made this circuit and Tor should not use it. */
 #define CIRCUIT_PURPOSE_CONTROLLER 19
-#define _CIRCUIT_PURPOSE_MAX 19
+#define CIRCUIT_PURPOSE_MAX_ 19
 /** A catch-all for unrecognized purposes. Currently we don't expect
  * to make or see any circuits with this purpose. */
 #define CIRCUIT_PURPOSE_UNKNOWN 255
 
 /** True iff the circuit purpose <b>p</b> is for a circuit that
  * originated at this node. */
-#define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>_CIRCUIT_PURPOSE_OR_MAX)
+#define CIRCUIT_PURPOSE_IS_ORIGIN(p) ((p)>CIRCUIT_PURPOSE_OR_MAX_)
 /** True iff the circuit purpose <b>p</b> is for a circuit that originated
  * here to serve as a client.  (Hidden services don't count here.) */
 #define CIRCUIT_PURPOSE_IS_CLIENT(p)  \
-  ((p)> _CIRCUIT_PURPOSE_OR_MAX &&    \
-   (p)<=_CIRCUIT_PURPOSE_C_MAX)
+  ((p)> CIRCUIT_PURPOSE_OR_MAX_ &&    \
+   (p)<=CIRCUIT_PURPOSE_C_MAX_)
 /** True iff the circuit_t <b>c</b> is actually an origin_circuit_t. */
 #define CIRCUIT_IS_ORIGIN(c) (CIRCUIT_PURPOSE_IS_ORIGIN((c)->purpose))
 /** True iff the circuit purpose <b>p</b> is for an established rendezvous
@@ -665,7 +665,7 @@ typedef enum {
 
 /* Reasons why we (or a remote OR) might close a circuit. See tor-spec.txt for
  * documentation of these. */
-#define _END_CIRC_REASON_MIN            0
+#define END_CIRC_REASON_MIN_            0
 #define END_CIRC_REASON_NONE            0
 #define END_CIRC_REASON_TORPROTOCOL     1
 #define END_CIRC_REASON_INTERNAL        2
@@ -679,7 +679,7 @@ typedef enum {
 #define END_CIRC_REASON_TIMEOUT         10
 #define END_CIRC_REASON_DESTROYED       11
 #define END_CIRC_REASON_NOSUCHSERVICE   12
-#define _END_CIRC_REASON_MAX            12
+#define END_CIRC_REASON_MAX_            12
 
 /** Bitwise-OR this with the argument to circuit_mark_for_close() or
  * control_event_circuit_status() to indicate that the reason was
@@ -1206,7 +1206,7 @@ typedef struct connection_t {
 
 /** Subtype of connection_t; used for a listener socket. */
 typedef struct listener_connection_t {
-  connection_t _base;
+  connection_t base_;
 
   /** If the connection is a CONN_TYPE_AP_DNS_LISTENER, this field points
    * to the evdns_server_port it uses to listen to and answer connections. */
@@ -1329,7 +1329,7 @@ typedef struct or_handshake_state_t {
 /** Subtype of connection_t for an "OR connection" -- that is, one that speaks
  * cells over TLS. */
 typedef struct or_connection_t {
-  connection_t _base;
+  connection_t base_;
 
   /** Hash of the public RSA key for the other side's identity key, or zeroes
    * if the other side hasn't shown us a valid identity key. */
@@ -1394,7 +1394,7 @@ typedef struct or_connection_t {
 /** Subtype of connection_t for an "edge connection" -- that is, an entry (ap)
  * connection, or an exit. */
 typedef struct edge_connection_t {
-  connection_t _base;
+  connection_t base_;
 
   struct edge_connection_t *next_stream; /**< Points to the next stream at this
                                           * edge, if any */
@@ -1447,7 +1447,7 @@ typedef struct edge_connection_t {
 /** Subtype of edge_connection_t for an "entry connection" -- that is, a SOCKS
  * connection, a DNS request, a TransPort connection or a NATD connection */
 typedef struct entry_connection_t {
-  edge_connection_t _edge;
+  edge_connection_t edge_;
 
   /** Nickname of planned exit node -- used with .exit support. */
   char *chosen_exit_name;
@@ -1525,7 +1525,7 @@ typedef struct entry_connection_t {
 /** Subtype of connection_t for an "directory connection" -- that is, an HTTP
  * connection to retrieve or serve directory material. */
 typedef struct dir_connection_t {
-  connection_t _base;
+  connection_t base_;
 
  /** Which 'resource' did we ask the directory for? This is typically the part
   * of the URL string that defines, relative to the directory conn purpose,
@@ -1572,7 +1572,7 @@ typedef struct dir_connection_t {
 
 /** Subtype of connection_t for an connection to a controller. */
 typedef struct control_connection_t {
-  connection_t _base;
+  connection_t base_;
 
   uint32_t event_mask; /**< Bitfield: which events does this controller
                         * care about? */
@@ -1599,12 +1599,12 @@ typedef struct control_connection_t {
 } control_connection_t;
 
 /** Cast a connection_t subtype pointer to a connection_t **/
-#define TO_CONN(c) (&(((c)->_base)))
-/** Helper macro: Given a pointer to to._base, of type from*, return &to. */
-#define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, _base))
+#define TO_CONN(c) (&(((c)->base_)))
+/** Helper macro: Given a pointer to to.base_, of type from*, return &to. */
+#define DOWNCAST(to, ptr) ((to*)SUBTYPE_P(ptr, to, base_))
 
 /** Cast a entry_connection_t subtype pointer to a edge_connection_t **/
-#define ENTRY_TO_EDGE_CONN(c) (&(((c))->_edge))
+#define ENTRY_TO_EDGE_CONN(c) (&(((c))->edge_))
 /** Cast a entry_connection_t subtype pointer to a connection_t **/
 #define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c)))
 
@@ -1649,12 +1649,12 @@ static INLINE edge_connection_t *TO_EDGE_CONN(connection_t *c)
 static INLINE entry_connection_t *TO_ENTRY_CONN(connection_t *c)
 {
   tor_assert(c->magic == ENTRY_CONNECTION_MAGIC);
-  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, _edge._base);
+  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
 }
 static INLINE entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *c)
 {
-  tor_assert(c->_base.magic == ENTRY_CONNECTION_MAGIC);
-  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, _edge);
+  tor_assert(c->base_.magic == ENTRY_CONNECTION_MAGIC);
+  return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
 }
 static INLINE control_connection_t *TO_CONTROL_CONN(connection_t *c)
 {
@@ -2726,7 +2726,7 @@ typedef enum {
 /** An origin_circuit_t holds data necessary to build and use a circuit.
  */
 typedef struct origin_circuit_t {
-  circuit_t _base;
+  circuit_t base_;
 
   /** Linked list of AP streams (or EXIT streams if hidden service)
    * associated with this circuit. */
@@ -2859,7 +2859,7 @@ typedef struct origin_circuit_t {
 /** An or_circuit_t holds information needed to implement a circuit at an
  * OR. */
 typedef struct or_circuit_t {
-  circuit_t _base;
+  circuit_t base_;
 
   /** Next circuit in the doubly-linked ring of circuits waiting to add
    * cells to p_chan.  NULL if we have no cells pending, or if we're not
@@ -2940,7 +2940,7 @@ typedef struct or_circuit_t {
 } or_circuit_t;
 
 /** Convert a circuit subtype to a circuit_t. */
-#define TO_CIRCUIT(x)  (&((x)->_base))
+#define TO_CIRCUIT(x)  (&((x)->base_))
 
 /** Convert a circuit_t* to a pointer to the enclosing or_circuit_t.  Assert
  * if the cast is impossible. */
@@ -3063,7 +3063,7 @@ typedef struct routerset_t routerset_t;
 
 /** Configuration options for a Tor process. */
 typedef struct {
-  uint32_t _magic;
+  uint32_t magic_;
 
   /** What should the tor process actually do? */
   enum {
@@ -3105,7 +3105,7 @@ typedef struct {
                                  * ORs not to consider as exits. */
 
   /** Union of ExcludeNodes and ExcludeExitNodes */
-  routerset_t *_ExcludeExitNodesUnion;
+  routerset_t *ExcludeExitNodesUnion_;
 
   int DisableAllSwap; /**< Boolean: Attempt to call mlockall() on our
                        * process for all current and future memory. */
@@ -3113,7 +3113,7 @@ typedef struct {
   /** List of "entry", "middle", "exit", "introduction", "rendezvous". */
   smartlist_t *AllowInvalidNodes;
   /** Bitmask; derived from AllowInvalidNodes. */
-  invalid_router_usage_t _AllowInvalid;
+  invalid_router_usage_t AllowInvalid_;
   config_line_t *ExitPolicy; /**< Lists of exit policy components. */
   int ExitPolicyRejectPrivate; /**< Should we not exit to local addresses? */
   config_line_t *SocksPolicy; /**< Lists of socks policy components */
@@ -3136,9 +3136,9 @@ typedef struct {
   /** Local address to bind outbound sockets */
   config_line_t *OutboundBindAddress;
   /** IPv4 address derived from OutboundBindAddress. */
-  tor_addr_t _OutboundBindAddressIPv4;
+  tor_addr_t OutboundBindAddressIPv4_;
   /** IPv6 address derived from OutboundBindAddress. */
-  tor_addr_t _OutboundBindAddressIPv6;
+  tor_addr_t OutboundBindAddressIPv6_;
   /** Directory server only: which versions of
    * Tor should we tell users to run? */
   config_line_t *RecommendedVersions;
@@ -3207,7 +3207,7 @@ typedef struct {
   char *BridgePassword;
   /** If BridgePassword is set, this is a SHA256 digest of the basic http
    * authenticator for it. Used so we can do a time-independent comparison. */
-  char *_BridgePassword_AuthDigest;
+  char *BridgePassword_AuthDigest_;
 
   int UseBridges; /**< Boolean: should we start all circuits with a bridge? */
   config_line_t *Bridges; /**< List of bootstrap bridge addresses. */
@@ -3233,7 +3233,7 @@ typedef struct {
    * "v1", "v2", "v3", "bridge", or "". */
   smartlist_t *PublishServerDescriptor;
   /** A bitfield of authority types, derived from PublishServerDescriptor. */
-  dirinfo_type_t _PublishServerDescriptor;
+  dirinfo_type_t PublishServerDescriptor_;
   /** Boolean: do we publish hidden service descriptors to the HS auths? */
   int PublishHidServDescriptors;
   int FetchServerDescriptors; /**< Do we fetch server descriptors as normal? */
@@ -3266,7 +3266,7 @@ typedef struct {
   int CloseHSServiceRendCircuitsImmediatelyOnTimeout;
 
   int ConnLimit; /**< Demanded minimum number of simultaneous connections. */
-  int _ConnLimit; /**< Maximum allowed number of simultaneous connections. */
+  int ConnLimit_; /**< Maximum allowed number of simultaneous connections. */
   int RunAsDaemon; /**< If true, run in the background. (Unix only) */
   int FascistFirewall; /**< Whether to prefer ORs reachable on open ports. */
   smartlist_t *FirewallPorts; /**< Which ports our firewall allows
@@ -3470,7 +3470,7 @@ typedef struct {
   /* Derived from SafeLogging */
   enum {
     SAFELOG_SCRUB_ALL, SAFELOG_SCRUB_RELAY, SAFELOG_SCRUB_NONE
-  } _SafeLogging;
+  } SafeLogging_;
 
   int SafeSocks; /**< Boolean: should we outright refuse application
                   * connections that use socks4 or socks5-with-local-dns? */
@@ -3688,7 +3688,7 @@ typedef struct {
   /** Set to true if the TestingTorNetwork configuration option is set.
    * This is used so that options_validate() has a chance to realize that
    * the defaults have changed. */
-  int _UsingTestNetworkDefaults;
+  int UsingTestNetworkDefaults_;
 
   /** If 1, we try to use microdescriptors to build circuits.  If 0, we don't.
    * If -1, Tor decides. */
@@ -3732,7 +3732,7 @@ typedef struct {
 
 /** Persistent state for an onion router, as saved to disk. */
 typedef struct {
-  uint32_t _magic;
+  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. */
@@ -4505,7 +4505,7 @@ typedef struct trusted_dir_server_t {
 #define PDS_NO_EXISTING_SERVERDESC_FETCH (1<<3)
 #define PDS_NO_EXISTING_MICRODESC_FETCH (1<<4)
 
-#define _PDS_PREFER_TUNNELED_DIR_CONNS (1<<16)
+#define PDS_PREFER_TUNNELED_DIR_CONNS_ (1<<16)
 
 /** Possible ways to weight routers when choosing one randomly.  See
  * routerlist_sl_choose_by_bandwidth() for more information.*/

+ 2 - 2
src/or/policies.h

@@ -9,8 +9,8 @@
  * \brief Header file for policies.c.
  **/
 
-#ifndef _TOR_POLICIES_H
-#define _TOR_POLICIES_H
+#ifndef TOR_POLICIES_H
+#define TOR_POLICIES_H
 
 /* (length of "accept 255.255.255.255/255.255.255.255:65535-65535\n" plus a
  * NUL.)

+ 2 - 2
src/or/reasons.h

@@ -9,8 +9,8 @@
  * \brief Header file for reasons.c.
  **/
 
-#ifndef _TOR_REASONS_H
-#define _TOR_REASONS_H
+#ifndef TOR_REASONS_H
+#define TOR_REASONS_H
 
 const char *stream_end_reason_to_control_string(int reason);
 const char *stream_end_reason_to_string(int reason);

+ 38 - 38
src/or/relay.c

@@ -230,7 +230,7 @@ circuit_receive_relay_cell(cell_t *cell, circuit_t *circ,
         cell_direction == CELL_DIRECTION_OUT) {
       or_circuit_t *splice = TO_OR_CIRCUIT(circ)->rend_splice;
       tor_assert(circ->purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
-      tor_assert(splice->_base.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
+      tor_assert(splice->base_.purpose == CIRCUIT_PURPOSE_REND_ESTABLISHED);
       cell->circ_id = splice->p_circ_id;
       cell->command = CELL_RELAY; /* can't be relay_early anyway */
       if ((reason = circuit_receive_relay_cell(cell, TO_CIRCUIT(splice),
@@ -422,7 +422,7 @@ relay_lookup_conn(circuit_t *circ, cell_t *cell,
     for (tmpconn = TO_ORIGIN_CIRCUIT(circ)->p_streams; tmpconn;
          tmpconn=tmpconn->next_stream) {
       if (rh.stream_id == tmpconn->stream_id &&
-          !tmpconn->_base.marked_for_close &&
+          !tmpconn->base_.marked_for_close &&
           tmpconn->cpath_layer == layer_hint) {
         log_debug(LD_APP,"found conn for stream %d.", rh.stream_id);
         return tmpconn;
@@ -432,7 +432,7 @@ relay_lookup_conn(circuit_t *circ, cell_t *cell,
     for (tmpconn = TO_OR_CIRCUIT(circ)->n_streams; tmpconn;
          tmpconn=tmpconn->next_stream) {
       if (rh.stream_id == tmpconn->stream_id &&
-          !tmpconn->_base.marked_for_close) {
+          !tmpconn->base_.marked_for_close) {
         log_debug(LD_EXIT,"found conn for stream %d.", rh.stream_id);
         if (cell_direction == CELL_DIRECTION_OUT ||
             connection_edge_is_rendezvous_stream(tmpconn))
@@ -442,7 +442,7 @@ relay_lookup_conn(circuit_t *circ, cell_t *cell,
     for (tmpconn = TO_OR_CIRCUIT(circ)->resolving_streams; tmpconn;
          tmpconn=tmpconn->next_stream) {
       if (rh.stream_id == tmpconn->stream_id &&
-          !tmpconn->_base.marked_for_close) {
+          !tmpconn->base_.marked_for_close) {
         log_debug(LD_EXIT,"found conn for stream %d.", rh.stream_id);
         return tmpconn;
       }
@@ -631,16 +631,16 @@ connection_edge_send_command(edge_connection_t *fromconn,
   tor_assert(fromconn);
   circ = fromconn->on_circuit;
 
-  if (fromconn->_base.marked_for_close) {
+  if (fromconn->base_.marked_for_close) {
     log_warn(LD_BUG,
              "called on conn that's already marked for close at %s:%d.",
-             fromconn->_base.marked_for_close_file,
-             fromconn->_base.marked_for_close);
+             fromconn->base_.marked_for_close_file,
+             fromconn->base_.marked_for_close);
     return 0;
   }
 
   if (!circ) {
-    if (fromconn->_base.type == CONN_TYPE_AP) {
+    if (fromconn->base_.type == CONN_TYPE_AP) {
       log_info(LD_APP,"no circ. Closing conn.");
       connection_mark_unattached_ap(EDGE_TO_ENTRY_CONN(fromconn),
                                     END_STREAM_REASON_INTERNAL);
@@ -777,8 +777,8 @@ connection_ap_process_end_not_open(
           circuit_log_path(LOG_INFO,LD_APP,circ);
           /* Mark this circuit "unusable for new streams". */
           /* XXXX024 this is a kludgy way to do this. */
-          tor_assert(circ->_base.timestamp_dirty);
-          circ->_base.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
+          tor_assert(circ->base_.timestamp_dirty);
+          circ->base_.timestamp_dirty -= get_options()->MaxCircuitDirtiness;
 
           if (conn->chosen_exit_optional) {
             /* stop wanting a specific exit */
@@ -854,7 +854,7 @@ connection_edge_process_relay_cell_not_open(
     edge_connection_t *conn, crypt_path_t *layer_hint)
 {
   if (rh->command == RELAY_COMMAND_END) {
-    if (CIRCUIT_IS_ORIGIN(circ) && conn->_base.type == CONN_TYPE_AP) {
+    if (CIRCUIT_IS_ORIGIN(circ) && conn->base_.type == CONN_TYPE_AP) {
       return connection_ap_process_end_not_open(rh, cell,
                                                 TO_ORIGIN_CIRCUIT(circ),
                                                 EDGE_TO_ENTRY_CONN(conn),
@@ -869,18 +869,18 @@ connection_edge_process_relay_cell_not_open(
     }
   }
 
-  if (conn->_base.type == CONN_TYPE_AP &&
+  if (conn->base_.type == CONN_TYPE_AP &&
       rh->command == RELAY_COMMAND_CONNECTED) {
     entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
     tor_assert(CIRCUIT_IS_ORIGIN(circ));
-    if (conn->_base.state != AP_CONN_STATE_CONNECT_WAIT) {
+    if (conn->base_.state != AP_CONN_STATE_CONNECT_WAIT) {
       log_fn(LOG_PROTOCOL_WARN, LD_APP,
              "Got 'connected' while not in state connect_wait. Dropping.");
       return 0;
     }
-    conn->_base.state = AP_CONN_STATE_OPEN;
+    conn->base_.state = AP_CONN_STATE_OPEN;
     log_info(LD_APP,"'connected' received after %d seconds.",
-             (int)(time(NULL) - conn->_base.timestamp_lastread));
+             (int)(time(NULL) - conn->base_.timestamp_lastread));
     if (rh->length >= 4) {
       uint32_t addr = ntohl(get_uint32(cell->payload+RELAY_HEADER_SIZE));
       int ttl;
@@ -944,13 +944,13 @@ connection_edge_process_relay_cell_not_open(
     }
     return 0;
   }
-  if (conn->_base.type == CONN_TYPE_AP &&
+  if (conn->base_.type == CONN_TYPE_AP &&
       rh->command == RELAY_COMMAND_RESOLVED) {
     int ttl;
     int answer_len;
     uint8_t answer_type;
     entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
-    if (conn->_base.state != AP_CONN_STATE_RESOLVE_WAIT) {
+    if (conn->base_.state != AP_CONN_STATE_RESOLVE_WAIT) {
       log_fn(LOG_PROTOCOL_WARN, LD_APP, "Got a 'resolved' cell while "
              "not in state resolve_wait. Dropping.");
       return 0;
@@ -1001,8 +1001,8 @@ connection_edge_process_relay_cell_not_open(
 
   log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
          "Got an unexpected relay command %d, in state %d (%s). Dropping.",
-         rh->command, conn->_base.state,
-         conn_state_to_string(conn->_base.type, conn->_base.state));
+         rh->command, conn->base_.state,
+         conn_state_to_string(conn->base_.type, conn->base_.state));
   return 0; /* for forward compatibility, don't kill the circuit */
 //  connection_edge_end(conn, END_STREAM_REASON_TORPROTOCOL);
 //  connection_mark_for_close(conn);
@@ -1050,9 +1050,9 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
    * conn points to the recognized stream. */
 
   if (conn && !connection_state_is_open(TO_CONN(conn))) {
-    if (conn->_base.type == CONN_TYPE_EXIT &&
-        (conn->_base.state == EXIT_CONN_STATE_CONNECTING ||
-         conn->_base.state == EXIT_CONN_STATE_RESOLVING) &&
+    if (conn->base_.type == CONN_TYPE_EXIT &&
+        (conn->base_.state == EXIT_CONN_STATE_CONNECTING ||
+         conn->base_.state == EXIT_CONN_STATE_RESOLVING) &&
         rh.command == RELAY_COMMAND_DATA) {
       /* Allow DATA cells to be delivered to an exit node in state
        * EXIT_CONN_STATE_CONNECTING or EXIT_CONN_STATE_RESOLVING.
@@ -1152,10 +1152,10 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
       }
 /* XXX add to this log_fn the exit node's nickname? */
       log_info(domain,"%d: end cell (%s) for stream %d. Removing stream.",
-               conn->_base.s,
+               conn->base_.s,
                stream_end_reason_to_string(reason),
                conn->stream_id);
-      if (conn->_base.type == CONN_TYPE_AP) {
+      if (conn->base_.type == CONN_TYPE_AP) {
         entry_connection_t *entry_conn = EDGE_TO_ENTRY_CONN(conn);
         if (entry_conn->socks_request &&
             !entry_conn->socks_request->has_finished)
@@ -1166,7 +1166,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
       conn->edge_has_sent_end = 1;
       if (!conn->end_reason)
         conn->end_reason = reason | END_STREAM_REASON_FLAG_REMOTE;
-      if (!conn->_base.marked_for_close) {
+      if (!conn->base_.marked_for_close) {
         /* only mark it if not already marked. it's possible to
          * get the 'end' right around when the client hangs up on us. */
         connection_mark_and_flush(TO_CONN(conn));
@@ -1392,21 +1392,21 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
   size_t bytes_to_process, length;
   char payload[CELL_PAYLOAD_SIZE];
   circuit_t *circ;
-  const unsigned domain = conn->_base.type == CONN_TYPE_AP ? LD_APP : LD_EXIT;
+  const unsigned domain = conn->base_.type == CONN_TYPE_AP ? LD_APP : LD_EXIT;
   int sending_from_optimistic = 0;
   const int sending_optimistically =
-    conn->_base.type == CONN_TYPE_AP &&
-    conn->_base.state != AP_CONN_STATE_OPEN;
+    conn->base_.type == CONN_TYPE_AP &&
+    conn->base_.state != AP_CONN_STATE_OPEN;
   entry_connection_t *entry_conn =
-    conn->_base.type == CONN_TYPE_AP ? EDGE_TO_ENTRY_CONN(conn) : NULL;
+    conn->base_.type == CONN_TYPE_AP ? EDGE_TO_ENTRY_CONN(conn) : NULL;
   crypt_path_t *cpath_layer = conn->cpath_layer;
 
   tor_assert(conn);
 
-  if (conn->_base.marked_for_close) {
+  if (conn->base_.marked_for_close) {
     log_warn(LD_BUG,
              "called on conn that's already marked for close at %s:%d.",
-             conn->_base.marked_for_close_file, conn->_base.marked_for_close);
+             conn->base_.marked_for_close_file, conn->base_.marked_for_close);
     return 0;
   }
 
@@ -1473,7 +1473,7 @@ connection_edge_package_raw_inbuf(edge_connection_t *conn, int package_partial,
     connection_fetch_from_buf(payload, length, TO_CONN(conn));
   }
 
-  log_debug(domain,"(%d) Packaging %d bytes (%d waiting).", conn->_base.s,
+  log_debug(domain,"(%d) Packaging %d bytes (%d waiting).", conn->base_.s,
             (int)length, (int)connection_get_inbuf_len(TO_CONN(conn)));
 
   if (sending_optimistically && !sending_from_optimistic) {
@@ -1539,9 +1539,9 @@ connection_edge_consider_sending_sendme(edge_connection_t *conn)
   }
 
   while (conn->deliver_window <= STREAMWINDOW_START - STREAMWINDOW_INCREMENT) {
-    log_debug(conn->_base.type == CONN_TYPE_AP ?LD_APP:LD_EXIT,
+    log_debug(conn->base_.type == CONN_TYPE_AP ?LD_APP:LD_EXIT,
               "Outbuf %d, Queuing stream sendme.",
-              (int)conn->_base.outbuf_flushlen);
+              (int)conn->base_.outbuf_flushlen);
     conn->deliver_window += STREAMWINDOW_INCREMENT;
     if (connection_edge_send_command(conn, RELAY_COMMAND_SENDME,
                                      NULL, 0) < 0) {
@@ -1630,7 +1630,7 @@ circuit_resume_edge_reading_helper(edge_connection_t *first_conn,
   /* Activate reading starting from the chosen stream */
   for (conn=chosen_stream; conn; conn = conn->next_stream) {
     /* Start reading for the streams starting from here */
-    if (conn->_base.marked_for_close || conn->package_window <= 0)
+    if (conn->base_.marked_for_close || conn->package_window <= 0)
       continue;
     if (!layer_hint || conn->cpath_layer == layer_hint) {
       connection_start_reading(TO_CONN(conn));
@@ -1641,7 +1641,7 @@ circuit_resume_edge_reading_helper(edge_connection_t *first_conn,
   }
   /* Go back and do the ones we skipped, circular-style */
   for (conn = first_conn; conn != chosen_stream; conn = conn->next_stream) {
-    if (conn->_base.marked_for_close || conn->package_window <= 0)
+    if (conn->base_.marked_for_close || conn->package_window <= 0)
       continue;
     if (!layer_hint || conn->cpath_layer == layer_hint) {
       connection_start_reading(TO_CONN(conn));
@@ -1667,7 +1667,7 @@ circuit_resume_edge_reading_helper(edge_connection_t *first_conn,
    * package.
    */
   for (conn=first_conn; conn; conn=conn->next_stream) {
-    if (conn->_base.marked_for_close || conn->package_window <= 0)
+    if (conn->base_.marked_for_close || conn->package_window <= 0)
       continue;
     if (!layer_hint || conn->cpath_layer == layer_hint) {
       int n = cells_per_conn, r;
@@ -1857,7 +1857,7 @@ dump_cell_pool_usage(int severity)
   circuit_t *c;
   int n_circs = 0;
   int n_cells = 0;
-  for (c = _circuit_get_global_list(); c; c = c->next) {
+  for (c = circuit_get_global_list_(); c; c = c->next) {
     n_cells += c->n_chan_cells.n;
     if (!CIRCUIT_IS_ORIGIN(c))
       n_cells += TO_OR_CIRCUIT(c)->p_chan_cells.n;

+ 2 - 2
src/or/relay.h

@@ -9,8 +9,8 @@
  * \brief Header file for relay.c.
  **/
 
-#ifndef _TOR_RELAY_H
-#define _TOR_RELAY_H
+#ifndef TOR_RELAY_H
+#define TOR_RELAY_H
 
 extern uint64_t stats_n_relay_cells_relayed;
 extern uint64_t stats_n_relay_cells_delivered;

+ 17 - 17
src/or/rendclient.c

@@ -44,7 +44,7 @@ rend_client_purge_state(void)
 void
 rend_client_introcirc_has_opened(origin_circuit_t *circ)
 {
-  tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
+  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
   tor_assert(circ->cpath);
 
   log_info(LD_REND,"introcirc is open");
@@ -57,7 +57,7 @@ rend_client_introcirc_has_opened(origin_circuit_t *circ)
 static int
 rend_client_send_establish_rendezvous(origin_circuit_t *circ)
 {
-  tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
+  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
   tor_assert(circ->rend_data);
   log_info(LD_REND, "Sending an ESTABLISH_RENDEZVOUS cell");
 
@@ -103,13 +103,13 @@ rend_client_reextend_intro_circuit(origin_circuit_t *circ)
   if (circ->remaining_relay_early_cells) {
     log_info(LD_REND,
              "Re-extending circ %d, this time to %s.",
-             circ->_base.n_circ_id,
+             circ->base_.n_circ_id,
              safe_str_client(extend_info_describe(extend_info)));
     result = circuit_extend_to_new_exit(circ, extend_info);
   } else {
     log_info(LD_REND,
              "Closing intro circ %d (out of RELAY_EARLY cells).",
-             circ->_base.n_circ_id);
+             circ->base_.n_circ_id);
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_FINISHED);
     /* connection_ap_handshake_attach_circuit will launch a new intro circ. */
     result = 0;
@@ -135,8 +135,8 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
   crypto_pk_t *intro_key = NULL;
   int status = 0;
 
-  tor_assert(introcirc->_base.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
-  tor_assert(rendcirc->_base.purpose == CIRCUIT_PURPOSE_C_REND_READY);
+  tor_assert(introcirc->base_.purpose == CIRCUIT_PURPOSE_C_INTRODUCING);
+  tor_assert(rendcirc->base_.purpose == CIRCUIT_PURPOSE_C_REND_READY);
   tor_assert(introcirc->rend_data);
   tor_assert(rendcirc->rend_data);
   tor_assert(!rend_cmp_service_ids(introcirc->rend_data->onion_address,
@@ -308,12 +308,12 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
   /* Set timestamp_dirty, because circuit_expire_building expects it
    * to specify when a circuit entered the _C_INTRODUCE_ACK_WAIT
    * state. */
-  introcirc->_base.timestamp_dirty = time(NULL);
+  introcirc->base_.timestamp_dirty = time(NULL);
 
   goto cleanup;
 
  perm_err:
-  if (!introcirc->_base.marked_for_close)
+  if (!introcirc->base_.marked_for_close)
     circuit_mark_for_close(TO_CIRCUIT(introcirc), END_CIRC_REASON_INTERNAL);
   circuit_mark_for_close(TO_CIRCUIT(rendcirc), END_CIRC_REASON_INTERNAL);
  cleanup:
@@ -328,7 +328,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
 void
 rend_client_rendcirc_has_opened(origin_circuit_t *circ)
 {
-  tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
+  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
 
   log_info(LD_REND,"rendcirc is open");
 
@@ -347,10 +347,10 @@ rend_client_introduction_acked(origin_circuit_t *circ,
   origin_circuit_t *rendcirc;
   (void) request; // XXXX Use this.
 
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) {
     log_warn(LD_PROTOCOL,
              "Received REND_INTRODUCE_ACK on unexpected circuit %d.",
-             circ->_base.n_circ_id);
+             circ->base_.n_circ_id);
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
     return -1;
   }
@@ -377,7 +377,7 @@ rend_client_introduction_acked(origin_circuit_t *circ,
       /* Set timestamp_dirty, because circuit_expire_building expects
        * it to specify when a circuit entered the
        * _C_REND_READY_INTRO_ACKED state. */
-      rendcirc->_base.timestamp_dirty = time(NULL);
+      rendcirc->base_.timestamp_dirty = time(NULL);
     } else {
       log_info(LD_REND,"...Found no rend circ. Dropping on the floor.");
     }
@@ -541,7 +541,7 @@ rend_client_purge_last_hid_serv_requests(void)
 
   if (old_last_hid_serv_requests != NULL) {
     log_info(LD_REND, "Purging client last-HS-desc-request-time table");
-    strmap_free(old_last_hid_serv_requests, _tor_free);
+    strmap_free(old_last_hid_serv_requests, tor_free_);
   }
 }
 
@@ -846,7 +846,7 @@ rend_client_rendezvous_acked(origin_circuit_t *circ, const uint8_t *request,
   (void) request;
   (void) request_len;
   /* we just got an ack for our establish-rendezvous. switch purposes. */
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_C_ESTABLISH_REND) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_C_ESTABLISH_REND) {
     log_warn(LD_PROTOCOL,"Got a rendezvous ack when we weren't expecting one. "
              "Closing circ.");
     circuit_mark_for_close(TO_CIRCUIT(circ), END_CIRC_REASON_TORPROTOCOL);
@@ -857,7 +857,7 @@ rend_client_rendezvous_acked(origin_circuit_t *circ, const uint8_t *request,
   circuit_change_purpose(TO_CIRCUIT(circ), CIRCUIT_PURPOSE_C_REND_READY);
   /* Set timestamp_dirty, because circuit_expire_building expects it
    * to specify when a circuit entered the _C_REND_READY state. */
-  circ->_base.timestamp_dirty = time(NULL);
+  circ->base_.timestamp_dirty = time(NULL);
   /* XXXX This is a pretty brute-force approach. It'd be better to
    * attach only the connections that are waiting on this circuit, rather
    * than trying to attach them all. See comments bug 743. */
@@ -875,8 +875,8 @@ rend_client_receive_rendezvous(origin_circuit_t *circ, const uint8_t *request,
   crypt_path_t *hop;
   char keys[DIGEST_LEN+CPATH_KEY_MATERIAL_LEN];
 
-  if ((circ->_base.purpose != CIRCUIT_PURPOSE_C_REND_READY &&
-       circ->_base.purpose != CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)
+  if ((circ->base_.purpose != CIRCUIT_PURPOSE_C_REND_READY &&
+       circ->base_.purpose != CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)
       || !circ->build_state->pending_final_cpath) {
     log_warn(LD_PROTOCOL,"Got rendezvous2 cell from hidden service, but not "
              "expecting it. Closing.");

+ 2 - 2
src/or/rendclient.h

@@ -9,8 +9,8 @@
  * \brief Header file for rendclient.c.
  **/
 
-#ifndef _TOR_RENDCLIENT_H
-#define _TOR_RENDCLIENT_H
+#ifndef TOR_RENDCLIENT_H
+#define TOR_RENDCLIENT_H
 
 void rend_client_purge_state(void);
 

+ 4 - 4
src/or/rendcommon.c

@@ -800,7 +800,7 @@ rend_cache_entry_free(rend_cache_entry_t *e)
 /** Helper: deallocate a rend_cache_entry_t.  (Used with strmap_free(), which
  * requires a function pointer whose argument is void*). */
 static void
-_rend_cache_entry_free(void *p)
+rend_cache_entry_free_(void *p)
 {
   rend_cache_entry_free(p);
 }
@@ -809,8 +809,8 @@ _rend_cache_entry_free(void *p)
 void
 rend_cache_free_all(void)
 {
-  strmap_free(rend_cache, _rend_cache_entry_free);
-  digestmap_free(rend_cache_v2_dir, _rend_cache_entry_free);
+  strmap_free(rend_cache, rend_cache_entry_free_);
+  digestmap_free(rend_cache_v2_dir, rend_cache_entry_free_);
   rend_cache = NULL;
   rend_cache_v2_dir = NULL;
 }
@@ -844,7 +844,7 @@ rend_cache_purge(void)
 {
   if (rend_cache) {
     log_info(LD_REND, "Purging client/v0-HS-authority HS descriptor cache");
-    strmap_free(rend_cache, _rend_cache_entry_free);
+    strmap_free(rend_cache, rend_cache_entry_free_);
   }
   rend_cache = strmap_new();
 }

+ 2 - 2
src/or/rendcommon.h

@@ -9,8 +9,8 @@
  * \brief Header file for rendcommon.c.
  **/
 
-#ifndef _TOR_RENDCOMMON_H
-#define _TOR_RENDCOMMON_H
+#ifndef TOR_RENDCOMMON_H
+#define TOR_RENDCOMMON_H
 
 /** Free all storage associated with <b>data</b> */
 static INLINE void

+ 4 - 4
src/or/rendmid.c

@@ -35,7 +35,7 @@ rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
            "Received an ESTABLISH_INTRO request on circuit %d",
            circ->p_circ_id);
 
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_OR || circ->_base.n_chan) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
          "Rejecting ESTABLISH_INTRO on non-OR or non-edge circuit.");
     reason = END_CIRC_REASON_TORPROTOCOL;
@@ -142,7 +142,7 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
   log_info(LD_REND, "Received an INTRODUCE1 request on circuit %d",
            circ->p_circ_id);
 
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_OR || circ->_base.n_chan) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_warn(LD_PROTOCOL,
              "Rejecting INTRODUCE1 on non-OR or non-edge circuit %d.",
              circ->p_circ_id);
@@ -224,7 +224,7 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request,
   log_info(LD_REND, "Received an ESTABLISH_RENDEZVOUS request on circuit %d",
            circ->p_circ_id);
 
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_OR || circ->_base.n_chan) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_warn(LD_PROTOCOL,
              "Tried to establish rendezvous on non-OR or non-edge circuit.");
     goto err;
@@ -277,7 +277,7 @@ rend_mid_rendezvous(or_circuit_t *circ, const uint8_t *request,
   char hexid[9];
   int reason = END_CIRC_REASON_INTERNAL;
 
-  if (circ->_base.purpose != CIRCUIT_PURPOSE_OR || circ->_base.n_chan) {
+  if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
     log_info(LD_REND,
              "Tried to complete rendezvous on non-OR or non-edge circuit %d.",
              circ->p_circ_id);

+ 2 - 2
src/or/rendmid.h

@@ -9,8 +9,8 @@
  * \brief Header file for rendmid.c.
  **/
 
-#ifndef _TOR_RENDMID_H
-#define _TOR_RENDMID_H
+#ifndef TOR_RENDMID_H
+#define TOR_RENDMID_H
 
 int rend_mid_establish_intro(or_circuit_t *circ, const uint8_t *request,
                              size_t request_len);

+ 31 - 31
src/or/rendservice.c

@@ -543,7 +543,7 @@ rend_config_services(const or_options_t *options, int validate_only)
     /* XXXX it would be nicer if we had a nicer abstraction to use here,
      * so we could just iterate over the list of services to close, but
      * once again, this isn't critical-path code. */
-    for (circ = _circuit_get_global_list(); circ; circ = circ->next) {
+    for (circ = circuit_get_global_list_(); circ; circ = circ->next) {
       if (!circ->marked_for_close &&
           circ->state == CIRCUIT_STATE_OPEN &&
           (circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
@@ -610,7 +610,7 @@ rend_service_update_descriptor(rend_service_t *service)
     }
 
     circ = find_intro_circuit(intro_svc, service->pk_digest);
-    if (!circ || circ->_base.purpose != CIRCUIT_PURPOSE_S_INTRO) {
+    if (!circ || circ->base_.purpose != CIRCUIT_PURPOSE_S_INTRO) {
       /* This intro point's circuit isn't finished yet.  Don't list it. */
       continue;
     }
@@ -1128,10 +1128,10 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   int replay;
 
   /* Do some initial validation and logging before we parse the cell */
-  if (circuit->_base.purpose != CIRCUIT_PURPOSE_S_INTRO) {
+  if (circuit->base_.purpose != CIRCUIT_PURPOSE_S_INTRO) {
     log_warn(LD_PROTOCOL,
              "Got an INTRODUCE2 over a non-introduction circuit %d.",
-             circuit->_base.n_circ_id);
+             circuit->base_.n_circ_id);
     goto err;
   }
 
@@ -1166,7 +1166,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   }
 
   log_info(LD_REND, "Received INTRODUCE2 cell for service %s on circ %d.",
-           escaped(serviceid), circuit->_base.n_circ_id);
+           escaped(serviceid), circuit->base_.n_circ_id);
 
   /* use intro key instead of service key. */
   intro_key = circuit->intro_key;
@@ -1181,7 +1181,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (!parsed_req) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->_base.n_circ_id);
+    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1191,7 +1191,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->_base.n_circ_id);
+    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1227,7 +1227,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->_base.n_circ_id);
+    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1237,7 +1237,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->_base.n_circ_id);
+    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
 
@@ -1247,7 +1247,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
   if (result < 0) {
     goto log_error;
   } else if (err_msg) {
-    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->_base.n_circ_id);
+    log_info(LD_REND, "%s on circ %d.", err_msg, circuit->base_.n_circ_id);
     tor_free(err_msg);
   }
   stage_descr = NULL;
@@ -1396,7 +1396,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
     }
   }
 
-  log_warn(LD_REND, "%s on circ %d", err_msg, circuit->_base.n_circ_id);
+  log_warn(LD_REND, "%s on circ %d", err_msg, circuit->base_.n_circ_id);
  err:
   status = -1;
   if (dh) crypto_dh_free(dh);
@@ -2264,7 +2264,7 @@ rend_service_relaunch_rendezvous(origin_circuit_t *oldcirc)
   origin_circuit_t *newcirc;
   cpath_build_state_t *newstate, *oldstate;
 
-  tor_assert(oldcirc->_base.purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
+  tor_assert(oldcirc->base_.purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
 
   /* Don't relaunch the same rend circ twice. */
   if (oldcirc->hs_service_side_rend_circ_has_been_relaunched) {
@@ -2369,7 +2369,7 @@ rend_service_launch_establish_intro(rend_service_t *service,
           sizeof(launched->rend_data->onion_address));
   memcpy(launched->rend_data->rend_pk_digest, service->pk_digest, DIGEST_LEN);
   launched->intro_key = crypto_pk_dup_key(intro->intro_key);
-  if (launched->_base.state == CIRCUIT_STATE_OPEN)
+  if (launched->base_.state == CIRCUIT_STATE_OPEN)
     rend_service_intro_has_opened(launched);
   return 0;
 }
@@ -2381,7 +2381,7 @@ count_established_intro_points(const char *query)
 {
   int num_ipos = 0;
   circuit_t *circ;
-  for (circ = _circuit_get_global_list(); circ; circ = circ->next) {
+  for (circ = circuit_get_global_list_(); circ; circ = circ->next) {
     if (!circ->marked_for_close &&
         circ->state == CIRCUIT_STATE_OPEN &&
         (circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
@@ -2410,7 +2410,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
   int reason = END_CIRC_REASON_TORPROTOCOL;
   crypto_pk_t *intro_key;
 
-  tor_assert(circuit->_base.purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
+  tor_assert(circuit->base_.purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO);
 #ifndef NON_ANONYMOUS_MODE_ENABLED
   tor_assert(!(circuit->build_state->onehop_tunnel));
 #endif
@@ -2424,7 +2424,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
                 circuit->rend_data->rend_pk_digest);
   if (!service) {
     log_warn(LD_REND, "Unrecognized service ID %s on introduction circuit %d.",
-             serviceid, circuit->_base.n_circ_id);
+             serviceid, circuit->base_.n_circ_id);
     reason = END_CIRC_REASON_NOSUCHSERVICE;
     goto err;
   }
@@ -2468,7 +2468,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
 
   log_info(LD_REND,
            "Established circuit %d as introduction point for service %s",
-           circuit->_base.n_circ_id, serviceid);
+           circuit->base_.n_circ_id, serviceid);
 
   /* Use the intro key instead of the service key in ESTABLISH_INTRO. */
   intro_key = circuit->intro_key;
@@ -2503,7 +2503,7 @@ rend_service_intro_has_opened(origin_circuit_t *circuit)
                                    buf, len, circuit->cpath->prev)<0) {
     log_info(LD_GENERAL,
              "Couldn't send introduction request for service %s on circuit %d",
-             serviceid, circuit->_base.n_circ_id);
+             serviceid, circuit->base_.n_circ_id);
     reason = END_CIRC_REASON_INTERNAL;
     goto err;
   }
@@ -2533,7 +2533,7 @@ rend_service_intro_established(origin_circuit_t *circuit,
   (void) request;
   (void) request_len;
 
-  if (circuit->_base.purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
+  if (circuit->base_.purpose != CIRCUIT_PURPOSE_S_ESTABLISH_INTRO) {
     log_warn(LD_PROTOCOL,
              "received INTRO_ESTABLISHED cell on non-intro circuit.");
     goto err;
@@ -2543,7 +2543,7 @@ rend_service_intro_established(origin_circuit_t *circuit,
                 circuit->rend_data->rend_pk_digest);
   if (!service) {
     log_warn(LD_REND, "Unknown service on introduction circuit %d.",
-             circuit->_base.n_circ_id);
+             circuit->base_.n_circ_id);
     goto err;
   }
   service->desc_is_dirty = time(NULL);
@@ -2553,7 +2553,7 @@ rend_service_intro_established(origin_circuit_t *circuit,
                 circuit->rend_data->rend_pk_digest, REND_SERVICE_ID_LEN);
   log_info(LD_REND,
            "Received INTRO_ESTABLISHED cell on circuit %d for service %s",
-           circuit->_base.n_circ_id, serviceid);
+           circuit->base_.n_circ_id, serviceid);
 
   return 0;
  err:
@@ -2574,7 +2574,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
   char hexcookie[9];
   int reason;
 
-  tor_assert(circuit->_base.purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
+  tor_assert(circuit->base_.purpose == CIRCUIT_PURPOSE_S_CONNECT_REND);
   tor_assert(circuit->cpath);
   tor_assert(circuit->build_state);
 #ifndef NON_ANONYMOUS_MODE_ENABLED
@@ -2590,7 +2590,7 @@ rend_service_rendezvous_has_opened(origin_circuit_t *circuit)
   log_info(LD_REND,
            "Done building circuit %d to rendezvous with "
            "cookie %s for service %s",
-           circuit->_base.n_circ_id, hexcookie, serviceid);
+           circuit->base_.n_circ_id, hexcookie, serviceid);
 
   /* Clear the 'in-progress HS circ has timed out' flag for
    * consistency with what happens on the client side; this line has
@@ -3150,7 +3150,7 @@ rend_services_introduce(void)
          j < (int)n_intro_points_to_open;
          ++j) { /* XXXX remove casts */
       router_crn_flags_t flags = CRN_NEED_UPTIME|CRN_NEED_DESC;
-      if (get_options()->_AllowInvalid & ALLOW_INVALID_INTRODUCTION)
+      if (get_options()->AllowInvalid_ & ALLOW_INVALID_INTRODUCTION)
         flags |= CRN_ALLOW_INVALID;
       node = router_choose_random_node(intro_nodes,
                                        options->ExcludeNodes, flags);
@@ -3300,7 +3300,7 @@ rend_service_dump_stats(int severity)
         continue;
       }
       log(severity, LD_GENERAL, "  Intro point %d at %s: circuit is %s",
-          j, safe_name, circuit_state_to_string(circ->_base.state));
+          j, safe_name, circuit_state_to_string(circ->base_.state));
     }
   }
 }
@@ -3319,7 +3319,7 @@ rend_service_set_connection_addr_port(edge_connection_t *conn,
   smartlist_t *matching_ports;
   rend_service_port_config_t *chosen_port;
 
-  tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_S_REND_JOINED);
+  tor_assert(circ->base_.purpose == CIRCUIT_PURPOSE_S_REND_JOINED);
   tor_assert(circ->rend_data);
   log_debug(LD_REND,"beginning to hunt for addr/port");
   base32_encode(serviceid, REND_SERVICE_ID_LEN_BASE32+1,
@@ -3329,25 +3329,25 @@ rend_service_set_connection_addr_port(edge_connection_t *conn,
   if (!service) {
     log_warn(LD_REND, "Couldn't find any service associated with pk %s on "
              "rendezvous circuit %d; closing.",
-             serviceid, circ->_base.n_circ_id);
+             serviceid, circ->base_.n_circ_id);
     return -1;
   }
   matching_ports = smartlist_new();
   SMARTLIST_FOREACH(service->ports, rend_service_port_config_t *, p,
   {
-    if (conn->_base.port == p->virtual_port) {
+    if (conn->base_.port == p->virtual_port) {
       smartlist_add(matching_ports, p);
     }
   });
   chosen_port = smartlist_choose(matching_ports);
   smartlist_free(matching_ports);
   if (chosen_port) {
-    tor_addr_copy(&conn->_base.addr, &chosen_port->real_addr);
-    conn->_base.port = chosen_port->real_port;
+    tor_addr_copy(&conn->base_.addr, &chosen_port->real_addr);
+    conn->base_.port = chosen_port->real_port;
     return 0;
   }
   log_info(LD_REND, "No virtual port mapping exists for port %d on service %s",
-           conn->_base.port,serviceid);
+           conn->base_.port,serviceid);
   return -1;
 }
 

+ 2 - 2
src/or/rendservice.h

@@ -9,8 +9,8 @@
  * \brief Header file for rendservice.c.
  **/
 
-#ifndef _TOR_RENDSERVICE_H
-#define _TOR_RENDSERVICE_H
+#ifndef TOR_RENDSERVICE_H
+#define TOR_RENDSERVICE_H
 
 #include "or.h"
 

+ 7 - 7
src/or/rephist.c

@@ -160,7 +160,7 @@ get_link_history(const char *from_id, const char *to_id)
 
 /** Helper: free storage held by a single link history entry. */
 static void
-_free_link_history(void *val)
+free_link_history_(void *val)
 {
   rephist_total_alloc -= sizeof(link_history_t);
   tor_free(val);
@@ -171,7 +171,7 @@ static void
 free_or_history(void *_hist)
 {
   or_history_t *hist = _hist;
-  digestmap_free(hist->link_history_map, _free_link_history);
+  digestmap_free(hist->link_history_map, free_link_history_);
   rephist_total_alloc -= sizeof(or_history_t);
   rephist_total_num--;
   tor_free(hist);
@@ -2131,7 +2131,7 @@ rep_hist_exit_stats_term(void)
  * but works fine for sorting an array of port numbers, which is what we use
  * it for. */
 static int
-_compare_int(const void *x, const void *y)
+compare_int_(const void *x, const void *y)
 {
   return (*(int*)x - *(int*)y);
 }
@@ -2218,7 +2218,7 @@ rep_hist_format_exit_stats(time_t now)
   other_streams = total_streams;
   /* Sort the ports; this puts them out of sync with top_bytes, but we
    * won't be using top_bytes again anyway */
-  qsort(top_ports, top_elements, sizeof(int), _compare_int);
+  qsort(top_ports, top_elements, sizeof(int), compare_int_);
   for (j = 0; j < top_elements; j++) {
     cur_port = top_ports[j];
     if (exit_bytes_written[cur_port] > 0) {
@@ -2440,7 +2440,7 @@ rep_hist_buffer_stats_add_circ(circuit_t *circ, time_t end_of_interval)
 /** Sorting helper: return -1, 1, or 0 based on comparison of two
  * circ_buffer_stats_t */
 static int
-_buffer_stats_compare_entries(const void **_a, const void **_b)
+buffer_stats_compare_entries_(const void **_a, const void **_b)
 {
   const circ_buffer_stats_t *a = *_a, *b = *_b;
   if (a->processed_cells < b->processed_cells)
@@ -2505,7 +2505,7 @@ rep_hist_format_buffer_stats(time_t now)
   number_of_circuits = smartlist_len(circuits_for_buffer_stats);
   if (number_of_circuits > 0) {
     smartlist_sort(circuits_for_buffer_stats,
-                   _buffer_stats_compare_entries);
+                   buffer_stats_compare_entries_);
     i = 0;
     SMARTLIST_FOREACH_BEGIN(circuits_for_buffer_stats,
                             circ_buffer_stats_t *, stat)
@@ -2590,7 +2590,7 @@ rep_hist_buffer_stats_write(time_t now)
     goto done; /* Not ready to write */
 
   /* Add open circuits to the history. */
-  for (circ = _circuit_get_global_list(); circ; circ = circ->next) {
+  for (circ = circuit_get_global_list_(); circ; circ = circ->next) {
     rep_hist_buffer_stats_add_circ(circ, now);
   }
 

+ 2 - 2
src/or/rephist.h

@@ -9,8 +9,8 @@
  * \brief Header file for rephist.c.
  **/
 
-#ifndef _TOR_REPHIST_H
-#define _TOR_REPHIST_H
+#ifndef TOR_REPHIST_H
+#define TOR_REPHIST_H
 
 void rep_hist_init(void);
 void rep_hist_note_connect_failed(const char* nickname, time_t when);

+ 1 - 1
src/or/replaycache.c

@@ -23,7 +23,7 @@ replaycache_free(replaycache_t *r)
     return;
   }
 
-  if (r->digests_seen) digestmap_free(r->digests_seen, _tor_free);
+  if (r->digests_seen) digestmap_free(r->digests_seen, tor_free_);
 
   tor_free(r);
 }

+ 2 - 2
src/or/replaycache.h

@@ -6,8 +6,8 @@
  * \brief Header file for replaycache.c.
  **/
 
-#ifndef _TOR_REPLAYCACHE_H
-#define _TOR_REPLAYCACHE_H
+#ifndef TOR_REPLAYCACHE_H
+#define TOR_REPLAYCACHE_H
 
 typedef struct replaycache_s replaycache_t;
 

+ 11 - 11
src/or/router.c

@@ -970,7 +970,7 @@ router_orport_found_reachable(void)
   if (!can_reach_or_port && me) {
     log_notice(LD_OR,"Self-testing indicates your ORPort is reachable from "
                "the outside. Excellent.%s",
-               get_options()->_PublishServerDescriptor != NO_DIRINFO ?
+               get_options()->PublishServerDescriptor_ != NO_DIRINFO ?
                  " Publishing server descriptor." : "");
     can_reach_or_port = 1;
     mark_my_descriptor_dirty("ORPort found reachable");
@@ -1013,9 +1013,9 @@ router_perform_bandwidth_test(int num_circs, time_t now)
                                               CIRCUIT_PURPOSE_TESTING))) {
     /* dump cells_per_circuit drop cells onto this circ */
     int i = cells_per_circuit;
-    if (circ->_base.state != CIRCUIT_STATE_OPEN)
+    if (circ->base_.state != CIRCUIT_STATE_OPEN)
       continue;
-    circ->_base.timestamp_dirty = now;
+    circ->base_.timestamp_dirty = now;
     while (i-- > 0) {
       if (relay_send_command_from_edge(0, TO_CIRCUIT(circ),
                                        RELAY_COMMAND_DROP,
@@ -1209,7 +1209,7 @@ decide_if_publishable_server(void)
 
   if (options->ClientOnly)
     return 0;
-  if (options->_PublishServerDescriptor == NO_DIRINFO)
+  if (options->PublishServerDescriptor_ == NO_DIRINFO)
     return 0;
   if (!server_mode(options))
     return 0;
@@ -1330,7 +1330,7 @@ router_upload_dir_desc_to_dirservers(int force)
   extrainfo_t *ei;
   char *msg;
   size_t desc_len, extra_len = 0, total_len;
-  dirinfo_type_t auth = get_options()->_PublishServerDescriptor;
+  dirinfo_type_t auth = get_options()->PublishServerDescriptor_;
 
   ri = router_get_my_routerinfo();
   if (!ri) {
@@ -1377,14 +1377,14 @@ router_compare_to_my_exit_policy(edge_connection_t *conn)
 
   /* make sure it's resolved to something. this way we can't get a
      'maybe' below. */
-  if (tor_addr_is_null(&conn->_base.addr))
+  if (tor_addr_is_null(&conn->base_.addr))
     return -1;
 
   /* XXXX IPv6 */
-  if (tor_addr_family(&conn->_base.addr) != AF_INET)
+  if (tor_addr_family(&conn->base_.addr) != AF_INET)
     return -1;
 
-  return compare_tor_addr_to_addr_policy(&conn->_base.addr, conn->_base.port,
+  return compare_tor_addr_to_addr_policy(&conn->base_.addr, conn->base_.port,
                    desc_routerinfo->exit_policy) != ADDR_POLICY_ACCEPTED;
 }
 
@@ -1796,7 +1796,7 @@ void
 mark_my_descriptor_dirty(const char *reason)
 {
   const or_options_t *options = get_options();
-  if (server_mode(options) && options->_PublishServerDescriptor)
+  if (server_mode(options) && options->PublishServerDescriptor_)
     log_info(LD_OR, "Decided to publish new relay descriptor: %s", reason);
   desc_clean_since = 0;
   if (!desc_dirty_reason)
@@ -1928,7 +1928,7 @@ router_new_address_suggestion(const char *suggestion,
     /* Don't believe anybody who says our IP is, say, 127.0.0.1. */
     return;
   }
-  if (tor_addr_eq(&d_conn->_base.addr, &addr)) {
+  if (tor_addr_eq(&d_conn->base_.addr, &addr)) {
     /* Don't believe anybody who says our IP is their IP. */
     log_debug(LD_DIR, "A directory server told us our IP address is %s, "
               "but he's just reporting his own IP address. Ignoring.",
@@ -1944,7 +1944,7 @@ router_new_address_suggestion(const char *suggestion,
                                 "EXTERNAL_ADDRESS ADDRESS=%s METHOD=DIRSERV",
                                 suggestion);
     log_addr_has_changed(LOG_NOTICE, &last_guessed_ip, &addr,
-                         d_conn->_base.address);
+                         d_conn->base_.address);
     ip_address_changed(0);
     tor_addr_copy(&last_guessed_ip, &addr); /* router_rebuild_descriptor()
                                                will fetch it */

+ 2 - 2
src/or/router.h

@@ -9,8 +9,8 @@
  * \brief Header file for router.c.
  **/
 
-#ifndef _TOR_ROUTER_H
-#define _TOR_ROUTER_H
+#ifndef TOR_ROUTER_H
+#define TOR_ROUTER_H
 
 crypto_pk_t *get_onion_key(void);
 time_t get_onion_key_set_at(void);

+ 19 - 19
src/or/routerlist.c

@@ -654,7 +654,7 @@ signed_desc_append_to_journal(signed_descriptor_t *desc,
  * signed_descriptor_t* in *<b>a</b> is older, the same age as, or newer than
  * the signed_descriptor_t* in *<b>b</b>. */
 static int
-_compare_signed_descriptors_by_age(const void **_a, const void **_b)
+compare_signed_descriptors_by_age_(const void **_a, const void **_b)
 {
   const signed_descriptor_t *r1 = *_a, *r2 = *_b;
   return (int)(r1->published_on - r2->published_on);
@@ -727,7 +727,7 @@ router_rebuild_store(int flags, desc_store_t *store)
                       smartlist_add(signed_descriptors, &ri->cache_info));
   }
 
-  smartlist_sort(signed_descriptors, _compare_signed_descriptors_by_age);
+  smartlist_sort(signed_descriptors, compare_signed_descriptors_by_age_);
 
   /* Now, add the appropriate members to chunk_list */
   SMARTLIST_FOREACH_BEGIN(signed_descriptors, signed_descriptor_t *, sd) {
@@ -946,7 +946,7 @@ router_pick_directory_server(dirinfo_type_t type, int flags)
 {
   const routerstatus_t *choice;
   if (get_options()->PreferTunneledDirConns)
-    flags |= _PDS_PREFER_TUNNELED_DIR_CONNS;
+    flags |= PDS_PREFER_TUNNELED_DIR_CONNS_;
 
   if (!routerlist)
     return NULL;
@@ -1053,7 +1053,7 @@ router_pick_trusteddirserver(dirinfo_type_t type, int flags)
   const routerstatus_t *choice;
   int busy = 0;
   if (get_options()->PreferTunneledDirConns)
-    flags |= _PDS_PREFER_TUNNELED_DIR_CONNS;
+    flags |= PDS_PREFER_TUNNELED_DIR_CONNS_;
 
   choice = router_pick_trusteddirserver_impl(type, flags, &busy);
   if (choice || !(flags & PDS_RETRY_IF_NO_SERVERS))
@@ -1080,7 +1080,7 @@ router_pick_trusteddirserver(dirinfo_type_t type, int flags)
  * routerlist.  Arguments are as for router_pick_directory_server(), except
  * that RETRY_IF_NO_SERVERS is ignored, and:
  *
- * If the _PDS_PREFER_TUNNELED_DIR_CONNS flag is set, prefer directory servers
+ * If the PDS_PREFER_TUNNELED_DIR_CONNS_ flag is set, prefer directory servers
  * that we can use with BEGINDIR.
  */
 static const routerstatus_t *
@@ -1095,7 +1095,7 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags)
   const networkstatus_t *consensus = networkstatus_get_latest_consensus();
   int requireother = ! (flags & PDS_ALLOW_SELF);
   int fascistfirewall = ! (flags & PDS_IGNORE_FASCISTFIREWALL);
-  int prefer_tunnel = (flags & _PDS_PREFER_TUNNELED_DIR_CONNS);
+  int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_);
   int try_excluding = 1, n_excluded = 0;
 
   if (!consensus)
@@ -1210,7 +1210,7 @@ router_pick_trusteddirserver_impl(dirinfo_type_t type, int flags,
   time_t now = time(NULL);
   const int requireother = ! (flags & PDS_ALLOW_SELF);
   const int fascistfirewall = ! (flags & PDS_IGNORE_FASCISTFIREWALL);
-  const int prefer_tunnel = (flags & _PDS_PREFER_TUNNELED_DIR_CONNS);
+  const int prefer_tunnel = (flags & PDS_PREFER_TUNNELED_DIR_CONNS_);
   const int no_serverdesc_fetching =(flags & PDS_NO_EXISTING_SERVERDESC_FETCH);
   const int no_microdesc_fetching =(flags & PDS_NO_EXISTING_MICRODESC_FETCH);
   int n_busy = 0;
@@ -2451,7 +2451,7 @@ signed_descriptor_from_routerinfo(routerinfo_t *ri)
 
 /** Helper: free the storage held by the extrainfo_t in <b>e</b>. */
 static void
-_extrainfo_free(void *e)
+extrainfo_free_(void *e)
 {
   extrainfo_free(e);
 }
@@ -2465,7 +2465,7 @@ routerlist_free(routerlist_t *rl)
   rimap_free(rl->identity_map, NULL);
   sdmap_free(rl->desc_digest_map, NULL);
   sdmap_free(rl->desc_by_eid_map, NULL);
-  eimap_free(rl->extra_info_map, _extrainfo_free);
+  eimap_free(rl->extra_info_map, extrainfo_free_);
   SMARTLIST_FOREACH(rl->routers, routerinfo_t *, r,
                     routerinfo_free(r));
   SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
@@ -2507,7 +2507,7 @@ dump_routerlist_mem_usage(int severity)
  * <b>ri</b>.  Return the index of <b>ri</b> in <b>sl</b>, or -1 if <b>ri</b>
  * is not in <b>sl</b>. */
 static INLINE int
-_routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
+routerlist_find_elt_(smartlist_t *sl, void *ri, int idx)
 {
   if (idx < 0) {
     idx = -1;
@@ -2804,7 +2804,7 @@ routerlist_replace(routerlist_t *rl, routerinfo_t *ri_old,
     ri_old->cache_info.routerlist_index = -1;
     ri_new->cache_info.routerlist_index = idx;
     /* Check that ri_old is not in rl->routers anymore: */
-    tor_assert( _routerlist_find_elt(rl->routers, ri_old, -1) == -1 );
+    tor_assert( routerlist_find_elt_(rl->routers, ri_old, -1) == -1 );
   } else {
     log_warn(LD_BUG, "Appending entry from routerlist_replace.");
     routerlist_insert(rl, ri_new);
@@ -3166,7 +3166,7 @@ router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
  * signed_descriptor_t* in *<b>a</b> has an identity digest preceding, equal
  * to, or later than that of *<b>b</b>. */
 static int
-_compare_old_routers_by_identity(const void **_a, const void **_b)
+compare_old_routers_by_identity_(const void **_a, const void **_b)
 {
   int i;
   const signed_descriptor_t *r1 = *_a, *r2 = *_b;
@@ -3186,7 +3186,7 @@ struct duration_idx_t {
 
 /** Sorting helper: compare two duration_idx_t by their duration. */
 static int
-_compare_duration_idx(const void *_d1, const void *_d2)
+compare_duration_idx_(const void *_d1, const void *_d2)
 {
   const struct duration_idx_t *d1 = _d1;
   const struct duration_idx_t *d2 = _d2;
@@ -3263,7 +3263,7 @@ routerlist_remove_old_cached_routers_with_id(time_t now,
      * the duration of liveness, and remove the ones we're not already going to
      * remove based on how long they were alive.
      **/
-    qsort(lifespans, n, sizeof(struct duration_idx_t), _compare_duration_idx);
+    qsort(lifespans, n, sizeof(struct duration_idx_t), compare_duration_idx_);
     for (i = 0; i < n && n_rmv < n_extra; ++i) {
       if (!must_keep[lifespans[i].idx-lo] && !lifespans[i].old) {
         rmv[lifespans[i].idx-lo] = 1;
@@ -3417,7 +3417,7 @@ routerlist_remove_old_routers(void)
     goto done;
 
   /* Sort by identity, then fix indices. */
-  smartlist_sort(routerlist->old_routers, _compare_old_routers_by_identity);
+  smartlist_sort(routerlist->old_routers, compare_old_routers_by_identity_);
   /* Fix indices. */
   for (i = 0; i < smartlist_len(routerlist->old_routers); ++i) {
     signed_descriptor_t *r = smartlist_get(routerlist->old_routers, i);
@@ -4775,7 +4775,7 @@ esc_router_info(const routerinfo_t *router)
 /** Helper for sorting: compare two routerinfos by their identity
  * digest. */
 static int
-_compare_routerinfo_by_id_digest(const void **a, const void **b)
+compare_routerinfo_by_id_digest_(const void **a, const void **b)
 {
   routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b;
   return fast_memcmp(first->cache_info.identity_digest,
@@ -4787,7 +4787,7 @@ _compare_routerinfo_by_id_digest(const void **a, const void **b)
 void
 routers_sort_by_identity(smartlist_t *routers)
 {
-  smartlist_sort(routers, _compare_routerinfo_by_id_digest);
+  smartlist_sort(routers, compare_routerinfo_by_id_digest_);
 }
 
 /** Called when we change a node set, or when we reload the geoip list:
@@ -4806,8 +4806,8 @@ refresh_all_country_info(void)
     routerset_refresh_countries(options->ExcludeNodes);
   if (options->ExcludeExitNodes)
     routerset_refresh_countries(options->ExcludeExitNodes);
-  if (options->_ExcludeExitNodesUnion)
-    routerset_refresh_countries(options->_ExcludeExitNodesUnion);
+  if (options->ExcludeExitNodesUnion_)
+    routerset_refresh_countries(options->ExcludeExitNodesUnion_);
 
   nodelist_refresh_countries();
 }

+ 2 - 2
src/or/routerlist.h

@@ -8,8 +8,8 @@
  * \brief Header file for routerlist.c.
  **/
 
-#ifndef _TOR_ROUTERLIST_H
-#define _TOR_ROUTERLIST_H
+#ifndef TOR_ROUTERLIST_H
+#define TOR_ROUTERLIST_H
 
 int get_n_authorities(dirinfo_type_t type);
 int trusted_dirs_reload_certs(void);

+ 27 - 27
src/or/routerparse.c

@@ -29,8 +29,8 @@
 /****************************************************************************/
 
 /** Enumeration of possible token types.  The ones starting with K_ correspond
- * to directory 'keywords'. _ERR is an error in the tokenizing process, _EOF
- * is an end-of-file marker, and _NIL is used to encode not-a-token.
+ * to directory 'keywords'. ERR_ is an error in the tokenizing process, EOF_
+ * is an end-of-file marker, and NIL_ is used to encode not-a-token.
  */
 typedef enum {
   K_ACCEPT = 0,
@@ -131,7 +131,7 @@ typedef enum {
 
   A_PURPOSE,
   A_LAST_LISTED,
-  _A_UNKNOWN,
+  A_UNKNOWN_,
 
   R_RENDEZVOUS_SERVICE_DESCRIPTOR,
   R_VERSION,
@@ -152,13 +152,13 @@ typedef enum {
   C_DESCRIPTOR_COOKIE,
   C_CLIENT_KEY,
 
-  _ERR,
-  _EOF,
-  _NIL
+  ERR_,
+  EOF_,
+  NIL_
 } directory_keyword;
 
 #define MIN_ANNOTATION A_PURPOSE
-#define MAX_ANNOTATION _A_UNKNOWN
+#define MAX_ANNOTATION A_UNKNOWN_
 
 /** Structure to hold a single directory token.
  *
@@ -181,7 +181,7 @@ typedef struct directory_token_t {
 
   crypto_pk_t *key;        /**< For public keys only.  Heap-allocated. */
 
-  char *error;                 /**< For _ERR tokens only. */
+  char *error;                 /**< For ERR_ tokens only. */
 } directory_token_t;
 
 /* ********************************************************************** */
@@ -235,7 +235,7 @@ typedef struct token_rule_t {
  */
 
 /** Appears to indicate the end of a table. */
-#define END_OF_TABLE { NULL, _NIL, 0,0,0, NO_OBJ, 0, INT_MAX, 0, 0 }
+#define END_OF_TABLE { NULL, NIL_, 0,0,0, NO_OBJ, 0, INT_MAX, 0, 0 }
 /** An item with no restrictions: used for obsolete document types */
 #define T(s,t,a,o)    { s, t, a, o, 0, INT_MAX, 0, 0 }
 /** An item with no restrictions on multiplicity or location. */
@@ -549,10 +549,10 @@ static int router_get_hashes_impl(const char *s, size_t s_len,
 static void token_clear(directory_token_t *tok);
 static smartlist_t *find_all_by_keyword(smartlist_t *s, directory_keyword k);
 static smartlist_t *find_all_exitpolicy(smartlist_t *s);
-static directory_token_t *_find_by_keyword(smartlist_t *s,
+static directory_token_t *find_by_keyword_(smartlist_t *s,
                                            directory_keyword keyword,
                                            const char *keyword_str);
-#define find_by_keyword(s, keyword) _find_by_keyword((s), (keyword), #keyword)
+#define find_by_keyword(s, keyword) find_by_keyword_((s), (keyword), #keyword)
 static directory_token_t *find_opt_by_keyword(smartlist_t *s,
                                               directory_keyword keyword);
 
@@ -2263,7 +2263,7 @@ compare_routerstatus_entries(const void **_a, const void **_b)
 
 /** Helper: used in call to _smartlist_uniq to clear out duplicate entries. */
 static void
-_free_duplicate_routerstatus_entry(void *e)
+free_duplicate_routerstatus_entry_(void *e)
 {
   log_warn(LD_DIR,
            "Network-status has two entries for the same router. "
@@ -2404,7 +2404,7 @@ networkstatus_v2_parse_from_string(const char *s)
   }
   smartlist_sort(ns->entries, compare_routerstatus_entries);
   smartlist_uniq(ns->entries, compare_routerstatus_entries,
-                 _free_duplicate_routerstatus_entry);
+                 free_duplicate_routerstatus_entry_);
 
   if (tokenize_string(area,s, NULL, footer_tokens, dir_footer_token_table,0)) {
     log_warn(LD_DIR, "Error tokenizing network-status footer.");
@@ -3661,7 +3661,7 @@ router_parse_addr_policy_item_from_string(const char *s, int assume_action)
   eos = cp + strlen(cp);
   area = memarea_new();
   tok = get_next_token(area, &cp, eos, routerdesc_token_table);
-  if (tok->tp == _ERR) {
+  if (tok->tp == ERR_) {
     log_warn(LD_DIR, "Error reading address policy: %s", tok->error);
     goto err;
   }
@@ -3814,14 +3814,14 @@ token_clear(directory_token_t *tok)
   STMT_BEGIN                                                       \
     if (tok) token_clear(tok);                                      \
     tok = ALLOC_ZERO(sizeof(directory_token_t));                   \
-    tok->tp = _ERR;                                                \
+    tok->tp = ERR_;                                                \
     tok->error = STRDUP(msg);                                      \
     goto done_tokenizing;                                          \
   STMT_END
 
 /** Helper: make sure that the token <b>tok</b> with keyword <b>kwd</b> obeys
  * the object syntax of <b>o_syn</b>.  Allocate all storage in <b>area</b>.
- * Return <b>tok</b> on success, or a new _ERR token if the token didn't
+ * Return <b>tok</b> on success, or a new ERR_ token if the token didn't
  * conform to the syntax we wanted.
  **/
 static INLINE directory_token_t *
@@ -3940,7 +3940,7 @@ get_next_token(memarea_t *area,
 
   tor_assert(area);
   tok = ALLOC_ZERO(sizeof(directory_token_t));
-  tok->tp = _ERR;
+  tok->tp = ERR_;
 
   /* Set *s to first token, eol to end-of-line, next to after first token */
   *s = eat_whitespace_eos(*s, eos); /* eat multi-line whitespace */
@@ -3997,10 +3997,10 @@ get_next_token(memarea_t *area,
     }
   }
 
-  if (tok->tp == _ERR) {
+  if (tok->tp == ERR_) {
     /* No keyword matched; call it an "K_opt" or "A_unrecognized" */
     if (**s == '@')
-      tok->tp = _A_UNKNOWN;
+      tok->tp = A_UNKNOWN_;
     else
       tok->tp = K_OPT;
     tok->args = ALLOC(sizeof(char*));
@@ -4090,7 +4090,7 @@ tokenize_string(memarea_t *area,
 {
   const char **s;
   directory_token_t *tok = NULL;
-  int counts[_NIL];
+  int counts[NIL_];
   int i;
   int first_nonannotation;
   int prev_len = smartlist_len(out);
@@ -4099,14 +4099,14 @@ tokenize_string(memarea_t *area,
   s = &start;
   if (!end)
     end = start+strlen(start);
-  for (i = 0; i < _NIL; ++i)
+  for (i = 0; i < NIL_; ++i)
     counts[i] = 0;
 
   SMARTLIST_FOREACH(out, const directory_token_t *, t, ++counts[t->tp]);
 
-  while (*s < end && (!tok || tok->tp != _EOF)) {
+  while (*s < end && (!tok || tok->tp != EOF_)) {
     tok = get_next_token(area, s, end, table);
-    if (tok->tp == _ERR) {
+    if (tok->tp == ERR_) {
       log_warn(LD_DIR, "parse error: %s", tok->error);
       token_clear(tok);
       return -1;
@@ -4196,7 +4196,7 @@ find_opt_by_keyword(smartlist_t *s, directory_keyword keyword)
  * with an assert if no such keyword is found.
  */
 static directory_token_t *
-_find_by_keyword(smartlist_t *s, directory_keyword keyword,
+find_by_keyword_(smartlist_t *s, directory_keyword keyword,
                  const char *keyword_as_string)
 {
   directory_token_t *tok = find_opt_by_keyword(s, keyword);
@@ -4695,7 +4695,7 @@ tor_version_same_series(tor_version_t *a, tor_version_t *b)
  * if _a precedes _b, 1 if _b precedes _a, and 0 if they are equivalent.
  * Used to sort a list of versions. */
 static int
-_compare_tor_version_str_ptr(const void **_a, const void **_b)
+compare_tor_version_str_ptr_(const void **_a, const void **_b)
 {
   const char *a = *_a, *b = *_b;
   int ca, cb;
@@ -4719,10 +4719,10 @@ _compare_tor_version_str_ptr(const void **_a, const void **_b)
 void
 sort_version_list(smartlist_t *versions, int remove_duplicates)
 {
-  smartlist_sort(versions, _compare_tor_version_str_ptr);
+  smartlist_sort(versions, compare_tor_version_str_ptr_);
 
   if (remove_duplicates)
-    smartlist_uniq(versions, _compare_tor_version_str_ptr, _tor_free);
+    smartlist_uniq(versions, compare_tor_version_str_ptr_, tor_free_);
 }
 
 /** Parse and validate the ASCII-encoded v2 descriptor in <b>desc</b>,

+ 2 - 2
src/or/routerparse.h

@@ -9,8 +9,8 @@
  * \brief Header file for routerparse.c.
  **/
 
-#ifndef _TOR_ROUTERPARSE_H
-#define _TOR_ROUTERPARSE_H
+#ifndef TOR_ROUTERPARSE_H
+#define TOR_ROUTERPARSE_H
 
 int router_get_router_hash(const char *s, size_t s_len, char *digest);
 int router_get_dir_hash(const char *s, char *digest);

Some files were not shown because too many files changed in this diff