diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-07-26 19:05:41 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-07-26 19:05:41 +0000 |
commit | e61d28dfb8f2936b8024f1cb4d3ad8ecf1cd25b5 (patch) | |
tree | e5e1a34aa6f63717ddcb75087bd1ec8f93939ce5 /src/or/circuitlist.c | |
parent | a88ec48a39e5531fa80a0b5d5ec42dd31f268b67 (diff) | |
download | tor-e61d28dfb8f2936b8024f1cb4d3ad8ecf1cd25b5.tar.gz tor-e61d28dfb8f2936b8024f1cb4d3ad8ecf1cd25b5.zip |
r6903@Kushana: nickm | 2006-07-25 18:22:48 -0400
No circuit can be both an intro point and a rend point, so we can merge both the cookie and the pk digest into one "rend_token" field for or circuits. This saves another 20 bytes per or circuit.
svn:r6904
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r-- | src/or/circuitlist.c | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index 2751dde6bf..db8b7577f2 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -652,44 +652,67 @@ circuit_get_by_rend_query_and_purpose(const char *rend_query, uint8_t purpose) * whose rend_pk_digest field is <b>digest</b> and whose purpose is * <b>purpose</b>. Returns NULL if no circuit is found. * If <b>start</b> is NULL, begin at the start of the list. + * DOCDOC origin. */ -circuit_t * -circuit_get_next_by_pk_and_purpose(circuit_t *start, +origin_circuit_t * +circuit_get_next_by_pk_and_purpose(origin_circuit_t *start, const char *digest, uint8_t purpose) { circuit_t *circ; + tor_assert(CIRCUIT_PURPOSE_IS_ORIGIN(purpose)); if (start == NULL) circ = global_circuitlist; else - circ = start->next; + circ = TO_CIRCUIT(start)->next; for ( ; circ; circ = circ->next) { if (circ->marked_for_close) continue; if (circ->purpose != purpose) continue; - if (!memcmp(circ->rend_pk_digest, digest, DIGEST_LEN)) - return circ; + if (!memcmp(TO_ORIGIN_CIRCUIT(circ)->rend_pk_digest, digest, DIGEST_LEN)) + return TO_ORIGIN_CIRCUIT(circ); } return NULL; } -/** Return the circuit waiting for a rendezvous with the provided cookie. - * Return NULL if no such circuit is found. - */ -or_circuit_t * -circuit_get_rendezvous(const char *cookie) +/* DOCDOC */ +static or_circuit_t * +circuit_get_by_rend_token_and_purpose(uint8_t purpose, const char *token, + size_t len) { circuit_t *circ; for (circ = global_circuitlist; circ; circ = circ->next) { if (! circ->marked_for_close && - circ->purpose == CIRCUIT_PURPOSE_REND_POINT_WAITING && - ! memcmp(circ->rend_cookie, cookie, REND_COOKIE_LEN) ) + circ->purpose == purpose && + ! memcmp(TO_OR_CIRCUIT(circ)->rend_token, token, len)) return TO_OR_CIRCUIT(circ); } return NULL; } +/** Return the circuit waiting for a rendezvous with the provided cookie. + * Return NULL if no such circuit is found. + */ +or_circuit_t * +circuit_get_rendezvous(const char *cookie) +{ + return circuit_get_by_rend_token_and_purpose( + CIRCUIT_PURPOSE_REND_POINT_WAITING, + cookie, REND_COOKIE_LEN); +} + +/** Return the circuit waiting for intro cells of the given digest. + * Return NULL if no such circuit is found. + */ +or_circuit_t * +circuit_get_intro_point(const char *digest) +{ + return circuit_get_by_rend_token_and_purpose( + CIRCUIT_PURPOSE_INTRO_POINT, digest, + DIGEST_LEN); +} + /** Return a circuit that is open, has specified <b>purpose</b>, * has a timestamp_dirty value of 0, is uptime/capacity/internal * if required, and if info is defined, does not already use info |