]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Extract cell type and their queues into new headers
authorNick Mathewson <nickm@torproject.org>
Fri, 15 Jun 2018 19:27:46 +0000 (15:27 -0400)
committerNick Mathewson <nickm@torproject.org>
Fri, 15 Jun 2018 19:27:46 +0000 (15:27 -0400)
Since packed_cell and destroy_cell exist only to be queued, they go
in the same headers as the queues.

34 files changed:
src/or/cell_queue_st.h [new file with mode: 0644]
src/or/cell_st.h [new file with mode: 0644]
src/or/channel.c
src/or/channelpadding.c
src/or/channeltls.c
src/or/circpathbias.c
src/or/circuit_st.h
src/or/circuitbuild.c
src/or/circuitmux.c
src/or/command.c
src/or/connection_edge.c
src/or/connection_or.c
src/or/destroy_cell_queue_st.h [new file with mode: 0644]
src/or/include.am
src/or/main.c
src/or/onion.c
src/or/or.h
src/or/proto_cell.c
src/or/relay.c
src/or/relay_crypto.c
src/or/var_cell_st.h [new file with mode: 0644]
src/test/bench.c
src/test/test_cell_formats.c
src/test/test_cell_queue.c
src/test/test_channel.c
src/test/test_channelpadding.c
src/test/test_circuitmux.c
src/test/test_helpers.c
src/test/test_link_handshake.c
src/test/test_oom.c
src/test/test_proto_misc.c
src/test/test_relay.c
src/test/test_relaycell.c
src/test/test_relaycrypt.c

diff --git a/src/or/cell_queue_st.h b/src/or/cell_queue_st.h
new file mode 100644 (file)
index 0000000..6c429ea
--- /dev/null
@@ -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 (file)
index 0000000..08ed290
--- /dev/null
@@ -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
+
index c30e5080187f73f3b4d3e6a11a7c5f5b87b32f76..d53e0d2e3f8fe953b6a22c900031f8c185c854aa 100644 (file)
@@ -80,6 +80,8 @@
 #include "networkstatus.h"
 #include "rendservice.h"
 
+#include "cell_queue_st.h"
+
 /* Global lists of channels */
 
 /* All channel_t instances */
index 7eb0cc282f13ab568322871468f3ac906cb51624..e3aa2dc10360cf2ae9e6d3f1db037e8bca9c9756 100644 (file)
@@ -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(
index dd0c1628c432f65781f35b32fbac16034a30c251..e2b6cabd46cef3b8bc528d1478f2a71fbed3bee0 100644 (file)
 #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;
index 9ca45df273a340d1382ef1695a5b0fefaaf0aebf..a36d67526d8d28c8976b90a4148a05182394086a 100644 (file)
@@ -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"
index 2c4f72a72506f5157b3be7ca114c2f43da1d769a..f977d542dd51e333b92bb6a860d3e66ec11e7cd2 100644 (file)
@@ -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
index 103dd6eb9b4148a789399ecf8cdf0a4ca95d1329..41afb75439c5c1c70998329d716068e88d30d4b2 100644 (file)
@@ -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"
index 5f7f002f41dcbcba2491a5244d9c12adf41f5d5f..e073311753575a79190ff4834276a90723cd877e 100644 (file)
@@ -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"
 
 /*
index 148578a26b6758966606fa3d2a93f1d0bee56dbd..39136966ec2bd30eedd50d98028d0161ba8032cb 100644 (file)
 #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;
index e177b0ee2df4dfd9a5590551a200d422384b786d..4f1b5d2d58f9c1c8d8abb340af0164cdccbdcffa 100644 (file)
@@ -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"
index 1810c39546fe54e0462fd85ddc1dfa31721be6d4..bbd6fa0edce4c2011a97b1a0c6f1604e5b02a06d 100644 (file)
 #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 (file)
index 0000000..67c2593
--- /dev/null
@@ -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
+
index cc059ef514826b1ef4f91dbc850e162b3860fa3d..ec8e2755621bddb454f279acbd1e177ddf7edf15 100644 (file)
@@ -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                         \
index 664105046b01892b4944c819ee602ea7e1ebbe75..bb5aaaf60820cd0e066ddbe6363efbcf1f476f02 100644 (file)
 #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"
index 813ad265ee8a603279f03a22c23a692edf4c83c7..ac2f40a55378f2c209e9518bde1589f79d86f8eb 100644 (file)
@@ -77,6 +77,7 @@
 #include "rephist.h"
 #include "router.h"
 
+#include "cell_st.h"
 #include "or_circuit_st.h"
 
 // trunnel
index 958c1e2bb5d5ce15790de21b2b19bf3d5d5a4f81..66c863a828f503b74c8d96c9abe7ea4919cdd03c 100644 (file)
@@ -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. */
index 75eb2a7e7fa529dc9b9dd4f2fe61ea53dceb3670..84620ce37dbf3a403aade55c84ec4ab9d1cb24d2 100644 (file)
@@ -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
index ff97b52664109057b10b31172a4a34bb035ee144..62c9204dbec020e2fb40fdbf7a2f9262dd234f7a 100644 (file)
 #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"
index 7603d3b4e127e071165aa8ec71360d48988505b1..82ff9aca88fd8ed9e0883c6a3716cd637ccbd81f 100644 (file)
@@ -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 (file)
index 0000000..1a9ea07
--- /dev/null
@@ -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
+
index 784bcf326b146d1c488755195d508c1fdd0e3217..cce94a1ce03b5960bc5a6e9d43ebcd4a32c9c291 100644 (file)
@@ -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)
index 54d9716780ca13b4bab6dedde6865db8fba55a61..fe9cfaf4afd8d61b2749cc9cff91d0ebe0c66518 100644 (file)
 #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>
index b41f7ac380528c93a886a731515cb4066287144d..a333fc55e814ca2c8a5de5d1007e465ff53ff948 100644 (file)
@@ -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"
 
index fbc964ecc0fbecc8466db4004b89cf0223e92d6c..ba9d8bfb297c3e94eb07ae6259b122c9926bfdb2 100644 (file)
 #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"
index 206b57ad1aa9843e1c673482af9711a20454c884..b2b9dc8d320b9c4a32c23f02f16b84c9f1c4d679 100644 (file)
@@ -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"
index 14c7598703936d04def348ac66f14d7c916906ef..85d91ab8b28e512513e7656cd0033c56bb62e757 100644 (file)
@@ -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)
index fc32665a1802ea4e31f10ccd98441abf9f19b4c8..7b6aa25e60d8971720803bd632b8f2a236191bd4 100644 (file)
@@ -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"
index 1c2e91b83c8e2f6eedd19594c2bcbb00168ad361..1447d0435a2d6dc386efdca35e7bcda3434c64b6 100644 (file)
@@ -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"
index fcee7cc73ffd1a8b46d2dbecc652ef0a806cb886..8d506271af6c00831ebe3cc783f1370a10b6778d 100644 (file)
@@ -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"
index 263ca474477b0ebecce881ccd21c787c300abbe2..e2d063a772939837e96e28e2c41b374c11fee367 100644 (file)
@@ -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)
 {
index 4a526671be14cfa91e86047fb8cef4d44a66ccd8..df1cfd79af7643ab46428e6e1889af627078f31f 100644 (file)
@@ -9,6 +9,7 @@
 /* For init/free stuff */
 #include "scheduler.h"
 
+#include "cell_st.h"
 #include "or_circuit_st.h"
 
 /* Test suite stuff */
index b5aba766d97b71b344290f7a521922e592d5b2c0..dc42709e03c914f6942fb49c95c23fad701676a3 100644 (file)
@@ -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"
index 62bcedabc9a79aaa63d961d8bb23b76c664313c5..9f6b5bbe6629e35d6496eaf3301c1f9e3b75193c 100644 (file)
@@ -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"