1 /***********************************************************************
7 * Copyright (C) 2002 by Roaring Penguin Software Inc.
9 * This software may be distributed under the terms of the GNU General
10 * Public License, Version 2, or (at your option) any later version.
14 ***********************************************************************/
16 static char const RCSID
[] =
17 "$Id: main.c,v 1.1.48.1 2005/08/08 12:05:25 honor Exp $";
29 usage(int argc
, char *argv
[], int exitcode
)
31 fprintf(stderr
, "\nl2tpd Version %s Copyright 2002 Roaring Penguin Software Inc.\n", VERSION
);
32 fprintf(stderr
, "http://www.roaringpenguin.com/\n\n");
33 fprintf(stderr
, "Usage: %s [options]\n", argv
[0]);
34 fprintf(stderr
, "Options:\n");
35 fprintf(stderr
, "-d level -- Set debugging to 'level'\n");
36 fprintf(stderr
, "-f -- Do not fork\n");
37 fprintf(stderr
, "-h -- Print usage\n");
38 fprintf(stderr
, "\nThis program is licensed under the terms of\nthe GNU General Public License, Version 2.\n");
43 sighandler(int signum
)
50 main(int argc
, char *argv
[])
52 EventSelector
*es
= Event_CreateSelector();
58 while((opt
= getopt(argc
, argv
, "d:fh")) != -1) {
61 usage(argc
, argv
, EXIT_SUCCESS
);
67 sscanf(optarg
, "%d", &debugmask
);
70 usage(argc
, argv
, EXIT_FAILURE
);
74 openlog(argv
[0], LOG_PID
, LOG_DAEMON
);
78 l2tp_debug_set_bitmask(debugmask
);
80 if (l2tp_parse_config_file(es
, "/tmp/l2tp.conf") < 0) { //2005-04-14 by kanki
84 if (!l2tp_network_init(es
)) {
100 signal(SIGHUP
, SIG_IGN
);
111 /* Point stdin/stdout/stderr to /dev/null */
112 for (i
=0; i
<3; i
++) {
115 i
= open("/dev/console", O_RDWR
); //2005-04-14 by kanki for debugging
124 signal(SIGTERM
, sighandler
);
125 signal(SIGINT
, sighandler
);
128 i
= Event_HandleEvent(es
);
130 fprintf(stderr
, "Event_HandleEvent returned %d\n", i
);