Make the router_get_*_orport interface consistent with node_*.

This commit is contained in:
Linus Nordberg 2011-11-28 13:51:56 +01:00 committed by Nick Mathewson
parent 3b51b326e4
commit 39ec781b8f
3 changed files with 14 additions and 15 deletions

View File

@ -740,8 +740,7 @@ void
node_get_pref_ipv6_addr(const node_t *node, tor_addr_port_t *ap_out) node_get_pref_ipv6_addr(const node_t *node, tor_addr_port_t *ap_out)
{ {
if (node->ri) { if (node->ri) {
tor_addr_copy(&ap_out->addr, &node->ri->ipv6_addr); router_get_pref_ipv6_orport(node->ri, ap_out);
ap_out->port = node->ri->ipv6_orport;
} else if (node->rs) { } else if (node->rs) {
/* No IPv6 in routerstatus_t yet. XXXprop186 ok for private /* No IPv6 in routerstatus_t yet. XXXprop186 ok for private
bridges but needs fixing */ bridges but needs fixing */

View File

@ -2132,16 +2132,6 @@ router_get_prim_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
ap_out->port = router->or_port; ap_out->port = router->or_port;
} }
/** Copy the alternative, presumably IPv6, OR port (IP address and TCP
* port) for <b>router</b> into *<b>ap_out</b>. */
void
router_get_alt_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{
tor_assert(ap_out != NULL);
tor_addr_copy(&ap_out->addr, &router->ipv6_addr);
ap_out->port = router->ipv6_orport;
}
/** Return 1 if we prefer the IPv6 address and OR TCP port of /** Return 1 if we prefer the IPv6 address and OR TCP port of
* <b>router</b>, else 0. * <b>router</b>, else 0.
* *
@ -2162,11 +2152,21 @@ void
router_get_pref_orport(const routerinfo_t *router, tor_addr_port_t *ap_out) router_get_pref_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{ {
if (router_ipv6_preferred(router)) if (router_ipv6_preferred(router))
router_get_alt_orport(router, ap_out); router_get_pref_ipv6_orport(router, ap_out);
else else
router_get_prim_orport(router, ap_out); router_get_prim_orport(router, ap_out);
} }
/** Copy the preferred IPv6 OR port (IP address and TCP port) for
* <b>router</b> into *<b>ap_out</b>. */
void
router_get_pref_ipv6_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{
tor_assert(ap_out != NULL);
tor_addr_copy(&ap_out->addr, &router->ipv6_addr);
ap_out->port = router->ipv6_orport;
}
/** Load the contents of <b>filename</b>, find the last line starting with /** Load the contents of <b>filename</b>, find the last line starting with
* <b>end_line</b>, ensure that its timestamp is not more than 25 hours in * <b>end_line</b>, ensure that its timestamp is not more than 25 hours in
* the past or more than 1 hour in the future with respect to <b>now</b>, * the past or more than 1 hour in the future with respect to <b>now</b>,

View File

@ -87,10 +87,10 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
crypto_pk_env_t *ident_key); crypto_pk_env_t *ident_key);
void router_get_prim_orport(const routerinfo_t *router, void router_get_prim_orport(const routerinfo_t *router,
tor_addr_port_t *addr_port_out); tor_addr_port_t *addr_port_out);
void router_get_alt_orport(const routerinfo_t *router,
tor_addr_port_t *addr_port_out);
void router_get_pref_orport(const routerinfo_t *router, void router_get_pref_orport(const routerinfo_t *router,
tor_addr_port_t *addr_port_out); tor_addr_port_t *addr_port_out);
void router_get_pref_ipv6_orport(const routerinfo_t *router,
tor_addr_port_t *addr_port_out);
int router_ipv6_preferred(const routerinfo_t *router); int router_ipv6_preferred(const routerinfo_t *router);
int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo, int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
crypto_pk_env_t *ident_key); crypto_pk_env_t *ident_key);