X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet_socket.c;h=b17dd8db86ca1ffe26833b537fe23a40207c73c0;hp=96a58b05cd363cfcd5f10d44c5c42b6599d8f2eb;hb=c08858baa91a00e38c0f5482dbb0817dbd0361f1;hpb=f75dcef72a81a337e847adf0bae54198894f65b9 diff --git a/src/net_socket.c b/src/net_socket.c index 96a58b05..b17dd8db 100644 --- a/src/net_socket.c +++ b/src/net_socket.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: net_socket.c,v 1.1.2.20 2002/09/09 21:24:41 guus Exp $ + $Id: net_socket.c,v 1.1.2.23 2003/01/17 00:37:20 guus Exp $ */ #include "config.h" @@ -26,15 +26,6 @@ #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 @@ -49,6 +40,15 @@ #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 @@ -84,7 +84,7 @@ int listen_sockets; /* Setup sockets */ -int setup_listen_socket(sockaddr_t * sa) +int setup_listen_socket(sockaddr_t *sa) { int nfd, flags; char *addrstr; @@ -139,7 +139,7 @@ int setup_listen_socket(sockaddr_t * sa) return -1; } #else - syslog(LOG_WARNING, _("BindToDevice not supported on this platform")); + syslog(LOG_WARNING, _("BindToInterface not supported on this platform")); #endif } @@ -162,7 +162,7 @@ int setup_listen_socket(sockaddr_t * sa) return nfd; } -int setup_vpn_in_socket(sockaddr_t * sa) +int setup_vpn_in_socket(sockaddr_t *sa) { int nfd, flags; char *addrstr; @@ -219,7 +219,7 @@ int setup_vpn_in_socket(sockaddr_t * sa) return nfd; } -void retry_outgoing(outgoing_t * outgoing) +void retry_outgoing(outgoing_t *outgoing) { event_t *event; @@ -242,53 +242,7 @@ void retry_outgoing(outgoing_t * outgoing) outgoing->timeout); } -int setup_outgoing_socket(connection_t * c) -{ - int option; - - cp(); - - if(debug_lvl >= DEBUG_CONNECTIONS) - syslog(LOG_INFO, _("Trying to connect to %s (%s)"), c->name, - c->hostname); - - c->socket = socket(c->address.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); - - if(c->socket == -1) { - syslog(LOG_ERR, _("Creating socket for %s failed: %s"), c->hostname, - strerror(errno)); - return -1; - } - - /* Optimize TCP settings */ - -#if defined(SOL_TCP) && defined(TCP_NODELAY) - option = 1; - setsockopt(c->socket, SOL_TCP, TCP_NODELAY, &option, sizeof(option)); -#endif - -#if defined(SOL_IP) && defined(IP_TOS) - option = IPTOS_LOWDELAY; - setsockopt(c->socket, SOL_IP, IP_TOS, &option, sizeof(option)); -#endif - - /* Connect */ - - if(connect(c->socket, &c->address.sa, SALEN(c->address.sa)) == -1) { - close(c->socket); - syslog(LOG_ERR, _("Error while connecting to %s (%s): %s"), c->name, - c->hostname, strerror(errno)); - return -1; - } - - if(debug_lvl >= DEBUG_CONNECTIONS) - syslog(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname); - - return 0; -} - - -void finish_connecting(connection_t * c) +void finish_connecting(connection_t *c) { cp(); @@ -300,7 +254,7 @@ void finish_connecting(connection_t * c) send_id(c); } -void do_outgoing_connection(connection_t * c) +void do_outgoing_connection(connection_t *c) { char *address, *port; int option, result, flags; @@ -403,7 +357,7 @@ begin: return; } -void setup_outgoing_connection(outgoing_t * outgoing) +void setup_outgoing_connection(outgoing_t *outgoing) { connection_t *c; node_t *n;