tor  0.4.0.0-alpha-dev
Data Structures | Macros | Typedefs | Functions
circuitmux.h File Reference
#include "core/or/or.h"
#include "lib/testsupport/testsupport.h"

Go to the source code of this file.

Data Structures

struct  circuitmux_policy_s
 
struct  circuitmux_policy_data_s
 
struct  circuitmux_policy_circ_data_s
 

Macros

#define TO_CMUX_POL_DATA(x)   (&((x)->base_))
 
#define TO_CMUX_POL_CIRC_DATA(x)   (&((x)->base_))
 
#define circuitmux_free(cmux)   FREE_AND_NULL(circuitmux_t, circuitmux_free_, (cmux))
 

Typedefs

typedef struct circuitmux_policy_s circuitmux_policy_t
 
typedef struct circuitmux_policy_data_s circuitmux_policy_data_t
 
typedef struct circuitmux_policy_circ_data_s circuitmux_policy_circ_data_t
 

Functions

void circuitmux_assert_okay (circuitmux_t *cmux)
 
circuitmux_tcircuitmux_alloc (void)
 
void circuitmux_detach_all_circuits (circuitmux_t *cmux, smartlist_t *detached_out)
 
void circuitmux_free_ (circuitmux_t *cmux)
 
void circuitmux_clear_policy (circuitmux_t *cmux)
 
 MOCK_DECL (const circuitmux_policy_t *, circuitmux_get_policy,(circuitmux_t *cmux))
 
void circuitmux_set_policy (circuitmux_t *cmux, const circuitmux_policy_t *pol)
 
cell_direction_t circuitmux_attached_circuit_direction (circuitmux_t *cmux, circuit_t *circ)
 
int circuitmux_is_circuit_attached (circuitmux_t *cmux, circuit_t *circ)
 
int circuitmux_is_circuit_active (circuitmux_t *cmux, circuit_t *circ)
 
unsigned int circuitmux_num_cells_for_circuit (circuitmux_t *cmux, circuit_t *circ)
 
 MOCK_DECL (unsigned int, circuitmux_num_cells,(circuitmux_t *cmux))
 
unsigned int circuitmux_num_circuits (circuitmux_t *cmux)
 
unsigned int circuitmux_num_active_circuits (circuitmux_t *cmux)
 
int64_t circuitmux_count_queued_destroy_cells (const channel_t *chan, const circuitmux_t *cmux)
 
circuit_tcircuitmux_get_first_active_circuit (circuitmux_t *cmux, destroy_cell_queue_t **destroy_queue_out)
 
void circuitmux_notify_xmit_cells (circuitmux_t *cmux, circuit_t *circ, unsigned int n_cells)
 
void circuitmux_notify_xmit_destroy (circuitmux_t *cmux)
 
 MOCK_DECL (void, circuitmux_attach_circuit,(circuitmux_t *cmux, circuit_t *circ, cell_direction_t direction))
 
 MOCK_DECL (void, circuitmux_detach_circuit,(circuitmux_t *cmux, circuit_t *circ))
 
void circuitmux_clear_num_cells (circuitmux_t *cmux, circuit_t *circ)
 
void circuitmux_set_num_cells (circuitmux_t *cmux, circuit_t *circ, unsigned int n_cells)
 
void circuitmux_append_destroy_cell (channel_t *chan, circuitmux_t *cmux, circid_t circ_id, uint8_t reason)
 
void circuitmux_mark_destroyed_circids_usable (circuitmux_t *cmux, channel_t *chan)
 
 MOCK_DECL (int, circuitmux_compare_muxes,(circuitmux_t *cmux_1, circuitmux_t *cmux_2))
 

Detailed Description

Header file for circuitmux.c.

Definition in file circuitmux.h.

Macro Definition Documentation

◆ TO_CMUX_POL_CIRC_DATA

#define TO_CMUX_POL_CIRC_DATA (   x)    (&((x)->base_))

Convert a circuitmux_policy_circ_data_t subtype to a circuitmux_policy_circ_data_t.

Definition at line 98 of file circuitmux.h.

◆ TO_CMUX_POL_DATA

#define TO_CMUX_POL_DATA (   x)    (&((x)->base_))

Convert a circuitmux_policy_data_t subtype to a circuitmux_policy_data_t.

Definition at line 91 of file circuitmux.h.

Function Documentation

◆ circuitmux_attached_circuit_direction()

cell_direction_t circuitmux_attached_circuit_direction ( circuitmux_t cmux,
circuit_t circ 
)

Query the direction of an attached circuit

Definition at line 607 of file circuitmux.c.

References circuitmux_find_map_entry(), and tor_assert().

◆ circuitmux_clear_num_cells()

void circuitmux_clear_num_cells ( circuitmux_t cmux,
circuit_t circ 
)

Clear the cell counter for a circuit on a circuitmux

Definition at line 1061 of file circuitmux.c.

References circuitmux_set_num_cells().

◆ circuitmux_clear_policy()

void circuitmux_clear_policy ( circuitmux_t cmux)

Remove any policy installed on cmux; all policy data will be freed and cmux behavior will revert to the built-in round-robin active_circuits mechanism.

Definition at line 460 of file circuitmux.c.

References circuitmux_set_policy(), and tor_assert().

◆ circuitmux_detach_all_circuits()

void circuitmux_detach_all_circuits ( circuitmux_t cmux,
smartlist_t detached_out 
)

Detach all circuits from a circuitmux (use before circuitmux_free())

If detached_out is non-NULL, add every detached circuit_t to detached_out.

Definition at line 263 of file circuitmux.c.

References tor_assert().

Referenced by channel_unlink_all_circuits().

◆ circuitmux_free_()

void circuitmux_free_ ( circuitmux_t cmux)

Free a circuitmux_t; the circuits must be detached first with circuitmux_detach_all_circuits().

Definition at line 396 of file circuitmux.c.

References circuitmux_s::destroy_cell_queue, circuitmux_s::destroy_ctr, global_destroy_ctr, destroy_cell_queue_t::n, tor_assert(), and tor_free.

◆ circuitmux_get_first_active_circuit()

circuit_t* circuitmux_get_first_active_circuit ( circuitmux_t cmux,
destroy_cell_queue_t **  destroy_queue_out 
)

Pick a circuit to send from, using the active circuits list or a circuitmux policy if one is available. This is called from channel.c.

If we would rather send a destroy cell, return NULL and set *destroy_queue_out to the destroy queue.

If we have nothing to send, set *destroy_queue_out to NULL and return NULL.

Definition at line 1134 of file circuitmux.c.

References circuitmux_s::destroy_cell_queue, circuitmux_s::last_cell_was_destroy, destroy_cell_queue_t::n, and tor_assert().

Referenced by MOCK_IMPL().

◆ circuitmux_is_circuit_active()

int circuitmux_is_circuit_active ( circuitmux_t cmux,
circuit_t circ 
)

Query whether a circuit is active on a circuitmux

Definition at line 700 of file circuitmux.c.

References circuitmux_find_map_entry(), and tor_assert().

◆ circuitmux_is_circuit_attached()

int circuitmux_is_circuit_attached ( circuitmux_t cmux,
circuit_t circ 
)

Query whether a circuit is attached to a circuitmux

Definition at line 685 of file circuitmux.c.

References circuitmux_find_map_entry().

Referenced by circuit_clear_cell_queue(), and update_circuit_on_cmux_().

◆ circuitmux_mark_destroyed_circids_usable()

void circuitmux_mark_destroyed_circids_usable ( circuitmux_t cmux,
channel_t chan 
)

Reclaim all circuit IDs currently marked as unusable on chan because of pending destroy cells in cmux.

This function must be called AFTER circuits are unlinked from the (channel, circuid-id) map with circuit_unlink_all_from_channel(), but before calling circuitmux_free().

Definition at line 382 of file circuitmux.c.

References channel_mark_circid_usable(), and circuitmux_s::destroy_cell_queue.

◆ circuitmux_notify_xmit_cells()

void circuitmux_notify_xmit_cells ( circuitmux_t cmux,
circuit_t circ,
unsigned int  n_cells 
)

Notify the circuitmux that cells have been sent on a circuit; this is called from channel.c.

Definition at line 1177 of file circuitmux.c.

References circuitmux_find_map_entry(), circuitmux_make_circuit_inactive(), and tor_assert().

◆ circuitmux_notify_xmit_destroy()

void circuitmux_notify_xmit_destroy ( circuitmux_t cmux)

Notify the circuitmux that a destroy was sent, so we can update the counter.

Definition at line 1237 of file circuitmux.c.

References circuitmux_s::destroy_ctr, global_destroy_ctr, and tor_assert().

Referenced by MOCK_IMPL().

◆ circuitmux_num_active_circuits()

unsigned int circuitmux_num_active_circuits ( circuitmux_t cmux)

Query total number of circuits active on a circuitmux

Definition at line 760 of file circuitmux.c.

References tor_assert().

◆ circuitmux_num_cells_for_circuit()

unsigned int circuitmux_num_cells_for_circuit ( circuitmux_t cmux,
circuit_t circ 
)

Query number of available cells for a circuit on a circuitmux

Definition at line 724 of file circuitmux.c.

References circuitmux_find_map_entry(), and tor_assert().

◆ circuitmux_num_circuits()

unsigned int circuitmux_num_circuits ( circuitmux_t cmux)

Query total number of circuits attached to a circuitmux

Definition at line 772 of file circuitmux.c.

References tor_assert().

◆ circuitmux_set_num_cells()

void circuitmux_set_num_cells ( circuitmux_t cmux,
circuit_t circ,
unsigned int  n_cells 
)

Set the cell counter for a circuit on a circuitmux

Definition at line 1072 of file circuitmux.c.

References circuitmux_find_map_entry(), circuitmux_make_circuit_active(), circuitmux_make_circuit_inactive(), and tor_assert().

Referenced by circuitmux_clear_num_cells().

◆ circuitmux_set_policy()

void circuitmux_set_policy ( circuitmux_t cmux,
const circuitmux_policy_t pol 
)

Set policy; allocate for new policy, detach all circuits from old policy if any, attach them to new policy, and free old policy data.

Definition at line 486 of file circuitmux.c.

References channel_find_by_global_id(), circuit_get_by_circid_channel_even_if_marked(), and tor_assert().

Referenced by circuitmux_clear_policy().