summaryrefslogtreecommitdiff
path: root/src/or/policies.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-07-25 15:11:21 +0000
committerNick Mathewson <nickm@torproject.org>2008-07-25 15:11:21 +0000
commit056d97da0c6c69aa2da9855675b6726f471b5f5a (patch)
tree7ea7884cc6b035e6d0985b750a1e3d29f067720f /src/or/policies.c
parent016adc9a08bdccf395b41709b5b534edf2298f6e (diff)
downloadtor-056d97da0c6c69aa2da9855675b6726f471b5f5a.tar.gz
tor-056d97da0c6c69aa2da9855675b6726f471b5f5a.zip
r17391@pc-10-8-1-079: nickm | 2008-07-25 17:11:17 +0200
Tor_addr_compare did a semantic comparison, such that ::1.2.3.4 and 1.2.3.4 were "equal". we sometimes need an exact comparison. Add a feature to do that. svn:r16210
Diffstat (limited to 'src/or/policies.c')
-rw-r--r--src/or/policies.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/or/policies.c b/src/or/policies.c
index fb5c0d56be..7fef216e3d 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -409,7 +409,7 @@ cmp_single_addr_policy(addr_policy_t *a, addr_policy_t *b)
return r;
if ((r=((int)a->is_private - (int)b->is_private)))
return r;
- if ((r=tor_addr_compare(&a->addr, &b->addr)))
+ if ((r=tor_addr_compare(&a->addr, &b->addr, CMP_EXACT)))
return r;
if ((r=((int)a->maskbits - (int)b->maskbits)))
return r;
@@ -558,7 +558,8 @@ compare_addr_to_addr_policy(uint32_t _addr, uint16_t port,
}
} else {
/* Address is known */
- if (!tor_addr_compare_masked(&addr, &tmpe->addr, tmpe->maskbits)) {
+ if (!tor_addr_compare_masked(&addr, &tmpe->addr, tmpe->maskbits,
+ CMP_SEMANTIC)) {
if (port >= tmpe->prt_min && port <= tmpe->prt_max) {
/* Exact match for the policy */
match = 1;
@@ -601,7 +602,7 @@ addr_policy_covers(addr_policy_t *a, addr_policy_t *b)
/* a has more fixed bits than b; it can't possibly cover b. */
return 0;
}
- if (tor_addr_compare_masked(&a->addr, &b->addr, a->maskbits)) {
+ if (tor_addr_compare_masked(&a->addr, &b->addr, a->maskbits, CMP_SEMANTIC)) {
/* There's a fixed bit in a that's set differently in b. */
return 0;
}
@@ -624,7 +625,7 @@ addr_policy_intersects(addr_policy_t *a, addr_policy_t *b)
minbits = a->maskbits;
else
minbits = b->maskbits;
- if (tor_addr_compare_masked(&a->addr, &b->addr, minbits))
+ if (tor_addr_compare_masked(&a->addr, &b->addr, minbits, CMP_SEMANTIC))
return 0;
if (a->prt_max < b->prt_min || b->prt_max < a->prt_min)
return 0;