diff options
author | Mike Perry <mikeperry-git@torproject.org> | 2017-08-04 17:16:38 -0400 |
---|---|---|
committer | Mike Perry <mikeperry-git@torproject.org> | 2017-12-07 00:04:33 +0000 |
commit | b5d4cd1b4178bfa285fc5c512a29daa2580d96b8 (patch) | |
tree | 343e3a9dd79f6c804aa2b789685ebd99715203ea /src/or/circuitlist.c | |
parent | 23820a39439637f401b24085dfe7a703dee88c43 (diff) | |
download | tor-b5d4cd1b4178bfa285fc5c512a29daa2580d96b8.tar.gz tor-b5d4cd1b4178bfa285fc5c512a29daa2580d96b8.zip |
Bug #23100: Count all 3 hop circuits for CBT.
This change causes us to count anything once it reaches 3 hops (but not
after).
Diffstat (limited to 'src/or/circuitlist.c')
-rw-r--r-- | src/or/circuitlist.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c index d37d986f17..20fa03306e 100644 --- a/src/or/circuitlist.c +++ b/src/or/circuitlist.c @@ -1789,6 +1789,25 @@ circuit_get_cpath_len(origin_circuit_t *circ) return n; } +/** Return the number of opened hops in circuit's path. + * If circ has no entries, or is NULL, returns 0. */ +int +circuit_get_cpath_opened_len(origin_circuit_t *circ) +{ + int n = 0; + if (circ && circ->cpath) { + crypt_path_t *cpath, *cpath_next = NULL; + for (cpath = circ->cpath; + cpath->state == CPATH_STATE_OPEN + && cpath_next != circ->cpath; + cpath = cpath_next) { + cpath_next = cpath->next; + ++n; + } + } + return n; +} + /** Return the <b>hopnum</b>th hop in <b>circ</b>->cpath, or NULL if there * aren't that many hops in the list. <b>hopnum</b> starts at 1. * Returns NULL if <b>hopnum</b> is 0 or negative. */ |