|
@@ -5,6 +5,9 @@
|
|
|
|
|
|
#define RELAY_PRIVATE
|
|
|
#define CIRCUITLIST_PRIVATE
|
|
|
+#define CONNECTION_EDGE_PRIVATE
|
|
|
+#define CONNECTION_PRIVATE
|
|
|
+
|
|
|
#include "or.h"
|
|
|
#include "main.h"
|
|
|
#include "config.h"
|
|
@@ -18,6 +21,11 @@
|
|
|
#include "relay.h"
|
|
|
#include "test.h"
|
|
|
|
|
|
+#include "log_test_helpers.h"
|
|
|
+
|
|
|
+#include "circpathbias.h"
|
|
|
+#include "connection_edge.h"
|
|
|
+
|
|
|
static int srm_ncalls;
|
|
|
static entry_connection_t *srm_conn;
|
|
|
static int srm_atype;
|
|
@@ -27,23 +35,6 @@ static uint8_t srm_answer[512];
|
|
|
static int srm_ttl;
|
|
|
static time_t srm_expires;
|
|
|
|
|
|
-void connection_free_minimal(connection_t*);
|
|
|
-int connected_cell_format_payload(uint8_t *payload_out,
|
|
|
- const tor_addr_t *addr,
|
|
|
- uint32_t ttl);
|
|
|
-void pathbias_count_valid_cells(origin_circuit_t *circ,
|
|
|
- cell_t *cell);
|
|
|
-half_edge_t *connection_half_edge_find_stream_id(
|
|
|
- const smartlist_t *half_conns,
|
|
|
- streamid_t stream_id);
|
|
|
-void connection_half_edge_add(const edge_connection_t *conn,
|
|
|
- origin_circuit_t *circ);
|
|
|
-
|
|
|
-int mock_send_command(streamid_t stream_id, circuit_t *circ,
|
|
|
- uint8_t relay_command, const char *payload,
|
|
|
- size_t payload_len, crypt_path_t *cpath_layer,
|
|
|
- const char *filename, int lineno);
|
|
|
-
|
|
|
/* Mock replacement for connection_ap_hannshake_socks_resolved() */
|
|
|
static void
|
|
|
socks_resolved_mock(entry_connection_t *conn,
|
|
@@ -143,7 +134,7 @@ mock_start_reading(connection_t *conn)
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
-int
|
|
|
+static int
|
|
|
mock_send_command(streamid_t stream_id, circuit_t *circ,
|
|
|
uint8_t relay_command, const char *payload,
|
|
|
size_t payload_len, crypt_path_t *cpath_layer,
|
|
@@ -230,7 +221,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
/* Data cell not in the half-opened list */
|
|
|
PACK_CELL(4000, RELAY_COMMAND_DATA, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -239,7 +230,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
/* Sendme cell not in the half-opened list */
|
|
|
PACK_CELL(4000, RELAY_COMMAND_SENDME, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -248,7 +239,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
/* Connected cell not in the half-opened list */
|
|
|
PACK_CELL(4000, RELAY_COMMAND_CONNECTED, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -257,7 +248,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
/* Resolved cell not in the half-opened list */
|
|
|
PACK_CELL(4000, RELAY_COMMAND_RESOLVED, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -267,7 +258,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
edgeconn = ENTRY_TO_EDGE_CONN(entryconn2);
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -279,7 +270,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -290,7 +281,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -302,7 +293,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_SENDME, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -313,7 +304,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_SENDME, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -324,7 +315,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -334,7 +325,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn2)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -359,7 +350,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
connection_edge_reached_eof(edgeconn);
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -369,7 +360,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_CONNECTED, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -380,7 +371,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -399,7 +390,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn3)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -419,7 +410,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_RESOLVED,
|
|
|
"\x04\x04\x12\x00\x00\x01\x00\x00\x02\x00");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -438,7 +429,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn4)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_DATA, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -449,7 +440,7 @@ subtest_circbw_halfclosed(origin_circuit_t *circ, streamid_t init_id)
|
|
|
ENTRY_TO_CONN(entryconn4)->outbuf_flushlen = 0;
|
|
|
PACK_CELL(edgeconn->stream_id, RELAY_COMMAND_END, "Data1234");
|
|
|
if (circ->base_.purpose == CIRCUIT_PURPOSE_PATH_BIAS_TESTING)
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
else
|
|
|
connection_edge_process_relay_cell(&cell, TO_CIRCUIT(circ), NULL,
|
|
|
circ->cpath);
|
|
@@ -870,7 +861,7 @@ test_circbw_relay(void *arg)
|
|
|
/* Path bias: truncated */
|
|
|
tt_int_op(circ->base_.marked_for_close, OP_EQ, 0);
|
|
|
PACK_CELL(0, RELAY_COMMAND_TRUNCATED, "Data1234");
|
|
|
- pathbias_count_valid_cells(circ, &cell);
|
|
|
+ pathbias_count_valid_cells(TO_CIRCUIT(circ), &cell);
|
|
|
tt_int_op(circ->base_.marked_for_close, OP_EQ, 1);
|
|
|
|
|
|
done:
|