Tor
0.4.7.0-alpha-dev
|
Code to manipulate encoded, reference-counted node families. We use these tricks to save space, since these families would otherwise require a large number of tiny allocations. More...
#include "core/or/or.h"
#include "feature/nodelist/nickname.h"
#include "feature/nodelist/nodefamily.h"
#include "feature/nodelist/nodefamily_st.h"
#include "feature/nodelist/nodelist.h"
#include "feature/relay/router.h"
#include "feature/nodelist/routerlist.h"
#include "ht.h"
#include "siphash.h"
#include "lib/container/smartlist.h"
#include "lib/ctime/di_ops.h"
#include "lib/defs/digest_sizes.h"
#include "lib/log/util_bug.h"
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Functions | |
static nodefamily_t * | nodefamily_alloc (int n_members) |
static unsigned int | nodefamily_hash (const nodefamily_t *nf) |
static unsigned int | nodefamily_eq (const nodefamily_t *a, const nodefamily_t *b) |
static | HT_HEAD (HT_PROTOTYPE(nodefamily_map, HT_PROTOTYPE(nodefamily_t) |
char * | nodefamily_canonicalize (const char *s, const uint8_t *rsa_id_self, unsigned flags) |
static int | compare_members (const void *a, const void *b) |
nodefamily_t * | nodefamily_from_members (const smartlist_t *members, const uint8_t *rsa_id_self, unsigned flags, smartlist_t *unrecognized_out) |
void | nodefamily_free_ (nodefamily_t *family) |
bool | nodefamily_contains_rsa_id (const nodefamily_t *family, const uint8_t *rsa_id) |
bool | nodefamily_contains_nickname (const nodefamily_t *family, const char *name) |
bool | nodefamily_contains_node (const nodefamily_t *family, const node_t *node) |
void | nodefamily_add_nodes_to_smartlist (const nodefamily_t *family, smartlist_t *out) |
char * | nodefamily_format (const nodefamily_t *family) |
void | nodefamily_free_all (void) |
Code to manipulate encoded, reference-counted node families. We use these tricks to save space, since these families would otherwise require a large number of tiny allocations.
Definition in file nodefamily.c.
|
static |
qsort helper for encoded nodefamily elements.
Definition at line 140 of file nodefamily.c.
void nodefamily_add_nodes_to_smartlist | ( | const nodefamily_t * | family, |
smartlist_t * | out | ||
) |
Look up every entry in family, and add add the corresponding node_t to out.
Definition at line 342 of file nodefamily.c.
|
static |
Allocate and return a blank node family with space to hold n_members members.
Definition at line 38 of file nodefamily.c.
char* nodefamily_canonicalize | ( | const char * | s, |
const uint8_t * | rsa_id_self, | ||
unsigned | flags | ||
) |
Canonicalize the family list s, returning a newly allocated string.
The canonicalization rules are fully specified in dir-spec.txt, but, briefly: $hexid entries are put in caps, $hexid[=~]foo entries are truncated, nicknames are put into lowercase, unrecognized entries are left alone, and everything is sorted.
Definition at line 111 of file nodefamily.c.
bool nodefamily_contains_nickname | ( | const nodefamily_t * | family, |
const char * | name | ||
) |
Return true iff family contains the nickname name.
Definition at line 304 of file nodefamily.c.
Referenced by nodefamily_contains_node().
bool nodefamily_contains_node | ( | const nodefamily_t * | family, |
const node_t * | node | ||
) |
Return true if family contains the nickname or the RSA ID for node
Definition at line 328 of file nodefamily.c.
Referenced by node_family_contains().
bool nodefamily_contains_rsa_id | ( | const nodefamily_t * | family, |
const uint8_t * | rsa_id | ||
) |
Return true iff family contains the SHA1 RSA1024 identity rsa_id.
Definition at line 283 of file nodefamily.c.
Referenced by nodefamily_contains_node().
|
inlinestatic |
Hashtable equality implementation.
Definition at line 61 of file nodefamily.c.
char* nodefamily_format | ( | const nodefamily_t * | family | ) |
Encode family as a space-separated string.
Definition at line 374 of file nodefamily.c.
void nodefamily_free_ | ( | nodefamily_t * | family | ) |
Drop our reference to family, freeing it if there are no more references.
Definition at line 265 of file nodefamily.c.
void nodefamily_free_all | ( | void | ) |
Free all storage held in the nodefamily map.
Definition at line 413 of file nodefamily.c.
nodefamily_t* nodefamily_from_members | ( | const smartlist_t * | members, |
const uint8_t * | rsa_id_self, | ||
unsigned | flags, | ||
smartlist_t * | unrecognized_out | ||
) |
Parse the member strings in members, returning their canonical nodefamily_t. Return NULL on error.
If rsa_id_self is provided, it is a DIGEST_LEN-byte digest for the router that declared this family: insert it into the family declaration if it is not there already.
The flags element is interpreted as in nodefamily_parse().
If unrecognized is provided, fill it copies of any unrecognized members. (Note that malformed $hexids are not considered unrecognized.)
Definition at line 159 of file nodefamily.c.
|
inlinestatic |
Hashtable hash implementation.
Definition at line 51 of file nodefamily.c.