mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
Refactor rend machines, stage 1/2: Move state transition code.
This commit is contained in:
parent
bbb974234c
commit
0cba53c6ed
@ -284,26 +284,6 @@ setup_obf_state_for_hiding_rend_circuits(circpad_state_t *obf_state)
|
|||||||
obf_state->histogram_total_tokens = 1;
|
obf_state->histogram_total_tokens = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Setup the simple state machine we use for all HS padding machines */
|
|
||||||
static void
|
|
||||||
setup_state_machine_for_hiding_rend_circuits(circpad_machine_spec_t *machine)
|
|
||||||
{
|
|
||||||
/* Two states: START, OBFUSCATE_CIRC_SETUP (and END) */
|
|
||||||
circpad_machine_states_init(machine, 2);
|
|
||||||
|
|
||||||
/* START -> OBFUSCATE_CIRC_SETUP transition upon sending the first
|
|
||||||
* non-padding cell (which is PADDING_NEGOTIATE) */
|
|
||||||
machine->states[CIRCPAD_STATE_START].
|
|
||||||
next_state[CIRCPAD_EVENT_NONPADDING_SENT] =
|
|
||||||
CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP;
|
|
||||||
|
|
||||||
/* OBFUSCATE_CIRC_SETUP -> END transition when we finish all the tokens */
|
|
||||||
machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
|
||||||
next_state[CIRCPAD_EVENT_PADDING_RECV] = CIRCPAD_STATE_END;
|
|
||||||
machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
|
||||||
next_state[CIRCPAD_EVENT_LENGTH_COUNT] = CIRCPAD_STATE_END;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create a client-side padding machine that aims to hide rendezvous
|
/** Create a client-side padding machine that aims to hide rendezvous
|
||||||
* circuits.*/
|
* circuits.*/
|
||||||
void
|
void
|
||||||
@ -360,8 +340,22 @@ circpad_machine_client_hide_rend_circuits(smartlist_t *machines_sl)
|
|||||||
client_machine->allowed_padding_count = 1;
|
client_machine->allowed_padding_count = 1;
|
||||||
client_machine->max_padding_percent = 1;
|
client_machine->max_padding_percent = 1;
|
||||||
|
|
||||||
/* Setup states and histograms */
|
/* Two states: START, OBFUSCATE_CIRC_SETUP (and END) */
|
||||||
setup_state_machine_for_hiding_rend_circuits(client_machine);
|
circpad_machine_states_init(client_machine, 2);
|
||||||
|
|
||||||
|
/* START -> OBFUSCATE_CIRC_SETUP transition upon sending the first
|
||||||
|
* non-padding cell (which is PADDING_NEGOTIATE) */
|
||||||
|
client_machine->states[CIRCPAD_STATE_START].
|
||||||
|
next_state[CIRCPAD_EVENT_NONPADDING_SENT] =
|
||||||
|
CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP;
|
||||||
|
|
||||||
|
/* OBFUSCATE_CIRC_SETUP -> END transition when we send our first
|
||||||
|
* padding packet and/or hit the state length (the state length is 1). */
|
||||||
|
client_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
||||||
|
next_state[CIRCPAD_EVENT_PADDING_RECV] = CIRCPAD_STATE_END;
|
||||||
|
client_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
||||||
|
next_state[CIRCPAD_EVENT_LENGTH_COUNT] = CIRCPAD_STATE_END;
|
||||||
|
|
||||||
setup_obf_state_for_hiding_rend_circuits(
|
setup_obf_state_for_hiding_rend_circuits(
|
||||||
&client_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP]);
|
&client_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP]);
|
||||||
|
|
||||||
@ -398,8 +392,22 @@ circpad_machine_relay_hide_rend_circuits(smartlist_t *machines_sl)
|
|||||||
relay_machine->allowed_padding_count = 1;
|
relay_machine->allowed_padding_count = 1;
|
||||||
relay_machine->max_padding_percent = 1;
|
relay_machine->max_padding_percent = 1;
|
||||||
|
|
||||||
/* Setup states and histograms */
|
/* Two states: START, OBFUSCATE_CIRC_SETUP (and END) */
|
||||||
setup_state_machine_for_hiding_rend_circuits(relay_machine);
|
circpad_machine_states_init(relay_machine, 2);
|
||||||
|
|
||||||
|
/* START -> OBFUSCATE_CIRC_SETUP transition upon sending the first
|
||||||
|
* non-padding cell (which is PADDING_NEGOTIATED) */
|
||||||
|
relay_machine->states[CIRCPAD_STATE_START].
|
||||||
|
next_state[CIRCPAD_EVENT_NONPADDING_SENT] =
|
||||||
|
CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP;
|
||||||
|
|
||||||
|
/* OBFUSCATE_CIRC_SETUP -> END transition when we send our first
|
||||||
|
* padding packet and/or hit the state length (the state length is 1). */
|
||||||
|
relay_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
||||||
|
next_state[CIRCPAD_EVENT_PADDING_RECV] = CIRCPAD_STATE_END;
|
||||||
|
relay_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP].
|
||||||
|
next_state[CIRCPAD_EVENT_LENGTH_COUNT] = CIRCPAD_STATE_END;
|
||||||
|
|
||||||
setup_obf_state_for_hiding_rend_circuits(
|
setup_obf_state_for_hiding_rend_circuits(
|
||||||
&relay_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP]);
|
&relay_machine->states[CIRCPAD_STATE_OBFUSCATE_CIRC_SETUP]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user