X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=7a2a8e7f8b20463aac07c40a744da91156022f3e;hp=718399159b975a73741c256b065b1598262fe82c;hb=24a2c7e51a0b080c4bdb55f697b3f0458ebc3fb1;hpb=8ed27d40f358581d021319cc26313c9f6ddf9a71 diff --git a/src/net.c b/src/net.c index 71839915..7a2a8e7f 100644 --- 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. - $Id: net.c,v 1.35.4.129 2001/09/01 12:36:06 guus Exp $ + $Id: net.c,v 1.35.4.131 2001/09/24 14:12:00 guus Exp $ */ #include "config.h" @@ -230,6 +230,7 @@ cp */ void send_packet(connection_t *cl, vpn_packet_t *packet) { + connection_t *hop; cp if(debug_lvl >= DEBUG_TRAFFIC) syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"), @@ -254,15 +255,28 @@ cp return; } - /* Check if it has to go via TCP or UDP... */ -cp - if((cl->options | myself->options) & OPTION_TCPONLY) + if(myself->options & OPTION_TCPONLY) { - if(send_tcppacket(cl, packet)) - terminate_connection(cl, 1); + if(send_tcppacket(cl->nexthop, packet)) + terminate_connection(cl->nexthop, 1); } else - send_udppacket(cl, packet); + { + if(myself->options & OPTION_INDIRECT) + send_udppacket(cl->nexthop, packet); + else + { + hop = cl; + + while(hop->options & OPTION_INDIRECT) + if(hop->lastbutonehop == myself) + break; + else + hop = hop->lastbutonehop; + + send_udppacket(hop, packet); + } + } } /* Broadcast a packet to all active direct connections */ @@ -369,18 +383,25 @@ cp 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 + 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 - { - 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 - 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 @@ -422,7 +443,7 @@ cp return -1; } - syslog(LOG_INFO, _("%s is a tun/tap device"), tapfname); + syslog(LOG_INFO, _("%s is a Solaris tun device"), tapfname); #endif cp