diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 1283256b01..faf939ec12 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -3332,16 +3332,15 @@ extend_info_alloc(const char *nickname, const char *digest,
extend_info_t *
extend_info_from_router(const routerinfo_t *r, int for_direct_connect)
{
- tor_addr_t addr;
- uint16_t port;
+ tor_addr_port_t ap;
tor_assert(r);
if (for_direct_connect)
- router_get_pref_addr_port(r, &addr, &port);
+ router_get_pref_orport(r, &ap);
else
- router_get_prim_addr_port(r, &addr, &port);
+ router_get_prim_orport(r, &ap);
return extend_info_alloc(r->nickname, r->cache_info.identity_digest,
- r->onion_pkey, &addr, port);
+ r->onion_pkey, &ap.addr, ap.port);
}
/** Allocate and return a new extend_info that can be used to build a
@@ -4855,11 +4854,10 @@ get_configured_bridge_by_addr_port_digest(const tor_addr_t *addr,
static bridge_info_t *
get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
{
- tor_addr_t addr;
- uint16_t port;
+ tor_addr_port_t ap;
- router_get_pref_addr_port(ri, &addr, &port);
- return get_configured_bridge_by_addr_port_digest(&addr, port,
+ router_get_pref_orport(ri, &ap);
+ return get_configured_bridge_by_addr_port_digest(&ap.addr, ap.port,
ri->cache_info.identity_digest);
}
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 493c03f825..921ce1ad34 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -688,7 +688,7 @@ void
node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
{
if (node->ri) {
- router_get_prim_addr_port(node->ri, &ap_out->addr, &ap_out->port);
+ router_get_prim_orport(node->ri, ap_out);
}
else if (node->rs) {
tor_addr_from_ipv4h(&ap_out->addr, node->rs->addr);
@@ -725,7 +725,7 @@ void
node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
{
if (node->ri) {
- router_get_pref_addr_port(node->ri, &ap_out->addr, &ap_out->port);
+ router_get_pref_orport(node->ri, ap_out);
} else if (node->rs) {
/* No IPv6 in routerstatus_t yet. XXXprop186 ok for private
bridges but needs fixing */
@@ -737,7 +737,7 @@ node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
/** Copy the preferred IPv6 OR port (address and TCP port) for
* node into *ap_out. */
void
-node_get_pref_ipv6_orport(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) {
tor_addr_copy(&ap_out->addr, &node->ri->ipv6_addr);
diff --git a/src/or/router.c b/src/or/router.c
index d0217371ed..a0ae79a2a7 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -2122,37 +2122,33 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
}
-/** Copy the primary, IPv4, address and port for router into
- *addr_out and *port_out. */
+/** Copy the primary (IPv4) OR port (IP address and TCP port) for
+ * router into *ap_out. */
void
-router_get_prim_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
- uint16_t *port_out)
+router_get_prim_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{
- if (addr_out != NULL)
- tor_addr_from_ipv4h(addr_out, router->addr);
- if (port_out != NULL)
- *port_out = router->or_port;
+ tor_assert(ap_out != NULL);
+ tor_addr_from_ipv4h(&ap_out->addr, router->addr);
+ ap_out->port = router->or_port;
}
-/** Copy the alternative, presumably IPv6, address and port for
- router into *addr_out and *port_out. */
+/** Copy the alternative, presumably IPv6, OR port (IP address and TCP
+ * port) for router into *ap_out. */
void
-router_get_alt_addr_port(const routerinfo_t *router,
- tor_addr_t *addr_out,
- uint16_t *port_out)
+router_get_alt_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{
- if (addr_out != NULL)
- tor_addr_copy(addr_out, &router->ipv6_addr);
- if (port_out != NULL)
- *port_out = router->ipv6_orport;
+ 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 of router, else 0.
-
- We prefer the IPv6 address if the router has one and
- i) the routerinfo_t says so
- or
- ii) the router has no IPv4 address. */
+/** Return 1 if we prefer the IPv6 address and OR TCP port of
+ * router, else 0.
+ *
+ * We prefer the IPv6 address if the router has one and
+ * i) the routerinfo_t says so
+ * or
+ * ii) the router has no IPv4 address. */
int
router_ipv6_preferred(const routerinfo_t *router)
{
@@ -2160,17 +2156,15 @@ router_ipv6_preferred(const routerinfo_t *router)
&& (router->ipv6_preferred || router->addr == 0));
}
-/** Copy the preferred IP address and port for router into
- *addr_out and *port_out . */
+/** Copy the preferred OR port (IP address and TCP port) for
+ * router into *addr_out. */
void
-router_get_pref_addr_port(const routerinfo_t *router,
- tor_addr_t *addr_out,
- uint16_t *port_out)
+router_get_pref_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
{
if (router_ipv6_preferred(router))
- router_get_alt_addr_port(router, addr_out, port_out);
+ router_get_alt_orport(router, ap_out);
else
- router_get_prim_addr_port(router, addr_out, port_out);
+ router_get_prim_orport(router, ap_out);
}
/** Load the contents of filename, find the last line starting with
diff --git a/src/or/router.h b/src/or/router.h
index 4094b665dc..6095d025e4 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -85,12 +85,12 @@ int router_pick_published_address(const or_options_t *options, uint32_t *addr);
int router_rebuild_descriptor(int force);
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
crypto_pk_env_t *ident_key);
-void router_get_prim_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
- uint16_t *port_out);
-void router_get_alt_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
- uint16_t *port_out);
-void router_get_pref_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
- uint16_t *port_out);
+void router_get_prim_orport(const routerinfo_t *router,
+ 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,
+ tor_addr_port_t *addr_port_out);
int router_ipv6_preferred(const routerinfo_t *router);
int extrainfo_dump_to_string(char **s, extrainfo_t *extrainfo,
crypto_pk_env_t *ident_key);