#include <unistd.h>
#include <signal.h>
#include <stdbool.h>
+#include <syslog.h>
#include <arpa/inet.h>
#include <net/if.h>
static struct nl_sock *rtnl_socket = NULL;
static int urandom_fd = -1;
-
static void sighandler(_unused int signal)
{
uloop_end();
"== %s Usage ==\n\n"
" -h, --help Print this help\n"
" -l level Specify log level 0..7 (default %d)\n",
- app, LOG_WARNING
+ app, config.log_level
);
}
{
openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
int opt;
- int log_level = LOG_INFO;
+
while ((opt = getopt(argc, argv, "hl:")) != -1) {
switch (opt) {
case 'h':
print_usage(argv[0]);
return 0;
case 'l':
- log_level = atoi(optarg);
- fprintf(stderr, "Log level set to %d\n", log_level);
+ config.log_level = (atoi(optarg) & LOG_PRIMASK);
+ fprintf(stderr, "Log level set to %d\n", config.log_level);
break;
}
}
- setlogmask(LOG_UPTO(log_level));
+ setlogmask(LOG_UPTO(config.log_level));
uloop_init();
if (getuid() != 0) {
((event->handle_error) ? ULOOP_ERROR_CB : 0));
}
+int odhcpd_deregister(struct odhcpd_event *event)
+{
+ event->uloop.cb = NULL;
+ return uloop_fd_delete(&event->uloop);
+}
+
void odhcpd_process(struct odhcpd_event *event)
{
odhcpd_receive_packets(&event->uloop, 0);