int main()
{
openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
+ setlogmask(LOG_UPTO(LOG_INFO));
uloop_init();
if (getuid() != 0) {
if (init_dhcpv4())
return 4;
- if (init_ubus())
- return 4;
-
odhcpd_run();
return 0;
}
int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6])
{
struct ifreq ifr;
+ memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, iface->ifname, sizeof(ifr.ifr_name));
if (ioctl(ioctl_sock, SIOCGIFHWADDR, &ifr) < 0)
return -1;
if (ifa->ifa_flags & IFA_F_DEPRECATED)
addrs[ret].preferred = 0;
+ addrs[ret].has_class = false;
+ addrs[ret].class = 0;
+#ifdef WITH_UBUS
+ struct interface *iface = odhcpd_get_interface_by_index(ifindex);
+ if (iface)
+ addrs[ret].has_class = ubus_get_class(iface->ifname,
+ &addrs[ret].addr, &addrs[ret].class);
+#endif
++ret;
}
int *hlim = NULL;
struct in6_pktinfo *pktinfo;
struct in_pktinfo *pkt4info;
- for (struct cmsghdr *ch = CMSG_FIRSTHDR(&msg); ch != NULL &&
- destiface == 0; ch = CMSG_NXTHDR(&msg, ch)) {
+ for (struct cmsghdr *ch = CMSG_FIRSTHDR(&msg); ch != NULL; ch = CMSG_NXTHDR(&msg, ch)) {
if (ch->cmsg_level == IPPROTO_IPV6 &&
ch->cmsg_type == IPV6_PKTINFO) {
pktinfo = (struct in6_pktinfo*)CMSG_DATA(ch);