#include <syslog.h>
#include <libubox/blobmsg.h>
-
-#ifndef typeof
-#define typeof __typeof
-#endif
-
-#ifndef container_of
-#define container_of(ptr, type, member) ( \
- (type *)( (char *)ptr - offsetof(type,member) ))
-#endif
-
#include <libubox/list.h>
#include <libubox/uloop.h>
-#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-
// RFC 6106 defines this router advertisement option
#define ND_OPT_ROUTE_INFO 24
#define ND_OPT_RECURSIVE_DNS 25
#define _unused __attribute__((unused))
#define _packed __attribute__((packed))
-
-#define ALL_IPV6_NODES {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}}}
-
-#define ALL_IPV6_ROUTERS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02}}}
+#define ALL_IPV6_NODES "ff02::1"
+#define ALL_IPV6_ROUTERS "ff02::2"
#define IN6_IS_ADDR_ULA(a) (((a)->s6_addr32[0] & htonl(0xfe000000)) == htonl(0xfc000000))
enum odhcpd_assignment_flags {
- OAF_BOUND = (1 << 0),
- OAF_STATIC = (1 << 1),
+ OAF_TENTATIVE = (1 << 0),
+ OAF_BOUND = (1 << 1),
+ OAF_STATIC = (1 << 2),
+ OAF_BROKEN_HOSTNAME = (1 << 3),
};
struct config {
bool ra_not_onlink;
bool ra_advrouter;
bool ra_useleasetime;
+ bool ra_dns;
bool no_dynamic_dhcp;
+ uint8_t pio_filter_length;
+ struct in6_addr pio_filter_addr;
// RA
int learn_routes;
void *dhcpv6_raw;
size_t dhcpv6_raw_len;
bool dhcpv6_assignall;
+ bool dhcpv6_pd;
+ bool dhcpv6_na;
char *upstream;
size_t upstream_len;
time_t odhcpd_time(void);
ssize_t odhcpd_unhexlify(uint8_t *dst, size_t len, const char *src);
void odhcpd_hexlify(char *dst, const uint8_t *src, size_t len);
+const char *odhcpd_print_mac(const uint8_t *mac, const size_t len);
int odhcpd_bmemcmp(const void *av, const void *bv, size_t bits);
void odhcpd_bmemcpy(void *av, const void *bv, size_t bits);
int odhcpd_netmask2bitlen(bool v6, void *mask);
bool odhcpd_bitlen2netmask(bool v6, unsigned int bits, void *mask);
+bool odhcpd_valid_hostname(const char *name);
int config_parse_interface(void *data, size_t len, const char *iname, bool overwrite);
const char* ubus_get_ifname(const char *name);
void ubus_apply_network(void);
bool ubus_has_prefix(const char *name, const char *ifname);
+void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac, const size_t mac_len,
+ const struct in_addr *addr, const char *name, const char *interface);
#endif
int netlink_add_netevent_handler(struct netevent_handler *hdlr);
int netlink_init(void);
int router_init(void);
int dhcpv6_init(void);
-int dhcpv4_init(void);
int ndp_init(void);
+#ifdef DHCPV4_SUPPORT
+int dhcpv4_init(void);
+int dhcpv4_setup_interface(struct interface *iface, bool enable);
+#endif
int router_setup_interface(struct interface *iface, bool enable);
int dhcpv6_setup_interface(struct interface *iface, bool enable);
int ndp_setup_interface(struct interface *iface, bool enable);
-int dhcpv4_setup_interface(struct interface *iface, bool enable);
void odhcpd_reload(void);