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

Comparing gvpe/src/vped.C (file contents):
Revision 1.12 by pcg, Thu Oct 16 14:12:00 2003 UTC vs.
Revision 1.22 by pcg, Thu Mar 3 16:54:34 2005 UTC

1/* 1/*
2 vped.C -- the main file for vped 2 vped.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 Marc Lehmann <pcg@goof.com> 5 2003-2005 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE.
8
7 This program is free software; you can redistribute it and/or modify 9 GVPE is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 11 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 12 (at your option) any later version.
11 13
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 17 GNU General Public License for more details.
16 18
17 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
18 along with this program; if not, write to the Free Software 20 along with gvpe; if not, write to the Free Software
19 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20*/ 22*/
21 23
22#include "config.h" 24#include "config.h"
23 25
24#include <cstdio> 26#include <cstdio>
25#include <cstring> 27#include <cstring>
28#include <cstdlib>
29#include <locale.h>
26 30
27#include <errno.h> 31#include <errno.h>
28#include <fcntl.h> 32#include <fcntl.h>
29#include <getopt.h> 33#include <getopt.h>
30#include <signal.h> 34#include <signal.h>
147*/ 151*/
148void cleanup_and_exit(int c) 152void cleanup_and_exit(int c)
149{ 153{
150 network.shutdown_all (); 154 network.shutdown_all ();
151 155
152 if (pidfilename) 156 if (conf.pidfilename)
153 remove_pid (pidfilename); 157 remove_pid (conf.pidfilename);
154 158
155 slog (L_INFO, _("terminating with exit code %d"), c); 159 slog (L_INFO, _("terminating with exit code %d"), c);
156 160
157 exit (c); 161 exit (c);
158} 162}
220 224
221 if (show_version) 225 if (show_version)
222 { 226 {
223 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), 227 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (),
224 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 228 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
229 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
225 printf (_ 230 printf (_
226 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" 231 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n"
227 "See the AUTHORS file for a complete list.\n\n" 232 "See the AUTHORS file for a complete list.\n\n"
228 "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 233 "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
229 "and you are welcome to redistribute it under certain conditions;\n" 234 "and you are welcome to redistribute it under certain conditions;\n"
243 if (do_mlock) 248 if (do_mlock)
244 if (mlockall (MCL_CURRENT | MCL_FUTURE)) 249 if (mlockall (MCL_CURRENT | MCL_FUTURE))
245 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); 250 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno));
246#endif 251#endif
247 252
248 make_names ();
249 conf.read_config (true); 253 conf.read_config (true);
250 254
251 set_loglevel (llevel != L_NONE ? llevel : conf.llevel); 255 set_loglevel (llevel != L_NONE ? llevel : conf.llevel);
252 256
253 RAND_load_file ("/dev/urandom", 1024); 257 RAND_load_file ("/dev/urandom", 1024);
254 258
255 if (!THISNODE) 259 if (!THISNODE)
256 { 260 {
257 slog (L_ERR, _("current node not set, or node '%s' not found in configfile, use the -n switch when starting vped."), 261 slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting vped."),
258 thisnode ? thisnode : "<unset>"); 262 thisnode ? thisnode : "<unset>");
259 exit (1); 263 exit (EXIT_FAILURE);
260 } 264 }
261 265
262 if (detach (do_detach)) 266 if (detach (do_detach))
263 exit (0); 267 exit (EXIT_SUCCESS);
264 268
265 setup_signals (); 269 setup_signals ();
266 270
267 if (!network.setup ()) 271 if (!network.setup ())
268 { 272 {
269 iom.loop (); 273 io_manager::loop ();
270 cleanup_and_exit (1); 274 cleanup_and_exit (EXIT_FAILURE);
271 } 275 }
272 276
273 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); 277 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting."));
274 cleanup_and_exit (1); 278 cleanup_and_exit (EXIT_FAILURE);
275} 279}
276 280

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines