aboutsummaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorteor (Tim Wilson-Brown) <teor2345@gmail.com>2015-12-22 10:42:09 +1100
committerteor (Tim Wilson-Brown) <teor2345@gmail.com>2016-01-29 07:13:56 +1100
commit4460feaf2850ef0fb027a2d01786a5bbaee056dc (patch)
tree8e3de118ffa8b198600cc4b8e56b37321369b69b /src/or/router.c
parentb9714e1366a19dff1f9abe18a22dc4367788cc3c (diff)
downloadtor-4460feaf2850ef0fb027a2d01786a5bbaee056dc.tar.gz
tor-4460feaf2850ef0fb027a2d01786a5bbaee056dc.zip
Fix *_get_all_orports to use ipv6_orport
node_get_all_orports and router_get_all_orports incorrectly used or_port with IPv6 addresses. They now use ipv6_orport. Also refactor and remove duplicated code.
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/or/router.c b/src/or/router.c
index c35f629f30..ba32d77fd1 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -3350,28 +3350,16 @@ router_free_all(void)
/** Return a smartlist of tor_addr_port_t's with all the OR ports of
<b>ri</b>. Note that freeing of the items in the list as well as
- the smartlist itself is the callers responsibility.
-
- XXX duplicating code from node_get_all_orports(). */
+ the smartlist itself is the callers responsibility. */
smartlist_t *
router_get_all_orports(const routerinfo_t *ri)
{
- smartlist_t *sl = smartlist_new();
tor_assert(ri);
-
- if (ri->addr != 0) {
- tor_addr_port_t *ap = tor_malloc(sizeof(tor_addr_port_t));
- tor_addr_from_ipv4h(&ap->addr, ri->addr);
- ap->port = ri->or_port;
- smartlist_add(sl, ap);
- }
- if (!tor_addr_is_null(&ri->ipv6_addr)) {
- tor_addr_port_t *ap = tor_malloc(sizeof(tor_addr_port_t));
- tor_addr_copy(&ap->addr, &ri->ipv6_addr);
- ap->port = ri->or_port;
- smartlist_add(sl, ap);
- }
-
- return sl;
+ node_t fake_node;
+ memset(&fake_node, 0, sizeof(fake_node));
+ /* we don't modify ri, fake_node is passed as a const node_t *
+ */
+ fake_node.ri = (routerinfo_t *)ri;
+ return node_get_all_orports(&fake_node);
}