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.15 by pcg, Fri Nov 21 05:02:08 2008 UTC vs.
Revision 1.18 by root, Tue Feb 8 23:11:36 2011 UTC

75 75
76/* If zero, don't detach from the terminal. */ 76/* If zero, don't detach from the terminal. */
77static int do_detach = 1; 77static int do_detach = 1;
78 78
79static struct option const long_options[] = 79static struct option const long_options[] =
80 { 80{
81 {"config", required_argument, NULL, 'c'}, 81 {"config", required_argument, NULL, 'c'},
82 {"help", no_argument, &show_help, 1}, 82 {"help", no_argument, &show_help, 1},
83 {"version", no_argument, &show_version, 1}, 83 {"version", no_argument, &show_version, 1},
84 {"no-detach", no_argument, &do_detach, 0}, 84 {"no-detach", no_argument, &do_detach, 0},
85 {"log-level", required_argument, NULL, 'l'}, 85 {"log-level", required_argument, NULL, 'l'},
86 {"mlock", no_argument, &do_mlock, 1}, 86 {"mlock", no_argument, &do_mlock, 1},
87 {NULL, 0, NULL, 0} 87 {NULL, 0, NULL, 0}
88 }; 88};
89 89
90static void 90static void
91usage (int status) 91usage (int status)
92{ 92{
93 if (status != 0) 93 if (status != 0)
97 printf (_("Usage: %s [option]... NODENAME\n\n"), get_identity ()); 97 printf (_("Usage: %s [option]... NODENAME\n\n"), get_identity ());
98 printf (_ 98 printf (_
99 (" -c, --config=DIR Read configuration options from DIR.\n" 99 (" -c, --config=DIR Read configuration options from DIR.\n"
100 " -D, --no-detach Don't fork and detach.\n" 100 " -D, --no-detach Don't fork and detach.\n"
101 " -l, --log-level=LEVEL Set logging level (info, notice, warn are common).\n" 101 " -l, --log-level=LEVEL Set logging level (info, notice, warn are common).\n"
102 " -L, --mlock Lock tinc into main memory.\n" 102 " -L, --mlock Lock gvpe into main memory.\n"
103 " --help Display this help and exit.\n" 103 " --help Display this help and exit.\n"
104 " --version Output version information and exit.\n\n")); 104 " --version Output version information and exit.\n\n"));
105 printf (_("Report bugs to <gvpe@schmorp.de>.\n")); 105 printf (_("Report bugs to <gvpe@schmorp.de>.\n"));
106 } 106 }
107 107
108 exit (status); 108 exit (status);
109} 109}
110 110
111void 111static void
112parse_options (int argc, char **argv, char **envp) 112parse_options (int argc, char **argv, char **envp)
113{ 113{
114 int r; 114 int r;
115 int option_index = 0; 115 int option_index = 0;
116 116
149 break; 149 break;
150 } 150 }
151 } 151 }
152} 152}
153 153
154/*
155 Close network connections, and terminate neatly 154// close network connections, and terminate neatly
156*/ 155static void
157void cleanup_and_exit(int c) 156cleanup_and_exit (int c)
158{ 157{
159 network.shutdown_all (); 158 network.shutdown_all ();
160 159
161 if (conf.pidfilename) 160 if (conf.pidfilename)
162 remove_pid (conf.pidfilename); 161 remove_pid (conf.pidfilename);
164 slog (L_INFO, _("terminating with exit code %d"), c); 163 slog (L_INFO, _("terminating with exit code %d"), c);
165 164
166 exit (c); 165 exit (c);
167} 166}
168 167
169/*
170 Signal handlers. 168// signal handlers
171*/ 169static RETSIGTYPE
172RETSIGTYPE
173sigterm_handler (int a) 170sigterm_handler (int a)
174{ 171{
175 network.events |= vpn::EVENT_SHUTDOWN; 172 network.events |= vpn::EVENT_SHUTDOWN;
176 network.event.start (); 173 network.event.start ();
177} 174}
178 175
179RETSIGTYPE 176static RETSIGTYPE
180sighup_handler (int a) 177sighup_handler (int a)
181{ 178{
182 network.events |= vpn::EVENT_RECONNECT; 179 network.events |= vpn::EVENT_RECONNECT;
183 network.event.start (); 180 network.event.start ();
184} 181}
185 182
186RETSIGTYPE 183static RETSIGTYPE
187sigusr1_handler (int a) 184sigusr1_handler (int a)
188{ 185{
189 network.dump_status (); 186 network.dump_status ();
190} 187}
191 188
192RETSIGTYPE 189static RETSIGTYPE
193sigusr2_handler (int a) 190sigusr2_handler (int a)
194{ 191{
195} 192}
196 193
197void 194static void
198setup_signals (void) 195setup_signals (void)
199{ 196{
200 struct sigaction act; 197 struct sigaction act;
201 198
202 sigfillset (&act.sa_mask); 199 sigfillset (&act.sa_mask);
235 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 232 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
236 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); 233 printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE);
237 printf (_ 234 printf (_
238 ("Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de> and others.\n" 235 ("Copyright (C) 2003-2008 Marc Lehmann <gvpe@schmorp.de> and others.\n"
239 "See the AUTHORS file for a complete list.\n\n" 236 "See the AUTHORS file for a complete list.\n\n"
240 "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" 237 "GVPE comes with ABSOLUTELY NO WARRANTY. This is free software,\n"
241 "and you are welcome to redistribute it under certain conditions;\n" 238 "and you are welcome to redistribute it under certain conditions;\n"
242 "see the file COPYING for details.\n")); 239 "see the file COPYING for details.\n"));
243 240
244 return 0; 241 return 0;
245 } 242 }
293 { 290 {
294 ev_loop (EV_DEFAULT_ 0); 291 ev_loop (EV_DEFAULT_ 0);
295 cleanup_and_exit (EXIT_FAILURE); 292 cleanup_and_exit (EXIT_FAILURE);
296 } 293 }
297 294
298 slog (L_ERR, _("unable to setup network, unrecoverable error, exiting.")); 295 slog (L_ERR, _("unrecoverable error while setting up network, exiting."));
299 cleanup_and_exit (EXIT_FAILURE); 296 cleanup_and_exit (EXIT_FAILURE);
300} 297}
301 298

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines