Tor  0.4.3.0-alpha-dev
routerset.c
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
7 /**
8  * \file routerset.c
9  *
10  * \brief Functions and structures to handle set-type selection of routers
11  * by name, ID, address, etc.
12  *
13  * This module implements the routerset_t data structure, whose purpose
14  * is to specify a set of relays based on a list of their identities or
15  * properties. Routersets can restrict relays by IP address mask,
16  * identity fingerprint, country codes, and nicknames (deprecated).
17  *
18  * Routersets are typically used for user-specified restrictions, and
19  * are created by invoking routerset_new and routerset_parse from
20  * config.c and confmgt.c. To use a routerset, invoke one of
21  * routerset_contains_...() functions , or use
22  * routerstatus_get_all_nodes() / routerstatus_subtract_nodes() to
23  * manipulate a smartlist of node_t pointers.
24  *
25  * Country-code restrictions are implemented in geoip.c.
26  */
27 
28 #define ROUTERSET_PRIVATE
29 
30 #include "core/or/or.h"
31 #include "core/or/policies.h"
32 #include "feature/client/bridges.h"
37 #include "lib/conf/conftypes.h"
38 #include "lib/confmgt/typedvar.h"
39 #include "lib/encoding/confline.h"
40 #include "lib/geoip/geoip.h"
41 
42 #include "core/or/addr_policy_st.h"
43 #include "core/or/extend_info_st.h"
48 
49 /** Return a new empty routerset. */
50 routerset_t *
52 {
53  routerset_t *result = tor_malloc_zero(sizeof(routerset_t));
54  result->list = smartlist_new();
55  result->names = strmap_new();
56  result->digests = digestmap_new();
57  result->policies = smartlist_new();
58  result->country_names = smartlist_new();
59  return result;
60 }
61 
62 /** If <b>c</b> is a country code in the form {cc}, return a newly allocated
63  * string holding the "cc" part. Else, return NULL. */
64 STATIC char *
66 {
67  char *country;
68 
69  if (strlen(c) < 4 || c[0] !='{' || c[3] !='}')
70  return NULL;
71 
72  country = tor_strndup(c+1, 2);
73  tor_strlower(country);
74  return country;
75 }
76 
77 /** Update the routerset's <b>countries</b> bitarray_t. Called whenever
78  * the GeoIP IPv4 database is reloaded.
79  */
80 void
81 routerset_refresh_countries(routerset_t *target)
82 {
83  int cc;
84  bitarray_free(target->countries);
85 
86  if (!geoip_is_loaded(AF_INET)) {
87  target->countries = NULL;
88  target->n_countries = 0;
89  return;
90  }
91  target->n_countries = geoip_get_n_countries();
92  target->countries = bitarray_init_zero(target->n_countries);
93  SMARTLIST_FOREACH_BEGIN(target->country_names, const char *, country) {
94  cc = geoip_get_country(country);
95  if (cc >= 0) {
96  tor_assert(cc < target->n_countries);
97  bitarray_set(target->countries, cc);
98  } else {
99  log_warn(LD_CONFIG, "Country code '%s' is not recognized.",
100  country);
101  }
102  } SMARTLIST_FOREACH_END(country);
103 }
104 
105 /** Parse the string <b>s</b> to create a set of routerset entries, and add
106  * them to <b>target</b>. In log messages, refer to the string as
107  * <b>description</b>. Return 0 on success, -1 on failure.
108  *
109  * Three kinds of elements are allowed in routersets: nicknames, IP address
110  * patterns, and fingerprints. They may be surrounded by optional space, and
111  * must be separated by commas.
112  */
113 int
114 routerset_parse(routerset_t *target, const char *s, const char *description)
115 {
116  int r = 0;
117  int added_countries = 0;
118  char *countryname;
119  smartlist_t *list = smartlist_new();
120  int malformed_list;
121  smartlist_split_string(list, s, ",",
122  SPLIT_SKIP_SPACE | SPLIT_IGNORE_BLANK, 0);
123  SMARTLIST_FOREACH_BEGIN(list, char *, nick) {
124  addr_policy_t *p;
125  /* if it doesn't pass our validation, assume it's malformed */
126  malformed_list = 1;
127  if (is_legal_hexdigest(nick)) {
128  char d[DIGEST_LEN];
129  if (*nick == '$')
130  ++nick;
131  log_debug(LD_CONFIG, "Adding identity %s to %s", nick, description);
132  base16_decode(d, sizeof(d), nick, HEX_DIGEST_LEN);
133  digestmap_set(target->digests, d, (void*)1);
134  } else if (is_legal_nickname(nick)) {
135  log_debug(LD_CONFIG, "Adding nickname %s to %s", nick, description);
136  strmap_set_lc(target->names, nick, (void*)1);
137  } else if ((countryname = routerset_get_countryname(nick)) != NULL) {
138  log_debug(LD_CONFIG, "Adding country %s to %s", nick,
139  description);
140  smartlist_add(target->country_names, countryname);
141  added_countries = 1;
142  } else if ((strchr(nick,'.') || strchr(nick, ':') || strchr(nick, '*'))
144  nick, ADDR_POLICY_REJECT,
145  &malformed_list))) {
146  /* IPv4 addresses contain '.', IPv6 addresses contain ':',
147  * and wildcard addresses contain '*'. */
148  log_debug(LD_CONFIG, "Adding address %s to %s", nick, description);
149  smartlist_add(target->policies, p);
150  } else if (malformed_list) {
151  log_warn(LD_CONFIG, "Entry '%s' in %s is malformed. Discarding entire"
152  " list.", nick, description);
153  r = -1;
154  tor_free(nick);
155  SMARTLIST_DEL_CURRENT(list, nick);
156  } else {
157  log_notice(LD_CONFIG, "Entry '%s' in %s is ignored. Using the"
158  " remainder of the list.", nick, description);
159  tor_free(nick);
160  SMARTLIST_DEL_CURRENT(list, nick);
161  }
162  } SMARTLIST_FOREACH_END(nick);
163  policy_expand_unspec(&target->policies);
164  smartlist_add_all(target->list, list);
165  smartlist_free(list);
166  if (added_countries)
168  return r;
169 }
170 
171 /** Add all members of the set <b>source</b> to <b>target</b>. */
172 void
173 routerset_union(routerset_t *target, const routerset_t *source)
174 {
175  char *s;
176  tor_assert(target);
177  if (!source || !source->list)
178  return;
179  s = routerset_to_string(source);
180  routerset_parse(target, s, "other routerset");
181  tor_free(s);
182 }
183 
184 /** Return true iff <b>set</b> lists only nicknames and digests, and includes
185  * no IP ranges or countries. */
186 int
187 routerset_is_list(const routerset_t *set)
188 {
189  return smartlist_len(set->country_names) == 0 &&
190  smartlist_len(set->policies) == 0;
191 }
192 
193 /** Return true iff we need a GeoIP IP-to-country database to make sense of
194  * <b>set</b>. */
195 int
196 routerset_needs_geoip(const routerset_t *set)
197 {
198  return set && smartlist_len(set->country_names);
199 }
200 
201 /** Return true iff there are no entries in <b>set</b>. */
202 int
203 routerset_is_empty(const routerset_t *set)
204 {
205  return !set || smartlist_len(set->list) == 0;
206 }
207 
208 /** Return the number of entries in <b>set</b>. This does NOT return a
209  * negative value. */
210 int
211 routerset_len(const routerset_t *set)
212 {
213  if (!set) {
214  return 0;
215  }
216  return smartlist_len(set->list);
217 }
218 
219 /** Helper. Return true iff <b>set</b> contains a router based on the other
220  * provided fields. Return higher values for more specific subentries: a
221  * single router is more specific than an address range of routers, which is
222  * more specific in turn than a country code.
223  *
224  * (If country is -1, then we take the country
225  * from addr.) */
226 STATIC int
227 routerset_contains(const routerset_t *set, const tor_addr_t *addr,
228  uint16_t orport,
229  const char *nickname, const char *id_digest,
230  country_t country)
231 {
232  if (!set || !set->list)
233  return 0;
234  if (nickname && strmap_get_lc(set->names, nickname))
235  return 4;
236  if (id_digest && digestmap_get(set->digests, id_digest))
237  return 4;
238  if (addr && compare_tor_addr_to_addr_policy(addr, orport, set->policies)
240  return 3;
241  if (set->countries) {
242  if (country < 0 && addr)
243  country = geoip_get_country_by_addr(addr);
244 
245  if (country >= 0 && country < set->n_countries &&
246  bitarray_is_set(set->countries, country))
247  return 2;
248  }
249  return 0;
250 }
251 
252 /** If *<b>setp</b> includes at least one country code, or if
253  * <b>only_some_cc_set</b> is 0, add the ?? and A1 country codes to
254  * *<b>setp</b>, creating it as needed. Return true iff *<b>setp</b> changed.
255  */
256 int
257 routerset_add_unknown_ccs(routerset_t **setp, int only_if_some_cc_set)
258 {
259  routerset_t *set;
260  int add_unknown, add_a1;
261  if (only_if_some_cc_set) {
262  if (!*setp || smartlist_len((*setp)->country_names) == 0)
263  return 0;
264  }
265  if (!*setp)
266  *setp = routerset_new();
267 
268  set = *setp;
269 
270  add_unknown = ! smartlist_contains_string_case(set->country_names, "??") &&
271  geoip_get_country("??") >= 0;
272  add_a1 = ! smartlist_contains_string_case(set->country_names, "a1") &&
273  geoip_get_country("A1") >= 0;
274 
275  if (add_unknown) {
276  smartlist_add_strdup(set->country_names, "??");
277  smartlist_add_strdup(set->list, "{??}");
278  }
279  if (add_a1) {
280  smartlist_add_strdup(set->country_names, "a1");
281  smartlist_add_strdup(set->list, "{a1}");
282  }
283 
284  if (add_unknown || add_a1) {
286  return 1;
287  }
288  return 0;
289 }
290 
291 /** Return true iff we can tell that <b>ei</b> is a member of <b>set</b>. */
292 int
293 routerset_contains_extendinfo(const routerset_t *set, const extend_info_t *ei)
294 {
295  return routerset_contains(set,
296  &ei->addr,
297  ei->port,
298  ei->nickname,
299  ei->identity_digest,
300  -1 /*country*/);
301 }
302 
303 /** Return true iff <b>ri</b> is in <b>set</b>. If country is <b>-1</b>, we
304  * look up the country. */
305 int
306 routerset_contains_router(const routerset_t *set, const routerinfo_t *ri,
307  country_t country)
308 {
309  tor_addr_t addr;
310  tor_addr_from_ipv4h(&addr, ri->addr);
311  return routerset_contains(set,
312  &addr,
313  ri->or_port,
314  ri->nickname,
315  ri->cache_info.identity_digest,
316  country);
317 }
318 
319 /** Return true iff <b>rs</b> is in <b>set</b>. If country is <b>-1</b>, we
320  * look up the country. */
321 int
322 routerset_contains_routerstatus(const routerset_t *set,
323  const routerstatus_t *rs,
324  country_t country)
325 {
326  tor_addr_t addr;
327  tor_addr_from_ipv4h(&addr, rs->addr);
328  return routerset_contains(set,
329  &addr,
330  rs->or_port,
331  rs->nickname,
332  rs->identity_digest,
333  country);
334 }
335 
336 /** Return true iff <b>node</b> is in <b>set</b>. */
337 int
338 routerset_contains_node(const routerset_t *set, const node_t *node)
339 {
340  if (node->rs)
341  return routerset_contains_routerstatus(set, node->rs, node->country);
342  else if (node->ri)
343  return routerset_contains_router(set, node->ri, node->country);
344  else
345  return 0;
346 }
347 
348 /** Return true iff <b>routerset</b> contains the bridge <b>bridge</b>. */
349 int
350 routerset_contains_bridge(const routerset_t *set, const bridge_info_t *bridge)
351 {
352  const char *id = (const char*)bridge_get_rsa_id_digest(bridge);
353  const tor_addr_port_t *addrport = bridge_get_addr_port(bridge);
354 
355  tor_assert(addrport);
356  return routerset_contains(set, &addrport->addr, addrport->port,
357  NULL, id, -1);
358 }
359 
360 /** Add every known node_t that is a member of <b>routerset</b> to
361  * <b>out</b>, but never add any that are part of <b>excludeset</b>.
362  * If <b>running_only</b>, only add the running ones. */
363 void
364 routerset_get_all_nodes(smartlist_t *out, const routerset_t *routerset,
365  const routerset_t *excludeset, int running_only)
366 {
367  tor_assert(out);
368  if (!routerset || !routerset->list)
369  return;
370 
371  if (routerset_is_list(routerset)) {
372  /* No routers are specified by type; all are given by name or digest.
373  * we can do a lookup in O(len(routerset)). */
374  SMARTLIST_FOREACH(routerset->list, const char *, name, {
375  const node_t *node = node_get_by_nickname(name, 0);
376  if (node) {
377  if (!running_only || node->is_running)
378  if (!routerset_contains_node(excludeset, node))
379  smartlist_add(out, (void*)node);
380  }
381  });
382  } else {
383  /* We need to iterate over the routerlist to get all the ones of the
384  * right kind. */
385  const smartlist_t *nodes = nodelist_get_list();
386  SMARTLIST_FOREACH(nodes, const node_t *, node, {
387  if (running_only && !node->is_running)
388  continue;
389  if (routerset_contains_node(routerset, node) &&
390  !routerset_contains_node(excludeset, node))
391  smartlist_add(out, (void*)node);
392  });
393  }
394 }
395 
396 /** Remove every node_t from <b>lst</b> that is in <b>routerset</b>. */
397 void
398 routerset_subtract_nodes(smartlist_t *lst, const routerset_t *routerset)
399 {
400  tor_assert(lst);
401  if (!routerset)
402  return;
403  SMARTLIST_FOREACH(lst, const node_t *, node, {
404  if (routerset_contains_node(routerset, node)) {
405  //log_debug(LD_DIR, "Subtracting %s",r->nickname);
406  SMARTLIST_DEL_CURRENT(lst, node);
407  }
408  });
409 }
410 
411 /** Return a new string that when parsed by routerset_parse_string() will
412  * yield <b>set</b>. */
413 char *
414 routerset_to_string(const routerset_t *set)
415 {
416  if (!set || !set->list)
417  return tor_strdup("");
418  return smartlist_join_strings(set->list, ",", 0, NULL);
419 }
420 
421 /** Helper: return true iff old and new are both NULL, or both non-NULL
422  * equal routersets. */
423 int
424 routerset_equal(const routerset_t *old, const routerset_t *new)
425 {
426  if (routerset_is_empty(old) && routerset_is_empty(new)) {
427  /* Two empty sets are equal */
428  return 1;
429  } else if (routerset_is_empty(old) || routerset_is_empty(new)) {
430  /* An empty set is equal to nothing else. */
431  return 0;
432  }
433  tor_assert(old != NULL);
434  tor_assert(new != NULL);
435 
436  if (smartlist_len(old->list) != smartlist_len(new->list))
437  return 0;
438 
439  SMARTLIST_FOREACH(old->list, const char *, cp1, {
440  const char *cp2 = smartlist_get(new->list, cp1_sl_idx);
441  if (strcmp(cp1, cp2))
442  return 0;
443  });
444 
445  return 1;
446 }
447 
448 /** Free all storage held in <b>routerset</b>. */
449 void
450 routerset_free_(routerset_t *routerset)
451 {
452  if (!routerset)
453  return;
454 
455  SMARTLIST_FOREACH(routerset->list, char *, cp, tor_free(cp));
456  smartlist_free(routerset->list);
457  SMARTLIST_FOREACH(routerset->policies, addr_policy_t *, p,
458  addr_policy_free(p));
459  smartlist_free(routerset->policies);
460  SMARTLIST_FOREACH(routerset->country_names, char *, cp, tor_free(cp));
461  smartlist_free(routerset->country_names);
462 
463  strmap_free(routerset->names, NULL);
464  digestmap_free(routerset->digests, NULL);
465  bitarray_free(routerset->countries);
466  tor_free(routerset);
467 }
468 
469 /**
470  * config helper: parse a routerset-typed variable.
471  *
472  * Takes as input as a single line in <b>line</b>; writes its results into a
473  * routerset_t** passed as <b>target</b>. On success return 0; on failure
474  * return -1 and store an error message into *<b>errmsg</b>.
475  **/
476 /*
477  * Warning: For this type, the default value (NULL) and "" are sometimes
478  * considered different values. That is generally risky, and best avoided for
479  * other types in the future. For cases where we want the default to be "all
480  * routers" (like EntryNodes) we should add a new routerset value indicating
481  * "all routers" (see #31908)
482  */
483 static int
484 routerset_kv_parse(void *target, const config_line_t *line, char **errmsg,
485  const void *params)
486 {
487  (void)params;
488  routerset_t **p = (routerset_t**)target;
489  routerset_free(*p); // clear the old value, if any.
490  routerset_t *rs = routerset_new();
491  if (routerset_parse(rs, line->value, line->key) < 0) {
492  routerset_free(rs);
493  *errmsg = tor_strdup("Invalid router list.");
494  return -1;
495  } else {
496  if (routerset_is_empty(rs)) {
497  /* Represent empty sets as NULL. */
498  routerset_free(rs);
499  }
500  *p = rs;
501  return 0;
502  }
503 }
504 
505 /**
506  * config helper: encode a routerset-typed variable.
507  *
508  * Return a newly allocated string containing the value of the
509  * routerset_t** passed as <b>value</b>.
510  */
511 static char *
512 routerset_encode(const void *value, const void *params)
513 {
514  (void)params;
515  const routerset_t **p = (const routerset_t**)value;
516  return routerset_to_string(*p);
517 }
518 
519 /**
520  * config helper: free and clear a routerset-typed variable.
521  *
522  * Clear the routerset_t** passed as <b>value</b>.
523  */
524 static void
525 routerset_clear(void *value, const void *params)
526 {
527  (void)params;
528  routerset_t **p = (routerset_t**)value;
529  routerset_free(*p); // sets *p to NULL.
530 }
531 
532 /**
533  * config helper: copy a routerset-typed variable.
534  *
535  * Takes it input from a routerset_t** in <b>src</b>; writes its output to a
536  * routerset_t** in <b>dest</b>. Returns 0 on success, -1 on (impossible)
537  * failure.
538  **/
539 static int
540 routerset_copy(void *dest, const void *src, const void *params)
541 {
542  (void)params;
543  routerset_t **output = (routerset_t**)dest;
544  const routerset_t *input = *(routerset_t**)src;
545  routerset_free(*output); // sets *output to NULL
546  if (! routerset_is_empty(input)) {
547  *output = routerset_new();
548  routerset_union(*output, input);
549  }
550  return 0;
551 }
552 
553 /**
554  * Function table to implement a routerset_t-based configuration type.
555  **/
558  .encode = routerset_encode,
559  .clear = routerset_clear,
560  .copy = routerset_copy
561 };
562 
563 /**
564  * Definition of a routerset_t-based configuration type.
565  *
566  * Values are mapped to and from strings using the format defined in
567  * routerset_parse(): nicknames, IP address patterns, and fingerprints--with
568  * optional space, separated by commas.
569  *
570  * Empty sets are represented as NULL.
571  **/
573  .name = "RouterList",
574  .fns = &routerset_type_fns
575 };
Header for confline.c.
void routerset_union(routerset_t *target, const routerset_t *source)
Definition: routerset.c:173
char identity_digest[DIGEST_LEN]
int routerset_contains_extendinfo(const routerset_t *set, const extend_info_t *ei)
Definition: routerset.c:293
Router descriptor structure.
void * strmap_get_lc(const strmap_t *map, const char *key)
Definition: map.c:393
Definition: node_st.h:33
char nickname[MAX_HEX_NICKNAME_LEN+1]
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
int routerset_contains_node(const routerset_t *set, const node_t *node)
Definition: routerset.c:338
tor_addr_t addr
void smartlist_add_strdup(struct smartlist_t *sl, const char *string)
const var_type_def_t ROUTERSET_type_defn
Definition: routerset.c:572
int geoip_get_n_countries(void)
Definition: geoip.c:437
Header file for nodelist.c.
addr_policy_t * router_parse_addr_policy_item_from_string(const char *s, int assume_action, int *malformed_list)
Definition: policy_parse.c:44
const uint8_t * bridge_get_rsa_id_digest(const bridge_info_t *bridge)
Definition: bridges.c:147
void smartlist_add(smartlist_t *sl, void *element)
char nickname[MAX_NICKNAME_LEN+1]
Node information structure.
char identity_digest[DIGEST_LEN]
Header file for nickname.c.
#define tor_assert(expr)
Definition: util_bug.h:102
Structure declarations for typedvar type definitions.
char * nickname
Definition: routerinfo_st.h:22
int routerset_is_list(const routerset_t *set)
Definition: routerset.c:187
#define tor_free(p)
Definition: malloc.h:52
int geoip_is_loaded(sa_family_t family)
Definition: geoip.c:458
addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr, uint16_t port, const smartlist_t *policy)
Definition: policies.c:1617
const char * name
Definition: config.c:2211
#define SMARTLIST_DEL_CURRENT(sl, var)
void * strmap_set_lc(strmap_t *map, const char *key, void *val)
Definition: map.c:379
smartlist_t * smartlist_new(void)
static char * routerset_encode(const void *value, const void *params)
Definition: routerset.c:512
void routerset_refresh_countries(routerset_t *target)
Definition: routerset.c:81
Header file for geoip.c.
#define STATIC
Definition: testsupport.h:32
static void bitarray_set(bitarray_t *b, int bit)
Definition: bitarray.h:68
void policy_expand_unspec(smartlist_t **policy)
Definition: policies.c:145
Header file for routerset.c.
Routerstatus (consensus entry) structure.
void routerset_free_(routerset_t *routerset)
Definition: routerset.c:450
Header file for policies.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)
Definition: routerset.c:227
char * routerset_to_string(const routerset_t *set)
Definition: routerset.c:414
int is_legal_hexdigest(const char *s)
Definition: nickname.c:45
static void routerset_clear(void *value, const void *params)
Definition: routerset.c:525
#define tor_addr_from_ipv4h(dest, v4addr)
Definition: address.h:287
Header file for policy_parse.c.
#define DIGEST_LEN
Definition: digest_sizes.h:20
static int routerset_kv_parse(void *target, const config_line_t *line, char **errmsg, const void *params)
Definition: routerset.c:484
int smartlist_contains_string_case(const smartlist_t *sl, const char *element)
Definition: smartlist.c:133
int routerset_contains_router(const routerset_t *set, const routerinfo_t *ri, country_t country)
Definition: routerset.c:306
Header file for circuitbuild.c.
Header for lib/confmgt/typedvar.c.
Master header file for Tor-specific functionality.
int geoip_get_country_by_addr(const tor_addr_t *addr)
Definition: geoip.c:424
static bitarray_t * bitarray_init_zero(unsigned int n_bits)
Definition: bitarray.h:33
Extend-info structure.
void tor_strlower(char *s)
Definition: util_string.c:127
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 is_legal_nickname(const char *s)
Definition: nickname.c:19
#define HEX_DIGEST_LEN
Definition: crypto_digest.h:35
const smartlist_t * nodelist_get_list(void)
Definition: nodelist.c:948
static int routerset_copy(void *dest, const void *src, const void *params)
Definition: routerset.c:540
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
Definition: smartlist.c:279
Types used to specify configurable options.
#define SMARTLIST_FOREACH(sl, type, var, cmd)
static const var_type_fns_t routerset_type_fns
Definition: routerset.c:556
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
country_t geoip_get_country(const char *country)
Definition: geoip.c:101
const char * name
char identity_digest[DIGEST_LEN]
country_t country
Definition: node_st.h:92
void smartlist_add_all(smartlist_t *s1, const smartlist_t *s2)
routerset_t * routerset_new(void)
Definition: routerset.c:51
int routerset_equal(const routerset_t *old, const routerset_t *new)
Definition: routerset.c:424
uint16_t or_port
Definition: routerinfo_st.h:25
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:506
int16_t country_t
Definition: country.h:17
uint32_t addr
Definition: routerinfo_st.h:24
const tor_addr_port_t * bridge_get_addr_port(const bridge_info_t *bridge)
Definition: bridges.c:161
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
static unsigned int bitarray_is_set(bitarray_t *b, int bit)
Definition: bitarray.h:81
int(* kv_parse)(void *target, const struct config_line_t *line, char **errmsg, const void *params)
int routerset_contains_bridge(const routerset_t *set, const bridge_info_t *bridge)
Definition: routerset.c:350
#define LD_CONFIG
Definition: log.h:68
int routerset_is_empty(const routerset_t *set)
Definition: routerset.c:203
Address policy structures.
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)