#include "odhcpd.h"
static struct blob_buf b;
-static int reload_pipe[2];
+static int reload_pipe[2] = { -1, -1 };
static int lease_cmp(const void *k1, const void *k2, void *ptr);
static void lease_update(struct vlist_tree *tree, struct vlist_node *node_new,
AVL_TREE(interfaces, avl_strcmp, false, NULL);
struct config config = {.legacy = false, .main_dhcpv4 = false,
.dhcp_cb = NULL, .dhcp_statefile = NULL,
- .log_level = LOG_INFO};
+ .log_level = LOG_WARNING};
+
+#define START_DEFAULT 100
+#define LIMIT_DEFAULT 150
enum {
IFACE_ATTR_INTERFACE,
{
iface->learn_routes = 1;
iface->dhcpv4_leasetime = 43200;
+ iface->dhcpv4_start.s_addr = htonl(START_DEFAULT);
+ iface->dhcpv4_end.s_addr = htonl(START_DEFAULT + LIMIT_DEFAULT - 1);
iface->dhcpv6_assignall = true;
iface->dhcpv6_pd = true;
iface->dhcpv6_na = true;
iface->name = strcpy(new_name, name);
iface->avl.key = iface->name;
+ iface->router_event.uloop.fd = -1;
+ iface->dhcpv6_event.uloop.fd = -1;
+ iface->ndp_event.uloop.fd = -1;
+ iface->ndp_ping_fd = -1;
+ iface->dhcpv4_event.uloop.fd = -1;
+ INIT_LIST_HEAD(&iface->ia_assignments);
+ INIT_LIST_HEAD(&iface->dhcpv4_assignments);
+ INIT_LIST_HEAD(&iface->dhcpv4_fr_ips);
+
set_interface_defaults(iface);
avl_insert(&interfaces, &iface->avl);
if ((c = tb[IFACE_ATTR_START])) {
iface->dhcpv4_start.s_addr = htonl(blobmsg_get_u32(c));
+ iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) +
+ LIMIT_DEFAULT - 1);
if (config.main_dhcpv4 && config.legacy)
iface->dhcpv4 = MODE_SERVER;
}
if ((c = tb[IFACE_ATTR_LIMIT]))
- iface->dhcpv4_end.s_addr = htonl(
- ntohl(iface->dhcpv4_start.s_addr) + blobmsg_get_u32(c));
+ iface->dhcpv4_end.s_addr = htonl(ntohl(iface->dhcpv4_start.s_addr) +
+ blobmsg_get_u32(c) - 1);
if ((c = tb[IFACE_ATTR_MASTER]))
iface->master = blobmsg_get_bool(c);
list_for_each_entry_safe(a, tmp, &l->assignments, lease_list) {
if (a->flags & flag)
-#ifdef DHCPV4_SUPPORT
- v6 ? dhcpv6_ia_free_assignment(a) : dhcpv4_free_assignment(a);
-#else
- dhcpv6_ia_free_assignment(a);
-#endif
+ free_assignment(a);
}
}
{
struct dhcp_assignment *a;
- list_for_each_entry(a, &l->assignments, lease_list) {
- if (a->flags & OAF_DHCPV6)
- dhcpv6_ia_free_assignment(a);
-#ifdef DHCPV4_SUPPORT
- else if (a->flags & OAF_DHCPV4)
- dhcpv4_free_assignment(a);
-#endif
- }
+ list_for_each_entry(a, &l->assignments, lease_list)
+ free_assignment(a);
free_lease(l);
}
odhcpd_reload();
}
-static struct uloop_fd reload_fd = { .cb = reload_cb };
+static struct uloop_fd reload_fd = { .fd = -1, .cb = reload_cb };
void odhcpd_run(void)
{