summaryrefslogtreecommitdiff
path: root/src/or/connection_st.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-07-03 11:09:54 -0400
committerNick Mathewson <nickm@torproject.org>2018-07-03 11:09:54 -0400
commit77e678c20daf8633ce1904dd1df28398d820f7c0 (patch)
tree411cb587ea7533b65edf60c8bc2221b072dda807 /src/or/connection_st.h
parenta01b4d7f87f2217f55f5c5113fe19a2d3081a44c (diff)
parent518ebe14dcc7568da353c4c517039d0c621deb28 (diff)
downloadtor-77e678c20daf8633ce1904dd1df28398d820f7c0.tar.gz
tor-77e678c20daf8633ce1904dd1df28398d820f7c0.zip
Merge remote-tracking branch 'github/shrink_or_h_more'
Diffstat (limited to 'src/or/connection_st.h')
-rw-r--r--src/or/connection_st.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/or/connection_st.h b/src/or/connection_st.h
index 2e785c6e6e..6c22478689 100644
--- a/src/or/connection_st.h
+++ b/src/or/connection_st.h
@@ -9,6 +9,16 @@
struct buf_t;
+/* Values for connection_t.magic: used to make sure that downcasts (casts from
+* connection_t to foo_connection_t) are safe. */
+#define BASE_CONNECTION_MAGIC 0x7C3C304Eu
+#define OR_CONNECTION_MAGIC 0x7D31FF03u
+#define EDGE_CONNECTION_MAGIC 0xF0374013u
+#define ENTRY_CONNECTION_MAGIC 0xbb4a5703
+#define DIR_CONNECTION_MAGIC 0x9988ffeeu
+#define CONTROL_CONNECTION_MAGIC 0x8abc765du
+#define LISTENER_CONNECTION_MAGIC 0x1a1ac741u
+
/** Description of a connection to another host or process, and associated
* data.
*
@@ -128,4 +138,12 @@ struct connection_t {
uint32_t n_written_conn_bw;
};
+/** True iff <b>x</b> is an edge connection. */
+#define CONN_IS_EDGE(x) \
+ ((x)->type == CONN_TYPE_EXIT || (x)->type == CONN_TYPE_AP)
+
+/** True iff the purpose of <b>conn</b> means that it's a server-side
+ * directory connection. */
+#define DIR_CONN_IS_SERVER(conn) ((conn)->purpose == DIR_PURPOSE_SERVER)
+
#endif