[tor-commits] [tor/master] Make register_padding_machine part of the public API.

nickm at torproject.org nickm at torproject.org
Fri May 17 12:23:09 UTC 2019


commit 39c52d14a619c9944321f404c74c9129a5e664cb
Author: George Kadianakis <desnacked at riseup.net>
Date:   Wed Mar 20 17:41:10 2019 +0200

    Make register_padding_machine part of the public API.
    
    We are gonna use this function to register our new machine.
---
 src/core/or/circuitpadding.c   | 14 ++++++++------
 src/core/or/circuitpadding.h   |  5 ++---
 src/test/test_circuitpadding.c |  8 ++++----
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/src/core/or/circuitpadding.c b/src/core/or/circuitpadding.c
index 61e222cbb..48d0d4a95 100644
--- a/src/core/or/circuitpadding.c
+++ b/src/core/or/circuitpadding.c
@@ -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,9 +2434,9 @@ 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,
-                         smartlist_t *machine_list)
+void
+circpad_register_padding_machine(circpad_machine_spec_t *machine,
+                                 smartlist_t *machine_list)
 {
   if (!padding_machine_is_valid(machine)) {
     log_warn(LD_GENERAL, "Machine #%u is invalid. Ignoring.",
@@ -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
 
diff --git a/src/core/or/circuitpadding.h b/src/core/or/circuitpadding.h
index 277a78001..059896ddf 100644
--- a/src/core/or/circuitpadding.h
+++ b/src/core/or/circuitpadding.h
@@ -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
diff --git a/src/test/test_circuitpadding.c b/src/test/test_circuitpadding.c
index bd6697922..c5aad0f5d 100644
--- a/src/test/test_circuitpadding.c
+++ b/src/test/test_circuitpadding.c
@@ -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





More information about the tor-commits mailing list