[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Split listener_connection_t into its own header



commit 6c0fe9d07c40ce453b5c9c7a60cbfd13bf3ca6d7
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Fri Jun 15 10:37:33 2018 -0400

    Split listener_connection_t into its own header
    
    For once, it's a type that is used almost nowhere else besides the
    logical place.
---
 src/or/connection.c             | 10 ++++++++++
 src/or/connection.h             |  2 ++
 src/or/dnsserv.c                |  1 +
 src/or/include.am               |  1 +
 src/or/listener_connection_st.h | 23 +++++++++++++++++++++++
 src/or/or.h                     | 21 +--------------------
 6 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/src/or/connection.c b/src/or/connection.c
index 8c7341992..11da4fc97 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -116,6 +116,7 @@
 #include "dir_connection_st.h"
 #include "control_connection_st.h"
 #include "entry_connection_st.h"
+#include "listener_connection_st.h"
 #include "port_cfg_st.h"
 
 static connection_t *connection_listener_new(
@@ -172,6 +173,15 @@ static smartlist_t *outgoing_addrs = NULL;
 
 /**************************************************************/
 
+/** Convert a connection_t* to an listener_connection_t*; assert if the cast
+ * is invalid. */
+listener_connection_t *
+TO_LISTENER_CONN(connection_t *c)
+{
+  tor_assert(c->magic == LISTENER_CONNECTION_MAGIC);
+  return DOWNCAST(listener_connection_t, c);
+}
+
 /**
  * Return the human-readable name for the connection type <b>type</b>
  */
diff --git a/src/or/connection.h b/src/or/connection.h
index 59720ce3b..df3388239 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -12,6 +12,8 @@
 #ifndef TOR_CONNECTION_H
 #define TOR_CONNECTION_H
 
+listener_connection_t *TO_LISTENER_CONN(connection_t *);
+
 /* XXXX For buf_datalen in inline function */
 #include "buffers.h"
 
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 46fb8f0a0..020cabb16 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -32,6 +32,7 @@
 
 #include "control_connection_st.h"
 #include "entry_connection_st.h"
+#include "listener_connection_st.h"
 
 #include <event2/dns.h>
 #include <event2/dns_compat.h>
diff --git a/src/or/include.am b/src/or/include.am
index 5249f683d..1de42b7c7 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -238,6 +238,7 @@ ORHEADERS = \
 	src/or/hs_stats.h				\
 	src/or/hs_service.h				\
 	src/or/keypin.h					\
+	src/or/listener_connection_st.h			\
 	src/or/main.h					\
 	src/or/microdesc.h				\
 	src/or/networkstatus.h				\
diff --git a/src/or/listener_connection_st.h b/src/or/listener_connection_st.h
new file mode 100644
index 000000000..67718c5a3
--- /dev/null
+++ b/src/or/listener_connection_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 LISTENER_CONNECTION_ST_H
+#define LISTENER_CONNECTION_ST_H
+
+/** Subtype of connection_t; used for a listener socket. */
+struct listener_connection_t {
+  connection_t base_;
+
+  /** If the connection is a CONN_TYPE_AP_DNS_LISTENER, this field points
+   * to the evdns_server_port it uses to listen to and answer connections. */
+  struct evdns_server_port *dns_server_port;
+
+  entry_port_cfg_t entry_cfg;
+
+};
+
+#endif
+
diff --git a/src/or/or.h b/src/or/or.h
index d9e074d4c..443e76f35 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1381,18 +1381,6 @@ typedef struct connection_t {
   uint32_t n_written_conn_bw;
 } connection_t;
 
-/** Subtype of connection_t; used for a listener socket. */
-typedef struct listener_connection_t {
-  connection_t base_;
-
-  /** If the connection is a CONN_TYPE_AP_DNS_LISTENER, this field points
-   * to the evdns_server_port it uses to listen to and answer connections. */
-  struct evdns_server_port *dns_server_port;
-
-  entry_port_cfg_t entry_cfg;
-
-} listener_connection_t;
-
 /** Minimum length of the random part of an AUTH_CHALLENGE cell. */
 #define OR_AUTH_CHALLENGE_LEN 32
 
@@ -1643,6 +1631,7 @@ typedef struct control_connection_t control_connection_t;
 typedef struct dir_connection_t dir_connection_t;
 typedef struct edge_connection_t edge_connection_t;
 typedef struct entry_connection_t entry_connection_t;
+typedef struct listener_connection_t listener_connection_t;
 
 /** Cast a connection_t subtype pointer to a connection_t **/
 #define TO_CONN(c) (&(((c)->base_)))
@@ -1653,20 +1642,12 @@ typedef struct entry_connection_t entry_connection_t;
 /** Convert a connection_t* to an or_connection_t*; assert if the cast is
  * invalid. */
 static or_connection_t *TO_OR_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 *);
 
 static inline or_connection_t *TO_OR_CONN(connection_t *c)
 {
   tor_assert(c->magic == OR_CONNECTION_MAGIC);
   return DOWNCAST(or_connection_t, c);
 }
-static inline listener_connection_t *TO_LISTENER_CONN(connection_t *c)
-{
-  tor_assert(c->magic == LISTENER_CONNECTION_MAGIC);
-  return DOWNCAST(listener_connection_t, c);
-}
 
 /** What action type does an address policy indicate: accept or reject? */
 typedef enum {



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits