projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Started implementing doc/CONNECTIVITY.
[tinc]
/
src
/
net.c
diff --git
a/src/net.c
b/src/net.c
index
7183991
..
e96ae51
100644
(file)
--- a/
src/net.c
+++ b/
src/net.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.
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.1
29 2001/09/01 12:36:06
guus Exp $
+ $Id: net.c,v 1.35.4.1
36 2001/10/08 13:37:30
guus Exp $
*/
#include "config.h"
*/
#include "config.h"
@@
-230,6
+230,7
@@
cp
*/
void send_packet(connection_t *cl, vpn_packet_t *packet)
{
*/
void send_packet(connection_t *cl, vpn_packet_t *packet)
{
+ connection_t *via;
cp
if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
cp
if(debug_lvl >= DEBUG_TRAFFIC)
syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"),
@@
-254,15
+255,22
@@
cp
return;
}
return;
}
- /* Check if it has to go via TCP or UDP... */
-cp
- if((cl->options | myself->options) & OPTION_TCPONLY)
+ if(cl->via == myself)
+ via = cl->nexthop;
+ else
+ via = cl->via;
+
+ if(via != cl && debug_lvl >= DEBUG_TRAFFIC)
+ syslog(LOG_ERR, _("Sending packet to %s via %s (%s)"),
+ cl->name, via->name, via->hostname);
+
+ if((myself->options | via->options) & OPTION_TCPONLY)
{
{
- if(send_tcppacket(
cl
, packet))
- terminate_connection(
cl
, 1);
+ if(send_tcppacket(
via
, packet))
+ terminate_connection(
via
, 1);
}
else
}
else
- send_udppacket(
cl
, packet);
+ send_udppacket(
via
, packet);
}
/* Broadcast a packet to all active direct connections */
}
/* Broadcast a packet to all active direct connections */
@@
-369,18
+377,25
@@
cp
cp
if (!ioctl(tap_fd, TUNSETIFF, (void *) &ifr))
{
cp
if (!ioctl(tap_fd, TUNSETIFF, (void *) &ifr))
{
- syslog(LOG_INFO, _("%s is a tun/tap device"), tapfname);
+ syslog(LOG_INFO, _("%s is a
Linux
tun/tap device"), tapfname);
taptype = TAP_TYPE_TUNTAP;
}
else
taptype = TAP_TYPE_TUNTAP;
}
else
+ if (!ioctl(tap_fd, (('T'<< 8) | 202), (void *) &ifr))
+ {
+ syslog(LOG_INFO, _("%s is a Linux tun/tap device"), tapfname);
+ syslog(LOG_WARNING, _("Old ioctl() request used"));
+ taptype = TAP_TYPE_TUNTAP;
+ }
+ else
#endif
#endif
- {
-
syslog(LOG_INFO, _("%s is an
ethertap device"), tapfname);
- taptype = TAP_TYPE_ETHERTAP;
- }
+
{
+
syslog(LOG_INFO, _("%s is a Linux
ethertap device"), tapfname);
+
taptype = TAP_TYPE_ETHERTAP;
+
}
#endif
#ifdef HAVE_FREEBSD
#endif
#ifdef HAVE_FREEBSD
- syslog(LOG_INFO, _("%s is a
tun/
tap device"), tapfname);
+ syslog(LOG_INFO, _("%s is a
FreeBSD
tap device"), tapfname);
taptype = TAP_TYPE_TUNTAP;
#endif
#ifdef HAVE_SOLARIS
taptype = TAP_TYPE_TUNTAP;
#endif
#ifdef HAVE_SOLARIS
@@
-422,7
+437,7
@@
cp
return -1;
}
return -1;
}
- syslog(LOG_INFO, _("%s is a
tun/tap
device"), tapfname);
+ syslog(LOG_INFO, _("%s is a
Solaris tun
device"), tapfname);
#endif
cp
#endif
cp
@@
-955,6
+970,9
@@
cp
cp
/* Done */
cp
/* Done */
+ myself->nexthop = myself;
+ myself->prevhop = myself;
+ myself->via = myself;
myself->status.active = 1;
id_add(myself);
myself->status.active = 1;
id_add(myself);
@@
-982,7
+1000,7
@@
cp
{
if(setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
retry = 1;
{
if(setup_outgoing_connection(cfg->data.ptr)) /* function returns 0 when there are no problems */
retry = 1;
- cfg = get_config_val(cfg, config_connectto); /* Or else we try the next ConnectTo line */
+ cfg = get_config_val(cfg
->next
, config_connectto); /* Or else we try the next ConnectTo line */
}
if(retry)
}
if(retry)
@@
-1266,17
+1284,18
@@
cp
void check_dead_connections(void)
{
time_t now;
void check_dead_connections(void)
{
time_t now;
- avl_node_t *node;
+ avl_node_t *node
, *next
;
connection_t *cl;
cp
now = time(NULL);
connection_t *cl;
cp
now = time(NULL);
- for(node = connection_tree->head; node; node = n
ode->n
ext)
+ for(node = connection_tree->head; node; node = next)
{
{
+ next = node->next;
cl = (connection_t *)node->data;
cl = (connection_t *)node->data;
- if(cl->
status.active
)
+ if(cl->
last_ping_time + timeout < now
)
{
{
- if(cl->
last_ping_time + timeout < now
)
+ if(cl->
status.active
)
{
if(cl->status.pinged)
{
{
if(cl->status.pinged)
{
@@
-1291,6
+1310,13
@@
cp
send_ping(cl);
}
}
send_ping(cl);
}
}
+ else
+ {
+ if(debug_lvl >= DEBUG_CONNECTIONS)
+ syslog(LOG_WARNING, _("Timeout from %s (%s) during authentication"),
+ cl->name, cl->hostname);
+ terminate_connection(cl, 0);
+ }
}
}
cp
}
}
cp
@@
-1349,7
+1375,7
@@
cp
if(FD_ISSET(p->meta_socket, f))
if(receive_meta(p) < 0)
{
if(FD_ISSET(p->meta_socket, f))
if(receive_meta(p) < 0)
{
- terminate_connection(p, p->status.
meta
);
+ terminate_connection(p, p->status.
active
);
return;
}
}
return;
}
}