|
@@ -84,6 +84,9 @@
|
|
|
|
|
|
event_label_t or_conn_link_protocol_version_ev = EVENT_LABEL_UNSET;
|
|
|
event_label_t or_conn_open_ev = EVENT_LABEL_UNSET;
|
|
|
+event_label_t or_conn_outgoing_packed_cell = EVENT_LABEL_UNSET;
|
|
|
+event_label_t or_conn_outgoing_fixed_cell = EVENT_LABEL_UNSET;
|
|
|
+event_label_t or_conn_outgoing_variable_cell = EVENT_LABEL_UNSET;
|
|
|
|
|
|
//static int connection_tls_finish_handshake(or_connection_t *conn);
|
|
|
static int connection_or_launch_v3_or_handshake(or_connection_t *conn);
|
|
@@ -126,11 +129,20 @@ or_conn_register_events(event_registry_t *registry)
|
|
|
{
|
|
|
tor_assert(or_conn_link_protocol_version_ev == EVENT_LABEL_UNSET);
|
|
|
tor_assert(or_conn_open_ev == EVENT_LABEL_UNSET);
|
|
|
+ tor_assert(or_conn_outgoing_packed_cell == EVENT_LABEL_UNSET);
|
|
|
+ tor_assert(or_conn_outgoing_fixed_cell == EVENT_LABEL_UNSET);
|
|
|
+ tor_assert(or_conn_outgoing_variable_cell == EVENT_LABEL_UNSET);
|
|
|
|
|
|
or_conn_link_protocol_version_ev = \
|
|
|
event_registry_register_event(registry, "Decided protocol version");
|
|
|
or_conn_open_ev = \
|
|
|
event_registry_register_event(registry, "Connection is open");
|
|
|
+ or_conn_outgoing_packed_cell = \
|
|
|
+ event_registry_register_event(registry, "Outgoing packed cell");
|
|
|
+ or_conn_outgoing_fixed_cell = \
|
|
|
+ event_registry_register_event(registry, "Outgoing fixed cell");
|
|
|
+ or_conn_outgoing_variable_cell = \
|
|
|
+ event_registry_register_event(registry, "Outgoing variable cell");
|
|
|
}
|
|
|
|
|
|
/** Global map between Extended ORPort identifiers and OR
|
|
@@ -2415,13 +2427,13 @@ connection_or_set_state_open(or_connection_t *conn)
|
|
|
void
|
|
|
connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)
|
|
|
{
|
|
|
- packed_cell_t networkcell;
|
|
|
- size_t cell_network_size = get_cell_network_size(conn->wide_circ_ids);
|
|
|
+ //packed_cell_t networkcell;
|
|
|
+ //size_t cell_network_size = get_cell_network_size(conn->wide_circ_ids);
|
|
|
|
|
|
tor_assert(cell);
|
|
|
tor_assert(conn);
|
|
|
|
|
|
- cell_pack(&networkcell, cell, conn->wide_circ_ids);
|
|
|
+ //cell_pack(&networkcell, cell, conn->wide_circ_ids);
|
|
|
|
|
|
/* We need to count padding cells from this non-packed code path
|
|
|
* since they are sent via chan->write_cell() (which is not packed) */
|
|
@@ -2429,7 +2441,11 @@ connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)
|
|
|
if (cell->command == CELL_PADDING)
|
|
|
rep_hist_padding_count_write(PADDING_TYPE_CELL);
|
|
|
|
|
|
- connection_buf_add(networkcell.body, cell_network_size, TO_CONN(conn));
|
|
|
+ //connection_buf_add(networkcell.body, cell_network_size, TO_CONN(conn));
|
|
|
+
|
|
|
+ event_data_t event_data = { .ptr = cell };
|
|
|
+ event_source_publish(TO_CONN(conn)->event_source,
|
|
|
+ or_conn_outgoing_fixed_cell, event_data, tor_free_);
|
|
|
|
|
|
/* Touch the channel's active timestamp if there is one */
|
|
|
if (conn->chan) {
|
|
@@ -2446,6 +2462,12 @@ connection_or_write_cell_to_buf(const cell_t *cell, or_connection_t *conn)
|
|
|
or_handshake_state_record_cell(conn, conn->handshake_state, cell, 0);
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+void_var_cell_free(void *void_var_cell)
|
|
|
+{
|
|
|
+ var_cell_free_((var_cell_t *)void_var_cell);
|
|
|
+}
|
|
|
+
|
|
|
/** Pack a variable-length <b>cell</b> into wire-format, and write it onto
|
|
|
* <b>conn</b>'s outbuf. Right now, this <em>DOES NOT</em> support cells that
|
|
|
* affect a circuit.
|
|
@@ -2454,14 +2476,20 @@ MOCK_IMPL(void,
|
|
|
connection_or_write_var_cell_to_buf,(const var_cell_t *cell,
|
|
|
or_connection_t *conn))
|
|
|
{
|
|
|
- int n;
|
|
|
- char hdr[VAR_CELL_MAX_HEADER_SIZE];
|
|
|
+ //int n;
|
|
|
+ //char hdr[VAR_CELL_MAX_HEADER_SIZE];
|
|
|
tor_assert(cell);
|
|
|
tor_assert(conn);
|
|
|
- n = var_cell_pack_header(cell, hdr, conn->wide_circ_ids);
|
|
|
- connection_buf_add(hdr, n, TO_CONN(conn));
|
|
|
- connection_buf_add((char*)cell->payload,
|
|
|
- cell->payload_len, TO_CONN(conn));
|
|
|
+ //n = var_cell_pack_header(cell, hdr, conn->wide_circ_ids);
|
|
|
+ //connection_buf_add(hdr, n, TO_CONN(conn));
|
|
|
+ //connection_buf_add((char*)cell->payload,
|
|
|
+ // cell->payload_len, TO_CONN(conn));
|
|
|
+
|
|
|
+ event_data_t event_data = { .ptr = cell };
|
|
|
+ event_source_publish(TO_CONN(conn)->event_source,
|
|
|
+ or_conn_outgoing_variable_cell, event_data,
|
|
|
+ void_var_cell_free);
|
|
|
+
|
|
|
if (conn->base_.state == OR_CONN_STATE_OR_HANDSHAKING_V3)
|
|
|
or_handshake_state_record_var_cell(conn, conn->handshake_state, cell, 0);
|
|
|
|
|
@@ -2598,7 +2626,7 @@ connection_or_send_versions(or_connection_t *conn, int v3_plus)
|
|
|
connection_or_write_var_cell_to_buf(cell, conn);
|
|
|
conn->handshake_state->sent_versions_at = time(NULL);
|
|
|
|
|
|
- var_cell_free(cell);
|
|
|
+ //var_cell_free(cell);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -2632,7 +2660,8 @@ netinfo_addr_from_tor_addr(const tor_addr_t *tor_addr)
|
|
|
MOCK_IMPL(int,
|
|
|
connection_or_send_netinfo,(or_connection_t *conn))
|
|
|
{
|
|
|
- cell_t cell;
|
|
|
+ //cell_t cell;
|
|
|
+ cell_t *cell = NULL;
|
|
|
time_t now = time(NULL);
|
|
|
const routerinfo_t *me;
|
|
|
int r = -1;
|
|
@@ -2645,8 +2674,9 @@ connection_or_send_netinfo,(or_connection_t *conn))
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- memset(&cell, 0, sizeof(cell_t));
|
|
|
- cell.command = CELL_NETINFO;
|
|
|
+ //memset(&cell, 0, sizeof(cell_t));
|
|
|
+ cell = tor_malloc_zero(sizeof(*cell));
|
|
|
+ cell->command = CELL_NETINFO;
|
|
|
|
|
|
netinfo_cell_t *netinfo_cell = netinfo_cell_new();
|
|
|
|
|
@@ -2688,18 +2718,20 @@ connection_or_send_netinfo,(or_connection_t *conn))
|
|
|
if ((errmsg = netinfo_cell_check(netinfo_cell))) {
|
|
|
log_warn(LD_OR, "Failed to validate NETINFO cell with error: %s",
|
|
|
errmsg);
|
|
|
+ tor_free(cell);
|
|
|
goto cleanup;
|
|
|
}
|
|
|
|
|
|
- if (netinfo_cell_encode(cell.payload, CELL_PAYLOAD_SIZE,
|
|
|
+ if (netinfo_cell_encode(cell->payload, CELL_PAYLOAD_SIZE,
|
|
|
netinfo_cell) < 0) {
|
|
|
log_warn(LD_OR, "Failed generating NETINFO cell");
|
|
|
+ tor_free(cell);
|
|
|
goto cleanup;
|
|
|
}
|
|
|
|
|
|
conn->handshake_state->digest_sent_data = 0;
|
|
|
conn->handshake_state->sent_netinfo = 1;
|
|
|
- connection_or_write_cell_to_buf(&cell, conn);
|
|
|
+ connection_or_write_cell_to_buf(cell, conn);
|
|
|
|
|
|
r = 0;
|
|
|
cleanup:
|
|
@@ -2851,7 +2883,7 @@ connection_or_send_certs_cell(or_connection_t *conn)
|
|
|
cell->payload_len = enc_len;
|
|
|
|
|
|
connection_or_write_var_cell_to_buf(cell, conn);
|
|
|
- var_cell_free(cell);
|
|
|
+ //var_cell_free(cell);
|
|
|
certs_cell_free(certs_cell);
|
|
|
//tor_x509_cert_free(own_link_cert);
|
|
|
|
|
@@ -2934,6 +2966,7 @@ connection_or_send_auth_challenge_cell(or_connection_t *conn)
|
|
|
if (len != cell->payload_len) {
|
|
|
/* LCOV_EXCL_START */
|
|
|
log_warn(LD_BUG, "Encoded auth challenge cell length not as expected");
|
|
|
+ var_cell_free(cell);
|
|
|
goto done;
|
|
|
/* LCOV_EXCL_STOP */
|
|
|
}
|
|
@@ -2943,7 +2976,7 @@ connection_or_send_auth_challenge_cell(or_connection_t *conn)
|
|
|
r = 0;
|
|
|
|
|
|
done:
|
|
|
- var_cell_free(cell);
|
|
|
+ //var_cell_free(cell);
|
|
|
auth_challenge_cell_free(ac);
|
|
|
|
|
|
return r;
|
|
@@ -3245,7 +3278,7 @@ connection_or_send_authenticate_cell,(or_connection_t *conn, int authtype))
|
|
|
return -1;
|
|
|
}
|
|
|
connection_or_write_var_cell_to_buf(cell, conn);
|
|
|
- var_cell_free(cell);
|
|
|
+ //var_cell_free(cell);
|
|
|
|
|
|
return 0;
|
|
|
}
|