{.ndm_family = AF_INET6, .ndm_flags = (proxy) ? NTF_PROXY : 0}
};
send(rtnl_event.uloop.fd, &req, sizeof(req), MSG_DONTWAIT);
+ odhcpd_process(&rtnl_event);
}
}
// Use rtnetlink to modify kernel routes
-static void setup_route(struct in6_addr *addr, struct interface *iface,
- bool add)
+static void setup_route(struct in6_addr *addr, struct interface *iface, bool add)
{
char namebuf[INET6_ADDRSTRLEN];
inet_ntop(AF_INET6, addr, namebuf, sizeof(namebuf));
- syslog(LOG_NOTICE, "%s about %s on %s", (add) ? "Learned" : "Forgot",
- namebuf, (iface) ? iface->ifname : "<pending>");
+ syslog(LOG_NOTICE, "%s about %s on %s",
+ (add) ? "Learned" : "Forgot", namebuf, iface->ifname);
- if (!iface || !iface->learn_routes)
- return;
-
- odhcpd_setup_route(addr, 128, iface, NULL, add);
+ if (iface->learn_routes)
+ odhcpd_setup_route(addr, 128, iface, NULL, add);
}
if (nh->nlmsg_type == RTM_NEWNEIGH) {
req.ndm.ndm_ifindex = iface->ifindex;
send(rtnl_event.uloop.fd, &req, sizeof(req), MSG_DONTWAIT);
+ setup_route(addr, iface, false);
dump_neigh = true;
}
} else if (add) {
static int urandom_fd = -1;
+static void sighandler(_unused int signal)
+{
+ uloop_end();
+}
+
+
int main()
{
openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
return 4;
signal(SIGUSR1, SIG_IGN);
+ signal(SIGINT, sighandler);
+ signal(SIGTERM, sighandler);
if (init_router())
return 4;
return uloop_fd_add(&event->uloop, ULOOP_READ);
}
+void odhcpd_process(struct odhcpd_event *event)
+{
+ odhcpd_receive_packets(&event->uloop, 0);
+}
+
void odhcpd_urandom(void *data, size_t len)
{
read(urandom_fd, data, len);
// Exported main functions
int odhcpd_open_rtnl(void);
int odhcpd_register(struct odhcpd_event *event);
+void odhcpd_process(struct odhcpd_event *event);
ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest,
struct iovec *iov, size_t iov_len,