Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Goulet
Tor
Commits
3196de33
Commit
3196de33
authored
Sep 23, 2020
by
Nick Mathewson
🎨
Browse files
Tidy up compare_routerinfo_by_ipv{4,6} to match better.
parent
81c05e1e
Changes
1
Show whitespace changes
Inline
Side-by-side
src/feature/dirauth/dirvote.c
View file @
3196de33
...
...
@@ -4215,19 +4215,16 @@ MOCK_IMPL(uint32_t,dirserv_get_bandwidth_for_router_kb,
STATIC
int
compare_routerinfo_by_ipv4
(
const
void
**
a
,
const
void
**
b
)
{
const
routerinfo_t
*
first
=
*
(
routerinfo_t
**
)
a
;
const
routerinfo_t
*
second
=
*
(
routerinfo_t
**
)
b
;
// If addresses are equal, use other comparison criterions
int
addr_comparison
=
tor_addr_compare
(
&
(
first
->
ipv4_addr
),
&
(
second
->
ipv4_addr
),
CMP_EXACT
);
if
(
addr_comparison
==
0
)
{
const
routerinfo_t
*
first
=
*
(
const
routerinfo_t
**
)
a
;
const
routerinfo_t
*
second
=
*
(
const
routerinfo_t
**
)
b
;
const
tor_addr_t
*
first_ipv4
=
&
first
->
ipv4_addr
;
const
tor_addr_t
*
second_ipv4
=
&
first
->
ipv4_addr
;
int
comparison
=
tor_addr_compare
(
first_ipv4
,
second_ipv4
,
CMP_EXACT
);
if
(
comparison
==
0
)
{
// If addresses are equal, use other comparison criteria
return
compare_routerinfo_usefulness
(
first
,
second
);
}
else
{
// Otherwise, compare the addresses
if
(
addr_comparison
<
0
)
return
-
1
;
else
return
1
;
return
comparison
;
}
}
...
...
@@ -4238,12 +4235,12 @@ compare_routerinfo_by_ipv4(const void **a, const void **b)
STATIC
int
compare_routerinfo_by_ipv6
(
const
void
**
a
,
const
void
**
b
)
{
const
routerinfo_t
*
first
=
*
(
routerinfo_t
**
)
a
;
const
routerinfo_t
*
second
=
*
(
routerinfo_t
**
)
b
;
const
routerinfo_t
*
first
=
*
(
const
routerinfo_t
**
)
a
;
const
routerinfo_t
*
second
=
*
(
const
routerinfo_t
**
)
b
;
const
tor_addr_t
*
first_ipv6
=
&
(
first
->
ipv6_addr
);
const
tor_addr_t
*
second_ipv6
=
&
(
second
->
ipv6_addr
);
int
comparison
=
tor_addr_compare
(
first_ipv6
,
second_ipv6
,
CMP_EXACT
);
// If addresses are equal, use other comparison criteri
ons
// If addresses are equal, use other comparison criteri
a
if
(
comparison
==
0
)
return
compare_routerinfo_usefulness
(
first
,
second
);
else
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment