Make register_padding_machine part of the public API.

We are gonna use this function to register our new machine.
This commit is contained in:
George Kadianakis 2019-03-20 17:41:10 +02:00
parent a014e01b68
commit 39c52d14a6
3 changed files with 14 additions and 13 deletions

View File

@ -2371,7 +2371,6 @@ circpad_setup_machine_on_circ(circuit_t *on_circ,
on_circ->padding_machine[machine->machine_index] = machine;
}
#ifdef TOR_UNIT_TESTS
/** Validate a single state of a padding machine */
static bool
padding_machine_state_is_valid(const circpad_state_t *state)
@ -2435,8 +2434,8 @@ padding_machine_is_valid(const circpad_machine_spec_t *machine)
/* Validate and register <b>machine</b> into <b>machine_list</b>. If
* <b>machine_list</b> is NULL, then just validate. */
STATIC void
register_padding_machine(circpad_machine_spec_t *machine,
void
circpad_register_padding_machine(circpad_machine_spec_t *machine,
smartlist_t *machine_list)
{
if (!padding_machine_is_valid(machine)) {
@ -2450,6 +2449,7 @@ register_padding_machine(circpad_machine_spec_t *machine,
}
}
#ifdef TOR_UNIT_TESTS
/* These padding machines are only used for tests pending #28634. */
static void
circpad_circ_client_machine_init(void)
@ -2502,7 +2502,8 @@ circpad_circ_client_machine_init(void)
circ_client_machine->states[CIRCPAD_STATE_BURST].histogram_total_tokens = 5;
circ_client_machine->machine_num = smartlist_len(origin_padding_machines);
register_padding_machine(circ_client_machine, origin_padding_machines);
circpad_register_padding_machine(circ_client_machine,
origin_padding_machines);
}
static void
@ -2602,7 +2603,8 @@ circpad_circ_responder_machine_init(void)
CIRCPAD_TOKEN_REMOVAL_CLOSEST_USEC;
circ_responder_machine->machine_num = smartlist_len(relay_padding_machines);
register_padding_machine(circ_responder_machine, relay_padding_machines);
circpad_register_padding_machine(circ_responder_machine,
relay_padding_machines);
}
#endif

View File

@ -698,6 +698,8 @@ circpad_machine_event_circ_has_no_relay_early(struct origin_circuit_t *circ);
void circpad_machines_init(void);
void circpad_machines_free(void);
void circpad_register_padding_machine(circpad_machine_spec_t *machine,
smartlist_t *machine_list);
void circpad_machine_states_init(circpad_machine_spec_t *machine,
circpad_statenum_t num_states);
@ -781,9 +783,6 @@ histogram_get_bin_upper_bound(const circpad_machine_runtime_t *mi,
extern smartlist_t *origin_padding_machines;
extern smartlist_t *relay_padding_machines;
STATIC void
register_padding_machine(circpad_machine_spec_t *machine,
smartlist_t *machine_list);
#endif
#endif

View File

@ -1759,7 +1759,7 @@ helper_create_conditional_machines(void)
add->conditions.state_mask = CIRCPAD_CIRC_BUILDING|
CIRCPAD_CIRC_NO_STREAMS|CIRCPAD_CIRC_HAS_RELAY_EARLY;
add->conditions.purpose_mask = CIRCPAD_PURPOSE_ALL;
register_padding_machine(add, origin_padding_machines);
circpad_register_padding_machine(add, origin_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 3;
@ -1778,15 +1778,15 @@ helper_create_conditional_machines(void)
add->conditions.state_mask = CIRCPAD_CIRC_OPENED|
CIRCPAD_CIRC_STREAMS|CIRCPAD_CIRC_HAS_NO_RELAY_EARLY;
add->conditions.purpose_mask = CIRCPAD_PURPOSE_ALL;
register_padding_machine(add, origin_padding_machines);
circpad_register_padding_machine(add, origin_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 2;
register_padding_machine(add, relay_padding_machines);
circpad_register_padding_machine(add, relay_padding_machines);
add = helper_create_conditional_machine();
add->machine_num = 3;
register_padding_machine(add, relay_padding_machines);
circpad_register_padding_machine(add, relay_padding_machines);
}
void