Disable debugging by default
[project/odhcpd.git] / src / odhcpd.c
index acedaec..39ce98e 100644 (file)
@@ -52,6 +52,7 @@ static int urandom_fd = -1;
 int main()
 {
        openlog("odhcpd", LOG_PERROR | LOG_PID, LOG_DAEMON);
+       setlogmask(LOG_UPTO(LOG_INFO));
        uloop_init();
 
        if (getuid() != 0) {
@@ -83,9 +84,6 @@ int main()
        if (init_dhcpv4())
                return 4;
 
-       if (init_ubus())
-               return 4;
-
        odhcpd_run();
        return 0;
 }
@@ -243,6 +241,14 @@ ssize_t odhcpd_get_interface_addresses(int ifindex,
                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;
        }
 
@@ -315,8 +321,7 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even
                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);