summaryrefslogtreecommitdiff
path: root/src/or/circuitlist.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-02-03 15:30:46 -0500
committerNick Mathewson <nickm@torproject.org>2017-08-08 20:29:33 -0400
commit00a02a3a59f6e44619e6caed150b001acae37231 (patch)
tree5b58a26b283d85688b8f4d524a0c67562c93b47a /src/or/circuitlist.c
parentc4ba4d4cc8a1d31f78d1dc54c7851bed32a25e5c (diff)
downloadtor-00a02a3a59f6e44619e6caed150b001acae37231.tar.gz
tor-00a02a3a59f6e44619e6caed150b001acae37231.zip
prop224: Service v3 descriptor creation and logic
This commit adds the functionality for a service to build its descriptor. Also, a global call to build all descriptors for all services is added to the service scheduled events. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r--src/or/circuitlist.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index d11e128787..f44343e11f 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -1532,6 +1532,41 @@ circuit_get_next_service_intro_circ(origin_circuit_t *start)
return NULL;
}
+/** Return the first service rendezvous circuit originating from the global
+ * circuit list after <b>start</b> or at the start of the list if <b>start</b>
+ * is NULL. Return NULL if no circuit is found.
+ *
+ * A service rendezvous point circuit has a purpose of either
+ * CIRCUIT_PURPOSE_S_CONNECT_REND or CIRCUIT_PURPOSE_S_REND_JOINED. This does
+ * not return a circuit marked for close and its state must be open. */
+origin_circuit_t *
+circuit_get_next_service_rp_circ(origin_circuit_t *start)
+{
+ int idx = 0;
+ smartlist_t *lst = circuit_get_global_list();
+
+ if (start) {
+ idx = TO_CIRCUIT(start)->global_circuitlist_idx + 1;
+ }
+
+ for ( ; idx < smartlist_len(lst); ++idx) {
+ circuit_t *circ = smartlist_get(lst, idx);
+
+ /* Ignore a marked for close circuit or purpose not matching a service
+ * intro point or if the state is not open. */
+ if (circ->marked_for_close || circ->state != CIRCUIT_STATE_OPEN ||
+ (circ->purpose != CIRCUIT_PURPOSE_S_CONNECT_REND &&
+ circ->purpose != CIRCUIT_PURPOSE_S_REND_JOINED)) {
+ continue;
+ }
+ /* The purposes we are looking for are only for origin circuits so the
+ * following is valid. */
+ return TO_ORIGIN_CIRCUIT(circ);
+ }
+ /* Not found. */
+ return NULL;
+}
+
/** Return the first circuit originating here in global_circuitlist after
* <b>start</b> whose purpose is <b>purpose</b>, and where <b>digest</b> (if
* set) matches the private key digest of the rend data associated with the