diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-06-15 10:07:17 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-06-15 10:10:24 -0400 |
commit | 5d5c442e6ad726382c7b8efc0e999825a783bd9e (patch) | |
tree | b840edeb2e62fe8a04b7735bdbec90ebd575c268 /src/or/connection_edge.c | |
parent | 2a574d11ac8747996dcb979b04e38b16c5a0a9de (diff) | |
download | tor-5d5c442e6ad726382c7b8efc0e999825a783bd9e.tar.gz tor-5d5c442e6ad726382c7b8efc0e999825a783bd9e.zip |
Split entry and edge_connection_t into their own headers.
Diffstat (limited to 'src/or/connection_edge.c')
-rw-r--r-- | src/or/connection_edge.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 046369af60..4bd50398bc 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. |