aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorLinus Nordberg <linus@nordberg.se>2011-11-28 13:47:12 +0100
committerNick Mathewson <nickm@torproject.org>2011-11-30 11:55:46 -0500
commit3b51b326e4fb71b7ec75c5c8ef5a4869f5c4acc1 (patch)
tree832e2ef76f4e83d4f30ee61f44f493a1abc2d574 /src/or/router.c
parent2376a6ade4c5258da5512885eba28e3e0461f2a8 (diff)
downloadtor-3b51b326e4fb71b7ec75c5c8ef5a4869f5c4acc1.tar.gz
tor-3b51b326e4fb71b7ec75c5c8ef5a4869f5c4acc1.zip
Make router_get_{prim,alt,pref}_addr_port take tor_addr_port_t *.
Rename to *_orport for consistency with node_*.
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c54
1 files changed, 24 insertions, 30 deletions
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 <b>router</b> into
- *<b>addr_out</b> and *<b>port_out</b>. */
+/** Copy the primary (IPv4) OR port (IP address and TCP port) for
+ * <b>router</b> into *<b>ap_out</b>. */
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
- <b>router</b> into *<b>addr_out</b> and *<b>port_out</b>. */
+/** 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_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 <b>router</b>, 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
+ * <b>router</b>, 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 <b>router</b> into
- *<b>addr_out</b> and *<b>port_out</b> . */
+/** Copy the preferred OR port (IP address and TCP port) for
+ * <b>router</b> into *<b>addr_out</b>. */
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 <b>filename</b>, find the last line starting with