Rename get_first_advertised_{addr,port}_by_type_af().

Rationale: these don't actually give the first advertised
address/port, but instead give us the first such port that we are
_configured_ to advertise.  Putting them in a portconf_ namespace
therefore makes sense.

Similarly, there are no other functions that get the first
configured advertised addr/port, so the "by_type_af()" part is needless.

This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        get_first_advertised_addr_by_type_af portconf_get_first_advertised_addr \
        get_first_advertised_port_by_type_af portconf_get_first_advertised_port
This commit is contained in:
Nick Mathewson 2020-07-21 12:02:01 -04:00
parent e8497bfaa7
commit fda9d7f5ed
5 changed files with 21 additions and 21 deletions

View File

@ -6508,7 +6508,7 @@ get_first_listener_addrport_string(int listener_type)
* <b>address_family</b>. Returns 0 when no port is found, and when passed
* AF_UNSPEC. */
int
get_first_advertised_port_by_type_af(int listener_type, int address_family)
portconf_get_first_advertised_port(int listener_type, int address_family)
{
if (address_family == AF_UNSPEC)
return 0;
@ -6530,7 +6530,7 @@ get_first_advertised_port_by_type_af(int listener_type, int address_family)
* <b>address_family</b>. Returns NULL if there is no advertised address,
* and when passed AF_UNSPEC. */
const tor_addr_t *
get_first_advertised_addr_by_type_af(int listener_type, int address_family)
portconf_get_first_advertised_addr(int listener_type, int address_family)
{
if (address_family == AF_UNSPEC)
return NULL;

View File

@ -159,13 +159,13 @@ int get_num_cpus(const or_options_t *options);
MOCK_DECL(const smartlist_t *,get_configured_ports,(void));
int port_binds_ipv4(const port_cfg_t *port);
int port_binds_ipv6(const port_cfg_t *port);
int get_first_advertised_port_by_type_af(int listener_type,
int portconf_get_first_advertised_port(int listener_type,
int address_family);
#define get_primary_or_port() \
(get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER, AF_INET))
(portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER, AF_INET))
#define get_primary_dir_port() \
(get_first_advertised_port_by_type_af(CONN_TYPE_DIR_LISTENER, AF_INET))
const tor_addr_t *get_first_advertised_addr_by_type_af(int listener_type,
(portconf_get_first_advertised_port(CONN_TYPE_DIR_LISTENER, AF_INET))
const tor_addr_t *portconf_get_first_advertised_addr(int listener_type,
int address_family);
int port_exists_by_type_addr_port(int listener_type, const tor_addr_t *addr,
int port, int check_wildcard);

View File

@ -15,7 +15,7 @@
#include "app/config/or_options_st.h"
#define get_orport_addr(family) \
(get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER, family))
(portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER, family))
bool find_my_address(const or_options_t *options, int family,
int warn_severity, tor_addr_t *addr_out,

View File

@ -1474,7 +1474,7 @@ uint16_t
router_get_advertised_or_port_by_af(const or_options_t *options,
sa_family_t family)
{
int port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
int port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
family);
(void)options;
@ -1502,7 +1502,7 @@ router_get_advertised_ipv6_or_ap(const or_options_t *options,
tor_addr_make_null(&ipv6_ap_out->addr, AF_INET6);
ipv6_ap_out->port = 0;
const tor_addr_t *addr = get_first_advertised_addr_by_type_af(
const tor_addr_t *addr = portconf_get_first_advertised_addr(
CONN_TYPE_OR_LISTENER,
AF_INET6);
const uint16_t port = router_get_advertised_or_port_by_af(
@ -1824,11 +1824,11 @@ router_check_descriptor_address_port_consistency(const tor_addr_t *addr,
family = tor_addr_family(addr);
/* The first advertised Port may be the magic constant CFG_AUTO_PORT. */
port_cfg = get_first_advertised_port_by_type_af(listener_type, family);
port_cfg = portconf_get_first_advertised_port(listener_type, family);
if (port_cfg != 0 &&
!port_exists_by_type_addr_port(listener_type, addr, port_cfg, 1)) {
const tor_addr_t *port_addr =
get_first_advertised_addr_by_type_af(listener_type, family);
portconf_get_first_advertised_addr(listener_type, family);
/* If we're building a descriptor with no advertised address,
* something is terribly wrong. */
tor_assert(port_addr);

View File

@ -5181,17 +5181,17 @@ test_config_get_first_advertised(void *data)
const tor_addr_t *addr;
// no ports are configured? We get NULL.
port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
AF_INET);
tt_int_op(port, OP_EQ, 0);
addr = get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER,
addr = portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER,
AF_INET);
tt_ptr_op(addr, OP_EQ, NULL);
port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
AF_INET6);
tt_int_op(port, OP_EQ, 0);
addr = get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER,
addr = portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER,
AF_INET6);
tt_ptr_op(addr, OP_EQ, NULL);
@ -5205,27 +5205,27 @@ test_config_get_first_advertised(void *data)
tt_assert(r == 0);
// UNSPEC gets us nothing.
port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
AF_UNSPEC);
tt_int_op(port, OP_EQ, 0);
addr = get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER,
addr = portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER,
AF_UNSPEC);
tt_ptr_op(addr, OP_EQ, NULL);
// Try AF_INET.
port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
AF_INET);
tt_int_op(port, OP_EQ, 9911);
addr = get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER,
addr = portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER,
AF_INET);
tt_ptr_op(addr, OP_NE, NULL);
tt_str_op(fmt_addrport(addr,port), OP_EQ, "5.6.7.8:9911");
// Try AF_INET6
port = get_first_advertised_port_by_type_af(CONN_TYPE_OR_LISTENER,
port = portconf_get_first_advertised_port(CONN_TYPE_OR_LISTENER,
AF_INET6);
tt_int_op(port, OP_EQ, 8080);
addr = get_first_advertised_addr_by_type_af(CONN_TYPE_OR_LISTENER,
addr = portconf_get_first_advertised_addr(CONN_TYPE_OR_LISTENER,
AF_INET6);
tt_ptr_op(addr, OP_NE, NULL);
tt_str_op(fmt_addrport(addr,port), OP_EQ, "[1234::5678]:8080");