circpad: Rename circpad_machine_state_t to circpad_machine_runtime_t.

The name of circpad_machine_state_t was very confusing since it was conflicting
with circpad_state_t and circpad_circuit_state_t.

Right now here is the current meaning of these structs:

      circpad_state_t -> A state of the state machine.
      circpad_machine_runtime_t -> The current mutable runtime info of the state machine.
      circpad_circuit_state_t -> Circuit conditions based on which we should apply a machine to the circuit
This commit is contained in:
George Kadianakis 2019-03-13 15:24:04 +02:00 committed by teor
parent 846d379b50
commit 5729160253
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A
4 changed files with 69 additions and 69 deletions

View File

@ -13,7 +13,7 @@
struct hs_token_t; struct hs_token_t;
struct circpad_machine_spec_t; struct circpad_machine_spec_t;
struct circpad_machine_state_t; struct circpad_machine_runtime_t;
/** Number of padding state machines on a circuit. */ /** Number of padding state machines on a circuit. */
#define CIRCPAD_MAX_MACHINES (2) #define CIRCPAD_MAX_MACHINES (2)
@ -193,8 +193,8 @@ struct circuit_t {
* and we can have up to CIRCPAD_MAX_MACHINES such machines. */ * and we can have up to CIRCPAD_MAX_MACHINES such machines. */
const struct circpad_machine_spec_t *padding_machine[CIRCPAD_MAX_MACHINES]; const struct circpad_machine_spec_t *padding_machine[CIRCPAD_MAX_MACHINES];
/** Adaptive Padding machine info for above machines. This is the /** Adaptive Padding machine runtime info for above machines. This is
* per-circuit mutable information, such as the current state and * the per-circuit mutable information, such as the current state and
* histogram token counts. Some of it is optional (aka NULL). * histogram token counts. Some of it is optional (aka NULL).
* If a machine is being shut down, these indexes can be NULL * If a machine is being shut down, these indexes can be NULL
* without the corresponding padding_machine being NULL, while we * without the corresponding padding_machine being NULL, while we
@ -202,7 +202,7 @@ struct circuit_t {
* *
* Each element of this array corresponds to a different padding machine, * Each element of this array corresponds to a different padding machine,
* and we can have up to CIRCPAD_MAX_MACHINES such machines. */ * and we can have up to CIRCPAD_MAX_MACHINES such machines. */
struct circpad_machine_state_t *padding_info[CIRCPAD_MAX_MACHINES]; struct circpad_machine_runtime_t *padding_info[CIRCPAD_MAX_MACHINES];
}; };
#endif #endif

View File

@ -23,7 +23,7 @@
* As specified by prop#254, clients can negotiate padding with relays by using * As specified by prop#254, clients can negotiate padding with relays by using
* PADDING_NEGOTIATE cells. After successful padding negotiation, padding * PADDING_NEGOTIATE cells. After successful padding negotiation, padding
* machines are assigned to the circuit in their mutable form as a * machines are assigned to the circuit in their mutable form as a
* circpad_machine_state_t. * circpad_machine_runtime_t.
* *
* Each state of a padding state machine can be either: * Each state of a padding state machine can be either:
* - A histogram that specifies inter-arrival padding delays. * - A histogram that specifies inter-arrival padding delays.
@ -188,11 +188,11 @@ circpad_circuit_free_all_machineinfos(circuit_t *circ)
/** /**
* Allocate a new mutable machineinfo structure. * Allocate a new mutable machineinfo structure.
*/ */
STATIC circpad_machine_state_t * STATIC circpad_machine_runtime_t *
circpad_circuit_machineinfo_new(circuit_t *on_circ, int machine_index) circpad_circuit_machineinfo_new(circuit_t *on_circ, int machine_index)
{ {
circpad_machine_state_t *mi = circpad_machine_runtime_t *mi =
tor_malloc_zero(sizeof(circpad_machine_state_t)); tor_malloc_zero(sizeof(circpad_machine_runtime_t));
mi->machine_index = machine_index; mi->machine_index = machine_index;
mi->on_circ = on_circ; mi->on_circ = on_circ;
@ -207,7 +207,7 @@ circpad_circuit_machineinfo_new(circuit_t *on_circ, int machine_index)
* invalid state. * invalid state.
*/ */
STATIC const circpad_state_t * STATIC const circpad_state_t *
circpad_machine_current_state(const circpad_machine_state_t *mi) circpad_machine_current_state(const circpad_machine_runtime_t *mi)
{ {
const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi); const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi);
@ -234,7 +234,7 @@ circpad_machine_current_state(const circpad_machine_state_t *mi)
* CIRCPAD_DELAY_INFINITE is returned. * CIRCPAD_DELAY_INFINITE is returned.
*/ */
STATIC circpad_delay_t STATIC circpad_delay_t
circpad_histogram_bin_to_usec(const circpad_machine_state_t *mi, circpad_histogram_bin_to_usec(const circpad_machine_runtime_t *mi,
circpad_hist_index_t bin) circpad_hist_index_t bin)
{ {
const circpad_state_t *state = circpad_machine_current_state(mi); const circpad_state_t *state = circpad_machine_current_state(mi);
@ -265,7 +265,7 @@ circpad_histogram_bin_to_usec(const circpad_machine_state_t *mi,
* (The upper bound is included in the bin.) * (The upper bound is included in the bin.)
*/ */
STATIC circpad_delay_t STATIC circpad_delay_t
histogram_get_bin_upper_bound(const circpad_machine_state_t *mi, histogram_get_bin_upper_bound(const circpad_machine_runtime_t *mi,
circpad_hist_index_t bin) circpad_hist_index_t bin)
{ {
return circpad_histogram_bin_to_usec(mi, bin+1) - 1; return circpad_histogram_bin_to_usec(mi, bin+1) - 1;
@ -273,7 +273,7 @@ histogram_get_bin_upper_bound(const circpad_machine_state_t *mi,
/** Return the midpoint of the histogram bin <b>bin_index</b>. */ /** Return the midpoint of the histogram bin <b>bin_index</b>. */
static circpad_delay_t static circpad_delay_t
circpad_get_histogram_bin_midpoint(const circpad_machine_state_t *mi, circpad_get_histogram_bin_midpoint(const circpad_machine_runtime_t *mi,
int bin_index) int bin_index)
{ {
circpad_delay_t left_bound = circpad_histogram_bin_to_usec(mi, bin_index); circpad_delay_t left_bound = circpad_histogram_bin_to_usec(mi, bin_index);
@ -291,7 +291,7 @@ circpad_get_histogram_bin_midpoint(const circpad_machine_state_t *mi,
* the highest non-infinity bin, that bin index will be returned. * the highest non-infinity bin, that bin index will be returned.
*/ */
STATIC circpad_hist_index_t STATIC circpad_hist_index_t
circpad_histogram_usec_to_bin(const circpad_machine_state_t *mi, circpad_histogram_usec_to_bin(const circpad_machine_runtime_t *mi,
circpad_delay_t usec) circpad_delay_t usec)
{ {
const circpad_state_t *state = circpad_machine_current_state(mi); const circpad_state_t *state = circpad_machine_current_state(mi);
@ -331,7 +331,7 @@ circpad_histogram_usec_to_bin(const circpad_machine_state_t *mi,
* Called after a state transition, or if the bins are empty. * Called after a state transition, or if the bins are empty.
*/ */
STATIC void STATIC void
circpad_machine_setup_tokens(circpad_machine_state_t *mi) circpad_machine_setup_tokens(circpad_machine_runtime_t *mi)
{ {
const circpad_state_t *state = circpad_machine_current_state(mi); const circpad_state_t *state = circpad_machine_current_state(mi);
@ -363,7 +363,7 @@ circpad_machine_setup_tokens(circpad_machine_state_t *mi)
* Choose a length for this state (in cells), if specified. * Choose a length for this state (in cells), if specified.
*/ */
static void static void
circpad_choose_state_length(circpad_machine_state_t *mi) circpad_choose_state_length(circpad_machine_runtime_t *mi)
{ {
const circpad_state_t *state = circpad_machine_current_state(mi); const circpad_state_t *state = circpad_machine_current_state(mi);
double length; double length;
@ -413,7 +413,7 @@ circpad_distribution_sample_iat_delay(const circpad_state_t *state,
* that bin's [start,end) time range. * that bin's [start,end) time range.
*/ */
STATIC circpad_delay_t STATIC circpad_delay_t
circpad_machine_sample_delay(circpad_machine_state_t *mi) circpad_machine_sample_delay(circpad_machine_runtime_t *mi)
{ {
const circpad_state_t *state = circpad_machine_current_state(mi); const circpad_state_t *state = circpad_machine_current_state(mi);
const circpad_hist_token_t *histogram = NULL; const circpad_hist_token_t *histogram = NULL;
@ -601,7 +601,7 @@ circpad_distribution_sample(circpad_distribution_t dist)
* greater than the target, and that has tokens remaining. * greater than the target, and that has tokens remaining.
*/ */
static circpad_hist_index_t static circpad_hist_index_t
circpad_machine_first_higher_index(const circpad_machine_state_t *mi, circpad_machine_first_higher_index(const circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec) circpad_delay_t target_bin_usec)
{ {
circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi, circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi,
@ -623,7 +623,7 @@ circpad_machine_first_higher_index(const circpad_machine_state_t *mi,
* <b>target_bin_usec</b>, and that still has tokens remaining. * <b>target_bin_usec</b>, and that still has tokens remaining.
*/ */
static circpad_hist_index_t static circpad_hist_index_t
circpad_machine_first_lower_index(const circpad_machine_state_t *mi, circpad_machine_first_lower_index(const circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec) circpad_delay_t target_bin_usec)
{ {
circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi, circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi,
@ -644,7 +644,7 @@ circpad_machine_first_lower_index(const circpad_machine_state_t *mi,
* greater than the target. * greater than the target.
*/ */
STATIC void STATIC void
circpad_machine_remove_higher_token(circpad_machine_state_t *mi, circpad_machine_remove_higher_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec) circpad_delay_t target_bin_usec)
{ {
/* We need to remove the token from the first bin /* We need to remove the token from the first bin
@ -665,7 +665,7 @@ circpad_machine_remove_higher_token(circpad_machine_state_t *mi,
* lower than the target. * lower than the target.
*/ */
STATIC void STATIC void
circpad_machine_remove_lower_token(circpad_machine_state_t *mi, circpad_machine_remove_lower_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec) circpad_delay_t target_bin_usec)
{ {
circpad_hist_index_t bin = circpad_machine_first_lower_index(mi, circpad_hist_index_t bin = circpad_machine_first_lower_index(mi,
@ -694,7 +694,7 @@ circpad_machine_remove_lower_token(circpad_machine_state_t *mi,
* If it is false, use bin index distance only. * If it is false, use bin index distance only.
*/ */
STATIC void STATIC void
circpad_machine_remove_closest_token(circpad_machine_state_t *mi, circpad_machine_remove_closest_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec, circpad_delay_t target_bin_usec,
bool use_usec) bool use_usec)
{ {
@ -776,7 +776,7 @@ circpad_machine_remove_closest_token(circpad_machine_state_t *mi,
* If it is empty, do nothing. * If it is empty, do nothing.
*/ */
static void static void
circpad_machine_remove_exact(circpad_machine_state_t *mi, circpad_machine_remove_exact(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_usec) circpad_delay_t target_bin_usec)
{ {
circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi, circpad_hist_index_t bin = circpad_histogram_usec_to_bin(mi,
@ -793,7 +793,7 @@ circpad_machine_remove_exact(circpad_machine_state_t *mi,
* otherwise returns 0. * otherwise returns 0.
*/ */
static circpad_decision_t static circpad_decision_t
check_machine_token_supply(circpad_machine_state_t *mi) check_machine_token_supply(circpad_machine_runtime_t *mi)
{ {
uint32_t histogram_total_tokens = 0; uint32_t histogram_total_tokens = 0;
@ -833,7 +833,7 @@ check_machine_token_supply(circpad_machine_state_t *mi)
* Returns 1 if we transition states, 0 otherwise. * Returns 1 if we transition states, 0 otherwise.
*/ */
STATIC circpad_decision_t STATIC circpad_decision_t
circpad_machine_remove_token(circpad_machine_state_t *mi) circpad_machine_remove_token(circpad_machine_runtime_t *mi)
{ {
const circpad_state_t *state = NULL; const circpad_state_t *state = NULL;
circpad_time_t current_time; circpad_time_t current_time;
@ -960,7 +960,7 @@ circpad_send_command_to_hop,(origin_circuit_t *circ, uint8_t hopnum,
* CIRCPAD_STATE_CHANGED. Otherwise return CIRCPAD_STATE_UNCHANGED. * CIRCPAD_STATE_CHANGED. Otherwise return CIRCPAD_STATE_UNCHANGED.
*/ */
circpad_decision_t circpad_decision_t
circpad_send_padding_cell_for_callback(circpad_machine_state_t *mi) circpad_send_padding_cell_for_callback(circpad_machine_runtime_t *mi)
{ {
circuit_t *circ = mi->on_circ; circuit_t *circ = mi->on_circ;
int machine_idx = mi->machine_index; int machine_idx = mi->machine_index;
@ -1046,7 +1046,7 @@ circpad_send_padding_cell_for_callback(circpad_machine_state_t *mi)
/** /**
* Tor-timer compatible callback that tells us to send a padding cell. * Tor-timer compatible callback that tells us to send a padding cell.
* *
* Timers are associated with circpad_machine_state_t's. When the machineinfo * Timers are associated with circpad_machine_runtime_t's. When the machineinfo
* is freed on a circuit, the timers are cancelled. Since the lifetime * is freed on a circuit, the timers are cancelled. Since the lifetime
* of machineinfo is always longer than the timers, handles are not * of machineinfo is always longer than the timers, handles are not
* needed. * needed.
@ -1055,7 +1055,7 @@ static void
circpad_send_padding_callback(tor_timer_t *timer, void *args, circpad_send_padding_callback(tor_timer_t *timer, void *args,
const struct monotime_t *time) const struct monotime_t *time)
{ {
circpad_machine_state_t *mi = ((circpad_machine_state_t*)args); circpad_machine_runtime_t *mi = ((circpad_machine_runtime_t*)args);
(void)timer; (void)time; (void)timer; (void)time;
if (mi && mi->on_circ) { if (mi && mi->on_circ) {
@ -1105,7 +1105,7 @@ circpad_new_consensus_params(const networkstatus_t *ns)
* Returns 1 if limits are set and we've hit them. Otherwise returns 0. * Returns 1 if limits are set and we've hit them. Otherwise returns 0.
*/ */
STATIC bool STATIC bool
circpad_machine_reached_padding_limit(circpad_machine_state_t *mi) circpad_machine_reached_padding_limit(circpad_machine_runtime_t *mi)
{ {
const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi); const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi);
@ -1153,7 +1153,7 @@ circpad_machine_reached_padding_limit(circpad_machine_state_t *mi)
* 0 otherwise. * 0 otherwise.
*/ */
MOCK_IMPL(circpad_decision_t, MOCK_IMPL(circpad_decision_t,
circpad_machine_schedule_padding,(circpad_machine_state_t *mi)) circpad_machine_schedule_padding,(circpad_machine_runtime_t *mi))
{ {
circpad_delay_t in_usec = 0; circpad_delay_t in_usec = 0;
struct timeval timeout; struct timeval timeout;
@ -1249,7 +1249,7 @@ circpad_machine_schedule_padding,(circpad_machine_state_t *mi))
* not access it. * not access it.
*/ */
static void static void
circpad_machine_spec_transitioned_to_end(circpad_machine_state_t *mi) circpad_machine_spec_transitioned_to_end(circpad_machine_runtime_t *mi)
{ {
const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi); const circpad_machine_spec_t *machine = CIRCPAD_GET_MACHINE(mi);
@ -1299,7 +1299,7 @@ circpad_machine_spec_transitioned_to_end(circpad_machine_state_t *mi)
* Returns 1 if we transition states, 0 otherwise. * Returns 1 if we transition states, 0 otherwise.
*/ */
MOCK_IMPL(circpad_decision_t, MOCK_IMPL(circpad_decision_t,
circpad_machine_spec_transition,(circpad_machine_state_t *mi, circpad_machine_spec_transition,(circpad_machine_runtime_t *mi,
circpad_event_t event)) circpad_event_t event))
{ {
const circpad_state_t *state = const circpad_state_t *state =
@ -1380,7 +1380,7 @@ circpad_machine_spec_transition,(circpad_machine_state_t *mi,
*/ */
static void static void
circpad_estimate_circ_rtt_on_received(circuit_t *circ, circpad_estimate_circ_rtt_on_received(circuit_t *circ,
circpad_machine_state_t *mi) circpad_machine_runtime_t *mi)
{ {
/* Origin circuits don't estimate RTT. They could do it easily enough, /* Origin circuits don't estimate RTT. They could do it easily enough,
* but they have no reason to use it in any delay calculations. */ * but they have no reason to use it in any delay calculations. */
@ -1427,7 +1427,7 @@ circpad_estimate_circ_rtt_on_received(circuit_t *circ,
*/ */
static void static void
circpad_estimate_circ_rtt_on_send(circuit_t *circ, circpad_estimate_circ_rtt_on_send(circuit_t *circ,
circpad_machine_state_t *mi) circpad_machine_runtime_t *mi)
{ {
/* Origin circuits don't estimate RTT. They could do it easily enough, /* Origin circuits don't estimate RTT. They could do it easily enough,
* but they have no reason to use it in any delay calculations. */ * but they have no reason to use it in any delay calculations. */
@ -1572,7 +1572,7 @@ circpad_cell_event_padding_received(circuit_t *on_circ)
* Return 1 if we decide to transition, 0 otherwise. * Return 1 if we decide to transition, 0 otherwise.
*/ */
circpad_decision_t circpad_decision_t
circpad_internal_event_infinity(circpad_machine_state_t *mi) circpad_internal_event_infinity(circpad_machine_runtime_t *mi)
{ {
return circpad_machine_spec_transition(mi, CIRCPAD_EVENT_INFINITY); return circpad_machine_spec_transition(mi, CIRCPAD_EVENT_INFINITY);
} }
@ -1586,7 +1586,7 @@ circpad_internal_event_infinity(circpad_machine_state_t *mi)
* Return 1 if we decide to transition, 0 otherwise. * Return 1 if we decide to transition, 0 otherwise.
*/ */
circpad_decision_t circpad_decision_t
circpad_internal_event_bins_empty(circpad_machine_state_t *mi) circpad_internal_event_bins_empty(circpad_machine_runtime_t *mi)
{ {
if (circpad_machine_spec_transition(mi, CIRCPAD_EVENT_BINS_EMPTY) if (circpad_machine_spec_transition(mi, CIRCPAD_EVENT_BINS_EMPTY)
== CIRCPAD_STATE_CHANGED) { == CIRCPAD_STATE_CHANGED) {
@ -1605,7 +1605,7 @@ circpad_internal_event_bins_empty(circpad_machine_state_t *mi)
* Return 1 if we decide to transition, 0 otherwise. * Return 1 if we decide to transition, 0 otherwise.
*/ */
circpad_decision_t circpad_decision_t
circpad_internal_event_state_length_up(circpad_machine_state_t *mi) circpad_internal_event_state_length_up(circpad_machine_runtime_t *mi)
{ {
return circpad_machine_spec_transition(mi, CIRCPAD_EVENT_LENGTH_COUNT); return circpad_machine_spec_transition(mi, CIRCPAD_EVENT_LENGTH_COUNT);
} }

View File

@ -88,7 +88,7 @@ typedef uint32_t circpad_delay_t;
/** /**
* Macro to clarify when we're checking the infinity bin. * Macro to clarify when we're checking the infinity bin.
* *
* Works with either circpad_state_t or circpad_machine_state_t * Works with either circpad_state_t or circpad_machine_runtime_t
*/ */
#define CIRCPAD_INFINITY_BIN(mi) ((mi)->histogram_len-1) #define CIRCPAD_INFINITY_BIN(mi) ((mi)->histogram_len-1)
@ -245,7 +245,7 @@ typedef uint16_t circpad_statenum_t;
* A state of a padding state machine. The information here are immutable and * A state of a padding state machine. The information here are immutable and
* represent the initial form of the state; it does not get updated as things * represent the initial form of the state; it does not get updated as things
* happen. The mutable information that gets updated in runtime are carried in * happen. The mutable information that gets updated in runtime are carried in
* a circpad_machine_state_t. * a circpad_machine_runtime_t.
* *
* This struct describes the histograms and parameters of a single * This struct describes the histograms and parameters of a single
* state in the adaptive padding machine. Instances of this struct * state in the adaptive padding machine. Instances of this struct
@ -467,7 +467,7 @@ typedef struct circpad_state_t {
* *
* XXX: Play with layout to minimize space on x64 Linux (most common relay). * XXX: Play with layout to minimize space on x64 Linux (most common relay).
*/ */
typedef struct circpad_machine_state_t { typedef struct circpad_machine_runtime_t {
/** The callback pointer for the padding callbacks. /** The callback pointer for the padding callbacks.
* *
* These timers stick around the machineinfo until the machineinfo's circuit * These timers stick around the machineinfo until the machineinfo's circuit
@ -551,7 +551,7 @@ typedef struct circpad_machine_state_t {
* CIRCPAD_MAX_MACHINES define). */ * CIRCPAD_MAX_MACHINES define). */
unsigned machine_index : 1; unsigned machine_index : 1;
} circpad_machine_state_t; } circpad_machine_runtime_t;
/** Helper macro to get an actual state machine from a machineinfo */ /** Helper macro to get an actual state machine from a machineinfo */
#define CIRCPAD_GET_MACHINE(machineinfo) \ #define CIRCPAD_GET_MACHINE(machineinfo) \
@ -629,11 +629,11 @@ void circpad_cell_event_padding_received(struct circuit_t *on_circ);
/** Internal events are events the machines send to themselves */ /** Internal events are events the machines send to themselves */
circpad_decision_t circpad_decision_t
circpad_internal_event_infinity(circpad_machine_state_t *mi); circpad_internal_event_infinity(circpad_machine_runtime_t *mi);
circpad_decision_t circpad_decision_t
circpad_internal_event_bins_empty(circpad_machine_state_t *); circpad_internal_event_bins_empty(circpad_machine_runtime_t *);
circpad_decision_t circpad_internal_event_state_length_up( circpad_decision_t circpad_internal_event_state_length_up(
circpad_machine_state_t *); circpad_machine_runtime_t *);
/** Machine creation events are events that cause us to set up or /** Machine creation events are events that cause us to set up or
* tear down padding state machines. */ * tear down padding state machines. */
@ -676,47 +676,47 @@ bool circpad_padding_negotiated(struct circuit_t *circ,
uint8_t response); uint8_t response);
MOCK_DECL(circpad_decision_t, MOCK_DECL(circpad_decision_t,
circpad_machine_schedule_padding,(circpad_machine_state_t *)); circpad_machine_schedule_padding,(circpad_machine_runtime_t *));
MOCK_DECL(circpad_decision_t, MOCK_DECL(circpad_decision_t,
circpad_machine_spec_transition, (circpad_machine_state_t *mi, circpad_machine_spec_transition, (circpad_machine_runtime_t *mi,
circpad_event_t event)); circpad_event_t event));
circpad_decision_t circpad_send_padding_cell_for_callback( circpad_decision_t circpad_send_padding_cell_for_callback(
circpad_machine_state_t *mi); circpad_machine_runtime_t *mi);
#ifdef CIRCUITPADDING_PRIVATE #ifdef CIRCUITPADDING_PRIVATE
STATIC circpad_delay_t STATIC circpad_delay_t
circpad_machine_sample_delay(circpad_machine_state_t *mi); circpad_machine_sample_delay(circpad_machine_runtime_t *mi);
STATIC bool STATIC bool
circpad_machine_reached_padding_limit(circpad_machine_state_t *mi); circpad_machine_reached_padding_limit(circpad_machine_runtime_t *mi);
STATIC STATIC
circpad_decision_t circpad_machine_remove_token(circpad_machine_state_t *mi); circpad_decision_t circpad_machine_remove_token(circpad_machine_runtime_t *mi);
STATIC circpad_delay_t STATIC circpad_delay_t
circpad_histogram_bin_to_usec(const circpad_machine_state_t *mi, circpad_histogram_bin_to_usec(const circpad_machine_runtime_t *mi,
circpad_hist_index_t bin); circpad_hist_index_t bin);
STATIC const circpad_state_t * STATIC const circpad_state_t *
circpad_machine_current_state(const circpad_machine_state_t *mi); circpad_machine_current_state(const circpad_machine_runtime_t *mi);
STATIC circpad_hist_index_t circpad_histogram_usec_to_bin( STATIC circpad_hist_index_t circpad_histogram_usec_to_bin(
const circpad_machine_state_t *mi, const circpad_machine_runtime_t *mi,
circpad_delay_t us); circpad_delay_t us);
STATIC circpad_machine_state_t *circpad_circuit_machineinfo_new( STATIC circpad_machine_runtime_t *circpad_circuit_machineinfo_new(
struct circuit_t *on_circ, struct circuit_t *on_circ,
int machine_index); int machine_index);
STATIC void circpad_machine_remove_higher_token(circpad_machine_state_t *mi, STATIC void circpad_machine_remove_higher_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_us); circpad_delay_t target_bin_us);
STATIC void circpad_machine_remove_lower_token(circpad_machine_state_t *mi, STATIC void circpad_machine_remove_lower_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_us); circpad_delay_t target_bin_us);
STATIC void circpad_machine_remove_closest_token(circpad_machine_state_t *mi, STATIC void circpad_machine_remove_closest_token(circpad_machine_runtime_t *mi,
circpad_delay_t target_bin_us, circpad_delay_t target_bin_us,
bool use_usec); bool use_usec);
STATIC void circpad_machine_setup_tokens(circpad_machine_state_t *mi); STATIC void circpad_machine_setup_tokens(circpad_machine_runtime_t *mi);
MOCK_DECL(STATIC signed_error_t, MOCK_DECL(STATIC signed_error_t,
circpad_send_command_to_hop,(struct origin_circuit_t *circ, uint8_t hopnum, circpad_send_command_to_hop,(struct origin_circuit_t *circ, uint8_t hopnum,
@ -724,7 +724,7 @@ circpad_send_command_to_hop,(struct origin_circuit_t *circ, uint8_t hopnum,
ssize_t payload_len)); ssize_t payload_len));
STATIC circpad_delay_t STATIC circpad_delay_t
histogram_get_bin_upper_bound(const circpad_machine_state_t *mi, histogram_get_bin_upper_bound(const circpad_machine_runtime_t *mi,
circpad_hist_index_t bin); circpad_hist_index_t bin);
#ifdef TOR_UNIT_TESTS #ifdef TOR_UNIT_TESTS

View File

@ -493,7 +493,7 @@ helper_create_machine_with_big_histogram(circpad_removal_t removal_strategy)
} }
static circpad_decision_t static circpad_decision_t
circpad_machine_schedule_padding_mock(circpad_machine_state_t *mi) circpad_machine_schedule_padding_mock(circpad_machine_runtime_t *mi)
{ {
(void)mi; (void)mi;
return 0; return 0;
@ -509,7 +509,7 @@ mock_monotime_absolute_usec(void)
static void static void
test_circuitpadding_token_removal_higher(void *arg) test_circuitpadding_token_removal_higher(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/* Mock it up */ /* Mock it up */
@ -614,7 +614,7 @@ test_circuitpadding_token_removal_higher(void *arg)
static void static void
test_circuitpadding_token_removal_lower(void *arg) test_circuitpadding_token_removal_lower(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/* Mock it up */ /* Mock it up */
@ -712,7 +712,7 @@ test_circuitpadding_token_removal_lower(void *arg)
static void static void
test_circuitpadding_closest_token_removal(void *arg) test_circuitpadding_closest_token_removal(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/* Mock it up */ /* Mock it up */
@ -818,7 +818,7 @@ test_circuitpadding_closest_token_removal(void *arg)
static void static void
test_circuitpadding_closest_token_removal_usec(void *arg) test_circuitpadding_closest_token_removal_usec(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/* Mock it up */ /* Mock it up */
@ -929,7 +929,7 @@ test_circuitpadding_closest_token_removal_usec(void *arg)
static void static void
test_circuitpadding_token_removal_exact(void *arg) test_circuitpadding_token_removal_exact(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/* Mock it up */ /* Mock it up */
@ -990,7 +990,7 @@ void
test_circuitpadding_tokens(void *arg) test_circuitpadding_tokens(void *arg)
{ {
const circpad_state_t *state; const circpad_state_t *state;
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
(void)arg; (void)arg;
/** Test plan: /** Test plan:
@ -2157,7 +2157,7 @@ helper_circpad_circ_distribution_machine_setup(int min, int max)
static void static void
test_circuitpadding_sample_distribution(void *arg) test_circuitpadding_sample_distribution(void *arg)
{ {
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
int n_samples; int n_samples;
int n_states; int n_states;
@ -2202,7 +2202,7 @@ test_circuitpadding_sample_distribution(void *arg)
} }
static circpad_decision_t static circpad_decision_t
circpad_machine_spec_transition_mock(circpad_machine_state_t *mi, circpad_machine_spec_transition_mock(circpad_machine_runtime_t *mi,
circpad_event_t event) circpad_event_t event)
{ {
(void) mi; (void) mi;
@ -2217,7 +2217,7 @@ test_circuitpadding_machine_rate_limiting(void *arg)
{ {
(void) arg; (void) arg;
bool retval; bool retval;
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
int i; int i;
/* Ignore machine transitions for the purposes of this function, we only /* Ignore machine transitions for the purposes of this function, we only
@ -2285,7 +2285,7 @@ test_circuitpadding_global_rate_limiting(void *arg)
{ {
(void) arg; (void) arg;
bool retval; bool retval;
circpad_machine_state_t *mi; circpad_machine_runtime_t *mi;
int i; int i;
/* Ignore machine transitions for the purposes of this function, we only /* Ignore machine transitions for the purposes of this function, we only