40  size_t alloc_len = offsetof(
nodefamily_t, family_members) +
 
 
   50static inline unsigned int 
   53  return (
unsigned) siphash24g(nf->family_members,
 
 
   60static inline unsigned int 
   64    fast_memeq(a->family_members, b->family_members,
 
 
   68static HT_HEAD(nodefamily_map, 
nodefamily_t) the_node_families
 
   91nodefamily_parse(
const char *s, 
const uint8_t *rsa_id_self,
 
  122                         SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
 
  130  smartlist_free(result_members);
 
 
  160                        const uint8_t *rsa_id_self,
 
  164  const int n_self = rsa_id_self ? 1 : 0;
 
  165  int n_bad_elements = 0;
 
  166  int n_members = smartlist_len(members) + n_self;
 
  171    bool bad_element = 
true;
 
  175      memcpy(ptr+1, cp, strlen(cp));
 
  188      if (unrecognized_out)
 
  195             "Bad element %s while parsing a node family.",
 
  199      ptr += NODEFAMILY_MEMBER_LEN;
 
  201  } SMARTLIST_FOREACH_END(cp);
 
  203  if (n_bad_elements && (flags & NF_REJECT_MALFORMED))
 
  212  n_members -= n_bad_elements;
 
  215  qsort(tmp->family_members, n_members, NODEFAMILY_MEMBER_LEN,
 
  220  for (i = 0; i < n_members-1; ++i) {
 
  223    if (
fast_memeq(thisptr, nextptr, NODEFAMILY_MEMBER_LEN)) {
 
  224      memmove(thisptr, nextptr, (n_members-i-1)*NODEFAMILY_MEMBER_LEN);
 
  233  nodefamily_t *found = HT_FIND(nodefamily_map, &the_node_families, tmp);
 
  241    if (n_members_alloc != n_members) {
 
  244      memcpy(tmp2->family_members, tmp->family_members,
 
  245             n_members * NODEFAMILY_MEMBER_LEN);
 
  251    HT_INSERT(nodefamily_map, &the_node_families, tmp);
 
 
  272  if (family->
refcnt == 0) {
 
  273    HT_REMOVE(nodefamily_map, &the_node_families, family);
 
 
  284                           const uint8_t *rsa_id)
 
  290  for (i = 0; i < family->
n_members; ++i) {
 
 
  311  for (i = 0; i < family->
n_members; ++i) {
 
 
  349  for (i = 0; i < family->
n_members; ++i) {
 
  351    const node_t *node = NULL;
 
 
  377    return tor_strdup(
"");
 
  381  for (i = 0; i < family->
n_members; ++i) {
 
 
  415  HT_CLEAR(nodefamily_map, &the_node_families);
 
 
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
#define fast_memeq(a, b, c)
#define fast_memcmp(a, b, c)
Definitions for common sizes of cryptographic digests.
const char * escaped(const char *s)
#define log_fn(severity, domain, args,...)
void * tor_reallocarray_(void *ptr, size_t sz1, size_t sz2)
void tor_free_(void *mem)
int is_legal_nickname(const char *s)
int is_legal_hexdigest(const char *s)
Header file for nickname.c.
bool nodefamily_contains_node(const nodefamily_t *family, const node_t *node)
char * nodefamily_format(const nodefamily_t *family)
static int compare_members(const void *a, const void *b)
static nodefamily_t * nodefamily_alloc(int n_members)
void nodefamily_add_nodes_to_smartlist(const nodefamily_t *family, smartlist_t *out)
bool nodefamily_contains_nickname(const nodefamily_t *family, const char *name)
void nodefamily_free_(nodefamily_t *family)
static unsigned int nodefamily_eq(const nodefamily_t *a, const nodefamily_t *b)
static unsigned int nodefamily_hash(const nodefamily_t *nf)
bool nodefamily_contains_rsa_id(const nodefamily_t *family, const uint8_t *rsa_id)
void nodefamily_free_all(void)
nodefamily_t * nodefamily_from_members(const smartlist_t *members, const uint8_t *rsa_id_self, unsigned flags, smartlist_t *unrecognized_out)
char * nodefamily_canonicalize(const char *s, const uint8_t *rsa_id_self, unsigned flags)
Header file for nodefamily.c.
Compact node-family structure.
#define NODEFAMILY_ARRAY_SIZE(n)
#define NODEFAMILY_BY_RSA_ID
#define NODEFAMILY_MEMBER_PTR(nf, i)
#define NODEFAMILY_BY_NICKNAME
const uint8_t * node_get_rsa_id_digest(const node_t *node)
const node_t * node_get_by_id(const char *identity_digest)
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
const char * node_get_nickname(const node_t *node)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
Header file for router.c.
int hex_digest_nickname_decode(const char *hexdigest, char *digest_out, char *nickname_qualifier_char_out, char *nickname_out)
Header file for routerlist.c.
void smartlist_sort_strings(smartlist_t *sl)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
void smartlist_add_strdup(struct smartlist_t *sl, const char *string)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
Macros to manage assertions, fatal and non-fatal.
#define tor_assert_nonfatal_unreached()
void tor_strlower(char *s)
void tor_strupper(char *s)