no dhcpv4 option set
leasefile string DHCP/v6 lease/hostfile
leasetrigger string Lease trigger script
+loglevel integer 6 Syslog level priority (0-7)
Sections of type dhcp (configure DHCP / DHCPv6 / RA / NDP service)
#include <libgen.h>
#include <string.h>
#include <sys/stat.h>
+#include <syslog.h>
#include <uci.h>
#include <uci_blob.h>
static int reload_pipe[2];
struct list_head leases = LIST_HEAD_INIT(leases);
struct list_head interfaces = LIST_HEAD_INIT(interfaces);
-struct config config = {false, NULL, NULL};
+struct config config = {.legacy = false, .dhcp_cb = NULL,
+ .dhcp_statefile = NULL, .log_level = LOG_INFO};
enum {
IFACE_ATTR_INTERFACE,
ODHCPD_ATTR_MAINDHCP,
ODHCPD_ATTR_LEASEFILE,
ODHCPD_ATTR_LEASETRIGGER,
+ ODHCPD_ATTR_LOGLEVEL,
ODHCPD_ATTR_MAX
};
[ODHCPD_ATTR_MAINDHCP] = { .name = "maindhcp", .type = BLOBMSG_TYPE_BOOL },
[ODHCPD_ATTR_LEASEFILE] = { .name = "leasefile", .type = BLOBMSG_TYPE_STRING },
[ODHCPD_ATTR_LEASETRIGGER] = { .name = "leasetrigger", .type = BLOBMSG_TYPE_STRING },
+ [ODHCPD_ATTR_LOGLEVEL] = { .name = "loglevel", .type = BLOBMSG_TYPE_INT32 },
};
const struct uci_blob_param_list odhcpd_attr_list = {
free(config.dhcp_cb);
config.dhcp_cb = strdup(blobmsg_get_string(c));
}
+
+ if ((c = tb[ODHCPD_ATTR_LOGLEVEL])) {
+ int log_level = (blobmsg_get_u32(c) & LOG_PRIMASK);
+
+ if (config.log_level != log_level) {
+ config.log_level = log_level;
+ setlogmask(LOG_UPTO(config.log_level));
+ }
+ }
}
static double parse_leasetime(struct blob_attr *c) {
#include <unistd.h>
#include <signal.h>
#include <stdbool.h>
+#include <syslog.h>
#include <arpa/inet.h>
#include <net/if.h>
static int ioctl_sock;
static struct nl_sock *rtnl_socket = NULL;
static int urandom_fd = -1;
-static int log_level = LOG_INFO;
static void sighandler(_unused int signal)
{
"== %s Usage ==\n\n"
" -h, --help Print this help\n"
" -l level Specify log level 0..7 (default %d)\n",
- app, log_level
+ app, config.log_level
);
}
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) {