add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra -DWITH_UBUS)
+if(${EXT_PREFIX_CLASS})
+ add_definitions(-DEXT_PREFIX_CLASS=${EXT_PREFIX_CLASS})
+endif(${EXT_PREFIX_CLASS})
+
+
add_executable(odhcpd src/odhcpd.c src/config.c src/router.c src/dhcpv6.c src/ndp.c src/md5.c src/dhcpv6-ia.c src/dhcpv4.c src/ubus.c)
target_link_libraries(odhcpd resolv ubus ubox uci)
a->assigned = reqhint;
a->all_class = class_oro;
a->classes_cnt = classes_cnt;
- a->classes = malloc(classes_cnt * sizeof(uint16_t));
- memcpy(a->classes, classes, classes_cnt * sizeof(uint16_t));
+ if (classes_cnt) {
+ a->classes = malloc(classes_cnt * sizeof(uint16_t));
+ memcpy(a->classes, classes, classes_cnt * sizeof(uint16_t));
+ }
if (first)
memcpy(a->key, first->key, sizeof(a->key));
addrs[ret].class = 0;
#ifdef WITH_UBUS
struct interface *iface = odhcpd_get_interface_by_index(ifindex);
- if (iface) {
- addrs[ret].has_class = true;
- addrs[ret].class = ubus_get_class(iface->ifname, &addrs[ret].addr);
- }
+ if (iface)
+ addrs[ret].has_class = ubus_get_class(iface->ifname,
+ &addrs[ret].addr, &addrs[ret].class);
#endif
++ret;
}
const char* ubus_get_ifname(const char *name);
void ubus_apply_network(void);
bool ubus_has_prefix(const char *name, const char *ifname);
-uint16_t ubus_get_class(const char *ifname, const struct in6_addr *addr);
+bool ubus_get_class(const char *ifname, const struct in6_addr *addr, uint16_t *pclass);
#endif
[ADDR_ATTR_CLASS] = { .name = "class", .type = BLOBMSG_TYPE_STRING },
};
-uint16_t ubus_get_class(const char *ifname, const struct in6_addr *addr)
+bool ubus_get_class(const char *ifname, const struct in6_addr *addr, uint16_t *pclass)
{
struct blob_attr *c, *cur;
unsigned rem;
if (!dump)
- return 0;
+ return false;
blobmsg_for_each_attr(c, dump, rem) {
struct blob_attr *tb[IFACE_ATTR_MAX];
struct in6_addr ip6addr;
inet_pton(AF_INET6, addrs, &ip6addr);
- if (IN6_ARE_ADDR_EQUAL(&ip6addr, addr))
- return atoi(class);
+ if (IN6_ARE_ADDR_EQUAL(&ip6addr, addr)) {
+ *pclass = atoi(class);
+ return true;
+ }
}
}
- return 0;
+ return false;
}
- return 0;
+ return false;
}