--- gvpe/src/vpn_tcp.C 2007/12/02 00:45:42 1.22 +++ gvpe/src/vpn_tcp.C 2011/02/08 23:11:36 1.27 @@ -1,22 +1,32 @@ /* vpn_tcp.C -- handle the tcp part of the protocol. - Copyright (C) 2003-2007 Marc Lehmann + Copyright (C) 2003-2008 Marc Lehmann This file is part of GVPE. - GVPE is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with gvpe; if not, write to the Free Software - Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + GVPE is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 3 of the License, or (at your + option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, see . + + Additional permission under GNU GPL version 3 section 7 + + If you modify this Program, or any covered work, by linking or + combining it with the OpenSSL project's OpenSSL library (or a modified + version of that library), containing parts covered by the terms of the + OpenSSL or SSLeay licenses, the licensors of this Program grant you + additional permission to convey the resulting work. Corresponding + Source for a non-source form of such a combination shall include the + source code for the parts of OpenSSL used as well as that of the + covered work. */ #include "config.h" @@ -61,15 +71,17 @@ struct tcp_si_map : public map { - void cleaner_cb (ev::timer &w, int revents); ev::timer cleaner; + inline void cleaner_cb (ev::timer &w, int revents); ev::timer cleaner; tcp_si_map () - : cleaner(this, &tcp_si_map::cleaner_cb) { + ev_default_loop (0); + cleaner.set (this); cleaner.start (::conf.keepalive / 2, ::conf.keepalive / 2); } +}; -} tcp_si; +static tcp_si_map tcp_si; struct tcp_connection : ev::io { @@ -91,7 +103,7 @@ int proxy_req_len; #endif - void tcpv4_ev (ev::io &w, int revents); + inline void tcpv4_ev (ev::io &w, int revents); bool send_packet (vpn_packet *pkt, int tos); bool write_packet (); @@ -107,7 +119,8 @@ ~tcp_connection (); }; -void tcp_si_map::cleaner_cb (ev::timer &w, int revents) +void +tcp_si_map::cleaner_cb (ev::timer &w, int revents) { tstamp to = ev_now () - ::conf.keepalive - 30 - 60; @@ -440,7 +453,8 @@ return state != ERROR; } -void tcp_connection::error () +void +tcp_connection::error () { stop (); @@ -461,8 +475,10 @@ } tcp_connection::tcp_connection (int fd_, const sockinfo &si_, vpn &v_) -: v(v_), si(si_), ev::io(this, &tcp_connection::tcpv4_ev) +: v(v_), si(si_) { + set (this); + last_activity = ev_now (); r_pkt = 0; w_pkt = 0;