tor  0.4.2.1-alpha-dev
routerset.h
1 /* Copyright (c) 2001-2004, Roger Dingledine.
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_ROUTERSET_H
12 #define TOR_ROUTERSET_H
13 
14 routerset_t *routerset_new(void);
15 void routerset_refresh_countries(routerset_t *rs);
16 int routerset_parse(routerset_t *target, const char *s,
17  const char *description);
18 void routerset_union(routerset_t *target, const routerset_t *source);
19 int routerset_is_list(const routerset_t *set);
20 int routerset_needs_geoip(const routerset_t *set);
21 int routerset_is_empty(const routerset_t *set);
22 int routerset_contains_router(const routerset_t *set, const routerinfo_t *ri,
23  country_t country);
24 int routerset_contains_routerstatus(const routerset_t *set,
25  const routerstatus_t *rs,
26  country_t country);
27 int routerset_contains_extendinfo(const routerset_t *set,
28  const extend_info_t *ei);
29 struct bridge_info_t;
30 int routerset_contains_bridge(const routerset_t *set,
31  const struct bridge_info_t *bridge);
32 int routerset_contains_node(const routerset_t *set, const node_t *node);
33 
34 void routerset_get_all_nodes(smartlist_t *out, const routerset_t *routerset,
35  const routerset_t *excludeset,
36  int running_only);
37 int routerset_add_unknown_ccs(routerset_t **setp, int only_if_some_cc_set);
39  const routerset_t *routerset);
40 
41 char *routerset_to_string(const routerset_t *routerset);
42 int routerset_equal(const routerset_t *old, const routerset_t *new);
43 void routerset_free_(routerset_t *routerset);
44 #define routerset_free(rs) FREE_AND_NULL(routerset_t, routerset_free_, (rs))
45 int routerset_len(const routerset_t *set);
46 
47 struct var_type_def_t;
48 extern const struct var_type_def_t ROUTERSET_type_defn;
49 
50 #ifdef ROUTERSET_PRIVATE
51 #include "lib/container/bitarray.h"
52 
53 STATIC char * routerset_get_countryname(const char *c);
54 STATIC int routerset_contains(const routerset_t *set, const tor_addr_t *addr,
55  uint16_t orport,
56  const char *nickname, const char *id_digest,
57  country_t country);
58 
63 struct routerset_t {
68  smartlist_t *list;
70  strmap_t *names;
72  digestmap_t *digests;
75  smartlist_t *policies;
76 
79  char *description;
80 
82  smartlist_t *country_names;
84  int n_countries;
89  bitarray_t *countries;
90 };
91 #endif /* defined(ROUTERSET_PRIVATE) */
92 #endif /* !defined(TOR_ROUTERSET_H) */
void routerset_union(routerset_t *target, const routerset_t *source)
Definition: routerset.c:173
int routerset_contains_extendinfo(const routerset_t *set, const extend_info_t *ei)
Definition: routerset.c:293
Definition: node_st.h:28
unsigned int bitarray_t
Definition: bitarray.h:30
int routerset_contains_node(const routerset_t *set, const node_t *node)
Definition: routerset.c:338
const var_type_def_t ROUTERSET_type_defn
Definition: routerset.c:565
Implements a variable-sized (but non-resizeable) bit-array.
int routerset_is_list(const routerset_t *set)
Definition: routerset.c:187
void routerset_refresh_countries(routerset_t *target)
Definition: routerset.c:81
void routerset_free_(routerset_t *routerset)
Definition: routerset.c:450
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)
Definition: routerset.c:227
char * routerset_to_string(const routerset_t *set)
Definition: routerset.c:414
int routerset_contains_router(const routerset_t *set, const routerinfo_t *ri, country_t country)
Definition: routerset.c:306
int routerset_add_unknown_ccs(routerset_t **setp, int only_if_some_cc_set)
Definition: routerset.c:257
int routerset_needs_geoip(const routerset_t *set)
Definition: routerset.c:196
int routerset_parse(routerset_t *target, const char *s, const char *description)
Definition: routerset.c:114
int routerset_len(const routerset_t *set)
Definition: routerset.c:211
void routerset_subtract_nodes(smartlist_t *lst, const routerset_t *routerset)
Definition: routerset.c:398
routerset_t * routerset_new(void)
Definition: routerset.c:51
int routerset_equal(const routerset_t *old, const routerset_t *new)
Definition: routerset.c:424
void routerset_get_all_nodes(smartlist_t *out, const routerset_t *routerset, const routerset_t *excludeset, int running_only)
Definition: routerset.c:364
int routerset_contains_routerstatus(const routerset_t *set, const routerstatus_t *rs, country_t country)
Definition: routerset.c:322
STATIC char * routerset_get_countryname(const char *c)
Definition: routerset.c:65
int routerset_contains_bridge(const routerset_t *set, const bridge_info_t *bridge)
Definition: routerset.c:350
int routerset_is_empty(const routerset_t *set)
Definition: routerset.c:203