aboutsummaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorKarsten Loesing <karsten.loesing@gmx.net>2013-05-24 12:29:42 +0200
committerKarsten Loesing <karsten.loesing@gmx.net>2013-05-25 19:51:38 +0200
commit26b49f525d5b2a4781755d72738491c016dd15a9 (patch)
tree98fbbb6fe3b79612e2c0adc2a44c5b83480a0720 /src/or/command.c
parent2f893624abb65a0df4f0f8ca6fbbe0c00fbf216a (diff)
downloadtor-26b49f525d5b2a4781755d72738491c016dd15a9.tar.gz
tor-26b49f525d5b2a4781755d72738491c016dd15a9.zip
Tweak CELL_STATS event based on comments by nickm.
- Move cell_command_to_string from control.c to command.c. - Use accessor for global_circuitlist instead of extern. - Add a struct for cell statistics by command instead of six arrays. - Split up control_event_circuit_cell_stats by using two helper functions. - Add TestingEnableCellStatsEvent option. - Prepare functions for testing. - Rename a few variables and document a few things better.
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 876ff526a6..d08633512e 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -52,6 +52,33 @@ static void command_process_created_cell(cell_t *cell, channel_t *chan);
static void command_process_relay_cell(cell_t *cell, channel_t *chan);
static void command_process_destroy_cell(cell_t *cell, channel_t *chan);
+/** Convert the cell <b>command</b> into a lower-case, human-readable
+ * string. */
+const char *
+cell_command_to_string(uint8_t command)
+{
+ switch (command) {
+ case CELL_PADDING: return "padding";
+ case CELL_CREATE: return "create";
+ case CELL_CREATED: return "created";
+ case CELL_RELAY: return "relay";
+ case CELL_DESTROY: return "destroy";
+ case CELL_CREATE_FAST: return "create_fast";
+ case CELL_CREATED_FAST: return "created_fast";
+ case CELL_VERSIONS: return "versions";
+ case CELL_NETINFO: return "netinfo";
+ case CELL_RELAY_EARLY: return "relay_early";
+ case CELL_CREATE2: return "create2";
+ case CELL_CREATED2: return "created2";
+ case CELL_VPADDING: return "vpadding";
+ case CELL_CERTS: return "certs";
+ case CELL_AUTH_CHALLENGE: return "auth_challenge";
+ case CELL_AUTHENTICATE: return "authenticate";
+ case CELL_AUTHORIZE: return "authorize";
+ default: return "unrecognized";
+ }
+}
+
#ifdef KEEP_TIMING_STATS
/** This is a wrapper function around the actual function that processes the
* <b>cell</b> that just arrived on <b>conn</b>. Increment <b>*time</b>