commit 5d5c442e6ad726382c7b8efc0e999825a783bd9e
Author: Nick Mathewson <nickm(a)torproject.org>
Date: Fri Jun 15 10:07:17 2018 -0400
Split entry and edge_connection_t into their own headers.
---
src/or/addressmap.c | 2 +
src/or/circuitbuild.c | 2 +
src/or/circuitlist.c | 2 +
src/or/circuituse.c | 2 +
src/or/connection.c | 1 +
src/or/connection_edge.c | 26 ++++++
src/or/connection_edge.h | 6 +-
src/or/control.c | 2 +
src/or/directory.c | 1 +
src/or/dns.c | 3 +
src/or/dnsserv.c | 3 +
src/or/edge_connection_st.h | 75 ++++++++++++++++
src/or/entry_connection_st.h | 100 ++++++++++++++++++++++
src/or/hs_client.c | 2 +
src/or/hs_common.c | 2 +
src/or/hs_service.c | 2 +
src/or/include.am | 2 +
src/or/main.c | 1 +
src/or/or.h | 174 +-------------------------------------
src/or/relay.c | 2 +
src/or/rendclient.c | 2 +
src/or/rendservice.c | 2 +
src/test/fuzz/fuzz_http_connect.c | 2 +
src/test/test_connection.c | 3 +
src/test/test_dns.c | 2 +
src/test/test_entryconn.c | 2 +
src/test/test_hs_client.c | 2 +
src/test/test_oom.c | 2 +
src/test/test_relaycell.c | 2 +
29 files changed, 256 insertions(+), 173 deletions(-)
diff --git a/src/or/addressmap.c b/src/or/addressmap.c
index 7f861e4d2..9808b7bdd 100644
--- a/src/or/addressmap.c
+++ b/src/or/addressmap.c
@@ -26,6 +26,8 @@
#include "nodelist.h"
#include "routerset.h"
+#include "entry_connection_st.h"
+
/** A client-side struct to remember requests to rewrite addresses
* to new addresses. These structs are stored in the hash table
* "addressmap" below.
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 3d1c9c1ab..883f93074 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -65,6 +65,8 @@
#include "routerset.h"
#include "transports.h"
+#include "entry_connection_st.h"
+
static channel_t * channel_connect_for_circuit(const tor_addr_t *addr,
uint16_t port,
const char *id_digest,
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index 45fff7cc1..e0ee28428 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -91,6 +91,8 @@
#include "ht.h"
+#include "edge_connection_st.h"
+
/********* START VARIABLES **********/
/** A global list of all circuits at this hop. */
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 8e007ce92..5494bf94e 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -56,6 +56,8 @@
#include "router.h"
#include "routerlist.h"
+#include "entry_connection_st.h"
+
static void circuit_expire_old_circuits_clientside(void);
static void circuit_increment_failure_count(void);
diff --git a/src/or/connection.c b/src/or/connection.c
index 0f6498225..fb16ac7b5 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -113,6 +113,7 @@
#include <sys/un.h>
#endif
+#include "entry_connection_st.h"
#include "port_cfg_st.h"
static connection_t *connection_listener_new(
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 046369af6..4bd50398b 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -97,6 +97,8 @@
#include "routerset.h"
#include "circuitbuild.h"
+#include "entry_connection_st.h"
+
#ifdef HAVE_LINUX_TYPES_H
#include <linux/types.h>
#endif
@@ -137,6 +139,30 @@ static int connection_exit_connect_dir(edge_connection_t *exitconn);
static int consider_plaintext_ports(entry_connection_t *conn, uint16_t port);
static int connection_ap_supports_optimistic_data(const entry_connection_t *);
+/** Convert a connection_t* to an edge_connection_t*; assert if the cast is
+ * invalid. */
+edge_connection_t *
+TO_EDGE_CONN(connection_t *c)
+{
+ tor_assert(c->magic == EDGE_CONNECTION_MAGIC ||
+ c->magic == ENTRY_CONNECTION_MAGIC);
+ return DOWNCAST(edge_connection_t, c);
+}
+
+entry_connection_t *
+TO_ENTRY_CONN(connection_t *c)
+{
+ tor_assert(c->magic == ENTRY_CONNECTION_MAGIC);
+ return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
+}
+
+entry_connection_t *
+EDGE_TO_ENTRY_CONN(edge_connection_t *c)
+{
+ tor_assert(c->base_.magic == ENTRY_CONNECTION_MAGIC);
+ return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
+}
+
/** An AP stream has failed/finished. If it hasn't already sent back
* a socks reply, send one now (based on endreason). Also set
* has_sent_end to 1, and mark the conn.
diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h
index c6583d384..27d2c8614 100644
--- a/src/or/connection_edge.h
+++ b/src/or/connection_edge.h
@@ -14,7 +14,11 @@
#include "testsupport.h"
-#define connection_mark_unattached_ap(conn, endreason) \
+edge_connection_t *TO_EDGE_CONN(connection_t *);
+entry_connection_t *TO_ENTRY_CONN(connection_t *);
+entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
+
+#define connection_mark_unattached_ap(conn, endreason) \
connection_mark_unattached_ap_((conn), (endreason), __LINE__, SHORT_FILE__)
MOCK_DECL(void,connection_mark_unattached_ap_,
diff --git a/src/or/control.c b/src/or/control.c
index 0d637dce7..7efa6d73b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -81,6 +81,8 @@
#include "routerparse.h"
#include "shared_random_client.h"
+#include "entry_connection_st.h"
+
#ifndef _WIN32
#include <pwd.h>
#include <sys/resource.h>
diff --git a/src/or/directory.c b/src/or/directory.c
index a65f1fb14..7321a97fc 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -54,6 +54,7 @@
#include "dirauth/shared_random.h"
#include "dir_server_st.h"
+#include "entry_connection_st.h"
/**
* \file directory.c
diff --git a/src/or/dns.c b/src/or/dns.c
index ba734ed90..422751553 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -64,6 +64,9 @@
#include "router.h"
#include "ht.h"
#include "sandbox.h"
+
+#include "edge_connection_st.h"
+
#include <event2/event.h>
#include <event2/dns.h>
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 7e344deea..39c96ee00 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -29,6 +29,9 @@
#include "control.h"
#include "main.h"
#include "policies.h"
+
+#include "entry_connection_st.h"
+
#include <event2/dns.h>
#include <event2/dns_compat.h>
/* XXXX this implies we want an improved evdns */
diff --git a/src/or/edge_connection_st.h b/src/or/edge_connection_st.h
new file mode 100644
index 000000000..3cffdea32
--- /dev/null
+++ b/src/or/edge_connection_st.h
@@ -0,0 +1,75 @@
+/* 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 EDGE_CONNECTION_ST_H
+#define EDGE_CONNECTION_ST_H
+
+#include "or.h"
+
+/** Subtype of connection_t for an "edge connection" -- that is, an entry (ap)
+ * connection, or an exit. */
+struct edge_connection_t {
+ connection_t base_;
+
+ struct edge_connection_t *next_stream; /**< Points to the next stream at this
+ * edge, if any */
+ int package_window; /**< How many more relay cells can I send into the
+ * circuit? */
+ int deliver_window; /**< How many more relay cells can end at me? */
+
+ struct circuit_t *on_circuit; /**< The circuit (if any) that this edge
+ * connection is using. */
+
+ /** A pointer to which node in the circ this conn exits at. Set for AP
+ * connections and for hidden service exit connections. */
+ struct crypt_path_t *cpath_layer;
+ /** What rendezvous service are we querying for (if an AP) or providing (if
+ * an exit)? */
+ rend_data_t *rend_data;
+
+ /* Hidden service connection identifier for edge connections. Used by the HS
+ * client-side code to identify client SOCKS connections and by the
+ * service-side code to match HS circuits with their streams. */
+ struct hs_ident_edge_conn_t *hs_ident;
+
+ uint32_t address_ttl; /**< TTL for address-to-addr mapping on exit
+ * connection. Exit connections only. */
+ uint32_t begincell_flags; /** Flags sent or received in the BEGIN cell
+ * for this connection */
+
+ streamid_t stream_id; /**< The stream ID used for this edge connection on its
+ * circuit */
+
+ /** The reason why this connection is closing; passed to the controller. */
+ uint16_t end_reason;
+
+ /** Bytes read since last call to control_event_stream_bandwidth_used() */
+ uint32_t n_read;
+
+ /** Bytes written since last call to control_event_stream_bandwidth_used() */
+ uint32_t n_written;
+
+ /** True iff this connection is for a DNS request only. */
+ unsigned int is_dns_request:1;
+ /** True iff this connection is for a PTR DNS request. (exit only) */
+ unsigned int is_reverse_dns_lookup:1;
+
+ unsigned int edge_has_sent_end:1; /**< For debugging; only used on edge
+ * connections. Set once we've set the stream end,
+ * and check in connection_about_to_close_connection().
+ */
+ /** True iff we've blocked reading until the circuit has fewer queued
+ * cells. */
+ unsigned int edge_blocked_on_circ:1;
+
+ /** Unique ID for directory requests; this used to be in connection_t, but
+ * that's going away and being used on channels instead. We still tag
+ * edge connections with dirreq_id from circuits, so it's copied here. */
+ uint64_t dirreq_id;
+};
+
+#endif
+
diff --git a/src/or/entry_connection_st.h b/src/or/entry_connection_st.h
new file mode 100644
index 000000000..c3b1ad2ab
--- /dev/null
+++ b/src/or/entry_connection_st.h
@@ -0,0 +1,100 @@
+/* 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 ENTRY_CONNECTION_ST_H
+#define ENTRY_CONNECTION_ST_H
+
+#include "edge_connection_st.h"
+
+/** Subtype of edge_connection_t for an "entry connection" -- that is, a SOCKS
+ * connection, a DNS request, a TransPort connection or a NATD connection */
+struct entry_connection_t {
+ struct edge_connection_t edge_;
+
+ /** Nickname of planned exit node -- used with .exit support. */
+ /* XXX prop220: we need to make chosen_exit_name able to encode Ed IDs too.
+ * That's logically part of the UI parts for prop220 though. */
+ char *chosen_exit_name;
+
+ socks_request_t *socks_request; /**< SOCKS structure describing request (AP
+ * only.) */
+
+ /* === Isolation related, AP only. === */
+ entry_port_cfg_t entry_cfg;
+ /** AP only: The newnym epoch in which we created this connection. */
+ unsigned nym_epoch;
+
+ /** AP only: The original requested address before we rewrote it. */
+ char *original_dest_address;
+ /* Other fields to isolate on already exist. The ClientAddr is addr. The
+ ClientProtocol is a combination of type and socks_request->
+ socks_version. SocksAuth is socks_request->username/password.
+ DestAddr is in socks_request->address. */
+
+ /** Number of times we've reassigned this application connection to
+ * a new circuit. We keep track because the timeout is longer if we've
+ * already retried several times. */
+ uint8_t num_socks_retries;
+
+ /** For AP connections only: buffer for data that we have sent
+ * optimistically, which we might need to re-send if we have to
+ * retry this connection. */
+ struct buf_t *pending_optimistic_data;
+ /* For AP connections only: buffer for data that we previously sent
+ * optimistically which we are currently re-sending as we retry this
+ * connection. */
+ struct buf_t *sending_optimistic_data;
+
+ /** If this is a DNSPort connection, this field holds the pending DNS
+ * request that we're going to try to answer. */
+ struct evdns_server_request *dns_server_request;
+
+#define DEBUGGING_17659
+
+#ifdef DEBUGGING_17659
+ uint16_t marked_pending_circ_line;
+ const char *marked_pending_circ_file;
+#endif
+
+#define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10
+ /** Number of times we've launched a circuit to handle this stream. If
+ * it gets too high, that could indicate an inconsistency between our
+ * "launch a circuit to handle this stream" logic and our "attach our
+ * stream to one of the available circuits" logic. */
+ unsigned int num_circuits_launched:4;
+
+ /** True iff this stream must attach to a one-hop circuit (e.g. for
+ * begin_dir). */
+ unsigned int want_onehop:1;
+ /** True iff this stream should use a BEGIN_DIR relay command to establish
+ * itself rather than BEGIN (either via onehop or via a whole circuit). */
+ unsigned int use_begindir:1;
+
+ /** For AP connections only. If 1, and we fail to reach the chosen exit,
+ * stop requiring it. */
+ unsigned int chosen_exit_optional:1;
+ /** For AP connections only. If non-zero, this exit node was picked as
+ * a result of the TrackHostExit, and the value decrements every time
+ * we fail to complete a circuit to our chosen exit -- if it reaches
+ * zero, abandon the associated mapaddress. */
+ unsigned int chosen_exit_retries:3;
+
+ /** True iff this is an AP connection that came from a transparent or
+ * NATd connection */
+ unsigned int is_transparent_ap:1;
+
+ /** For AP connections only: Set if this connection's target exit node
+ * allows optimistic data (that is, data sent on this stream before
+ * the exit has sent a CONNECTED cell) and we have chosen to use it.
+ */
+ unsigned int may_use_optimistic_data : 1;
+};
+
+/** Cast a entry_connection_t subtype pointer to a edge_connection_t **/
+#define ENTRY_TO_EDGE_CONN(c) (&(((c))->edge_))
+
+#endif
+
diff --git a/src/or/hs_client.c b/src/or/hs_client.c
index 26e8785d9..8c04026a7 100644
--- a/src/or/hs_client.c
+++ b/src/or/hs_client.c
@@ -35,6 +35,8 @@
#include "router.h"
#include "routerset.h"
+#include "entry_connection_st.h"
+
/* Return a human-readable string for the client fetch status code. */
static const char *
fetch_status_to_string(hs_client_fetch_status_t status)
diff --git a/src/or/hs_common.c b/src/or/hs_common.c
index 3081ad216..33c09b53f 100644
--- a/src/or/hs_common.c
+++ b/src/or/hs_common.c
@@ -33,6 +33,8 @@
#include "shared_random_client.h"
#include "dirauth/shared_random_state.h"
+#include "edge_connection_st.h"
+
/* Trunnel */
#include "ed25519_cert.h"
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index f1f26954a..44ee7bb66 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -39,6 +39,8 @@
#include "hs_service.h"
#include "hs_stats.h"
+#include "edge_connection_st.h"
+
/* Trunnel */
#include "ed25519_cert.h"
#include "hs/cell_common.h"
diff --git a/src/or/include.am b/src/or/include.am
index b6e8e6daf..2c5c759ca 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -211,6 +211,8 @@ ORHEADERS = \
src/or/dns_structs.h \
src/or/dnsserv.h \
src/or/dos.h \
+ src/or/edge_connection_st.h \
+ src/or/entry_connection_st.h \
src/or/entry_port_cfg_st.h \
src/or/ext_orport.h \
src/or/fallback_dirs.inc \
diff --git a/src/or/main.c b/src/or/main.c
index 1f6d16a19..3bbd0a1d4 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 "entry_connection_st.h"
#include "port_cfg_st.h"
#ifdef HAVE_SYSTEMD
diff --git a/src/or/or.h b/src/or/or.h
index bf2efd147..b592484a5 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1639,151 +1639,8 @@ typedef struct or_connection_t {
uint64_t bytes_xmitted, bytes_xmitted_by_tls;
} or_connection_t;
-/** Subtype of connection_t for an "edge connection" -- that is, an entry (ap)
- * connection, or an exit. */
-typedef struct edge_connection_t {
- connection_t base_;
-
- struct edge_connection_t *next_stream; /**< Points to the next stream at this
- * edge, if any */
- int package_window; /**< How many more relay cells can I send into the
- * circuit? */
- int deliver_window; /**< How many more relay cells can end at me? */
-
- struct circuit_t *on_circuit; /**< The circuit (if any) that this edge
- * connection is using. */
-
- /** A pointer to which node in the circ this conn exits at. Set for AP
- * connections and for hidden service exit connections. */
- struct crypt_path_t *cpath_layer;
- /** What rendezvous service are we querying for (if an AP) or providing (if
- * an exit)? */
- rend_data_t *rend_data;
-
- /* Hidden service connection identifier for edge connections. Used by the HS
- * client-side code to identify client SOCKS connections and by the
- * service-side code to match HS circuits with their streams. */
- struct hs_ident_edge_conn_t *hs_ident;
-
- uint32_t address_ttl; /**< TTL for address-to-addr mapping on exit
- * connection. Exit connections only. */
- uint32_t begincell_flags; /** Flags sent or received in the BEGIN cell
- * for this connection */
-
- streamid_t stream_id; /**< The stream ID used for this edge connection on its
- * circuit */
-
- /** The reason why this connection is closing; passed to the controller. */
- uint16_t end_reason;
-
- /** Bytes read since last call to control_event_stream_bandwidth_used() */
- uint32_t n_read;
-
- /** Bytes written since last call to control_event_stream_bandwidth_used() */
- uint32_t n_written;
-
- /** True iff this connection is for a DNS request only. */
- unsigned int is_dns_request:1;
- /** True iff this connection is for a PTR DNS request. (exit only) */
- unsigned int is_reverse_dns_lookup:1;
-
- unsigned int edge_has_sent_end:1; /**< For debugging; only used on edge
- * connections. Set once we've set the stream end,
- * and check in connection_about_to_close_connection().
- */
- /** True iff we've blocked reading until the circuit has fewer queued
- * cells. */
- unsigned int edge_blocked_on_circ:1;
-
- /** Unique ID for directory requests; this used to be in connection_t, but
- * that's going away and being used on channels instead. We still tag
- * edge connections with dirreq_id from circuits, so it's copied here. */
- uint64_t dirreq_id;
-} edge_connection_t;
-
-/** Subtype of edge_connection_t for an "entry connection" -- that is, a SOCKS
- * connection, a DNS request, a TransPort connection or a NATD connection */
-typedef struct entry_connection_t {
- edge_connection_t edge_;
-
- /** Nickname of planned exit node -- used with .exit support. */
- /* XXX prop220: we need to make chosen_exit_name able to encode Ed IDs too.
- * That's logically part of the UI parts for prop220 though. */
- char *chosen_exit_name;
-
- socks_request_t *socks_request; /**< SOCKS structure describing request (AP
- * only.) */
-
- /* === Isolation related, AP only. === */
- entry_port_cfg_t entry_cfg;
- /** AP only: The newnym epoch in which we created this connection. */
- unsigned nym_epoch;
-
- /** AP only: The original requested address before we rewrote it. */
- char *original_dest_address;
- /* Other fields to isolate on already exist. The ClientAddr is addr. The
- ClientProtocol is a combination of type and socks_request->
- socks_version. SocksAuth is socks_request->username/password.
- DestAddr is in socks_request->address. */
-
- /** Number of times we've reassigned this application connection to
- * a new circuit. We keep track because the timeout is longer if we've
- * already retried several times. */
- uint8_t num_socks_retries;
-
- /** For AP connections only: buffer for data that we have sent
- * optimistically, which we might need to re-send if we have to
- * retry this connection. */
- struct buf_t *pending_optimistic_data;
- /* For AP connections only: buffer for data that we previously sent
- * optimistically which we are currently re-sending as we retry this
- * connection. */
- struct buf_t *sending_optimistic_data;
-
- /** If this is a DNSPort connection, this field holds the pending DNS
- * request that we're going to try to answer. */
- struct evdns_server_request *dns_server_request;
-
-#define DEBUGGING_17659
-
-#ifdef DEBUGGING_17659
- uint16_t marked_pending_circ_line;
- const char *marked_pending_circ_file;
-#endif
-
-#define NUM_CIRCUITS_LAUNCHED_THRESHOLD 10
- /** Number of times we've launched a circuit to handle this stream. If
- * it gets too high, that could indicate an inconsistency between our
- * "launch a circuit to handle this stream" logic and our "attach our
- * stream to one of the available circuits" logic. */
- unsigned int num_circuits_launched:4;
-
- /** True iff this stream must attach to a one-hop circuit (e.g. for
- * begin_dir). */
- unsigned int want_onehop:1;
- /** True iff this stream should use a BEGIN_DIR relay command to establish
- * itself rather than BEGIN (either via onehop or via a whole circuit). */
- unsigned int use_begindir:1;
-
- /** For AP connections only. If 1, and we fail to reach the chosen exit,
- * stop requiring it. */
- unsigned int chosen_exit_optional:1;
- /** For AP connections only. If non-zero, this exit node was picked as
- * a result of the TrackHostExit, and the value decrements every time
- * we fail to complete a circuit to our chosen exit -- if it reaches
- * zero, abandon the associated mapaddress. */
- unsigned int chosen_exit_retries:3;
-
- /** True iff this is an AP connection that came from a transparent or
- * NATd connection */
- unsigned int is_transparent_ap:1;
-
- /** For AP connections only: Set if this connection's target exit node
- * allows optimistic data (that is, data sent on this stream before
- * the exit has sent a CONNECTED cell) and we have chosen to use it.
- */
- unsigned int may_use_optimistic_data : 1;
-} entry_connection_t;
+typedef struct edge_connection_t edge_connection_t;
+typedef struct entry_connection_t entry_connection_t;
/** Subtype of connection_t for an "directory connection" -- that is, an HTTP
* connection to retrieve or serve directory material. */
@@ -1873,8 +1730,6 @@ typedef struct control_connection_t {
/** Cast a connection_t subtype pointer to a connection_t **/
#define TO_CONN(c) (&(((c)->base_)))
-/** Cast a entry_connection_t subtype pointer to a edge_connection_t **/
-#define ENTRY_TO_EDGE_CONN(c) (&(((c))->edge_))
/** Cast a entry_connection_t subtype pointer to a connection_t **/
#define ENTRY_TO_CONN(c) (TO_CONN(ENTRY_TO_EDGE_CONN(c)))
@@ -1884,15 +1739,6 @@ static or_connection_t *TO_OR_CONN(connection_t *);
/** Convert a connection_t* to a dir_connection_t*; assert if the cast is
* invalid. */
static dir_connection_t *TO_DIR_CONN(connection_t *);
-/** Convert a connection_t* to an edge_connection_t*; assert if the cast is
- * invalid. */
-static edge_connection_t *TO_EDGE_CONN(connection_t *);
-/** Convert a connection_t* to an entry_connection_t*; assert if the cast is
- * invalid. */
-static entry_connection_t *TO_ENTRY_CONN(connection_t *);
-/** Convert a edge_connection_t* to an entry_connection_t*; assert if the cast
- * is invalid. */
-static entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *);
/** Convert a connection_t* to an control_connection_t*; assert if the cast is
* invalid. */
static control_connection_t *TO_CONTROL_CONN(connection_t *);
@@ -1910,22 +1756,6 @@ static inline dir_connection_t *TO_DIR_CONN(connection_t *c)
tor_assert(c->magic == DIR_CONNECTION_MAGIC);
return DOWNCAST(dir_connection_t, c);
}
-static inline edge_connection_t *TO_EDGE_CONN(connection_t *c)
-{
- tor_assert(c->magic == EDGE_CONNECTION_MAGIC ||
- c->magic == ENTRY_CONNECTION_MAGIC);
- return DOWNCAST(edge_connection_t, c);
-}
-static inline entry_connection_t *TO_ENTRY_CONN(connection_t *c)
-{
- tor_assert(c->magic == ENTRY_CONNECTION_MAGIC);
- return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_.base_);
-}
-static inline entry_connection_t *EDGE_TO_ENTRY_CONN(edge_connection_t *c)
-{
- tor_assert(c->base_.magic == ENTRY_CONNECTION_MAGIC);
- return (entry_connection_t*) SUBTYPE_P(c, entry_connection_t, edge_);
-}
static inline control_connection_t *TO_CONTROL_CONN(connection_t *c)
{
tor_assert(c->magic == CONTROL_CONNECTION_MAGIC);
diff --git a/src/or/relay.c b/src/or/relay.c
index 50f59d6b9..757613e9d 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -81,6 +81,8 @@
#include "scheduler.h"
#include "rephist.h"
+#include "entry_connection_st.h"
+
static edge_connection_t *relay_lookup_conn(circuit_t *circ, cell_t *cell,
cell_direction_t cell_direction,
crypt_path_t *layer_hint);
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 7ef12a4fa..c153862e6 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -33,6 +33,8 @@
#include "routerlist.h"
#include "routerset.h"
+#include "entry_connection_st.h"
+
static extend_info_t *rend_client_get_random_intro_impl(
const rend_cache_entry_t *rend_query,
const int strict, const int warnings);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 92c323b10..4d9309e49 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -36,6 +36,8 @@
#include "routerparse.h"
#include "routerset.h"
+#include "edge_connection_st.h"
+
struct rend_service_t;
static origin_circuit_t *find_intro_circuit(rend_intro_point_t *intro,
const char *pk_digest);
diff --git a/src/test/fuzz/fuzz_http_connect.c b/src/test/fuzz/fuzz_http_connect.c
index dc674070b..4b1ea8c72 100644
--- a/src/test/fuzz/fuzz_http_connect.c
+++ b/src/test/fuzz/fuzz_http_connect.c
@@ -15,6 +15,8 @@
#include "proto_socks.h"
#include "torlog.h"
+#include "entry_connection_st.h"
+
#include "fuzzing.h"
static void
diff --git a/src/test/test_connection.c b/src/test/test_connection.c
index dc0f6860d..05c4bb7f1 100644
--- a/src/test/test_connection.c
+++ b/src/test/test_connection.c
@@ -11,6 +11,7 @@
#include "test.h"
#include "connection.h"
+#include "connection_edge.h"
#include "hs_common.h"
#include "main.h"
#include "microdesc.h"
@@ -23,6 +24,8 @@
#include "test_connection.h"
#include "test_helpers.h"
+#include "entry_connection_st.h"
+
static void * test_conn_get_basic_setup(const struct testcase_t *tc);
static int test_conn_get_basic_teardown(const struct testcase_t *tc,
void *arg);
diff --git a/src/test/test_dns.c b/src/test/test_dns.c
index 1fee01d2c..c472b9790 100644
--- a/src/test/test_dns.c
+++ b/src/test/test_dns.c
@@ -10,6 +10,8 @@
#include "connection.h"
#include "router.h"
+#include "edge_connection_st.h"
+
#define NS_MODULE dns
#define NS_SUBMODULE clip_ttl
diff --git a/src/test/test_entryconn.c b/src/test/test_entryconn.c
index 9d8a072c7..ec8d7196e 100644
--- a/src/test/test_entryconn.c
+++ b/src/test/test_entryconn.c
@@ -19,6 +19,8 @@
#include "hs_cache.h"
#include "rendcache.h"
+#include "entry_connection_st.h"
+
static void *
entryconn_rewrite_setup(const struct testcase_t *tc)
{
diff --git a/src/test/test_hs_client.c b/src/test/test_hs_client.c
index 50dca588e..0828364e8 100644
--- a/src/test/test_hs_client.c
+++ b/src/test/test_hs_client.c
@@ -37,6 +37,8 @@
#include "connection_edge.h"
#include "networkstatus.h"
+#include "entry_connection_st.h"
+
static int
mock_connection_ap_handshake_send_begin(entry_connection_t *ap_conn)
{
diff --git a/src/test/test_oom.c b/src/test/test_oom.c
index abf889645..98935fe45 100644
--- a/src/test/test_oom.c
+++ b/src/test/test_oom.c
@@ -18,6 +18,8 @@
#include "test.h"
#include "test_helpers.h"
+#include "entry_connection_st.h"
+
/* small replacement mock for circuit_mark_for_close_ to avoid doing all
* the other bookkeeping that comes with marking circuits. */
static void
diff --git a/src/test/test_relaycell.c b/src/test/test_relaycell.c
index 841174982..b4cb9d4bb 100644
--- a/src/test/test_relaycell.c
+++ b/src/test/test_relaycell.c
@@ -16,6 +16,8 @@
#include "relay.h"
#include "test.h"
+#include "entry_connection_st.h"
+
static int srm_ncalls;
static entry_connection_t *srm_conn;
static int srm_atype;