tor  master
Data Structures | Functions
fp_pair.c File Reference

Manages data structures for associating pairs of fingerprints. Used to handle combinations of identity/signing-key fingerprints for authorities. More...

#include "or.h"
#include "fp_pair.h"
Include dependency graph for fp_pair.c:

Data Structures

struct  fp_pair_map_entry_s
 
struct  fp_pair_map_s
 

Functions

 HT_PROTOTYPE (HT_GENERATE2(fp_pair_map_impl, HT_GENERATE2(fp_pair_map_entry_s, HT_GENERATE2(node, HT_GENERATE2(fp_pair_map_entry_hash, HT_GENERATE2(fp_pair_map_entries_eq)
 
void * fp_pair_map_set (fp_pair_map_t *map, const fp_pair_t *key, void *val)
 
void * fp_pair_map_set_by_digests (fp_pair_map_t *map, const char *first, const char *second, void *val)
 
void * fp_pair_map_get (const fp_pair_map_t *map, const fp_pair_t *key)
 
void * fp_pair_map_get_by_digests (const fp_pair_map_t *map, const char *first, const char *second)
 
void * fp_pair_map_remove (fp_pair_map_t *map, const fp_pair_t *key)
 
void fp_pair_map_free_ (fp_pair_map_t *map, void(*free_val)(void *))
 
int fp_pair_map_isempty (const fp_pair_map_t *map)
 
int fp_pair_map_size (const fp_pair_map_t *map)
 
fp_pair_map_iter_tfp_pair_map_iter_init (fp_pair_map_t *map)
 
fp_pair_map_iter_tfp_pair_map_iter_next (fp_pair_map_t *map, fp_pair_map_iter_t *iter)
 
fp_pair_map_iter_tfp_pair_map_iter_next_rmv (fp_pair_map_t *map, fp_pair_map_iter_t *iter)
 
void fp_pair_map_iter_get (fp_pair_map_iter_t *iter, fp_pair_t *key_out, void **val_out)
 
int fp_pair_map_iter_done (fp_pair_map_iter_t *iter)
 
void fp_pair_map_assert_ok (const fp_pair_map_t *map)
 

Detailed Description

Manages data structures for associating pairs of fingerprints. Used to handle combinations of identity/signing-key fingerprints for authorities.

This is a nice, simple, compact data structure module that handles a map from (signing key fingerprint, identity key fingerprint) to void *. The fingerprints here are SHA1 digests of RSA keys.

This structure is used in directory.c and in routerlist.c for handling handling authority certificates, since we never want more than a single certificate for any (ID key, signing key) pair.

Function Documentation

◆ fp_pair_map_assert_ok()

void fp_pair_map_assert_ok ( const fp_pair_map_t map)

Assert if anything has gone wrong with the internal representation of map.

◆ fp_pair_map_free_()

void fp_pair_map_free_ ( fp_pair_map_t map,
void(*)(void *)  free_val 
)

Remove all entries from map, and deallocate storage for those entries. If free_val is provided, it is invoked on every value in map.

◆ fp_pair_map_get()

void* fp_pair_map_get ( const fp_pair_map_t map,
const fp_pair_t key 
)

Return the current value associated with key, or NULL if no value is set.

Here is the caller graph for this function:

◆ fp_pair_map_get_by_digests()

void* fp_pair_map_get_by_digests ( const fp_pair_map_t map,
const char *  first,
const char *  second 
)

Return the current value associated the key (first, second), or NULL if no value is set.

Here is the call graph for this function:

◆ fp_pair_map_isempty()

int fp_pair_map_isempty ( const fp_pair_map_t map)

Return true iff map has no entries.

◆ fp_pair_map_iter_done()

int fp_pair_map_iter_done ( fp_pair_map_iter_t iter)

Return true iff iter has advanced past the last entry of its map.

◆ fp_pair_map_iter_get()

void fp_pair_map_iter_get ( fp_pair_map_iter_t iter,
fp_pair_t key_out,
void **  val_out 
)

Set *key_out and *val_out to the current entry pointed to by iter.

◆ fp_pair_map_iter_init()

fp_pair_map_iter_t* fp_pair_map_iter_init ( fp_pair_map_t map)

return an iterator pointing to the start of map.

◆ fp_pair_map_iter_next()

fp_pair_map_iter_t* fp_pair_map_iter_next ( fp_pair_map_t map,
fp_pair_map_iter_t iter 
)

Advance iter a single step to the next entry of map, and return its new value.

◆ fp_pair_map_iter_next_rmv()

fp_pair_map_iter_t* fp_pair_map_iter_next_rmv ( fp_pair_map_t map,
fp_pair_map_iter_t iter 
)

Advance iter a single step to the next entry of map, removing the current entry, and return its new value.

◆ fp_pair_map_remove()

void* fp_pair_map_remove ( fp_pair_map_t map,
const fp_pair_t key 
)

Remove the value currently associated with key from the map. Return the value if one was set, or NULL if there was no entry for key. The caller must free any storage associated with the returned value.

◆ fp_pair_map_set()

void* fp_pair_map_set ( fp_pair_map_t map,
const fp_pair_t key,
void *  val 
)

Set the current value for key to val; returns the previous value for key if one was set, or NULL if one was not.

Here is the caller graph for this function:

◆ fp_pair_map_set_by_digests()

void* fp_pair_map_set_by_digests ( fp_pair_map_t map,
const char *  first,
const char *  second,
void *  val 
)

Set the current value for the key (first, second) to val; returns the previous value for key if one was set, or NULL if one was not.

Here is the call graph for this function:

◆ fp_pair_map_size()

int fp_pair_map_size ( const fp_pair_map_t map)

Return the number of items in map.

◆ HT_PROTOTYPE()

HT_PROTOTYPE ( HT_GENERATE2(  fp_pair_map_impl,
HT_GENERATE2(  fp_pair_map_entry_s,
HT_GENERATE2(  node,
HT_GENERATE2(  fp_pair_map_entry_hash,
HT_GENERATE2(  fp_pair_map_entries_eq 
)

Constructor to create a new empty map from fp_pair_t to void *