tor  0.4.2.1-alpha-dev
Macros | Functions
btrack_orconn_maps.c File Reference
#include <stdbool.h>
#include "core/or/or.h"
#include "ht.h"
#include "siphash.h"
#include "feature/control/btrack_orconn.h"
#include "feature/control/btrack_orconn_maps.h"
#include "lib/log/log.h"

Go to the source code of this file.

Functions

static unsigned int bto_gid_hash_ (bt_orconn_t *elm)
 
static int bto_gid_eq_ (bt_orconn_t *a, bt_orconn_t *b)
 
static unsigned int bto_chan_hash_ (bt_orconn_t *elm)
 
static int bto_chan_eq_ (bt_orconn_t *a, bt_orconn_t *b)
 
 HT_HEAD (bto_gid_ht, bt_orconn_t)
 
 HT_GENERATE2 (bto_gid_ht, bt_orconn_t, node, bto_gid_hash_, bto_gid_eq_, 0.6, tor_reallocarray_, tor_free_) static struct bto_gid_ht *bto_gid_map
 
 HT_HEAD (bto_chan_ht, bt_orconn_t)
 
 HT_GENERATE2 (bto_chan_ht, bt_orconn_t, chan_node, bto_chan_hash_, bto_chan_eq_, 0.6, tor_reallocarray_, tor_free_) static struct bto_chan_ht *bto_chan_map
 
static void bto_gid_clear_map (void)
 
static void bto_chan_clear_map (void)
 
void bto_delete (uint64_t gid)
 
static bt_orconn_t * bto_update (bt_orconn_t *bto, const bt_orconn_t *key)
 
static bt_orconn_t * bto_new (const bt_orconn_t *key)
 
bt_orconn_t * bto_find_or_new (uint64_t gid, uint64_t chan)
 
void bto_init_maps (void)
 
void bto_clear_maps (void)
 

Detailed Description

Hash map implementation for btrack_orconn.c.

These functions manipulate the hash maps that contain bt_orconn objects.

Definition in file btrack_orconn_maps.c.

Function Documentation

◆ bto_chan_clear_map()

static void bto_chan_clear_map ( void  )
static

Clear the chan ID hash map, freeing any bt_orconn_t objects that become unreferenced

Definition at line 88 of file btrack_orconn_maps.c.

References tor_free.

Referenced by bto_clear_maps().

◆ bto_clear_maps()

void bto_clear_maps ( void  )

Clear the hash maps, freeing all associated storage

Definition at line 219 of file btrack_orconn_maps.c.

References bto_chan_clear_map(), and bto_gid_clear_map().

Referenced by btrack_orconn_fini().

◆ bto_delete()

void bto_delete ( uint64_t  gid)

Delete a bt_orconn from the hash maps by GID

Definition at line 109 of file btrack_orconn_maps.c.

◆ bto_find_or_new()

bt_orconn_t* bto_find_or_new ( uint64_t  gid,
uint64_t  chan 
)

Insert a new bt_orconn with the given GID and chan ID, or update the GID and chan ID if one already exists.

Return the found or allocated bt_orconn.

Definition at line 188 of file btrack_orconn_maps.c.

References bto_new(), bto_update(), and tor_assert().

Referenced by bto_chan_rcvr(), and bto_state_rcvr().

◆ bto_gid_clear_map()

static void bto_gid_clear_map ( void  )
static

Clear the GID hash map, freeing any bt_orconn_t objects that become unreferenced

Definition at line 66 of file btrack_orconn_maps.c.

References tor_free.

Referenced by bto_clear_maps().

◆ bto_init_maps()

void bto_init_maps ( void  )

Initialize the hash maps

Definition at line 209 of file btrack_orconn_maps.c.

Referenced by btrack_orconn_init().

◆ bto_new()

static bt_orconn_t* bto_new ( const bt_orconn_t *  key)
static

Helper for bto_find_or_new()

Definition at line 162 of file btrack_orconn_maps.c.

Referenced by bto_find_or_new().

◆ bto_update()

static bt_orconn_t* bto_update ( bt_orconn_t *  bto,
const bt_orconn_t *  key 
)
static

Helper for bto_find_or_new().

Update GID and chan ID of an existing bt_orconn object if needed, given a search key previously used within bto_find_or_new().

Definition at line 137 of file btrack_orconn_maps.c.

References tor_assert().

Referenced by bto_find_or_new().