aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2013-05-31 15:51:25 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2013-05-31 16:12:28 +0200
commite39292f21dd363bd7601b63b4f43a95705c3332b (patch)
treea54ba8d1b8a066f556113968fdcde05b7f22df2b /src/or
parentb33b366a7f8bcab1c9b4859788e3b2c7d3dcf180 (diff)
downloadtor-e39292f21dd363bd7601b63b4f43a95705c3332b.tar
tor-e39292f21dd363bd7601b63b4f43a95705c3332b.tar.gz
Test functions used for TB_EMPTY and CELL_STATS events.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c5
-rw-r--r--src/or/connection.h11
-rw-r--r--src/or/control.c22
-rw-r--r--src/or/control.h26
4 files changed, 42 insertions, 22 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 88def49e5..842523958 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -17,6 +17,7 @@
* part of a subclass (channel_tls_t).
*/
#define TOR_CHANNEL_INTERNAL_
+#define CONNECTION_PRIVATE
#include "channel.h"
#include "channeltls.h"
#include "circuitbuild.h"
@@ -2561,7 +2562,7 @@ msec_since_midnight(struct timeval tvnow)
* <b>tokens_removed</b> tokens removed at timestamp <b>tvnow</b> has run
* out of tokens, and if so, note the milliseconds since midnight in
* <b>timestamp_var</b> for the next TB_EMPTY event. */
-static void
+void
connection_buckets_note_empty_ts(uint32_t *timestamp_var,
int tokens_before, size_t tokens_removed,
struct timeval tvnow)
@@ -2728,7 +2729,7 @@ connection_bucket_refill_helper(int *bucket, int rate, int burst,
* <b>tvnow</b>, capped at <b>milliseconds_elapsed</b> milliseconds since
* last refilling that bucket. Return 0 if the bucket has not been empty
* since the last refill or has not been refilled. */
-static uint32_t
+uint32_t
bucket_millis_empty(int tokens_before, uint32_t last_empty_time,
int tokens_after, int milliseconds_elapsed,
struct timeval tvnow)
diff --git a/src/or/connection.h b/src/or/connection.h
index 3e656ec06..c0894cd09 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -214,5 +214,16 @@ void connection_enable_rate_limiting(connection_t *conn);
#define connection_type_uses_bufferevent(c) (0)
#endif
+#ifdef CONNECTION_PRIVATE
+/* Used only by connection.c and test*.c */
+uint32_t bucket_millis_empty(int tokens_before, uint32_t last_empty_time,
+ int tokens_after, int milliseconds_elapsed,
+ struct timeval tvnow);
+void connection_buckets_note_empty_ts(uint32_t *timestamp_var,
+ int tokens_before,
+ size_t tokens_removed,
+ struct timeval tvnow);
+#endif
+
#endif
diff --git a/src/or/control.c b/src/or/control.c
index 5e2020f7c..495b7d7b0 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4015,27 +4015,11 @@ control_event_conn_bandwidth_used(void)
return 0;
}
-/** Helper structure: temporarily stores cell statistics for a circuit. */
-typedef struct cell_stats_t {
- /** Number of cells added in app-ward direction by command. */
- uint64_t added_cells_appward[CELL_COMMAND_MAX_ + 1];
- /** Number of cells added in exit-ward direction by command. */
- uint64_t added_cells_exitward[CELL_COMMAND_MAX_ + 1];
- /** Number of cells removed in app-ward direction by command. */
- uint64_t removed_cells_appward[CELL_COMMAND_MAX_ + 1];
- /** Number of cells removed in exit-ward direction by command. */
- uint64_t removed_cells_exitward[CELL_COMMAND_MAX_ + 1];
- /** Total waiting time of cells in app-ward direction by command. */
- uint64_t total_time_appward[CELL_COMMAND_MAX_ + 1];
- /** Total waiting time of cells in exit-ward direction by command. */
- uint64_t total_time_exitward[CELL_COMMAND_MAX_ + 1];
-} cell_stats_t;
-
/** Helper: iterate over cell statistics of <b>circ</b> and sum up added
* cells, removed cells, and waiting times by cell command and direction.
* Store results in <b>cell_stats</b>. Free cell statistics of the
* circuit afterwards. */
-static void
+void
sum_up_cell_stats_by_command(circuit_t *circ, cell_stats_t *cell_stats)
{
memset(cell_stats, 0, sizeof(cell_stats_t));
@@ -4067,7 +4051,7 @@ sum_up_cell_stats_by_command(circuit_t *circ, cell_stats_t *cell_stats)
* the (possibly zero) entry from <code>number_to_include</code>. If no
* entry in <code>include_if_non_zero</code> is positive, no string will
* be added to <code>event_parts</code>. */
-static void
+void
append_cell_stats_by_command(smartlist_t *event_parts, const char *key,
uint64_t *include_if_non_zero,
uint64_t *number_to_include)
@@ -4092,7 +4076,7 @@ append_cell_stats_by_command(smartlist_t *event_parts, const char *key,
/** Helper: format <b>cell_stats</b> for <b>circ</b> for inclusion in a
* CELL_STATS event and write result string to <b>event_string</b>. */
-static void
+void
format_cell_stats(char **event_string, circuit_t *circ,
cell_stats_t *cell_stats)
{
diff --git a/src/or/control.h b/src/or/control.h
index c79c432ef..1773a8737 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -97,9 +97,33 @@ void control_event_bootstrap_problem(const char *warn, int reason);
void control_event_clients_seen(const char *controller_str);
#ifdef CONTROL_PRIVATE
-/* Used only by control.c and test.c */
+/* Used only by control.c and test*.c */
size_t write_escaped_data(const char *data, size_t len, char **out);
size_t read_escaped_data(const char *data, size_t len, char **out);
+
+/** Helper structure: temporarily stores cell statistics for a circuit. */
+typedef struct cell_stats_t {
+ /** Number of cells added in app-ward direction by command. */
+ uint64_t added_cells_appward[CELL_COMMAND_MAX_ + 1];
+ /** Number of cells added in exit-ward direction by command. */
+ uint64_t added_cells_exitward[CELL_COMMAND_MAX_ + 1];
+ /** Number of cells removed in app-ward direction by command. */
+ uint64_t removed_cells_appward[CELL_COMMAND_MAX_ + 1];
+ /** Number of cells removed in exit-ward direction by command. */
+ uint64_t removed_cells_exitward[CELL_COMMAND_MAX_ + 1];
+ /** Total waiting time of cells in app-ward direction by command. */
+ uint64_t total_time_appward[CELL_COMMAND_MAX_ + 1];
+ /** Total waiting time of cells in exit-ward direction by command. */
+ uint64_t total_time_exitward[CELL_COMMAND_MAX_ + 1];
+} cell_stats_t;
+void sum_up_cell_stats_by_command(circuit_t *circ,
+ cell_stats_t *cell_stats);
+void append_cell_stats_by_command(smartlist_t *event_parts,
+ const char *key,
+ uint64_t *include_if_non_zero,
+ uint64_t *number_to_include);
+void format_cell_stats(char **event_string, circuit_t *circ,
+ cell_stats_t *cell_stats);
#endif
#endif