summaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-09-29 22:34:22 +0000
committerNick Mathewson <nickm@torproject.org>2008-09-29 22:34:22 +0000
commit25f833552883727b718ca7782efe344434c703f4 (patch)
tree5fd5516dcb6b13a9d6169b83c6b0bf7e7ff9d6f5 /src/or/circuitlist.c
parent9d950f7d25c91ede1b46fac7466add5cbf5a0d71 (diff)
downloadtor-25f833552883727b718ca7782efe344434c703f4.tar.gz
tor-25f833552883727b718ca7782efe344434c703f4.zip
Include circuit purposes in circuit events. Now all circuit events are extended; this makes the code simpler.
svn:r17007
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 29dd1fd50a..9dbec897c9 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -319,6 +319,50 @@ circuit_state_to_string(int state)
}
}
+/** Map a circuit purpose to a string suitable to be displayed to a
+ * controller. */
+const char *
+circuit_purpose_to_controller_string(uint8_t purpose)
+{
+ static char buf[32];
+ switch (purpose) {
+ case CIRCUIT_PURPOSE_OR:
+ case CIRCUIT_PURPOSE_INTRO_POINT:
+ case CIRCUIT_PURPOSE_REND_POINT_WAITING:
+ case CIRCUIT_PURPOSE_REND_ESTABLISHED:
+ return "SERVER"; /* A controller should never see these, actually. */
+
+ case CIRCUIT_PURPOSE_C_GENERAL:
+ return "GENERAL";
+ case CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT:
+ case CIRCUIT_PURPOSE_C_INTRODUCE_ACKED:
+ return "HS_CLIENT_INTRO";
+
+ case CIRCUIT_PURPOSE_C_ESTABLISH_REND:
+ case CIRCUIT_PURPOSE_C_REND_READY:
+ case CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED:
+ case CIRCUIT_PURPOSE_C_REND_JOINED:
+ return "HS_CLIENT_REND";
+
+ case CIRCUIT_PURPOSE_S_ESTABLISH_INTRO:
+ case CIRCUIT_PURPOSE_S_INTRO:
+ return "HS_SERVICE_INTRO";
+
+ case CIRCUIT_PURPOSE_S_CONNECT_REND:
+ case CIRCUIT_PURPOSE_S_REND_JOINED:
+ return "HS_SERVICE_REND";
+
+ case CIRCUIT_PURPOSE_TESTING:
+ return "TESTING";
+ case CIRCUIT_PURPOSE_CONTROLLER:
+ return "CONTROLLER";
+
+ default:
+ tor_snprintf(buf, sizeof(buf), "UNKNOWN_%d", (int)purpose);
+ return buf;
+ }
+}
+
/** Initialize the common elements in a circuit_t, and add it to the global
* list. */
static void