- list_for_each_entry_safe(i, n, &interfaces, head) {
- if (i->inuse) {
- // Resolve hybrid mode
- if (i->dhcpv6 == RELAYD_HYBRID)
- i->dhcpv6 = (master && master->dhcpv6 == RELAYD_RELAY) ?
- RELAYD_RELAY : RELAYD_SERVER;
-
- if (i->ra == RELAYD_HYBRID)
- i->ra = (master && master->ra == RELAYD_RELAY) ?
- RELAYD_RELAY : RELAYD_SERVER;
-
- if (i->ndp == RELAYD_HYBRID)
- i->ndp = (master && master->ndp == RELAYD_RELAY) ?
- RELAYD_RELAY : RELAYD_SERVER;
-
- setup_router_interface(i, true);
- setup_dhcpv6_interface(i, true);
- setup_ndp_interface(i, true);
- setup_dhcpv4_interface(i, true);
- i->inuse = false;
- } else {
- close_interface(i);
- }
- }
+ if (signal == SIGHUP) {
+ if (write(reload_pipe[1], b, sizeof(b)) < 0) {}
+ } else
+ uloop_end();
+}
+
+static void reload_cb(struct uloop_fd *u, _unused unsigned int events)
+{
+ char b[512];
+ if (read(u->fd, b, sizeof(b)) < 0) {}
+
+ odhcpd_reload();
+}
+
+static struct uloop_fd reload_fd = { .cb = reload_cb };
+
+void odhcpd_run(void)
+{
+ if (pipe2(reload_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {}
+
+ reload_fd.fd = reload_pipe[0];
+ uloop_fd_add(&reload_fd, ULOOP_READ);
+
+ signal(SIGTERM, handle_signal);
+ signal(SIGINT, handle_signal);
+ signal(SIGHUP, handle_signal);
+
+#ifdef WITH_UBUS
+ while (init_ubus())
+ sleep(1);
+#endif