RFC 2132 defines:
3.5. Router Option
The router option specifies a list of IP addresses for routers on the
client's subnet. Routers SHOULD be listed in order of preference.
The code for the router option is 3. The minimum length for the
router option is 4 octets, and the length MUST always be a multiple
of 4.
Code Len Address 1 Address 2
+-----+-----+-----+-----+-----+-----+-----+-----+--
| 3 | n | a1 | a2 | a3 | a4 | a1 | a2 | ...
+-----+-----+-----+-----+-----+-----+-----+-----+--
dynamicdhcp bool 1 dynamically create leases
for DHCPv4 and DHCPv6
dynamicdhcp bool 1 dynamically create leases
for DHCPv4 and DHCPv6
+router list <local address> Routers to announce
+ accepts IPv4 only
dns list <local address> DNS servers to announce
accepts IPv4 and IPv6
domain list <local search domain> Search domains to announce
dns list <local address> DNS servers to announce
accepts IPv4 and IPv6
domain list <local search domain> Search domains to announce
IFACE_ATTR_DHCPV4,
IFACE_ATTR_DHCPV6,
IFACE_ATTR_NDP,
IFACE_ATTR_DHCPV4,
IFACE_ATTR_DHCPV6,
IFACE_ATTR_NDP,
IFACE_ATTR_DNS,
IFACE_ATTR_DOMAIN,
IFACE_ATTR_FILTER_CLASS,
IFACE_ATTR_DNS,
IFACE_ATTR_DOMAIN,
IFACE_ATTR_FILTER_CLASS,
[IFACE_ATTR_DHCPV4] = { .name = "dhcpv4", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_DHCPV6] = { .name = "dhcpv6", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_NDP] = { .name = "ndp", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_DHCPV4] = { .name = "dhcpv4", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_DHCPV6] = { .name = "dhcpv6", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_NDP] = { .name = "ndp", .type = BLOBMSG_TYPE_STRING },
+ [IFACE_ATTR_ROUTER] = { .name = "router", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_DOMAIN] = { .name = "domain", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_FILTER_CLASS] = { .name = "filter_class", .type = BLOBMSG_TYPE_STRING },
[IFACE_ATTR_DNS] = { .name = "dns", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_DOMAIN] = { .name = "domain", .type = BLOBMSG_TYPE_ARRAY },
[IFACE_ATTR_FILTER_CLASS] = { .name = "filter_class", .type = BLOBMSG_TYPE_STRING },
free(iface->search);
free(iface->upstream);
free(iface->static_ndp);
free(iface->search);
free(iface->upstream);
free(iface->static_ndp);
+ free(iface->dhcpv4_router);
free(iface->dhcpv4_dns);
free(iface->dhcpv6_raw);
free(iface->filter_class);
free(iface->dhcpv4_dns);
free(iface->dhcpv6_raw);
free(iface->filter_class);
+ if ((c = tb[IFACE_ATTR_ROUTER])) {
+ struct blob_attr *cur;
+ unsigned rem;
+
+ blobmsg_for_each_attr(cur, c, rem) {
+ if (blobmsg_type(cur) != BLOBMSG_TYPE_STRING || !blobmsg_check_attr(cur, NULL))
+ continue;
+
+ struct in_addr addr4;
+ if (inet_pton(AF_INET, blobmsg_get_string(cur), &addr4) == 1) {
+ iface->dhcpv4_router = realloc(iface->dhcpv4_router,
+ (++iface->dhcpv4_router_cnt) * sizeof(*iface->dhcpv4_router));
+ if (!iface->dhcpv4_router)
+ goto err;
+
+ iface->dhcpv4_router[iface->dhcpv4_router_cnt - 1] = addr4;
+ } else {
+ goto err;
+ }
+ }
+ }
+
if ((c = tb[IFACE_ATTR_DNS])) {
struct blob_attr *cur;
unsigned rem;
if ((c = tb[IFACE_ATTR_DNS])) {
struct blob_attr *cur;
unsigned rem;
- dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr);
-
+ if (iface->dhcpv4_router_cnt == 0)
+ dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER, 4, &ifaddr.sin_addr);
+ else
+ dhcpv4_put(&reply, &cookie, DHCPV4_OPT_ROUTER,
+ 4 * iface->dhcpv4_router_cnt, iface->dhcpv4_router);
if (iface->dhcpv4_dns_cnt == 0)
if (iface->dhcpv4_dns_cnt == 0)
// DHCPv4
struct in_addr dhcpv4_start;
struct in_addr dhcpv4_end;
// DHCPv4
struct in_addr dhcpv4_start;
struct in_addr dhcpv4_end;
+ struct in_addr *dhcpv4_router;
+ size_t dhcpv4_router_cnt;
struct in_addr *dhcpv4_dns;
size_t dhcpv4_dns_cnt;
uint32_t dhcpv4_leasetime;
struct in_addr *dhcpv4_dns;
size_t dhcpv4_dns_cnt;
uint32_t dhcpv4_leasetime;