tor  0.4.2.0-alpha-dev
Data Structures | Macros | Typedefs | Functions | Variables
btrack_circuit.c File Reference
#include "core/or/or.h"
#include "core/or/ocirc_event.h"
#include "feature/control/btrack_circuit.h"
#include "feature/control/control.h"
#include "lib/log/log.h"

Go to the source code of this file.

Data Structures

struct  btc_best_t
 

Macros

#define N_CIRC_EVENT_ORDER   (sizeof(circ_event_order) / sizeof(circ_event_order[0]))
 

Typedefs

typedef struct btc_best_t btc_best_t
 

Functions

static void btc_reset_bests (void)
 
static bool btc_state_better (int state, const btc_best_t *best)
 
static bool btc_evtype_better (int state, const btc_best_t *best)
 
static bool btc_update_state (const ocirc_state_msg_t *msg, btc_best_t *best, const char *type)
 
static bool btc_update_evtype (const ocirc_cevent_msg_t *msg, btc_best_t *best, const char *type)
 
 DECLARE_SUBSCRIBE (ocirc_state, btc_state_rcvr)
 
 DECLARE_SUBSCRIBE (ocirc_cevent, btc_cevent_rcvr)
 
 DECLARE_SUBSCRIBE (ocirc_chan, btc_chan_rcvr)
 
static void btc_state_rcvr (const msg_t *msg, const ocirc_state_msg_t *arg)
 
static void btc_cevent_rcvr (const msg_t *msg, const ocirc_cevent_msg_t *arg)
 
static void btc_chan_rcvr (const msg_t *msg, const ocirc_chan_msg_t *arg)
 
int btrack_circ_add_pubsub (pubsub_connector_t *connector)
 
void btrack_circ_fini (void)
 

Variables

static btc_best_t best_any_state = { 0, -1 }
 
static btc_best_t best_ap_state = { 0, -1 }
 
static btc_best_t best_any_evtype = { 0, -1 }
 
static btc_best_t best_ap_evtype = { 0, -1 }
 
static int circ_event_order []
 

Detailed Description

Bootstrap tracker for origin circuits.

Track state changes of origin circuits, as published by the circuit subsystem.

Definition in file btrack_circuit.c.

Typedef Documentation

◆ btc_best_t

typedef struct btc_best_t btc_best_t

Pair of a best origin circuit GID with its state or status

Function Documentation

◆ btc_evtype_better()

static bool btc_evtype_better ( int  state,
const btc_best_t best 
)
static

True if state is a "better" origin circuit event status than best->val

Definition at line 72 of file btrack_circuit.c.

References tor_assert().

◆ btc_reset_bests()

static void btc_reset_bests ( void  )
static

Reset cached "best" values

Definition at line 37 of file btrack_circuit.c.

References best_any_evtype, best_any_state, best_ap_evtype, and best_ap_state.

◆ btc_state_better()

static bool btc_state_better ( int  state,
const btc_best_t best 
)
static

True if state is a "better" origin circuit state than best->val

Definition at line 47 of file btrack_circuit.c.

Variable Documentation

◆ best_any_evtype

btc_best_t best_any_evtype = { 0, -1 }
static

GID and status of the best origin circuit we've seen so far

Definition at line 31 of file btrack_circuit.c.

Referenced by btc_reset_bests().

◆ best_any_state

btc_best_t best_any_state = { 0, -1 }
static

GID and state of the best origin circuit we've seen so far

Definition at line 27 of file btrack_circuit.c.

Referenced by btc_reset_bests().

◆ best_ap_evtype

btc_best_t best_ap_evtype = { 0, -1 }
static

GID and status of the best application circuit we've seen so far

Definition at line 33 of file btrack_circuit.c.

Referenced by btc_reset_bests().

◆ best_ap_state

btc_best_t best_ap_state = { 0, -1 }
static

GID and state of the best application circuit we've seen so far

Definition at line 29 of file btrack_circuit.c.

Referenced by btc_reset_bests().

◆ circ_event_order

int circ_event_order[]
static
Initial value:
= {
[CIRC_EVENT_FAILED] = -1,
[CIRC_EVENT_CLOSED] = -1,
[CIRC_EVENT_LAUNCHED] = 1,
[CIRC_EVENT_EXTENDED] = 2,
[CIRC_EVENT_BUILT] = 3,
}

Definine an ordering on circuit status events

The CIRC_EVENT_ constants aren't sorted in a useful order, so this array helps to decode them. This approach depends on the statuses being nonnegative and dense.

Definition at line 59 of file btrack_circuit.c.