diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-07-05 14:51:07 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-07-05 14:51:07 -0400 |
commit | 0adcfbc7c8b579ebfe4c16c86700e8b466fc9a56 (patch) | |
tree | b6bba4d836d10e6285e357de9970bfdc3eb3b8a9 /src/common | |
parent | 24c0f83185a9c5dff080b250d9a8e15bbf8e1a88 (diff) | |
download | tor-0adcfbc7c8b579ebfe4c16c86700e8b466fc9a56.tar.gz tor-0adcfbc7c8b579ebfe4c16c86700e8b466fc9a56.zip |
Move address_set to src/or
This is temporary, until src/or is split.
Putting this in containers would be another logical alternative,
except that addresses depend on containers, and we don't like
cycles.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/address_set.c | 71 | ||||
-rw-r--r-- | src/common/address_set.h | 31 | ||||
-rw-r--r-- | src/common/include.am | 2 |
3 files changed, 0 insertions, 104 deletions
diff --git a/src/common/address_set.c b/src/common/address_set.c deleted file mode 100644 index 1bd1462387..0000000000 --- a/src/common/address_set.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (c) 2018-2018, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file address_set.c - * \brief Implementation for a set of addresses. - * - * This module was first written on a semi-emergency basis to improve the - * robustness of the anti-DoS module. As such, it's written in a pretty - * conservative way, and should be susceptible to improvement later on. - **/ - -#include "orconfig.h" -#include "common/address_set.h" -#include "lib/net/address.h" -#include "lib/container/bloomfilt.h" -#include "lib/crypt_ops/crypto_rand.h" -#include "siphash.h" - -/* Wrap our hash function to have the signature that the bloom filter - * needs. */ -static uint64_t -bloomfilt_addr_hash(const struct sipkey *key, - const void *item) -{ - return tor_addr_keyed_hash(key, item); -} - -/** - * Allocate and return an address_set, suitable for holding up to - * <b>max_address_guess</b> distinct values. - */ -address_set_t * -address_set_new(int max_addresses_guess) -{ - uint8_t k[BLOOMFILT_KEY_LEN]; - crypto_rand((void*)k, sizeof(k)); - return bloomfilt_new(max_addresses_guess, bloomfilt_addr_hash, k); -} - -/** - * Add <b>addr</b> to <b>set</b>. - * - * All future queries for <b>addr</b> in set will return true. Removing - * items is not possible. - */ -void -address_set_add(address_set_t *set, const struct tor_addr_t *addr) -{ - bloomfilt_add(set, addr); -} - -/** As address_set_add(), but take an ipv4 address in host order. */ -void -address_set_add_ipv4h(address_set_t *set, uint32_t addr) -{ - tor_addr_t a; - tor_addr_from_ipv4h(&a, addr); - address_set_add(set, &a); -} - -/** - * Return true if <b>addr</b> is a member of <b>set</b>. (And probably, - * return false if <b>addr</b> is not a member of set.) - */ -int -address_set_probably_contains(const address_set_t *set, - const struct tor_addr_t *addr) -{ - return bloomfilt_probably_contains(set, addr); -} diff --git a/src/common/address_set.h b/src/common/address_set.h deleted file mode 100644 index 2efa1cb03b..0000000000 --- a/src/common/address_set.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2018-2018, The Tor Project, Inc. */ -/* See LICENSE for licensing information */ - -/** - * \file address_set.h - * \brief Types to handle sets of addresses. - **/ - -#ifndef TOR_ADDRESS_SET_H -#define TOR_ADDRESS_SET_H - -#include "orconfig.h" -#include "lib/cc/torint.h" -#include "lib/container/bloomfilt.h" - -/** - * An address_set_t represents a set of tor_addr_t values. The implementation - * is probabilistic: false negatives cannot occur but false positives are - * possible. - */ -typedef struct bloomfilt_t address_set_t; -struct tor_addr_t; - -address_set_t *address_set_new(int max_addresses_guess); -#define address_set_free(set) bloomfilt_free(set) -void address_set_add(address_set_t *set, const struct tor_addr_t *addr); -void address_set_add_ipv4h(address_set_t *set, uint32_t addr); -int address_set_probably_contains(const address_set_t *set, - const struct tor_addr_t *addr); - -#endif diff --git a/src/common/include.am b/src/common/include.am index 565482bcf9..de4ecbaeea 100644 --- a/src/common/include.am +++ b/src/common/include.am @@ -18,7 +18,6 @@ libor_extra_source= endif LIBOR_A_SRC = \ - src/common/address_set.c \ src/common/token_bucket.c \ src/common/workqueue.c \ $(libor_extra_source) @@ -49,7 +48,6 @@ src_common_libor_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) src_common_libor_event_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) COMMONHEADERS = \ - src/common/address_set.h \ src/common/compat_libevent.h \ src/common/procmon.h \ src/common/timers.h \ |