mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Remove some totally unused functions
This commit is contained in:
parent
365e302f61
commit
5bfa373eee
@ -1565,32 +1565,6 @@ addr_mask_get_bits(uint32_t mask)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Compare two addresses <b>a1</b> and <b>a2</b> for equality under a
|
||||
* netmask of <b>mbits</b> bits. Return -1, 0, or 1.
|
||||
*
|
||||
* XXXX_IP6 Temporary function to allow masks as bitcounts everywhere. This
|
||||
* will be replaced with an IPv6-aware version as soon as 32-bit addresses are
|
||||
* no longer passed around.
|
||||
*/
|
||||
int
|
||||
addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits)
|
||||
{
|
||||
if (bits > 32)
|
||||
bits = 32;
|
||||
else if (bits == 0)
|
||||
return 0;
|
||||
|
||||
a1 >>= (32-bits);
|
||||
a2 >>= (32-bits);
|
||||
|
||||
if (a1 < a2)
|
||||
return -1;
|
||||
else if (a1 > a2)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Parse a string <b>s</b> in the format of (*|port(-maxport)?)?, setting the
|
||||
* various *out pointers as appropriate. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
@ -1643,93 +1617,6 @@ parse_port_range(const char *port, uint16_t *port_min_out,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Parse a string <b>s</b> in the format of
|
||||
* (IP(/mask|/mask-bits)?|*)(:(*|port(-maxport))?)?, setting the various
|
||||
* *out pointers as appropriate. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
parse_addr_and_port_range(const char *s, uint32_t *addr_out,
|
||||
maskbits_t *maskbits_out, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out)
|
||||
{
|
||||
char *address;
|
||||
char *mask, *port, *endptr;
|
||||
struct in_addr in;
|
||||
int bits;
|
||||
|
||||
tor_assert(s);
|
||||
tor_assert(addr_out);
|
||||
tor_assert(maskbits_out);
|
||||
tor_assert(port_min_out);
|
||||
tor_assert(port_max_out);
|
||||
|
||||
address = tor_strdup(s);
|
||||
/* Break 'address' into separate strings.
|
||||
*/
|
||||
mask = strchr(address,'/');
|
||||
port = strchr(mask?mask:address,':');
|
||||
if (mask)
|
||||
*mask++ = '\0';
|
||||
if (port)
|
||||
*port++ = '\0';
|
||||
/* Now "address" is the IP|'*' part...
|
||||
* "mask" is the Mask|Maskbits part...
|
||||
* and "port" is the *|port|min-max part.
|
||||
*/
|
||||
|
||||
if (strcmp(address,"*")==0) {
|
||||
*addr_out = 0;
|
||||
} else if (tor_inet_aton(address, &in) != 0) {
|
||||
*addr_out = ntohl(in.s_addr);
|
||||
} else {
|
||||
log_warn(LD_GENERAL, "Malformed IP %s in address pattern; rejecting.",
|
||||
escaped(address));
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!mask) {
|
||||
if (strcmp(address,"*")==0)
|
||||
*maskbits_out = 0;
|
||||
else
|
||||
*maskbits_out = 32;
|
||||
} else {
|
||||
endptr = NULL;
|
||||
bits = (int) strtol(mask, &endptr, 10);
|
||||
if (!*endptr) {
|
||||
/* strtol handled the whole mask. */
|
||||
if (bits < 0 || bits > 32) {
|
||||
log_warn(LD_GENERAL,
|
||||
"Bad number of mask bits on address range; rejecting.");
|
||||
goto err;
|
||||
}
|
||||
*maskbits_out = bits;
|
||||
} else if (tor_inet_aton(mask, &in) != 0) {
|
||||
bits = addr_mask_get_bits(ntohl(in.s_addr));
|
||||
if (bits < 0) {
|
||||
log_warn(LD_GENERAL,
|
||||
"Mask %s on address range isn't a prefix; dropping",
|
||||
escaped(mask));
|
||||
goto err;
|
||||
}
|
||||
*maskbits_out = bits;
|
||||
} else {
|
||||
log_warn(LD_GENERAL,
|
||||
"Malformed mask %s on address range; rejecting.",
|
||||
escaped(mask));
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
|
||||
if (parse_port_range(port, port_min_out, port_max_out)<0)
|
||||
goto err;
|
||||
|
||||
tor_free(address);
|
||||
return 0;
|
||||
err:
|
||||
tor_free(address);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Given an IPv4 in_addr struct *<b>in</b> (in network order, as usual),
|
||||
* write it as a string into the <b>buf_len</b>-byte buffer in
|
||||
* <b>buf</b>.
|
||||
|
@ -219,11 +219,7 @@ int addr_port_lookup(int severity, const char *addrport, char **address,
|
||||
uint32_t *addr, uint16_t *port_out);
|
||||
int parse_port_range(const char *port, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out);
|
||||
int parse_addr_and_port_range(const char *s, uint32_t *addr_out,
|
||||
maskbits_t *maskbits_out, uint16_t *port_min_out,
|
||||
uint16_t *port_max_out);
|
||||
int addr_mask_get_bits(uint32_t mask);
|
||||
int addr_mask_cmp_bits(uint32_t a1, uint32_t a2, maskbits_t bits);
|
||||
/** Length of a buffer to allocate to hold the results of tor_inet_ntoa.*/
|
||||
#define INET_NTOA_BUF_LEN 16
|
||||
int tor_inet_ntoa(const struct in_addr *in, char *buf, size_t buf_len);
|
||||
|
@ -675,11 +675,6 @@ median_int32(int32_t *array, int n_elements)
|
||||
{
|
||||
return find_nth_int32(array, n_elements, (n_elements-1)/2);
|
||||
}
|
||||
static INLINE long
|
||||
median_long(long *array, int n_elements)
|
||||
{
|
||||
return find_nth_long(array, n_elements, (n_elements-1)/2);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1253,42 +1253,6 @@ wrap_string(smartlist_t *out, const char *string, size_t width,
|
||||
* Time
|
||||
* ===== */
|
||||
|
||||
/**
|
||||
* Converts struct timeval to a double value.
|
||||
* Preserves microsecond precision, but just barely.
|
||||
* Error is approx +/- 0.1 usec when dealing with epoch values.
|
||||
*/
|
||||
double
|
||||
tv_to_double(const struct timeval *tv)
|
||||
{
|
||||
double conv = tv->tv_sec;
|
||||
conv += tv->tv_usec/1000000.0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts timeval to milliseconds.
|
||||
*/
|
||||
int64_t
|
||||
tv_to_msec(const struct timeval *tv)
|
||||
{
|
||||
int64_t conv = ((int64_t)tv->tv_sec)*1000L;
|
||||
/* Round ghetto-style */
|
||||
conv += ((int64_t)tv->tv_usec+500)/1000L;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts timeval to microseconds.
|
||||
*/
|
||||
int64_t
|
||||
tv_to_usec(const struct timeval *tv)
|
||||
{
|
||||
int64_t conv = ((int64_t)tv->tv_sec)*1000000L;
|
||||
conv += tv->tv_usec;
|
||||
return conv;
|
||||
}
|
||||
|
||||
/** Return the number of microseconds elapsed between *start and *end.
|
||||
*/
|
||||
long
|
||||
|
@ -239,9 +239,6 @@ void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen);
|
||||
|
||||
/* Time helpers */
|
||||
double tv_to_double(const struct timeval *tv);
|
||||
int64_t tv_to_msec(const struct timeval *tv);
|
||||
int64_t tv_to_usec(const struct timeval *tv);
|
||||
long tv_udiff(const struct timeval *start, const struct timeval *end);
|
||||
long tv_mdiff(const struct timeval *start, const struct timeval *end);
|
||||
int tor_timegm(const struct tm *tm, time_t *time_out);
|
||||
|
@ -1432,18 +1432,6 @@ consensus_is_waiting_for_certs(void)
|
||||
? 1 : 0;
|
||||
}
|
||||
|
||||
/** Return the network status with a given identity digest. */
|
||||
networkstatus_v2_t *
|
||||
networkstatus_v2_get_by_digest(const char *digest)
|
||||
{
|
||||
SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
|
||||
{
|
||||
if (tor_memeq(ns->identity_digest, digest, DIGEST_LEN))
|
||||
return ns;
|
||||
});
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/** Return the most recent consensus that we have downloaded, or NULL if we
|
||||
* don't have one. */
|
||||
networkstatus_t *
|
||||
|
@ -75,7 +75,6 @@ void update_certificate_downloads(time_t now);
|
||||
int consensus_is_waiting_for_certs(void);
|
||||
int client_would_use_router(const routerstatus_t *rs, time_t now,
|
||||
const or_options_t *options);
|
||||
networkstatus_v2_t *networkstatus_v2_get_by_digest(const char *digest);
|
||||
networkstatus_t *networkstatus_get_latest_consensus(void);
|
||||
networkstatus_t *networkstatus_get_latest_consensus_by_flavor(
|
||||
consensus_flavor_t f);
|
||||
|
@ -1452,13 +1452,6 @@ rend_process_relay_cell(circuit_t *circ, const crypt_path_t *layer_hint,
|
||||
command);
|
||||
}
|
||||
|
||||
/** Return the number of entries in our rendezvous descriptor cache. */
|
||||
int
|
||||
rend_cache_size(void)
|
||||
{
|
||||
return strmap_size(rend_cache);
|
||||
}
|
||||
|
||||
/** Allocate and return a new rend_data_t with the same
|
||||
* contents as <b>query</b>. */
|
||||
rend_data_t *
|
||||
|
@ -49,7 +49,6 @@ int rend_cache_store(const char *desc, size_t desc_len, int published,
|
||||
int rend_cache_store_v2_desc_as_client(const char *desc,
|
||||
const rend_data_t *rend_query);
|
||||
int rend_cache_store_v2_desc_as_dir(const char *desc);
|
||||
int rend_cache_size(void);
|
||||
int rend_encode_v2_descriptors(smartlist_t *descs_out,
|
||||
rend_service_descriptor_t *desc, time_t now,
|
||||
uint8_t period, rend_auth_type_t auth_type,
|
||||
|
@ -2966,23 +2966,6 @@ router_get_verbose_nickname(char *buf, const routerinfo_t *router)
|
||||
strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
|
||||
}
|
||||
|
||||
/** Set <b>buf</b> (which must have MAX_VERBOSE_NICKNAME_LEN+1 bytes) to the
|
||||
* verbose representation of the identity of <b>router</b>. The format is:
|
||||
* A dollar sign.
|
||||
* The upper-case hexadecimal encoding of the SHA1 hash of router's identity.
|
||||
* A "=" if the router is named; a "~" if it is not.
|
||||
* The router's nickname.
|
||||
**/
|
||||
void
|
||||
routerstatus_get_verbose_nickname(char *buf, const routerstatus_t *router)
|
||||
{
|
||||
buf[0] = '$';
|
||||
base16_encode(buf+1, HEX_DIGEST_LEN+1, router->identity_digest,
|
||||
DIGEST_LEN);
|
||||
buf[1+HEX_DIGEST_LEN] = router->is_named ? '=' : '~';
|
||||
strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
|
||||
}
|
||||
|
||||
/** Forget that we have issued any router-related warnings, so that we'll
|
||||
* warn again if we see the same errors. */
|
||||
void
|
||||
|
@ -132,8 +132,6 @@ const char *routerstatus_describe(const routerstatus_t *ri);
|
||||
const char *extend_info_describe(const extend_info_t *ei);
|
||||
|
||||
void router_get_verbose_nickname(char *buf, const routerinfo_t *router);
|
||||
void routerstatus_get_verbose_nickname(char *buf,
|
||||
const routerstatus_t *router);
|
||||
void router_reset_warnings(void);
|
||||
void router_reset_reachability(void);
|
||||
void router_free_all(void);
|
||||
|
@ -54,8 +54,6 @@ static const routerstatus_t *router_pick_dirserver_generic(
|
||||
smartlist_t *sourcelist,
|
||||
dirinfo_type_t type, int flags);
|
||||
static void mark_all_dirservers_up(smartlist_t *server_list);
|
||||
static int router_nickname_matches(const routerinfo_t *router,
|
||||
const char *nickname);
|
||||
static void dir_server_free(dir_server_t *ds);
|
||||
static int signed_desc_digest_is_recognized(signed_descriptor_t *desc);
|
||||
static const char *signed_descriptor_get_body_impl(
|
||||
@ -1461,30 +1459,6 @@ routerlist_add_node_and_family(smartlist_t *sl, const routerinfo_t *router)
|
||||
nodelist_add_node_and_family(sl, node);
|
||||
}
|
||||
|
||||
/** Return 1 iff any member of the (possibly NULL) comma-separated list
|
||||
* <b>list</b> is an acceptable nickname or hexdigest for <b>router</b>. Else
|
||||
* return 0.
|
||||
*/
|
||||
int
|
||||
router_nickname_is_in_list(const routerinfo_t *router, const char *list)
|
||||
{
|
||||
smartlist_t *nickname_list;
|
||||
int v = 0;
|
||||
|
||||
if (!list)
|
||||
return 0; /* definitely not */
|
||||
tor_assert(router);
|
||||
|
||||
nickname_list = smartlist_new();
|
||||
smartlist_split_string(nickname_list, list, ",",
|
||||
SPLIT_SKIP_SPACE|SPLIT_STRIP_SPACE|SPLIT_IGNORE_BLANK, 0);
|
||||
SMARTLIST_FOREACH(nickname_list, const char *, cp,
|
||||
if (router_nickname_matches(router, cp)) {v=1;break;});
|
||||
SMARTLIST_FOREACH(nickname_list, char *, cp, tor_free(cp));
|
||||
smartlist_free(nickname_list);
|
||||
return v;
|
||||
}
|
||||
|
||||
/** Add every suitable node from our nodelist to <b>sl</b>, so that
|
||||
* we can pick a node for a circuit.
|
||||
*/
|
||||
@ -2311,18 +2285,6 @@ router_hex_digest_matches(const routerinfo_t *router, const char *hexdigest)
|
||||
router_is_named(router));
|
||||
}
|
||||
|
||||
/** Return true if <b>router</b>'s nickname matches <b>nickname</b>
|
||||
* (case-insensitive), or if <b>router's</b> identity key digest
|
||||
* matches a hexadecimal value stored in <b>nickname</b>. Return
|
||||
* false otherwise. */
|
||||
static int
|
||||
router_nickname_matches(const routerinfo_t *router, const char *nickname)
|
||||
{
|
||||
if (nickname[0]!='$' && !strcasecmp(router->nickname, nickname))
|
||||
return 1;
|
||||
return router_hex_digest_matches(router, nickname);
|
||||
}
|
||||
|
||||
/** Return true iff <b>digest</b> is the digest of the identity key of a
|
||||
* trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
|
||||
* is zero, any authority is okay. */
|
||||
@ -4051,17 +4013,6 @@ clear_dir_servers(void)
|
||||
router_dir_info_changed();
|
||||
}
|
||||
|
||||
/** Return 1 if any trusted dir server supports v1 directories,
|
||||
* else return 0. */
|
||||
int
|
||||
any_trusted_dir_is_v1_authority(void)
|
||||
{
|
||||
if (trusted_dir_servers)
|
||||
return get_n_authorities(V1_DIRINFO) > 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** For every current directory connection whose purpose is <b>purpose</b>,
|
||||
* and where the resource being downloaded begins with <b>prefix</b>, split
|
||||
* rest of the resource into base16 fingerprints (or base64 fingerprints if
|
||||
|
@ -42,7 +42,6 @@ int router_get_my_share_of_directory_requests(double *v2_share_out,
|
||||
double *v3_share_out);
|
||||
void router_reset_status_download_failures(void);
|
||||
int routers_have_same_or_addrs(const routerinfo_t *r1, const routerinfo_t *r2);
|
||||
int router_nickname_is_in_list(const routerinfo_t *router, const char *list);
|
||||
const routerinfo_t *routerlist_find_my_routerinfo(void);
|
||||
uint32_t router_get_advertised_bandwidth(const routerinfo_t *router);
|
||||
uint32_t router_get_advertised_bandwidth_capped(const routerinfo_t *router);
|
||||
@ -146,7 +145,6 @@ void dir_server_add(dir_server_t *ent);
|
||||
|
||||
void authority_cert_free(authority_cert_t *cert);
|
||||
void clear_dir_servers(void);
|
||||
int any_trusted_dir_is_v1_authority(void);
|
||||
void update_consensus_router_descriptor_downloads(time_t now, int is_vote,
|
||||
networkstatus_t *consensus);
|
||||
void update_router_descriptor_downloads(time_t now);
|
||||
|
Loading…
Reference in New Issue
Block a user