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

[tor-commits] [tor/master] Make server_port_cfg_t and port_cfg_t into separate headers.



commit df9a3fe86f6dfabbe5ae777c3e60ec91edf09d23
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Jun 14 16:41:54 2018 -0400

    Make server_port_cfg_t and port_cfg_t into separate headers.
---
 src/or/config.c             |  2 ++
 src/or/connection.c         |  2 ++
 src/or/include.am           |  2 ++
 src/or/main.c               |  2 ++
 src/or/or.h                 | 32 ++------------------------------
 src/or/policies.c           |  2 ++
 src/or/port_cfg_st.h        | 35 +++++++++++++++++++++++++++++++++++
 src/or/router.c             |  2 ++
 src/or/server_port_cfg_st.h | 20 ++++++++++++++++++++
 src/test/test_config.c      |  1 +
 src/test/test_dir.c         |  2 ++
 src/test/test_policy.c      |  2 ++
 12 files changed, 74 insertions(+), 30 deletions(-)

diff --git a/src/or/config.c b/src/or/config.c
index 94a58f348..51ecca431 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -116,6 +116,8 @@
 #include "dirauth/dirvote.h"
 #include "dirauth/mode.h"
 
+#include "port_cfg_st.h"
+
 #ifdef HAVE_SYSTEMD
 #   if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
 /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse
diff --git a/src/or/connection.c b/src/or/connection.c
index 5185b45b1..0f6498225 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -113,6 +113,8 @@
 #include <sys/un.h>
 #endif
 
+#include "port_cfg_st.h"
+
 static connection_t *connection_listener_new(
                                const struct sockaddr *listensockaddr,
                                socklen_t listensocklen, int type,
diff --git a/src/or/include.am b/src/or/include.am
index c38e677a6..1dc6c79ca 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -246,6 +246,7 @@ ORHEADERS = \
 	src/or/transports.h				\
 	src/or/parsecommon.h			\
 	src/or/periodic.h				\
+	src/or/port_cfg_st.h				\
 	src/or/policies.h				\
 	src/or/protover.h				\
 	src/or/proto_cell.h				\
@@ -270,6 +271,7 @@ ORHEADERS = \
 	src/or/routerset.h				\
 	src/or/routerparse.h				\
 	src/or/scheduler.h				\
+	src/or/server_port_cfg_st.h			\
 	src/or/shared_random_client.h			\
 	src/or/statefile.h				\
 	src/or/status.h					\
diff --git a/src/or/main.c b/src/or/main.c
index 9dce158b3..1f6d16a19 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -122,6 +122,8 @@
 #include "dirauth/mode.h"
 #include "dirauth/shared_random.h"
 
+#include "port_cfg_st.h"
+
 #ifdef HAVE_SYSTEMD
 #   if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
 /* Systemd's use of gcc's __INCLUDE_LEVEL__ extension macro appears to confuse
diff --git a/src/or/or.h b/src/or/or.h
index 5321c81c8..6c54c2752 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1248,15 +1248,7 @@ typedef struct {
 
 typedef struct socks_request_t socks_request_t;
 typedef struct entry_port_cfg_t entry_port_cfg_t;
-
-typedef struct server_port_cfg_t {
-  /* Server port types (or, dir) only: */
-  unsigned int no_advertise : 1;
-  unsigned int no_listen : 1;
-  unsigned int all_addrs : 1;
-  unsigned int bind_ipv4_only : 1;
-  unsigned int bind_ipv6_only : 1;
-} server_port_cfg_t;
+typedef struct server_port_cfg_t server_port_cfg_t;
 
 /* Values for connection_t.magic: used to make sure that downcasts (casts from
 * connection_t to foo_connection_t) are safe. */
@@ -3585,27 +3577,7 @@ static inline const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(
 /** First automatically allocated session group number */
 #define SESSION_GROUP_FIRST_AUTO -4
 
-/** Configuration for a single port that we're listening on. */
-typedef struct port_cfg_t {
-  tor_addr_t addr; /**< The actual IP to listen on, if !is_unix_addr. */
-  int port; /**< The configured port, or CFG_AUTO_PORT to tell Tor to pick its
-             * own port. */
-  uint8_t type; /**< One of CONN_TYPE_*_LISTENER */
-  unsigned is_unix_addr : 1; /**< True iff this is an AF_UNIX address. */
-
-  unsigned is_group_writable : 1;
-  unsigned is_world_writable : 1;
-  unsigned relax_dirmode_check : 1;
-
-  entry_port_cfg_t entry_cfg;
-
-  server_port_cfg_t server_cfg;
-
-  /* Unix sockets only: */
-  /** Path for an AF_UNIX address */
-  char unix_addr[FLEXIBLE_ARRAY_MEMBER];
-} port_cfg_t;
-
+typedef struct port_cfg_t port_cfg_t;
 typedef struct routerset_t routerset_t;
 
 /** A magic value for the (Socks|OR|...)Port options below, telling Tor
diff --git a/src/or/policies.c b/src/or/policies.c
index 1210ca687..a78e8a1c8 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -30,6 +30,8 @@
 #include "geoip.h"
 #include "ht.h"
 
+#include "port_cfg_st.h"
+
 /** Policy that addresses for incoming SOCKS connections must match. */
 static smartlist_t *socks_policy = NULL;
 /** Policy that addresses for incoming directory connections must match. */
diff --git a/src/or/port_cfg_st.h b/src/or/port_cfg_st.h
new file mode 100644
index 000000000..8b6b018c5
--- /dev/null
+++ b/src/or/port_cfg_st.h
@@ -0,0 +1,35 @@
+/* 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 PORT_CFG_ST_H
+#define PORT_CFG_ST_H
+
+#include "entry_port_cfg_st.h"
+#include "server_port_cfg_st.h"
+
+/** Configuration for a single port that we're listening on. */
+struct port_cfg_t {
+  tor_addr_t addr; /**< The actual IP to listen on, if !is_unix_addr. */
+  int port; /**< The configured port, or CFG_AUTO_PORT to tell Tor to pick its
+             * own port. */
+  uint8_t type; /**< One of CONN_TYPE_*_LISTENER */
+  unsigned is_unix_addr : 1; /**< True iff this is an AF_UNIX address. */
+
+  unsigned is_group_writable : 1;
+  unsigned is_world_writable : 1;
+  unsigned relax_dirmode_check : 1;
+
+  entry_port_cfg_t entry_cfg;
+
+  server_port_cfg_t server_cfg;
+
+  /* Unix sockets only: */
+  /** Path for an AF_UNIX address */
+  char unix_addr[FLEXIBLE_ARRAY_MEMBER];
+};
+
+#endif
+
diff --git a/src/or/router.c b/src/or/router.c
index 3879863e8..9eaef4460 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -39,6 +39,8 @@
 
 #include "dirauth/mode.h"
 
+#include "port_cfg_st.h"
+
 /**
  * \file router.c
  * \brief Miscellaneous relay functionality, including RSA key maintenance,
diff --git a/src/or/server_port_cfg_st.h b/src/or/server_port_cfg_st.h
new file mode 100644
index 000000000..7a6a0a53f
--- /dev/null
+++ b/src/or/server_port_cfg_st.h
@@ -0,0 +1,20 @@
+/* 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 SERVER_PORT_CFG_ST_H
+#define SERVER_PORT_CFG_ST_H
+
+struct server_port_cfg_t {
+  /* Server port types (or, dir) only: */
+  unsigned int no_advertise : 1;
+  unsigned int no_listen : 1;
+  unsigned int all_addrs : 1;
+  unsigned int bind_ipv4_only : 1;
+  unsigned int bind_ipv6_only : 1;
+};
+
+#endif
+
diff --git a/src/test/test_config.c b/src/test/test_config.c
index 461aa646d..e8bfe9e12 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -43,6 +43,7 @@
 #include "statefile.h"
 
 #include "test_helpers.h"
+#include "port_cfg_st.h"
 
 static void
 test_config_addressmap(void *arg)
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index 0106e40d9..538fb8db1 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -44,6 +44,8 @@
 #include "log_test_helpers.h"
 #include "voting_schedule.h"
 
+#include "port_cfg_st.h"
+
 #define NS_MODULE dir
 
 static void
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index e89d49aaf..e55452d3e 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -10,6 +10,8 @@
 #include "policies.h"
 #include "test.h"
 
+#include "port_cfg_st.h"
+
 /* Helper: assert that short_policy parses and writes back out as itself,
    or as <b>expected</b> if that's provided. */
 static void



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