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.8 by pcg, Mon Sep 1 21:23:35 2003 UTC vs.
Revision 1.13 by pcg, Thu Oct 16 21:57:54 2003 UTC

1/* 1/*
2 vped.C -- the main file for vped 2 vped.C -- the main file for vped
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 Lehmannn <pcg@goof.com> 5 2003 Marc Lehmann <pcg@goof.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 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 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
31#include <sys/types.h> 31#include <sys/types.h>
32#include <unistd.h> 32#include <unistd.h>
33#include <signal.h> 33#include <signal.h>
34#include <termios.h> 34#include <termios.h>
35 35
36#if HAVE_SYS_MMAN_H
36#include <sys/mman.h> 37# include <sys/mman.h>
38#endif
37 39
38#include <openssl/err.h> 40#include <openssl/err.h>
39#include <openssl/rand.h> 41#include <openssl/rand.h>
40 42
41#include "gettext.h" 43#include "gettext.h"
45#include "slog.h" 47#include "slog.h"
46#include "util.h" 48#include "util.h"
47#include "vpn.h" 49#include "vpn.h"
48#include "iom.h" 50#include "iom.h"
49 51
50vpn network;
51
52static loglevel llevel = L_NONE; 52static loglevel llevel = L_NONE;
53 53
54/* If nonzero, display usage information and exit. */ 54/* If nonzero, display usage information and exit. */
55static int show_help; 55static int show_help;
56 56
57/* If nonzero, print the version on standard output and exit. */ 57/* If nonzero, print the version on standard output and exit. */
58static int show_version; 58static int show_version;
59 59
60#if HAVE_MLOCKALL
61/* If nonzero, disable swapping for this process. */ 60/* If nonzero, disable swapping for this process. */
62static int do_mlock = 0; 61static int do_mlock = 0;
63#endif
64 62
65/* If zero, don't detach from the terminal. */ 63/* If zero, don't detach from the terminal. */
66static int do_detach = 1; 64static int do_detach = 1;
67 65
68static struct option const long_options[] = 66static struct option const long_options[] =
70 {"config", required_argument, NULL, 'c'}, 68 {"config", required_argument, NULL, 'c'},
71 {"help", no_argument, &show_help, 1}, 69 {"help", no_argument, &show_help, 1},
72 {"version", no_argument, &show_version, 1}, 70 {"version", no_argument, &show_version, 1},
73 {"no-detach", no_argument, &do_detach, 0}, 71 {"no-detach", no_argument, &do_detach, 0},
74 {"log-level", required_argument, NULL, 'l'}, 72 {"log-level", required_argument, NULL, 'l'},
75#if HAVE_MLOCKALL
76 {"mlock", no_argument, &do_mlock, 1}, 73 {"mlock", no_argument, &do_mlock, 1},
77#endif
78 {NULL, 0, NULL, 0} 74 {NULL, 0, NULL, 0}
79 }; 75 };
80 76
81static void 77static void
82usage (int status) 78usage (int status)
122 118
123 case 'D': /* no detach */ 119 case 'D': /* no detach */
124 do_detach = 0; 120 do_detach = 0;
125 break; 121 break;
126 122
127#if HAVE_MLOCKALL
128 case 'L': /* lock into memory */ 123 case 'L': /* lock into memory */
129 do_mlock = 1; 124 do_mlock = 1;
130 break; 125 break;
131#endif
132 126
133 case 'l': /* inc debug level */ 127 case 'l': /* inc debug level */
134 { 128 {
135 llevel = string_to_loglevel (optarg); 129 llevel = string_to_loglevel (optarg);
136 130
226 220
227 if (show_version) 221 if (show_version)
228 { 222 {
229 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), 223 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (),
230 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 224 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
225 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
231 printf (_ 226 printf (_
232 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n" 227 ("Copyright (C) 2003 Marc Lehmann <vpe@plan9.de> and others.\n"
233 "See the AUTHORS file for a complete list.\n\n" 228 "See the AUTHORS file for a complete list.\n\n"
234 "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 229 "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
235 "and you are welcome to redistribute it under certain conditions;\n" 230 "and you are welcome to redistribute it under certain conditions;\n"
243 238
244 log_to (LOGTO_SYSLOG | LOGTO_STDERR); 239 log_to (LOGTO_SYSLOG | LOGTO_STDERR);
245 240
246 /* Lock all pages into memory if requested */ 241 /* Lock all pages into memory if requested */
247 242
248#if HAVE_MLOCKALL 243#if HAVE_MLOCKALL && HAVE_SYS_MMAN_H && _POSIX_MEMLOCK
249 if (do_mlock) 244 if (do_mlock)
250 if (mlockall (MCL_CURRENT | MCL_FUTURE)) 245 if (mlockall (MCL_CURRENT | MCL_FUTURE))
251 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); 246 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno));
252#endif 247#endif
253 248

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines