[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Split control_connection_t into its own header.
commit 3b917b2408748efb2ce84c2725e2e81ee0217e03
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Jun 15 10:17:27 2018 -0400
Split control_connection_t into its own header.
This one was actually fairly simple.
---
src/or/connection.c | 1 +
src/or/control.c | 10 ++++++++++
src/or/control.h | 2 ++
src/or/control_connection_st.h | 45 ++++++++++++++++++++++++++++++++++++++++++
src/or/dnsserv.c | 1 +
src/or/include.am | 1 +
src/or/or.h | 41 +-------------------------------------
src/test/test_controller.c | 2 ++
8 files changed, 63 insertions(+), 40 deletions(-)
diff --git a/src/or/connection.c b/src/or/connection.c
index fb16ac7b5..0042d3e0d 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -113,6 +113,7 @@
#include <sys/un.h>
#endif
+#include "control_connection_st.h"
#include "entry_connection_st.h"
#include "port_cfg_st.h"
diff --git a/src/or/control.c b/src/or/control.c
index 7efa6d73b..ba9f26c6b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -81,6 +81,7 @@
#include "routerparse.h"
#include "shared_random_client.h"
+#include "control_connection_st.h"
#include "entry_connection_st.h"
#ifndef _WIN32
@@ -228,6 +229,15 @@ static void flush_queued_events_cb(mainloop_event_t *event, void *arg);
static char * download_status_to_string(const download_status_t *dl);
static void control_get_bytes_rw_last_sec(uint64_t *r, uint64_t *w);
+/** Convert a connection_t* to an control_connection_t*; assert if the cast is
+ * invalid. */
+control_connection_t *
+TO_CONTROL_CONN(connection_t *c)
+{
+ tor_assert(c->magic == CONTROL_CONNECTION_MAGIC);
+ return DOWNCAST(control_connection_t, c);
+}
+
/** Given a control event code for a message event, return the corresponding
* log severity. */
static inline int
diff --git a/src/or/control.h b/src/or/control.h
index 92cbf866d..a499e4533 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -12,6 +12,8 @@
#ifndef TOR_CONTROL_H
#define TOR_CONTROL_H
+control_connection_t *TO_CONTROL_CONN(connection_t *);
+
void control_initialize_event_queue(void);
void control_update_global_event_mask(void);
diff --git a/src/or/control_connection_st.h b/src/or/control_connection_st.h
new file mode 100644
index 000000000..2d8efec1f
--- /dev/null
+++ b/src/or/control_connection_st.h
@@ -0,0 +1,45 @@
+/* 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 CONTROL_CONNECTION_ST_H
+#define CONTROL_CONNECTION_ST_H
+
+#include "or.h"
+
+/** Subtype of connection_t for an connection to a controller. */
+struct control_connection_t {
+ connection_t base_;
+
+ uint64_t event_mask; /**< Bitfield: which events does this controller
+ * care about?
+ * EVENT_MAX_ is >31, so we need a 64 bit mask */
+
+ /** True if we have sent a protocolinfo reply on this connection. */
+ unsigned int have_sent_protocolinfo:1;
+ /** True if we have received a takeownership command on this
+ * connection. */
+ unsigned int is_owning_control_connection:1;
+
+ /** List of ephemeral onion services belonging to this connection. */
+ smartlist_t *ephemeral_onion_services;
+
+ /** If we have sent an AUTHCHALLENGE reply on this connection and
+ * have not received a successful AUTHENTICATE command, points to
+ * the value which the client must send to authenticate itself;
+ * otherwise, NULL. */
+ char *safecookie_client_hash;
+
+ /** Amount of space allocated in incoming_cmd. */
+ uint32_t incoming_cmd_len;
+ /** Number of bytes currently stored in incoming_cmd. */
+ uint32_t incoming_cmd_cur_len;
+ /** A control command that we're reading from the inbuf, but which has not
+ * yet arrived completely. */
+ char *incoming_cmd;
+};
+
+#endif
+
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 39c96ee00..46fb8f0a0 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -30,6 +30,7 @@
#include "main.h"
#include "policies.h"
+#include "control_connection_st.h"
#include "entry_connection_st.h"
#include <event2/dns.h>
diff --git a/src/or/include.am b/src/or/include.am
index 2c5c759ca..cff38d0b6 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -202,6 +202,7 @@ ORHEADERS = \
src/or/conscache.h \
src/or/consdiff.h \
src/or/consdiffmgr.h \
+ src/or/control_connection_st.h \
src/or/control.h \
src/or/cpuworker.h \
src/or/directory.h \
diff --git a/src/or/or.h b/src/or/or.h
index b592484a5..138c5a18d 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1639,6 +1639,7 @@ typedef struct or_connection_t {
uint64_t bytes_xmitted, bytes_xmitted_by_tls;
} or_connection_t;
+typedef struct control_connection_t control_connection_t;
typedef struct edge_connection_t edge_connection_t;
typedef struct entry_connection_t entry_connection_t;
@@ -1695,38 +1696,6 @@ typedef struct dir_connection_t {
#endif /* defined(MEASUREMENTS_21206) */
} dir_connection_t;
-/** Subtype of connection_t for an connection to a controller. */
-typedef struct control_connection_t {
- connection_t base_;
-
- uint64_t event_mask; /**< Bitfield: which events does this controller
- * care about?
- * EVENT_MAX_ is >31, so we need a 64 bit mask */
-
- /** True if we have sent a protocolinfo reply on this connection. */
- unsigned int have_sent_protocolinfo:1;
- /** True if we have received a takeownership command on this
- * connection. */
- unsigned int is_owning_control_connection:1;
-
- /** List of ephemeral onion services belonging to this connection. */
- smartlist_t *ephemeral_onion_services;
-
- /** If we have sent an AUTHCHALLENGE reply on this connection and
- * have not received a successful AUTHENTICATE command, points to
- * the value which the client must send to authenticate itself;
- * otherwise, NULL. */
- char *safecookie_client_hash;
-
- /** Amount of space allocated in incoming_cmd. */
- uint32_t incoming_cmd_len;
- /** Number of bytes currently stored in incoming_cmd. */
- uint32_t incoming_cmd_cur_len;
- /** A control command that we're reading from the inbuf, but which has not
- * yet arrived completely. */
- char *incoming_cmd;
-} control_connection_t;
-
/** Cast a connection_t subtype pointer to a connection_t **/
#define TO_CONN(c) (&(((c)->base_)))
@@ -1739,9 +1708,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 control_connection_t*; assert if the cast is
- * invalid. */
-static control_connection_t *TO_CONTROL_CONN(connection_t *);
/** Convert a connection_t* to an listener_connection_t*; assert if the cast is
* invalid. */
static listener_connection_t *TO_LISTENER_CONN(connection_t *);
@@ -1756,11 +1722,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 control_connection_t *TO_CONTROL_CONN(connection_t *c)
-{
- tor_assert(c->magic == CONTROL_CONNECTION_MAGIC);
- return DOWNCAST(control_connection_t, c);
-}
static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c)
{
tor_assert(c->magic == LISTENER_CONNECTION_MAGIC);
diff --git a/src/test/test_controller.c b/src/test/test_controller.c
index 1a350f66c..6b8edc57c 100644
--- a/src/test/test_controller.c
+++ b/src/test/test_controller.c
@@ -13,6 +13,8 @@
#include "test.h"
#include "test_helpers.h"
+#include "control_connection_st.h"
+
static void
test_add_onion_helper_keyarg_v3(void *arg)
{
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits