[or-cvs] r10699: merged with current trunk (in tor/branches/114-dist-storage: doc doc/design-paper doc/spec doc/spec/proposals src/common src/or src/tools)

kloesing at seul.org kloesing at seul.org
Thu Jun 28 18:07:47 UTC 2007


Author: kloesing
Date: 2007-06-28 14:07:46 -0400 (Thu, 28 Jun 2007)
New Revision: 10699

Modified:
   tor/branches/114-dist-storage/doc/TODO
   tor/branches/114-dist-storage/doc/design-paper/sptor.tex
   tor/branches/114-dist-storage/doc/spec/control-spec.txt
   tor/branches/114-dist-storage/doc/spec/dir-spec.txt
   tor/branches/114-dist-storage/doc/spec/proposals/107-uptime-sanity-checking.txt
   tor/branches/114-dist-storage/doc/spec/proposals/108-mtbf-based-stability.txt
   tor/branches/114-dist-storage/doc/spec/proposals/109-no-sharing-ips.txt
   tor/branches/114-dist-storage/doc/spec/proposals/110-avoid-infinite-circuits.txt
   tor/branches/114-dist-storage/doc/spec/proposals/111-local-traffic-priority.txt
   tor/branches/114-dist-storage/doc/spec/proposals/112-bring-back-pathlencoinweight.txt
   tor/branches/114-dist-storage/doc/spec/proposals/114-distributed-storage.txt
   tor/branches/114-dist-storage/doc/spec/proposals/115-two-hop-paths.txt
   tor/branches/114-dist-storage/src/common/compat.h
   tor/branches/114-dist-storage/src/common/container.c
   tor/branches/114-dist-storage/src/common/container.h
   tor/branches/114-dist-storage/src/common/ht.h
   tor/branches/114-dist-storage/src/common/log.h
   tor/branches/114-dist-storage/src/common/mempool.c
   tor/branches/114-dist-storage/src/common/test.h
   tor/branches/114-dist-storage/src/common/util.h
   tor/branches/114-dist-storage/src/or/buffers.c
   tor/branches/114-dist-storage/src/or/circuitlist.c
   tor/branches/114-dist-storage/src/or/config.c
   tor/branches/114-dist-storage/src/or/control.c
   tor/branches/114-dist-storage/src/or/dirserv.c
   tor/branches/114-dist-storage/src/or/dirvote.c
   tor/branches/114-dist-storage/src/or/dns.c
   tor/branches/114-dist-storage/src/or/dnsserv.c
   tor/branches/114-dist-storage/src/or/eventdns.c
   tor/branches/114-dist-storage/src/or/main.c
   tor/branches/114-dist-storage/src/or/or.h
   tor/branches/114-dist-storage/src/or/policies.c
   tor/branches/114-dist-storage/src/or/routerparse.c
   tor/branches/114-dist-storage/src/or/test.c
   tor/branches/114-dist-storage/src/tools/tor-resolve.c
Log:
merged with current trunk

Modified: tor/branches/114-dist-storage/doc/TODO
===================================================================
--- tor/branches/114-dist-storage/doc/TODO	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/TODO	2007-06-28 18:07:46 UTC (rev 10699)
@@ -285,6 +285,11 @@
       packages, as documented in tor-doc-unix.html
 P - Figure out why dll's compiled in mingw don't work right in WinXP.
 P - Figure out why openssl 0.9.8e "make test" fails at sha256t test.
+P - Figure out if including RSA and IDEA are bad for Tor from a legal
+     perspective
+P - Create packages for Nokia 800, requested by Chris Soghoian
+P - Consider creating special Tor-Polipo-Vidalia test packages,
+    requested by Dmitri Vitalev
   - add an AuthDirBadexit torrc option if we decide we want one.
 
 Deferred from 0.1.2.x:
@@ -587,6 +592,8 @@
 P - evaluate https://sourceforge.net/projects/kleanup/
 P - evaluate TorK
 P - figure out selinux policy for tor
+P - change packaging system to more automated and specific for each
+     platform, suggested by Paul Wouter
 
 Website:
   - and remove home and make the "Tor" picture be the link to home.

Modified: tor/branches/114-dist-storage/doc/design-paper/sptor.tex
===================================================================
--- tor/branches/114-dist-storage/doc/design-paper/sptor.tex	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/design-paper/sptor.tex	2007-06-28 18:07:46 UTC (rev 10699)
@@ -71,20 +71,22 @@
 enables hosts to be publicly accessible yet have similar protection
 against location through its \emph{location-hidden services}.
 
-To connect to a remote server via Tor, the client software learns
+To connect to a remote server via Tor the client software first learns
 a %signed
 list of Tor nodes from several central \emph{directory servers} via a
-voting protocol to avoid dependence on or complete trust in any one of
-them, and incrementally creates a private pathway or \emph{circuit} of
-encrypted connections through authenticated Tor nodes on the network
-whose public keys were obtained form the directory servers,
-negotiating a separate set of encryption keys for each hop along the
+voting protocol (to avoid dependence on or complete trust in any one
+of these servers). It then incrementally creates a private pathway or
+\emph{circuit} across the network. This circuit consists of
+encrypted connections through authenticated Tor nodes
+whose public keys were obtained from the directory servers. The client
+software negotiates a separate set of encryption keys for each hop along the
 circuit. The nodes in the circuit are chosen at random by the client
 subject to a preference for higher performing nodes to allocate
 resources effectively and with a client-chosen preferred set of first
 nodes called \emph{entry guards} to complicate profiling attacks by
 internal adversaries~\cite{hs-attack}.
-The circuit is extended one node at a time, and each node
+The circuit is extended one node at a time, tunneling extensions
+through already established portions of the circuit, and each node
 along the way knows only the immediately previous and following nodes
 in the circuit, so no individual Tor node knows the complete path that
 each fixed-sized data packet (or \emph{cell}) will take.  Thus,
@@ -341,8 +343,10 @@
 
 These are difficult and open questions. Yet choosing not to solve them
 means leaving most users to a less secure network or no anonymizing
-network at all.
+network at all.\\
 
+\noindent{\bf Acknowledgment:} Thanks to Matt Edman for many
+  helpful comments on a draft of this article.
 \bibliographystyle{plain} \bibliography{tor-design}
 
 \end{document}

Modified: tor/branches/114-dist-storage/doc/spec/control-spec.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/control-spec.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/control-spec.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -835,7 +835,8 @@
 
       "650" SP "STREAM" SP StreamID SP StreamStatus SP CircID SP Target
           [SP "REASON=" Reason [ SP "REMOTE_REASON=" Reason ]]
-          [SP "SOURCE=" Source] CRLF
+          [SP "SOURCE=" Source] [ SP "SOURCE_ADDR=" Address ":" Port ]
+          CRLF
 
       StreamStatus =
                "NEW"          / ; New request to connect
@@ -879,6 +880,11 @@
    answer, and "EXIT" is given if the remote node we queried gave us
    the new address as a response.
 
+   The "SOURCE_ADDR" field is included with NEW and NEWRESOLVE events if
+   extended events are enabled.  It indicates the address that requested
+   the connection, and can be (e.g.) used to look up the requesting
+   program.
+
 4.1.3. OR Connection status changed
 
   The syntax is:

Modified: tor/branches/114-dist-storage/doc/spec/dir-spec.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/dir-spec.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/dir-spec.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -19,7 +19,7 @@
        103  Splitting identity key from regularly used signing key
        104  Long and Short Router Descriptors
 
-   AS OF 18 MAY 2007, THIS SPECIFICATION HAS NOT YET BEEN COMPLETELY
+   AS OF 14 JUNE 2007, THIS SPECIFICATION HAS NOT YET BEEN COMPLETELY
    IMPLEMENTED, OR COMPLETELY COMPLETED.
 
    XXX when to download certificates.
@@ -35,19 +35,17 @@
    The Version 1 Directory protocol
    --------------------------------
 
-   [XXX say which versions added what.]
-
-   Early versions of Tor introduced "Directory authorities": servers that
-   served signed "directory" documents containing a list of signed "router
-   descriptors", along with short summary of the status of each router.
-   Thus, clients could get up-to-date information on the state of the
-   network automatically, and be certain that they list they were getting
+   Early versions of Tor (0.0.2) introduced "Directory authorities": servers
+   that served signed "directory" documents containing a list of signed
+   "router descriptors", along with short summary of the status of each
+   router.  Thus, clients could get up-to-date information on the state of
+   the network automatically, and be certain that they list they were getting
    was attested by a trusted directory authority.
 
-   Later versions added directory caches, which download directories from
-   the authorities and serve them to clients.  Non-caches fetch from the
-   caches in preference to fetching from the authorities, thus distributing
-   bandwidth requirements.
+   Later versions (0.0.8) added directory caches, which download
+   directories from the authorities and serve them to clients.  Non-caches
+   fetch from the caches in preference to fetching from the authorities, thus
+   distributing bandwidth requirements.
 
    Also added during the version 1 directory protocol were "router status"
    documents: short documents that listed only the up/down status of the
@@ -513,6 +511,18 @@
         it is prefixed with "opt"; it should be so prefixed until these
         versions are obsolete.]
 
+   "hidden-service-dir" NL
+
+       [At most once.]
+
+       Present only if this router stores and serves hidden service
+       descriptors.
+
+       [Versions other than SVN branch 114-dist-storage don't recognize this,
+        and versions before 0.1.2.5-alpha will reject descriptors containing
+        it unless it is prefixed with "opt"; it should be so prefixed until
+        these versions are obsolete.]
+
 2.2. Extra-info documents
 
    Extra-info documents consist of the following items:
@@ -695,7 +705,7 @@
 
     "published" SP YYYY-MM-DD SP HH:MM:SS NL
 
-        [Exactly once for votes; Does not occur in consensuses.]
+        [Exactly once for votes; does not occur in consensuses.]
 
         The publication time for this status document (if a vote).
 
@@ -753,7 +763,8 @@
    The authority section of a vote contains the following items, followed
    in turn by the authority's current key certificate:
 
-    "dir-source" SP nickname SP identity SP address SP IP SP dirport SP orport NL
+    "dir-source" SP nickname SP identity SP address SP IP SP dirport SP
+       orport NL
 
         [Exactly once, at start]
 
@@ -775,7 +786,8 @@
    in the order given, with one group for each authority that contributed to
    the consensus, with groups sorted by authority identity digest:
 
-    "dir-source" SP nickname SP identity SP address SP IP SP dirport SP orport NL
+    "dir-source" SP nickname SP identity SP address SP IP SP dirport SP
+       orport NL
 
         [Exactly once, at start]
 
@@ -931,11 +943,14 @@
    Given a set of votes, authorities compute the contents of the consensus
    document as follows:
 
-     The "valid-after" is the latest of all valid-after times on the votes.
+     The "valid-after", "valid-until", and "fresh-until" times are taken as
+     the median of the respective values from all the votes.
 
-     The "valid-until" is the earliest of all valid-until times on the
-     votes.
+     The times in the "voting-delay" line are taken as the median of the
+     VoteSeconds and DistSeconds times in the votes.
 
+     Known-flags is the union of all flags known by any voter.
+
     "client-versions" and "server-versions" are sorted in ascending
      order; A version is recommended in the consensus if it is recommended
      by more than half of the voting authorities that included a
@@ -946,19 +961,30 @@
      authorities. These groups are sorted by the digests of the
      authorities identity keys, in ascending order.
 
-     A router status entry is included in the result if it is included by more
-     than half of the authorities (total authorities, not just those whose
-     votes we have).  A router entry has a flag set if it is included by
-     more than half of the authorities who care about that flag.  Two
-     router entries are "the same" if they have the same identity digest.
-     We use whatever descriptor digest is attested to by the most
-     authorities among the voters, breaking ties in favor of the one with
-     the most recent publication time.
+     A router status entry:
+        * is included in the result if some router status entry with the same
+          identity is included by more than half of the authorities (total
+          authorities, not just those whose votes we have).
 
-     (XXXX what to do about version, published time, IP, orport, dirport,
-       nickname, version?)
+        * For any given identity, we include at most one router status entry.
 
-     The signatures at the end of the document appear are sorted in
+        * A router entry has a flag set if that is included by more than half
+          of the authorities who care about that flag.
+
+        * Two router entries are "the same" if they have the same
+          <descriptor digest, published time, nickname, IP, ports> tuple.
+          We choose the tuple for a given router as whichever tuple appears
+          for that router in the most votes.  We break ties in favor of
+          the more recently published.
+
+        * The Named flag appears if it is included for this routerstatus by
+          _any_ authority, and if all authorities that list it list the same
+          nickname.
+
+        * The version is given as whichever version is listed by the most
+          voters, with ties decided in favor of more recent versions.
+
+     The signatures at the end of a consensus document are sorted in
      ascending order by identity digest.
 
 3.4. Detached signatures
@@ -981,7 +1007,7 @@
 
         [As in the consensus]
 
-    "directory signature"
+    "directory-signature"
 
         [As in the consensus; the signature object is the same as in the
         consensus document.]

Modified: tor/branches/114-dist-storage/doc/spec/proposals/107-uptime-sanity-checking.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/107-uptime-sanity-checking.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/107-uptime-sanity-checking.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 107-uptime-sanity-checking.txt
 Title: Uptime Sanity Checking
-Version:
-Last-Modified:
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 01:23:19 +0200 (So, 17 Jun 2007) $
 Author: Kevin Bauer & Damon McCoy
 Created: 8-March-2007
 Status: Closed

Modified: tor/branches/114-dist-storage/doc/spec/proposals/108-mtbf-based-stability.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/108-mtbf-based-stability.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/108-mtbf-based-stability.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 108-mtbf-based-stability.txt
 Title: Base "Stable" Flag on Mean Time Between Failures
-Version: $Revision: 12105 $
-Last-Modified: $Date: 2007-01-30T07:50:01.643717Z $
+Version: $Revision: 10684 $
+Last-Modified: $Date: 2007-06-26 23:48:42 +0200 (Di, 26 Jun 2007) $
 Author: Nick Mathewson
 Created: 10-Mar-2007
 Status: Open
@@ -29,33 +29,60 @@
    known to drop circuits stupidly. (0.1.1.10-alpha through 0.1.1.16-rc
    are stupid this way.)
 
-   Stability shall be defined as the mean length of the runs observed by a
-   given directory authority.  A run begins when an authority decides
-   that the server is Running, and ends when the authority decides that
-   the server is not Running.  In-progress runs are counted when
-   measuring Stability.
+   Stability shall be defined as the weighted mean length of the runs
+   observed by a given directory authority.  A run begins when an authority
+   decides that the server is Running, and ends when the authority decides
+   that the server is not Running.  In-progress runs are counted when
+   measuring Stability.  When calculating the mean, runs are weighted by
+   $\alpha ^ t$, where $t$ is time elapsed since the end of the run, and
+   $0 < \alpha < 1$.  Time when an authority is down do not count to the
+   length of the run.
 
-Issues:
+Rejected Alternative:
 
-   How do you define a clipped MTBF?  If the current month begins with one
-   day at the end of a one-year uptime, and then has 29 days of uptime, do we
-   average one day and 29 days?  Or do we average one year and 29 days?  Or
-   take 29 days on its own and discard the year?
+   "A router's Stability shall be defined as the sum of $\alpha ^ d$ for every
+   $d$ such that the router was not observed to be unavailable $d$ days ago."
 
-   Surely somebody has done this kinds of thing before.
+   This allows a simpler implementation: every day, we multiply
+   yesterday's Stability by alpha, and if the router was observed to be
+   available every time we looked today, we add 1.
 
-Alternative:
+   Instead of "day", we could pick an arbitrary time unit.  We should
+   pick alpha to be high enough that long-term stability counts, but low
+   enough that the distant past is eventually forgotten.  Something
+   between .8 and .95 seems right.
 
-   "A router's Stability shall be defined as the sum of $alpha ^ d$ for every
-   $d$ such that the router was not observed to be unavailable $d$ days ago."
+   (By requiring that routers be up for an entire day to get their
+   stability increased, instead of counting fractions of a day, we
+   capture the notion that stability is more like "probability of being
+   staying up for the next hour" than it is like "probability of being
+   up at some randomly chosen time over the next hour."  The former
+   notion of stability is far more relevant for long-lived circuits.)
 
-   This allows a simpler implementation: every day, we multiply yesterday's
-   Stability by alpha, and if the router was running for all of today, we add
-   1.
-
 Limitations:
 
    Authorities can have false positives and false negatives when trying to
    tell whether a router is up or down.  So long as these aren't terribly
    wrong, and so long as they aren't significantly biased, we should be able
    to use them to estimate stability pretty well.
+
+   Probing approaches like the above could miss short incidents of
+   downtime.  If we use the router's declared uptime, we could detect
+   these: but doing so would penalize routers who reported their uptime
+   accurately.
+
+Implementation:
+
+   For now, the easiest way to store this information at authorities
+   would probably be in some kind of periodically flushed flat file.
+   Later, we could move to Berkeley db or something if we really had to.
+
+   For each router, an authority will need to store:
+     The router ID.
+     Whether the router is up.
+     The time when the current run started, if the router is up.
+     The weighted sum length of all previous runs.
+     The time at which the weighted sum length was last weighted down.
+
+   Servers should probe at random intervals to test whether servers are
+   running.

Modified: tor/branches/114-dist-storage/doc/spec/proposals/109-no-sharing-ips.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/109-no-sharing-ips.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/109-no-sharing-ips.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 109-no-sharing-ips.txt
 Title: No more than one server per IP address.
-Version:
-Last-Modified:
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 01:23:19 +0200 (So, 17 Jun 2007) $
 Author: Kevin Bauer & Damon McCoy
 Created: 9-March-2007
 Status: Accepted

Modified: tor/branches/114-dist-storage/doc/spec/proposals/110-avoid-infinite-circuits.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/110-avoid-infinite-circuits.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/110-avoid-infinite-circuits.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 1xx-avoid-infinite-circuits.txt
 Title: Avoiding infinite length circuits
-Version:
-Last-Modified:
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 01:23:19 +0200 (So, 17 Jun 2007) $
 Author: Roger Dingledine
 Created: 13-Mar-2007
 Status: Open

Modified: tor/branches/114-dist-storage/doc/spec/proposals/111-local-traffic-priority.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/111-local-traffic-priority.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/111-local-traffic-priority.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 111-local-traffic-priority.txt
 Title: Prioritizing local traffic over relayed traffic
-Version:
-Last-Modified:
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 01:23:19 +0200 (So, 17 Jun 2007) $
 Author: Roger Dingledine
 Created: 14-Mar-2007
 Status: Open

Modified: tor/branches/114-dist-storage/doc/spec/proposals/112-bring-back-pathlencoinweight.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/112-bring-back-pathlencoinweight.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/112-bring-back-pathlencoinweight.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 112-bring-back-pathlencoinweight.txt
 Title: Bring Back Pathlen Coin Weight
-Version:
-Last-Modified:
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 01:23:19 +0200 (So, 17 Jun 2007) $
 Author: Mike Perry
 Created:
 Status: Superseded

Modified: tor/branches/114-dist-storage/doc/spec/proposals/114-distributed-storage.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/114-distributed-storage.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/114-distributed-storage.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 114-distributed-storage.txt
 Title: Distributed Storage for Tor Hidden Service Descriptors
-Version: $Revision$
-Last-Modified: $Date$
+Version: $Revision: 10624 $
+Last-Modified: $Date: 2007-06-16 23:58:33 +0100 (Sa, 16 Jun 2007) $
 Author: Karsten Loesing
 Created: 13-May-2007
 Status: Open

Modified: tor/branches/114-dist-storage/doc/spec/proposals/115-two-hop-paths.txt
===================================================================
--- tor/branches/114-dist-storage/doc/spec/proposals/115-two-hop-paths.txt	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/doc/spec/proposals/115-two-hop-paths.txt	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,7 +1,7 @@
 Filename: 115-two-hop-paths.txt
 Title: Two Hop Paths
-Version: $Revision$
-Last-Modified: $Date$
+Version: $Revision: 10625 $
+Last-Modified: $Date: 2007-06-17 00:23:19 +0100 (So, 17 Jun 2007) $
 Author: Mike Perry
 Created:
 Status: Open

Modified: tor/branches/114-dist-storage/src/common/compat.h
===================================================================
--- tor/branches/114-dist-storage/src/common/compat.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/compat.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -120,6 +120,21 @@
 #define PREDICT_UNLIKELY(exp) (exp)
 #endif
 
+/* Ways to declare macros. */
+#define STMT_NIL (void)0
+#ifdef __GNUC__
+#define STMT_BEGIN (void) ({
+#define STMT_END })
+#else
+#if defined(sun) || defined(__sun__)
+#define STMT_BEGIN if (1) {
+#define STMT_END } else STMT_NIL
+#else
+#define STMT_BEGIN do {
+#define STMT_END } while(0)
+#endif
+#endif
+
 /* ===== String compatibility */
 #ifdef MS_WINDOWS
 /* Windows names string functions differently from most other platforms. */
@@ -339,9 +354,9 @@
 unsigned long tor_get_thread_id(void);
 #else
 #define tor_mutex_new() ((tor_mutex_t*)tor_malloc(sizeof(int)))
-#define tor_mutex_acquire(m) do { } while (0)
-#define tor_mutex_release(m) do { } while (0)
-#define tor_mutex_free(m) do { tor_free(m); } while (0)
+#define tor_mutex_acquire(m) STMT_NIL
+#define tor_mutex_release(m) STMT_NIL
+#define tor_mutex_free(m) STMT_BEGIN tor_free(m); STMT_END
 #define tor_get_thread_id() (1UL)
 #endif
 

Modified: tor/branches/114-dist-storage/src/common/container.c
===================================================================
--- tor/branches/114-dist-storage/src/common/container.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/container.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -663,7 +663,7 @@
   } prefix ## entry_t;                                    \
   struct maptype {                                        \
     HT_HEAD(prefix ## impl, prefix ## entry_t) head;      \
-  };
+  }
 
 DEFINE_MAP_STRUCTS(strmap_t, char *key, strmap_);
 DEFINE_MAP_STRUCTS(digestmap_t, char key[DIGEST_LEN], digestmap_);
@@ -698,14 +698,14 @@
 }
 
 HT_PROTOTYPE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
-             strmap_entries_eq);
+             strmap_entries_eq)
 HT_GENERATE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
-            strmap_entries_eq, 0.6, malloc, realloc, free);
+            strmap_entries_eq, 0.6, malloc, realloc, free)
 
 HT_PROTOTYPE(digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash,
-             digestmap_entries_eq);
+             digestmap_entries_eq)
 HT_GENERATE(digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash,
-            digestmap_entries_eq, 0.6, malloc, realloc, free);
+            digestmap_entries_eq, 0.6, malloc, realloc, free)
 
 /** Constructor to create a new empty map from strings to void*'s.
  */

Modified: tor/branches/114-dist-storage/src/common/container.h
===================================================================
--- tor/branches/114-dist-storage/src/common/container.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/container.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -159,24 +159,24 @@
  * </pre>
  */
 #define SMARTLIST_FOREACH(sl, type, var, cmd)                   \
-  do {                                                          \
+  STMT_BEGIN                                                    \
     int var ## _sl_idx, var ## _sl_len=(sl)->num_used;          \
     type var;                                                   \
     for (var ## _sl_idx = 0; var ## _sl_idx < var ## _sl_len;   \
          ++var ## _sl_idx) {                                    \
       var = (sl)->list[var ## _sl_idx];                         \
       cmd;                                                      \
-    } } while (0)
+    } STMT_END
 
 /** Helper: While in a SMARTLIST_FOREACH loop over the list <b>sl</b> indexed
  * with the variable <b>var</b>, remove the current element in a way that
  * won't confuse the loop. */
 #define SMARTLIST_DEL_CURRENT(sl, var)          \
-  do {                                          \
+  STMT_BEGIN                                    \
     smartlist_del(sl, var ## _sl_idx);          \
     --var ## _sl_idx;                           \
     --var ## _sl_len;                           \
-  } while (0);
+  STMT_END
 
 #define DECLARE_MAP_FNS(maptype, keytype, prefix)                       \
   typedef struct maptype maptype;                                       \
@@ -193,7 +193,7 @@
   prefix##iter_t *prefix##iter_next_rmv(maptype *map, prefix##iter_t *iter); \
   void prefix##iter_get(prefix##iter_t *iter, keytype *keyp, void **valp); \
   int prefix##iter_done(prefix##iter_t *iter);                          \
-  void prefix##assert_ok(const maptype *map);
+  void prefix##assert_ok(const maptype *map)
 
 /* Map from const char * to void *. Implemented with a hash table. */
 DECLARE_MAP_FNS(strmap_t, const char *, strmap_);

Modified: tor/branches/114-dist-storage/src/common/ht.h
===================================================================
--- tor/branches/114-dist-storage/src/common/ht.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/ht.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -79,9 +79,7 @@
 }
 
 #define _HT_SET_HASH(elm, field, hashfn)        \
-  do {                                          \
-    (elm)->field.hte_hash = hashfn(elm);        \
-  } while (0)
+    (elm)->field.hte_hash = hashfn(elm)
 
 #define HT_FOREACH(x, name, head)                 \
   for ((x) = HT_START(name, head);                \

Modified: tor/branches/114-dist-storage/src/common/log.h
===================================================================
--- tor/branches/114-dist-storage/src/common/log.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/log.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -131,10 +131,10 @@
 #define log_fn(severity, domain, args...)               \
   _log_fn(severity, domain, __PRETTY_FUNCTION__, args)
 #define log_debug(domain, args...)                                      \
-  do {                                                                  \
+  STMT_BEGIN                                                            \
     if (PREDICT_UNLIKELY(_log_global_min_severity == LOG_DEBUG))        \
       _log_fn(LOG_DEBUG, domain, __PRETTY_FUNCTION__, args);            \
-  } while (0)
+  STMT_END
 #define log_info(domain, args...)                           \
   _log_fn(LOG_INFO, domain, __PRETTY_FUNCTION__, args)
 #define log_notice(domain, args...)                         \

Modified: tor/branches/114-dist-storage/src/common/mempool.c
===================================================================
--- tor/branches/114-dist-storage/src/common/mempool.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/mempool.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1,6 +1,11 @@
 /* Copyright 2007 Nick Mathewson */
 /* See LICENSE for licensing information */
 /* $Id$ */
+#if 1
+/* Tor dependencies */
+#include "orconfig.h"
+#endif
+
 #include <stdlib.h>
 #include <string.h>
 

Modified: tor/branches/114-dist-storage/src/common/test.h
===================================================================
--- tor/branches/114-dist-storage/src/common/test.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/test.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -16,9 +16,6 @@
 #include <stdio.h>
 #include "compat.h"
 
-#define STMT_BEGIN  do {
-#define STMT_END    } while (0)
-
 #ifdef __GNUC__
 #define PRETTY_FUNCTION __PRETTY_FUNCTION__
 #else

Modified: tor/branches/114-dist-storage/src/common/util.h
===================================================================
--- tor/branches/114-dist-storage/src/common/util.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/common/util.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -47,14 +47,14 @@
 
 /** Like assert(3), but send assertion failures to the log as well as to
  * stderr. */
-#define tor_assert(expr) do {                                           \
+#define tor_assert(expr) STMT_BEGIN                                     \
     if (PREDICT_UNLIKELY(IS_FALSE_AS_INT(expr))) {                      \
       log(LOG_ERR, LD_BUG, "%s:%d: %s: Assertion %s failed; aborting.", \
           _SHORT_FILE_, __LINE__, __func__, #expr);                     \
       fprintf(stderr,"%s:%d %s: Assertion %s failed; aborting.\n",      \
               _SHORT_FILE_, __LINE__, __func__, #expr);                 \
       abort();                                                          \
-    } } while (0)
+    } STMT_END
 #endif
 
 #ifdef USE_DMALLOC
@@ -83,19 +83,19 @@
 #ifdef USE_DMALLOC
 extern int dmalloc_free(const char *file, const int line, void *pnt,
                         const int func_id);
-#define tor_free(p) do { \
+#define tor_free(p) STMT_BEGIN \
     if (PREDICT_LIKELY((p)!=NULL)) {                \
       dmalloc_free(_SHORT_FILE_, __LINE__, (p), 0); \
       (p)=NULL;                                     \
     }                                               \
-  } while (0)
+  STMT_END
 #else
-#define tor_free(p) do {                                       \
+#define tor_free(p) STMT_BEGIN                                 \
     if (PREDICT_LIKELY((p)!=NULL)) {                           \
       free(p);                                                 \
       (p)=NULL;                                                \
     }                                                          \
-  } while (0)
+  STMT_END
 #endif
 
 #define tor_malloc(size)       _tor_malloc(size DMALLOC_ARGS)

Modified: tor/branches/114-dist-storage/src/or/buffers.c
===================================================================
--- tor/branches/114-dist-storage/src/or/buffers.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/buffers.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -40,18 +40,21 @@
 /** Initialize the sentinel values on <b>m</b> (a value of buf-&gt;mem), which
  * has <b>ln</b> useful bytes. */
 #define SET_GUARDS(m, ln) \
-  do { set_uint32((m)-4,START_MAGIC); set_uint32((m)+ln,END_MAGIC); } while (0)
+  STMT_BEGIN                         \
+    set_uint32((m)-4,START_MAGIC);   \
+    set_uint32((m)+ln,END_MAGIC);    \
+  STMT_END
 #else
 #define RAW_MEM(m) (m)
 #define GUARDED_MEM(m) (m)
 #define ALLOC_LEN(ln) (ln)
-#define SET_GUARDS(m,ln) do {} while (0)
+#define SET_GUARDS(m,ln) STMT_NIL
 #endif
 
 #ifdef PARANOIA
-#define check() do { assert_buf_ok(buf); } while (0)
+#define check() STMT_BEGIN assert_buf_ok(buf); STMT_END
 #else
-#define check() do { } while (0)
+#define check() STMT_NIL
 #endif
 
 #ifdef NOINLINE

Modified: tor/branches/114-dist-storage/src/or/circuitlist.c
===================================================================
--- tor/branches/114-dist-storage/src/or/circuitlist.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/circuitlist.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -60,10 +60,10 @@
 static HT_HEAD(orconn_circid_map, orconn_circid_circuit_map_t)
      orconn_circid_circuit_map = HT_INITIALIZER();
 HT_PROTOTYPE(orconn_circid_map, orconn_circid_circuit_map_t, node,
-             _orconn_circid_entry_hash, _orconn_circid_entries_eq);
+             _orconn_circid_entry_hash, _orconn_circid_entries_eq)
 HT_GENERATE(orconn_circid_map, orconn_circid_circuit_map_t, node,
             _orconn_circid_entry_hash, _orconn_circid_entries_eq, 0.6,
-            malloc, realloc, free);
+            malloc, realloc, free)
 
 /** The most recently returned entry from circuit_get_by_circid_orconn;
  * used to improve performance when many cells arrive in a row from the

Modified: tor/branches/114-dist-storage/src/or/config.c
===================================================================
--- tor/branches/114-dist-storage/src/or/config.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/config.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -258,6 +258,8 @@
   OBSOLETE("StatusFetchPeriod"),
   VAR("StoreV2HidServDescriptorsToDisk",BOOL,
                                        StoreV2HidServDescriptorsToDisk,"0"),
+//  VAR("StoreAndServeV2HidServDescriptors", BOOL,
+//                                   StoreAndServeV2HidServDescriptors, "0"),
   VAR("StrictEntryNodes",    BOOL,     StrictEntryNodes,     "0"),
   VAR("StrictExitNodes",     BOOL,     StrictExitNodes,      "0"),
   OBSOLETE("SysLog"),
@@ -558,11 +560,11 @@
 
 /** Macro: assert that <b>cfg</b> has the right magic field for format
  * <b>fmt</b>. */
-#define CHECK(fmt, cfg) do {                                            \
+#define CHECK(fmt, cfg) STMT_BEGIN                                      \
     tor_assert(fmt && cfg);                                             \
     tor_assert((fmt)->magic ==                                          \
                *(uint32_t*)STRUCT_VAR_P(cfg,fmt->magic_offset));        \
-  } while (0)
+  STMT_END
 
 static void config_line_append(config_line_t **lst,
                                const char *key, const char *val);
@@ -2425,8 +2427,8 @@
   const char *uname = get_uname();
   char buf[1024];
 #define REJECT(arg) \
-  do { *msg = tor_strdup(arg); return -1; } while (0)
-#define COMPLAIN(arg) do { log(LOG_WARN, LD_CONFIG, arg); } while (0)
+  STMT_BEGIN *msg = tor_strdup(arg); return -1; STMT_END
+#define COMPLAIN(arg) STMT_BEGIN log(LOG_WARN, LD_CONFIG, arg); STMT_END
 
   tor_assert(msg);
   *msg = NULL;

Modified: tor/branches/114-dist-storage/src/or/control.c
===================================================================
--- tor/branches/114-dist-storage/src/or/control.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/control.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -425,7 +425,7 @@
  * but it will always end with a CRLF sequence.
  *
  * Currently the length of the message is limited to 1024 (including the
- * ending \n\r\0. */
+ * ending \r\n\0. */
 static void
 connection_printf_to_buf(control_connection_t *conn, const char *format, ...)
 {
@@ -2636,6 +2636,7 @@
                             int reason_code)
 {
   char reason_buf[64];
+  char addrport_buf[64];
   const char *status;
   circuit_t *circ;
   origin_circuit_t *origin_circ = NULL;
@@ -2698,15 +2699,25 @@
       break;
     }
   }
+
+  if (tp == STREAM_EVENT_NEW) {
+    tor_snprintf(addrport_buf,sizeof(addrport_buf), "%sSOURCE_ADDR=%s:%d",
+                 strlen(reason_buf) ? " " : "",
+                 TO_CONN(conn)->address, TO_CONN(conn)->port );
+  } else {
+    addrport_buf[0] = '\0';
+  }
+
   circ = circuit_get_by_edge_conn(conn);
   if (circ && CIRCUIT_IS_ORIGIN(circ))
     origin_circ = TO_ORIGIN_CIRCUIT(circ);
   send_control_event_extended(EVENT_STREAM_STATUS, ALL_NAMES,
-                        "650 STREAM %lu %s %lu %s@%s\r\n",
+                        "650 STREAM %lu %s %lu %s@%s%s\r\n",
                         (unsigned long)conn->global_identifier, status,
                         origin_circ?
                            (unsigned long)origin_circ->global_identifier : 0ul,
-                        buf, reason_buf);
+                        buf, reason_buf, addrport_buf);
+
   /* XXX need to specify its intended exit, etc? */
 
   return 0;

Modified: tor/branches/114-dist-storage/src/or/dirserv.c
===================================================================
--- tor/branches/114-dist-storage/src/or/dirserv.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/dirserv.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1575,7 +1575,9 @@
   smartlist_free(bandwidths_excluding_exits);
 }
 
-/** DOCDOC */
+/** Given a platform string as in a routerinfo_t (possibly null), return a
+ * newly allocated version string for a networkstatus document, or NULL if the
+ * platform doesn't give a Tor version. */
 static char *
 version_from_platform(const char *platform)
 {

Modified: tor/branches/114-dist-storage/src/or/dirvote.c
===================================================================
--- tor/branches/114-dist-storage/src/or/dirvote.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/dirvote.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -12,7 +12,7 @@
  * \file dirvote.c
  **/
 
-/** DOCDOC */
+/** Clear all storage held in <b>ns</b>. */
 void
 networkstatus_vote_free(networkstatus_vote_t *ns)
 {
@@ -56,7 +56,9 @@
   tor_free(ns);
 }
 
-/** DOCDOC */
+/** Return the voter info from <b>vote</b> for the voter whose identity digest
+ * is <b>identity</b>, or NULL if no such voter is associated with
+ * <b>vote</b>. */
 networkstatus_voter_info_t *
 networkstatus_get_voter_by_id(networkstatus_vote_t *vote,
                               const char *identity)
@@ -69,7 +71,7 @@
   return NULL;
 }
 
-/** DOCDOC */
+/** Helper for sorting a list of time_t* */
 static int
 _compare_times(const void **_a, const void **_b)
 {
@@ -82,7 +84,7 @@
     return 0;
 }
 
-/** DOCDOC */
+/** Helper for sorting a list of int* */
 static int
 _compare_ints(const void **_a, const void **_b)
 {
@@ -95,26 +97,30 @@
     return 0;
 }
 
-/** DOCDOC */
+/** Given a list of one or more time_t*, return the (low) median. */
 static time_t
 median_time(smartlist_t *times)
 {
   int idx;
+  tor_assert(smartlist_len(times));
   smartlist_sort(times, _compare_times);
   idx = (smartlist_len(times)-1)/2;
   return *(time_t*)smartlist_get(times, idx);
 }
 
-/** DOCDOC */
+/** Given a list of one or more int*, return the (low) median. */
 static int
 median_int(smartlist_t *ints)
 {
   int idx;
+  tor_assert(smartlist_len(ints));
   smartlist_sort(ints, _compare_ints);
   idx = (smartlist_len(ints)-1)/2;
   return *(time_t*)smartlist_get(ints, idx);
 }
 
+/** Given a vote <b>vote</b> (not a consensus!), return its associated
+ * networkstatus_voter_info_t.*/
 static networkstatus_voter_info_t *
 get_voter(const networkstatus_vote_t *vote)
 {
@@ -125,7 +131,8 @@
   return smartlist_get(vote->voters, 0);
 }
 
-/** DOCDOC */
+/** Helper for sorting networkstatus_vote_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)
 {
@@ -134,7 +141,8 @@
                 get_voter(b)->identity_digest, DIGEST_LEN);
 }
 
-/** DOCDOC */
+/** Given a sorted list of strings <b>in</b>, add every member to <b>out</b>
+ * that occurs more than <b>min</b> times. */
 static void
 get_frequent_members(smartlist_t *out, smartlist_t *in, int min)
 {
@@ -155,7 +163,8 @@
     smartlist_add(out, cur);
 }
 
-/** DOCDOC */
+/** Given a sorted list of strings <b>lst</b>, return the member that appears
+ * most.  Break ties in favor of later-occuring members. */
 static const char *
 get_most_frequent_member(smartlist_t *lst)
 {
@@ -185,11 +194,16 @@
   return most_frequent;
 }
 
-/** DOCDOC */
+/** Return 0 if and only if <b>a</b> and <b>b</b> are routerstatuses
+ * that come from the same routerinfo, with the same derived elements.
+ */
 static int
-compare_votes(const vote_routerstatus_t *a, const vote_routerstatus_t *b)
+compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b)
 {
   int r;
+  if ((r = memcmp(a->status.identity_digest, b->status.identity_digest,
+                  DIGEST_LEN)))
+    return r;
   if ((r = memcmp(a->status.descriptor_digest, b->status.descriptor_digest,
                   DIGEST_LEN)))
     return r;
@@ -197,6 +211,8 @@
     return r;
   if ((r = strcmp(b->status.nickname, a->status.nickname)))
     return r;
+  if ((r = (((int)b->status.addr) - ((int)a->status.addr))))
+    return r;
   if ((r = (((int)b->status.or_port) - ((int)a->status.or_port))))
     return r;
   if ((r = (((int)b->status.dir_port) - ((int)a->status.dir_port))))
@@ -204,15 +220,18 @@
   return 0;
 }
 
-/** DOCDOC */
+/** Helper for sorting routerlists based on compare_vote_rs. */
 static int
-_compare_votes(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_votes(a,b);
+  return compare_vote_rs(a,b);
 }
 
-/** DOCDOC */
+/** Given a list of vote_routerstatus_t, all for the same router identity,
+ * return whichever is most frequent, breaking ties in favor of more
+ * recently published vote_routerstatus_t.
+ */
 static vote_routerstatus_t *
 compute_routerstatus_consensus(smartlist_t *votes)
 {
@@ -220,10 +239,10 @@
   int most_n = 0, cur_n = 0;
   time_t most_published = 0;
 
-  smartlist_sort(votes, _compare_votes);
+  smartlist_sort(votes, _compare_vote_rs);
   SMARTLIST_FOREACH(votes, vote_routerstatus_t *, rs,
   {
-    if (cur && !compare_votes(cur, rs)) {
+    if (cur && !compare_vote_rs(cur, rs)) {
       ++cur_n;
     } else {
       if (cur_n > most_n ||
@@ -249,7 +268,8 @@
   return most;
 }
 
-/** DOCDOC */
+/** Given a list of strings in <b>lst</b>, set the DIGEST_LEN-byte digest at
+ * <b>digest_out</b> to the hash of the concatenation of those strings. */
 static void
 hash_list_members(char *digest_out, smartlist_t *lst)
 {
@@ -260,9 +280,14 @@
   crypto_free_digest_env(d);
 }
 
-/** DOCDOC */
+/** Given a list of vote networkstatus_vote_t in <b>votes</b>, our public
+ * authority <b>identity_key</b>, our private authority <b>signing_key</b>,
+ * and the number of <b>total_authorities</b> that we believe exist in our
+ * voting quorum, generate the text of a new v3 consensus vote, and return the
+ * value in a newly allocated string. */
 char *
 networkstatus_compute_consensus(smartlist_t *votes,
+                                int total_authorities,
                                 crypto_pk_env_t *identity_key,
                                 crypto_pk_env_t *signing_key)
 {
@@ -273,7 +298,7 @@
   int vote_seconds, dist_seconds;
   char *client_versions = NULL, *server_versions = NULL;
   smartlist_t *flags;
-  int total_authorities = smartlist_len(votes); /*XXXX020 not right. */
+  tor_assert(total_authorities >= smartlist_len(votes));
 
   if (!smartlist_len(votes)) {
     log_warn(LD_DIR, "Can't compute a consensus from no votes.");
@@ -516,7 +541,7 @@
         }
         if (rs->flags & (U64_LITERAL(1) << named_flag[v_sl_idx])) {
           if (chosen_name && strcmp(chosen_name, rs->status.nickname))
-            naming_conflict = 1;
+            naming_conflict = 1; /* XXXX020 warn? */
           chosen_name = rs->status.nickname;
         }
 
@@ -646,8 +671,11 @@
   return result;
 }
 
-/** DOCDOC */
-/* private */
+/** Check whether the pending_signature on <b>voter</b> is correctly signed by
+ * the signing key of <b>cert</b>. Return -1 if <b>cert</b> doesn't match the
+ * signing key; otherwise set the good_signature or bad_signature flag on
+ * <b>voter</b>, and return 0. */
+/* (private; exposed for testing.) */
 int
 networkstatus_check_voter_signature(networkstatus_vote_t *consensus,
                                     networkstatus_voter_info_t *voter,
@@ -735,7 +763,8 @@
   tor_free(cert);
 }
 
-/** DOCDOC */
+/** Allocate and return a new authority_cert_t with the same contents as
+ * <b>cert</b>. */
 authority_cert_t *
 authority_cert_dup(authority_cert_t *cert)
 {

Modified: tor/branches/114-dist-storage/src/or/dns.c
===================================================================
--- tor/branches/114-dist-storage/src/or/dns.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/dns.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -103,7 +103,7 @@
 static void _assert_cache_ok(void);
 #define assert_cache_ok() _assert_cache_ok()
 #else
-#define assert_cache_ok() do {} while (0)
+#define assert_cache_ok() STMT_NIL
 #endif
 static void assert_resolve_ok(cached_resolve_t *resolve);
 
@@ -128,9 +128,9 @@
 }
 
 HT_PROTOTYPE(cache_map, cached_resolve_t, node, cached_resolve_hash,
-             cached_resolves_eq);
+             cached_resolves_eq)
 HT_GENERATE(cache_map, cached_resolve_t, node, cached_resolve_hash,
-            cached_resolves_eq, 0.6, malloc, realloc, free);
+            cached_resolves_eq, 0.6, malloc, realloc, free)
 
 /** Initialize the DNS cache. */
 static void

Modified: tor/branches/114-dist-storage/src/or/dnsserv.c
===================================================================
--- tor/branches/114-dist-storage/src/or/dnsserv.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/dnsserv.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -23,6 +23,7 @@
   struct evdns_server_question *q = NULL;
   struct sockaddr_storage addr;
   struct sockaddr *sa;
+  struct sockaddr_in *sin;
   int addrlen;
   uint32_t ipaddr;
   int err = DNS_ERR_NONE;
@@ -49,9 +50,10 @@
     evdns_server_request_respond(req, DNS_ERR_SERVERFAILED);
     return;
   } else {
-    struct sockaddr_in *sin = (struct sockaddr_in*)&addr;
+    sin = (struct sockaddr_in*)&addr;
     ipaddr = ntohl(sin->sin_addr.s_addr);
   }
+
   if (!socks_policy_permits_address(ipaddr)) {
     log_warn(LD_APP, "Rejecting DNS request from disallowed IP.");
     evdns_server_request_respond(req, DNS_ERR_REFUSED);
@@ -112,6 +114,11 @@
   /* Make a new dummy AP connection, and attach the request to it. */
   conn = TO_EDGE_CONN(connection_new(CONN_TYPE_AP, AF_INET));
   conn->_base.state = AP_CONN_STATE_RESOLVE_WAIT;
+
+  TO_CONN(conn)->addr = ntohl(sin->sin_addr.s_addr);
+  TO_CONN(conn)->port = ntohs(sin->sin_port);
+  TO_CONN(conn)->address = tor_dup_addr(TO_CONN(conn)->addr);
+
   if (q->type == EVDNS_TYPE_A)
     conn->socks_request->command = SOCKS_COMMAND_RESOLVE;
   else

Modified: tor/branches/114-dist-storage/src/or/eventdns.c
===================================================================
--- tor/branches/114-dist-storage/src/or/eventdns.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/eventdns.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -32,10 +32,9 @@
  * Version: 0.1b
  */
 
-#include <sys/types.h>
 #include "eventdns_tor.h"
+#include <sys/types.h>
 //#define NDEBUG
-#include "../common/torint.h"
 
 #ifndef DNS_USE_CPU_CLOCK_FOR_ID
 #ifndef DNS_USE_GETTIMEOFDAY_FOR_ID

Modified: tor/branches/114-dist-storage/src/or/main.c
===================================================================
--- tor/branches/114-dist-storage/src/or/main.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/main.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1965,7 +1965,7 @@
     goto err;
   }
 
-#define LOAD(f) do {                                                    \
+#define LOAD(f) STMT_BEGIN                                              \
     if (!(fn = GetProcAddress(library, #f))) {                          \
       log_err(LD_BUG,                                                   \
               "Couldn't find %s in advapi32.dll! We probably got the "  \
@@ -1974,7 +1974,7 @@
     } else {                                                            \
       service_fns.f ## _fn = fn;                                        \
     }                                                                   \
-  } while (0)
+  STMT_END
 
   LOAD(ChangeServiceConfig2A);
   LOAD(CloseServiceHandle);

Modified: tor/branches/114-dist-storage/src/or/or.h
===================================================================
--- tor/branches/114-dist-storage/src/or/or.h	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/or.h	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1878,6 +1878,7 @@
   int FetchServerDescriptors; /**< Do we fetch server descriptors as normal? */
   int FetchHidServDescriptors; /** and hidden service descriptors? */
   int FetchV2HidServDescriptors; /** and v2 hidden service descriptors? */
+//  int StoreAndServeV2HidServDescriptors; /** Do we act as hs dir? */
   int FetchUselessDescriptors; /**< Do we fetch non-running descriptors too? */
   int AllDirActionsPrivate; /**< Should every directory action be sent
                              * through a Tor circuit? */
@@ -2582,14 +2583,14 @@
  * Stmt must not contain any return or goto statements.
  */
 #define CONN_LOG_PROTECT(conn, stmt)                                    \
-  do {                                                                  \
+  STMT_BEGIN                                                            \
     int _log_conn_is_control = (conn && conn->type == CONN_TYPE_CONTROL); \
     if (_log_conn_is_control)                                           \
       disable_control_logging();                                        \
-    do {stmt;} while (0);                                               \
+  STMT_BEGIN stmt; STMT_END;                                            \
     if (_log_conn_is_control)                                           \
       enable_control_logging();                                         \
-  } while (0)
+  STMT_END
 
 /** Log information about the connection <b>conn</b>, protecting it as with
  * CONN_LOG_PROTECT. Example:
@@ -2764,6 +2765,7 @@
 
 void networkstatus_vote_free(networkstatus_vote_t *ns);
 char *networkstatus_compute_consensus(smartlist_t *votes,
+                                      int total_authorities,
                                       crypto_pk_env_t *identity_key,
                                       crypto_pk_env_t *signing_key);
 networkstatus_voter_info_t *networkstatus_get_voter_by_id(

Modified: tor/branches/114-dist-storage/src/or/policies.c
===================================================================
--- tor/branches/114-dist-storage/src/or/policies.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/policies.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -220,7 +220,7 @@
 }
 
 #define REJECT(arg) \
-  do { *msg = tor_strdup(arg); goto err; } while (0)
+  STMT_BEGIN *msg = tor_strdup(arg); goto err; STMT_END
 
 /** Config helper: If there's any problem with the policy configuration
  * options in <b>options</b>, return -1 and set <b>msg</b> to a newly

Modified: tor/branches/114-dist-storage/src/or/routerparse.c
===================================================================
--- tor/branches/114-dist-storage/src/or/routerparse.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/routerparse.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -2322,12 +2322,13 @@
 }
 
 #define RET_ERR(msg)                                               \
-  do {                                                             \
+  STMT_BEGIN                                                       \
     if (tok) token_free(tok);                                      \
     tok = tor_malloc_zero(sizeof(directory_token_t));              \
     tok->tp = _ERR;                                                \
     tok->error = tor_strdup(msg);                                  \
-    goto done_tokenizing; } while (0)
+    goto done_tokenizing;                                          \
+  STMT_END
 
 static INLINE directory_token_t *
 token_check_object(const char *kwd,
@@ -2386,12 +2387,13 @@
   const char *kwd = "";
 
 #define RET_ERR(msg)                                               \
-  do {                                                             \
+  STMT_BEGIN                                                       \
     if (tok) token_free(tok);                                      \
     tok = tor_malloc_zero(sizeof(directory_token_t));              \
     tok->tp = _ERR;                                                \
     tok->error = tor_strdup(msg);                                  \
-    goto done_tokenizing; } while (0)
+    goto done_tokenizing;                                          \
+  STMT_END
 
   tok = tor_malloc_zero(sizeof(directory_token_t));
   tok->tp = _ERR;

Modified: tor/branches/114-dist-storage/src/or/test.c
===================================================================
--- tor/branches/114-dist-storage/src/or/test.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/or/test.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -1007,25 +1007,25 @@
 }
 #define test_eq_ip6(a,b) _test_eq_ip6((a),(b),#a,#b,__LINE__)
 
-#define test_pton6_same(a,b) do {                 \
+#define test_pton6_same(a,b) STMT_BEGIN          \
     r = tor_inet_pton(AF_INET6, a, &a1);         \
     test_assert(r==1);                           \
     r = tor_inet_pton(AF_INET6, b, &a2);         \
     test_assert(r==1);                           \
     test_eq_ip6(&a1,&a2);                        \
-  } while (0)
+  STMT_END
 
 #define test_pton6_bad(a)                       \
   test_eq(0, tor_inet_pton(AF_INET6, a, &a1))
 
-#define test_ntop6_reduces(a,b) do {                                    \
+#define test_ntop6_reduces(a,b) STMT_BEGIN                              \
     r = tor_inet_pton(AF_INET6, a, &a1);                                \
     test_assert(r==1);                                                  \
     test_streq(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf)), b);      \
     r = tor_inet_pton(AF_INET6, b, &a2);                                \
     test_assert(r==1);                                                  \
     test_eq_ip6(&a1, &a2);                                              \
-  } while (0)
+  STMT_END
 
 static void
 test_ip6_helpers(void)
@@ -1408,7 +1408,7 @@
   /* Skip this test if we aren't threading. We should be threading most
    * everywhere by now. */
   if (1)
-    return 0;
+    return;
 #endif
   _thread_test_mutex = tor_mutex_new();
   _thread_test_start1 = tor_mutex_new();
@@ -1520,7 +1520,7 @@
     test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
                                    GZIP_METHOD));
     test_assert(buf2);
-    test_assert(!memcmp(buf2, "\037\213", 2)); /* Gztip magic. */
+    test_assert(!memcmp(buf2, "\037\213", 2)); /* Gzip magic. */
     test_assert(detect_compression_method(buf2, len1) == GZIP_METHOD);
 
     test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
@@ -2386,14 +2386,14 @@
   smartlist_add(votes, v3);
   smartlist_add(votes, v1);
   smartlist_add(votes, v2);
-  consensus_text = networkstatus_compute_consensus(votes,
+  consensus_text = networkstatus_compute_consensus(votes, 3,
                                                    cert3->identity_key,
                                                    sign_skey_3);
   test_assert(consensus_text);
   con = networkstatus_parse_vote_from_string(consensus_text, 0);
   test_assert(con);
-  log_notice(LD_GENERAL, "<<%s>>\n<<%s>>\n<<%s>>\n",
-             v1_text, v2_text, v3_text);
+  //log_notice(LD_GENERAL, "<<%s>>\n<<%s>>\n<<%s>>\n",
+  //           v1_text, v2_text, v3_text);
 
   /* Check consensus contents. */
   test_assert(!con->is_vote);

Modified: tor/branches/114-dist-storage/src/tools/tor-resolve.c
===================================================================
--- tor/branches/114-dist-storage/src/tools/tor-resolve.c	2007-06-28 12:52:30 UTC (rev 10698)
+++ tor/branches/114-dist-storage/src/tools/tor-resolve.c	2007-06-28 18:07:46 UTC (rev 10699)
@@ -41,8 +41,8 @@
 
 #define RESPONSE_LEN_4 8
 #define log_sock_error(act, _s)                                         \
-  do { log_fn(LOG_ERR, LD_NET, "Error while %s: %s", act,              \
-              tor_socket_strerror(tor_socket_errno(_s))); } while (0)
+  STMT_BEGIN log_fn(LOG_ERR, LD_NET, "Error while %s: %s", act,         \
+              tor_socket_strerror(tor_socket_errno(_s))); STMT_END
 
 static void usage(void) ATTR_NORETURN;
 



More information about the tor-commits mailing list