aboutsummaryrefslogtreecommitdiff
path: root/src/or/circuitbuild.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-11-06 19:56:47 -0500
committerNick Mathewson <nickm@torproject.org>2012-11-06 21:23:46 -0500
commitbfffc1f0fc7616a25c32da2eb759dade4651659e (patch)
treeb31b3fe368816de2f5a001fbd975ead5aa1c2d9e /src/or/circuitbuild.c
parentcd054ceadaa4723f076c7050160424b356b985ca (diff)
downloadtor-bfffc1f0fc7616a25c32da2eb759dade4651659e.tar
tor-bfffc1f0fc7616a25c32da2eb759dade4651659e.tar.gz
Allow a v4 link protocol for 4-byte circuit IDs.
Implements proposal 214. Needs testing.
Diffstat (limited to 'src/or/circuitbuild.c')
-rw-r--r--src/or/circuitbuild.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 1fb93bbd2..7607348b8 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -89,7 +89,7 @@ get_unique_circ_id_by_chan(channel_t *chan)
{
circid_t test_circ_id;
circid_t attempts=0;
- circid_t high_bit;
+ circid_t high_bit, max_range;
tor_assert(chan);
@@ -99,17 +99,17 @@ get_unique_circ_id_by_chan(channel_t *chan)
"a client with no identity.");
return 0;
}
- high_bit =
- (chan->circ_id_type == CIRC_ID_TYPE_HIGHER) ? 1<<15 : 0;
+ max_range = (chan->wide_circ_ids) ? (1u<<31) : (1u<<15);
+ high_bit = (chan->circ_id_type == CIRC_ID_TYPE_HIGHER) ? max_range : 0;
do {
- /* Sequentially iterate over test_circ_id=1...1<<15-1 until we find a
+ /* Sequentially iterate over test_circ_id=1...max_range until we find a
* circID such that (high_bit|test_circ_id) is not already used. */
test_circ_id = chan->next_circ_id++;
- if (test_circ_id == 0 || test_circ_id >= 1<<15) {
+ if (test_circ_id == 0 || test_circ_id >= max_range) {
test_circ_id = 1;
chan->next_circ_id = 2;
}
- if (++attempts > 1<<15) {
+ if (++attempts > max_range) {
/* Make sure we don't loop forever if all circ_id's are used. This
* matters because it's an external DoS opportunity.
*/