Make server_port_cfg_t and port_cfg_t into separate headers.

This commit is contained in:
Nick Mathewson 2018-06-14 16:41:54 -04:00
parent 6896ab28b2
commit df9a3fe86f
12 changed files with 74 additions and 30 deletions

View File

@ -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

View File

@ -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,

View File

@ -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 \

View File

@ -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

View File

@ -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

View File

@ -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. */

35
src/or/port_cfg_st.h Normal file
View File

@ -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

View File

@ -39,6 +39,8 @@
#include "dirauth/mode.h"
#include "port_cfg_st.h"
/**
* \file router.c
* \brief Miscellaneous relay functionality, including RSA key maintenance,

View File

@ -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

View File

@ -43,6 +43,7 @@
#include "statefile.h"
#include "test_helpers.h"
#include "port_cfg_st.h"
static void
test_config_addressmap(void *arg)

View File

@ -44,6 +44,8 @@
#include "log_test_helpers.h"
#include "voting_schedule.h"
#include "port_cfg_st.h"
#define NS_MODULE dir
static void

View File

@ -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