ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/gvpe.C
(Generate patch)

Comparing gvpe/src/gvpe.C (file contents):
Revision 1.9 by pcg, Tue Jun 21 08:50:37 2005 UTC vs.
Revision 1.14 by pcg, Thu Aug 7 19:07:03 2008 UTC

1/* 1/*
2 gvpe.C -- the main file for gvpe 2 gvpe.C -- the main file for gvpe
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003-2005 Marc Lehmann <gvpe@schmorp.de> 5 2003-2008 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
8 8
9 GVPE is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify it
10 it under the terms of the GNU General Public License as published by 10 under the terms of the GNU General Public License as published by the
11 the Free Software Foundation; either version 2 of the License, or 11 Free Software Foundation; either version 3 of the License, or (at your
12 (at your option) any later version. 12 option) any later version.
13 13
14 This program is distributed in the hope that it will be useful, 14 This program is distributed in the hope that it will be useful, but
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 GNU General Public License for more details. 17 Public License for more details.
18 18
19 You should have received a copy of the GNU General Public License 19 You should have received a copy of the GNU General Public License along
20 along with gvpe; if not, write to the Free Software 20 with this program; if not, see <http://www.gnu.org/licenses/>.
21 Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21
22 Additional permission under GNU GPL version 3 section 7
23
24 If you modify this Program, or any covered work, by linking or
25 combining it with the OpenSSL project's OpenSSL library (or a modified
26 version of that library), containing parts covered by the terms of the
27 OpenSSL or SSLeay licenses, the licensors of this Program grant you
28 additional permission to convey the resulting work. Corresponding
29 Source for a non-source form of such a combination shall include the
30 source code for the parts of OpenSSL used as well as that of the
31 covered work.
22*/ 32*/
23 33
24#include "config.h" 34#include "config.h"
25 35
26#include <cstdio> 36#include <cstdio>
48 58
49#include "conf.h" 59#include "conf.h"
50#include "slog.h" 60#include "slog.h"
51#include "util.h" 61#include "util.h"
52#include "vpn.h" 62#include "vpn.h"
53#include "iom.h" 63#include "ev_cpp.h"
54 64
55static loglevel llevel = L_NONE; 65static loglevel llevel = L_NONE;
56 66
57/* If nonzero, display usage information and exit. */ 67/* If nonzero, display usage information and exit. */
58static int show_help; 68static int show_help;
161*/ 171*/
162RETSIGTYPE 172RETSIGTYPE
163sigterm_handler (int a) 173sigterm_handler (int a)
164{ 174{
165 network.events |= vpn::EVENT_SHUTDOWN; 175 network.events |= vpn::EVENT_SHUTDOWN;
166 network.event.start (0); 176 network.event.start ();
167} 177}
168 178
169RETSIGTYPE 179RETSIGTYPE
170sighup_handler (int a) 180sighup_handler (int a)
171{ 181{
172 network.events |= vpn::EVENT_RECONNECT; 182 network.events |= vpn::EVENT_RECONNECT;
173 network.event.start (0); 183 network.event.start ();
174} 184}
175 185
176RETSIGTYPE 186RETSIGTYPE
177sigusr1_handler (int a) 187sigusr1_handler (int a)
178{ 188{
193 act.sa_flags = 0; 203 act.sa_flags = 0;
194 204
195 act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL); 205 act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL);
196 act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL); 206 act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL);
197 act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL); 207 act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL);
198 act.sa_handler = SIG_IGN; sigaction (SIGCHLD, &act, NULL);
199 act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); 208 act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL);
200 act.sa_flags = SA_RESETHAND; 209 act.sa_flags = SA_RESETHAND;
201 act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL); 210 act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL);
202 act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL); 211 act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL);
203} 212}
252 { 261 {
253 thisnode = *argv++; 262 thisnode = *argv++;
254 argc--; 263 argc--;
255 } 264 }
256 265
266 if (!ev_default_loop (0))
267 {
268 slog (L_ERR, _("unable to initialise the event loop (bad $LIBEV_METHODS?)"));
269 exit (EXIT_FAILURE);
270 }
271
257 { 272 {
258 configuration_parser (conf, true, argc, argv); 273 configuration_parser (conf, true, argc, argv);
259 } 274 }
260 275
261 set_loglevel (llevel != L_NONE ? llevel : conf.llevel); 276 set_loglevel (llevel != L_NONE ? llevel : conf.llevel);
274 289
275 setup_signals (); 290 setup_signals ();
276 291
277 if (!network.setup ()) 292 if (!network.setup ())
278 { 293 {
279 io_manager::loop (); 294 ev_loop (EV_DEFAULT_ 0);
280 cleanup_and_exit (EXIT_FAILURE); 295 cleanup_and_exit (EXIT_FAILURE);
281 } 296 }
282 297
283 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); 298 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting."));
284 cleanup_and_exit (EXIT_FAILURE); 299 cleanup_and_exit (EXIT_FAILURE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines