diff options
author | dana koch <dsk@google.com> | 2014-08-27 20:41:25 +1000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-08-29 12:55:28 -0400 |
commit | c887e20e6a5a2c17c65f308e70e578e773b2ab23 (patch) | |
tree | ceef57b8043c107c11ed17f9658c737d2c2caf23 /src/or/routerset.h | |
parent | cc3b04a8c1edbeb1a488e319e3c0d28acd227417 (diff) | |
download | tor-c887e20e6a5a2c17c65f308e70e578e773b2ab23.tar.gz tor-c887e20e6a5a2c17c65f308e70e578e773b2ab23.zip |
Introduce full coverage tests for module routerset.c.
This is using the paradigm introduced for test_status.c.
Diffstat (limited to 'src/or/routerset.h')
-rw-r--r-- | src/or/routerset.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/or/routerset.h b/src/or/routerset.h index 8261c7fb09..eafd331b00 100644 --- a/src/or/routerset.h +++ b/src/or/routerset.h @@ -39,5 +39,45 @@ char *routerset_to_string(const routerset_t *routerset); int routerset_equal(const routerset_t *old, const routerset_t *new); void routerset_free(routerset_t *routerset); +#ifdef ROUTERSET_PRIVATE +STATIC char * routerset_get_countryname(const char *c); +STATIC int routerset_contains(const routerset_t *set, const tor_addr_t *addr, + uint16_t orport, + const char *nickname, const char *id_digest, + country_t country); + +/** A routerset specifies constraints on a set of possible routerinfos, based + * on their names, identities, or addresses. It is optimized for determining + * whether a router is a member or not, in O(1+P) time, where P is the number + * of address policy constraints. */ +struct routerset_t { + /** A list of strings for the elements of the policy. Each string is either + * a nickname, a hexadecimal identity fingerprint, or an address policy. A + * router belongs to the set if its nickname OR its identity OR its address + * matches an entry here. */ + smartlist_t *list; + /** A map from lowercase nicknames of routers in the set to (void*)1 */ + strmap_t *names; + /** A map from identity digests routers in the set to (void*)1 */ + digestmap_t *digests; + /** An address policy for routers in the set. For implementation reasons, + * a router belongs to the set if it is _rejected_ by this policy. */ + smartlist_t *policies; + + /** A human-readable description of what this routerset is for. Used in + * log messages. */ + char *description; + + /** A list of the country codes in this set. */ + smartlist_t *country_names; + /** Total number of countries we knew about when we built <b>countries</b>.*/ + int n_countries; + /** Bit array mapping the return value of geoip_get_country() to 1 iff the + * country is a member of this routerset. Note that we MUST call + * routerset_refresh_countries() whenever the geoip country list is + * reloaded. */ + bitarray_t *countries; +}; +#endif #endif |