Browse Source

Make circpathbias and circuitbuild compile.

That was the tricky part
Nick Mathewson 10 years ago
parent
commit
5cba0ddfc4
3 changed files with 46 additions and 30 deletions
  1. 44 4
      src/or/circpathbias.c
  2. 2 0
      src/or/circpathbias.h
  3. 0 26
      src/or/circuitbuild.c

+ 44 - 4
src/or/circpathbias.c

@@ -1,14 +1,54 @@
-
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#include "or.h"
+#include "channel.h"
 #include "circpathbias.h"
 #include "circuitbuild.h"
+#include "circuitlist.h"
+#include "circuituse.h"
+#include "circuitstats.h"
+#include "connection_edge.h"
+#include "config.h"
+#include "entrynodes.h"
+#include "networkstatus.h"
+#include "relay.h"
 
-static void pathbias_count_build_success(origin_circuit_t *circ);
 static void pathbias_count_successful_close(origin_circuit_t *circ);
 static void pathbias_count_collapse(origin_circuit_t *circ);
 static void pathbias_count_use_failed(origin_circuit_t *circ);
 static void pathbias_measure_use_rate(entry_guard_t *guard);
 static void pathbias_measure_close_rate(entry_guard_t *guard);
 static void pathbias_scale_use_rates(entry_guard_t *guard);
+static void pathbias_scale_close_rates(entry_guard_t *guard);
+static int entry_guard_inc_circ_attempt_count(entry_guard_t *guard);
+
+/** Increment the number of times we successfully extended a circuit to
+ * <b>guard</b>, first checking if the failure rate is high enough that
+ * we should eliminate the guard. Return -1 if the guard looks no good;
+ * return 0 if the guard looks fine.
+ */
+static int
+entry_guard_inc_circ_attempt_count(entry_guard_t *guard)
+{
+  entry_guards_changed();
+
+  pathbias_measure_close_rate(guard);
+
+  if (guard->path_bias_disabled)
+    return -1;
+
+  pathbias_scale_close_rates(guard);
+  guard->circ_attempts++;
+
+  log_info(LD_CIRC, "Got success count %f/%f for guard %s ($%s)",
+           guard->circ_successes, guard->circ_attempts, guard->nickname,
+           hex_str(guard->identity, DIGEST_LEN));
+  return 0;
+}
 
 /** The minimum number of circuit attempts before we start
   * thinking about warning about path bias and dropping guards */
@@ -349,7 +389,7 @@ pathbias_should_count(origin_circuit_t *circ)
  *
  * Also check for several potential error cases for bug #6475.
  */
-static int
+int
 pathbias_count_build_attempt(origin_circuit_t *circ)
 {
 #define CIRC_ATTEMPT_NOTICE_INTERVAL (600)
@@ -435,7 +475,7 @@ pathbias_count_build_attempt(origin_circuit_t *circ)
  *
  * Also check for several potential error cases for bug #6475.
  */
-static void
+void
 pathbias_count_build_success(origin_circuit_t *circ)
 {
 #define SUCCESS_NOTICE_INTERVAL (600)

+ 2 - 0
src/or/circpathbias.h

@@ -16,6 +16,8 @@ double pathbias_get_extreme_rate(const or_options_t *options);
 double pathbias_get_extreme_use_rate(const or_options_t *options);
 int pathbias_get_dropguards(const or_options_t *options);
 void pathbias_count_timeout(origin_circuit_t *circ);
+void pathbias_count_build_success(origin_circuit_t *circ);
+int pathbias_count_build_attempt(origin_circuit_t *circ);
 int pathbias_check_close(origin_circuit_t *circ, int reason);
 int pathbias_check_probe_response(circuit_t *circ, const cell_t *cell);
 void pathbias_count_use_attempt(origin_circuit_t *circ);

+ 0 - 26
src/or/circuitbuild.c

@@ -41,7 +41,6 @@
 #include "routerparse.h"
 #include "routerset.h"
 #include "crypto.h"
-#include "connection_edge.h"
 
 #ifndef MIN
 #define MIN(a,b) ((a)<(b)?(a):(b))
@@ -58,7 +57,6 @@ static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
 static int onion_extend_cpath(origin_circuit_t *circ);
 static int count_acceptable_nodes(smartlist_t *routers);
 static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
-static int entry_guard_inc_circ_attempt_count(entry_guard_t *guard);
 
 /** This function tries to get a channel to the specified endpoint,
  * and then calls command_setup_channel() to give it the right
@@ -1078,30 +1076,6 @@ circuit_init_cpath_crypto(crypt_path_t *cpath, const char *key_data,
   return 0;
 }
 
-/** Increment the number of times we successfully extended a circuit to
- * <b>guard</b>, first checking if the failure rate is high enough that
- * we should eliminate the guard. Return -1 if the guard looks no good;
- * return 0 if the guard looks fine.
- */
-static int
-entry_guard_inc_circ_attempt_count(entry_guard_t *guard)
-{
-  entry_guards_changed();
-
-  pathbias_measure_close_rate(guard);
-
-  if (guard->path_bias_disabled)
-    return -1;
-
-  pathbias_scale_close_rates(guard);
-  guard->circ_attempts++;
-
-  log_info(LD_CIRC, "Got success count %f/%f for guard %s ($%s)",
-           guard->circ_successes, guard->circ_attempts, guard->nickname,
-           hex_str(guard->identity, DIGEST_LEN));
-  return 0;
-}
-
 /** A "created" cell <b>reply</b> came back to us on circuit <b>circ</b>.
  * (The body of <b>reply</b> varies depending on what sort of handshake
  * this is.)