[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Extract cell type and their queues into new headers
commit fde868ffe3ace818d67374858c54418296a62e79
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Jun 15 15:27:46 2018 -0400
Extract cell type and their queues into new headers
Since packed_cell and destroy_cell exist only to be queued, they go
in the same headers as the queues.
---
src/or/cell_queue_st.h | 28 ++++++++++++++++++++
src/or/cell_st.h | 20 ++++++++++++++
src/or/channel.c | 2 ++
src/or/channelpadding.c | 1 +
src/or/channeltls.c | 3 +++
src/or/circpathbias.c | 1 +
src/or/circuit_st.h | 2 ++
src/or/circuitbuild.c | 1 +
src/or/circuitmux.c | 2 ++
src/or/command.c | 2 ++
src/or/connection_edge.c | 1 +
src/or/connection_or.c | 3 +++
src/or/destroy_cell_queue_st.h | 27 +++++++++++++++++++
src/or/include.am | 4 +++
src/or/main.c | 1 +
src/or/onion.c | 1 +
src/or/or.h | 59 +++++-------------------------------------
src/or/proto_cell.c | 2 ++
src/or/relay.c | 3 +++
src/or/relay_crypto.c | 1 +
src/or/var_cell_st.h | 23 ++++++++++++++++
src/test/bench.c | 1 +
src/test/test_cell_formats.c | 5 ++++
src/test/test_cell_queue.c | 2 ++
src/test/test_channel.c | 2 ++
src/test/test_channelpadding.c | 1 +
src/test/test_circuitmux.c | 2 ++
src/test/test_helpers.c | 1 +
src/test/test_link_handshake.c | 1 +
src/test/test_oom.c | 1 +
src/test/test_proto_misc.c | 2 ++
src/test/test_relay.c | 1 +
src/test/test_relaycell.c | 1 +
src/test/test_relaycrypt.c | 1 +
34 files changed, 155 insertions(+), 53 deletions(-)
diff --git a/src/or/cell_queue_st.h b/src/or/cell_queue_st.h
new file mode 100644
index 000000000..6c429eacc
--- /dev/null
+++ b/src/or/cell_queue_st.h
@@ -0,0 +1,28 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef PACKED_CELL_ST_H
+#define PACKED_CELL_ST_H
+
+/** A cell as packed for writing to the network. */
+struct packed_cell_t {
+ /** Next cell queued on this circuit. */
+ TOR_SIMPLEQ_ENTRY(packed_cell_t) next;
+ char body[CELL_MAX_NETWORK_SIZE]; /**< Cell as packed for network. */
+ uint32_t inserted_timestamp; /**< Time (in timestamp units) when this cell
+ * was inserted */
+};
+
+/** A queue of cells on a circuit, waiting to be added to the
+ * or_connection_t's outbuf. */
+struct cell_queue_t {
+ /** Linked list of packed_cell_t*/
+ TOR_SIMPLEQ_HEAD(cell_simpleq, packed_cell_t) head;
+ int n; /**< The number of cells in the queue. */
+};
+
+#endif
+
diff --git a/src/or/cell_st.h b/src/or/cell_st.h
new file mode 100644
index 000000000..08ed29087
--- /dev/null
+++ b/src/or/cell_st.h
@@ -0,0 +1,20 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef CELL_ST_H
+#define CELL_ST_H
+
+/** Parsed onion routing cell. All communication between nodes
+ * is via cells. */
+struct cell_t {
+ circid_t circ_id; /**< Circuit which received the cell. */
+ uint8_t command; /**< Type of the cell: one of CELL_PADDING, CELL_CREATE,
+ * CELL_DESTROY, etc */
+ uint8_t payload[CELL_PAYLOAD_SIZE]; /**< Cell body. */
+};
+
+#endif
+
diff --git a/src/or/channel.c b/src/or/channel.c
index c30e50801..d53e0d2e3 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -80,6 +80,8 @@
#include "networkstatus.h"
#include "rendservice.h"
+#include "cell_queue_st.h"
+
/* Global lists of channels */
/* All channel_t instances */
diff --git a/src/or/channelpadding.c b/src/or/channelpadding.c
index 7eb0cc282..e3aa2dc10 100644
--- a/src/or/channelpadding.c
+++ b/src/or/channelpadding.c
@@ -23,6 +23,7 @@
#include "compat_time.h"
#include "rendservice.h"
+#include "cell_st.h"
#include "or_connection_st.h"
STATIC int32_t channelpadding_get_netflow_inactive_timeout_ms(
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index dd0c1628c..e2b6cabd4 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -60,10 +60,13 @@
#include "channelpadding_negotiation.h"
#include "channelpadding.h"
+#include "cell_st.h"
+#include "cell_queue_st.h"
#include "or_connection_st.h"
#include "or_handshake_certs_st.h"
#include "or_handshake_state_st.h"
#include "routerinfo_st.h"
+#include "var_cell_st.h"
/** How many CELL_PADDING cells have we received, ever? */
uint64_t stats_n_padding_cells_processed = 0;
diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c
index 9ca45df27..a36d67526 100644
--- a/src/or/circpathbias.c
+++ b/src/or/circpathbias.c
@@ -35,6 +35,7 @@
#include "networkstatus.h"
#include "relay.h"
+#include "cell_st.h"
#include "cpath_build_state_st.h"
#include "crypt_path_st.h"
#include "origin_circuit_st.h"
diff --git a/src/or/circuit_st.h b/src/or/circuit_st.h
index 2c4f72a72..f977d542d 100644
--- a/src/or/circuit_st.h
+++ b/src/or/circuit_st.h
@@ -9,6 +9,8 @@
#include "or.h"
+#include "cell_queue_st.h"
+
/**
* A circuit is a path over the onion routing
* network. Applications can connect to one end of the circuit, and can
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 103dd6eb9..41afb7543 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -65,6 +65,7 @@
#include "routerset.h"
#include "transports.h"
+#include "cell_st.h"
#include "cpath_build_state_st.h"
#include "entry_connection_st.h"
#include "node_st.h"
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 5f7f002f4..e07331175 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -75,6 +75,8 @@
#include "circuitmux.h"
#include "relay.h"
+#include "cell_queue_st.h"
+#include "destroy_cell_queue_st.h"
#include "or_circuit_st.h"
/*
diff --git a/src/or/command.c b/src/or/command.c
index 148578a26..39136966e 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -56,8 +56,10 @@
#include "router.h"
#include "routerlist.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
+#include "var_cell_st.h"
/** How many CELL_CREATE cells have we received, ever? */
uint64_t stats_n_create_cells_processed = 0;
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index e177b0ee2..4f1b5d2d5 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -97,6 +97,7 @@
#include "routerset.h"
#include "circuitbuild.h"
+#include "cell_st.h"
#include "cpath_build_state_st.h"
#include "dir_connection_st.h"
#include "entry_connection_st.h"
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 1810c3954..bbd6fa0ed 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -61,10 +61,13 @@
#include "torcert.h"
#include "channelpadding.h"
+#include "cell_st.h"
+#include "cell_queue_st.h"
#include "or_connection_st.h"
#include "or_handshake_certs_st.h"
#include "or_handshake_state_st.h"
#include "routerinfo_st.h"
+#include "var_cell_st.h"
static int connection_tls_finish_handshake(or_connection_t *conn);
static int connection_or_launch_v3_or_handshake(or_connection_t *conn);
diff --git a/src/or/destroy_cell_queue_st.h b/src/or/destroy_cell_queue_st.h
new file mode 100644
index 000000000..67c25935e
--- /dev/null
+++ b/src/or/destroy_cell_queue_st.h
@@ -0,0 +1,27 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef DESTROY_CELL_QUEUE_ST_H
+#define DESTROY_CELL_QUEUE_ST_H
+
+/** A single queued destroy cell. */
+struct destroy_cell_t {
+ TOR_SIMPLEQ_ENTRY(destroy_cell_t) next;
+ circid_t circid;
+ uint32_t inserted_timestamp; /**< Time (in timestamp units) when this cell
+ * was inserted */
+ uint8_t reason;
+};
+
+/** A queue of destroy cells on a channel. */
+struct destroy_cell_queue_t {
+ /** Linked list of packed_cell_t */
+ TOR_SIMPLEQ_HEAD(dcell_simpleq, destroy_cell_t) head;
+ int n; /**< The number of cells in the queue. */
+};
+
+#endif
+
diff --git a/src/or/include.am b/src/or/include.am
index cc059ef51..ec8e27556 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -184,6 +184,8 @@ ORHEADERS = \
src/or/authority_cert_st.h \
src/or/auth_dirs.inc \
src/or/bridges.h \
+ src/or/cell_st.h \
+ src/or/cell_queue_st.h \
src/or/channel.h \
src/or/channelpadding.h \
src/or/channeltls.h \
@@ -213,6 +215,7 @@ ORHEADERS = \
src/or/crypt_path_reference_st.h \
src/or/cpuworker.h \
src/or/desc_store_st.h \
+ src/or/destroy_cell_queue_st.h \
src/or/directory.h \
src/or/dirserv.h \
src/or/dir_connection_st.h \
@@ -316,6 +319,7 @@ ORHEADERS = \
src/or/torcert.h \
src/or/tor_api_internal.h \
src/or/tor_version_st.h \
+ src/or/var_cell_st.h \
src/or/vote_microdesc_hash_st.h \
src/or/vote_routerstatus_st.h \
src/or/vote_timing_st.h \
diff --git a/src/or/main.c b/src/or/main.c
index 664105046..bb5aaaf60 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -122,6 +122,7 @@
#include "dirauth/mode.h"
#include "dirauth/shared_random.h"
+#include "cell_st.h"
#include "entry_connection_st.h"
#include "networkstatus_st.h"
#include "or_connection_st.h"
diff --git a/src/or/onion.c b/src/or/onion.c
index 813ad265e..ac2f40a55 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -77,6 +77,7 @@
#include "rephist.h"
#include "router.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
// trunnel
diff --git a/src/or/or.h b/src/or/or.h
index 958c1e2bb..66c863a82 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1176,26 +1176,12 @@ typedef struct channel_tls_s channel_tls_t;
typedef struct circuitmux_s circuitmux_t;
-/** Parsed onion routing cell. All communication between nodes
- * is via cells. */
-typedef struct cell_t {
- circid_t circ_id; /**< Circuit which received the cell. */
- uint8_t command; /**< Type of the cell: one of CELL_PADDING, CELL_CREATE,
- * CELL_DESTROY, etc */
- uint8_t payload[CELL_PAYLOAD_SIZE]; /**< Cell body. */
-} cell_t;
-
-/** Parsed variable-length onion routing cell. */
-typedef struct var_cell_t {
- /** Type of the cell: CELL_VERSIONS, etc. */
- uint8_t command;
- /** Circuit thich received the cell */
- circid_t circ_id;
- /** Number of bytes actually stored in <b>payload</b> */
- uint16_t payload_len;
- /** Payload of this cell */
- uint8_t payload[FLEXIBLE_ARRAY_MEMBER];
-} var_cell_t;
+typedef struct cell_t cell_t;
+typedef struct var_cell_t var_cell_t;
+typedef struct packed_cell_t packed_cell_t;
+typedef struct cell_queue_t cell_queue_t;
+typedef struct destroy_cell_t destroy_cell_t;
+typedef struct destroy_cell_queue_t destroy_cell_queue_t;
/** A parsed Extended ORPort message. */
typedef struct ext_or_cmd_t {
@@ -1204,39 +1190,6 @@ typedef struct ext_or_cmd_t {
char body[FLEXIBLE_ARRAY_MEMBER]; /** Message body */
} ext_or_cmd_t;
-/** A cell as packed for writing to the network. */
-typedef struct packed_cell_t {
- /** Next cell queued on this circuit. */
- TOR_SIMPLEQ_ENTRY(packed_cell_t) next;
- char body[CELL_MAX_NETWORK_SIZE]; /**< Cell as packed for network. */
- uint32_t inserted_timestamp; /**< Time (in timestamp units) when this cell
- * was inserted */
-} packed_cell_t;
-
-/** A queue of cells on a circuit, waiting to be added to the
- * or_connection_t's outbuf. */
-typedef struct cell_queue_t {
- /** Linked list of packed_cell_t*/
- TOR_SIMPLEQ_HEAD(cell_simpleq, packed_cell_t) head;
- int n; /**< The number of cells in the queue. */
-} cell_queue_t;
-
-/** A single queued destroy cell. */
-typedef struct destroy_cell_t {
- TOR_SIMPLEQ_ENTRY(destroy_cell_t) next;
- circid_t circid;
- uint32_t inserted_timestamp; /**< Time (in timestamp units) when this cell
- * was inserted */
- uint8_t reason;
-} destroy_cell_t;
-
-/** A queue of destroy cells on a channel. */
-typedef struct destroy_cell_queue_t {
- /** Linked list of packed_cell_t */
- TOR_SIMPLEQ_HEAD(dcell_simpleq, destroy_cell_t) head;
- int n; /**< The number of cells in the queue. */
-} destroy_cell_queue_t;
-
/** Beginning of a RELAY cell payload. */
typedef struct {
uint8_t command; /**< The end-to-end relay command. */
diff --git a/src/or/proto_cell.c b/src/or/proto_cell.c
index 75eb2a7e7..84620ce37 100644
--- a/src/or/proto_cell.c
+++ b/src/or/proto_cell.c
@@ -10,6 +10,8 @@
#include "connection_or.h"
+#include "var_cell_st.h"
+
/** True iff the cell command <b>command</b> is one that implies a
* variable-length cell in Tor link protocol <b>linkproto</b>. */
static inline int
diff --git a/src/or/relay.c b/src/or/relay.c
index ff97b5266..62c9204db 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -82,8 +82,11 @@
#include "scheduler.h"
#include "rephist.h"
+#include "cell_st.h"
+#include "cell_queue_st.h"
#include "cpath_build_state_st.h"
#include "dir_connection_st.h"
+#include "destroy_cell_queue_st.h"
#include "entry_connection_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
diff --git a/src/or/relay_crypto.c b/src/or/relay_crypto.c
index 7603d3b4e..82ff9aca8 100644
--- a/src/or/relay_crypto.c
+++ b/src/or/relay_crypto.c
@@ -12,6 +12,7 @@
#include "relay.h"
#include "relay_crypto.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
diff --git a/src/or/var_cell_st.h b/src/or/var_cell_st.h
new file mode 100644
index 000000000..1a9ea0759
--- /dev/null
+++ b/src/or/var_cell_st.h
@@ -0,0 +1,23 @@
+/* Copyright (c) 2001 Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2017, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef VAR_CELL_ST_H
+#define VAR_CELL_ST_H
+
+/** Parsed variable-length onion routing cell. */
+struct var_cell_t {
+ /** Type of the cell: CELL_VERSIONS, etc. */
+ uint8_t command;
+ /** Circuit thich received the cell */
+ circid_t circ_id;
+ /** Number of bytes actually stored in <b>payload</b> */
+ uint16_t payload_len;
+ /** Payload of this cell */
+ uint8_t payload[FLEXIBLE_ARRAY_MEMBER];
+};
+
+#endif
+
diff --git a/src/test/bench.c b/src/test/bench.c
index 784bcf326..cce94a1ce 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -26,6 +26,7 @@
#include "crypto_rand.h"
#include "consdiff.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c
index 54d971678..fe9cfaf4a 100644
--- a/src/test/test_cell_formats.c
+++ b/src/test/test_cell_formats.c
@@ -18,6 +18,11 @@
#include "onion_fast.h"
#include "onion_ntor.h"
#include "relay.h"
+
+#include "cell_st.h"
+#include "cell_queue_st.h"
+#include "var_cell_st.h"
+
#include "test.h"
#include <stdlib.h>
diff --git a/src/test/test_cell_queue.c b/src/test/test_cell_queue.c
index b41f7ac38..a333fc55e 100644
--- a/src/test/test_cell_queue.c
+++ b/src/test/test_cell_queue.c
@@ -8,6 +8,8 @@
#include "relay.h"
#include "test.h"
+#include "cell_st.h"
+#include "cell_queue_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
diff --git a/src/test/test_channel.c b/src/test/test_channel.c
index fbc964ecc..ba9d8bfb2 100644
--- a/src/test/test_channel.c
+++ b/src/test/test_channel.c
@@ -20,9 +20,11 @@
#include "scheduler.h"
#include "networkstatus.h"
+#include "cell_st.h"
#include "networkstatus_st.h"
#include "origin_circuit_st.h"
#include "routerstatus_st.h"
+#include "var_cell_st.h"
/* Test suite stuff */
#include "log_test_helpers.h"
diff --git a/src/test/test_channelpadding.c b/src/test/test_channelpadding.c
index 206b57ad1..b2b9dc8d3 100644
--- a/src/test/test_channelpadding.c
+++ b/src/test/test_channelpadding.c
@@ -20,6 +20,7 @@
#include "networkstatus.h"
#include "log_test_helpers.h"
+#include "cell_st.h"
#include "networkstatus_st.h"
#include "or_connection_st.h"
#include "routerstatus_st.h"
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index 14c759870..85d91ab8b 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -13,6 +13,8 @@
#include "scheduler.h"
#include "test.h"
+#include "destroy_cell_queue_st.h"
+
/* XXXX duplicated function from test_circuitlist.c */
static channel_t *
new_fake_channel(void)
diff --git a/src/test/test_helpers.c b/src/test/test_helpers.c
index fc32665a1..7b6aa25e6 100644
--- a/src/test/test_helpers.c
+++ b/src/test/test_helpers.c
@@ -24,6 +24,7 @@
#include "relay.h"
#include "routerlist.h"
+#include "cell_st.h"
#include "connection_st.h"
#include "node_st.h"
#include "origin_circuit_st.h"
diff --git a/src/test/test_link_handshake.c b/src/test/test_link_handshake.c
index 1c2e91b83..1447d0435 100644
--- a/src/test/test_link_handshake.c
+++ b/src/test/test_link_handshake.c
@@ -24,6 +24,7 @@
#include "or_connection_st.h"
#include "or_handshake_certs_st.h"
#include "or_handshake_state_st.h"
+#include "var_cell_st.h"
#include "test.h"
#include "log_test_helpers.h"
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index fcee7cc73..8d506271a 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -18,6 +18,7 @@
#include "test.h"
#include "test_helpers.h"
+#include "cell_st.h"
#include "entry_connection_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
diff --git a/src/test/test_proto_misc.c b/src/test/test_proto_misc.c
index 263ca4744..e2d063a77 100644
--- a/src/test/test_proto_misc.c
+++ b/src/test/test_proto_misc.c
@@ -15,6 +15,8 @@
#include "proto_control0.h"
#include "proto_ext_or.h"
+#include "var_cell_st.h"
+
static void
test_proto_var_cell(void *arg)
{
diff --git a/src/test/test_relay.c b/src/test/test_relay.c
index 4a526671b..df1cfd79a 100644
--- a/src/test/test_relay.c
+++ b/src/test/test_relay.c
@@ -9,6 +9,7 @@
/* For init/free stuff */
#include "scheduler.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
/* Test suite stuff */
diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c
index b5aba766d..dc42709e0 100644
--- a/src/test/test_relaycell.c
+++ b/src/test/test_relaycell.c
@@ -16,6 +16,7 @@
#include "relay.h"
#include "test.h"
+#include "cell_st.h"
#include "crypt_path_st.h"
#include "entry_connection_st.h"
#include "origin_circuit_st.h"
diff --git a/src/test/test_relaycrypt.c b/src/test/test_relaycrypt.c
index 62bcedabc..9f6b5bbe6 100644
--- a/src/test/test_relaycrypt.c
+++ b/src/test/test_relaycrypt.c
@@ -11,6 +11,7 @@
#include "relay.h"
#include "relay_crypto.h"
+#include "cell_st.h"
#include "or_circuit_st.h"
#include "origin_circuit_st.h"
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits