mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Remove some code that is #ifdefed out, and that we no longer seem to use, if we ever did.
svn:r17827
This commit is contained in:
parent
ffe22fab9b
commit
52932d6f1a
@ -560,22 +560,6 @@ tor_addr_parse_mask_ports(const char *s, tor_addr_t *addr_out,
|
||||
|
||||
v4map = tor_addr_is_v4(addr_out);
|
||||
|
||||
/*
|
||||
#ifdef ALWAYS_V6_MAP
|
||||
if (v_family == AF_INET) {
|
||||
v_family = AF_INET6;
|
||||
IN_ADDR6(addr_out).s6_addr32[3] = IN6_ADDRESS(addr_out).s_addr;
|
||||
memset(&IN6_ADDRESS(addr_out), 0, 10);
|
||||
IN_ADDR6(addr_out).s6_addr16[5] = 0xffff;
|
||||
}
|
||||
#else
|
||||
if (v_family == AF_INET6 && v4map) {
|
||||
v_family = AF_INET;
|
||||
IN4_ADDRESS((addr_out).s_addr = IN6_ADDRESS(addr_out).s6_addr32[3];
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* Parse mask */
|
||||
if (maskbits_out) {
|
||||
int bits = 0;
|
||||
|
@ -87,10 +87,6 @@ const char compat_c_id[] =
|
||||
#include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_BSOCKETS
|
||||
#include <bsocket.h>
|
||||
#endif
|
||||
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
#include "container.h"
|
||||
@ -630,9 +626,7 @@ tor_close_socket(int s)
|
||||
* tor_close_socket to close sockets, and always using close() on
|
||||
* files.
|
||||
*/
|
||||
#ifdef USE_BSOCKETS
|
||||
r = bclose(s);
|
||||
#elif defined(MS_WINDOWS)
|
||||
#if defined(MS_WINDOWS)
|
||||
r = closesocket(s);
|
||||
#else
|
||||
r = close(s);
|
||||
@ -718,7 +712,7 @@ get_n_open_sockets(void)
|
||||
void
|
||||
set_socket_nonblocking(int socket)
|
||||
{
|
||||
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
|
||||
#if defined(MS_WINDOWS)
|
||||
unsigned long nonblocking = 1;
|
||||
ioctlsocket(socket, FIONBIO, (unsigned long*) &nonblocking);
|
||||
#else
|
||||
@ -761,8 +755,6 @@ tor_socketpair(int family, int type, int protocol, int fd[2])
|
||||
}
|
||||
}
|
||||
return r < 0 ? -errno : r;
|
||||
#elif defined(USE_BSOCKETS)
|
||||
return bsocketpair(family, type, protocol, fd);
|
||||
#else
|
||||
/* This socketpair does not work when localhost is down. So
|
||||
* it's really not the same thing at all. But it's close enough
|
||||
@ -2082,7 +2074,7 @@ tor_threads_init(void)
|
||||
* should call tor_socket_errno <em>at most once</em> on the failing
|
||||
* socket to get the error.
|
||||
*/
|
||||
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
|
||||
#if defined(MS_WINDOWS)
|
||||
int
|
||||
tor_socket_errno(int sock)
|
||||
{
|
||||
@ -2098,7 +2090,7 @@ tor_socket_errno(int sock)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
|
||||
#if defined(MS_WINDOWS)
|
||||
#define E(code, s) { code, (s " [" #code " ]") }
|
||||
struct { int code; const char *msg; } windows_socket_errors[] = {
|
||||
E(WSAEINTR, "Interrupted function call"),
|
||||
|
@ -324,13 +324,8 @@ int tor_open_socket(int domain, int type, int protocol);
|
||||
int tor_accept_socket(int sockfd, struct sockaddr *addr, socklen_t *len);
|
||||
int get_n_open_sockets(void);
|
||||
|
||||
#ifdef USE_BSOCKETS
|
||||
#define tor_socket_send(s, buf, len, flags) bsend(s, buf, len, flags)
|
||||
#define tor_socket_recv(s, buf, len, flags) brecv(s, buf, len, flags)
|
||||
#else
|
||||
#define tor_socket_send(s, buf, len, flags) send(s, buf, len, flags)
|
||||
#define tor_socket_recv(s, buf, len, flags) recv(s, buf, len, flags)
|
||||
#endif
|
||||
|
||||
/* Define struct in6_addr on platforms that do not have it. Generally,
|
||||
* these platforms are ones without IPv6 support, but we want to have
|
||||
@ -403,7 +398,7 @@ int network_init(void);
|
||||
* errnos against expected values, and use tor_socket_errno to find
|
||||
* the actual errno after a socket operation fails.
|
||||
*/
|
||||
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
|
||||
#if defined(MS_WINDOWS)
|
||||
/** Return true if e is EAGAIN or the local equivalent. */
|
||||
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || (e) == WSAEWOULDBLOCK)
|
||||
/** Return true if e is EINPROGRESS or the local equivalent. */
|
||||
|
@ -95,12 +95,9 @@ should_log_function_name(log_domain_mask_t domain, int severity)
|
||||
}
|
||||
}
|
||||
|
||||
#define USE_LOG_MUTEX
|
||||
|
||||
#ifdef USE_LOG_MUTEX
|
||||
/** A mutex to guard changes to logfiles and logging. */
|
||||
static tor_mutex_t *log_mutex = NULL;
|
||||
#endif
|
||||
|
||||
/** Linked list of logfile_t. */
|
||||
static logfile_t *logfiles = NULL;
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
@ -109,15 +106,10 @@ static logfile_t *logfiles = NULL;
|
||||
static int syslog_count = 0;
|
||||
#endif
|
||||
|
||||
#ifdef USE_LOG_MUTEX
|
||||
#define LOCK_LOGS() STMT_BEGIN \
|
||||
tor_mutex_acquire(log_mutex); \
|
||||
STMT_END
|
||||
#define UNLOCK_LOGS() STMT_BEGIN tor_mutex_release(log_mutex); STMT_END
|
||||
#else
|
||||
#define LOCK_LOGS() STMT_NIL
|
||||
#define UNLOCK_LOGS() STMT_NIL
|
||||
#endif
|
||||
|
||||
/** What's the lowest log level anybody cares about? Checking this lets us
|
||||
* bail out early from log_debug if we aren't debugging. */
|
||||
|
@ -12,8 +12,6 @@
|
||||
#define MEMPOOL_PRIVATE
|
||||
#include "mempool.h"
|
||||
|
||||
#define LAZY_CHUNK_SORT
|
||||
|
||||
/* OVERVIEW:
|
||||
*
|
||||
* This is an implementation of memory pools for Tor cells. It may be
|
||||
@ -407,7 +405,6 @@ mp_pool_new(size_t item_size, size_t chunk_capacity)
|
||||
return pool;
|
||||
}
|
||||
|
||||
#ifdef LAZY_CHUNK_SORT
|
||||
/** Helper function for qsort: used to sort pointers to mp_chunk_t into
|
||||
* descending order of fullness. */
|
||||
static int
|
||||
@ -449,17 +446,8 @@ mp_pool_sort_used_chunks(mp_pool_t *pool)
|
||||
}
|
||||
chunks[n-1]->next = NULL;
|
||||
FREE(chunks);
|
||||
#if 0
|
||||
inverted = 0;
|
||||
for (chunk = pool->used_chunks; chunk; chunk = chunk->next) {
|
||||
if (chunk->next) {
|
||||
ASSERT(chunk->next->n_allocated <= chunk->n_allocated);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
mp_pool_assert_ok(pool);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** If there are more than <b>n</b> empty chunks in <b>pool</b>, free the
|
||||
* excess ones that have been empty for the longest. If
|
||||
@ -471,9 +459,7 @@ mp_pool_clean(mp_pool_t *pool, int n_to_keep, int keep_recently_used)
|
||||
{
|
||||
mp_chunk_t *chunk, **first_to_free;
|
||||
|
||||
#ifdef LAZY_CHUNK_SORT
|
||||
mp_pool_sort_used_chunks(pool);
|
||||
#endif
|
||||
ASSERT(n_to_keep >= 0);
|
||||
|
||||
if (keep_recently_used) {
|
||||
|
@ -199,7 +199,7 @@ tls_log_errors(tor_tls_t *tls, int severity, const char *doing)
|
||||
static int
|
||||
tor_errno_to_tls_error(int e)
|
||||
{
|
||||
#if defined(MS_WINDOWS) && !defined(USE_BSOCKETS)
|
||||
#if defined(MS_WINDOWS)
|
||||
switch (e) {
|
||||
case WSAECONNRESET: // most common
|
||||
return TOR_TLS_ERROR_CONNRESET;
|
||||
@ -839,11 +839,7 @@ tor_tls_new(int sock, int isServer)
|
||||
if (!isServer)
|
||||
rectify_client_ciphers(&result->ssl->cipher_list);
|
||||
result->socket = sock;
|
||||
#ifdef USE_BSOCKETS
|
||||
bio = BIO_new_bsocket(sock, BIO_NOCLOSE);
|
||||
#else
|
||||
bio = BIO_new_socket(sock, BIO_NOCLOSE);
|
||||
#endif
|
||||
if (! bio) {
|
||||
tls_log_errors(NULL, LOG_WARN, "opening BIO");
|
||||
SSL_free(result->ssl);
|
||||
|
@ -23,7 +23,6 @@ const char buffers_c_id[] =
|
||||
#endif
|
||||
|
||||
//#define PARANOIA
|
||||
//#define NOINLINE
|
||||
|
||||
#ifdef PARANOIA
|
||||
/** Helper: If PARANOIA is defined, assert that the buffer in local variable
|
||||
@ -33,11 +32,6 @@ const char buffers_c_id[] =
|
||||
#define check() STMT_NIL
|
||||
#endif
|
||||
|
||||
#ifdef NOINLINE
|
||||
#undef INLINE
|
||||
#define INLINE
|
||||
#endif
|
||||
|
||||
/* Implementation notes:
|
||||
*
|
||||
* After flirting with memmove, and dallying with ring-buffers, we're finally
|
||||
|
@ -187,21 +187,6 @@ onion_skin_create(crypto_pk_env_t *dest_router_key,
|
||||
if (crypto_dh_get_public(dh, challenge, dhbytes))
|
||||
goto err;
|
||||
|
||||
#ifdef DEBUG_ONION_SKINS
|
||||
#define PA(a,n) \
|
||||
{ int _i; for (_i = 0; _i<n; ++_i) printf("%02x ",((int)(a)[_i])&0xFF); }
|
||||
|
||||
printf("Client: client g^x:");
|
||||
PA(challenge+16,3);
|
||||
printf("...");
|
||||
PA(challenge+141,3);
|
||||
puts("");
|
||||
|
||||
printf("Client: client symkey:");
|
||||
PA(challenge+0,16);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
note_crypto_pk_op(ENC_ONIONSKIN);
|
||||
|
||||
/* set meeting point, meeting cookie, etc here. Leave zero for now. */
|
||||
@ -269,14 +254,6 @@ onion_skin_server_handshake(const char *onion_skin, /*ONIONSKIN_CHALLENGE_LEN*/
|
||||
goto err;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ONION_SKINS
|
||||
printf("Server: server g^y:");
|
||||
PA(handshake_reply_out+0,3);
|
||||
printf("...");
|
||||
PA(handshake_reply_out+125,3);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
key_material_len = DIGEST_LEN+key_out_len;
|
||||
key_material = tor_malloc(key_material_len);
|
||||
len = crypto_dh_compute_secret(dh, challenge, DH_KEY_LEN,
|
||||
@ -292,15 +269,6 @@ onion_skin_server_handshake(const char *onion_skin, /*ONIONSKIN_CHALLENGE_LEN*/
|
||||
/* use the rest of the key material for our shared keys, digests, etc */
|
||||
memcpy(key_out, key_material+DIGEST_LEN, key_out_len);
|
||||
|
||||
#ifdef DEBUG_ONION_SKINS
|
||||
printf("Server: key material:");
|
||||
PA(key_material, DH_KEY_LEN);
|
||||
puts("");
|
||||
printf("Server: keys out:");
|
||||
PA(key_out, key_out_len);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
memset(challenge, 0, sizeof(challenge));
|
||||
memset(key_material, 0, key_material_len);
|
||||
tor_free(key_material);
|
||||
@ -337,14 +305,6 @@ onion_skin_client_handshake(crypto_dh_env_t *handshake_state,
|
||||
size_t key_material_len;
|
||||
tor_assert(crypto_dh_get_bytes(handshake_state) == DH_KEY_LEN);
|
||||
|
||||
#ifdef DEBUG_ONION_SKINS
|
||||
printf("Client: server g^y:");
|
||||
PA(handshake_reply+0,3);
|
||||
printf("...");
|
||||
PA(handshake_reply+125,3);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
key_material_len = DIGEST_LEN + key_out_len;
|
||||
key_material = tor_malloc(key_material_len);
|
||||
len = crypto_dh_compute_secret(handshake_state, handshake_reply, DH_KEY_LEN,
|
||||
@ -362,12 +322,6 @@ onion_skin_client_handshake(crypto_dh_env_t *handshake_state,
|
||||
/* use the rest of the key material for our shared keys, digests, etc */
|
||||
memcpy(key_out, key_material+DIGEST_LEN, key_out_len);
|
||||
|
||||
#ifdef DEBUG_ONION_SKINS
|
||||
printf("Client: keys out:");
|
||||
PA(key_out, key_out_len);
|
||||
puts("");
|
||||
#endif
|
||||
|
||||
memset(key_material, 0, key_material_len);
|
||||
tor_free(key_material);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user