mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Make router_get_{prim,alt,pref}_addr_port take tor_addr_port_t *.
Rename to *_orport for consistency with node_*.
This commit is contained in:
parent
2376a6ade4
commit
3b51b326e4
@ -3332,16 +3332,15 @@ extend_info_alloc(const char *nickname, const char *digest,
|
|||||||
extend_info_t *
|
extend_info_t *
|
||||||
extend_info_from_router(const routerinfo_t *r, int for_direct_connect)
|
extend_info_from_router(const routerinfo_t *r, int for_direct_connect)
|
||||||
{
|
{
|
||||||
tor_addr_t addr;
|
tor_addr_port_t ap;
|
||||||
uint16_t port;
|
|
||||||
tor_assert(r);
|
tor_assert(r);
|
||||||
|
|
||||||
if (for_direct_connect)
|
if (for_direct_connect)
|
||||||
router_get_pref_addr_port(r, &addr, &port);
|
router_get_pref_orport(r, &ap);
|
||||||
else
|
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,
|
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
|
/** 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 *
|
static bridge_info_t *
|
||||||
get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
|
get_configured_bridge_by_routerinfo(const routerinfo_t *ri)
|
||||||
{
|
{
|
||||||
tor_addr_t addr;
|
tor_addr_port_t ap;
|
||||||
uint16_t port;
|
|
||||||
|
|
||||||
router_get_pref_addr_port(ri, &addr, &port);
|
router_get_pref_orport(ri, &ap);
|
||||||
return get_configured_bridge_by_addr_port_digest(&addr, port,
|
return get_configured_bridge_by_addr_port_digest(&ap.addr, ap.port,
|
||||||
ri->cache_info.identity_digest);
|
ri->cache_info.identity_digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -688,7 +688,7 @@ void
|
|||||||
node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
|
node_get_prim_orport(const node_t *node, tor_addr_port_t *ap_out)
|
||||||
{
|
{
|
||||||
if (node->ri) {
|
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) {
|
else if (node->rs) {
|
||||||
tor_addr_from_ipv4h(&ap_out->addr, node->rs->addr);
|
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)
|
node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out)
|
||||||
{
|
{
|
||||||
if (node->ri) {
|
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) {
|
} 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 */
|
||||||
@ -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
|
/** Copy the preferred IPv6 OR port (address and TCP port) for
|
||||||
* <b>node</b> into *<b>ap_out</b>. */
|
* <b>node</b> into *<b>ap_out</b>. */
|
||||||
void
|
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) {
|
if (node->ri) {
|
||||||
tor_addr_copy(&ap_out->addr, &node->ri->ipv6_addr);
|
tor_addr_copy(&ap_out->addr, &node->ri->ipv6_addr);
|
||||||
|
@ -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
|
/** Copy the primary (IPv4) OR port (IP address and TCP port) for
|
||||||
*<b>addr_out</b> and *<b>port_out</b>. */
|
* <b>router</b> into *<b>ap_out</b>. */
|
||||||
void
|
void
|
||||||
router_get_prim_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
|
router_get_prim_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
|
||||||
uint16_t *port_out)
|
|
||||||
{
|
{
|
||||||
if (addr_out != NULL)
|
tor_assert(ap_out != NULL);
|
||||||
tor_addr_from_ipv4h(addr_out, router->addr);
|
tor_addr_from_ipv4h(&ap_out->addr, router->addr);
|
||||||
if (port_out != NULL)
|
ap_out->port = router->or_port;
|
||||||
*port_out = router->or_port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy the alternative, presumably IPv6, address and port for
|
/** Copy the alternative, presumably IPv6, OR port (IP address and TCP
|
||||||
<b>router</b> into *<b>addr_out</b> and *<b>port_out</b>. */
|
* port) for <b>router</b> into *<b>ap_out</b>. */
|
||||||
void
|
void
|
||||||
router_get_alt_addr_port(const routerinfo_t *router,
|
router_get_alt_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
|
||||||
tor_addr_t *addr_out,
|
|
||||||
uint16_t *port_out)
|
|
||||||
{
|
{
|
||||||
if (addr_out != NULL)
|
tor_assert(ap_out != NULL);
|
||||||
tor_addr_copy(addr_out, &router->ipv6_addr);
|
tor_addr_copy(&ap_out->addr, &router->ipv6_addr);
|
||||||
if (port_out != NULL)
|
ap_out->port = router->ipv6_orport;
|
||||||
*port_out = router->ipv6_orport;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return 1 if we prefer the IPv6 address of <b>router</b>, else 0.
|
/** 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
|
* We prefer the IPv6 address if the router has one and
|
||||||
or
|
* i) the routerinfo_t says so
|
||||||
ii) the router has no IPv4 address. */
|
* or
|
||||||
|
* ii) the router has no IPv4 address. */
|
||||||
int
|
int
|
||||||
router_ipv6_preferred(const routerinfo_t *router)
|
router_ipv6_preferred(const routerinfo_t *router)
|
||||||
{
|
{
|
||||||
@ -2160,17 +2156,15 @@ router_ipv6_preferred(const routerinfo_t *router)
|
|||||||
&& (router->ipv6_preferred || router->addr == 0));
|
&& (router->ipv6_preferred || router->addr == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy the preferred IP address and port for <b>router</b> into
|
/** Copy the preferred OR port (IP address and TCP port) for
|
||||||
*<b>addr_out</b> and *<b>port_out</b> . */
|
* <b>router</b> into *<b>addr_out</b>. */
|
||||||
void
|
void
|
||||||
router_get_pref_addr_port(const routerinfo_t *router,
|
router_get_pref_orport(const routerinfo_t *router, tor_addr_port_t *ap_out)
|
||||||
tor_addr_t *addr_out,
|
|
||||||
uint16_t *port_out)
|
|
||||||
{
|
{
|
||||||
if (router_ipv6_preferred(router))
|
if (router_ipv6_preferred(router))
|
||||||
router_get_alt_addr_port(router, addr_out, port_out);
|
router_get_alt_orport(router, ap_out);
|
||||||
else
|
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
|
/** Load the contents of <b>filename</b>, find the last line starting with
|
||||||
|
@ -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_rebuild_descriptor(int force);
|
||||||
int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
|
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_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
|
void router_get_prim_orport(const routerinfo_t *router,
|
||||||
uint16_t *port_out);
|
tor_addr_port_t *addr_port_out);
|
||||||
void router_get_alt_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
|
void router_get_alt_orport(const routerinfo_t *router,
|
||||||
uint16_t *port_out);
|
tor_addr_port_t *addr_port_out);
|
||||||
void router_get_pref_addr_port(const routerinfo_t *router, tor_addr_t *addr_out,
|
void router_get_pref_orport(const routerinfo_t *router,
|
||||||
uint16_t *port_out);
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user