--- gvpe/src/vpn.C 2007/12/02 00:54:52 1.42 +++ gvpe/src/vpn.C 2008/08/07 17:54:27 1.47 @@ -1,22 +1,32 @@ /* vpn.C -- handle the protocol, encryption, handshaking etc. - 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" @@ -89,14 +99,16 @@ } } -const char *vpn::script_if_init () +inline const char * +vpn::script_if_init () { script_init_env (); return tap->if_up (); } -const char *vpn::script_if_up () +inline const char * +vpn::script_if_up () { script_init_env (); @@ -331,15 +343,19 @@ fcntl (tap->fd, F_SETFD, FD_CLOEXEC); + run_script_cb cb; + cb.set (this); + if (tap->if_up () && - !run_script (run_script_cb (this, &vpn::script_if_init), true)) + !run_script (cb, true)) { slog (L_ERR, _("interface initialization command '%s' failed, exiting."), tap->if_up ()); exit (EXIT_FAILURE); } - if (!run_script (run_script_cb (this, &vpn::script_if_up), true)) + cb.set (this); + if (!run_script (cb, true)) { slog (L_ERR, _("if-up command execution failed, exiting.")); exit (EXIT_FAILURE); @@ -425,7 +441,7 @@ // we have to connect to all hosts... for (conns_vector::iterator c = conns.begin (); c != conns.end (); ++c) if ((*c)->conf != THISNODE) - (*c)->inject_data_packet (pkt, true); + (*c)->inject_data_packet (pkt); } } @@ -499,7 +515,7 @@ return false; } -void +inline void vpn::ipv4_ev (ev::io &w, int revents) { if (revents & EV_READ) @@ -540,7 +556,7 @@ } #if ENABLE_ICMP -void +inline void vpn::icmpv4_ev (ev::io &w, int revents) { if (revents & EV_READ) @@ -588,7 +604,7 @@ } #endif -void +inline void vpn::udpv4_ev (ev::io &w, int revents) { if (revents & EV_READ) @@ -625,7 +641,7 @@ } } -void +inline void vpn::tap_ev (ev::io &w, int revents) { if (revents & EV_READ) @@ -667,7 +683,7 @@ abort (); } -void +inline void vpn::event_cb (ev::timer &w, int) { if (events) @@ -778,20 +794,20 @@ } vpn::vpn (void) -: event (this, &vpn::event_cb) -, udpv4_ev_watcher (this, &vpn::udpv4_ev) -, ipv4_ev_watcher (this, &vpn::ipv4_ev) +{ + event .set (this); + udpv4_ev_watcher .set (this); + ipv4_ev_watcher .set (this); #if ENABLE_TCP -, tcpv4_ev_watcher (this, &vpn::tcpv4_ev) + tcpv4_ev_watcher .set (this); #endif #if ENABLE_ICMP -, icmpv4_ev_watcher(this, &vpn::icmpv4_ev) + icmpv4_ev_watcher.set (this); #endif #if ENABLE_DNS -, dnsv4_ev_watcher (this, &vpn::dnsv4_ev) + dnsv4_ev_watcher .set (this); #endif -, tap_ev_watcher (this, &vpn::tap_ev) -{ + tap_ev_watcher .set (this); } vpn::~vpn ()