X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fnet.c;h=da39686d4afb475aad67d19c1b3cd6919eb5b99e;hp=dce4ae4fcf27038fbf4bd8af3228faec87d03f08;hb=b6997b0050e78a2f2e517beba3ff01d9232b3d1f;hpb=42455e97a057fb4386f9d8fb2f8963b2ec6ddf24 diff --git a/src/net.c b/src/net.c index dce4ae4f..da39686d 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.20 2000/07/02 13:40:57 guus Exp $ + $Id: net.c,v 1.35.4.22 2000/08/07 16:27:28 guus Exp $ */ #include "config.h" @@ -95,7 +95,6 @@ cp int xsend(conn_list_t *cl, void *packet) { - int r; real_packet_t rp; cp do_encrypt((vpn_packet_t*)packet, &rp, cl->key); @@ -107,16 +106,19 @@ cp syslog(LOG_ERR, _("Sending packet of %d bytes to %s (%s)"), ntohs(rp.len), cl->vpn_hostname, cl->real_hostname); - if((r = send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0) + total_socket_out += ntohs(rp.len); + + cl->want_ping = 1; + + if((cl->flags | myself->flags) & TCPONLY) + return send_tcppacket(cl, (void*)&rp, ntohs(rp.len)); + + if((send(cl->socket, (char*)&rp, ntohs(rp.len), 0)) < 0) { syslog(LOG_ERR, _("Error sending packet to %s (%s): %m"), cl->vpn_hostname, cl->real_hostname); return -1; } - - total_socket_out += r; - - cl->want_ping = 1; cp return 0; } @@ -127,17 +129,18 @@ int xrecv(conn_list_t *cl, void *packet) int lenin; cp do_decrypt((real_packet_t*)packet, &vp, cl->key); +cp add_mac_addresses(&vp); - +cp if(debug_lvl > 3) syslog(LOG_ERR, _("Receiving packet of %d bytes from %s (%s)"), ((real_packet_t*)packet)->len, cl->vpn_hostname, cl->real_hostname); - +cp if((lenin = write(tap_fd, &vp, vp.len + sizeof(vp.len))) < 0) syslog(LOG_ERR, _("Can't write to tap device: %m")); else total_tap_out += lenin; - +cp cl->want_ping = 0; cl->last_ping_time = time(NULL); cp @@ -524,13 +527,13 @@ cp } flags = fcntl(cl->meta_socket, F_GETFL); - if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0) +/* if(fcntl(cl->meta_socket, F_SETFL, flags | O_NONBLOCK) < 0) { syslog(LOG_ERR, _("fcntl for %s port %d: %m"), cl->real_hostname, cl->port); return -1; } - +*/ if(debug_lvl > 0) syslog(LOG_INFO, _("Connected to %s port %hd"), cl->real_hostname, cl->port); @@ -602,10 +605,14 @@ cp else myself->port = cfg->data.val; - if(cfg = get_config_val(indirectdata)) + if((cfg = get_config_val(indirectdata))) if(cfg->data.val == stupid_true) myself->flags |= EXPORTINDIRECTDATA; + if((cfg = get_config_val(tcponly))) + if(cfg->data.val == stupid_true) + myself->flags |= TCPONLY; + if((myself->meta_socket = setup_listen_meta_socket(myself->port)) < 0) { syslog(LOG_ERR, _("Unable to set up a listening socket")); @@ -904,7 +911,7 @@ cp */ void terminate_connection(conn_list_t *cl) { - conn_list_t *p, *q; + conn_list_t *p; cp if(cl->status.remove) @@ -1070,9 +1077,11 @@ cp if(errno==EINTR) return 0; if(errno==0) - if(debug_lvl>0) - syslog(LOG_NOTICE, _("Connection closed by %s (%s)"), - cl->vpn_hostname, cl->real_hostname); + { + if(debug_lvl>0) + syslog(LOG_NOTICE, _("Connection closed by %s (%s)"), + cl->vpn_hostname, cl->real_hostname); + } else syslog(LOG_ERR, _("Metadata socket read error for %s (%s): %m"), cl->vpn_hostname, cl->real_hostname);