Tor  0.4.7.0-alpha-dev
Macros | Typedefs | Functions | Variables
routerset.h File Reference

Header file for routerset.c. More...

Go to the source code of this file.

Macros

#define routerset_free(rs)   FREE_AND_NULL(routerset_t, routerset_free_, (rs))
 

Typedefs

typedef routerset_t * config_decl_ROUTERSET
 

Functions

routerset_t * routerset_new (void)
 
void routerset_refresh_countries (routerset_t *rs)
 
int routerset_parse (routerset_t *target, const char *s, const char *description)
 
void routerset_union (routerset_t *target, const routerset_t *source)
 
int routerset_is_list (const routerset_t *set)
 
int routerset_needs_geoip (const routerset_t *set)
 
int routerset_is_empty (const routerset_t *set)
 
int routerset_contains_router (const routerset_t *set, const routerinfo_t *ri, country_t country)
 
int routerset_contains_routerstatus (const routerset_t *set, const routerstatus_t *rs, country_t country)
 
int routerset_contains_extendinfo (const routerset_t *set, const extend_info_t *ei)
 
int routerset_contains_bridge (const routerset_t *set, const struct bridge_info_t *bridge)
 
int routerset_contains_node (const routerset_t *set, const node_t *node)
 
void routerset_get_all_nodes (smartlist_t *out, const routerset_t *routerset, const routerset_t *excludeset, int running_only)
 
int routerset_add_unknown_ccs (routerset_t **setp, int only_if_some_cc_set)
 
void routerset_subtract_nodes (smartlist_t *out, const routerset_t *routerset)
 
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)
 
int routerset_len (const routerset_t *set)
 

Variables

const struct var_type_def_t ROUTERSET_type_defn
 

Detailed Description

Header file for routerset.c.

Definition in file routerset.h.

Function Documentation

◆ routerset_add_unknown_ccs()

int routerset_add_unknown_ccs ( routerset_t **  setp,
int  only_if_some_cc_set 
)

If *setp includes at least one country code, or if only_some_cc_set is 0, add the ?? and A1 country codes to *setp, creating it as needed. Return true iff *setp changed.

Definition at line 272 of file routerset.c.

◆ routerset_contains_extendinfo()

int routerset_contains_extendinfo ( const routerset_t *  set,
const extend_info_t ei 
)

Return true iff we can tell that ei is a member of set.

Definition at line 308 of file routerset.c.

◆ routerset_contains_node()

int routerset_contains_node ( const routerset_t *  set,
const node_t node 
)

Return true iff node is in set.

Definition at line 353 of file routerset.c.

Referenced by node_passes_guard_filter(), pick_restricted_middle_node(), router_find_exact_exit_enclave(), and routerset_subtract_nodes().

◆ routerset_contains_router()

int routerset_contains_router ( const routerset_t *  set,
const routerinfo_t ri,
country_t  country 
)

Return true iff ri is in set. If country is -1, we look up the country.

Definition at line 328 of file routerset.c.

Referenced by router_should_check_reachability(), and routerset_contains_node().

◆ routerset_contains_routerstatus()

int routerset_contains_routerstatus ( const routerset_t *  set,
const routerstatus_t rs,
country_t  country 
)

Return true iff rs is in set. If country is -1, we look up the country.

Definition at line 339 of file routerset.c.

Referenced by routerset_contains_node().

◆ routerset_equal()

int routerset_equal ( const routerset_t *  old,
const routerset_t *  new 
)

Helper: return true iff old and new are both NULL, or both non-NULL equal routersets.

Definition at line 439 of file routerset.c.

◆ routerset_free_()

void routerset_free_ ( routerset_t *  routerset)

Free all storage held in routerset.

Definition at line 465 of file routerset.c.

◆ routerset_get_all_nodes()

void routerset_get_all_nodes ( smartlist_t out,
const routerset_t *  routerset,
const routerset_t *  excludeset,
int  running_only 
)

Add every known node_t that is a member of routerset to out, but never add any that are part of excludeset. If running_only, only add the running ones.

Definition at line 379 of file routerset.c.

◆ routerset_is_empty()

int routerset_is_empty ( const routerset_t *  set)

Return true iff there are no entries in set.

Definition at line 204 of file routerset.c.

Referenced by addressmap_clear_excluded_trackexithosts(), and routerset_equal().

◆ routerset_is_list()

int routerset_is_list ( const routerset_t *  set)

Return true iff set lists only nicknames and digests, and includes no IP ranges or countries.

Definition at line 188 of file routerset.c.

Referenced by routerset_get_all_nodes().

◆ routerset_len()

int routerset_len ( const routerset_t *  set)

Return the number of entries in set. This does NOT return a negative value.

Definition at line 212 of file routerset.c.

◆ routerset_needs_geoip()

int routerset_needs_geoip ( const routerset_t *  set)

Return true iff we need a GeoIP IP-to-country database to make sense of set.

Definition at line 197 of file routerset.c.

Referenced by options_need_geoip_info().

◆ routerset_new()

routerset_t* routerset_new ( void  )

Return a new empty routerset.

Definition at line 51 of file routerset.c.

◆ routerset_parse()

int routerset_parse ( routerset_t *  target,
const char *  s,
const char *  description 
)

Parse the string s to create a set of routerset entries, and add them to target. In log messages, refer to the string as description. Return 0 on success, -1 on failure.

Three kinds of elements are allowed in routersets: nicknames, IP address patterns, and fingerprints. They may be surrounded by optional space, and must be separated by commas.

Definition at line 115 of file routerset.c.

Referenced by routerset_union().

◆ routerset_refresh_countries()

void routerset_refresh_countries ( routerset_t *  target)

Update the routerset's countries bitarray_t. Called whenever the GeoIP IPv4 database is reloaded.

Definition at line 82 of file routerset.c.

Referenced by refresh_all_country_info().

◆ routerset_subtract_nodes()

void routerset_subtract_nodes ( smartlist_t lst,
const routerset_t *  routerset 
)

Remove every node_t from lst that is in routerset.

Definition at line 413 of file routerset.c.

◆ routerset_to_string()

char* routerset_to_string ( const routerset_t *  set)

Return a new string that when parsed by routerset_parse_string() will yield set.

Definition at line 429 of file routerset.c.

Referenced by routerset_encode(), and routerset_union().

◆ routerset_union()

void routerset_union ( routerset_t *  target,
const routerset_t *  source 
)

Add all members of the set source to target.

Definition at line 174 of file routerset.c.

Variable Documentation

◆ ROUTERSET_type_defn

const struct var_type_def_t ROUTERSET_type_defn
extern

Definition of a routerset_t-based configuration type.

Values are mapped to and from strings using the format defined in routerset_parse(): nicknames, IP address patterns, and fingerprints–with optional space, separated by commas.

Empty sets are represented as NULL.

Definition at line 608 of file routerset.c.