[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Rename get_first_advertised_{addr, port}_by_type_af().
commit fda9d7f5ed0758957b98d3b16a62bfd785f1917c
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Tue Jul 21 12:02:01 2020 -0400
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
---
src/app/config/config.c | 4 ++--
src/app/config/config.h | 8 ++++----
src/app/config/resolve_addr.h | 2 +-
src/feature/relay/router.c | 8 ++++----
src/test/test_config.c | 20 ++++++++++----------
5 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/src/app/config/config.c b/src/app/config/config.c
index 9e7d1179ba..269677cbdf 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -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;
diff --git a/src/app/config/config.h b/src/app/config/config.h
index f7d4e49f6f..fdffd66683 100644
--- a/src/app/config/config.h
+++ b/src/app/config/config.h
@@ -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);
diff --git a/src/app/config/resolve_addr.h b/src/app/config/resolve_addr.h
index 369f621fa9..c279d19f6e 100644
--- a/src/app/config/resolve_addr.h
+++ b/src/app/config/resolve_addr.h
@@ -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,
diff --git a/src/feature/relay/router.c b/src/feature/relay/router.c
index c2b01a641d..18d815097f 100644
--- a/src/feature/relay/router.c
+++ b/src/feature/relay/router.c
@@ -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);
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 376200827d..e61a62818d 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -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");
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits