… | |
… | |
21 | |
21 | |
22 | #include "config.h" |
22 | #include "config.h" |
23 | |
23 | |
24 | #include <cstdio> |
24 | #include <cstdio> |
25 | #include <cstring> |
25 | #include <cstring> |
|
|
26 | #include <cstdlib> |
|
|
27 | #include <clocale> |
26 | |
28 | |
27 | #include <errno.h> |
29 | #include <errno.h> |
28 | #include <fcntl.h> |
30 | #include <fcntl.h> |
29 | #include <getopt.h> |
31 | #include <getopt.h> |
30 | #include <signal.h> |
32 | #include <signal.h> |
… | |
… | |
147 | */ |
149 | */ |
148 | void cleanup_and_exit(int c) |
150 | void cleanup_and_exit(int c) |
149 | { |
151 | { |
150 | network.shutdown_all (); |
152 | network.shutdown_all (); |
151 | |
153 | |
152 | if (pidfilename) |
154 | if (conf.pidfilename) |
153 | remove_pid (pidfilename); |
155 | remove_pid (conf.pidfilename); |
154 | |
156 | |
155 | slog (L_INFO, _("terminating with exit code %d"), c); |
157 | slog (L_INFO, _("terminating with exit code %d"), c); |
156 | |
158 | |
157 | exit (c); |
159 | exit (c); |
158 | } |
160 | } |
… | |
… | |
220 | |
222 | |
221 | if (show_version) |
223 | if (show_version) |
222 | { |
224 | { |
223 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
225 | printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), |
224 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
226 | VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); |
|
|
227 | printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); |
225 | printf (_ |
228 | printf (_ |
226 | ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" |
229 | ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" |
227 | "See the AUTHORS file for a complete list.\n\n" |
230 | "See the AUTHORS file for a complete list.\n\n" |
228 | "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" |
231 | "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" |
229 | "and you are welcome to redistribute it under certain conditions;\n" |
232 | "and you are welcome to redistribute it under certain conditions;\n" |
… | |
… | |
252 | |
255 | |
253 | RAND_load_file ("/dev/urandom", 1024); |
256 | RAND_load_file ("/dev/urandom", 1024); |
254 | |
257 | |
255 | if (!THISNODE) |
258 | if (!THISNODE) |
256 | { |
259 | { |
257 | slog (L_ERR, _("current node not set, or node '%s' not found in configfile, use the -n switch when starting vped."), |
260 | slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting vped."), |
258 | thisnode ? thisnode : "<unset>"); |
261 | thisnode ? thisnode : "<unset>"); |
259 | exit (1); |
262 | exit (EXIT_FAILURE); |
260 | } |
263 | } |
261 | |
264 | |
262 | if (detach (do_detach)) |
265 | if (detach (do_detach)) |
263 | exit (0); |
266 | exit (EXIT_SUCCESS); |
264 | |
267 | |
265 | setup_signals (); |
268 | setup_signals (); |
266 | |
269 | |
267 | if (!network.setup ()) |
270 | if (!network.setup ()) |
268 | { |
271 | { |
269 | iom.loop (); |
272 | iom.loop (); |
270 | cleanup_and_exit (1); |
273 | cleanup_and_exit (EXIT_FAILURE); |
271 | } |
274 | } |
272 | |
275 | |
273 | slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); |
276 | slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); |
274 | cleanup_and_exit (1); |
277 | cleanup_and_exit (EXIT_FAILURE); |
275 | } |
278 | } |
276 | |
279 | |