Browse Source

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.
Nick Mathewson 6 years ago
parent
commit
fde868ffe3

+ 28 - 0
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
+

+ 20 - 0
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
+

+ 2 - 0
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 */

+ 1 - 0
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(

+ 3 - 0
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;

+ 1 - 0
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"

+ 2 - 0
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

+ 1 - 0
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"

+ 2 - 0
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"
 
 /*

+ 2 - 0
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;

+ 1 - 0
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"

+ 3 - 0
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);

+ 27 - 0
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
+

+ 4 - 0
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				\

+ 1 - 0
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"

+ 1 - 0
src/or/onion.c

@@ -77,6 +77,7 @@
 #include "rephist.h"
 #include "router.h"
 
+#include "cell_st.h"
 #include "or_circuit_st.h"
 
 // trunnel

+ 6 - 53
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. */

+ 2 - 0
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

+ 3 - 0
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"

+ 1 - 0
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"
 

+ 23 - 0
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
+

+ 1 - 0
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)

+ 5 - 0
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>

+ 2 - 0
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"
 

+ 2 - 0
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"

+ 1 - 0
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"

+ 2 - 0
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)

+ 1 - 0
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"

+ 1 - 0
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"

+ 1 - 0
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"

+ 2 - 0
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)
 {

+ 1 - 0
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 */

+ 1 - 0
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"

+ 1 - 0
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"