[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Report HS circ states stored in circ purpose field in CIRC events



commit c7d01b0541a10a51b5e41f3e68eabb90fca3067a
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date:   Thu Jun 23 17:28:59 2011 -0700

    Report HS circ states stored in circ purpose field in CIRC events
---
 changes/feature2411  |    4 +++
 src/or/circuitlist.c |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 src/or/circuitlist.h |    1 +
 src/or/control.c     |   13 +++++++++++
 4 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/changes/feature2411 b/changes/feature2411
index b60fbfd..e029162 100644
--- a/changes/feature2411
+++ b/changes/feature2411
@@ -4,4 +4,8 @@
       controllers in CIRC events and in replies to 'GETINFO
       circuit-status'.  Implements part of ticket 2411.
 
+    - Report the current state of a hidden-service-related circuit to
+      controllers in CIRC events and in replies to 'GETINFO
+      circuit-status'.  Implements part of ticket 2411.
+
 
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 25b80f1..daf2eef 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -378,6 +378,63 @@ circuit_purpose_to_controller_string(uint8_t purpose)
   }
 }
 
+/** Return a string specifying the state of the hidden-service circuit
+ * purpose <b>purpose</b>, or NULL if <b>purpose</b> is not a
+ * hidden-service-related circuit purpose. */
+const char *
+circuit_purpose_to_controller_hs_state_string(uint8_t purpose)
+{
+  switch (purpose)
+    {
+    default:
+      log_fn(LOG_WARN, LD_BUG,
+             "Unrecognized circuit purpose: %d",
+             (int)purpose);
+      tor_fragile_assert();
+      /* fall through */
+
+    case CIRCUIT_PURPOSE_OR:
+    case CIRCUIT_PURPOSE_C_GENERAL:
+    case CIRCUIT_PURPOSE_C_MEASURE_TIMEOUT:
+    case CIRCUIT_PURPOSE_TESTING:
+    case CIRCUIT_PURPOSE_CONTROLLER:
+      return NULL;
+
+    case CIRCUIT_PURPOSE_INTRO_POINT:
+      return "OR_HSSI_ESTABLISHED";
+    case CIRCUIT_PURPOSE_REND_POINT_WAITING:
+      return "OR_HSCR_ESTABLISHED";
+    case CIRCUIT_PURPOSE_REND_ESTABLISHED:
+      return "OR_HS_R_JOINED";
+
+    case CIRCUIT_PURPOSE_C_INTRODUCING:
+      return "HSCI_CONNECTING";
+    case CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT:
+      return "HSCI_INTRO_SENT";
+    case CIRCUIT_PURPOSE_C_INTRODUCE_ACKED:
+      return "HSCI_DONE";
+
+    case CIRCUIT_PURPOSE_C_ESTABLISH_REND:
+      return "HSCR_CONNECTING";
+    case CIRCUIT_PURPOSE_C_REND_READY:
+      return "HSCR_ESTABLISHED_IDLE";
+    case CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED:
+      return "HSCR_ESTABLISHED_WAITING";
+    case CIRCUIT_PURPOSE_C_REND_JOINED:
+      return "HSCR_JOINED";
+
+    case CIRCUIT_PURPOSE_S_ESTABLISH_INTRO:
+      return "HSSI_CONNECTING";
+    case CIRCUIT_PURPOSE_S_INTRO:
+      return "HSSI_ESTABLISHED";
+
+    case CIRCUIT_PURPOSE_S_CONNECT_REND:
+      return "HSSR_CONNECTING";
+    case CIRCUIT_PURPOSE_S_REND_JOINED:
+      return "HSSR_JOINED";
+    }
+}
+
 /** Return a human-readable string for the circuit purpose <b>purpose</b>. */
 const char *
 circuit_purpose_to_string(uint8_t purpose)
diff --git a/src/or/circuitlist.h b/src/or/circuitlist.h
index 7b01ca3..8ed089c 100644
--- a/src/or/circuitlist.h
+++ b/src/or/circuitlist.h
@@ -15,6 +15,7 @@
 circuit_t * _circuit_get_global_list(void);
 const char *circuit_state_to_string(int state);
 const char *circuit_purpose_to_controller_string(uint8_t purpose);
+const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);
 const char *circuit_purpose_to_string(uint8_t purpose);
 void circuit_dump_by_conn(connection_t *conn, int severity);
 void circuit_set_p_circid_orconn(or_circuit_t *circ, circid_t id,
diff --git a/src/or/control.c b/src/or/control.c
index 2957309..6b7f9dc 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1829,6 +1829,19 @@ circuit_describe_status_for_controller(origin_circuit_t *circ)
     smartlist_add(descparts, purpose);
   }
 
+  {
+    char *hs_state_arg = NULL;
+    const char *hs_state =
+      circuit_purpose_to_controller_hs_state_string(circ->_base.purpose);
+
+    if (hs_state != NULL) {
+      tor_asprintf(&hs_state_arg, "HS_STATE=%s",
+                   hs_state);
+
+      smartlist_add(descparts, hs_state_arg);
+    }
+  }
+
   rv = smartlist_join_strings(descparts, " ", 0, NULL);
 
   SMARTLIST_FOREACH(descparts, char *, cp, tor_free(cp));



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits