static struct odhcpd_event router_event = {{.fd = -1}, handle_icmpv6};
static FILE *fp_route = NULL;
+#define RA_IOV_LEN 6
int init_router(void)
return found_default;
}
+// Unicsat RAs
+static void send_neigh_ra(const struct in6_addr *addr,
+ const struct interface *iface, void *data)
+{
+ struct sockaddr_in6 dest = {
+ .sin6_family = AF_INET6,
+ .sin6_addr = *addr,
+ .sin6_scope_id = iface->ifindex,
+ };
+ odhcpd_send(router_event.uloop.fd, &dest, data, RA_IOV_LEN, iface);
+}
+
// Router Advert server mode
static uint64_t send_router_advert(struct interface *iface, const struct in6_addr *from)
{
- int mtu = odhcpd_get_interface_mtu(iface->ifname);
- if (mtu < 0)
- mtu = 1500;
+ int mtu = odhcpd_get_interface_config(iface->ifname, "mtu");
+ int hlim = odhcpd_get_interface_config(iface->ifname, "hop_limit");
+
+ if (mtu < 1280)
+ mtu = 1280;
struct {
struct nd_router_advert h;
.mtu = {ND_OPT_MTU, 1, 0, htonl(mtu)},
};
+ if (hlim > 0)
+ adv.h.nd_ra_curhoplimit = hlim;
+
if (iface->dhcpv6)
adv.h.nd_ra_flags_reserved = ND_RA_FLAG_OTHER;
.data = {0, 0, maxival >> 24, maxival >> 16, maxival >> 8, maxival}
};
- struct iovec iov[] = {{&adv, (uint8_t*)&adv.prefix[cnt] - (uint8_t*)&adv},
+ struct iovec iov[RA_IOV_LEN] = {
+ {&adv, (uint8_t*)&adv.prefix[cnt] - (uint8_t*)&adv},
{&routes, routes_cnt * sizeof(*routes)},
{&dns, (dns_cnt) ? sizeof(dns) : 0},
{dns_addr, dns_cnt * sizeof(*dns_addr)},
odhcpd_send(router_event.uloop.fd,
&dest, iov, ARRAY_SIZE(iov), iface);
+ odhcpd_iterate_interface_neighbors(iface, send_neigh_ra, iov);
return msecs;
}