From: Guus Sliepen Date: Thu, 17 Jul 2003 15:06:27 +0000 (+0000) Subject: Big header file cleanup: everything that has to do with standard system X-Git-Tag: release-1.0~60 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=e449d94caef963809d417f16497f6f978e10d731;p=oweals%2Ftinc.git Big header file cleanup: everything that has to do with standard system libraries is moved to system.h. --- diff --git a/configure.in b/configure.in index a51bd29..52b9196 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -dnl $Id: configure.in,v 1.13.2.66 2003/07/11 16:12:58 guus Exp $ +dnl $Id: configure.in,v 1.13.2.67 2003/07/17 15:06:25 guus Exp $ AC_PREREQ(2.53) AC_INIT(src/tincd.c) @@ -67,6 +67,10 @@ case $host_os in AC_DEFINE(HAVE_CYGWIN, 1, [Cygwin]) [ rm -f src/device.c; ln -sf cygwin/device.c src/device.c ] ;; + *mingw*) + AC_DEFINE(HAVE_CYGWIN, 1, [MinGW]) + [ rm -f src/device.c; ln -sf mingw/device.c src/device.c ] + ;; *) AC_MSG_ERROR("Unknown operating system.") ;; @@ -85,14 +89,18 @@ dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h malloc.h stdint.h strings.h syslog.h unistd.h \ - sys/file.h sys/ioctl.h sys/param.h sys/time.h netinet/in_systm.h]) -AC_CHECK_HEADERS([net/ethernet.h net/if.h netinet/ip.h netinet/tcp.h netinet/ip6.h], [], [], - [#include - #include - #ifdef HAVE_NETINET_IN_SYSTM_H - #include - #endif]) +AC_CHECK_HEADERS([syslog.h sys/file.h sys/ioctl.h sys/param.h \ + sys/time.h sys/socket.h sys/wait.h netdb.h arpa/inet.h netinet/in_systm.h]) +AC_CHECK_HEADERS([net/ethernet.h net/if.h net/if_arp.h netinet/if_ether.h netinet/ip.h \ + netinet/tcp.h netinet/ip_icmp.h netinet/ip6.h netinet/icmp6.h], + [], [], + [#include + #include + #ifdef HAVE_NETINET_IN_SYSTM_H + #include + #endif + ] +) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST diff --git a/lib/avl_tree.c b/lib/avl_tree.c index fc3c27e..65df7b7 100644 --- a/lib/avl_tree.c +++ b/lib/avl_tree.c @@ -29,14 +29,13 @@ library for inclusion into tinc (http://tinc.nl.linux.org/) by Guus Sliepen . - $Id: avl_tree.c,v 1.1.2.15 2003/07/12 17:48:38 guus Exp $ + $Id: avl_tree.c,v 1.1.2.16 2003/07/17 15:06:25 guus Exp $ */ -#include -#include -#include +#include "system.h" #include "avl_tree.h" +#include "xalloc.h" #ifdef AVL_COUNT #define AVL_NODE_COUNT(n) ((n) ? (n)->count : 0) diff --git a/lib/dropin.c b/lib/dropin.c index 24d25ca..0efa5f2 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -17,23 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: dropin.c,v 1.1.2.14 2003/07/12 17:48:38 guus Exp $ + $Id: dropin.c,v 1.1.2.15 2003/07/17 15:06:25 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include +#include "system.h" #ifndef HAVE_DAEMON /* diff --git a/lib/dropin.h b/lib/dropin.h index e4aa702..c0bf14d 100644 --- a/lib/dropin.h +++ b/lib/dropin.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: dropin.h,v 1.1.2.11 2003/07/12 17:48:38 guus Exp $ + $Id: dropin.h,v 1.1.2.12 2003/07/17 15:06:25 guus Exp $ */ #ifndef __DROPIN_H__ @@ -36,8 +36,6 @@ extern int asprintf(char **, const char *, ...); #endif #ifndef HAVE_GETNAMEINFO -#include -#include extern int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); #endif diff --git a/lib/fake-getaddrinfo.c b/lib/fake-getaddrinfo.c index 5e95a2a..e170680 100644 --- a/lib/fake-getaddrinfo.c +++ b/lib/fake-getaddrinfo.c @@ -9,17 +9,7 @@ * that ai_family is AF_INET. Don't use it for another purpose. */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include +#include "system.h" #include "fake-getaddrinfo.h" diff --git a/lib/fake-getaddrinfo.h b/lib/fake-getaddrinfo.h index 3f24375..db7b147 100644 --- a/lib/fake-getaddrinfo.h +++ b/lib/fake-getaddrinfo.h @@ -1,14 +1,8 @@ -/* $Id: fake-getaddrinfo.h,v 1.1.2.2 2003/07/06 23:16:27 guus Exp $ */ +/* $Id: fake-getaddrinfo.h,v 1.1.2.3 2003/07/17 15:06:25 guus Exp $ */ #ifndef _FAKE_GETADDRINFO_H #define _FAKE_GETADDRINFO_H -#include "config.h" - -#include -#include -#include - #include "fake-gai-errnos.h" #ifndef AI_PASSIVE diff --git a/lib/fake-getnameinfo.c b/lib/fake-getnameinfo.c index 50d0722..8774da2 100644 --- a/lib/fake-getnameinfo.c +++ b/lib/fake-getnameinfo.c @@ -9,17 +9,7 @@ * that ai_family is AF_INET. Don't use it for another purpose. */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include - -#include +#include "system.h" #include "fake-getnameinfo.h" #include "fake-getaddrinfo.h" diff --git a/lib/fake-getnameinfo.h b/lib/fake-getnameinfo.h index 20889a6..1d7b0db 100644 --- a/lib/fake-getnameinfo.h +++ b/lib/fake-getnameinfo.h @@ -1,13 +1,8 @@ -/* $Id: fake-getnameinfo.h,v 1.1.2.2 2003/07/12 17:41:45 guus Exp $ */ +/* $Id: fake-getnameinfo.h,v 1.1.2.3 2003/07/17 15:06:25 guus Exp $ */ #ifndef _FAKE_GETNAMEINFO_H #define _FAKE_GETNAMEINFO_H -#include "config.h" - -#include -#include - #ifndef HAVE_GETNAMEINFO int getnameinfo(const struct sockaddr *sa, size_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags); diff --git a/lib/ipv6.h b/lib/ipv6.h index c04ada2..92a0ae0 100644 --- a/lib/ipv6.h +++ b/lib/ipv6.h @@ -17,19 +17,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: ipv6.h,v 1.1.2.3 2003/07/11 16:12:59 guus Exp $ + $Id: ipv6.h,v 1.1.2.4 2003/07/17 15:06:25 guus Exp $ */ #ifndef __TINC_IPV6_H__ #define __TINC_IPV6_H__ -#include "config.h" - -#include -#ifdef HAVE_INTTYPES_H -#include -#endif - #ifndef AF_INET6 #define AF_INET6 10 #endif diff --git a/lib/list.c b/lib/list.c index 0b516c8..573bc9e 100644 --- a/lib/list.c +++ b/lib/list.c @@ -17,17 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: list.c,v 1.1.2.15 2003/07/12 17:48:38 guus Exp $ + $Id: list.c,v 1.1.2.16 2003/07/17 15:06:25 guus Exp $ */ -#include "config.h" - -#include - -#include -#include +#include "system.h" #include "list.h" +#include "xalloc.h" /* (De)constructors */ diff --git a/lib/pidfile.c b/lib/pidfile.c index 250f67b..2dea70b 100644 --- a/lib/pidfile.c +++ b/lib/pidfile.c @@ -25,16 +25,7 @@ * First version (v0.2) released */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" /* read_pid * diff --git a/lib/utils.c b/lib/utils.c index 9552c5c..9ffad70 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -18,15 +18,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "config.h" +#include "system.h" -#include -#include -#include - -#include -#include -#include +#include "../src/logger.h" +#include "utils.h" #ifdef ENABLE_TRACING volatile int (cp_line[]) = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; @@ -64,7 +59,7 @@ void bin2hex(char *src, char *dst, int length) #ifdef ENABLE_TRACING void cp_trace() { - syslog(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d...", + logger(LOG_DEBUG, "Checkpoint trace: %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d <- %s:%d...", cp_file[(cp_index + 15) % 16], cp_line[(cp_index + 15) % 16], cp_file[(cp_index + 14) % 16], cp_line[(cp_index + 14) % 16], cp_file[(cp_index + 13) % 16], cp_line[(cp_index + 13) % 16], diff --git a/lib/utils.h b/lib/utils.h index 2a56ef5..caf6e6f 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -21,14 +21,6 @@ #ifndef __TINC_UTILS_H__ #define __TINC_UTILS_H__ -#include - -#include "fake-getaddrinfo.h" -#include "fake-getnameinfo.h" -#include "ipv6.h" - -#define min(a,b) (((a)<(b))?(a):(b)) - #ifdef ENABLE_TRACING extern volatile int cp_line[]; extern volatile char *cp_file[]; diff --git a/src/conf.c b/src/conf.c index b6d2b0a..f7019d1 100644 --- a/src/conf.c +++ b/src/conf.c @@ -19,31 +19,17 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.c,v 1.9.4.65 2003/07/12 17:41:45 guus Exp $ + $Id: conf.c,v 1.9.4.66 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include /* for cp */ -#include +#include "system.h" +#include "avl_tree.h" #include "conf.h" -#include "netutl.h" /* for str2address */ #include "logger.h" - -#include "system.h" +#include "netutl.h" /* for str2address */ +#include "utils.h" /* for cp */ +#include "xalloc.h" avl_tree_t *config_tree; diff --git a/src/conf.h b/src/conf.h index 76e3893..32bb909 100644 --- a/src/conf.h +++ b/src/conf.h @@ -17,18 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: conf.h,v 1.6.4.38 2003/07/12 17:41:45 guus Exp $ + $Id: conf.h,v 1.6.4.39 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_CONF_H__ #define __TINC_CONF_H__ -#include -#include -#include - -#include -#include "net.h" +#include "avl_tree.h" #include "subnet.h" typedef struct config_t { @@ -57,7 +52,6 @@ extern int get_config_bool(config_t *, int *); extern int get_config_int(config_t *, int *); extern int get_config_string(config_t *, char **); extern int get_config_address(config_t *, struct addrinfo **); -struct subnet_t; /* Needed for next line. */ extern int get_config_subnet(config_t *, struct subnet_t **); extern int read_config_file(avl_tree_t *, const char *); diff --git a/src/connection.c b/src/connection.c index dbfe6d6..9890f51 100644 --- a/src/connection.c +++ b/src/connection.c @@ -17,27 +17,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: connection.c,v 1.1.2.39 2003/07/12 17:41:45 guus Exp $ + $Id: connection.c,v 1.1.2.40 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include - -#include -#include +#include "system.h" +#include "avl_tree.h" +#include "conf.h" +#include "list.h" +#include "logger.h" #include "net.h" /* Don't ask. */ #include "netutl.h" -#include "conf.h" -#include #include "subnet.h" -#include "logger.h" - +#include "utils.h" #include "xalloc.h" -#include "system.h" avl_tree_t *connection_tree; /* Meta connections */ connection_t *broadcast; diff --git a/src/connection.h b/src/connection.h index 30102f2..1b3ca36 100644 --- a/src/connection.h +++ b/src/connection.h @@ -17,34 +17,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: connection.h,v 1.1.2.33 2003/07/12 17:41:45 guus Exp $ + $Id: connection.h,v 1.1.2.34 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_CONNECTION_H__ #define __TINC_CONNECTION_H__ -#include +#include +#include -#include -#include - -#ifdef HAVE_OPENSSL_EVP_H -# include -#else -# include -#endif - -#ifdef HAVE_OPENSSL_RSA_H -# include -#else -# include -#endif - -#include "net.h" +#include "avl_tree.h" #include "conf.h" - -#include "node.h" #include "edge.h" +#include "list.h" +#include "net.h" +#include "node.h" #define OPTION_INDIRECT 0x0001 #define OPTION_TCPONLY 0x0002 diff --git a/src/edge.c b/src/edge.c index 3bceb00..48ead00 100644 --- a/src/edge.c +++ b/src/edge.c @@ -17,28 +17,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.c,v 1.1.2.21 2003/07/12 17:41:45 guus Exp $ + $Id: edge.c,v 1.1.2.22 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include - -#include -#include +#include "system.h" -#include "net.h" /* Don't ask. */ -#include "netutl.h" -#include "conf.h" -#include -#include "subnet.h" +#include "avl_tree.h" #include "edge.h" -#include "node.h" #include "logger.h" - +#include "netutl.h" +#include "node.h" +#include "utils.h" #include "xalloc.h" -#include "system.h" avl_tree_t *edge_weight_tree; /* Tree with all edges, sorted on weight */ diff --git a/src/edge.h b/src/edge.h index 3fe8645..b841bc9 100644 --- a/src/edge.h +++ b/src/edge.h @@ -17,17 +17,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: edge.h,v 1.1.2.13 2003/07/12 17:41:45 guus Exp $ + $Id: edge.h,v 1.1.2.14 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_EDGE_H__ #define __TINC_EDGE_H__ -#include - +#include "avl_tree.h" +#include "connection.h" #include "net.h" #include "node.h" -#include "connection.h" typedef struct edge_t { struct node_t *from; diff --git a/src/event.c b/src/event.c index 4596165..4eae34d 100644 --- a/src/event.c +++ b/src/event.c @@ -17,21 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: event.c,v 1.1.4.8 2003/07/12 17:41:45 guus Exp $ + $Id: event.c,v 1.1.4.9 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include +#include "system.h" +#include "avl_tree.h" #include "event.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" avl_tree_t *event_tree; extern time_t now; diff --git a/src/event.h b/src/event.h index fb10c4a..71aae18 100644 --- a/src/event.h +++ b/src/event.h @@ -17,14 +17,13 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: event.h,v 1.1.4.6 2003/07/12 17:41:45 guus Exp $ + $Id: event.h,v 1.1.4.7 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_EVENT_H__ #define __TINC_EVENT_H__ -#include -#include +#include "avl_tree.h" extern avl_tree_t *event_tree; diff --git a/src/graph.c b/src/graph.c index 3692f44..2c6ad22 100644 --- a/src/graph.c +++ b/src/graph.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: graph.c,v 1.1.2.24 2003/07/12 17:41:45 guus Exp $ + $Id: graph.c,v 1.1.2.25 2003/07/17 15:06:26 guus Exp $ */ /* We need to generate two trees from the graph: @@ -44,27 +44,17 @@ destination address and port of a node if possible. */ -#include "config.h" - -#include -#include -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#include - -#include -#include +#include "system.h" -#include "netutl.h" -#include "node.h" -#include "edge.h" +#include "avl_tree.h" #include "connection.h" -#include "process.h" #include "device.h" +#include "edge.h" #include "logger.h" - -#include "system.h" +#include "netutl.h" +#include "node.h" +#include "process.h" +#include "utils.h" /* Implementation of Kruskal's algorithm. Running time: O(EN) diff --git a/src/linux/device.c b/src/linux/device.c index f9105e6..08d9364 100644 --- a/src/linux/device.c +++ b/src/linux/device.c @@ -17,20 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: device.c,v 1.1.2.17 2003/07/12 17:41:48 guus Exp $ + $Id: device.c,v 1.1.2.18 2003/07/17 15:06:27 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" #ifdef HAVE_TUNTAP #ifdef LINUX_IF_TUN_H @@ -43,13 +33,11 @@ #define DEFAULT_DEVICE "/dev/tap0" #endif -#include #include "conf.h" +#include "logger.h" #include "net.h" #include "route.h" -#include "logger.h" - -#include "system.h" +#include "utils.h" enum { DEVICE_TYPE_ETHERTAP, diff --git a/src/logger.c b/src/logger.c index 012f19d..b8ea092 100644 --- a/src/logger.c +++ b/src/logger.c @@ -17,19 +17,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: logger.c,v 1.1.2.3 2003/07/12 17:41:45 guus Exp $ + $Id: logger.c,v 1.1.2.4 2003/07/17 15:06:26 guus Exp $ */ -#include -#include -#include -#include +#include "system.h" #include "conf.h" #include "logger.h" -#include "system.h" - int debug_level = DEBUG_NOTHING; static int logmode = LOGMODE_STDERR; static pid_t logpid; diff --git a/src/logger.h b/src/logger.h index edd0d93..615d0c3 100644 --- a/src/logger.h +++ b/src/logger.h @@ -1,8 +1,5 @@ #ifndef __TINC_LOGGER_H__ -#include -#include - enum { DEBUG_NOTHING = 0, /* Quiet mode, only show starting/stopping of the daemon */ DEBUG_ALWAYS = 0, diff --git a/src/meta.c b/src/meta.c index 939f76b..967477b 100644 --- a/src/meta.c +++ b/src/meta.c @@ -17,27 +17,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: meta.c,v 1.1.2.35 2003/07/12 17:41:45 guus Exp $ + $Id: meta.c,v 1.1.2.36 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" -#include -#include - -#include -#include -#include -/* This line must be below the rest for FreeBSD */ -#include -#include +#include "system.h" #include -#include "net.h" +#include "avl_tree.h" #include "connection.h" -#include "system.h" -#include "protocol.h" #include "logger.h" +#include "net.h" +#include "protocol.h" +#include "system.h" +#include "utils.h" int send_meta(connection_t *c, char *buffer, int length) { diff --git a/src/net.c b/src/net.c index 8b2c9f0..d43aede 100644 --- a/src/net.c +++ b/src/net.c @@ -17,62 +17,28 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.c,v 1.35.4.190 2003/07/12 17:41:45 guus Exp $ + $Id: net.c,v 1.35.4.191 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* SunOS really wants sys/socket.h BEFORE net/if.h, - and FreeBSD wants these lines below the rest. */ -#include -#include -#include -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif -#include -#ifdef HAVE_NETINET_IP_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif +#include "system.h" #include -#include -#include -#include -#include - +#include "utils.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" +#include "device.h" +#include "event.h" +#include "graph.h" +#include "logger.h" #include "meta.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" -#include "subnet.h" -#include "graph.h" -#include "process.h" #include "route.h" -#include "device.h" -#include "event.h" -#include "logger.h" - -#include "system.h" +#include "subnet.h" int do_purge = 0; int sighup = 0; diff --git a/src/net.h b/src/net.h index 8ad8994..43371ad 100644 --- a/src/net.h +++ b/src/net.h @@ -17,26 +17,14 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.h,v 1.9.4.63 2003/07/12 17:41:46 guus Exp $ + $Id: net.h,v 1.9.4.64 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_NET_H__ #define __TINC_NET_H__ -#include "config.h" - -#include -#include -#include -#include #include -#ifdef HAVE_INTTYPES_H -#include -#endif - -#include "utils.h" - #ifdef ENABLE_JUMBOGRAMS #define MTU 9014 /* 9000 bytes payload + 14 bytes ethernet header */ #else @@ -97,6 +85,8 @@ typedef struct packet_queue_t { queue_element_t *tail; } packet_queue_t; +#include "conf.h" + typedef struct outgoing_t { char *name; int timeout; @@ -115,8 +105,6 @@ extern int maxtimeout; extern int seconds_till_retry; extern int addressfamily; -#include "connection.h" /* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ - extern listen_socket_t listen_socket[MAXSOCKETS]; extern int listen_sockets; extern int keyexpires; @@ -127,10 +115,14 @@ extern char *myport; extern time_t now; extern EVP_CIPHER_CTX packet_ctx; +/* Yes, very strange placement indeed, but otherwise the typedefs get all tangled up */ +#include "connection.h" +#include "node.h" + extern void retry_outgoing(outgoing_t *); extern void handle_incoming_vpn_data(int); -extern void finish_connecting(connection_t *); -extern void do_outgoing_connection(connection_t *); +extern void finish_connecting(struct connection_t *); +extern void do_outgoing_connection(struct connection_t *); extern int handle_new_meta_connection(int); extern int setup_listen_socket(sockaddr_t *); extern int setup_vpn_in_socket(sockaddr_t *); @@ -142,7 +134,7 @@ extern void setup_outgoing_connection(struct outgoing_t *); extern void try_outgoing_connections(void); extern void close_network_connections(void); extern void main_loop(void); -extern void terminate_connection(connection_t *, int); +extern void terminate_connection(struct connection_t *, int); extern void flush_queue(struct node_t *); extern int read_rsa_public_key(struct connection_t *); diff --git a/src/net_packet.c b/src/net_packet.c index c0bd247..e858daa 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -17,37 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_packet.c,v 1.1.2.33 2003/07/12 17:41:46 guus Exp $ + $Id: net_packet.c,v 1.1.2.34 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* SunOS really wants sys/socket.h BEFORE net/if.h, - and FreeBSD wants these lines below the rest. */ -#include -#include -#include -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif -#ifdef HAVE_NETINET_IP_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif +#include "system.h" #include #include @@ -57,27 +30,21 @@ #include #include -#include -#include -#include -#include - +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "meta.h" +#include "device.h" +#include "event.h" +#include "graph.h" +#include "list.h" +#include "logger.h" #include "net.h" #include "netutl.h" -#include "process.h" #include "protocol.h" -#include "subnet.h" -#include "graph.h" #include "process.h" #include "route.h" -#include "device.h" -#include "event.h" -#include "logger.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" int keylifetime = 0; int keyexpires = 0; diff --git a/src/net_setup.c b/src/net_setup.c index 4c258ab..ca7aa61 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -17,63 +17,30 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_setup.c,v 1.1.2.34 2003/07/12 17:41:46 guus Exp $ + $Id: net_setup.c,v 1.1.2.35 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* SunOS really wants sys/socket.h BEFORE net/if.h, - and FreeBSD wants these lines below the rest. */ -#include -#include -#include -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif -#ifdef HAVE_NETINET_IP_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif +#include "system.h" #include #include #include -#include -#include -#include -#include - +#include "avl_tree.h" #include "conf.h" #include "connection.h" -#include "meta.h" +#include "device.h" +#include "event.h" +#include "graph.h" +#include "logger.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" -#include "subnet.h" -#include "graph.h" -#include "process.h" #include "route.h" -#include "device.h" -#include "event.h" -#include "logger.h" - -#include "system.h" +#include "subnet.h" +#include "utils.h" +#include "xalloc.h" char *myport; diff --git a/src/net_socket.c b/src/net_socket.c index 1b5c18f..bb5208f 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -17,63 +17,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_socket.c,v 1.1.2.26 2003/07/12 17:41:46 guus Exp $ + $Id: net_socket.c,v 1.1.2.27 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* SunOS really wants sys/socket.h BEFORE net/if.h, - and FreeBSD wants these lines below the rest. */ -#include -#include -#include -#ifdef HAVE_NETINET_IN_SYSTM_H -#include -#endif -#ifdef HAVE_NETINET_IP_H -#include -#endif -#ifdef HAVE_NETINET_TCP_H -#include -#endif - -#include -#include -#include -#include +#include "system.h" +#include "avl_tree.h" #include "conf.h" #include "connection.h" +#include "event.h" +#include "logger.h" #include "meta.h" #include "net.h" #include "netutl.h" -#include "process.h" #include "protocol.h" -#include "subnet.h" -#include "graph.h" -#include "process.h" -#include "route.h" -#include "device.h" -#include "event.h" -#include "logger.h" - -#include "system.h" - -#ifndef HAVE_RAND_PSEUDO_BYTES -#define RAND_pseudo_bytes RAND_bytes -#endif +#include "utils.h" +#include "xalloc.h" int addressfamily = AF_UNSPEC; int maxtimeout = 900; diff --git a/src/netutl.c b/src/netutl.c index 1f5e4af..6784833 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -17,34 +17,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netutl.c,v 1.12.4.46 2003/07/12 17:41:46 guus Exp $ + $Id: netutl.c,v 1.12.4.47 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_INTTYPES_H -#include -#endif -#include -#include -#include -#include - -#include -#include - -#include "errno.h" -#include "conf.h" +#include "system.h" + #include "net.h" #include "netutl.h" #include "logger.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" int hostnames = 0; diff --git a/src/netutl.h b/src/netutl.h index b946b77..eb5aeeb 100644 --- a/src/netutl.h +++ b/src/netutl.h @@ -17,16 +17,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netutl.h,v 1.2.4.15 2003/07/12 17:41:46 guus Exp $ + $Id: netutl.h,v 1.2.4.16 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_NETUTL_H__ #define __TINC_NETUTL_H__ -#include -#include -#include - #include "net.h" extern int hostnames; diff --git a/src/node.c b/src/node.c index 6dba7f2..5fc94a9 100644 --- a/src/node.c +++ b/src/node.c @@ -17,23 +17,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: node.c,v 1.1.2.22 2003/07/12 17:41:46 guus Exp $ + $Id: node.c,v 1.1.2.23 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include +#include "system.h" -#include -#include "node.h" -#include "netutl.h" -#include "net.h" +#include "avl_tree.h" #include "logger.h" - -#include -#include - -#include "system.h" +#include "net.h" +#include "netutl.h" +#include "node.h" +#include "utils.h" +#include "xalloc.h" avl_tree_t *node_tree; /* Known nodes, sorted by name */ avl_tree_t *node_udp_tree; /* Known nodes, sorted by address and port */ diff --git a/src/node.h b/src/node.h index 085d6a4..a4e439a 100644 --- a/src/node.h +++ b/src/node.h @@ -17,20 +17,16 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: node.h,v 1.1.2.24 2003/07/12 17:41:46 guus Exp $ + $Id: node.h,v 1.1.2.25 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_NODE_H__ #define __TINC_NODE_H__ -#ifdef HAVE_INTTYPES_H -#include -#endif - -#include - -#include "subnet.h" +#include "avl_tree.h" #include "connection.h" +#include "list.h" +#include "subnet.h" typedef struct node_status_t { int active:1; /* 1 if active.. */ diff --git a/src/process.c b/src/process.c index 326d3ff..b0e1e63 100644 --- a/src/process.c +++ b/src/process.c @@ -17,37 +17,22 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.c,v 1.1.2.54 2003/07/12 17:41:46 guus Exp $ + $Id: process.c,v 1.1.2.55 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" #include "conf.h" -#include "process.h" -#include "subnet.h" -#include "device.h" #include "connection.h" #include "device.h" +#include "edge.h" #include "logger.h" - -#include "system.h" +#include "node.h" +#include "pidfile.h" +#include "process.h" +#include "subnet.h" +#include "utils.h" +#include "xalloc.h" /* If zero, don't detach from the terminal. */ int do_detach = 1; diff --git a/src/process.h b/src/process.h index cae136c..cb5f7c7 100644 --- a/src/process.h +++ b/src/process.h @@ -17,14 +17,12 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: process.h,v 1.1.2.15 2003/07/12 17:41:46 guus Exp $ + $Id: process.h,v 1.1.2.16 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_PROCESS_H__ #define __TINC_PROCESS_H__ -#include "config.h" - extern int do_detach; extern void setup_signals(void); diff --git a/src/protocol.c b/src/protocol.c index c8b868c..47cc948 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -17,29 +17,18 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.c,v 1.28.4.140 2003/07/12 17:41:46 guus Exp $ + $Id: protocol.c,v 1.28.4.141 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include - -#include -#include -#include -#include -#include - -#include -#include +#include "system.h" #include "conf.h" -#include "protocol.h" -#include "meta.h" #include "connection.h" #include "logger.h" - -#include "system.h" +#include "meta.h" +#include "protocol.h" +#include "utils.h" +#include "xalloc.h" /* Jumptable for the request handlers */ diff --git a/src/protocol.h b/src/protocol.h index 6e71f81..6f01a76 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -17,15 +17,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol.h,v 1.5.4.38 2003/07/06 23:16:28 guus Exp $ + $Id: protocol.h,v 1.5.4.39 2003/07/17 15:06:26 guus Exp $ */ #ifndef __TINC_PROTOCOL_H__ #define __TINC_PROTOCOL_H__ +#include "edge.h" #include "net.h" #include "node.h" -#include "edge.h" #include "subnet.h" /* Protocol version. Different versions are incompatible, diff --git a/src/protocol_auth.c b/src/protocol_auth.c index 1b8794d..88fba26 100644 --- a/src/protocol_auth.c +++ b/src/protocol_auth.c @@ -17,37 +17,27 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_auth.c,v 1.1.4.23 2003/07/12 17:41:47 guus Exp $ + $Id: protocol_auth.c,v 1.1.4.24 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" #include #include #include +#include "avl_tree.h" #include "conf.h" -#include "net.h" -#include "netutl.h" -#include "protocol.h" -#include "meta.h" #include "connection.h" -#include "node.h" #include "edge.h" #include "graph.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "netutl.h" +#include "node.h" +#include "protocol.h" +#include "utils.h" +#include "xalloc.h" int send_id(connection_t *c) { diff --git a/src/protocol_edge.c b/src/protocol_edge.c index d81fc87..75b4995 100644 --- a/src/protocol_edge.c +++ b/src/protocol_edge.c @@ -17,33 +17,24 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_edge.c,v 1.1.4.17 2003/07/12 17:41:47 guus Exp $ + $Id: protocol_edge.c,v 1.1.4.18 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" +#include "avl_tree.h" #include "conf.h" -#include "net.h" -#include "netutl.h" -#include "protocol.h" -#include "meta.h" #include "connection.h" -#include "node.h" #include "edge.h" #include "graph.h" #include "logger.h" - -#include "system.h" +#include "meta.h" +#include "net.h" +#include "netutl.h" +#include "node.h" +#include "protocol.h" +#include "utils.h" +#include "xalloc.h" int send_add_edge(connection_t *c, edge_t *e) { diff --git a/src/protocol_key.c b/src/protocol_key.c index 1a6804a..832b2af 100644 --- a/src/protocol_key.c +++ b/src/protocol_key.c @@ -17,31 +17,20 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_key.c,v 1.1.4.18 2003/07/12 17:41:47 guus Exp $ + $Id: protocol_key.c,v 1.1.4.19 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" -#include "conf.h" +#include "avl_tree.h" +#include "connection.h" +#include "logger.h" #include "net.h" #include "netutl.h" -#include "protocol.h" -#include "meta.h" -#include "connection.h" #include "node.h" -#include "logger.h" - -#include "system.h" +#include "protocol.h" +#include "utils.h" +#include "xalloc.h" int mykeyused = 0; diff --git a/src/protocol_misc.c b/src/protocol_misc.c index d5c9aeb..934a182 100644 --- a/src/protocol_misc.c +++ b/src/protocol_misc.c @@ -17,28 +17,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_misc.c,v 1.1.4.10 2003/07/12 17:41:47 guus Exp $ + $Id: protocol_misc.c,v 1.1.4.11 2003/07/17 15:06:26 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include - -#include +#include "system.h" #include "conf.h" +#include "connection.h" +#include "logger.h" +#include "meta.h" #include "net.h" #include "netutl.h" #include "protocol.h" -#include "meta.h" -#include "connection.h" -#include "logger.h" - -#include "system.h" +#include "utils.h" /* Status and error notification routines */ diff --git a/src/protocol_subnet.c b/src/protocol_subnet.c index c0a351f..f29bdbe 100644 --- a/src/protocol_subnet.c +++ b/src/protocol_subnet.c @@ -17,31 +17,21 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: protocol_subnet.c,v 1.1.4.11 2003/07/12 17:41:47 guus Exp $ + $Id: protocol_subnet.c,v 1.1.4.12 2003/07/17 15:06:27 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" #include "conf.h" +#include "connection.h" +#include "logger.h" #include "net.h" #include "netutl.h" -#include "protocol.h" -#include "meta.h" -#include "connection.h" #include "node.h" -#include "logger.h" - -#include "system.h" +#include "protocol.h" +#include "subnet.h" +#include "utils.h" +#include "xalloc.h" int send_add_subnet(connection_t *c, subnet_t *subnet) { diff --git a/src/route.c b/src/route.c index f00728c..3d9b28b 100644 --- a/src/route.c +++ b/src/route.c @@ -17,50 +17,39 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: route.c,v 1.1.2.58 2003/07/15 16:26:18 guus Exp $ + $Id: route.c,v 1.1.2.59 2003/07/17 15:06:27 guus Exp $ */ -#include "config.h" +#include "system.h" -#ifdef HAVE_SYS_PARAM_H -#include -#endif -#include -#include -#ifdef HAVE_NET_IF_H -#include -#endif #ifdef HAVE_NET_ETHERNET_H #include #endif -#ifdef HAVE_NETINET_IN_SYSTM_H -#include +#ifdef HAVE_NET_IF_ARP_H +#include #endif -#include +#ifdef HAVE_NETINET_IP_ICMP_H #include +#endif #ifdef HAVE_NETINET_IP6_H #include +#endif +#ifdef HAVE_NETINET_ICMP6_H #include #endif +#ifdef HAVE_NETINET_IF_ETHER_H #include -#include -#include -#include -#ifdef HAVE_INTTYPES_H -#include #endif -#include - -#include "net.h" +#include "avl_tree.h" #include "connection.h" -#include "subnet.h" -#include "route.h" -#include "protocol.h" #include "device.h" #include "logger.h" - -#include "system.h" +#include "net.h" +#include "protocol.h" +#include "route.h" +#include "subnet.h" +#include "utils.h" /* Missing definitions */ diff --git a/src/subnet.c b/src/subnet.c index 2aab91d..f5a8bd4 100644 --- a/src/subnet.c +++ b/src/subnet.c @@ -17,30 +17,19 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: subnet.c,v 1.1.2.46 2003/07/12 17:41:47 guus Exp $ + $Id: subnet.c,v 1.1.2.47 2003/07/17 15:06:27 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include +#include "system.h" -#include "conf.h" +#include "avl_tree.h" +#include "logger.h" #include "net.h" +#include "netutl.h" #include "node.h" #include "subnet.h" -#include "netutl.h" -#include "logger.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" /* lists type of subnet */ diff --git a/src/tincd.c b/src/tincd.c index 185a96a..8ef8c51 100644 --- a/src/tincd.c +++ b/src/tincd.c @@ -17,21 +17,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: tincd.c,v 1.10.4.72 2003/07/12 17:41:47 guus Exp $ + $Id: tincd.c,v 1.10.4.73 2003/07/17 15:06:27 guus Exp $ */ -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "system.h" /* Darwin (MacOS/X) needs the following definition... */ #ifndef _P1003_1B_VISIBLE @@ -40,10 +29,6 @@ #include -#ifdef HAVE_SYS_IOCTL_H -# include -#endif - #include #include #include @@ -51,18 +36,14 @@ #include -#include -#include - #include "conf.h" +#include "logger.h" #include "net.h" #include "netutl.h" #include "process.h" #include "protocol.h" -#include "subnet.h" -#include "logger.h" - -#include "system.h" +#include "utils.h" +#include "xalloc.h" /* The name this program was run with. */ char *program_name = NULL; diff --git a/system.h b/system.h index 6391c39..c4dd0d1 100644 --- a/system.h +++ b/system.h @@ -1,6 +1,7 @@ /* - system.h -- header for locale settings - Copyright (C) 1998,99,2000 Ivo Timmermans + system.h -- system headers + Copyright (C) 1998-2003 Ivo Timmermans + 2003 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,6 +21,102 @@ #ifndef __TINC_SYSTEM_H__ #define __TINC_SYSTEM_H__ +#include "config.h" + +/* Include standard headers */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_INTTYPES_H +#include +#endif + +/* Include system specific headers */ + +#ifdef HAVE_SYSLOG_H +#include +#endif + +#ifdef HAVE_SYS_TIME_H +#include +#endif + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#ifdef HAVE_SYS_STAT_H +#include +#endif + +#ifdef HAVE_SYS_FILE_H +#include +#endif + +#ifdef HAVE_SYS_WAIT_H +#include +#endif + +#ifdef HAVE_SYS_IOCTL_H +#include +#endif + +#ifdef HAVE_SYS_PARAM_H +#include +#endif + +/* SunOS really wants sys/socket.h BEFORE net/if.h, + and FreeBSD wants these lines below the rest. */ + +#ifdef HAVE_NETDB_H +#include +#endif + +#ifdef HAVE_ARPA_INET_H +#include +#endif + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +#ifdef HAVE_NET_IF_H +#include +#endif + +#ifdef HAVE_NETINET_IN_SYSTM_H +#include +#endif + +#ifdef HAVE_NETINET_IN_H +#include +#endif + +#ifdef HAVE_NETINET_IP_H +#include +#endif + +#ifdef HAVE_NETINET_TCP_H +#include +#endif + +#ifdef HAVE_MINGW +#include +#include +#endif + +/* Include localisation support */ + #include "gettext.h" #ifndef HAVE_STRSIGNAL @@ -27,7 +124,8 @@ #endif /* Other functions */ -#include + +#include "dropin.h" #ifndef HAVE_SOCKLEN_T typedef int socklen_t;