projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be on the safe side with initialisation of c->name.
[tinc]
/
src
/
net_socket.c
diff --git
a/src/net_socket.c
b/src/net_socket.c
index
b90dcf5
..
dbd09dd
100644
(file)
--- a/
src/net_socket.c
+++ b/
src/net_socket.c
@@
-1,7
+1,7
@@
/*
net_socket.c -- Handle various kinds of sockets.
/*
net_socket.c -- Handle various kinds of sockets.
- Copyright (C) 1998-200
3 Ivo Timmermans <ivo@o2w.nl
>,
- 2000-200
3 Guus Sliepen <guus@sliepen.eu
.org>
+ Copyright (C) 1998-200
4 Ivo Timmermans <ivo@tinc-vpn.org
>,
+ 2000-200
4 Guus Sliepen <guus@tinc-vpn
.org>
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
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
@@
-17,7
+17,7
@@
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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.37 2003/12/20 21:09:33 guus Exp
$
+ $Id$
*/
#include "system.h"
*/
#include "system.h"
@@
-41,6
+41,7
@@
int addressfamily = AF_UNSPEC;
int maxtimeout = 900;
int seconds_till_retry = 5;
int addressfamily = AF_UNSPEC;
int maxtimeout = 900;
int seconds_till_retry = 5;
+bool blockingtcp = false;
listen_socket_t listen_socket[MAXSOCKETS];
int listen_sockets;
listen_socket_t listen_socket[MAXSOCKETS];
int listen_sockets;
@@
-163,13
+164,9
@@
int setup_vpn_in_socket(const sockaddr_t *sa)
{
bool choice;
{
bool choice;
- if(
sa->sa.sa_family == AF_INET &&
get_config_bool(lookup_config(myself->connection->config_tree, "PMTUDiscovery"), &choice) && choice) {
+ if(get_config_bool(lookup_config(myself->connection->config_tree, "PMTUDiscovery"), &choice) && choice) {
option = IP_PMTUDISC_DO;
option = IP_PMTUDISC_DO;
- if(setsockopt(nfd, SOL_IP, IP_MTU_DISCOVER, &option, sizeof(option))) {
- closesocket(nfd);
- logger(LOG_ERR, _("Can't set PMTU discovery mode: %s"), strerror(errno));
- return -1;
- }
+ setsockopt(nfd, SOL_IP, IP_MTU_DISCOVER, &option, sizeof(option));
}
}
#endif
}
}
#endif
@@
-178,13
+175,9
@@
int setup_vpn_in_socket(const sockaddr_t *sa)
{
bool choice;
{
bool choice;
- if(
sa->sa.sa_family == AF_INET6 &&
get_config_bool(lookup_config(myself->connection->config_tree, "PMTUDiscovery"), &choice) && choice) {
+ if(get_config_bool(lookup_config(myself->connection->config_tree, "PMTUDiscovery"), &choice) && choice) {
option = IPV6_PMTUDISC_DO;
option = IPV6_PMTUDISC_DO;
- if(setsockopt(nfd, SOL_IPV6, IPV6_MTU_DISCOVER, &option, sizeof(option))) {
- closesocket(nfd);
- logger(LOG_ERR, _("Can't set PMTU discovery mode: %s"), strerror(errno));
- return -1;
- }
+ setsockopt(nfd, SOL_IPV6, IPV6_MTU_DISCOVER, &option, sizeof(option));
}
}
#endif
}
}
#endif
@@
-248,6
+241,16
@@
void finish_connecting(connection_t *c)
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
ifdebug(CONNECTIONS) logger(LOG_INFO, _("Connected to %s (%s)"), c->name, c->hostname);
+#ifdef O_NONBLOCK
+ if(blockingtcp) {
+ int flags = fcntl(c->socket, F_GETFL);
+
+ if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) {
+ logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
+ }
+ }
+#endif
+
c->last_ping_time = now;
send_id(c);
c->last_ping_time = now;
send_id(c);
@@
-421,6
+424,7
@@
bool handle_new_meta_connection(int sock)
sockaddrunmap(&sa);
c = new_connection();
sockaddrunmap(&sa);
c = new_connection();
+ c->name = NULL;
c->outcipher = myself->connection->outcipher;
c->outdigest = myself->connection->outdigest;
c->outmaclength = myself->connection->outmaclength;
c->outcipher = myself->connection->outcipher;
c->outdigest = myself->connection->outdigest;
c->outmaclength = myself->connection->outmaclength;
@@
-433,6
+437,16
@@
bool handle_new_meta_connection(int sock)
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
ifdebug(CONNECTIONS) logger(LOG_NOTICE, _("Connection from %s"), c->hostname);
+#ifdef O_NONBLOCK
+ if(blockingtcp) {
+ int flags = fcntl(c->socket, F_GETFL);
+
+ if(fcntl(c->socket, F_SETFL, flags & ~O_NONBLOCK) < 0) {
+ logger(LOG_ERR, _("fcntl for %s: %s"), c->hostname, strerror(errno));
+ }
+ }
+#endif
+
connection_add(c);
c->allow_request = ID;
connection_add(c);
c->allow_request = ID;
@@
-449,8
+463,7
@@
void try_outgoing_connections(void)
cp();
cp();
- for(cfg = lookup_config(config_tree, "ConnectTo"); cfg;
- cfg = lookup_config_next(config_tree, cfg)) {
+ for(cfg = lookup_config(config_tree, "ConnectTo"); cfg; cfg = lookup_config_next(config_tree, cfg)) {
get_config_string(cfg, &name);
if(!check_id(name)) {
get_config_string(cfg, &name);
if(!check_id(name)) {