#undef LOCAL_DEBUG
-#define _GNU_SOURCE 1
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
#include <stdio.h>
#include <stdlib.h>
#include "lib/resource.h"
#include "lib/socket.h"
#include "lib/event.h"
+#include "lib/timer.h"
#include "lib/string.h"
#include "nest/route.h"
#include "nest/protocol.h"
* Debugging
*/
-#ifdef DEBUGGING
-static int debug_flag = 1;
-#else
-static int debug_flag = 0;
-#endif
-
void
async_dump(void)
{
rdump(&root_pool);
sk_dump_all();
- tm_dump_all();
+ // XXXX tm_dump_all();
if_dump_all();
neigh_dump_all();
rta_dump_all();
#else
static inline void
-drop_uid(uid_t uid)
+drop_uid(uid_t uid UNUSED)
{
die("Cannot change user on this platform");
}
if (*p == '#' || *p == '\n' || *p == 0)
continue;
-
+
if (sscanf(p, "0x%x %s\n", &val, name) != 2 &&
sscanf(p, "0x%x %s #", &val, name) != 2 &&
sscanf(p, "%d %s\n", &val, name) != 2 &&
int
sysdep_commit(struct config *new, struct config *old UNUSED)
{
- log_switch(debug_flag, &new->logfiles, new->syslog_name);
+ log_switch(0, &new->logfiles, new->syslog_name);
return 0;
}
if (!unix_read_config(&conf, config_name))
{
if (conf->err_msg)
- die("%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ die("%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
else
die("Unable to open configuration file %s: %m", config_name);
}
if (!unix_read_config(&conf, config_name))
{
if (conf->err_msg)
- log(L_ERR "%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ log(L_ERR "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
else
log(L_ERR "Unable to open configuration file %s: %m", config_name);
config_free(conf);
if (!unix_read_config(&conf, name))
{
if (conf->err_msg)
- cli_msg(8002, "%s, line %d: %s", conf->err_file_name, conf->err_lino, conf->err_msg);
+ cli_msg(8002, "%s:%d:%d %s", conf->err_file_name, conf->err_lino, conf->err_chno, conf->err_msg);
else
cli_msg(8002, "%s: %m", name);
config_free(conf);
}
void
-cmd_reconfig(char *name, int type, int timeout)
+cmd_reconfig(char *name, int type, uint timeout)
{
if (cli_access_restricted())
return;
}
static int
-cli_rx(sock *s, int size UNUSED)
+cli_rx(sock *s, uint size UNUSED)
{
cli_kick(s->data);
return 0;
}
static int
-cli_connect(sock *s, int size UNUSED)
+cli_connect(sock *s, uint size UNUSED)
{
cli *c;
rv = ftruncate(pid_fd, 0);
if (rv < 0)
die("fruncate: %m");
-
+
rv = write(pid_fd, ps, pl);
if(rv < 0)
die("write: %m");
* Parsing of command-line arguments
*/
-static char *opt_list = "c:dD:ps:P:u:g:flR";
+static char *opt_list = "bc:dD:ps:P:u:g:flRh";
static int parse_and_exit;
char *bird_name;
static char *use_user;
static int run_in_foreground = 0;
static void
-usage(void)
+display_usage(void)
+{
+ fprintf(stderr, "Usage: %s [--version] [--help] [-c <config-file>] [OPTIONS]\n", bird_name);
+}
+
+static void
+display_help(void)
+{
+ display_usage();
+
+ fprintf(stderr,
+ "\n"
+ "Options: \n"
+ " -c <config-file> Use given configuration file instead of\n"
+ " " PATH_CONFIG_FILE "\n"
+ " -d Enable debug messages and run bird in foreground\n"
+ " -D <debug-file> Log debug messages to given file instead of stderr\n"
+ " -f Run bird in foreground\n"
+ " -g <group> Use given group ID\n"
+ " -h, --help Display this information\n"
+ " -l Look for a configuration file and a control socket\n"
+ " in the current working directory\n"
+ " -p Test configuration file and exit without start\n"
+ " -P <pid-file> Create a PID file with given filename\n"
+ " -R Apply graceful restart recovery after start\n"
+ " -s <control-socket> Use given filename for a control socket\n"
+ " -u <user> Drop privileges and use given user ID\n"
+ " --version Display version of BIRD\n");
+
+ exit(0);
+}
+
+static void
+display_version(void)
{
- fprintf(stderr, "Usage: %s [-c <config-file>] [-d] [-D <debug-file>] [-p] [-s <control-socket>] [-P <pid-file>] [-u <user>] [-g <group>] [-f] [-l] [-R]\n", bird_name);
- exit(1);
+ fprintf(stderr, "BIRD version " BIRD_VERSION "\n");
+ exit(0);
}
static inline char *
if (argc == 2)
{
if (!strcmp(argv[1], "--version"))
- {
- fprintf(stderr, "BIRD version " BIRD_VERSION "\n");
- exit(0);
- }
+ display_version();
if (!strcmp(argv[1], "--help"))
- usage();
+ display_help();
}
while ((c = getopt(argc, argv, opt_list)) >= 0)
switch (c)
config_changed = 1;
break;
case 'd':
- debug_flag |= 1;
+ log_init_debug("");
+ run_in_foreground = 1;
break;
case 'D':
log_init_debug(optarg);
- debug_flag |= 2;
break;
case 'p':
parse_and_exit = 1;
case 'R':
graceful_restart_recovery();
break;
+ case 'h':
+ display_help();
+ break;
default:
- usage();
+ fputc('\n', stderr);
+ display_usage();
+ exit(1);
}
if (optind < argc)
- usage();
+ {
+ display_usage();
+ exit(1);
+ }
}
/*
#endif
parse_args(argc, argv);
- if (debug_flag == 1)
- log_init_debug("");
- log_switch(debug_flag, NULL, NULL);
+ log_switch(1, NULL, NULL);
+ net_init();
resource_init();
+ timer_init();
olock_init();
io_init();
rt_init();
if (parse_and_exit)
exit(0);
- if (!(debug_flag||run_in_foreground))
+ if (!run_in_foreground)
{
pid_t pid = fork();
if (pid < 0)